liveBook · Manning

PPU VRAM address register

As explained in Classic Game Programming on the NES: Make your own retro video game

An NES PPU register used to set the VRAM address for subsequent video-memory accesses.

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

How Classic Game Programming on the NES: Make your own retro video game covers it

How deep it goes
Explains two-byte address setup and automatic post-write increment, without covering the alternate increment mode.
Examples
Uses an assembly palette-transfer loop that writes 32 values beginning at VRAM address $3F00.
What you can do after
Operate/configure the register to select a VRAM destination and stream palette values through PPU_VRAM_IO.
How it connects
Connects PPU VRAM addressing with palette data, PPU VRAM I/O, NMI routines, and rendering control.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Classic Game Programming on the NES: Make your own retro video game. The section links point to the parts of the book it draws on.