From 7d79361aca683b8e59d46bbad03f279befd51f11 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Fri, 21 Oct 2022 05:12:50 -0300 Subject: [PATCH] chore(cpu): add inline fn isHalted() --- src/cpu.zig | 4 ++++ src/emu.zig | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cpu.zig b/src/cpu.zig index 416868e..98a5bb2 100644 --- a/src/cpu.zig +++ b/src/cpu.zig @@ -148,6 +148,10 @@ pub const Arm7tdmi = struct { }; } + pub inline fn isHalted(self: *const Self) bool { + return self.bus.io.haltcnt == .Halt; + } + pub fn setCpsr(self: *Self, value: u32) void { if (value & 0x1F != self.cpsr.raw & 0x1F) self.changeModeFromIdx(@truncate(u5, value & 0x1F)); self.cpsr.raw = value; diff --git a/src/emu.zig b/src/emu.zig index d297b4f..e963b25 100644 --- a/src/emu.zig +++ b/src/emu.zig @@ -52,7 +52,7 @@ pub fn runFrame(sched: *Scheduler, cpu: *Arm7tdmi) void { while (true) { while (sched.tick < std.math.min(frame_end, sched.nextTimestamp())) { - if (cpu.bus.io.haltcnt == .Execute) cpu.step() else sched.tick += 1; + if (!cpu.isHalted()) cpu.step() else sched.tick += 1; cpu.handleDMATransfers(); }