From a25ad398e89eb9a7c39ec12627da1d04edf56f0b Mon Sep 17 00:00:00 2001 From: Rob McMullen Date: Tue, 19 Dec 2017 14:59:28 -0800 Subject: [PATCH] Added -f flag to step through emulation at max possible speed (i.e. without the delay loop) --- 6502-emu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/6502-emu.c b/6502-emu.c index 599fcc4..d91d159 100644 --- a/6502-emu.c +++ b/6502-emu.c @@ -19,7 +19,7 @@ void step_delay() nanosleep(&req, &rem); } -void run_cpu(long cycle_stop, int verbose, int mem_dump, int break_pc) +void run_cpu(long cycle_stop, int verbose, int mem_dump, int break_pc, int fast) { long cycles = 0; int cycles_per_step = (CPU_FREQ / (ONE_SECOND / STEP_DURATION)); @@ -37,7 +37,7 @@ void run_cpu(long cycle_stop, int verbose, int mem_dump, int break_pc) goto end; } } - step_delay(); // remove this for more speed + if (!fast) step_delay(); } end: return; @@ -70,7 +70,7 @@ int hextoint(char *str) { int main(int argc, char *argv[]) { int a, x, y, sp, sr, pc, load_addr; - int verbose, interactive, mem_dump, break_pc; + int verbose, interactive, mem_dump, break_pc, fast; long cycles; int opt; @@ -80,13 +80,14 @@ int main(int argc, char *argv[]) cycles = 0; load_addr = 0xC000; break_pc = -1; + fast = 0; a = 0; x = 0; y = 0; sp = 0; sr = 0; pc = -RST_VEC; // negative implies indirect - while ((opt = getopt(argc, argv, "vima:b:x:y:r:p:s:g:c:l:")) != -1) { + while ((opt = getopt(argc, argv, "vimfa:b:x:y:r:p:s:g:c:l:")) != -1) { switch (opt) { case 'v': verbose = 1; @@ -97,6 +98,9 @@ int main(int argc, char *argv[]) case 'm': mem_dump = 1; break; + case 'f': + fast = 1; + break; case 'b': break_pc = hextoint(optarg); break; @@ -147,7 +151,7 @@ int main(int argc, char *argv[]) init_uart(); reset_cpu(a, x, y, sp, sr, pc); - run_cpu(cycles, verbose, mem_dump, break_pc); + run_cpu(cycles, verbose, mem_dump, break_pc, fast); return EXIT_SUCCESS; }