I Miss Palette Rotation
Tue 26 November 2024
Background
In the halcyon days of 16-bit microcomputers, there was a computer graphics technique used by many demos and some games known as Palette Rotation, Palette Shifting, Palette Animation, or Color Cycling.
Computers weren't fast enough to change the entire contents of screen memory in graphics mode (even relatively low resolution ones like 320x200) until the 32-bit era, but 16-bit (and even some 8-bit) machines had a nifty trick called Palette Rotation: instead of struggling to change the contents of screen memory 15+ times per second, the screen was painted once, and the color palette was continually changed, instead. This gave the effect of animation without actually having to re-draw the screen.
The palette is animated/changed several times a second, rather than the whole screen: that's only 768 bytes, maximum (up to 256 colors, each up to 3 bytes), rather than having to manipulate up to 62 KiB (320x200 pixels x 1 byte per pixel) of data several times per second. That might not sound like much to our modern ears, but take into account that you have to read/calculate that data from somewhere for each pixel on the screen, and a lot of 16-bit systems used bitplanes, meaning each pixel required up to 8 memory operations to write).
Why "Palettes"?
You have to understand that early computers did not have enough RAM (or VRAM) to display full-color (24 bits per pixel) images. Very early machines were monochrome, or 4 colors, and some nicer ones had 16 color modes. The machines with really nice graphics let you assign colors in a palette: You still only had 16 or at most 256 colors to work with, but you could assign what those colors were out of a larger palette (of 4096 or more colors). So, the computer got to save RAM/VRAM by only having to work with a small number of bits per pixel (4 for 16 colors up to 8 for 256), but you still got to pick what those colors were for the best possible expression.
For an example of why variable/custom/assignable palettes were an awesome thing, imagine that you're trying to show a picture of a room illuminated by a single blue light bulb. Every color in the image is a shade of blue: no reds or greens. If you were stuck with a static 16-color palette, then you might have anywhere from two to four shades of blue to work with, and that's it. On PCs with VGA graphics, the standard 16-color palette would give you black, white, light blue and dark blue to work with to recreate your all-blue image. That's four colors, but really three, as the white wouldn't be that useful. If you can set your own palette, then it can be sixteen shades of blue, and that's not too bad!
For another example, let's say you have a very colorful image (not just blues), but it's dark (and you want it to be dark). If you were stuck with a set 16-color palette, then only half of the colors in the palette would be useful to you (the dark ones), and you'd basically have 8 colors to use to reproduce your image, instead of 16. With a changeable palette, you get to pick the best colors to best reproduce the image.
The "BOING!" Heard 'Round the World
While the variable color palettes were created with better image reproduction in mind (and not necessarily animation), it became an incredibly effect technique for moving images.
One of the most impressive examples of this technique was the famous Amiga "Boing!" Demo (from 1984!). When seeing it today, a modern viewer would conclude, "ok, so they're calculating the shape of ball each frame, apply a rotation for each frame, and re-drawing the ball with a 1-pixel x and y offset for each frame."
BUT NO! None of that is happening. The ball is drawn ONCE, and the rotation is performed by merely rotating the color palette (probably 16 colors) to give the effect of rotating the ball. The motion of the ball is performed by modifying x and y drawing registers in hardware, so once the ball is drawn once, modifying the palette and the two coordinate registers several times per second is all that has to be done.
You can find many examples of this technique by searching "Amiga Demoscene" in YouTube, or looking at some of TechHut's videos, where he explains the advanced programming techniques he used (such as Palette Rotation) in his 16-bit-era video games.
(Original image source: direct image link, source page. Image was hand-animated by me in GIMP)
Category: Tech Tagged: Amiga Beauty Computing Entertainment Gaming Non-religious post Retrocomputing Video WritingMonth