A pixel on the NES is a 6-bit colour number. The PPU makes the video signal from it directly, so there is no single “true” RGB value for a colour: it depends on the television. The RGB numbers below are the wiki’s approximations. They follow the NESdev Wiki pages named under Sources.
Palette RAM
- Palette RAM is 32 bytes at
$3F00to$3F1F, mirrored through$3F00to$3FFF. Background palettes 0 to 3 are at$3F00,$3F04,$3F08,$3F0C. Sprite palettes are at$3F10,$3F14,$3F18,$3F1C. Each palette has 4 colours. - Each byte holds a 6-bit colour number.
- Entry 0 of each palette is transparent, so its colour is normally unused. Entry 0 of palette 0 is the backdrop colour, shown wherever background and sprites are both transparent. Entry 0 is shared between background and sprite palettes:
$3F10is the same storage as$3F00,$3F14as$3F04,$3F18as$3F08,$3F1Cas$3F0C. - One element on screen uses one palette: for the background usually a 16 × 16 pixel area (as small as 8 × 1 with help from a mapper), for a sprite the whole 8 × 8 or 8 × 16 sprite.
- The pixel’s 5-bit palette RAM index is
SAAPP:Sbackground (0) or sprite (1),AAthe palette from the attributes,PPthe pixel value from the tile pattern. - With rendering off and
vpointing into palette RAM the colour at that address is drawn instead of the backdrop (the “backdrop override”). Updating palettes outside vblank can therefore flash the colour on screen. See PPU rendering sequence.
Hue and value
5 bit 0
-------
VV HHHH
|| ||||
|| ++++- Hue (phase: sets the NTSC/PAL chroma)
++------ Value (voltage: sets the luma)
- Hue
$0is light grey,$1to$Crun from blue through red and green to cyan,$Dis dark grey,$Eand$Fare black (the same as$1D). The usual code for black is$0F. - The 2C03 (PlayChoice-10) and 2C05-99 (Famicom Titler) RGB PPUs show hue
$Das black. The 2C04 PPUs of many Vs. System games have completely different palettes, as copy protection. - Do not use colour
$0Don the 2C02: it gives a “blacker than black” signal that can upset some televisions. - Names the wiki suggests. Luma:
$0Fblack,$00dark grey,$10light grey,$20white; rows$01–$0Cdark,$11–$1Cmedium,$21–$2Clight,$31–$3Cpale. Hues:$x0grey,$x1azure,$x2blue,$x3violet,$x4magenta,$x5rose,$x6red,$x7orange,$x8yellow,$x9chartreuse,$xAgreen,$xBspring,$xCcyan. Nearest colours to the 16 RGBI colours:$0Fblack,$02navy,$1Agreen,$1Cteal,$06maroon,$14purple,$18olive,$10silver,$00grey,$12blue,$2Alime,$2Caqua,$16red,$24fuchsia,$28yellow,$30white.
The NTSC signal
The 2C02 makes composite video itself. Its master clock is 21.47727273 MHz and the colour generator runs on both edges of it (about 42.95 MHz). One PPU pixel lasts eight colour-generator clocks (four master clocks, about 186 ns). The video output is delayed by one pixel.
Voltage levels
Measured into a terminated 75 ohm input (about 10 mV noise, so about ±2 IRE). The value is the level of the colour’s “low” and “high” part: colours $x1 to $xC are a square wave between the levels of $xD and $x0. $xE and $xF equal $1D. $20 and $30 are the same.
| Signal | Level (mV) | IRE ($1D = 0) |
|---|---|---|
| Sync | 48 | -37 |
| Colour burst low | 148 | -23 |
$0D | 228 | -12 |
$1D (black) | 312 | 0 |
| Colour burst high | 524 | 30 |
$2D | 552 | 34 |
$00 | 616 | 43 |
$10 | 840 | 74 |
$3D | 880 | 80 |
$20 | 1100 | 110 |
$0D with emphasis | 192 | -17 |
$1D with emphasis | 256 | -8 |
$2D with emphasis | 448 | 19 |
$00 with emphasis | 500 | 26 |
$10 with emphasis | 676 | 51 |
$3D with emphasis | 712 | 56 |
$20 with emphasis | 896 | 82 |
Standard video (not NES) uses: peak white 120 IRE, white 100 IRE (714 mV), colour burst high 20 IRE (143 mV), black 7.5 IRE (53.6 mV), blanking 0, colour burst low -20 IRE (-143 mV), sync -40 IRE (-286 mV). US NTSC has a “setup” (black above blanking). Japanese NTSC has none, so the same console looks slightly darker and more contrasty on a US set. On the PPU the blanking level equals the level of $0F black. When greyscale is on, all colours $x1 to $xD are treated as $x0; this extends to the first pixel of the border, which acts as a sync pulse on every visible line.
Colour phases
There are 12 colour square waves, evenly spaced in phase, each at the 3.58 MHz subcarrier rate. Colour $xY uses the wave numbered Y (the diagram is one row per hue, over 12 half-clocks; - is the low level):
$x1 111111------ $x7 ------777777
$x2 22222------2 $x8 -----888888-
$x3 3333------33 $x9 ----999999--
$x4 444------444 $xA ---AAAAAA---
$x5 55------5555 $xB --BBBBBB----
$x6 6------66666 $xC -CCCCCC-----
The NTSC colour burst has the same phase as wave 8 (pure -U). The PAL 2C07 burst phase is $x7, which shifts hues by -15 degrees against the 2C02.
Line layout
A line is 341 pixels. In standard NTSC a line is 227.5 subcarrier cycles (341.25 pixels) and a field 262.5 lines. The NES makes 227⅓ cycles a line and always 262 lines, so the fields draw on top of each other (“240p”).
| Part of a visible line (rows 0 to 239) | Starts at pixel | Length |
|---|---|---|
| Horizontal sync | 277 | 25 |
| Back porch (blank) | 302 | 4 |
| Colour burst | 306 | 15 |
| Back porch, continued (blank) | 321 | 5 |
| Pulse (backdrop in greyscale) | 326 | 1 |
| Left border (backdrop) | 327 | 15 |
| Active picture | 1 | 256 |
| Right border (backdrop) | 257 | 11 |
| Front porch (blank) | 268 | 9 |
Other rows: rows 240 and 241 have the bottom border (backdrop) from pixel 327 for 282 pixels (the vblank flag is set on row 241); rows 242 to 244 are blank after the burst; rows 245 to 247 carry the vertical blanking pulse (pixel 277, 318 long) with a serration at pixel 254 (32 long); rows 248 to 261 are blank (vblank is cleared on row 261). Rows 242 to 261 have the same horizontal sync, porch and burst as above. On odd frames with rendering on, row 261 ends with a 14-pixel left border.
Colour emphasis
Bits 7, 6 and 5 of PPUMASK ($2001) are the emphasis (tint) bits. Each enables an attenuator that is active while one colour square wave is high. The attenuator is shared and active for 6 of 12 half-clocks if one bit is set, 10 if two bits are set, 12 if all three are set.
| PPUMASK bit | Active wave (NTSC) | Diagram | Complement (the visible tint) |
|---|---|---|---|
| 7 | 8 | -----888888- | wave 2, blue |
| 6 | 4 | 444------444 | wave A, green |
| 5 | C | -CCCCCC----- | wave 6, red |
- Each bit emphasises one colour while darkening the other two. Bit 5 is red on NTSC and green on PAL and Dendy; bit 6 is green on NTSC and red on PAL and Dendy; bit 7 is blue on all.
- Emphasis does not change the black of columns
$Eand$F(so$0Fis untouched), but does change every other colour, including$1Dand the greys of column$D. - The attenuated absolute voltage is on average 0.816328 times the plain one.
- Emphasis works independently of greyscale (PPUMASK bit 0).
- The RGB PPUs differ: they force the matching channel to full brightness instead of darkening the others. A few games that set all three bits to darken everything turn the screen white on those PPUs.
Decoding the signal to RGB
The PPU draws the composite waveform directly, so it is decoded as if it had been encoded from YUV. One way (televisions differ):
- Luma Y: low-pass filter (or comb filter) the signal.
- Chroma: multiply the signal by a subcarrier reference locked to the colour burst to get U, and by the same reference delayed 90 degrees to get V, then filter. Multiply U and V by 2 to correct the saturation (the mean of sin² is 0.5). To follow SMPTE 170M further, scale by
(40/140) / (burst high - burst low). - YUV to RGB:
R = Y + V × 1.139883,G = Y - U × 0.394642 - V × 0.580622,B = Y + U × 2.032062. - Normalise each channel: black point = level of
$0F+ 7.5/140 (or just the level of$0Ffor sets without setup), white point = level of$0F+ 100/140 (or the level of$20).C = (C - black) / (white - black), then clip to 0 to 1. - Quantise:
C8 = (int)(C × 255), after a colour-space correction matrix if the display’s primaries are not sRGB.
The forward matrix is Y = 0.299 R + 0.587 G + 0.114 B, U = (-0.299 R - 0.587 G + 0.886 B) × 0.492111, V = (0.701 R - 0.587 G - 0.114 B) × 0.877283. YIQ is the same with U and V rotated by 33 degrees; it does not change the hue. The real picture varies with the mismatch of impedance (which causes differential phase distortion: bright colours lose saturation and shift in hue), the set’s hue and saturation controls, its decoder and its phosphors.
RGB values
Columns: 2C02 US and 2C02 JP (NTSC; the wiki’s palettes made with the tool “pally”; the US one assumes the 7.5 IRE setup, the Japanese one does not), 2C07 (PAL), 2C03 / 2C05 (the three-digit RGB number from the PPU’s lookup table, each digit 0 to 7 for red, green, blue; the 8-bit value is 255 × digit / 7) and 2C05-99 (the Famicom Titler’s composite output, 8-bit hex). Colours $0D to $0F, $1D to $1F and so on are black except as shown.
| # | 2C02 US | 2C02 JP | 2C07 | 2C03/2C05 | 2C05-99 |
|---|---|---|---|---|---|
| $00 | 575757 | 626262 | 626262 | 333 | 6E6E6E |
| $01 | 000C8E | 001C95 | 002365 | 014 | 0F225C |
| $02 | 0800A6 | 1904AC | 0D107F | 006 | 0B0E7B |
| $03 | 340096 | 42009D | 2B017F | 326 | 6958A1 |
| $04 | 550061 | 61006B | 450065 | 403 | 621B52 |
| $05 | 630015 | 6E0025 | 540037 | 503 | 7A2258 |
| $06 | 5A0000 | 650500 | 540501 | 510 | 7F3720 |
| $07 | 3C0E00 | 491E00 | 451500 | 420 | 734F26 |
| $08 | 112800 | 223700 | 2B2800 | 320 | 5B4920 |
| $09 | 003B00 | 004900 | 0D3700 | 120 | 2A3C14 |
| $0A | 004200 | 004F00 | 003F00 | 031 | 235731 |
| $0B | 003A05 | 004816 | 003E01 | 040 | 2E7326 |
| $0C | 002652 | 00355E | 003337 | 022 | 173B3C |
| $0D | 000000 | 000000 | 000000 | 000 | 000000 |
| $0E | 000000 | 000000 | 000000 | 000 | 000000 |
| $0F | 000000 | 000000 | 000000 | 000 | 000000 |
| $10 | A5A5A5 | ABABAB | ABABAB | 555 | B8B8B8 |
| $11 | 0041D9 | 0C4EDB | 1151AA | 036 | 30649C |
| $12 | 2F1EFF | 3D2EFF | 3438CE | 027 | 2649A5 |
| $13 | 6704F2 | 7115F3 | 5C23CE | 407 | 6C29A6 |
| $14 | 9400B4 | 9B0BB9 | 7F19AA | 507 | 842FAB |
| $15 | AA0057 | B01262 | 931A6C | 704 | AB3378 |
| $16 | A31800 | A92704 | 932824 | 700 | A32920 |
| $17 | 803900 | 894600 | 7F3F00 | 630 | AD793E |
| $18 | 4B5B00 | 576600 | 5C5800 | 430 | 7E6D32 |
| $19 | 137600 | 237F00 | 346C00 | 140 | 45782C |
| $1A | 008100 | 008900 | 117700 | 040 | 2E7326 |
| $1B | 007923 | 008332 | 007524 | 053 | 439773 |
| $1C | 006288 | 006D90 | 00676C | 044 | 387C7D |
| $1D | 000000 | 000000 | 000000 | 000 | 000000 |
| $1E | 000000 | 000000 | 000000 | 000 | 000000 |
| $1F | 000000 | 000000 | 000000 | 000 | 000000 |
| $20 | FFFFFF | FFFFFF | FFFFFF | 777 | FFFFFF |
| $21 | 4A9FFF | 57A5FF | 61A1FB | 357 | 8FB1D5 |
| $22 | 797EFF | 8287FF | 8489FF | 447 | 9A9AD0 |
| $23 | AF63FF | B46DFF | AD74FF | 637 | BC8AD0 |
| $24 | DD55FF | DF60FF | D069FB | 707 | B23DB6 |
| $25 | F757C2 | F863C6 | E46BBC | 737 | D290D6 |
| $26 | F76A63 | F8746D | E47974 | 740 | CE9B4F |
| $27 | DC8810 | DE9020 | D08F36 | 750 | DAB85A |
| $28 | AEA900 | B3AE00 | ADA812 | 660 | CFCE60 |
| $29 | 78C400 | 81C800 | 84BD12 | 360 | 8BBD4E |
| $2A | 4AD211 | 56D522 | 61C836 | 070 | 57C948 |
| $2B | 2FCF64 | 3DD36F | 4DC674 | 276 | 8FE1D1 |
| $2C | 2FBDC4 | 3EC1C8 | 4DB8BC | 077 | 67D8DA |
| $2D | 414141 | 4E4E4E | 4E4E4E | 000 | 000000 |
| $2E | 000000 | 000000 | 000000 | 000 | 000000 |
| $2F | 000000 | 000000 | 000000 | 000 | 000000 |
| $30 | FFFFFF | FFFFFF | FFFFFF | 777 | FFFFFF |
| $31 | B9DDFF | BEE0FF | C4DDFF | 567 | C8D8EA |
| $32 | CAD1FF | CDD4FF | D1D3FF | 657 | D2C2E5 |
| $33 | DEC6FF | E0CAFF | E1CBFF | 757 | E9C8EA |
| $34 | F0C0FF | F1C4FF | EFC7FF | 747 | DEACE0 |
| $35 | FCC0EE | FCC4EF | F7C8E7 | 755 | E4C3C2 |
| $36 | FDC6CA | FDCACE | F7CDCB | 764 | EDDDB9 |
| $37 | F5D0AA | F5D4AF | EFD6B3 | 772 | F4F49A |
| $38 | E4DD95 | E6DF9C | E1DFA5 | 773 | F6F6AF |
| $39 | D0E892 | D3E99A | D1E7A5 | 572 | C8E98F |
| $3A | BDEEA2 | C2EFA8 | C4ECB3 | 473 | B4E59E |
| $3B | B2EEC0 | B7EFC4 | BCEBCB | 276 | 8FE1D1 |
| $3C | B0E8E3 | B6EAE5 | BCE5E7 | 467 | B2D3E5 |
| $3D | B3B3B3 | B8B8B8 | B8B8B8 | 000 | 000000 |
| $3E | 000000 | 000000 | 000000 | 000 | 000000 |
| $3F | 000000 | 000000 | 000000 | 000 | 000000 |
The 2C02 columns are decoded for a large flat area with the settings the wiki gives (pally.py --skip-plot -cld -phd 4 -blp 7.5 -e for US, the same without -blp 7.5 for Japan); the 2C07 column used -ppu "2C07" -phd 4 --delay-line-filter -e. In the 2C03 table colours $0B and $1A are both 040, and $2B and $3B both 276. The 2C03 has no greys in $2D and $3D. The 2C05 gives the 2C03 palette; it is used in some later Vs. games for copy protection, and swapping PPUCTRL and PPUMASK addresses (A0' = A0 xor (A1 nor A2)) makes it work as a 2C03. The 2C05-99 in the Sharp Famicom Titler feeds an X0858CE converter that lowers the saturation, which is why its column differs; the raw internal palette is believed to equal the 2C03’s. Greyscale on every RGB PPU works as on the 2C02 (it masks colour numbers to column $x0).
The 2C04 variants
The four 2C04 PPUs (RP2C04-0001 to 0004) hold the same master palette in four different orders. No chip was made with the “ordered” layout below, which shows how it relates to the 2C03 (three-digit RGB numbers, rows of 16 as $x0 to $xF):
$0x 333 014 006 326 403 503 510 420 320 120 031 040 022 111 003 020
$1x 555 036 027 407 507 704 700 630 430 140 040 053 044 222 200 310
$2x 777 357 447 637 707 737 740 750 660 360 070 276 077 444 000 000
$3x 777 567 657 757 747 755 764 770 773 572 473 276 467 666 653 760
It adds four greys and six other colours to the 2C03 palette and makes the bright yellow ($37 and $38 there) purer. Each chip’s index maps to the ordered palette like this (the wiki’s lookup tables; repeated black and white entries may map to any equal entry):
RP2C04-0001
35 23 16 22 1C 09 1D 15 20 00 27 05 04 28 08 20
21 3E 1F 29 3C 32 36 12 3F 2B 2E 1E 3D 2D 24 01
0E 31 33 2A 2C 0C 1B 14 2E 07 34 06 13 02 26 2E
2E 19 10 0A 39 03 37 17 0F 11 0B 0D 38 25 18 3A
RP2C04-0002
2E 27 18 39 3A 25 1C 31 16 13 38 34 20 23 3C 0B
0F 21 06 3D 1B 29 1E 22 1D 24 0E 2B 32 08 2E 03
04 36 26 33 11 1F 10 02 14 3F 00 09 12 2E 28 20
3E 0D 2A 17 0C 01 15 19 2E 2C 07 37 35 05 0A 2D
RP2C04-0003
14 25 3A 10 0B 20 31 09 01 2E 36 08 15 3D 3E 3C
22 1C 05 12 19 18 17 1B 00 03 2E 02 16 06 34 35
23 0F 0E 37 0D 27 26 20 29 04 21 24 11 2D 2E 1F
2C 1E 39 33 07 2A 28 1D 0A 2E 32 38 13 2B 3F 0C
RP2C04-0004
18 03 1C 28 2E 35 01 17 10 1F 2A 0E 36 37 0B 39
25 1E 12 34 2E 1D 06 26 3E 1B 22 19 04 2E 3A 21
05 0A 07 02 13 14 00 15 0C 3D 11 0F 0D 38 2D 24
33 20 08 16 3F 2B 20 3C 2E 27 23 31 29 32 2C 09
The greyscale bit has the same effect as on the 2C02: it forces the colour index to the first column, so on the scrambled 2C04 each row collapses to the colours of column $0x of that chip. Games known to work with several 2C04 versions through DIP switches: Atari RBI Baseball, Battle City, Star Luster, Super Sky Kid, Super Xevious, Tetris (Tengen) and TKO Boxing. The wiki’s printed table orders for each 2C04 version list the raw three-digit codes; the lookup tables above are equivalent to them.
Sources
The NESdev Wiki text is available under CC BY-SA 3.0. This page is written in our own words from the raw wikitext kept in samples/nes/sources/hardware. Left out: the PAL video page (composite decoding of PAL, delay-line detail), the wiki’s C++ emulation code and its picture files, the 2C02’s differential phase distortion simulation, and the PAL-specific waveforms.