From 9554f80a0085f3285f592bdb54f5de45945f521a Mon Sep 17 00:00:00 2001 From: Brad Grantham Date: Sun, 20 Nov 2016 12:23:42 -0800 Subject: [PATCH] Allow option to free-run 6502 clock -fast command-line option and "fast" debugger command enable 6502 to essentially run as fast as possible. In "fast mode", execute approximately 10 seconds worth of instructions before UI update. Since UI update is probably locked to 60Hz max, upper limit will be 600x normal speed But my guess is (on my Macbook Pro 13 Retina 2013) it's running about 70x, so there's enough overhead to limit execution to ~70MHz. --- apple2e.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/apple2e.cpp b/apple2e.cpp index a93eaa1..6b8b069 100644 --- a/apple2e.cpp +++ b/apple2e.cpp @@ -1430,7 +1430,7 @@ struct CPU6502 void usage(char *progname) { printf("\n"); - printf("usage: %s [-debugger] ROM.bin\n", progname); + printf("usage: %s [-debugger] [-fast] ROM.bin\n", progname); printf("\n"); printf("\n"); } @@ -1596,6 +1596,10 @@ int main(int argc, char **argv) debugging = true; argv++; argc--; + } else if(strcmp(argv[0], "-fast") == 0) { + run_fast = true; + argv += 1; + argc -= 1; } else if(strcmp(argv[0], "-d") == 0) { debug = atoi(argv[1]); argv += 2; @@ -1667,6 +1671,7 @@ int main(int argc, char **argv) if(have_key) { if(key == '') { debugging = true; + printf("enter debugger\n"); clear_strobe(); stop_keyboard(); continue; @@ -1677,11 +1682,16 @@ int main(int argc, char **argv) } chrono::time_point then; - int inst_per_slice = 255750 * millis_per_slice / 1000 * 2; + int inst_per_slice; + if(run_fast) + inst_per_slice = 2557500; + else + inst_per_slice = 255750 * millis_per_slice / 1000 * 2; for(int i = 0; i < inst_per_slice; i++) { - string dis = read_bus_and_disassemble(bus, cpu.pc); - if(debug & DEBUG_DECODE) + if(debug & DEBUG_DECODE) { + string dis = read_bus_and_disassemble(bus, cpu.pc); printf("%s\n", dis.c_str()); + } if(use_fake6502) step6502(); else @@ -1737,9 +1747,10 @@ int main(int argc, char **argv) cpu.nmi(bus); continue; } - string dis = read_bus_and_disassemble(bus, cpu.pc); - if(debug & DEBUG_DECODE) + if(debug & DEBUG_DECODE) { + string dis = read_bus_and_disassemble(bus, cpu.pc); printf("%s\n", dis.c_str()); + } if(use_fake6502) step6502();