Skip to content

Commit

Permalink
Added text for SET CONSOLE and minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
breakintoprogram committed Nov 11, 2023
1 parent cd43ea1 commit b2f2292
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 90 deletions.
56 changes: 29 additions & 27 deletions src/mos.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Title: AGON MOS - MOS code
* Author: Dean Belfield
* Created: 10/07/2022
* Last Updated: 10/11/2023
* Last Updated: 11/11/2023
*
* Modinfo:
* 11/07/2022: Added mos_cmdDIR, mos_cmdLOAD, removed mos_cmdBYE
Expand All @@ -29,12 +29,12 @@
* 26/03/2023: Fixed SET KEYBOARD command
* 14/04/2023: Added fat_EOF
* 15/04/2023: Added mos_GETFIL, mos_FREAD, mos_FWRITE, mos_FLSEEK, refactored MOS file commands
* 23/04/2023: Added mos_cmdHELP, mos_cmdTYPE, mos_cmdCLS, mos_cmdMOUNT, mos_mount
* 30/05/2023: Fixed bug in mos_parseNumber to detect invalid numeric characters, mos_FGETC now returns EOF flag
* 08/07/2023: Added mos_trim function; mos_exec now trims whitespace from input string, various bug fixes
* 15/09/2023: Function mos_trim now includes the asterisk character as whitespace
* 26/09/2023: Refactored mos_GETRTC and mos_SETRTC
* 10/11/2023: Added CONSOLE to mos_cmdSET
* 11/11/2023: Added mos_cmdHELP, mos_cmdTYPE, mos_cmdCLS, mos_cmdMOUNT, mos_mount
*/

#include <eZ80.h>
Expand Down Expand Up @@ -63,7 +63,7 @@ extern volatile BYTE vpd_protocol_flags; // In globals.asm
extern BYTE rtc; // In globals.asm

static FATFS fs; // Handle for the file system
static char * mos_strtok_ptr; // Pointer for current position in string tokeniser
static char * mos_strtok_ptr; // Pointer for current position in string tokeniser

extern volatile BYTE history_no;

Expand All @@ -72,28 +72,28 @@ t_mosFileObject mosFileObjects[MOS_maxOpenFiles];
// Array of MOS commands and pointer to the C function to run
//
static t_mosCommand mosCommands[] = {
{ ".", &mos_cmdDIR, HELP_CAT_ARGS, HELP_CAT, HELP_DOT_ALIASES },
{ "DIR", &mos_cmdDIR, HELP_CAT_ARGS, HELP_CAT, HELP_DIR_ALIASES },
{ "CAT", &mos_cmdDIR, HELP_CAT_ARGS, HELP_CAT, HELP_CAT_ALIASES },
{ "LOAD", &mos_cmdLOAD, HELP_LOAD_ARGS, HELP_LOAD, NULL },
{ "SAVE", &mos_cmdSAVE, HELP_SAVE_ARGS, HELP_SAVE, NULL },
{ ".", &mos_cmdDIR, HELP_CAT_ARGS, HELP_CAT, HELP_DOT_ALIASES },
{ "DIR", &mos_cmdDIR, HELP_CAT_ARGS, HELP_CAT, HELP_DIR_ALIASES },
{ "CAT", &mos_cmdDIR, HELP_CAT_ARGS, HELP_CAT, HELP_CAT_ALIASES },
{ "LOAD", &mos_cmdLOAD, HELP_LOAD_ARGS, HELP_LOAD, NULL },
{ "SAVE", &mos_cmdSAVE, HELP_SAVE_ARGS, HELP_SAVE, NULL },
{ "DELETE", &mos_cmdDEL, HELP_DELETE_ARGS, HELP_DELETE, HELP_DELETE_ALIASES },
{ "ERASE", &mos_cmdDEL, HELP_DELETE_ARGS, HELP_DELETE, HELP_ERASE_ALIASES },
{ "JMP", &mos_cmdJMP, HELP_JMP_ARGS, HELP_JMP, NULL },
{ "RUN", &mos_cmdRUN, HELP_RUN_ARGS, HELP_RUN, NULL },
{ "CD", &mos_cmdCD, HELP_CD_ARGS, HELP_CD, NULL },
{ "JMP", &mos_cmdJMP, HELP_JMP_ARGS, HELP_JMP, NULL },
{ "RUN", &mos_cmdRUN, HELP_RUN_ARGS, HELP_RUN, NULL },
{ "CD", &mos_cmdCD, HELP_CD_ARGS, HELP_CD, NULL },
{ "RENAME", &mos_cmdREN, HELP_RENAME_ARGS, HELP_RENAME, HELP_RENAME_ALIASES },
{ "MOVE", &mos_cmdREN, HELP_RENAME_ARGS, HELP_RENAME, HELP_MOVE_ALIASES },
{ "MKDIR", &mos_cmdMKDIR, HELP_MKDIR_ARGS, HELP_MKDIR, NULL },
{ "COPY", &mos_cmdCOPY, HELP_COPY_ARGS, HELP_COPY, NULL },
{ "SET", &mos_cmdSET, HELP_SET_ARGS, HELP_SET, NULL },
{ "VDU", &mos_cmdVDU, HELP_VDU_ARGS, HELP_VDU, NULL },
{ "TIME", &mos_cmdTIME, HELP_TIME_ARGS, HELP_TIME, NULL },
{ "CREDITS", &mos_cmdCREDITS, NULL, HELP_CREDITS, NULL },
{ "TYPE", &mos_cmdTYPE, HELP_TYPE_ARGS, HELP_TYPE, NULL },
{ "CLS", &mos_cmdCLS, NULL, HELP_CLS, NULL },
{ "MOUNT", &mos_cmdMOUNT, NULL, HELP_MOUNT, NULL },
{ "HELP", &mos_cmdHELP, HELP_HELP_ARGS, HELP_HELP, NULL },
{ "MKDIR", &mos_cmdMKDIR, HELP_MKDIR_ARGS, HELP_MKDIR, NULL },
{ "COPY", &mos_cmdCOPY, HELP_COPY_ARGS, HELP_COPY, NULL },
{ "SET", &mos_cmdSET, HELP_SET_ARGS, HELP_SET, NULL },
{ "VDU", &mos_cmdVDU, HELP_VDU_ARGS, HELP_VDU, NULL },
{ "TIME", &mos_cmdTIME, HELP_TIME_ARGS, HELP_TIME, NULL },
{ "CREDITS", &mos_cmdCREDITS, NULL, HELP_CREDITS, NULL },
{ "TYPE", &mos_cmdTYPE, HELP_TYPE_ARGS, HELP_TYPE, NULL },
{ "CLS", &mos_cmdCLS, NULL, HELP_CLS, NULL },
{ "MOUNT", &mos_cmdMOUNT, NULL, HELP_MOUNT, NULL },
{ "HELP", &mos_cmdHELP, HELP_HELP_ARGS, HELP_HELP, NULL },
};

#define mosCommands_count (sizeof(mosCommands)/sizeof(t_mosCommand))
Expand Down Expand Up @@ -125,12 +125,16 @@ static char * mos_errors[] = {
"Invalid executable",
};

#define mos_errors_count (sizeof(mos_errors)/sizeof(char *))

// Output a file error
// Parameters:
// - error: The FatFS error number
//
void mos_error(int error) {
printf("\n\r%s\n\r", mos_errors[error]);
if(error >= 0 && error < mos_errors_count) {
printf("\n\r%s\n\r", mos_errors[error]);
}
}

// Wait for a keycode character from the VPD
Expand Down Expand Up @@ -759,8 +763,8 @@ void printCommandInfo(t_mosCommand * cmd) {
// Parameters:
// - ptr: Pointer to the argument string in the line edit buffer
// Returns:
// - 0: success
// -1: command not found
// - 0: Success
// 20: Failure
//
int mos_cmdHELP(char *ptr) {
int i;
Expand All @@ -782,10 +786,8 @@ int mos_cmdHELP(char *ptr) {
}

if (cmd != NULL && !found) {
printf("Error: '%s' not found\r\n", cmd);
return -1;
return 20;
}

return 0;
}

Expand Down
130 changes: 67 additions & 63 deletions src/mos.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Title: AGON MOS - MOS code
* Author: Dean Belfield
* Created: 10/07/2022
* Last Updated: 08/07/2023
* Last Updated: 11/11/2023
*
* Modinfo:
* 11/07/2022: Removed mos_cmdBYE, Added mos_cmdLOAD
Expand All @@ -26,9 +26,9 @@
* 21/03/2023: Added mos_SETINTVECTOR
* 14/04/2023: Added fat_EOF
* 15/04/2023: Added mos_GETFIL, mos_FREAD, mos_FWRITE, mos_FLSEEK
* 24/05/2023: Added mos_cmdHELP, mos_cmdTYPE, mos_cmdCLS, mos_cmdMOUNT
* 30/05/2023: Function mos_FGETC now returns EOF flag
* 08/07/2023 Added mos_trim function
* 11/11/2023: Added mos_cmdHELP, mos_cmdTYPE, mos_cmdCLS, mos_cmdMOUNT
*/

#ifndef MOS_H
Expand Down Expand Up @@ -61,7 +61,7 @@ char * mos_strtok_r(char *s1, const char *s2, char **ptr);
int mos_exec(char * buffer);
UINT8 mos_execMode(UINT8 * ptr);

int mos_mount(void);
int mos_mount(void);

BOOL mos_parseNumber(char * ptr, UINT24 * p_Value);
BOOL mos_parseString(char * ptr, char ** p_Value);
Expand Down Expand Up @@ -114,83 +114,87 @@ UINT24 mos_GETFIL(UINT8 fh);

UINT8 fat_EOF(FIL * fp);

#define HELP_CAT "Directory listing of the current directory\r\n"
#define HELP_CAT_ARGS "<path>"
#define HELP_CAT "Directory listing of the current directory\r\n"
#define HELP_CAT_ARGS "<path>"
#define HELP_CAT_ALIASES "DIR and ."
#define HELP_DIR_ALIASES "CAT and ."
#define HELP_DOT_ALIASES "CAT and DIR"

#define HELP_CD "Change current directory\r\n"
#define HELP_CD_ARGS "<path>"
#define HELP_CD "Change current directory\r\n"
#define HELP_CD_ARGS "<path>"

#define HELP_COPY "Create a copy of a file\r\n"
#define HELP_COPY_ARGS "<filename1> <filename2>"
#define HELP_COPY "Create a copy of a file\r\n"
#define HELP_COPY_ARGS "<filename1> <filename2>"

#define HELP_CREDITS "Output credits and version numbers for\r\n" \
"third-party libraries used in the Agon firmware\r\n"
#define HELP_CREDITS "Output credits and version numbers for\r\n" \
"third-party libraries used in the Agon firmware\r\n"

#define HELP_DELETE "Delete a file or folder (must be empty)\r\n"
#define HELP_DELETE "Delete a file or folder (must be empty)\r\n"
#define HELP_DELETE_ARGS "<filename>"
#define HELP_DELETE_ALIASES "ERASE"
#define HELP_ERASE_ALIASES "DELETE"

#define HELP_JMP "Jump to the specified address in memory\r\n"
#define HELP_JMP_ARGS "<addr>"
#define HELP_JMP "Jump to the specified address in memory\r\n"
#define HELP_JMP_ARGS "<addr>"

#define HELP_LOAD "Load a file from the SD card to the specified address.\r\n" \
"If no `addr` parameter is passed it will" \
"default to &40000\r\n"
#define HELP_LOAD_ARGS "<filename> [<addr>]"
#define HELP_LOAD "Load a file from the SD card to the specified address.\r\n" \
"If no `addr` parameter is passed it will" \
"default to &40000\r\n"
#define HELP_LOAD_ARGS "<filename> [<addr>]"

#define HELP_MKDIR "Create a new folder on the SD card\r\n"
#define HELP_MKDIR_ARGS "<filename>"
#define HELP_MKDIR "Create a new folder on the SD card\r\n"
#define HELP_MKDIR_ARGS "<filename>"

#define HELP_RENAME "Rename a file in the same folder\r\n"
#define HELP_RENAME "Rename a file in the same folder\r\n"
#define HELP_RENAME_ARGS "<filename1> <filename2>"
#define HELP_RENAME_ALIASES "MOVE"
#define HELP_MOVE_ALIASES "RENAME"

#define HELP_RUN "Call an executable binary loaded in memory.\r\n"\
"If no parameters are passed, then addr will " \
"default to &40000.\r\n"
#define HELP_RUN_ARGS "[<addr>]"

#define HELP_SAVE "Save a block of memory to the SD card\r\n"
#define HELP_SAVE_ARGS "<filename> <addr> <size>"

#define HELP_SET "Set a system option\r\n\r\n" \
"Keyboard Layout\r\n" \
"SET KEYBOARD n: Set the keyboard layout\r\n" \
" 0: UK\r\n" \
" 1: US\r\n" \
" 2: German\r\n" \
" 3: Italian\r\n" \
" 4: Spanish\r\n" \
" 5: French\r\n" \
" 6: Belgian\r\n" \
" 7: Norwegian\r\n" \
" 8: Japanese\r\n"
#define HELP_SET_ARGS "<option> <value>"

#define HELP_TIME "Set and read the ESP32 real-time clock\r\n"
#define HELP_TIME_ARGS "[ <yyyy> <mm> <dd> <hh> <mm> <ss> ]"

#define HELP_VDU "Write a stream of characters to the VDP\r\n" \
"Character values are converted to bytes before sending\r\n"
#define HELP_VDU_ARGS "<char1> <char2> ... <charN>"

#define HELP_TYPE "Display the contents of a file on the screen\r\n"
#define HELP_TYPE_ARGS "<filename>"

#define HELP_CLS "Clear the screen\r\n"

#define HELP_MOUNT "(Re-)mount the MicroSD card\r\n"

#define HELP_HELP "Display help on a single or all commands.\r\n" \
"List of commands:\r\n" \
"CAT, CD, COPY, CREDITS, DELETE, JMP, \r\n" \
"LOAD, MKDIR, RENAME, RUN, SAVE, SET, \r\n" \
"TIME, VDU, TYPE, CLS, MOUNT, HELP.\r\n"
#define HELP_HELP_ARGS "[ <command> | all ]"
#define HELP_RUN "Call an executable binary loaded in memory.\r\n" \
"If no parameters are passed, then addr will " \
"default to &40000.\r\n"
#define HELP_RUN_ARGS "[<addr>]"

#define HELP_SAVE "Save a block of memory to the SD card\r\n"
#define HELP_SAVE_ARGS "<filename> <addr> <size>"

#define HELP_SET "Set a system option\r\n\r\n" \
"Keyboard Layout\r\n" \
"SET KEYBOARD n: Set the keyboard layout\r\n" \
" 0: UK\r\n" \
" 1: US\r\n" \
" 2: German\r\n" \
" 3: Italian\r\n" \
" 4: Spanish\r\n" \
" 5: French\r\n" \
" 6: Belgian\r\n" \
" 7: Norwegian\r\n" \
" 8: Japanese\r\n\r\n" \
"Serial Console\r\n" \
"SET CONSOLE n: Serial console\r\n" \
" 0: Console off\r\n" \
" 1: Console on\r\n"
#define HELP_SET_ARGS "<option> <value>"

#define HELP_TIME "Set and read the ESP32 real-time clock\r\n"
#define HELP_TIME_ARGS "[ <yyyy> <mm> <dd> <hh> <mm> <ss> ]"

#define HELP_VDU "Write a stream of characters to the VDP\r\n" \
"Character values are converted to bytes before sending\r\n"
#define HELP_VDU_ARGS "<char1> <char2> ... <charN>"

#define HELP_TYPE "Display the contents of a file on the screen\r\n"
#define HELP_TYPE_ARGS "<filename>"

#define HELP_CLS "Clear the screen\r\n"

#define HELP_MOUNT "(Re-)mount the MicroSD card\r\n"

#define HELP_HELP "Display help on a single or all commands.\r\n" \
"List of commands:\r\n" \
"CAT, CD, COPY, CREDITS, DELETE, JMP, \r\n" \
"LOAD, MKDIR, RENAME, RUN, SAVE, SET, \r\n" \
"TIME, VDU, TYPE, CLS, MOUNT, HELP.\r\n"
#define HELP_HELP_ARGS "[ <command> | all ]"

#endif MOS_H

0 comments on commit b2f2292

Please sign in to comment.