diff --git a/examples/sdl/src/main.rs b/examples/sdl/src/main.rs index bc62660b8df0cba899afde803901a48f034355b7..2a5968850e8810d1f67262292f3f8df78626957b 100644 --- a/examples/sdl/src/main.rs +++ b/examples/sdl/src/main.rs @@ -4,7 +4,7 @@ fn main() { let mut game_boy = GameBoy::new(); game_boy.load_boot_default(); - for i in 0..24612 { + for i in 0..24650 { game_boy.clock(); if game_boy.cpu().pc() >= 0x3032 { println!("{}", i); diff --git a/src/cpu.rs b/src/cpu.rs index a28049fd816f545253928c6b0c045f4a67502f98..e15cb36efa05a32cf2a215c49e08e2f6ff83b686 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -619,7 +619,7 @@ impl Cpu { #[inline(always)] fn push_byte(&mut self, byte: u8) { - self.sp -= 1; + self.sp = self.sp.wrapping_sub(1); self.mmu.write(self.sp, byte); } @@ -632,7 +632,7 @@ impl Cpu { #[inline(always)] fn pop_byte(&mut self) -> u8 { let byte = self.mmu.read(self.sp); - self.sp += 1; + self.sp = self.sp.wrapping_add(1); byte } diff --git a/src/mmu.rs b/src/mmu.rs index 3cd912f14b2ccbdd0b46867a18c4bf9fc66fa749..23e74f4a5075f43faca14b58aecf7d6637924f50 100644 --- a/src/mmu.rs +++ b/src/mmu.rs @@ -81,7 +81,7 @@ impl Mmu { } 0xf00 => { if addr >= 0xff80 { - self.ram[(addr & 0x7f) as usize] + self.hram[(addr & 0x7f) as usize] } else { println!("WRITING TO IO control"); 0x00 @@ -137,7 +137,6 @@ impl Mmu { } 0xf00 => { if addr >= 0xff80 { - println!("WRITING TO Zero page"); self.hram[(addr & 0x7f) as usize] = value; } else { println!("WRITING TO IO control");