move ime_scheduled logic from opcode handler

This commit is contained in:
Alex Janka 2023-02-02 11:00:59 +11:00
parent 8fc35fa1e1
commit d73fbc827c

View file

@ -30,6 +30,14 @@ impl CPU {
self.last_instruction_addr = self.reg.pc; self.last_instruction_addr = self.reg.pc;
let opcode = self.next_opcode(); let opcode = self.next_opcode();
self.last_instruction = opcode; self.last_instruction = opcode;
if self.memory.ime_scheduled > 0 {
self.memory.ime_scheduled = self.memory.ime_scheduled.saturating_sub(1);
if self.memory.ime_scheduled == 0 {
self.memory.ime = true;
}
}
verbose_println!( verbose_println!(
"exec {:#4X} from pc: {:#X}", "exec {:#4X} from pc: {:#X}",
opcode, opcode,