perf: don't check scheduler every iteration of runFrame loop
~20fps gain in Pokemon Emerald, nice
This commit is contained in:
parent
8f5d054195
commit
f9bb0460d8
12
src/emu.zig
12
src/emu.zig
|
@ -51,13 +51,15 @@ pub fn runFrame(sched: *Scheduler, cpu: *Arm7tdmi) void {
|
||||||
const frame_end = sched.tick + cycles_per_frame;
|
const frame_end = sched.tick + cycles_per_frame;
|
||||||
|
|
||||||
while (sched.tick < frame_end) {
|
while (sched.tick < frame_end) {
|
||||||
if (cpu.bus.io.haltcnt == .Halt) sched.tick += 1;
|
const next = sched.nextTimestamp();
|
||||||
if (cpu.bus.io.haltcnt == .Execute) cpu.step();
|
if (next > frame_end) break;
|
||||||
cpu.handleDMATransfers();
|
|
||||||
|
|
||||||
while (sched.tick >= sched.nextTimestamp()) {
|
while (sched.tick < next) {
|
||||||
sched.handleEvent(cpu);
|
if (cpu.bus.io.haltcnt == .Execute) cpu.step() else sched.tick += 1;
|
||||||
|
cpu.handleDMATransfers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sched.handleEvent(cpu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue