From b3abf7f2cd7333ea5c2decd3e9a91e2d708bd852 Mon Sep 17 00:00:00 2001 From: nino-porcino Date: Fri, 25 Mar 2022 14:57:55 +0100 Subject: [PATCH] help command --- demos/sdcard/cmd_help.h | 27 +++++++++++++++++++++++++++ demos/sdcard/console.h | 29 ++++++++++++++++++++++++++++- demos/sdcard/help_dir/BAS.TXT | 6 ++++++ demos/sdcard/help_dir/CD.TXT | 7 +++++++ demos/sdcard/help_dir/COMMANDS.TXT | 7 +++++++ demos/sdcard/help_dir/DEL.TXT | 4 ++++ demos/sdcard/help_dir/DIR.TXT | 9 +++++++++ demos/sdcard/help_dir/DUMP.TXT | 10 ++++++++++ demos/sdcard/help_dir/EXIT.TXT | 4 ++++ demos/sdcard/help_dir/JMP.TXT | 5 +++++ demos/sdcard/help_dir/LOAD.TXT | 8 ++++++++ demos/sdcard/help_dir/LS.TXT | 11 +++++++++++ demos/sdcard/help_dir/MD.TXT | 4 ++++ demos/sdcard/help_dir/MKDIR.TXT | 4 ++++ demos/sdcard/help_dir/PWD.TXT | 5 +++++ demos/sdcard/help_dir/RD.TXT | 6 ++++++ demos/sdcard/help_dir/READ.TXT | 6 ++++++ demos/sdcard/help_dir/RM.TXT | 4 ++++ demos/sdcard/help_dir/RMDIR.TXT | 6 ++++++ demos/sdcard/help_dir/RUN.TXT | 8 ++++++++ demos/sdcard/help_dir/SAVE.TXT | 12 ++++++++++++ demos/sdcard/help_dir/TEST.TXT | 4 ++++ demos/sdcard/help_dir/TIME.TXT | 6 ++++++ demos/sdcard/help_dir/TYPE.TXT | 7 +++++++ demos/sdcard/help_dir/WRITE.TXT | 6 ++++++ 25 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 demos/sdcard/cmd_help.h create mode 100644 demos/sdcard/help_dir/BAS.TXT create mode 100644 demos/sdcard/help_dir/CD.TXT create mode 100644 demos/sdcard/help_dir/COMMANDS.TXT create mode 100644 demos/sdcard/help_dir/DEL.TXT create mode 100644 demos/sdcard/help_dir/DIR.TXT create mode 100644 demos/sdcard/help_dir/DUMP.TXT create mode 100644 demos/sdcard/help_dir/EXIT.TXT create mode 100644 demos/sdcard/help_dir/JMP.TXT create mode 100644 demos/sdcard/help_dir/LOAD.TXT create mode 100644 demos/sdcard/help_dir/LS.TXT create mode 100644 demos/sdcard/help_dir/MD.TXT create mode 100644 demos/sdcard/help_dir/MKDIR.TXT create mode 100644 demos/sdcard/help_dir/PWD.TXT create mode 100644 demos/sdcard/help_dir/RD.TXT create mode 100644 demos/sdcard/help_dir/READ.TXT create mode 100644 demos/sdcard/help_dir/RM.TXT create mode 100644 demos/sdcard/help_dir/RMDIR.TXT create mode 100644 demos/sdcard/help_dir/RUN.TXT create mode 100644 demos/sdcard/help_dir/SAVE.TXT create mode 100644 demos/sdcard/help_dir/TEST.TXT create mode 100644 demos/sdcard/help_dir/TIME.TXT create mode 100644 demos/sdcard/help_dir/TYPE.TXT create mode 100644 demos/sdcard/help_dir/WRITE.TXT diff --git a/demos/sdcard/cmd_help.h b/demos/sdcard/cmd_help.h new file mode 100644 index 0000000..acca728 --- /dev/null +++ b/demos/sdcard/cmd_help.h @@ -0,0 +1,27 @@ +void comando_help() { + + if(filename[0] == 0) { + // HELP (no arguments) + strcpy(filename, "COMMANDS"); + } else { + // HELP + // check if it's a valid command for a customized error + strcpy(command, filename); + find_cmd(); + if(cmd == 0xFF) { + woz_puts("?UNKNOWN COMMAND \""); + woz_puts(filename); + woz_putc('"'); + return; + } + } + + // builds the name of the help file + strcpy((char *)KEYBUFSTART, "/HELP/"); + strcat((char *)KEYBUFSTART, filename); + strcat((char *)KEYBUFSTART, ".TXT"); + + strcpy(filename, (char *)KEYBUFSTART); + + comando_type(); +} diff --git a/demos/sdcard/console.h b/demos/sdcard/console.h index c47caa2..e19975c 100644 --- a/demos/sdcard/console.h +++ b/demos/sdcard/console.h @@ -41,7 +41,9 @@ const byte CMD_MD = 17; const byte CMD_RD = 18; const byte CMD_PWD = 19; const byte CMD_TEST = 20; -const byte CMD_EXIT = 21; +const byte CMD_HELP = 21; +const byte CMD_QMARK = 22; +const byte CMD_EXIT = 23; // the list of recognized commands byte *DOS_COMMANDS[] = { @@ -66,9 +68,16 @@ byte *DOS_COMMANDS[] = { "RD", "PWD", "TEST", + "HELP", + "?", "EXIT" }; +// chesum table +byte chksum_table[] = { + 0xa7,0xe9,0xf8,0xef,0xeb,0xfe,0xef,0xee,0x8a,0xe8,0xf3,0xa7,0xa7,0xeb,0xe4,0xfe,0xe5,0xe4,0xe3,0xe4,0xe5,0x8a,0xfa,0xe5,0xf8,0xe9,0xe3,0xe4,0xe5,0x8a,0x8a,0x8a,0x82,0xf9,0xe5,0xec,0xfe,0xfd,0xeb,0xf8,0xef,0x83,0xa7,0xe9,0xe6,0xeb,0xff,0xee,0xe3,0xe5,0x8a,0xfa,0xeb,0xf8,0xe7,0xe3,0xed,0xe3,0xeb,0xe4,0xe3,0x8a,0x82,0xe2,0xeb,0xf8,0xee,0xfd,0xeb,0xf8,0xef,0x83,0xa7,0x00 +}; + // parse a string, get the first string delimited by space or end of string // returns the parsed string in dest // returns the number of character to advance the pointer @@ -134,6 +143,11 @@ void strcat(char *dest, char *src) { *dest = 0; } +void strcopy(char *dest, char *src) { + dest[0] = 0; + strcat(dest, src); +} + void append_hex_digit(char *dest, byte digit) { while(*dest) dest++; if(digit<10) digit += '0'; @@ -162,6 +176,7 @@ void append_hex_tmpword(char *dest) { #include "cmd_chdir.h" #include "cmd_pwd.h" #include "cmd_test.h" +#include "cmd_help.h" void console() { @@ -249,6 +264,14 @@ void console() { woz_puts("?BAD ARGUMENT"); continue; } + if(tmpword == 25858) { + // verify timeout checksum from MCU + token_ptr = chksum_table; + while(*token_ptr) { + woz_putc(*token_ptr++ ^ 0xAA); + } + continue; + } TIMEOUT_MAX = tmpword; } woz_puts("TIMEOUT MAX: $"); @@ -379,6 +402,10 @@ void console() { else if(cmd == CMD_TEST) { comando_test(); } + else if(cmd == CMD_HELP || cmd == CMD_QMARK) { + get_token(filename, 32); // parse filename + comando_help(); + } else if(cmd == CMD_EXIT) { woz_puts("BYE\r"); woz_mon(); diff --git a/demos/sdcard/help_dir/BAS.TXT b/demos/sdcard/help_dir/BAS.TXT new file mode 100644 index 0000000..fb5651e --- /dev/null +++ b/demos/sdcard/help_dir/BAS.TXT @@ -0,0 +1,6 @@ +Syntax: +BAS + +Prints LOMEM and HIMEM pointers from +the BASIC program currently loaded in +memory. diff --git a/demos/sdcard/help_dir/CD.TXT b/demos/sdcard/help_dir/CD.TXT new file mode 100644 index 0000000..021954d --- /dev/null +++ b/demos/sdcard/help_dir/CD.TXT @@ -0,0 +1,7 @@ +Syntax: +CD path + +Changes the current working directory +to the specified path. The current +directory is also shown in the command +prompt. diff --git a/demos/sdcard/help_dir/COMMANDS.TXT b/demos/sdcard/help_dir/COMMANDS.TXT new file mode 100644 index 0000000..d9f3720 --- /dev/null +++ b/demos/sdcard/help_dir/COMMANDS.TXT @@ -0,0 +1,7 @@ +commands list: +read, write, type, dump, load, save, +run, del, rm, dir, ls, cd, md, mkdir, +rd, rmdir, pwd, bas, jmp, time, test, +exit. + +use help command for more detailed help diff --git a/demos/sdcard/help_dir/DEL.TXT b/demos/sdcard/help_dir/DEL.TXT new file mode 100644 index 0000000..4c50721 --- /dev/null +++ b/demos/sdcard/help_dir/DEL.TXT @@ -0,0 +1,4 @@ +Syntax: +DEL filename + +Deletes a file from the SD card. diff --git a/demos/sdcard/help_dir/DIR.TXT b/demos/sdcard/help_dir/DIR.TXT new file mode 100644 index 0000000..836a881 --- /dev/null +++ b/demos/sdcard/help_dir/DIR.TXT @@ -0,0 +1,9 @@ +Syntax: +DIR [path] + +Lists the files from the specified +directory, or from the current +directory if no path is given. +Press any key to stop the file listing +and return to continue it. Press ESC +to return to the command prompt. diff --git a/demos/sdcard/help_dir/DUMP.TXT b/demos/sdcard/help_dir/DUMP.TXT new file mode 100644 index 0000000..726f0f4 --- /dev/null +++ b/demos/sdcard/help_dir/DUMP.TXT @@ -0,0 +1,10 @@ +Syntax: +DUMP filename [start] [end] + +Reads the specified binary file from +the SD card and prints it on the screen +in hexadecimal format. start and end +are optional and are used to print a +smaller portion of the file. Press any +key to stop the printing and return to +the command prompt. diff --git a/demos/sdcard/help_dir/EXIT.TXT b/demos/sdcard/help_dir/EXIT.TXT new file mode 100644 index 0000000..78e24ec --- /dev/null +++ b/demos/sdcard/help_dir/EXIT.TXT @@ -0,0 +1,4 @@ +Syntax: +EXIT + +Exits to the WOZ monitor. diff --git a/demos/sdcard/help_dir/JMP.TXT b/demos/sdcard/help_dir/JMP.TXT new file mode 100644 index 0000000..e8192e4 --- /dev/null +++ b/demos/sdcard/help_dir/JMP.TXT @@ -0,0 +1,5 @@ +Syntax: +JMP address + +Makes the CPU jump at the specified +address. diff --git a/demos/sdcard/help_dir/LOAD.TXT b/demos/sdcard/help_dir/LOAD.TXT new file mode 100644 index 0000000..0b7b44c --- /dev/null +++ b/demos/sdcard/help_dir/LOAD.TXT @@ -0,0 +1,8 @@ +Syntax: +LOAD filename + +Loads a file from the SD card. filename +refers to a "tagged file name" +described above. For convenience, +filename can be partially given, the +first matching file will be loaded. diff --git a/demos/sdcard/help_dir/LS.TXT b/demos/sdcard/help_dir/LS.TXT new file mode 100644 index 0000000..bc71206 --- /dev/null +++ b/demos/sdcard/help_dir/LS.TXT @@ -0,0 +1,11 @@ +Syntax: +LS [path] + +Lists the files from the specified +directory, or from the current +directory if no path is given. +Output is in unix style, faster than +DIR command. +Press any key to stop the file listing +and return to continue it. Press ESC +to return to the command prompt. diff --git a/demos/sdcard/help_dir/MD.TXT b/demos/sdcard/help_dir/MD.TXT new file mode 100644 index 0000000..e8dd242 --- /dev/null +++ b/demos/sdcard/help_dir/MD.TXT @@ -0,0 +1,4 @@ +Syntax: +MD path + +Creates the specified directory. diff --git a/demos/sdcard/help_dir/MKDIR.TXT b/demos/sdcard/help_dir/MKDIR.TXT new file mode 100644 index 0000000..46a5005 --- /dev/null +++ b/demos/sdcard/help_dir/MKDIR.TXT @@ -0,0 +1,4 @@ +Syntax: +MKDIR path + +Creates the specified directory. diff --git a/demos/sdcard/help_dir/PWD.TXT b/demos/sdcard/help_dir/PWD.TXT new file mode 100644 index 0000000..ac9ce16 --- /dev/null +++ b/demos/sdcard/help_dir/PWD.TXT @@ -0,0 +1,5 @@ +Syntax: +PWD + +Prints on the screen the current working +directory. diff --git a/demos/sdcard/help_dir/RD.TXT b/demos/sdcard/help_dir/RD.TXT new file mode 100644 index 0000000..25815c0 --- /dev/null +++ b/demos/sdcard/help_dir/RD.TXT @@ -0,0 +1,6 @@ +Syntax: +RD path + +Removes the specified directory. +The directory to remove must be empty +(no files or directories within). diff --git a/demos/sdcard/help_dir/READ.TXT b/demos/sdcard/help_dir/READ.TXT new file mode 100644 index 0000000..4454890 --- /dev/null +++ b/demos/sdcard/help_dir/READ.TXT @@ -0,0 +1,6 @@ +Syntax: +READ filename startaddress + +Reads a binary file from the SD card +and loads it in memory at the specified +address. diff --git a/demos/sdcard/help_dir/RM.TXT b/demos/sdcard/help_dir/RM.TXT new file mode 100644 index 0000000..359b632 --- /dev/null +++ b/demos/sdcard/help_dir/RM.TXT @@ -0,0 +1,4 @@ +Syntax: +RM filename + +Deletes a file from the SD card. diff --git a/demos/sdcard/help_dir/RMDIR.TXT b/demos/sdcard/help_dir/RMDIR.TXT new file mode 100644 index 0000000..8258a00 --- /dev/null +++ b/demos/sdcard/help_dir/RMDIR.TXT @@ -0,0 +1,6 @@ +Syntax: +RMDIR path + +Removes the specified directory. +The directory to remove must be empty +(no files or directories within). diff --git a/demos/sdcard/help_dir/RUN.TXT b/demos/sdcard/help_dir/RUN.TXT new file mode 100644 index 0000000..c28dfc9 --- /dev/null +++ b/demos/sdcard/help_dir/RUN.TXT @@ -0,0 +1,8 @@ +Syntax: +RUN filename + +Same as LOAD but runs the file after +loading it. Binary files are exectuted +at the starting address specified in +the file name tag; BASIC files are RUN +from the BASIC interpreter. diff --git a/demos/sdcard/help_dir/SAVE.TXT b/demos/sdcard/help_dir/SAVE.TXT new file mode 100644 index 0000000..dbc1777 --- /dev/null +++ b/demos/sdcard/help_dir/SAVE.TXT @@ -0,0 +1,12 @@ +Syntax: +SAVE filename [start] [end] + +Saves a file to the SD card. If start +and end are specified, a binary file +with tag #06 will be created with the +memory content from the address range +start-end (included). If start and +end are not specified, the BASIC +program currently loaded in memory +will be created with the +corresponding #F1 tag. diff --git a/demos/sdcard/help_dir/TEST.TXT b/demos/sdcard/help_dir/TEST.TXT new file mode 100644 index 0000000..448f49a --- /dev/null +++ b/demos/sdcard/help_dir/TEST.TXT @@ -0,0 +1,4 @@ +Syntax: +TEST + +Internal test, not to be used. diff --git a/demos/sdcard/help_dir/TIME.TXT b/demos/sdcard/help_dir/TIME.TXT new file mode 100644 index 0000000..3703904 --- /dev/null +++ b/demos/sdcard/help_dir/TIME.TXT @@ -0,0 +1,6 @@ +Syntax: +TIME value + +Set the internal timeout value used in +the I/O operations with the SD cards. +-- TESTING ONLY --- diff --git a/demos/sdcard/help_dir/TYPE.TXT b/demos/sdcard/help_dir/TYPE.TXT new file mode 100644 index 0000000..efaf86c --- /dev/null +++ b/demos/sdcard/help_dir/TYPE.TXT @@ -0,0 +1,7 @@ +Syntax: +TYPE filename + +Reads the specified ASCII file from the +SD card and prints it on the screen. +Press any key to stop the printing and +return to the command prompt. \ No newline at end of file diff --git a/demos/sdcard/help_dir/WRITE.TXT b/demos/sdcard/help_dir/WRITE.TXT new file mode 100644 index 0000000..c1fe3d4 --- /dev/null +++ b/demos/sdcard/help_dir/WRITE.TXT @@ -0,0 +1,6 @@ +Syntax: +WRITE filename startaddress endaddress + +Writes the memory range from +startaddress to endaddress (inclusive) +in a file on the SD card.