diff --git a/src/memory/io.rs b/src/memory/io.rs index 6dedbc5..4acf357 100644 --- a/src/memory/io.rs +++ b/src/memory/io.rs @@ -195,49 +195,3 @@ pub trait BusAux: BusIO { self.read_arr(0x14e).ok().map(u16::from_be_bytes) } } - -pub mod interrupt { - use super::BusIO; - use bitfield_struct::bitfield; - - /// Interrupt Enable register - const IE: usize = 0xffff; - /// Interrupt Flags register - const IF: usize = 0xff0f; - - #[bitfield(u8)] - #[derive(PartialEq, Eq)] - pub struct Interrupt { - vblank: bool, - lcd: bool, - timer: bool, - serial: bool, - joypad: bool, - #[bits(3)] - _reserved: (), - } - - impl Interrupts for B {} - /// Functionality for working with [Interrupt]s - pub trait Interrupts: BusIO { - /// Gets the set of enabled [Interrupt]s - fn enabled(&self) -> Option { - self.read(IE).map(Interrupt::from_bits) - } - /// Gets the set of raised [Interrupt]s - #[inline] - fn raised(&self) -> Option { - self.read(IF).map(Interrupt::from_bits) - } - /// Raises [Interrupt]s with the provided mask. - fn raise(&mut self, int: Interrupt) { - let flags = self.raised().unwrap_or_default(); - let _ = self.write(IF, flags.into_bits() | int.into_bits()); - } - /// Clears [Interrupt]s with the provided mask. - fn clear(&mut self, int: Interrupt) { - let flags = self.raised().unwrap_or_default(); - let _ = self.write(IF, flags.into_bits() & !int.into_bits()); - } - } -}