add cpu usage meter under experimental settings

This commit is contained in:
Matthew Berry 2022-12-12 21:32:10 -08:00
parent 51a9de443a
commit b73bad6ae2
3 changed files with 6 additions and 0 deletions

View file

@ -60,6 +60,8 @@ class GBAController < Controller
ImGui.window("Experimental Settings", pointerof(@experimental_settings)) do
ImGui.checkbox("Attempt waitloop detection", pointerof(@emu.cpu.attempt_waitloop_detection))
ImGui.checkbox("Cache waitloop results", pointerof(@emu.cpu.cache_waitloop_results))
progress = emu.cpu.count_cycles.to_f32 / 280896_f32
ImGui.progress_bar(progress, ImGui::ImVec2.new(0, 0));
end
end
end

View file

@ -134,6 +134,8 @@ module GBA
end
end
property count_cycles = 0
def tick : Nil
unless @halted
instr = read_instr
@ -144,6 +146,7 @@ module GBA
arm_execute instr
end
cycles, @gba.bus.cycles = @gba.bus.cycles, 0
@count_cycles += cycles
if @entered_waitloop
@gba.scheduler.fast_forward
@entered_waitloop = false

View file

@ -49,6 +49,7 @@ module GBA
end
def run_until_frame : Nil
cpu.count_cycles = 0
until ppu.frame
cpu.tick
end