Apple II Colors
This is a message I posted while I was doing my work on xapple2. It shows how I worked out the exact RGB values for the Apple ][ colors. The RGB color values are something that emulator developers had hitherto been trying to guess by visual inspection.
From: munafo(at)gcctech(dot)com Newsgroups: comp.emulators.apple2,comp.sys.apple2.programmer Subject: RGB values for the standard Apple ][ colors Date: Thu, 12 Oct 2000 03:13:33 GMTI 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 180If 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 are the starting values (angle, chroma, luma) and final RGB values.
--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
Apple ][ viewed on a TV
In the above image, the Apple ][ was running this Integer BASIC program: 10 GR 20 FOR C = 0 TO 14 30 COLOR= C + 1 40 FOR Y = C * 2 TO C * 2 + 10 50 FOR X = C * 2 TO C * 2 + 10 60 PLOT X,Y 70 NEXT X 80 NEXT Y 90 NEXT C
Top: surface of RGB colour cube
Bottom: closest available Apple ][ colors
IIGS
As seen in this IIGS TechNote, the Apple IIGS defines RGB values for the 16 colors that are different from the ones I've listed above:
..Original Apple ][ values... ..........IIGS values.......... -R- -G- -B- 12-bit -R- -G- -B- black COLOR=0 0 0 0 Black $0000 0 0 0 red COLOR=1 227 30 96 Deep Red $0D03 221 0 51 dk blue COLOR=2 96 78 189 Dark Blue $0009 0 0 153 purple COLOR=3 255 68 253 Purple $0D2D 221 34 221 dk green COLOR=4 0 163 96 Dark Green $0072 0 119 34 gray COLOR=5 156 156 156 Dark Gray $0555 85 85 85 med blue COLOR=6 20 207 253 Medium Blue $022F 34 34 255 lt blue COLOR=7 208 195 255 Light Blue $06AF 102 170 255 brown COLOR=8 96 114 3 Brown $0850 136 85 0 orange COLOR=9 255 106 60 Orange $0F60 255 102 0 grey COLOR=10 156 156 156 Light Gray $0AAA 170 170 170 pink COLOR=11 255 160 208 Pink $0F98 255 153 136 lt green COLOR=12 20 245 60 Light Green $01D0 17 221 0 yellow COLOR=13 208 221 141 Yellow $0FF0 255 255 0 aqua COLOR=14 114 255 208 Aquamarine $04F9 68 255 153 white COLOR=15 255 255 255 White $0FFF 255 255 255The color graphics in the IIGS Apple ][ emulation modes come from a lookup table within the Mega II chip. Apple engineers were able to select any RGB values they wanted (from the same 4,096 color palette as used in the new Super-highres modes, i.e. RGB with 4 bits per component). I suspect they chose values that were more useful (turning the two gray values into Dark Gray and Light Gray), and/or more aesthetically appealing.
See also
Kelin J. Kuhn, Conventional Analog Television - An Introduction
http://www.landfield.com/faqs/apple2/faq/part16/
http://www.grin.net/~cturley/gsezine/GS.WorldView/v2000/Aug/Articles/A2.InfoArchives.Aug.2000.txt
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!
Full Table With Intermediate Values
This table shows all the intermediate steps in the calculation:
QIph, chr, lum: QIph is the phase with respect to the Q and I axes (differs by 180-33 = 147 degrees from the color burst); chr is chroma adjusted when needed to avoid oversaturation; lum is same as starting luma
R-Y, B-Y: chroma/luma values transformed to R-Y and B-Y
Y, U, V: now transformed to YUV
r, g, b: Red, Green, Blue on a scale of 0.0 to 1.0 (but not clipped)
R, G, B: Scaled to byte values (0 through 255); this step requires a gamma correction for display on an RGB monitor, I used Y to the power of -0.3.
Again for reference, the NTSC "color bars" test pattern colors and the YIQ axis colors are also given.
Color name vect chr luma QIph chr lum R-Y B-Y Y U V r g b R G B black COLOR=0 0 0 0 0 0 0 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0 0 0 gray COLOR=5 0 0 50 0 0 50 0.00 0.00 0.50 0.00 0.00 0.50 0.50 0.50 156 156 156 grey COLOR=10 0 0 50 0 0 50 0.00 0.00 0.50 0.00 0.00 0.50 0.50 0.50 156 156 156 white COLOR=15 0 0 100 0 0 100 0.00 0.00 1.00 0.00 0.00 1.00 1.00 1.00 255 255 255 dk blue COLOR=2 0 60 25 0 55 25 0.00 0.28 0.25 0.14 0.00 0.25 0.20 0.49 96 78 189 lt blue COLOR=7 0 60 75 0 55 75 0.00 0.28 0.75 0.14 0.00 0.75 0.70 0.99 208 195 255 purple COLOR=3 45 100 50 12 100 50 0.35 0.35 0.50 0.17 0.31 0.93 0.22 0.81 255 68 253 purple HCOLOR=2 45 100 50 12 100 50 0.35 0.35 0.50 0.17 0.31 0.93 0.22 0.81 255 68 253 red COLOR=1 90 60 25 57 55 25 0.27 -0.00 0.25 -0.00 0.24 0.59 0.08 0.25 227 30 96 pink COLOR=11 90 60 75 57 55 75 0.27 -0.00 0.75 -0.00 0.24 1.09 0.58 0.75 255 160 208 orange COLOR=9 135 100 50 102 100 50 0.35 -0.35 0.50 -0.17 0.31 0.93 0.34 0.19 255 106 60 orange HCOLOR=5 135 100 50 102 100 50 0.35 -0.35 0.50 -0.17 0.31 0.93 0.34 0.19 255 106 60 brown COLOR=8 180 60 25 147 55 25 -0.00 -0.27 0.25 -0.14 -0.00 0.25 0.30 0.01 96 114 3 yellow COLOR=13 180 60 75 147 55 75 -0.00 -0.27 0.75 -0.14 -0.00 0.75 0.80 0.51 208 221 141 lt green COLOR=12 225 100 50 192 100 50 -0.35 -0.35 0.50 -0.17 -0.31 0.07 0.78 0.19 20 245 60 green HCOLOR=1 225 100 50 192 100 50 -0.35 -0.35 0.50 -0.17 -0.31 0.07 0.78 0.19 20 245 60 dk green COLOR=4 270 60 25 237 55 25 -0.27 0.00 0.25 0.00 -0.24 -0.09 0.42 0.25 0 163 96 aqua COLOR=14 270 60 75 237 55 75 -0.27 0.00 0.75 0.00 -0.24 0.41 0.92 0.75 114 255 208 med blue COLOR=6 315 100 50 282 100 50 -0.35 0.35 0.50 0.17 -0.31 0.07 0.66 0.81 20 207 253 blue HCOLOR=6 315 100 50 282 100 50 -0.35 0.35 0.50 0.17 -0.31 0.07 0.66 0.81 20 207 253 NTSC Hsync 0 0 -40 0 -40 -40 -0.00 -0.20 -0.40 -0.10 -0.00 -0.40 -0.37 -0.57 0 0 0 NTSC black 0 0 7.5 0 0 7 0.00 0.00 0.07 0.00 0.00 0.07 0.07 0.07 41 41 41 NTSC Gray75 0 0 77 0 0 77 0.00 0.00 0.77 0.00 0.00 0.77 0.77 0.77 212 212 212 YIQ +Q 33 100 50 0 100 50 0.27 0.42 0.50 0.21 0.24 0.83 0.26 0.87 255 81 255 NTSC magenta 61 82 36 28 77 36 0.34 0.19 0.36 0.09 0.30 0.77 0.12 0.52 255 40 181 NTSC red 104 88 28 71 72 28 0.35 -0.09 0.28 -0.04 0.31 0.71 0.08 0.20 255 28 76 YIQ +I 123 100 50 90 100 50 0.42 -0.27 0.50 -0.13 0.37 1.02 0.28 0.26 255 89 82 NTSC yellow 167 62 69 134 62 69 0.07 -0.30 0.69 -0.15 0.06 0.78 0.70 0.43 221 198 121 Color burst 180 40 0 147 20 0 -0.00 -0.10 0.00 -0.05 -0.00 -0.00 0.02 -0.09 0 4 0 YIQ -Q 213 100 50 180 100 50 -0.27 -0.42 0.50 -0.21 -0.24 0.17 0.74 0.13 51 232 41 NTSC green 241 82 48 208 82 48 -0.36 -0.20 0.48 -0.10 -0.31 0.04 0.74 0.31 12 234 97 NTSC cyan 284 88 56 251 88 56 -0.43 0.11 0.56 0.05 -0.37 0.04 0.81 0.65 10 245 198 YIQ -I 303 100 50 270 100 50 -0.42 0.27 0.50 0.13 -0.37 -0.02 0.72 0.74 0 224 231 NTSC blue 347 62 15 314 46 15 -0.05 0.22 0.15 0.11 -0.05 0.09 0.14 0.35 38 65 155
This page was written in the "embarrassingly readable" markup language RHTF, and was last updated on 2021 Jul 27. s.27