interrupt and halt improvements (?)

This commit is contained in:
Alex Janka 2023-02-24 15:05:57 +11:00
parent db57cf58e1
commit 44ad6bdad5
2 changed files with 8 additions and 6 deletions

View file

@ -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()
}

View file

@ -46,10 +46,9 @@ impl Cpu {
}
pub fn exec_next(&mut self) {
if self.halted {
let interrupt_cycles = self.handle_interrupts();
self.increment_timers(interrupt_cycles);
if self.halted {
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 {