Skip to content

Commit

Permalink
ignore stop instructions and can now pass cpu_instrs test rom 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanballs committed Sep 17, 2024
1 parent 08d5daf commit 486331c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cpu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ impl CPU {
self.ime = true;
}
}
Instruction::Halt => length = 0,
Instruction::Halt => {
if mmu.ie & mmu.read_byte(0xFF0F) == 0 {
length = 0
}
}
Instruction::Stop => {}

// Unhandled instructions
_ => {
Expand All @@ -151,7 +156,7 @@ impl CPU {
mmu.timer.do_cycles(cycles);

// Handle interrupts
if (self.ime && !just_set_ei) || matches!(instruction, Instruction::Halt) {
if self.ime && !just_set_ei {
let return_pc = if matches!(instruction, Instruction::Halt) {
self.registers.pc + 1
} else {
Expand Down

0 comments on commit 486331c

Please sign in to comment.