interrupt and halt improvements (?)
This commit is contained in:
parent
db57cf58e1
commit
44ad6bdad5
|
@ -49,15 +49,15 @@ pub struct Interrupts {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Interrupts {
|
impl Interrupts {
|
||||||
pub(super) fn get_enable_register(&self) -> u8 {
|
pub fn get_enable_register(&self) -> u8 {
|
||||||
self.enable_register.as_register()
|
0b11100000 | self.enable_register.as_register()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn set_enable_register(&mut self, data: u8) {
|
pub(super) fn set_enable_register(&mut self, data: u8) {
|
||||||
self.enable_register.set_from_bits(data);
|
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()
|
0b11100000 | self.flag_register.as_register()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,9 @@ impl Cpu {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec_next(&mut self) {
|
pub fn exec_next(&mut self) {
|
||||||
let interrupt_cycles = self.handle_interrupts();
|
|
||||||
self.increment_timers(interrupt_cycles);
|
|
||||||
|
|
||||||
if self.halted {
|
if self.halted {
|
||||||
|
let interrupt_cycles = self.handle_interrupts();
|
||||||
|
self.increment_timers(interrupt_cycles);
|
||||||
self.increment_timers(1);
|
self.increment_timers(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +74,9 @@ impl Cpu {
|
||||||
self.last_instruction_addr
|
self.last_instruction_addr
|
||||||
);
|
);
|
||||||
self.run_and_increment_timers(opcode);
|
self.run_and_increment_timers(opcode);
|
||||||
|
|
||||||
|
let interrupt_cycles = self.handle_interrupts();
|
||||||
|
self.increment_timers(interrupt_cycles);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_opcode(&mut self) -> u8 {
|
fn next_opcode(&mut self) -> u8 {
|
||||||
|
|
Loading…
Reference in a new issue