fn write(&mut self, addr: u16, val: u8, _: i32, _: &mut cpu::Cpu) {
        if cfg!(not(test)) {
            debug_assert!(addr <= 0x3fff);
        }

        if addr >= 0x3f00 {
            let addr = super::calc_ppu_palette_addr(addr);
            unsafe { *self.palettes.get_unchecked_mut(addr as usize) = val };
            return;
        }

        if addr >= 0x2000 {
            let addr = super::calc_ppu_nametable_addr_with_mirroring(addr, self.hor_mirroring);
            unsafe { *self.nametables.get_unchecked_mut(addr as usize) = val };
            return;
        }

        unsafe { *self.chr_ram.get_unchecked_mut(addr as usize) = val };
    }
// NOTE: passing addresses higher than 0x3fff will write to palette ram
passing addresses higher than 0x3fff will write to palette ram
passing addresses higher than 0x3fff will write to palette ram
fn write(&mut self, addr: u16, val: u8, _: i32, _: &mut cpu::Cpu) {
        if cfg!(not(test)) {
            debug_assert!(addr <= 0x3fff);
        }
        if addr >= 0x3f00 {
            let addr = super::calc_ppu_palette_addr(addr);
            unsafe { *self.palettes.get_unchecked_mut(addr as usize) = val };
            return;
        }
        if addr >= 0x2000 {
            let addr = super::calc_ppu_nametable_addr_with_mirroring(addr, self.hor_mirroring);
            unsafe { *self.nametables.get_unchecked_mut(addr as usize) = val };
            return;
        }
        unsafe { *self.chr_ram.get_unchecked_mut(addr as usize) = val };
    }
fn write ( & mut self , addr : u16 , val : u8 , _ : i32 , _ : & mut cpu :: Cpu ) { if cfg ! ( not ( test ) ) { debug_assert ! ( addr 0x3fff ) ; } if addr >= 0x3f00 { let addr = super :: calc_ppu_palette_addr ( addr ) ; unsafe { * self . palettes . get_unchecked_mut ( addr as usize ) = val } ; return ; } if addr >= 0x2000 { let addr = super :: calc_ppu_nametable_addr_with_mirroring ( addr , self . hor_mirroring ) ; unsafe { * self . nametables . get_unchecked_mut ( addr as usize ) = val } ; return ; } unsafe { * self . chr_ram . get_unchecked_mut ( addr as usize ) = val } ; }
NOTE: passing addresses higher than 0x3fff will write to palette ram
NOTE : passing addresses higher than 0x3fff will write to palette ram
&mut self
addr
u16
val
&mut cpu::Cpu
&mut self
addr
u16
val
&mut cpu::Cpu