From 5465cc99d28930ede8a0c1607eb54ef669e0a293 Mon Sep 17 00:00:00 2001 From: Takashi Toyoshima Date: Mon, 8 Dec 2014 03:11:03 +0900 Subject: [PATCH] Update test.c to check Apple BASIC behaviors --- Makefile | 2 +- test.c | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 338050a..676ccdc 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ $(ROM).rom: # Test binary that runs on qemu user mode emulation for testing test: 6502.S test.c $(CC) -mthumb -static $(FRAMEPTR) test.c 6502.S -o test && \ - reset && qemu-arm test 2> log + qemu-arm test 2> log # Test binary that runs on qemu user mode emulation for functional tests ftest: 6502.S ftest.c diff --git a/test.c b/test.c index 0785d2d..81765b1 100644 --- a/test.c +++ b/test.c @@ -6,6 +6,8 @@ static uint8_t mem[0x10000]; static uint8_t key = 0x80; +static char keyString[] = "10 print \"hello\"\r20 end\rlist\rrun\r"; +static uint32_t keyCount = 0; static uint8_t last = 0x00; void prn(int c) { @@ -53,10 +55,23 @@ uint8_t cpu6502_load(uint16_t addr) { abort(); } else if (0xc000 <= addr & addr < 0xcfff) { // I/O emulation. - if (0xc000 == addr) - result = key; - if (0xc010 == addr) + if (0xc000 == addr) { + keyCount++; + if (keyCount < 100000) + result = key; + else if (keyCount & 0xffff) + result = key; + else { + uint32_t n = (keyCount - 100000) >> 16; + if (n >= sizeof(keyString)) + result = key; + else + result = keyString[n] | 0x80; + } + } else if (0xc010 == addr) { key &= 0x7f; + result = 0; + } } else { // Installed memory. result = mem[addr];