One of the Amiga’s big claims to fame is its custom chipset, which gave it multimedia capabilities that were basically unheard of 30 years ago. I spent my retro-time this weekend learning a few new old tricks.
The Copper is a simple but powerful coprocessor that’s part of the Amiga’s Agnus chip. Out of all the custom chips, it’s the only one capable of running its own (exceedingly simple) program. It has three instructions:
WAIT – wait for the beam to reach a certain position on screen.
MOVE – write a value to one of the custom chip registers.
SKIP – skip the next instruction. Apparently you can use SKIP to create loops, but I haven’t mucked with that yet.
What can you actually do with that? Quite a few things. The Copper is what lets the Amiga display multiple screens with different resolutions or palettes simultaneously. It’s used to create special graphics modes like “Sliced HAM”, and can even draw blocky graphics all on its own.
On older computers like the Commodore 64 or Atari 2600, a lot of graphics routines relied on executing code or changing registers when the beam reached a certain point on screen, and the entire program had to be written around that. The Copper makes this a lot easier, because it’ll run through its program every frame while the CPU – and your program – is taking care of other stuff.
I decided to use the Copper to add some color and flair to my graphics program. My first attempt borrowed from an example in the RKRM – it changed the background from a flat gray to a rainbow of horizontal stripes. The Copper program (also called a “Copper list”) was simple – every 10 lines or so it would write a new value to color register 0, which contains the background color. Even though my graphics were only using a single bitplane, I suddenly had an image with almost two dozen distinct colors.
Compared to my trials with the back-face culling algorithm last week, getting the Copper list stuff to work was a breeze. I did run into one “old fashioned C compiler gotcha”. In K&R style C, functions didn’t have to be declared before being used – but without the declaration, the compiler would assume that all the arguments were supposed to be ints – or at least int-sized. I forgot to include the header file for graphics.library’s Copper list utility functions – which are actually supposed to take 16-bit words as arguments – resulting in some weird errors because the values I was passing were being promoted from words to ints behind my back – right under my nose!
Once I got that straightened out, I decided to have some fun. I came up with a Copper list that was my best attempt at coming up with a twilight sky and barren ground. The effect kind of worked, but it still needed something. It didn’t exactly need my mediocre artistic skills, but that’s what it got.
Amiga displays are composed of multiple bitplanes. That’s not the way most modern graphics hardware works, but it has its pros and cons. One pro is that I can draw my graphics in one bitplane without modifying another one. So I added a second bitplane to the display, and to fill it in I created a picture in DeluxePaint IV – just some pyramids, a full moon, and some stars. I converted the picture to a C source code file using a program called “IFF to Source” by J.Tyberghein, which I vaguely remember installing on this hard drive image back in the early 90s.
With two bitplanes I have four colors. The background is 0, and the pyramids and moon are color 2. The rotating cube uses colors 1 and 3 (depending on whether a line overlaps the picture or not). I added a couple more entries to my copper list so that color 2 would be pale white at the top (for the moon and stars) and dark gray for the bottom (the pyramids).
The best part is that none of this Copper list stuff affected my frame rate. The Copper program doesn’t have a noticeable effect. The background details image is copied into the frame buffer once at the start of the program (well, twice since my graphics are double-buffered), and after that I don’t have to do anything with it. I like the overall effect – it’s a lot more fun than staring at gray and black all the time. The video at the top shows the transition of how things developed over the course of the weekend.