PPU attribute tables

From NESdev Wiki
Revision as of 06:30, 17 April 2009 by Banshaku (talk | contribs) (Created page with '=== Attribute tables === <div style="float:right"> +---+---+---+---+ | | | | | + D1-D0 + D3-D2 + | | | | | +---+---+---+---+ | | | | | + D5-D4 + D7...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Attribute tables

+---+---+---+---+
|   |   |   |   |
+ D1-D0 + D3-D2 +
|   |   |   |   |
+---+---+---+---+
|   |   |   |   |
+ D5-D4 + D7-D6 +
|   |   |   |   |
+---+---+---+---+

This is admittedly one of the hardest things for a beginner to grasp about the PPU. The last 64 bytes of each nametable (at $23C0, $27C0, $2BC0, and $2FC0) is an "attribute table" related to the preceding nametable. Each byte in the attribute table controls the palette of a 4x4 cell (32x32 pixel) square, and two bits of each byte control the palette of a 2x2 cell (16x16 pixel) area. This is why most NES games used 16x16 metatiles (size of Super Mario Bros. ? block) or 32x32 metatiles (width of SMB pipe).

Nametable tiles are 8x8 pixels, and the $2001 mask is 8 pixels wide, but attribute table tiles are 16x16 pixels. This is why games that use the horizontal or vertical mirroring mode for diagonal scrolling often have color artifacts on one side of the screen (on the right side in Super Mario Bros. 3; on the trailing side of the scroll in Kirby's Adventure; at the top and bottom in Super C).