RGB

Question - what is the RGB palette for the 7800 color space?

Unfortunately there is no definitive RGB palette for the 7800. The colors used by emulators are “best guesses” because the 7800 does not have RGB output. Instead the 7800, like the 2600, 5200 and many other consoles, generates the television signal directly. Instead of RGB, color is expressed as luminance and a color phase values.

As well there are several factors which will affect color reproduction including: the color adjustment in the console, TV color and tint controls, contrast and brightness controls, and monitor color tempature and gamma controls.

There are several ways to create an RGB palette for the 7800:

  • coming up with numbers out of thin air, perhaps based on color descriptions in the programmer's guide
  • manually matching the color on the TV to the PC monitor (tedious, with multiple sources of error)
  • using a video capture card (better, but there are still several error sources and less control)
  • mathmatically, based on established formulas, techical information and logic
The latter was discussed on Stellalist and the following is largely based on that discussion.

First we start with the generally accepted NTSC formulas for RGB to YUV:

Y' = 0.299R' + 0.587G' + 0.114B'
U' = 0.492( B' - Y' )
V' = 0.877( R' - Y' )

The range of R',G',B' and Y' are 0..1 and the ' indicates they are non-linear.

These formulas can be inverted:

R' = Y' + 1.140V'
G' = Y' - 0.3947U' - 0.5808V'
B' = Y' + 2.033U'

Note: because the 7800 generates YUV directly, the RGB values may be outside the range 0..1 in which case they should be clipped to 0 or 1. Multiply by 255 for 24 bit RGB values.

Okay, so now how to get from COLU to Y'U'V'? The answer is:

Y' = ( COLU AND 15 ) * Contrast + Brightness
U' = sat * cos( hue )
V' = sat * sin( hue )
hue = Tint - ( COLU / 16 - 1 ) * Phase
sat = 0 if COLU = $0x, otherwise sat = Color

(The same forumlas are used for PAL, and the same methods can be used to define values. The PAL values will be covered a little later.)

Now the task becomes defining reasonable values for Contrast, Brightness, Tint, Phase and Color. Contrast, Brightness, Tint and Color relate to those controls on the TV, while Phase is controlled by a variable resistor inside the 7800.

The MARIA GPU in the 7800 generates video via 6 output pins: phase shifted colorburst COL, and digital luma SYNC, LM3, LM2, LM1 and LM0. The phase shift for the COL pin is gerated internal to the MARIA via some delay gates selected via a multiplexer (with an output disable when COLU=$0x). SYNC and LM3-0 drive a simple resistor D to A converter. (Note: the pins sink current, so a lower resistance means a higher output voltage.)

On the 7800 SYNC is 8.2Kohm, LUM3 is 10Kohm, LUM2 is 20Kohm, LUM1 is 39Kohm, and LUM0 is 82Kohm. (Note - the TIA in the 7800 is connected to the same resistors which are slightly different than a 2600.) When talking about NTSC video video IRE units are used, where sync = -40 IRE, blank = 0 IRE, black = 7.5 IRE and 100% white = 100 IRE.

Contrast = ( 40 * 8.2 )*(( 1/10 + 1/20 + 1/39 + 1/82 ) / 15 )/( 100 - 7.5 )
Contrast = 0.0444
We also need to account for the 7.5 IRE difference between BLANK and BLACK:
Brightness = -7.5 / ( 100 - 7.5 )
Brightness = -0.081
Unfortunately, this makes the palette very dark. To a certain extent this is unavoidable because of the non-linear Y'. So instead let us assume that SYNC is 47.5 IRE so Y starts from BLACK rather than BLANK. We'll also ignore the minor variation in resistor values.
Contrast = (( 40 + 7.5 ) * 8.2 )*(( 1/10 + 1/20 + 1/40 + 1/80 ) / 15 )/( 100 - 7.5 )
Contrast = 0.0526
Brightness = 0.0

Because the 7800 uses the same signal to generate both the colorburst and color, the magnitude of both will be the same (40 IRE). Some reference documents I have give the IRE levels for 100% color bars and some calculations show that 100% U' or V' is 185 IRE. Thus

Color = 40 / 185 = 0.2162
The phase of colorbust is 180 degrees, thus normally Tint = 180. Most modern TVs will adjust automatically, but this is something else which can be tweaked.

More importantly is the Phase difference between color values. Ideally this would be 24 degrees, so each color would be distinct. Unfortunately, most 7800s are calibrated initially so that color 15 and color 1 are the same. It's done this way because the adjustment is visual and is quick and easy to do. Maybe it shouldn't be done like that...we're losing 8 colors from the palette. But there's no quick and easy way to precisely adjust so that color 15 has exactly 336 degrees of phase shift relative to color 1. Thus:

Phase = 360 / 14 = 25.714
Note: there are two variable resistors inside the 7800, one for the TIA and one for MARIA. So there can be differences between 7800 and 2600 colors on the same 7800!

Unlike the 2600, the PAL 7800 palette is very similar to NTSC, although there are some differences in the signal which will change the palette slightly.

PAL SYNC is -43 IRE, BLACK is 0 IRE and 100% white is 100 IRE. The LUM resistor values are the same, thus:

Contrast = ( 43 * 8.2 ) * (( 1/10 + 1/20 + 1/40 + 1/80 ) / 15 ) / 100
Contrast = 0.044
Brightness = 0.0
PAL colorburst is 42.86 IRE and 100% U' or V' is 200 IRE, thus
Color = 42.86 / 200 = 0.2143
Comments