Update test: now it can run Apple BASIC.
]10 PRINT "HELLO" ]20 END ]LIST 10 PRINT "HELLO" 20 END ]RUN HELLO ]
This commit is contained in:
parent
faacc4ea52
commit
826647fb93
6
Makefile
6
Makefile
|
@ -41,13 +41,11 @@ $(ROM).rom:
|
||||||
|
|
||||||
# Test binary that runs on qemu user mode emulation for testing
|
# Test binary that runs on qemu user mode emulation for testing
|
||||||
test: 6502.S test.c
|
test: 6502.S test.c
|
||||||
$(CC) -mthumb -static $(FRAMEPTR) test.c 6502.S -o test && \
|
$(CC) -mthumb -static $(FRAMEPTR) test.c 6502.S -o test && qemu-arm test 2> /dev/null
|
||||||
qemu-arm test 2> log
|
|
||||||
|
|
||||||
# Test binary that runs on qemu user mode emulation for functional tests
|
# Test binary that runs on qemu user mode emulation for functional tests
|
||||||
ftest: 6502.S ftest.c
|
ftest: 6502.S ftest.c
|
||||||
$(CC) -mthumb -static $(FRAMEPTR) ftest.c 6502.S -o ftest && \
|
$(CC) -mthumb -static $(FRAMEPTR) ftest.c 6502.S -o ftest && qemu-arm ftest 2> flog
|
||||||
qemu-arm ftest 2> flog
|
|
||||||
|
|
||||||
# Assume a CQ Mary comaptible board.
|
# Assume a CQ Mary comaptible board.
|
||||||
run: $(APP).bin
|
run: $(APP).bin
|
||||||
|
|
4
ftest.c
4
ftest.c
|
@ -38,7 +38,7 @@ uint8_t cpu6502_load(uint16_t addr) {
|
||||||
uint8_t result = 0;
|
uint8_t result = 0;
|
||||||
__asm__("movs %0, r12": "=r"(fp));
|
__asm__("movs %0, r12": "=r"(fp));
|
||||||
result = mem[addr];
|
result = mem[addr];
|
||||||
fprintf(stderr, "load $%04x => $%02x\n", addr, result);
|
//fprintf(stderr, "load $%04x => $%02x\n", addr, result);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
__asm__("movs r12, %0":: "r"(fp));
|
__asm__("movs r12, %0":: "r"(fp));
|
||||||
return result;
|
return result;
|
||||||
|
@ -48,7 +48,7 @@ void cpu6502_store(uint16_t addr, uint8_t data) {
|
||||||
uint32_t fp;
|
uint32_t fp;
|
||||||
__asm__("movs %0, r12": "=r"(fp));
|
__asm__("movs %0, r12": "=r"(fp));
|
||||||
mem[addr] = data;
|
mem[addr] = data;
|
||||||
fprintf(stderr, "store $%04x <= $%02x\n", addr, data);
|
//fprintf(stderr, "store $%04x <= $%02x\n", addr, data);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
__asm__("movs r12, %0":: "r"(fp));
|
__asm__("movs r12, %0":: "r"(fp));
|
||||||
}
|
}
|
||||||
|
|
29
test.c
29
test.c
|
@ -20,6 +20,7 @@ void prn(int c) {
|
||||||
|
|
||||||
void cpu6502_dump(uint32_t pc, uint32_t a, uint32_t x, uint32_t y,
|
void cpu6502_dump(uint32_t pc, uint32_t a, uint32_t x, uint32_t y,
|
||||||
uint32_t sp, uint32_t sr) {
|
uint32_t sp, uint32_t sr) {
|
||||||
|
/*
|
||||||
uint32_t fp;
|
uint32_t fp;
|
||||||
__asm__("movs %0, r12": "=r"(fp));
|
__asm__("movs %0, r12": "=r"(fp));
|
||||||
assert(pc < 0x10000);
|
assert(pc < 0x10000);
|
||||||
|
@ -34,6 +35,7 @@ void cpu6502_dump(uint32_t pc, uint32_t a, uint32_t x, uint32_t y,
|
||||||
(sr >> 3) & 1, (sr >> 2) & 1, (sr >> 1) & 1, sr & 1);
|
(sr >> 3) & 1, (sr >> 2) & 1, (sr >> 1) & 1, sr & 1);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
__asm__("movs r12, %0":: "r"(fp));
|
__asm__("movs r12, %0":: "r"(fp));
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t cpu6502_load(uint16_t addr) {
|
uint8_t cpu6502_load(uint16_t addr) {
|
||||||
|
@ -57,16 +59,15 @@ uint8_t cpu6502_load(uint16_t addr) {
|
||||||
// I/O emulation.
|
// I/O emulation.
|
||||||
if (0xc000 == addr) {
|
if (0xc000 == addr) {
|
||||||
keyCount++;
|
keyCount++;
|
||||||
if (keyCount < 100000)
|
if (keyCount < 0x800) {
|
||||||
result = key;
|
result = key;
|
||||||
else if (keyCount & 0xffff)
|
} else if (keyCount & 0xff) {
|
||||||
|
result = key;
|
||||||
|
} else {
|
||||||
|
uint32_t n = (keyCount - 0x800) >> 8;
|
||||||
|
if (n < sizeof(keyString))
|
||||||
|
key = keyString[n] | 0x80;
|
||||||
result = key;
|
result = key;
|
||||||
else {
|
|
||||||
uint32_t n = (keyCount - 100000) >> 16;
|
|
||||||
if (n >= sizeof(keyString))
|
|
||||||
result = key;
|
|
||||||
else
|
|
||||||
result = keyString[n] | 0x80;
|
|
||||||
}
|
}
|
||||||
} else if (0xc010 == addr) {
|
} else if (0xc010 == addr) {
|
||||||
key &= 0x7f;
|
key &= 0x7f;
|
||||||
|
@ -99,18 +100,24 @@ void cpu6502_store(uint16_t addr, uint8_t data) {
|
||||||
x -= 0x28;
|
x -= 0x28;
|
||||||
y += 0x08;
|
y += 0x08;
|
||||||
}
|
}
|
||||||
if (y < 24)
|
if (y < 24) {
|
||||||
printf("\e[%d;%dH%c", y + 2, x + 1, ascii[data & 0x3f]);
|
fprintf(stdout, "\e[%d;%dH%c", y + 7, x + 1, ascii[data & 0x3f]);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
} else if ((0x0300 <= addr && addr <= 0x03ff) ||
|
} else if ((0x0300 <= addr && addr <= 0x03ff) ||
|
||||||
(0x0900 <= addr && addr <= 0x0fff)) {
|
(0x0900 <= addr && addr <= 0x0fff)) {
|
||||||
// Fake memory impl to make it run on low memory chip.
|
// Fake memory impl to make it run on low memory chip.
|
||||||
last = data;
|
last = data;
|
||||||
} else if (0x1000 <= addr & addr < 0xcfff) {
|
} else if (0x1000 <= addr & addr < 0xbfff) {
|
||||||
// Bus error due to minimum memory installation.
|
// Bus error due to minimum memory installation.
|
||||||
return;
|
return;
|
||||||
fprintf(stdout, "\e[1;1Hinvalid store $%04x\n", addr);
|
fprintf(stdout, "\e[1;1Hinvalid store $%04x\n", addr);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
abort();
|
abort();
|
||||||
|
} else if (0xc000 <= addr & addr < 0xcfff) {
|
||||||
|
// I/O emulation.
|
||||||
|
if (0xc000 == addr)
|
||||||
|
key = data;
|
||||||
} else {
|
} else {
|
||||||
// Installed memory.
|
// Installed memory.
|
||||||
mem[addr] = data;
|
mem[addr] = data;
|
||||||
|
|
Loading…
Reference in New Issue