fn write8(&mut self, addr: u16, data: u8) {
        match addr {
            0x8000..=0x9FFF => self.vram[(addr as usize) & 0x1FFF] = data,
            0xFE00..=0xFE9F => self.oam[(addr as usize) & 0x00FF] = data,
            0xFF40 => self.registers.control = ControlFlags::from_bits_truncate(data),
            0xFF41 => self.registers.status = data,
            0xFF42 => self.registers.scroll_y = data,
            0xFF43 => self.registers.scroll_x = data,
            0xFF44 => self.registers.ly = data,
            0xFF45 => self.registers.lyc = data,
            0xFF46 => self.registers.dma = data,
            0xFF47 => self.registers.bg_palette = data,
            0xFF48 => self.registers.obj0_palette = data,
            0xFF49 => self.registers.obj1_palette = data,
            0xFF4A => self.registers.window_y = data,
            0xFF4B => self.registers.window_x = data,
            _ => panic!(
                "Attempted to access [WR] PPU memory from an invalid address: {:#X}",
                addr
            ),
        }
    }
/// Handle memory writes to the PPU data registers only, otherwise panic
Handle memory writes to the PPU data registers only, otherwise panic
Handle memory writes to the PPU data registers only otherwise panic
fn write8(&mut self, addr: u16, data: u8) {
        match addr {
            0x8000..=0x9FFF => self.vram[(addr as usize) & 0x1FFF] = data,
            0xFE00..=0xFE9F => self.oam[(addr as usize) & 0x00FF] = data,
            0xFF40 => self.registers.control = ControlFlags::from_bits_truncate(data),
            0xFF41 => self.registers.status = data,
            0xFF42 => self.registers.scroll_y = data,
            0xFF43 => self.registers.scroll_x = data,
            0xFF44 => self.registers.ly = data,
            0xFF45 => self.registers.lyc = data,
            0xFF46 => self.registers.dma = data,
            0xFF47 => self.registers.bg_palette = data,
            0xFF48 => self.registers.obj0_palette = data,
            0xFF49 => self.registers.obj1_palette = data,
            0xFF4A => self.registers.window_y = data,
            0xFF4B => self.registers.window_x = data,
            _ => panic!(
                "Attempted to access [WR] PPU memory from an invalid address: {:#X}",
                addr
            ),
        }
    }
fn write8 ( & mut self , addr : u16 , data : u8 ) { match addr { 0x8000 ..= 0x9FFF => self . vram [ ( addr as usize ) & 0x1FFF ] = data , 0xFE00 ..= 0xFE9F => self . oam [ ( addr as usize ) & 0x00FF ] = data , 0xFF40 => self . registers . control = ControlFlags :: from_bits_truncate ( data ) , 0xFF41 => self . registers . status = data , 0xFF42 => self . registers . scroll_y = data , 0xFF43 => self . registers . scroll_x = data , 0xFF44 => self . registers . ly = data , 0xFF45 => self . registers . lyc = data , 0xFF46 => self . registers . dma = data , 0xFF47 => self . registers . bg_palette = data , 0xFF48 => self . registers . obj0_palette = data , 0xFF49 => self . registers . obj1_palette = data , 0xFF4A => self . registers . window_y = data , 0xFF4B => self . registers . window_x = data , _ => panic ! ( " " addr ) , } }
Handle memory writes to the PPU data registers only, otherwise panic
Handle memory writes to the PPU data registers only otherwise panic
&mut self
addr
u16
data
u8
&mut self
addr
u16
data
u8