help command

This commit is contained in:
nino-porcino 2022-03-25 14:57:55 +01:00
parent 550e0ba1cf
commit b3abf7f2cd
25 changed files with 204 additions and 1 deletions

27
demos/sdcard/cmd_help.h Normal file
View File

@ -0,0 +1,27 @@
void comando_help() {
if(filename[0] == 0) {
// HELP (no arguments)
strcpy(filename, "COMMANDS");
} else {
// HELP <command>
// 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();
}

View File

@ -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();

View File

@ -0,0 +1,6 @@
Syntax:
BAS
Prints LOMEM and HIMEM pointers from
the BASIC program currently loaded in
memory.

View File

@ -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.

View File

@ -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

View File

@ -0,0 +1,4 @@
Syntax:
DEL filename
Deletes a file from the SD card.

View File

@ -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.

View File

@ -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.

View File

@ -0,0 +1,4 @@
Syntax:
EXIT
Exits to the WOZ monitor.

View File

@ -0,0 +1,5 @@
Syntax:
JMP address
Makes the CPU jump at the specified
address.

View File

@ -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.

View File

@ -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.

View File

@ -0,0 +1,4 @@
Syntax:
MD path
Creates the specified directory.

View File

@ -0,0 +1,4 @@
Syntax:
MKDIR path
Creates the specified directory.

View File

@ -0,0 +1,5 @@
Syntax:
PWD
Prints on the screen the current working
directory.

View File

@ -0,0 +1,6 @@
Syntax:
RD path
Removes the specified directory.
The directory to remove must be empty
(no files or directories within).

View File

@ -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.

View File

@ -0,0 +1,4 @@
Syntax:
RM filename
Deletes a file from the SD card.

View File

@ -0,0 +1,6 @@
Syntax:
RMDIR path
Removes the specified directory.
The directory to remove must be empty
(no files or directories within).

View File

@ -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.

View File

@ -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.

View File

@ -0,0 +1,4 @@
Syntax:
TEST
Internal test, not to be used.

View File

@ -0,0 +1,6 @@
Syntax:
TIME value
Set the internal timeout value used in
the I/O operations with the SD cards.
-- TESTING ONLY ---

View File

@ -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.

View File

@ -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.