Set the starting address for NES PPU video-memory writes by sending its high byte first and low byte second. Writing $3F followed by $00 selects address $3F00, the palette area. section 5.13
A palette update follows these steps:
- Write the high address byte ($3F) to PPU_VRAM_ADDRESS2. section 5.13
- Write the low address byte ($00) to select $3F00. section 5.13
- Send each palette value to PPU_VRAM_IO; the address automatically increments after every write. section 5.13
Listing 5.21 Transferring the palette table to video memory (example.s)
#1
lda #%10001000 #2
sta PPU_CONTROL
lda PPU_STATUS
lda #$3F #3
sta PPU_VRAM_ADDRESS2
stx PPU_VRAM_ADDRESS2
ldx #0 #4
loop:
lda palette, x
sta PPU_VRAM_IO
inx
cpx #32
bcc loop
Annotated assembly shows the register sequence used to select $3F00 and transfer 32 palette values. section 5.13
