support halting + fast-forwarding the scheduler on halt

this improves performance dramatically in games that utilize halting, including pokemon ruby and golden sun. in both games, framerate was doubled or trippled in many cases
This commit is contained in:
Matthew Berry 2021-04-29 23:50:48 -07:00
parent b8c64fa69d
commit c584c29fd6
4 changed files with 13 additions and 6 deletions

View file

@ -136,8 +136,10 @@ class CPU
else else
arm_execute instr arm_execute instr
end end
@gba.scheduler.tick 1
else
@gba.scheduler.fast_forward
end end
@gba.tick 1
end end
def check_cond(cond : Word) : Bool def check_cond(cond : Word) : Bool

View file

@ -83,8 +83,4 @@ class GBA
cpu.tick cpu.tick
end end
end end
def tick(cycles : Int) : Nil
scheduler.tick cycles
end
end end

View file

@ -67,7 +67,11 @@ class MMIO
mask = 0xFF00_u16 >> shift mask = 0xFF00_u16 >> shift
@waitcnt.value = (@waitcnt.value & mask) | value.to_u16 << shift @waitcnt.value = (@waitcnt.value & mask) | value.to_u16 << shift
elsif io_addr == 0x301 elsif io_addr == 0x301
@gba.cpu.halted = bit?(value, 7) if bit?(value, 7)
abort "Stopping not supported"
else
@gba.cpu.halted = true
end
elsif not_used? io_addr elsif not_used? io_addr
else else
puts "Unmapped MMIO write ~ addr:#{hex_str index.to_u32}, val:#{hex_str value}".colorize(:yellow) puts "Unmapped MMIO write ~ addr:#{hex_str index.to_u32}, val:#{hex_str value}".colorize(:yellow)

View file

@ -63,4 +63,9 @@ class Scheduler
end end
end end
end end
def fast_forward : Nil
@cycles = @next_event
call_current
end
end end