From d73fbc827c797a49018aaa477e54d8beebddc7fa Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Thu, 2 Feb 2023 11:00:59 +1100 Subject: [PATCH] move ime_scheduled logic from opcode handler --- src/processor/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 7f5fd78..9464812 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -30,6 +30,14 @@ impl CPU { self.last_instruction_addr = self.reg.pc; let opcode = self.next_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!( "exec {:#4X} from pc: {:#X}", opcode,