Notes on Video Output


A composite color television signal is actually made up of three separate signals: luminance, chrominance (color), and sound. The original NTSC television standard allowed a bandwidth of 6MHz from one channel to the next. Most of that space is taken up by the luminance signal, which is an amplitude-modulated signal. The sound channel is a frequency-modulated signal at the high end of the bandwidth. The sound isn't important for the rest of the video discussion.

Vertical blank and horizontal blank are integrated into the luminance signal. Luminance is actually white at an amplitude of 0, and black at full amplitude. During the blanking periods, pulses are generated at higher than normal black amplitudes. Television receivers can lock onto these pulses to synchronize the vertical and horizontal hold. A typical scan line of black and white video might look something like this (drawing is not to scale; I'm a terrible freehand artist):

Luminance Signal

When color was introduced, it had to be designed so that the black and white portion of the signal would remain the same, even though color televisions use a triad of red, green, and blue to make color. So instead of creating three separate RGB signals, the HSB (Hue-Saturation-Brightness) model was developed. The hue and saturation would be combined into a new signal that is squeezed between the luminance and audio signals.

There are two ways of looking at how the hue and saturation are combined. The first view, which makes the resulting signal easier to understand, is that it's both phase-shifted and amplitude-modulated. The amplitude of the signal determines the color saturation, and the phase determines the hue. Thus, if the amplitude of the color signal is 0, you have no saturation and the result is the same as a black and white signal.

In order to see how this relates to CTIA, it is necessary to picture the chrominance signal added to the luminance signal. In order to keep the signals distinct, television receivers are designed to ignore fluctuations in the luminance signal above a certain frequency. The chrominance signal is defined at a frequency of 3.58MHz. Therefore, when the luminance signal is extracted it is taken to be the average amplitude over a period of one or more chrominance cycles. Now, according to De Re Atari, CTIA is able to change the luminance signal at a rate of 7.16MHz when it is displaying one of ANTIC's luminance-only modes. So if you have a display line that changes the luminance from 0 to 14 and back repeatedly, you are actually simulating a constant 3.58MHz waveform, thus tricking the television into believing that it actually has a chrominance signal with a constant amplitude.

Alternating Luminance

Luminance signal alternating 0's and 1's

Constant Chrominance

Constant chrominance signal

The hue is determined by the phase shift of the chrominance signal, but to determine the phase there must be a reference signal. This reference is provided in the form of a "color burst", which is a fixed-phase chrominance signal of at least 8 cycles performed during each horizontal blank period. The difference between the high points of the chrominance signal in relation to those of the color burst determines the hue that will be shown. This explains why you get two different colors depending on whether your display line has points drawn on even pixels or on odd pixels. It also shows that drawing the line just a fraction of a pixel off can dramatically change the hue. Compare the output of the original CTIA chips with the newer GTIA chips.

In order to learn exactly what colors are produced, however, you must change your view of the chrominance signal from a phase-shifted signal to two separate amplitude-only signals that are superimposed. This is achieved by keeping the signals at the same frequency of 3.58MHz, but shifting one signal by 90º with respect to the other so that the peak value of either signal coincides with the 0 value of the other, as follows:

R-Y and B-Y Reference Signals

The magenta curve represents the combined color signal. Every 90º, the signal can be sampled with respect to one of the two reference signals to find the amplitude of that signal. As shown in the diagram, the red amplitude is found at the red lines and inverted at the cyan lines, and the blue amplitude is found at the blue lines and inverted at the yellow lines. To achieve the translation of B/W luminance into RGB levels, the reference signals above are used to generate and decode two difference signals: R-Y and B-Y, which represent the amplitude difference between overall luminance (Y) and the red and blue colors. Since we now know the amount of red and blue that contribute to the overall luminance, green can be computed from the luminance left over. That completes the RGB signal.

At this point, it is worth noting that since Atari's luminance signal changes at 7.18MHz, each cycle covers 180º of the color signal. That means that it always covers two adjacent peaks of the R-Y and B-Y references. It just so happens that the CTIA chip covers [-(R-Y), +(B-Y)] and [+(R-Y), -(B-Y)], and GTIA covers [+(B-Y), +(R-Y)] and [-(B-Y), -(R-Y)]. This fact lets us compute precisely what colors will result from oscillating the luminance at any given levels. But first, we need some formulas.

In determining the relationship between RGB color and Black and White, it was determined that each color contributes the following amount to the overall brightness:

Red 30.0%
(3/10)
Green 58.9%
(53/90)
Blue 11.1%
(1/9)

The RGB components are computed from the input signals according to the following formulas (where Y indicates luminance):

R = Y + (R-Y)
G = Y - (27/53)(R-Y) - (10/53)(B-Y)
B = Y + (B-Y)

Using these equations, we can now determine what colors will result with alternating luminances. For example, using a luminance-only mode with a black background and a foreground color E, the television is tricked into thinking the luminance is at 7 and there is a color signal with an equivalent saturation level. The possible colors are:

Color R G B
CTIA orange 100% 34% 0%
CTIA cyan 0% 84% 100%
GTIA green 0% 85% 0%
GTIA magenta 100% 15% 100%

(By the way, have you noticed on the old Atari 800 demo program how it used to make accurate colors for the simulated computer screen and console buttons in graphics mode 8? That was CTIA cyan and CTIA orange. The same colors were also used in Choplifter to make the american flag at the embassy. I wonder what country uses a green and purple flag?)

Now we must revert to the model of a single phase-shifted single in order to discuss the concept of hue. Although chrominance is actually made up of separate R-Y and B-Y signals, it is convenient to think of the addition of these signals as a single waveform that shifts phase to create a continuous range of hues. It also appears to be the only explanation of how CTIA/GTIA generates colors. As shown on the color wheel on the left, pure red is not exactly at 90º and pure blue is not at exactly 180º. This is because green must be extrapolated from the R-Y and B-Y signals. When you select a color on the Atari, C/GTIA actually converts the hue to a phase shift of its chrominance signal. I haven't verified the exact formula yet, but it's something like 30º × hue - 52.5º for hues from 1-15. The approximate 'angles' for the principle colors are:


Yellow Red Magenta Blue Cyan Green
7.1º 66.8º 135º 187.1º 246.8º 315º
2, 14 4 6 8 10 12

If we use the hue phase shift (Ø) and the saturation level (S) in the previous RGB equations, the new equations become (pretending Ø is the greek letter Theta):

R = Y + S × sin Ø
G = Y - (27/53) × S × sin Ø + (10/53) × S × cos Ø
B = Y - S × cos Ø

Atari Color Table I've generated an approximation of Atari's 128 colors based on a simplistic set of equations about the luminance and saturation levels:


atari_colors.gif Finally, thanks to my NeXT computer, I have a screen capture of the actual colors generated by an Atari with a GTIA chip for comparison:


Now we finally get the the hard part: what kind of artifacting is done on the boundary between two arbitrary colors? The simple equations given above no longer suffice, because now you have to account for the transition of the chrominance signal from one saturation level to another with a difference in phase shift, plus the effect of all that on the perceived luminance level. Depending on the colors involved, this may result in a band that's lighter or darker than either of the surrounding colors, and less noticeably, a change in hue.


Back to Atari page Back to Atari Technical Information page