, 19 tweets, 5 min read Read on Twitter
Today, in "engineering tricks that blew my mind," I would like to talk about the Apple II HIRES mode! It was the "high resolution" graphics mode of the Apple II. It's more than 40 years old, but it's a good demonstration of great engineering optimization. A thread!
First of all, if you prefer a long read format, check out this blog post by @pixinn, which covers the various modes of the Apple II from a programmer's perspective, and with much more depth: xtof.info/blog/?p=768
In the rest of the thread, I'll focus only on the HIRES mode, and in particular on the tricks and techniques used by Steve Wozniak that made it cheap to implement high resolution color display on the Apple II.
The first thing that intrigued me with the HIRES mode is that it has 6 colors. Usually, each pixel is coded with N bits, so the number of colors is a power of 2, for instance 4, 16, 256...
In fact, HIRES (kind of) has two palettes of 4 colors each. The first palette has black, white, green, and purple. The second palette has black, white, blue, and orange.
This reminds a bit of the IBM CGA mode, which had two palettes of 4 colors as well, making it very easy to recognize (like here, using the black white cyan magenta palette).
But on the Apple II, instead of setting the palette for the entire screen, you could switch it for each block of 7 pixels! So as long as you didn't need pixels in the same block to use colors from the two palettes, you were fine. (If you did, here's what would happen!)
The result? Instead of needing 3 bits per pixel, you need like 2.3. But it's not just about memory saving; that technique also made it really cheap to produce the color video signal.
The original Apple II wasn't sending RGB signals (like CGA and EGA would do a few years later), probably because this would have required more expensive monitors. Instead, it sent a composite video signal, which could more easily be sent to a TV set.
(Nowadays we have cheap HD TVs that we can connect to a computer over HDMI and get decent display; but this is a very recent thing. Computer screens used to be very expensive!)
This composite video signal was using the NTSC standard. Similar to other video standards (like PAL and SECAM), NTSC started as black-and-white and added the color information later, in a backward-compatible way (so that B&W sets would display color signal in B&W).
In NTSC, color information is coded with a "chroma sub-carrier" (a kind of hidden signal) where the amplitude corresponds to color saturation (very colored vs. gray-ish), and the phase corresponds to the hue (or tint). What's the connection with the Apple II colors?
Precisely: the two bits per pixel of the Apple II video memory correspond exactly to that chroma sub-carrier. With 000000… or 111111…, we get flat signals (with no phase or frequency information) corresponding to black and white respectively.
But with 010101… or 101010… (corresponding to purple and green), we get oscillating signals of opposite phase. Now, if we "switch the palette" in the Apple II, 010101… and 101010… become blue and red.
Under the hood, what happens when we "switch the palette"? We shift the video signal by half a dot. This corresponds to a 90° phase shift. Can you see it on this NTSC "vectorograph"?
Purple and green are on opposite sides of the color wheel. Red (actually slightly orange) and blue are on opposite sides, shifted 90° from purple and green.
To summarize: in HIRES mode, the pixels in the video memory correspond not only to actual pixels (that can be on or off), but also to the chroma sub-carrier used by the NTSC signal, thus allowing color output with very little extra circuitry.
Without this hack, color output would require to map each color to a specific phase shift of the chroma signal. This is basically what happens in LORES mode; but LORES is 40x40 pixels, while HIRES is 280x192.
If you think that this must be a nightmare to program, you're not wrong, my friend. @pixinn's article (xtof.info/blog/?p=768) gives more details about the software side of the story. I'm grateful that in 40 years, displaying colors became much easier! <fin>
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Jérôme Petazzoni
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!

This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member and get exclusive features!

Premium member ($3.00/month or $30.00/year)

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!