NTSC video: Difference between revisions
(→Color Tint Bits: Example of how darkening yellows (color 4) makes blue) |
m (→Color Tint Bits: And this is how inconsistent information (such as that in the early docs) gets spread.) |
||
Line 81: | Line 81: | ||
! $2001 || Active phase || Complement | ! $2001 || Active phase || Complement | ||
|- | |- | ||
|| Bit 7 || Color 8 || Color 2 ( | || Bit 7 || Color 8 || Color 2 (blue) | ||
|- | |- | ||
|| Bit 6 || Color 4 || Color A (green) | || Bit 6 || Color 4 || Color A (green) |
Revision as of 14:08, 21 December 2010
Note: This data is preliminary and still being reviewed.
Basics
Master clock is 21.47727273 MHz. Each PPU pixel lasts four clocks. $xy refers to a palette color in the range $00 to $3F.
Scanline Timing
Values in PPU pixels (341 total per scanline).
sync | 25 |
black | 4 |
colorburst | 15 |
black | 5 |
pulse | 1 |
left border (background color) | 15 |
active | 256 |
right border (background color) | 11 |
black | 9 |
Brightness Levels
Voltage levels used by the PPU are as follows - absolute, relative to synch, and normalized between black level and white:
Type | Absolute | Relative | Normalized |
Synch | 0.781 | 0.000 | -0.359 |
Colorburst L | 1.000 | 0.218 | -0.208 |
Colorburst H | 1.712 | 0.931 | 0.286 |
Color 0D | 1.131 | 0.350 | -0.117 |
Color 1D (black) | 1.300 | 0.518 | 0.000 |
Color 2D | 1.743 | 0.962 | 0.308 |
Color 3D | 2.331 | 1.550 | 0.715 |
Color 00 | 1.875 | 1.090 | 0.397 |
Color 10 | 2.287 | 1.500 | 0.681 |
Color 20 | 2.743 | 1.960 | 1.000 |
Color 30 | 2.743 | 1.960 | 1.000 |
$xE/$xF output the same voltage as $1D. $x1-$xC output a square wave alternating between levels for $xD and $x0. Colors $20 and $30 are exactly the same.
Color Phases
111111------ 22222------2 3333------33 444------444 55------5555 6------66666 ------777777 -----888888- ----999999-- ---AAAAAA--- --BBBBBB---- -CCCCCC-----
The color generator is clocked by the rising and falling edges of the ~21.48 MHz clock, resulting in an effective ~42.95 MHz clock rate. There are 12 color square waves, spaced at regular phases. Each runs at the ~3.58 MHz colorburst rate. Color $xY uses the wave shown in row Y from the table. Color burst uses color phase 8 (with voltages listed above).
Color Tint Bits
There are three color modulation channels controlled by the top three bits of $2001. Each channel uses one of the color square waves (see above diagram) and enables attenuation of the video signal when the color square wave is high. A single attenuator is shared by all channels.
$2001 | Active phase | Complement |
---|---|---|
Bit 7 | Color 8 | Color 2 (blue) |
Bit 6 | Color 4 | Color A (green) |
Bit 5 | Color C | Color 6 (red) |
When signal attenuation is enabled by one or more of the channels and the current pixel is a color other than $xE/$xF (black), the signal is attenuated as follows (calculations given for both relative and absolute values as shown in the voltage table above):
relative = relative * 0.746
normalized = normalized * 0.746 - 0.0912
For example, when $2001 bit 6 is true, the attenuator will be active during the phases of color 4. This means the attenuator is not active during its complement (color A), and the screen appears to have a tint of color A, which is green.
Example Waveform
This waveform steps through various grays and then stops on a color.
1.0 +--+ 0.9 | | 0.8 | | 0.7 +--+ | +-+ +-+ 0.6 | | | | | | 0.5 | | | | | | 0.4 +--+ | | | | | 0.3 +--+ | | | | | 0.2 | | | | | | 0.1 | | | | | | 0.0 . +--+ . . . . . +-+ +-+ + . . -0.1 --+ 0D 0F 2D 00 10 30 11
Interactive Demo
The following C source code implements the above described algorithm and displays it on screen with interactive mouse control of phase using SDL.
- nes_ntsc_waveform.c
- Windows executable (requires SDL.dll)
- nes_ntsc_palette.c - a sample NTSC palette generator program