Merge pull request #7 from fstark/master

Added support for AUTOTYPING.TXT with Shift-K
This commit is contained in:
Nobuhiro Hatano 2024-10-07 08:07:05 +09:00 committed by GitHub
commit 9aa66f65f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 58 additions and 4 deletions

4
AUTOTYPING.TXT Normal file
View File

@ -0,0 +1,4 @@
E000R
10 PRINT "HELLO, WORLD! ";
20 GOTO 10
RUN

3
README
View File

@ -59,7 +59,7 @@ type E2B3R<enter>
- 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

View File

@ -25,6 +25,43 @@
#include "keyboard.h"
#include "screen.h"
#include <stdio.h>
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();

View File

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

View File

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