Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joajfreitas committed Jun 11, 2024
1 parent 335bc33 commit acc1f77
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 2 additions & 2 deletions fpt-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn debug(args: Run) -> Result<()> {
if gameboy.paused() {
break;
}
gameboy.instruction();
gameboy.step();
}
}
}
Expand Down Expand Up @@ -151,7 +151,7 @@ fn run(gb_config: GameboyConfig, args: Run) -> Result<()> {
if args.debug.unwrap_or(false) {
println!("{:#02X}: {:?}", gameboy.cpu().pc(), gameboy.cpu().decode());
}
gameboy.instruction();
gameboy.step();
}
}

Expand Down
2 changes: 1 addition & 1 deletion fpt/src/debugger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Debugger {
impl Debugger {
pub fn new() -> Self {
Self {
breakpoints: vec![Breakpoint::new(0, true)],
breakpoints: Vec::new(),
watchpoints: Vec::new(),
paused: false,
}
Expand Down
9 changes: 8 additions & 1 deletion fpt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,21 @@ impl Gameboy {
&mut self.ppu
}

pub fn instruction(&mut self) -> u32 {
pub fn step(&mut self) -> u32 {
//let cycles = self.cpu.instruction() as u32;
self.cpu.t_cycle();
// TODO: care for double speed mode (need to run half as much dots)
self.ppu.step(1);
1
}

pub fn instruction(&mut self) -> u32 {
let cycles = self.cpu.instruction() as u32;
// TODO: care for double speed mode (need to run half as much dots)
self.ppu.step(cycles);
cycles
}

pub fn debug_cmd(&mut self, cmd: &DebugCmd) -> Option<DebugEvent> {
self.cpu_mut().receive_command(cmd)
}
Expand Down

0 comments on commit acc1f77

Please sign in to comment.