Jon Relay's Apple II Info Archives
Video Display Theory
Robert Munafo's Response
From: munafο@gcctеch.cοm Newsgroups: comp.emulators.apple2, comp.sys.apple2.programmer Subject: RGB values for the standard Apple ][ colors Date: Thu, 12 Oct 2000 03:13:33 GMT
I am giving a table of all the lores and hires colors with their values in RGB. First, though there is a bit to explain...
The Apple ][ hardware generates a NTSC composite (luma plus chroma) signal complete with a color burst on the "back porch" of each scanline. The dots for all display modes (text, lores and hires) come from a master 14.31818-MHz clock, which is divided by 4 to produce the color burst. Dots for 40-col text and hires graphics come out at 7.15909 MHz. Dots for 80-col text, lores graphics, and double hires graphics come out at 14.31818 MHz. Although NTSC defines the scanline as 227.5 cycles per scanline (so the phase alternates on alternate scanlines, producing a dithering effect), the Apple rounds it up to 228. (This is why solid bright colors on a monochrome monitor appear as vertical stripes rather than the "tiny checkerboard" pattern you see when watching a TV program on the same monochrome monitor.)
To understand the NTSC standard fully, there are four coordinate systems you have to deal with:
- chroma phase, chroma amplitude and luma
- YIQ
- Y B-Y R-Y
- RGB
The "color burst" signal I just described, plus the positions of some of the coordinate axes of the other systems, are all defined by relative phase angles with respect to each other. I'll skip all the details, but you are invited to read any of the URLs I'm listing at the end if you want to know more (some are dead but cached on Google).
The important things to know for our purposes are:
1. On the Apple ][, all pixels and the color burst are in phase with the master clock. However, they come out as square waves, and the effect of the TV's circuitry (or a composite monitor) is to turn the square wave into the closest matching sine wave.
2. Because all the pixels generated are in phase with the color burst signal, the phase of the sine wave is always 0, 45, 90, 135, 180, 225, 270, or 315. The color burst itself is phase 180. For example, "green" HCOLOR=1 and "light green" COLOR=12 are 50% duty cycle square waves centered at phase 225.
3. The 4 hires colors are all 50% square waves, which gives a chroma amplitude higher than anything in a real TV broadcast. This is why they look so garish. Contrary to what was recently said in the article "Jon Relay's Apple II Info Archives" in the Aug 2000 GS WorldView, these four colors are not the same as the NTSC "+I, +Q, -I and -Q" colors. They are actually 12 degrees lower in phase -- probably not enough to notice, since your tint control is probably a bit off anyway (-:
4. The lores colors are derived a similar way, although two of them (the two grays) are square waves of twice the chroma frequency, and these are "averaged out" to a flat 50% gray by the TV. All of the lores colors are binary combinations of the four primary lores colors, which are the four that appear "dark gray" on a monochrome monitor:
duty cycle phase Red COLOR=1 45 to 135 90 Dark-blue COLOR=2 315 to 45 0 Dark-green COLOR=4 225 to 315 270 Brown COLOR=8 135 to 225 180
If we combine COLOR 4 and COLOR 8, we get COLOR 12: 4 plus 8 = 12. This color is "on" from 135 to 315, which makes a 50% square wave centered on 225. Thus, it appears the same as the HCOLOR=1 described above.
Here is the table. It was used by taking the chroma/luma values and transforming to R-Y and B-Y, then transforming to YUV and finally to RGB. The last step requires a gamma correction for display on an RGB monitor, I used Y to the power of -0.4. For reference, the NTSC "color bars" test pattern colors and the YIQ axis colors are also given.
--chroma-- Color name phase ampl luma -R- -G- -B- black COLOR=0 0 0 0 0 0 0 gray COLOR=5 0 0 50 156 156 156 grey COLOR=10 0 0 50 156 156 156 white COLOR=15 0 0 100 255 255 255 dk blue COLOR=2 0 60 25 96 78 189 lt blue COLOR=7 0 60 75 208 195 255 purple COLOR=3 45 100 50 255 68 253 purple HCOLOR=2 45 100 50 255 68 253 red COLOR=1 90 60 25 227 30 96 pink COLOR=11 90 60 75 255 160 208 orange COLOR=9 135 100 50 255 106 60 orange HCOLOR=5 135 100 50 255 106 60 brown COLOR=8 180 60 25 96 114 3 yellow COLOR=13 180 60 75 208 221 141 lt green COLOR=12 225 100 50 20 245 60 green HCOLOR=1 225 100 50 20 245 60 dk green COLOR=4 270 60 25 0 163 96 aqua COLOR=14 270 60 75 114 255 208 med blue COLOR=6 315 100 50 20 207 253 blue HCOLOR=6 315 100 50 20 207 253 NTSC Hsync 0 0 -40 0 0 0 NTSC black 0 0 7.5 41 41 41 NTSC Gray75 0 0 77 212 212 212 YIQ +Q 33 100 50 255 81 255 NTSC magenta 61 82 36 255 40 181 NTSC red 104 88 28 255 28 76 YIQ +I 123 100 50 255 89 82 NTSC yellow 167 62 69 221 198 121 Color burst 180 40 0 0 4 0 YIQ -Q 213 100 50 51 232 41 NTSC green 241 82 48 12 234 97 NTSC cyan 284 88 56 10 245 198 YIQ -I 303 100 50 0 224 231 NTSC blue 347 62 15 38 65 155
See also
- http://www.ee.washington.edu/conselec/CE/kuhn/ntsc/95x4.htm
- http://www.landfield.com/faqs/apple2/faq/part16/
- http://www-viz.tamu.edu/faculty/parke/ends489f00/notes/sec1_4.html
- http://www.neutralzone.org/home/faqsys/docs/codet
- http://www.belle-nuit.com/archives/videoglossary.html
- http://www.itc-usa.com/noframe/radapclr.htm
- Robert Munafo Apple ][ programmer since 1980!