Skip to content
Snippets Groups Projects
Verified Commit 5de8af66 authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

feat: small refactor and some docs added

parent 050c2ca2
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,9 @@ A Game Boy emulator that is written in Rust 🦀. ...@@ -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) * [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) * [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) * [Game Boy CPU Opcodes](https://izik1.github.io/gbops)
### ROMs
* [GitHub - c-sp/gameboy-test-roms](https://github.com/c-sp/gameboy-test-roms) * [GitHub - c-sp/gameboy-test-roms](https://github.com/c-sp/gameboy-test-roms)
### Emulators ### Emulators
......
...@@ -431,7 +431,7 @@ pub struct Cpu { ...@@ -431,7 +431,7 @@ pub struct Cpu {
half_carry: bool, half_carry: bool,
carry: bool, carry: bool,
mmu: Mmu, mmu: Mmu,
clocks: u32, ticks: u32,
} }
impl Cpu { impl Cpu {
...@@ -451,7 +451,7 @@ impl Cpu { ...@@ -451,7 +451,7 @@ impl Cpu {
half_carry: false, half_carry: false,
carry: false, carry: false,
mmu: mmu, mmu: mmu,
clocks: 0, ticks: 0,
} }
} }
...@@ -475,10 +475,10 @@ impl Cpu { ...@@ -475,10 +475,10 @@ impl Cpu {
let (instruction_fn, instruction_size, instruction_str) = instruction; 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); 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)] #[inline(always)]
...@@ -668,7 +668,7 @@ fn jr_nz_i8(cpu: &mut Cpu) { ...@@ -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.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) { fn ld_hl_u16(cpu: &mut Cpu) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment