mirror of
https://github.com/nobuh/napple1.git
synced 2024-12-11 16:49:28 +00:00
Cleaned up autotyping and made code closer to original repo style
This commit is contained in:
parent
0e328339d4
commit
13baf1a6a7
1
AUTOTYPING.TXT
Normal file
1
AUTOTYPING.TXT
Normal file
@ -0,0 +1 @@
|
||||
280.28f
|
1
KBD.TXT
1
KBD.TXT
@ -1 +0,0 @@
|
||||
Change content of the "kbd.txt" file to change auto-keyboard input.
|
12
README
12
README
@ -1,15 +1,7 @@
|
||||
# Fork of napple1
|
||||
|
||||
This forks enables to emulate keyboard entry on the apple1
|
||||
|
||||
This kludge is done by creating a "KBD.TXT" file. When pressing "shift-K",
|
||||
the keyboard I/O will be replaced by the content of this file.
|
||||
|
||||
This have been done to be able to load basic programs and use the 'dump"
|
||||
features to transfer them to binary files.
|
||||
|
||||
|
||||
|
||||
This forks enables to emulate keyboard entry on the apple1. When pressing "shift-K",
|
||||
the keyboard I/O will be replaced by the content of the 'AUTOTYPING.TXT' file. (note: this have been done to be able to type in basic programs and use the 'dump" features to transfer them to binary files).
|
||||
|
||||
napple1 is an Apple 1 emulator using ncurses, ported from the SDL version
|
||||
Pom1 emulafor. If you have some questions, please report it as an issue.
|
||||
|
@ -27,7 +27,40 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
FILE *kbd_txt;
|
||||
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)
|
||||
{
|
||||
@ -36,13 +69,11 @@ int handleInput(void)
|
||||
tmp = '\0';
|
||||
while ( (tmp = getch_screen()) == '\0' )
|
||||
;
|
||||
if (tmp=='K')
|
||||
{
|
||||
/* We open the "KBD.TXT" file if it exists */
|
||||
kbd_txt = fopen("KBD.TXT", "r");
|
||||
return 1;
|
||||
if (tmp=='K') {
|
||||
if (startAutotyping("AUTOTYPING.TXT"))
|
||||
return 1;
|
||||
}
|
||||
if (tmp == 'B') {
|
||||
else if (tmp == 'B') {
|
||||
loadBasic();
|
||||
resetPia6820();
|
||||
resetM6502();
|
||||
|
@ -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);
|
||||
|
@ -1,8 +1,7 @@
|
||||
# napple1 makefile
|
||||
# Nobu Hatano <nobuhatano@gmail.com>
|
||||
CC = gcc
|
||||
CFLAGS = -Wall
|
||||
# CFLAGS = -Wall -ansi
|
||||
CFLAGS = -Wall -ansi
|
||||
THREAD = -lpthread
|
||||
|
||||
# Support Linux and Cygwin
|
||||
|
23
src/memory.c
23
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
|
||||
@ -164,26 +165,8 @@ unsigned char memRead(unsigned short address)
|
||||
if (address == 0xD011)
|
||||
{
|
||||
unsigned char v = readKbdCr();
|
||||
extern FILE *kbd_txt;
|
||||
if (!(v & 0x80) && kbd_txt)
|
||||
{
|
||||
// Read on char from file
|
||||
int c = fgetc(kbd_txt);
|
||||
if (c!=EOF)
|
||||
{
|
||||
if (c=='\n')
|
||||
c = 0x0d;
|
||||
if (v>='a' && v<='z')
|
||||
c = c - 'a' + 'A';
|
||||
writeKbd((unsigned char)(c + 0x80));
|
||||
writeKbdCr(0xA7);
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(kbd_txt);
|
||||
kbd_txt = NULL;
|
||||
}
|
||||
}
|
||||
if (!(v & 0x80))
|
||||
nextAutotyping();
|
||||
return v;
|
||||
}
|
||||
if (address == 0xD010)
|
||||
|
Loading…
Reference in New Issue
Block a user