From ecde36b995274870f0c4e5feaff55c4e52f78231 Mon Sep 17 00:00:00 2001 From: John Date: Tue, 9 Jul 2024 01:42:55 -0500 Subject: [PATCH] io: Remove interrupt circuitry (it doesn't belong there anyway) --- src/memory/io.rs | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) 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()); - } - } -}