src/memory/memory.cc
/*
 * Writes the given value to the palette data array, then decodes the value
 * and writes it to the pixel data array. If the value is at a mirrored
 * address, then it is written again to the mirrored position in both arrays.
 *
 * Assumes that the palette has been initialized.
 */
Writes the given value to the palette data array, then decodes the value
and writes it to the pixel data array. If the value is at a mirrored
address, then it is written again to the mirrored position in both arrays.

Assumes that the palette has been initialized.
Writes the given value to the palette data array then decodes the value and writes it to the pixel data array . If the value is at a mirrored address then it is written again to the mirrored position in both arrays . Assumes that the palette has been initialized .
void Memory::PaletteWrite(DoubleWord addr, DataWord val) {
  const DoubleWord kPaletteMirrorAccessMask = 0x03U;
  const DoubleWord kPaletteMirrorBit = 0x10U;
  addr &= PALETTE_ADDR_MASK;
  Pixel pixel_val = palette_->Decode(val);
  pixels_->nes[addr] = val;
  pixels_->emu[addr] = pixel_val;
  if ((addr & kPaletteMirrorAccessMask) == 0) {
    addr ^= kPaletteMirrorBit;
    pixels_->nes[addr] = val;
    pixels_->emu[addr] = pixel_val;
  }
  return;
}
void Memory :: PaletteWrite ( DoubleWord addr , DataWord val ) { const DoubleWord kPaletteMirrorAccessMask = 0x03U ; const DoubleWord kPaletteMirrorBit = 0x10U ; addr &= PALETTE_ADDR_MASK ; Pixel pixel_val = palette_ -> Decode ( val ) ; pixels_ -> nes [ addr ] = val ; pixels_ -> emu [ addr ] = pixel_val ; if ( ( addr & kPaletteMirrorAccessMask ) == 0 ) { addr ^= kPaletteMirrorBit ; pixels_ -> nes [ addr ] = val ; pixels_ -> emu [ addr ] = pixel_val ; } return ; }
Writes the given value to the palette data array, then decodes the value
 and writes it to the pixel data array.
Writes the given value to the palette data array then decodes the value and writes it to the pixel data array .
// Used to check if a palette access needs to be mirrored. // Update the palette and pixel arrays. // Check if the address is mirrored, and update its mirror if it is. // Values whose low 2 bits are zero are mirrored.