Added -f flag to step through emulation at max possible speed (i.e. without the delay loop)
This commit is contained in:
parent
649b7f8349
commit
a25ad398e8
14
6502-emu.c
14
6502-emu.c
|
@ -19,7 +19,7 @@ void step_delay()
|
||||||
nanosleep(&req, &rem);
|
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;
|
long cycles = 0;
|
||||||
int cycles_per_step = (CPU_FREQ / (ONE_SECOND / STEP_DURATION));
|
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;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
step_delay(); // remove this for more speed
|
if (!fast) step_delay();
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
return;
|
return;
|
||||||
|
@ -70,7 +70,7 @@ int hextoint(char *str) {
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int a, x, y, sp, sr, pc, load_addr;
|
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;
|
long cycles;
|
||||||
int opt;
|
int opt;
|
||||||
|
|
||||||
|
@ -80,13 +80,14 @@ int main(int argc, char *argv[])
|
||||||
cycles = 0;
|
cycles = 0;
|
||||||
load_addr = 0xC000;
|
load_addr = 0xC000;
|
||||||
break_pc = -1;
|
break_pc = -1;
|
||||||
|
fast = 0;
|
||||||
a = 0;
|
a = 0;
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
sp = 0;
|
sp = 0;
|
||||||
sr = 0;
|
sr = 0;
|
||||||
pc = -RST_VEC; // negative implies indirect
|
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) {
|
switch (opt) {
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
|
@ -97,6 +98,9 @@ int main(int argc, char *argv[])
|
||||||
case 'm':
|
case 'm':
|
||||||
mem_dump = 1;
|
mem_dump = 1;
|
||||||
break;
|
break;
|
||||||
|
case 'f':
|
||||||
|
fast = 1;
|
||||||
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
break_pc = hextoint(optarg);
|
break_pc = hextoint(optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -147,7 +151,7 @@ int main(int argc, char *argv[])
|
||||||
init_uart();
|
init_uart();
|
||||||
|
|
||||||
reset_cpu(a, x, y, sp, sr, pc);
|
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;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue