fix ie behaviour

This commit is contained in:
Alex Janka 2023-02-27 17:26:32 +11:00
parent 6d2cab2d87
commit 0c0c42e8ba

View file

@ -40,21 +40,32 @@ pub enum Interrupt {
Joypad, Joypad,
} }
#[derive(Default)]
pub struct Interrupts { pub struct Interrupts {
// 0xFFFF // 0xFFFF
enable_register: InterruptRegister, enable_register: InterruptRegister,
enable_register_unused: u8,
// 0xFF0F // 0xFF0F
flag_register: InterruptRegister, flag_register: InterruptRegister,
} }
impl Default for Interrupts {
fn default() -> Self {
Self {
enable_register: Default::default(),
enable_register_unused: 0b11100000,
flag_register: Default::default(),
}
}
}
impl Interrupts { impl Interrupts {
pub fn get_enable_register(&self) -> u8 { pub fn get_enable_register(&self) -> u8 {
0b11100000 | self.enable_register.as_register() self.enable_register_unused | 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);
self.enable_register_unused = data & 0b11100000;
} }
pub fn get_flag_register(&self) -> u8 { pub fn get_flag_register(&self) -> u8 {