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.
This commit is contained in:
Brad Grantham 2016-11-20 12:23:42 -08:00
parent eec4926c50
commit 9554f80a00
1 changed files with 17 additions and 6 deletions

View File

@ -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<chrono::system_clock> 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();