Analysis model: gpt-5.5 xhigh

# Copper by Surprise! Productions - technical dissection

This is a reverse-engineering note for **Copper** by Surprise! Productions,
released for MS-DOS in December 1992 at The Party 1992. The prod page is on
Pouet at https://www.pouet.net/prod.php?which=2048; the NFO is at
https://www.pouet.net/prod_nfo.php?which=2048; the archive I inspected came
from the Pouet scene.org download link:
https://files.scene.org/get/demos/groups/surprise_productions/pc/copper.zip.

The short version: Copper is not a software renderer pretending to be a VGA
demo. It is mostly a collection of carefully timed writes to real VGA state:
the Attribute Controller, DAC, Sequencer, and CRTC. The pictures and text are
often static in video memory; the moving part is the display hardware being
reprogrammed during the frame, sometimes during individual scanlines.

## Evidence and address conventions

Files inspected:

| File | Size | SHA-256 |
| --- | ---: | --- |
| `COPPER.EXE` | 153,769 | `bcbe41ffb583449085e53c058beb1b5f1f8132b289e5a4ac0114727e7735aecd` |
| `COPPER.NFO` | 6,636 | `c1eaa588896d8e5d8e46cca2785e864c18ad479e15fceed85d2ab67e97fc385c` |
| captured unpacked image | 334,336 | `ea2bae89e0ad83a55804eaa04352694e2dd4749b946da0b2200fbf6e627621b0` |

I used DOSBox-X to run the executable long enough for the packer to expand the
program, then extracted RAM from a save state. In that state:

- DOS PSP for Copper is at segment `081A`.
- The loaded executable image begins at `082A:0000`.
- In this document, `image+xxxx` means an offset inside that unpacked image,
  not an offset in the packed EXE file.
- The captured image is a memory image, not a relinked EXE. Code and data are
  interleaved exactly as the running program uses them.

The NFO says the demo needs roughly 430 KB free RAM, a standard VGA, and an
AdLib-compatible card for sound. It also explicitly frames the demo as a PC
simulation of the Amiga copper/raster trick, and lists the key VGA ports used:
`3DAh`/`3BAh`, `3C8h`/`3C9h`, `3D4h`/`3B4h` indexes `13h` and `04h`, and
Attribute Controller indexes `10h` and `14h`.

## Runtime Capture

The runtime pass used the verified `COPPER.EXE` hash listed above in DOSBox-X
2026.01.02. The capture used a temporary Xvfb display and external `ffmpeg`
X11 grab, which avoids relying on DOSBox-X's internal capture hook for a
timing-heavy raster demo.

```text
Machine:        svga_s3
Memory:         16 MB
CPU:            normal core, fixed 50000 cycles
DOS memory:     XMS on, EMS off
Audio path:     Sound Blaster 16 environment, SDL dummy host audio
Environment:    BLASTER=A220 I7 D1 H5 T6
Capture:        existing Xvfb 1024x768 video
Derived assets: direct ffmpeg frame/time-slice outputs with no crop or scale
Duration:       120.000 s
```

![Copper runtime contact sheet](images/copper-runtime-contact.png)

The first two minutes cover the intro text, page movement, full-screen wobble,
credits, explanatory hardware-function text, parallax/raster bars, and
traditional copper bars. That is enough to validate the main static claim:
the visible animation is dominated by changing VGA display state, not by
redrawing all pixels as a conventional software renderer.

![Copper intro still](images/copper-runtime-intro.png)

![Copper page/logo still](images/copper-runtime-logo.png)

![Copper wobble still](images/copper-runtime-wobble.png)

![Copper raster bars still](images/copper-runtime-bars.png)

## What the demo is doing visually

The embedded script text gives a useful map of the show:

- Surprise! Productions presents / credits.
- "All effects in this demo are hardware functions of the VGA."
- Full-screen wobble.
- Sinus wobble.
- A J.O.E picture.
- Parallax bars.
- Traditional copper bars.
- Line fading.
- Flicker-free flood effects.
- Hardware Y zoom on a standard VGA.
- Combined Y zoom and wobbling, presented as water-like effects.
- More zooming, greets, and end/exit screens.

Most of those labels are literal strings in the unpacked image. The text uses a
small custom character mapping in storage, for example `p` for space, `k` for
hyphen, `g` for exclamation, `i` for colon, and `l` for slash.

## The packed EXE and `MyLZ` loader

The packed file is a normal DOS MZ executable whose entry point is near the end
of the file.

| MZ field | Value |
| --- | --- |
| header paragraphs | `0002h` |
| relocation count | `0000h` |
| entry CS:IP | `256F:000E` |
| entry file offset | `2571Eh` |
| initial SS:SP | `51AB:0080` |
| minimum allocation | `2C65h` paragraphs |
| maximum allocation | `FFFFh` |

The file starts, after the 32-byte MZ header, with the marker `MyLZ!=`. There
are no MZ relocation records. The loader therefore has to decompress the real
program and apply its own relocation/fixup stream.

### Stage 1: move the loader/image upward

The MZ entry begins with a backwards copy:

```asm
; packed file offset 2571Eh, MZ entry point
push es
push cs
pop  ds
mov  cx,[000Ch]
mov  si,cx
dec  si
mov  di,si
mov  bx,ds
add  bx,[000Ah]
mov  es,bx
std
rep  movsb
push bx
mov  ax,002Bh
push ax
retf
```

This copies a block from the current code segment to a higher segment, going
backwards so source bytes are not overwritten. Then it far-returns into the
moved copy. That is a classic DOS packer trick: once the packed payload is
going to expand downward or over the loader's original load area, move the
loader out of the way first.

### Stage 2: unpack blocks in 64 KB-ish chunks

After the move, the loader adjusts `DS`, `ES`, and `BP` in chunks:

```asm
mov  bp,cs:[0008h]
...
cmp  ax,1000h
jbe  short last_chunk
mov  ax,1000h
sub  bp,ax
sub  dx,ax
sub  bx,ax
mov  ds,dx
mov  es,bx
...
rep  movsw
or   bp,bp
jnz  next_chunk
```

The values are paragraph counts. This is why the EXE can expand to roughly
330 KB even though the decompressor runs in a 16-bit real-mode address space:
it walks segments and moves at most `1000h` paragraphs at a time.

### Stage 3: LZ bitstream

The main decompression loop uses a 16-bit bit bucket in `BP`; `DX` counts
remaining bits. It reloads with `LODSW` when the bucket is empty.

The control bit decides literal versus match:

```asm
shr  bp,1
dec  dx
jnz  bit_ok
lodsw
mov  bp,ax
mov  dl,10h
bit_ok:
jc   literal
; otherwise decode match
```

If the bit is set, one literal byte is copied from compressed source to output:

```asm
literal:
movsb
jmp next_token
```

If the bit is clear, the loader decodes a back-reference. There are two forms.
The short form encodes a tiny length with two extra bits and an 8-bit negative
offset:

```asm
xor  cx,cx
; read discriminator bit
; if short:
rcl  cx,1
rcl  cx,1
add  cx,2
mov  bh,0FFh
lodsb
mov  bl,al
; copy CX bytes from ES:[DI+BX] to ES:[DI]
```

The long form reads a word. The top bits become a signed negative offset, and
the low 3 bits of the high byte become a length:

```asm
lodsw
mov  bx,ax
mov  cl,3
shr  bh,cl
or   bh,0E0h
and  ah,07h
jnz  normal_len
lodsb
cmp  al,0
je   end_stream
cmp  al,1
je   segment_hop
mov  cl,al
inc  cx
jmp  copy_match

normal_len:
mov  cl,ah
add  cx,2
```

The actual match copy is `CX` reads from already decompressed output:

```asm
copy_match:
mov  al,es:[di+bx]
stosb
loop copy_match
```

That is LZSS: literals seed the buffer, matches repeat earlier output. The
interesting loader detail is that the match source is in `ES`, not `DS`, so
the source and destination are the same decompressed output stream.

### Stage 4: fixup stream and final jump

After the compressed data ends, the loader reads a compact relocation/fixup
stream. Tokens advance `DI`, recompute `ES = DX + (DI >> 4)`, normalize
`DI &= 0Fh`, and add the load base to the word at `ES:DI`.

Two special tokens matter:

- A zero token advances the relocation page by adding `0FFFh` to `DX`.
- Token `1` ends fixups, restores the original stack, computes the program
  data segment, and far-jumps through a pointer stored in the loader metadata.

So the packer is not just "decompress bytes"; it reconstructs the real linked
program and applies relocation-like patches that the MZ header no longer
contains.

## Runtime initialization

The main control flow is visible around `image+7F3E`. The early sequence is:

```asm
7f3e: call 6b2d        ; shrink DOS memory block
7f41: call 7ee7        ; allocate/read external data from EXE/file
7f44: call 6e04        ; install keyboard IRQ handler variant
7f47: call 0dc0        ; detect OPL/AdLib-compatible port
7f4a: cmp  ax,0
7f4d: jne  7f58
7f4f: mov  byte ptr cs:[0a30],90h ; enable music dispatch
7f55: call 0ef3        ; initialize video/picture/music path
7f58: call 2a73        ; initialize VGA mode
...
```

At `image+7F5B`, it unlocks CRTC register `11h` by clearing bit 7:

```asm
mov dx,03D4h
mov al,11h
out dx,al
inc dx
in  al,dx
and al,7Fh
out dx,al
```

This is necessary before writing protected vertical timing registers on VGA.

The part sequence is then a long list of calls, with `call 703A` between most
parts. `image+703A` checks a keyboard/skip flag and exits or skips cleanly if
the user pressed the relevant key.

## VGA mode setup

The setup routine is at `image+2A73`:

```asm
2a73: sti
2a74: mov ax,0013h
2a77: int 10h
2a79: cli

; wait until currently inside vertical retrace, then until outside it
2a7a: mov dx,03DAh
2a7d: in  al,dx
2a7e: test al,08h
2a80: je  2a7d
2a82: in  al,dx
2a83: test al,08h
2a85: jne 2a82

; Sequencer index 4, memory mode = 06h
2a87: mov dx,03C4h
2a8a: mov ax,0604h
2a8d: out dx,ax

; Attribute Controller setup
2a8e: mov dx,03DAh
2a91: in  al,dx              ; reset AC flip-flop
2a92: mov dx,03C0h
2a95: mov al,10h             ; Attribute Mode Control
2a97: out dx,al
2a98: mov al,61h
2a9a: out dx,al
2a9b: mov al,11h             ; Overscan/border
2a9d: out dx,al
2a9e: mov al,00h
2aa0: out dx,al
2aa1: mov al,20h             ; re-enable display
2aa3: out dx,al

; CRTC register table
2aa4: mov dx,03D4h
2aa7: mov si,2A5Ah
...
2ab4: mov cx,19h
2ab7: mov al,00h
2ab9: mov ah,cs:[si]
2abc: out dx,ax              ; AL=index, AH=value
2abd: inc al
2abf: inc si
2ac0: loop 2ab9

; enable all planes and clear A000
2ac2: mov dx,03C4h
2ac5: mov ax,0F02h           ; Sequencer Map Mask = all 4 planes
2ac8: out dx,ax
2ac9: mov ax,0A000h
2acc: mov es,ax
2ace: xor di,di
2ad1: mov cx,8000h
2ad4: xor ax,ax
2ad6: rep stosw
2ad8: sti
```

Starting from BIOS mode 13h gives a known 320x200x256 baseline. Then Copper
turns off chain-4 style address sequencing by changing Sequencer memory mode
register `04h` to `06h`, and it uses planar writes through the map mask. This
is the usual "Mode X" family of tweaked VGA modes: still 256-color, but with
four addressable planes and CRTC-controlled display start/offset behavior.

## Timing primitives: vertical and horizontal retrace

Everything depends on polling VGA status port `3DAh`.

Vertical retrace is bit `08h`. A full "wait for next vertical retrace start"
looks like this, seen many times:

```asm
mov dx,03DAh
in  al,dx
test al,08h
jne short still_in_old_vblank
in  al,dx
test al,08h
je  short wait_for_new_vblank
```

Horizontal retrace is bit `01h`. A scanline wait generally consumes one
inactive-to-active transition:

```asm
mov dx,03DAh
in  al,dx
test al,01h
jne short wait_until_not_hsync
mov dx,03DAh
in  al,dx
test al,01h
je  short wait_until_hsync
```

`cs:[0A2Eh]` is incremented all over these loops. It is a software scanline or
timing counter used by parts and by skip logic. It is not responsible for the
visual effect by itself; the effect is the port write that happens after the
right number of retrace transitions.

Most timing-heavy sections use `CLI` while doing scanline-critical writes.
That removes timer/keyboard jitter, at the cost of needing explicit restore
points and skip handling elsewhere.

## DAC palette upload and palette rastering

The general palette upload helper is at `image+0ECF`:

```asm
0ecf: mov word ptr cs:[0A2E],0
0ed6: mov dx,03DAh
0ed9: in  al,dx
0eda: test al,08h
0edc: jne 0ed9
0ede: in  al,dx
0edf: test al,08h
0ee1: je  0ede

0ee3: mov dx,03C8h       ; DAC write index
0ee6: mov ax,di          ; DI = first color index
0ee8: out dx,al
0ee9: inc dx             ; DX = 03C9h, DAC data
0eea: mov ax,cx          ; CX colors
0eec: shl cx,1
0eee: add cx,ax          ; CX *= 3
0ef0: rep outsb          ; write R,G,B triplets from DS:SI
0ef2: ret
```

That helper waits for vertical retrace, selects a DAC start index through
`3C8h`, then streams `3 * color_count` bytes to `3C9h`.

A more aggressive palette-raster routine appears around `image+3D8A`. It
updates DAC bytes on horizontal-retrace boundaries:

```asm
3d84: push cx
3d85: mov  si,di
3d87: mov  cx,000Eh
3d8a: mov  dx,03C8h
3d8d: xor  al,al
3d8f: out  dx,al
3d90: inc  dx             ; 03C9h
3d91: outsb               ; first DAC component
3d92: outsb               ; second DAC component

3d93: mov  dx,03DAh
3d96: in   al,dx
3d97: test al,01h
3d99: je   3d96           ; wait for horizontal retrace active

3d9b: mov  dx,03C9h
3d9e: outsb               ; third DAC component

3d9f: inc  word ptr cs:[0A2Eh]
3da4: mov  dx,03DAh
3da7: in   al,dx
3da8: test al,01h
3daa: jne  3da7           ; wait retrace inactive
3dac: loop 3d8a
```

This is a good example of how tight the demo is. A normal palette fade would
upload a table during vblank. Copper sometimes deliberately lands individual
DAC writes at line transitions.

## Attribute Controller color pages and line fading

The Attribute Controller uses a flip-flop: before writing an index to `3C0h`,
code usually reads `3DAh`. Copper follows that pattern:

```asm
; enable bit 7 of Attribute Mode Control, index 10h
ba c0 03        mov dx,03C0h
b0 10           mov al,10h
ee              out dx,al
42              inc dx
ec              in  al,dx
8a d8           mov bl,al
80 cb 80        or  bl,80h
ba da 03        mov dx,03DAh
ec              in  al,dx
ba c0 03        mov dx,03C0h
b0 10           mov al,10h
ee              out dx,al
8a c3           mov al,bl
ee              out dx,al
b0 20           mov al,20h
ee              out dx,al
```

There is a matching routine that clears the same bit with `and bl,7Fh`.

The line-fading core starts around `image+0BE5`. The effect is:

1. Wait for vertical retrace.
2. Enable the Attribute Controller mode-control bit.
3. Write Attribute Controller index `14h` to select a high palette/color page.
4. Wait a programmable number of scanlines by polling horizontal retrace.
5. Walk the color page value down or up every couple of lines.
6. Disable the color page mode again.

Representative inner loop:

```asm
; delay BP scanlines
0c1d: mov cx,bp
0c1f: inc word ptr cs:[0A2Eh]
0c24: mov dx,03DAh
0c27: in  al,dx
0c28: test al,01h
0c2a: jne 0c27
0c2c: mov dx,03DAh
0c2f: in  al,dx
0c30: test al,01h
0c32: je  0c2f
0c34: loop 0c1f

; then write a new color-select page every two lines
0c57: mov dx,03C0h
0c5a: mov al,14h
0c5c: out dx,al
0c5d: mov al,bl
0c5f: out dx,al
0c60: mov al,20h
0c62: out dx,al
0c63: dec bl
0c65: loop 0c3b
```

This explains the NFO warning about "colorpages" failing on some VGA cards.
The demo is relying on Attribute Controller color-select behavior in a 256-color
tweaked mode, and clone VGA implementations disagreed about that behavior.

## CRTC start address: page movement without copying pixels

Several parts set the display start address through CRTC indexes `0Ch` and
`0Dh`:

```asm
4d92: mov bx,1090h
4d95: mov dx,03D4h
4d98: mov ah,bh
4d9a: mov al,0Ch
4d9c: out dx,ax
4d9d: inc al
4d9f: mov ah,bl
4da1: out dx,ax
```

This changes where the VGA begins fetching display memory. Combined with
preloaded off-screen pages, it gives scrolling, page swaps, and picture
positioning with almost no memory bandwidth.

That same routine then enables all VGA planes and clears the display page:

```asm
4da5: mov dx,03C4h
4da8: mov ax,0F02h
4dab: out dx,ax
4dac: xor ax,ax
4daf: mov cx,1E78h
4db2: rep stosw
```

The code draws text or images into a page, then uses hardware address changes
and per-line CRTC changes to animate it.

![Copper CRTC wobble motion](images/copper-runtime-wobble.gif)

The wobble clip is the clearest runtime proof of the CRTC-start-address model:
large static-looking page material bends and slides because the displayed start
position and per-line timing change, not because a whole new bitmap is drawn
for every frame.

## CRTC register `13h`: hardware Y zoom / stretch

CRTC index `13h` is the Offset register: how far the display address advances
after a scanline. In 320-wide 256-color mode, normal offset is `28h`. Writing a
smaller value makes the next scanline fetch from a nearer address; writing zero
can repeat or smear lines. Copper rewrites this register while the screen is
being drawn.

The first Y-zoom routine begins near `image+7268`:

```asm
7268: mov dx,03D4h
726b: mov al,09h
726d: out dx,al
726e: inc dx
726f: in  al,dx
7270: and al,7Fh
7272: out dx,al           ; clear bit 7 of Max Scan Line

727d: mov dx,03D4h
7280: mov ax,0013h
7283: out dx,ax           ; Offset = 00h
7284: inc dx
7285: lodsb               ; table value
7286: xor ah,ah
7288: shl ax,1
728a: mov bp,0136h
728d: sub bp,ax
7291: mov cx,ax
7293: dec cx
```

Then it waits scanlines and writes offset values at exact moments:

```asm
7294: inc word ptr cs:[0A2Eh]
7299: mov dx,03DAh
729c: in  al,dx
729d: test al,01h
729f: jne 729c
72a1: mov dx,03DAh
72a4: in  al,dx
72a5: test al,01h
72a7: je  72a4
72a9: mov ax,0013h
72ac: mov dx,03D4h
72af: out dx,ax           ; keep repeating/freeze stretch
72b0: loop 7294

72c7: mov ax,2813h
72ca: mov dx,03D4h
72cd: out dx,ax           ; restore normal offset
```

A later section loads an offset byte from a table and writes it as the value
for CRTC index `13h`:

```asm
72e5: mov dx,03D4h
72e8: lodsb
72e9: mov ah,al
72eb: mov al,13h
72ed: out dx,ax
72ee: loop 72d0
```

That is the advertised "hardware Y zoom." The CPU is not scaling a bitmap.
It changes the address stride so the VGA repeats, skips, or compresses source
rows while scanning out the frame.

![Copper raster bar motion](images/copper-runtime-raster-bars.gif)

## CRTC register `04h`: horizontal wobble

The NFO's "wobbling" hint points at CRTC index `04h`. That is the Start
Horizontal Retrace register. Changing it per scanline changes where the VGA
asserts horizontal sync/retrace. Depending on card and monitor, the visible
line appears horizontally displaced.

The water/wobble variant around `image+74E0` combines register `13h` Y-stretch
with register `04h` horizontal movement:

```asm
751e: mov ax,0013h
7521: mov dx,03D4h
7524: out dx,ax           ; CRTC Offset = 00h or table-controlled

7525: mov al,cs:[bx]      ; wobble table
7528: add bx,cs:[7363h]   ; phase/step
752d: add al,54h
752f: mov ah,04h
7531: xchg al,ah          ; AL=index 04h, AH=value
7533: out dx,ax           ; Start Horizontal Retrace = table + 54h
7534: cmp bx,7101h
7538: jb  753d
753a: sub bx,006Ch
753d: loop 7509
```

The same pattern appears again while CRTC offset is restored to `28h` or loaded
from a Y-zoom table:

```asm
7572: mov dx,03D4h
7575: lodsb
7576: mov ah,al
7578: mov al,13h
757a: out dx,ax           ; Y address stride

757b: mov al,cs:[bx]
7583: add al,54h
7585: mov ah,04h
7587: xchg al,ah
7589: out dx,ax           ; horizontal sync start
```

This is why the effect is both impressive and temperamental. It is not merely a
card effect; it also depends on whether the monitor or capture device accepts
rapid scanline-to-scanline changes to sync timing.

![Copper traditional copper bars](images/copper-runtime-copper-bars.gif)

The bar clips are deliberately short because the important evidence is
temporal. A still captures the colors, but not the scanline-synchronized
palette/register behavior that the code is built around.

## Bitmap/page loading and planar copies

The demo includes a small RLE-style expander at `image+0A5E`:

```asm
0a5e: lodsb
0a5f: mov cl,al
0a61: xor ch,ch
0a63: cmp cl,7Fh
0a66: ja  repeat_run

; literal run: copy CL+1 bytes
0a68: inc cx
0a69: sub bx,cx
0a6b: rep movsb
0a6d: jmp done_or_continue

repeat_run:
0a70: lodsb
0a71: mov dx,0101h
0a74: sub dx,cx            ; count = 257 - token
0a76: mov cx,dx
0a78: sub bx,cx
0a7a: mov es:[di],al
0a7d: inc di
0a7e: loop 0a7a
```

So bytes `00h..7Fh` mean "copy the next `n+1` bytes." Bytes above `7Fh` mean
"repeat the next byte `257-n` times." This is used for packed picture/text
data, not the EXE packer.

For planar image placement, Copper cycles the Sequencer Map Mask through
planes and copies every fourth source byte:

```asm
0ae2: mov dx,03C4h
0ae5: mov ax,0102h       ; index 2, map mask = 1
0ae8: mov cx,0004h
0aeb: out dx,ax
0aec: shl ah,1           ; next plane mask
0aee: push cx
0aef: push di
0af0: push si
0af1: mov cx,2800h
0af4: movsb
0af5: add si,0003h       ; every fourth byte goes to this plane
0af8: loop 0af4
0afa: pop si
0afb: pop di
0afc: inc si
0afd: pop cx
0afe: loop 0aeb
```

This converts chunky-ish source data into VGA planar memory. Again, the CPU is
mostly arranging data. The final spatial distortion is done by CRTC registers.

## Font and mask blitter

There is also a bit-oriented blitter around `image+6E24`. Its input is run
length encoded, and each source bit either ORs or ANDs a bit in video memory:

```asm
6e7a: xor cx,cx
6e7c: mov cl,[si]
6e7e: inc si
6e7f: cmp cl,7Fh
6e82: ja  repeat_case
6e84: inc cx
...
6e8c: mov cx,0008h
6e8f: rcl bl,1
6e91: jb  set_pixel
6e93: and es:[di],ah
6e96: jmp next_bit
6e99: or  es:[di],al
6e9c: inc di
6e9d: loop 6e8f
```

`AL` is the bit mask for the current plane/bit position, and `AH` is its
inverse. For zero bits it clears with `AND`; for one bits it sets with `OR`.
The routine advances `DI` one byte per bit and repeats for runs. This is used
for crisp text/shape rendering into planar VGA pages.

## Interpolation helper for fades and transitions

`image+0D8E` interpolates byte tables:

```asm
0d8e: mov ax,cx
0d90: shl cx,1
0d92: add cx,ax           ; CX *= 3
0d94: xor ah,ah
0d96: lodsb               ; source byte
0d97: push ax
0d98: mov ah,[di]         ; destination/current byte
0d9a: inc di
0d9b: xchg al,ah
0d9d: sub al,ah           ; delta
0d9f: imul dh             ; delta * current_step
0da1: idiv dl             ; / total_steps
0da3: xor ah,ah
0da5: pop bx
0da6: add ax,bx
0da8: mov ds:[bp],al
0dac: inc bp
0dad: loop 0d94
```

Callers set `DL` to the number of steps and `DH` to the current step. Because
many palette tables are RGB triplets, the routine multiplies color count by 3.
This is a general "build this frame's intermediate table" helper, usually
followed by the DAC upload helper.

## Music: OPL detection, self-modifying dispatch, and 70 Hz calls

The AdLib/OPL detection routine starts at `image+0DC0`. It tries a small table
of candidate base ports:

```asm
0db0: dw 0218h,0288h,0318h,0388h,0FFFFh
0dba: dw 0388h
0dbc: dw 0389h
```

For each base, it writes OPL timer/control registers and checks status bits:

```asm
0dd2: mov dx,cs:[0DBAh]   ; base
0dd7: mov al,04h
0dd9: out dx,al
0dda: call short_delay
0ddd: mov dx,cs:[0DBCh]   ; base+1
0de2: mov al,60h
0de4: out dx,al
0de5: call long_delay
...
0e03: in  al,dx
0e04: and al,0E0h
0e06: mov cs:[0DBEh],al
...
0e3e: in  al,dx
0e3f: and al,0E0h
0e41: mov cs:[0DBFh],al
...
0e71: cmp byte ptr cs:[0DBEh],00h
0e79: cmp byte ptr cs:[0DBFh],0C0h
0e81: xor ax,ax           ; AX=0 means found
```

The delays are fixed busy loops:

```asm
0e96: mov cx,012Ch
0e9a: loop 0e9a

0e9e: mov cx,000Fh
0ea2: loop 0ea2
```

The music call gate is deliberately self-modifying:

```asm
0a30: ret
0a31: call far 1030:0000
0a36: ret
```

If OPL detection succeeds, startup patches the first byte from `C3` (`ret`) to
`90` (`nop`), so later `call 0A30h` calls through to the player. If no OPL is
detected, `0A30h` remains an immediate return and the demo runs silently.

Initialization also patches the far-call segment:

```asm
0a37: mov ax,1030h
0a3b: mov cs:[0A34h],ax
...
0a40: mov ax,2000h
0a43: call 0A30h
0a46: mov ax,5000h
0a49: mov bx,10B1h
0a4d: call 0A30h
0a50: mov ax,4001h
0a53: call 0A30h
```

The NFO says the Jesper Olsen/Vibrants player runs at 70 calls per second and
describes it as vertical-interrupt driven. The unpacked executable I captured
also contains a clear `INT 08h`/PIT wrapper for 70 Hz calls:

```asm
; set PIT divisor to 1193180 / BX
365b: cli
365c: mov dx,0012h
365f: mov ax,34DCh       ; DX:AX = 1234DCh = 1193180
3662: div bx
3665: mov al,36h
3667: out 43h,al
3669: out 40h,al
366c: xchg al,ah
366e: out 40h,al
3670: sti
3671: ret

; INT 08 handler
3672: pusha
3673: cli
3674: xor ax,ax
3677: call 0A30h         ; music tick
367a: mov al,20h
367c: out 20h,al         ; PIC EOI
367e: sti
367f: popa
3680: iret
```

And the installer:

```asm
368e: pusha
3691: mov ah,35h
3693: mov al,08h
3695: int 21h            ; get old INT 08
...
36d9: mov dx,3672h
36dc: mov ah,25h
36de: mov al,08h
36e0: int 21h            ; set INT 08 to music handler
36e2: mov bx,0046h       ; 70 decimal
36e5: call 365Bh         ; PIT = 70 Hz
```

So in this build, the regular player tick is backed by the PIT/IRQ0 path while
the visual effects themselves are synchronized to VGA retrace polling.

## Keyboard and skip handling

The keyboard handler is installed on `INT 09h` around `image+6DBE`:

```asm
6dbe: push ds
6dbf: push es
6dc0: mov ah,35h
6dc2: mov al,09h
6dc4: int 21h
6dc6: mov ax,es
6dc8: mov cs:[6CECh],ax
6dcc: mov cs:[6CEEh],bx
6dd1: push cs
6dd2: pop ds
6dd3: mov dx,6D77h
6dd6: mov ax,2509h
6dd9: int 21h
```

The handler reads port `60h`, folds the make/break bit into a table index, and
sets flags in `cs:[6CF0...]`:

```asm
6d80: mov dx,0060h
6d83: in  al,dx
6d84: xor ah,ah
6d88: xor al,80h
6d8a: shl al,1
6d8c: rcl ah,1
6d8e: shr al,1
6d90: mov bl,al
6d92: mov cs:[bx+6CF0h],ah
...
6db4: mov dx,0020h
6db7: mov al,dl
6db9: out dx,al
6dbd: iret
```

Mainline code checks flags such as `cs:[6D76]` and `cs:[6D75]` between parts.
That is how the NFO's "press Escape to skip" behavior is implemented without
letting keyboard IRQ timing disturb inner scanline loops.

## Runtime-To-Code Concordance

The three runtime GIFs are direct checks against the scanline/register code:

- `copper-runtime-wobble.gif` maps to the CRTC-start-address and horizontal
  wobble paths. The page movement uses CRTC indexes `0Ch`/`0Dh` around
  `image+4D92` to change the display start without copying pixels. The water
  wobble combines CRTC offset `13h` with horizontal retrace register `04h`
  around `image+74E0..7589`, using table-driven per-scanline writes timed by
  `3DAh` polling.
- `copper-runtime-raster-bars.gif` maps to the Y-zoom/raster-bar family. The
  main anchors are the CRTC offset writes around `image+7268..72ED`, where
  register `13h` is set to `00h`, restored to `28h`, or loaded from a table
  while the beam is active. The GIF proves hardware stride/repeat behavior,
  not software bitmap scaling.
- `copper-runtime-copper-bars.gif` maps to the palette/color-page raster
  sections. The Attribute Controller color-select path around `image+0C1D`
  writes index `14h` through port `3C0h` after scanline waits, while the DAC
  helpers and interpolation path prepare per-frame color tables. The temporal
  bars are therefore VGA register timing artifacts over prepared data.

The stills and contact sheet anchor the surrounding static pages: intro text,
logo/page material, explanatory hardware-function text, and the prepared
picture/text assets. The media files themselves were already corrected to be
direct runtime frame/time slices; this section only explains which code paths
the clips validate.

## Why Copper is so fragile and so fancy

Copper is fancy because it treats the VGA like a raster co-processor:

- `3DAh` is polled to place writes on vertical or horizontal retrace edges.
- `3C8h`/`3C9h` stream DAC palette changes, sometimes per line.
- Attribute Controller index `14h` changes color-page selection during the
  frame for line fades.
- CRTC index `13h` changes display address stride per line, creating hardware
  Y stretching/zooming.
- CRTC index `04h` changes horizontal retrace start per line, creating wobble.
- CRTC indexes `0Ch`/`0Dh` move display start address without copying pixels.
- Sequencer map mask and memory mode turn mode 13h into a planar tweaked mode.

It is fragile for the same reason. The demo assumes specific timing and
specific VGA behavior in corners that clone cards and monitors did not always
implement the same way. This is why the NFO calls out Tseng ET4000/ET3000 test
systems and warns that color-page parts may black-screen on some adapters.

The important technical distinction is that the CPU is usually not computing
the final warped pixels. It loads pictures, palettes, and tables, then waits
for the beam and pokes one or two VGA registers at the exact line. The VGA
hardware then fetches different addresses, uses different palette pages, or
shifts sync timing while scanning the already-loaded image.

That is the PC equivalent of the Amiga copper idea: a tiny stream of precisely
timed register changes creates effects much larger than the number of CPU
instructions executed per frame.

## Source links

- Pouet prod page: https://www.pouet.net/prod.php?which=2048
- Pouet NFO page: https://www.pouet.net/prod_nfo.php?which=2048
- scene.org archive URL used for the binary:
  https://files.scene.org/get/demos/groups/surprise_productions/pc/copper.zip
- Local archive contents inspected: `COPPER.EXE`, `COPPER.NFO`
