diff --git a/README.md b/README.md index 7e8071d410f354129344b385510d401131bc8b93..47c5c1df1a7ef95288938fd85527bad6f5e96229 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,9 @@ A Game Boy emulator that is written in Rust 🦀. * [GameBoy Emulation in JavaScript](http://imrannazar.com/GameBoy-Emulation-in-JavaScript:-The-CPU) * [POKEGB: a gameboy emulator that only plays Pokémon blue](https://binji.github.io/posts/pokegb) * [Game Boy CPU Opcodes](https://izik1.github.io/gbops) + +### ROMs + * [GitHub - c-sp/gameboy-test-roms](https://github.com/c-sp/gameboy-test-roms) ### Emulators diff --git a/src/cpu.rs b/src/cpu.rs index 7edd5dc20da6a83f07549b2552434973aef2d940..88b5d3dc25281d6056a701d2e10639d62f509fb2 100644 --- a/src/cpu.rs +++ b/src/cpu.rs @@ -431,7 +431,7 @@ pub struct Cpu { half_carry: bool, carry: bool, mmu: Mmu, - clocks: u32, + ticks: u32, } impl Cpu { @@ -451,7 +451,7 @@ impl Cpu { half_carry: false, carry: false, mmu: mmu, - clocks: 0, + ticks: 0, } } @@ -475,10 +475,10 @@ impl Cpu { let (instruction_fn, instruction_size, instruction_str) = instruction; - println!("{}\t({:#x})\t${:04x}", instruction_str, opcode, pc); + println!("{}\t(0x{:02x})\t${:04x}", instruction_str, opcode, pc); instruction_fn(self); - self.clocks = self.clocks.wrapping_add(*instruction_size as u32); + self.ticks = self.ticks.wrapping_add(*instruction_size as u32); } #[inline(always)] @@ -668,7 +668,7 @@ fn jr_nz_i8(cpu: &mut Cpu) { } cpu.pc = (cpu.pc as i16).wrapping_add(byte as i16) as u16; - cpu.clocks += 4; + cpu.ticks = cpu.ticks.wrapping_add(4); } fn ld_hl_u16(cpu: &mut Cpu) {