PEEKaboo

$DFF000 the custom chips, all of them, one address

The Curious

For anyone who ever wondered how an Amiga with 512 KB and a 7 MHz CPU did that. Pause any demo or game and take its picture apart: the bitplanes it's made of, the copper list that colours it, the blits that drew it, and how every slot on the bus was spent.

01Three chips and a bus

The Amiga's trick was to give graphics and sound their own chips, each able to fetch from memory without the CPU's help:

ChipDoesIn PEEKaboo
AgnusFetches the picture from memory and runs the copper and the blitter.Copper, Blitter Operations, DMA Stats
DeniseTurns bitplanes and sprites into pixels and colours.Display, Bitplanes, Sprites
PaulaPlays the four sound channels, and handles the disk and the serial port.Audio, Disk I/O

Their registers all live together at $DFF000, which is why demo coders know that address by heart. Every window in this guide is under the Debug menu.

02The Graphics workspace

Boot a demo, then switch to View › Workspaces › Graphics. Press F5 to pause on a frame you like. Everything below works while paused, and F6 steps forward one frame at a time.

PEEKaboo · the Graphics workspace
The Graphics workspace, paused on a demo: the Frame Scrubber across the top, the Amiga's picture of a pentagram on marble on the left, DMA Stats below it, and the Display panel with overlay, bitplane, sprite and playfield switches on the right.
  1. Frame Scrubber. Everything that happened in this frame, against the beam's path down the screen.
  2. The picture. Anarchy Incorporated by Crass, paused.
  3. DMA Stats. How the frame's time on the bus was shared out.
  4. Overlays. Extra information drawn over the picture.
  5. Layer switches. Turn individual bitplanes, sprites and playfields off and on.
  6. More tabs. Sprites, Bitplanes and the Memory Map.

03Bitplanes: a picture in layers

An Amiga picture isn't stored pixel by pixel. It's stored as up to six bitplanes (eight on AGA), each a black-and-white image. For every pixel, Denise reads one bit from each plane and joins them into a number, and that number picks the colour from a palette. Five planes give 2⁵ = 32 colours.

Untick bitplanes in the Display panel's Bitplanes section to see what each one adds. Here's the same frame with one plane, three, then all five:

  • BPL1 only
    Only bitplane 1: a noisy black-and-white texture with the pentagram's outline.
    One plane: 2 colours. Just noise and an outline.
  • BPL1–3
    Bitplanes 1 to 3: the marble texture and pentagram appear in cold blue-grey tones.
    Three planes: 8 colours. The shapes are all there, in the wrong colours.
  • All five
    All five bitplanes: the full picture, a steel pentagram on warm brown marble.
    Five planes: 32 colours, and the full picture.

Hiding a layer only changes what's drawn. The Amiga still runs exactly as before, so you can't break anything.

Bitplanes
The Bitplanes window: one display region, scanlines 10 to 312, lores with 5 planes, a preview, the display state, the five plane pointers in chip memory, and the 32-colour palette.
The Bitplanes tab lists each region of the screen. Click one to see where in memory its planes are, its resolution and its palette.

04The copper: changing things mid-screen

The copper is a tiny co-processor with three instructions: WAIT for the beam to reach a position, MOVE a value into a chip register, and SKIP. That's enough to change colours, pointers and modes partway down the screen, every frame, with no CPU time at all. The rainbow skies in a thousand demos are copper lists.

Copper
The Copper window, Live tab: the copper list at $000042AC, starting with a WAIT for line 10, then MOVEs to the five bitplane pointers, BPLCON0, the display window and data fetch registers, and COLOR00 to COLOR15 with a swatch for each colour.
This demo's copper list sets up the screen: it waits for line 10, points the five bitplanes at their memory, then loads the palette. Each colour has a swatch beside it.

Open it from Debug › Copper. Live shows the copper list in memory, and Trace records what the copper did as the frame ran. Tick Show Documentation, then click an instruction to see what the register it writes does.

05Every register, explained

Debug › Custom Registers lists all the chip registers with their current values. Click one to decode it bit by bit, with the documentation beside it.

Custom Registers
The Custom Registers window with DMACONR selected: value $03C1 decoded into bits, with DMAEN, BPLEN, COPEN, BLTEN and AUD0EN set, and the hardware reference's description of each bit below.
DMACONR says which chips may use the bus. Here the bitplanes, copper, blitter and sound channel 0 are on, and sprites and the disk are off.

06Follow the beam

A frame is drawn line by line as the beam sweeps the screen, 50 times a second. Everything on the bus has to happen in time with it. Tick Raster Overlay in the Display panel to see the whole frame as the chips saw it, beam position by beam position.

Raster Overlay
The picture inset in the full beam area, every colour clock painted with what used the bus at that moment: dense vertical stripes of red, blue and green across the screen and its borders.
The picture sits inside the full frame, borders and blanking included. Copper instructions are coloured by the register they write. Click any point to sync the Copper trace, Frame Scrubber and disassembly to that moment.

DMA Stats adds it all up: of the frame's memory slots, how many went to the copper, the blitter, the CPU, bitplanes, sprites, disk and audio, and how many were idle.

DMA Stats
DMA Stats for the frame: Copper 105, Blitter 11,896, CPU 21,353, Bitplane 25,600, Sprite 0, Disk 0, Audio 52, Other 1,248, Idle 10,882. Total 60,254 slots, 84.7% utilised.
Five bitplanes take 25,600 slots, more than the CPU gets. Every plane a screen adds is time taken from the CPU.

For the full picture of one frame, open the Frame Scrubber. It lays out every instruction, blit and copper move against the beam. You can zoom from the whole frame down to a single instruction.

07The blitter

The blitter copies and combines blocks of memory: drawing bobs, filling polygons, clearing the screen and scrolling. Debug › Blitter Operations lists every blit in the frame: when it started (line and clock), whether the CPU or the copper started it, and what it did.

Blitter Operations
Blitter Operations: 34 blits this frame, all triggered by the CPU, listed with their address, number, line, clock and operation.
34 blits in this frame. Turn on Blit Overlay in the Display panel to see which blit drew each pixel.

08Paula's four voices

Debug › Audio shows each of Paula's four channels as a scope, with the sample's address, length, period, note and volume. Click a channel's tick to mute it, or S to solo it, and hear how a tracker tune is put together.

Audio
The Audio window: four channel scopes, channel 0 playing at period 678 (5.2 kHz, note E-1) and the others off, with a table of each channel's registers.
Channel 0 is playing at period 678, which Paula turns into 5.2 kHz. That's the note E-1.

Where next