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

        // if address points to palette indices
        if addr >= 0x3f00 {
            let addr = super::calc_ppu_palette_addr(addr);
            return unsafe { *self.palettes.get_unchecked(addr as usize) };
        }

        // if address is in the range 0x2000-0x3eff
        if addr >= 0x2000 {
            let addr = super::calc_ppu_nametable_addr_with_mirroring(addr, self.hor_mirroring);
            return unsafe { *self.nametables.get_unchecked(addr as usize) };
        }

        // address is in the range 0-0x1fff (chr ram)
        unsafe { *self.chr_ram.get_unchecked(addr as usize) }
    }
// NOTE: passing addresses higher than 0x3fff will read from palette ram
passing addresses higher than 0x3fff will read from palette ram
passing addresses higher than 0x3fff will read from palette ram
fn read(&mut self, addr: u16, _: i32, _: &mut cpu::Cpu) -> u8 {
        if cfg!(not(test)) {
            debug_assert!(addr <= 0x3fff);
        }
        // if address points to palette indices
        if addr >= 0x3f00 {
            let addr = super::calc_ppu_palette_addr(addr);
            return unsafe { *self.palettes.get_unchecked(addr as usize) };
        }
        // if address is in the range 0x2000-0x3eff
        if addr >= 0x2000 {
            let addr = super::calc_ppu_nametable_addr_with_mirroring(addr, self.hor_mirroring);
            return unsafe { *self.nametables.get_unchecked(addr as usize) };
        }
        // address is in the range 0-0x1fff (chr ram)
        unsafe { *self.chr_ram.get_unchecked(addr as usize) }
    }
fn read ( & mut self , addr : u16 , _ : i32 , _ : & mut cpu :: Cpu ) -> u8 { if cfg ! ( not ( test ) ) { debug_assert ! ( addr 0x3fff ) ; } // if address points to palette indices if addr >= 0x3f00 { let addr = super :: calc_ppu_palette_addr ( addr ) ; return unsafe { * self . palettes . get_unchecked ( addr as usize ) } ; } // if address is in the range 0x2000-0x3eff if addr >= 0x2000 { let addr = super :: calc_ppu_nametable_addr_with_mirroring ( addr , self . hor_mirroring ) ; return unsafe { * self . nametables . get_unchecked ( addr as usize ) } ; } // address is in the range 0-0x1fff (chr ram) unsafe { * self . chr_ram . get_unchecked ( addr as usize ) } }
NOTE: passing addresses higher than 0x3fff will read from palette ram
NOTE : passing addresses higher than 0x3fff will read from palette ram
&mut self
addr
&mut cpu::Cpu
&mut self
addr
&mut cpu::Cpu