diff --git a/src/crab/cpu.cr b/src/crab/cpu.cr index 6c2d78f..4655e34 100644 --- a/src/crab/cpu.cr +++ b/src/crab/cpu.cr @@ -136,8 +136,10 @@ class CPU else arm_execute instr end + @gba.scheduler.tick 1 + else + @gba.scheduler.fast_forward end - @gba.tick 1 end def check_cond(cond : Word) : Bool diff --git a/src/crab/gba.cr b/src/crab/gba.cr index d50d69a..4ea8076 100644 --- a/src/crab/gba.cr +++ b/src/crab/gba.cr @@ -83,8 +83,4 @@ class GBA cpu.tick end end - - def tick(cycles : Int) : Nil - scheduler.tick cycles - end end diff --git a/src/crab/mmio.cr b/src/crab/mmio.cr index 4705503..075257c 100644 --- a/src/crab/mmio.cr +++ b/src/crab/mmio.cr @@ -67,7 +67,11 @@ class MMIO mask = 0xFF00_u16 >> shift @waitcnt.value = (@waitcnt.value & mask) | value.to_u16 << shift 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 else puts "Unmapped MMIO write ~ addr:#{hex_str index.to_u32}, val:#{hex_str value}".colorize(:yellow) diff --git a/src/crab/scheduler.cr b/src/crab/scheduler.cr index 9b1d0e0..648918e 100644 --- a/src/crab/scheduler.cr +++ b/src/crab/scheduler.cr @@ -63,4 +63,9 @@ class Scheduler end end end + + def fast_forward : Nil + @cycles = @next_event + call_current + end end