From af81d64ee738fc32662fe9cc086d2300cc0ad8f6 Mon Sep 17 00:00:00 2001 From: lyrakisk <24938740+lyrakisk@users.noreply.github.com> Date: Thu, 28 Nov 2024 23:53:41 +0100 Subject: [PATCH] Implement nametable_base() and nmi_enable() --- src/ppu/registers/control.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ppu/registers/control.rs b/src/ppu/registers/control.rs index 88d3568..97f17fa 100644 --- a/src/ppu/registers/control.rs +++ b/src/ppu/registers/control.rs @@ -9,6 +9,16 @@ impl Control { return Control { value }; } + pub fn nametable_base(&self) -> u16 { + match self.value & 0b0000_0011 { + 0 => 0x2000, + 1 => 0x2400, + 2 => 0x2800, + 3 => 0x2c00, + _ => panic!("Not possible") + } + } + pub fn vram_increment(&self) -> u16 { if (self.value & 0b0000_0100) >> 2 == 0 { return 1; @@ -16,6 +26,10 @@ impl Control { return 32; } } + + pub fn nmi_enable(&self) -> bool { + return (self.value & 0b1000_0000) >> 7 == 1 + } } impl Register8 for Control { @@ -27,3 +41,4 @@ impl Register8 for Control { self.value = data; } } +