diff --git a/AUTOTYPING.TXT b/AUTOTYPING.TXT new file mode 100644 index 0000000..7ddee74 --- /dev/null +++ b/AUTOTYPING.TXT @@ -0,0 +1,4 @@ +E000R +10 PRINT "HELLO, WORLD! "; +20 GOTO 10 +RUN diff --git a/README b/README index 61c40d5..56a8ea3 100644 --- a/README +++ b/README @@ -59,7 +59,7 @@ type E2B3R - Emulator commands Command Key Description --------------------------------------------------------------------- +--------------------------------------------------------------------------- Basic load Shidt + B Load rom/basic.rom to ram Dump core Shift + D Dump memory to core/_file name_ Load core Shift + L Load memory from core/_file name_ @@ -67,6 +67,7 @@ Reset Shift + R Reset the emulator Hard reset Shidt + H Reset & Clear memory Quit Shidt + Q Quit the emulator Mode Shift + M Mode change 8KB & 32KB ram mode + Shift + K Automatically type in AUTOTYPING.TXT file if present - Load / Save programs diff --git a/src/keyboard.c b/src/keyboard.c index f66628a..ea74af3 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -25,6 +25,43 @@ #include "keyboard.h" #include "screen.h" +#include + +FILE *autotyping_file = NULL; + +int startAutotyping(const char *filename) +{ + if (autotyping_file) + stopAutotyping(); + autotyping_file = fopen(filename, "r"); + return !!autotyping_file; +} + +int nextAutotyping(void) +{ + if (!autotyping_file) + return -1; + int c = fgetc(autotyping_file); + if (c!=EOF) { + if (c=='\n') + c = 0x0d; + if (c>='a' && c<='z') + c = c - 'a' + 'A'; + writeKbd((unsigned char)(c + 0x80)); + writeKbdCr(0xA7); + } + else + stopAutotyping(); + return c; +} + +void stopAutotyping(void) +{ + if (autotyping_file) + fclose(autotyping_file); + autotyping_file = NULL; +} + int handleInput(void) { char tmp; @@ -32,7 +69,11 @@ int handleInput(void) tmp = '\0'; while ( (tmp = getch_screen()) == '\0' ) ; - if (tmp == 'B') { + if (tmp=='K') { + if (startAutotyping("AUTOTYPING.TXT")) + return 1; + } + else if (tmp == 'B') { loadBasic(); resetPia6820(); resetM6502(); diff --git a/src/keyboard.h b/src/keyboard.h index 990226f..fff4664 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -20,3 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ int handleInput(void); +int startAutotyping(const char *filename); +int nextAutotyping(void); +void stopAutotyping(void); diff --git a/src/memory.c b/src/memory.c index fd43898..46d4fd7 100644 --- a/src/memory.c +++ b/src/memory.c @@ -82,6 +82,7 @@ #include "memory.h" #include "screen.h" #include "msgbuf.h" +#include "keyboard.h" #define MEMMAX 0xFFFF #define FNAME_LEN_MAX 1024 @@ -161,8 +162,12 @@ unsigned char memRead(unsigned short address) return readDspCr(); if (address == 0xD012) return readDsp(); - if (address == 0xD011) - return readKbdCr(); + if (address == 0xD011) { + unsigned char v = readKbdCr(); + if (!(v & 0x80)) + nextAutotyping(); + return v; + } if (address == 0xD010) return readKbd();