fix: reimplement halt fast-forwarding
This commit is contained in:
parent
0939d6d7bc
commit
45fc49b216
15
src/emu.zig
15
src/emu.zig
|
@ -51,14 +51,17 @@ pub fn run(quit: *Atomic(bool), fps: *FpsTracker, sched: *Scheduler, cpu: *Arm7t
|
||||||
pub fn runFrame(sched: *Scheduler, cpu: *Arm7tdmi) void {
|
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 (true) {
|
while (sched.tick < frame_end) {
|
||||||
while (sched.tick < std.math.min(frame_end, sched.nextTimestamp())) {
|
if (!cpu.stepDmaTransfer()) {
|
||||||
if (cpu.stepDmaTransfer()) continue; // DMA is blocking, ticks scheduler
|
if (cpu.isHalted()) {
|
||||||
if (!cpu.isHalted()) cpu.step() else sched.tick += 1;
|
// Fast-forward to next Event
|
||||||
|
sched.tick = sched.queue.peek().?.tick;
|
||||||
|
} else {
|
||||||
|
cpu.step();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sched.tick >= frame_end) break;
|
if (sched.tick >= sched.nextTimestamp()) sched.handleEvent(cpu);
|
||||||
sched.handleEvent(cpu);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue