From b76481b34c5c44ecca706b888d56a1419b666670 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:30 -0300 Subject: [PATCH] chore: don't assume 1cpi when stepping by a frame --- src/emu.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/emu.zig b/src/emu.zig index 2ff3990..74db05d 100644 --- a/src/emu.zig +++ b/src/emu.zig @@ -43,8 +43,9 @@ pub fn run(kind: RunKind, quit: *Atomic(bool), fps: *FpsAverage, sched: *Schedul } pub fn runFrame(sched: *Scheduler, cpu: *Arm7tdmi, bus: *Bus) void { - var cycles: u64 = 0; - while (cycles < cycles_per_frame) : (cycles += 1) { + const frame_end = sched.tick + cycles_per_frame; + + while (sched.tick < frame_end) { sched.tick += 1; _ = cpu.step();