fn calc_ppu_palette_addr(mut addr: u16) -> u8 {
    // ignore all but lowest 5 bits (32 palettes)
    addr &= 0b11111;

    // ensure 0x10, 0x14, 0x18, 0x1c are mirrored down
    if matches!(addr, 0x10 | 0x14 | 0x18 | 0x1c) {
        addr &= 0xf;
    }

    addr as u8
}
// assumes 'addr' points to ppu palette memory and applies
// proper mirroring to it. returns a 5-bit index
assumes 'addr' points to ppu palette memory and applies
proper mirroring to it. returns a 5-bit index
assumes ' addr ' points to ppu palette memory and applies proper mirroring to it . returns a 5 - bit index
fn calc_ppu_palette_addr(mut addr: u16) -> u8 {
    // ignore all but lowest 5 bits (32 palettes)
    addr &= 0b11111;
    // ensure 0x10, 0x14, 0x18, 0x1c are mirrored down
    if matches!(addr, 0x10 | 0x14 | 0x18 | 0x1c) {
        addr &= 0xf;
    }
    addr as u8
}
fn calc_ppu_palette_addr ( mut addr : u16 ) -> u8 { // ignore all but lowest 5 bits (32 palettes) addr &= 0b11111 ; // ensure 0x10, 0x14, 0x18, 0x1c are mirrored down if matches ! ( addr 0x10 0x14 0x18 0x1c ) { addr &= 0xf ; } addr as u8 }
assumes 'addr' points to ppu palette memory and applies
proper mirroring to it.
assumes ' addr ' points to ppu palette memory and applies proper mirroring to it .
addr
u16
addr
u16