From 44ad6bdad5299f7039973bf653dd582004f43283 Mon Sep 17 00:00:00 2001 From: Alex Janka Date: Fri, 24 Feb 2023 15:05:57 +1100 Subject: [PATCH] interrupt and halt improvements (?) --- src/processor/memory/interrupts.rs | 6 +++--- src/processor/mod.rs | 8 +++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/processor/memory/interrupts.rs b/src/processor/memory/interrupts.rs index 9931f8c..eae0946 100644 --- a/src/processor/memory/interrupts.rs +++ b/src/processor/memory/interrupts.rs @@ -49,15 +49,15 @@ pub struct Interrupts { } impl Interrupts { - pub(super) fn get_enable_register(&self) -> u8 { - self.enable_register.as_register() + pub fn get_enable_register(&self) -> u8 { + 0b11100000 | self.enable_register.as_register() } pub(super) fn set_enable_register(&mut self, data: u8) { self.enable_register.set_from_bits(data); } - pub(super) fn get_flag_register(&self) -> u8 { + pub fn get_flag_register(&self) -> u8 { 0b11100000 | self.flag_register.as_register() } diff --git a/src/processor/mod.rs b/src/processor/mod.rs index be5277f..d4ff4c1 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -46,10 +46,9 @@ impl Cpu { } pub fn exec_next(&mut self) { - let interrupt_cycles = self.handle_interrupts(); - self.increment_timers(interrupt_cycles); - if self.halted { + let interrupt_cycles = self.handle_interrupts(); + self.increment_timers(interrupt_cycles); self.increment_timers(1); return; } @@ -75,6 +74,9 @@ impl Cpu { self.last_instruction_addr ); self.run_and_increment_timers(opcode); + + let interrupt_cycles = self.handle_interrupts(); + self.increment_timers(interrupt_cycles); } fn next_opcode(&mut self) -> u8 {