diff --git a/examples/sdl/src/main.rs b/examples/sdl/src/main.rs index 8f0ef696d9928fd182f430e5f2967d3584ea3d1d..c241329b987dccbc03c0baa84ee26ab1bd918119 100644 --- a/examples/sdl/src/main.rs +++ b/examples/sdl/src/main.rs @@ -5,13 +5,9 @@ fn main() { game_boy.load_boot_default(); for i in 0..37000 { - // runs the CPU clock and determines the number of - // cycles that have advanced for that clock tick - let cycles = game_boy.clock(); - - // calls the clock in the PPU to update its own - // execution lifecycle by one set of ticks - game_boy.ppu_clock(cycles); + // runs the Game Boy clock, this operations should + // include the advance of both the CPU and the PPU + game_boy.clock(); if game_boy.cpu().pc() >= 0x6032 { println!("{}", i); diff --git a/src/gb.rs b/src/gb.rs index 463d819157e33267aee950a0657c47fbee1b6eb1..182ec36f7f6a26ae2966be8dfb53b414fae999c0 100644 --- a/src/gb.rs +++ b/src/gb.rs @@ -13,6 +13,12 @@ impl GameBoy { } pub fn clock(&mut self) -> u8 { + let cycles = self.cpu_clock(); + self.ppu_clock(cycles); + cycles + } + + pub fn cpu_clock(&mut self) -> u8 { self.cpu.clock() }