Config, CTRL+C, exit
This commit is contained in:
1 parent
9e6a96f93a
commit
8101cc3f62
6 files changed
+42
-18
No files matched your search
@@ -1,13 +1,20 @@
|
||||
; configuration
|
||||
CONFIG_2A := 1
|
||||
|
||||
CONFIG_DATAFLG := 1
|
||||
CONFIG_EASTER_EGG := 1
|
||||
CONFIG_NO_READ_Y_IS_ZERO_HACK := 1
|
||||
CONFIG_PEEK_SAVE_LINNUM := 1
|
||||
CONFIG_SCRTCH_ORDER := 2
|
||||
|
||||
; zero page
|
||||
ZP_START0 = $00
|
||||
; zero page -- CBM BASIC V2 layout
|
||||
ZP_START1 = $02
|
||||
ZP_START2 = $0C
|
||||
ZP_START3 = $62
|
||||
ZP_START4 = $6D
|
||||
ZP_START3 = $12
|
||||
ZP_START4 = $1D
|
||||
|
||||
; input buffer
|
||||
INPUTBUFFER := $0200
|
||||
|
||||
; extra/override ZP variables
|
||||
USR := GORESTART ; XXX
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
.segment "CODE"
|
||||
|
||||
.ifndef CONFIG_NO_INPUTBUFFER_ZP
|
||||
.ifndef CONFIG_NO_LINE_EDITING
|
||||
L2420:
|
||||
.ifdef OSI
|
||||
jsr OUTDO
|
||||
|
||||
@@ -8,13 +8,18 @@ SAVE:
|
||||
rts
|
||||
|
||||
ISCNTC:
|
||||
lda $BC01
|
||||
cmp #$03
|
||||
beq @break
|
||||
rts
|
||||
@break:
|
||||
jmp STOP
|
||||
|
||||
MONRDKEY:
|
||||
lda $BC01
|
||||
bmi MONRDKEY_SKIP_ECHO
|
||||
bmi @skipped
|
||||
sta $BC00 ; echo
|
||||
MONRDKEY_SKIP_ECHO:
|
||||
@skipped:
|
||||
rts
|
||||
|
||||
MONCOUT:
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ LE878:
|
||||
|
||||
.ifndef KBD
|
||||
L29B9:
|
||||
.ifdef CBM2
|
||||
.ifdef CONFIG_INPUTBUFFER_0200
|
||||
lda #$00
|
||||
sta INPUTBUFFER,x
|
||||
ldx #<(INPUTBUFFER-1)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "io.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int putChar(uint8_t c) {
|
||||
int _c = putchar(c);
|
||||
@@ -28,5 +29,9 @@ int getChar(void) {
|
||||
c = c - 'a' + 'A';
|
||||
}
|
||||
|
||||
if (c == 0x07) {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
+17
-10
@@ -23,7 +23,9 @@ void set_nonblocking_input(void) {
|
||||
atexit(restore_terminal);
|
||||
|
||||
raw = orig_termios;
|
||||
raw.c_lflag &= ~(ICANON | ECHO); // disable line buffering and echo
|
||||
raw.c_lflag &= ~(ICANON | ECHO); // disable line buffering, echo
|
||||
/* Ctrl+C becomes ordinary input byte 0x03 */
|
||||
raw.c_cc[VINTR] = _POSIX_VDISABLE;
|
||||
raw.c_cc[VMIN] = 0; // don't block waiting for input
|
||||
raw.c_cc[VTIME] = 0;
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &raw);
|
||||
@@ -34,6 +36,9 @@ void set_nonblocking_input(void) {
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printf("6502PC Emulator with MS Basic\n");
|
||||
printf("CTRL + G to exit\n");
|
||||
|
||||
uint8_t *ram = NULL;
|
||||
CPU cpu;
|
||||
|
||||
@@ -43,26 +48,26 @@ int main(void) {
|
||||
|
||||
if (createRAM(&ram) != 0) {
|
||||
printf("Could not create RAM\n");
|
||||
return 1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* DEBUG */
|
||||
|
||||
//FILE *fp = fopen("/Users/Kili2/Documents/Projekte/6502pc/6502_65C02_functional_tests/6502_functional_test.bin", "rb");
|
||||
//FILE *fp = fopen("/Users/Kili2/Documents/Projekte/6502pc/6502_65C02_functional_tests/6502_decimal_test.bin", "rb");
|
||||
//FILE *fp = fopen("/mnt/c/Users/llego/source/repos/6502PC/6502_65C02_functional_tests/6502_functional_test.bin", "rb");
|
||||
//FILE *fp = fopen("/mnt/c/Users/llego/source/repos/6502PC/6502_65C02_functional_tests/6502_decimal_test.bin", "rb");
|
||||
// FILE *fp = fopen("/Users/Kili2/Documents/Projekte/6502pc/6502_65C02_functional_tests/6502_functional_test.bin", "rb");
|
||||
// FILE *fp = fopen("/Users/Kili2/Documents/Projekte/6502pc/6502_65C02_functional_tests/6502_decimal_test.bin", "rb");
|
||||
// FILE *fp = fopen("/mnt/c/Users/llego/source/repos/6502PC/6502_65C02_functional_tests/6502_functional_test.bin", "rb");
|
||||
// FILE *fp = fopen("/mnt/c/Users/llego/source/repos/6502PC/6502_65C02_functional_tests/6502_decimal_test.bin", "rb");
|
||||
/*
|
||||
if (!fp) {
|
||||
perror("fopen");
|
||||
return 1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fread(ram, 1, RAM_SIZE, fp);
|
||||
if (ferror(fp)) {
|
||||
perror("fread");
|
||||
fclose(fp);
|
||||
return 1;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
@@ -76,8 +81,10 @@ int main(void) {
|
||||
while (1) {
|
||||
uint8_t sleep = runCycle(&cpu, ram, rom);
|
||||
if (sleep == 1) {
|
||||
printf("opcode missing: 0x%X\n", ram[cpu.ProgrammeCounter - 1]);
|
||||
return 1;
|
||||
printf("Illegal opcode $%02X at $%04X "
|
||||
"A=$%02X X=$%02X Y=$%02X SP=$%02X\n",
|
||||
ram[cpu.ProgrammeCounter - 1], cpu.ProgrammeCounter - 1, cpu.Accumulator, cpu.X, cpu.Y, cpu.StackPointer);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
sleepTime.tv_sec = 0;
|
||||
sleepTime.tv_nsec = sleep * (1000 / MACHINE_SPEED_HZ);
|
||||
|
||||
Reference in new issue
Block a user