From bc1e99fccd65915aab87e3edfe4ae00573f16d67 Mon Sep 17 00:00:00 2001 From: nino-porcino Date: Tue, 15 Feb 2022 17:44:20 +0100 Subject: [PATCH] new CD and PWD commands, new prompt --- demos/sdcard/cmd_chdir.h | 12 +++++-- demos/sdcard/cmd_pwd.h | 8 +++++ demos/sdcard/console.h | 73 ++++++++++++++++++++++------------------ 3 files changed, 59 insertions(+), 34 deletions(-) create mode 100644 demos/sdcard/cmd_pwd.h diff --git a/demos/sdcard/cmd_chdir.h b/demos/sdcard/cmd_chdir.h index 66330df..c6e6f17 100644 --- a/demos/sdcard/cmd_chdir.h +++ b/demos/sdcard/cmd_chdir.h @@ -7,6 +7,14 @@ void comando_cd() { send_string_to_MCU(filename); if(TIMEOUT) return; - print_string_response(); - return; + // response + byte response = receive_byte_from_MCU(); + if(TIMEOUT) return; + + if(response == ERR_RESPONSE) { + // error with file, print message + print_string_response(); + woz_putc('\r'); // add an extra newline because CD is a command without output + return; + } } diff --git a/demos/sdcard/cmd_pwd.h b/demos/sdcard/cmd_pwd.h new file mode 100644 index 0000000..e8ad873 --- /dev/null +++ b/demos/sdcard/cmd_pwd.h @@ -0,0 +1,8 @@ +void comando_pwd() { + // send command byte + send_byte_to_MCU(CMD_PWD); + if(TIMEOUT) return; + + print_string_response(); + return; +} diff --git a/demos/sdcard/console.h b/demos/sdcard/console.h index e17e282..2d155b4 100644 --- a/demos/sdcard/console.h +++ b/demos/sdcard/console.h @@ -3,10 +3,10 @@ byte **const BASIC_LOMEM = (byte **) 0x004a; // lomem pointer used by integer BASIC byte **const BASIC_HIMEM = (byte **) 0x004c; // himem pointer used by integer BASIC -byte *const KEYBUF = (byte *) 0x0200; // use the same keyboard buffer as in WOZ monitor +byte *const KEYBUF = (byte *) 0x0200; // use the same keyboard buffer as in WOZ monitor #define KEYBUFSTART (0x200) -#define KEYBUFLEN (40) +#define KEYBUFLEN (79) // keyboard buffer 0x200-27F uses only the first 40 bytes, the rest is recycled for free mem @@ -15,30 +15,31 @@ byte *const filename = (byte *) (KEYBUFSTART+KEYBUFLEN+6 ); // [33] stores a byte *const hex1 = (byte *) (KEYBUFSTART+KEYBUFLEN+6+33 ); // [5] stores a hex parameter byte *const hex2 = (byte *) (KEYBUFSTART+KEYBUFLEN+6+33+5); // [5] stores a hex parameter +const byte OK_RESPONSE = 0x00; const byte ERR_RESPONSE = 0xFF; // command constants, which are also byte commands to send to the MCU -const byte CMD_READ = 0; -const byte CMD_WRITE = 1; -const byte CMD_DIR = 2; -const byte CMD_TIME = 3; -const byte CMD_LOAD = 4; -const byte CMD_RUN = 5; -const byte CMD_SAVE = 6; -const byte CMD_TYPE = 7; -const byte CMD_DUMP = 8; -const byte CMD_JMP = 9; -const byte CMD_BAS = 10; -const byte CMD_DEL = 11; -const byte CMD_LS = 12; -const byte CMD_CD = 13; -const byte CMD_MKDIR = 14; -const byte CMD_RMDIR = 15; -const byte CMD_RM = 16; -const byte CMD_MD = 17; -const byte CMD_RD = 18; -const byte CMD_PWD = 19; -const byte CMD_EXIT = 16; +const byte CMD_READ = 0; +const byte CMD_WRITE = 1; +const byte CMD_DIR = 2; +const byte CMD_TIME = 3; +const byte CMD_LOAD = 4; +const byte CMD_RUN = 5; +const byte CMD_SAVE = 6; +const byte CMD_TYPE = 7; +const byte CMD_DUMP = 8; +const byte CMD_JMP = 9; +const byte CMD_BAS = 10; +const byte CMD_DEL = 11; +const byte CMD_LS = 12; +const byte CMD_CD = 13; +const byte CMD_MKDIR = 14; +const byte CMD_RMDIR = 15; +const byte CMD_RM = 16; +const byte CMD_MD = 17; +const byte CMD_RD = 18; +const byte CMD_PWD = 19; +const byte CMD_EXIT = 20; // the list of recognized commands byte *DOS_COMMANDS[] = { @@ -99,7 +100,7 @@ void get_token(byte *dest, byte max) { // looks "command" into table "DOS_COMMANDS" and // if found sets the index in "cmd", 0xFF if not found -void find_command() { +void find_cmd() { for(cmd=0; cmd