diff options
Diffstat (limited to 'src/test.c')
-rw-r--r-- | src/test.c | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/src/test.c b/src/test.c new file mode 100644 index 0000000..0aec2ce --- /dev/null +++ b/src/test.c @@ -0,0 +1,100 @@ +#include "cpu/core.h" +#include "apple.h" +#include "video/interface.h" +#include <ncurses.h> +#include <unistd.h> + + +/* + README + Assumes that the definition of ROM in apple.c has + been commented out. + + This program is a successor to my 'interpreter.c' + utility, which unfortunately did not keep up with + the progress of my program. + This one works by letting you program the ROM with + whatever machine code you want. + + */ + + + +byte ROM[] = { + // ADC : 0xFF00 + 0x18, + 0xA5, 0x20, + 0x65, 0x22, + 0x85, 0x24, + 0xA5, 0x21, + 0x65, 0x23, + 0x85, 0x25, + // SBC : 0xFF0D + 0x38, + 0xA5, 0x30, + 0xE5, 0x32, + 0x85, 0x34, + 0xA5, 0x31, + 0xE5, 0x33, + 0x85, 0x35 +}; + +int main() { + + + AppleOn(); + + PC = 0xFF0D; + + // ADC Memory + SetMemory(0x0020, 0x31); + SetMemory(0x0021, 0x11); + SetMemory(0x0022, 0xF9); + SetMemory(0x0023, 0x0A); + // SBC Memory + SetMemory(0x0030, 0x34); + SetMemory(0x0031, 0x12); + SetMemory(0x0032, 0x43); + SetMemory(0x0033, 0x01); + + DisplayInit(); + + while(1) { + // Computing + CallInstructionTable(GetMemory(PC), 0); + // Display information + PrintInfo(); + // Wait to proceed + WAIT_ON_USER: + char c = getch(); + mvprintw(28, 4, " "); + // If user presses enter, get input. + if (c == 0x0A) { + address a = 0x0000; + mvprintw(28, 4, "Enter address: 0x"); + for (int i = 3; i >= 0; i--) { + GET_HEX: + c = getch(); + char cc; + if ((c >= '0') && (c <= '9')) { + cc = c-'0'; + } + else if ((c >= 'A') && (c <= 'F')) { + cc = c-'A'+10; + } + else { + goto GET_HEX; + // Direct all complaints to /dev/null + } + mvaddch(28, 24-i, c); + a |= ((address)cc) << 4*i; + } + mvprintw(28, 25, " -> %02x", GetMemory(a)); + goto WAIT_ON_USER; + } + } + + DisplayClose(); + + return 0; +} |