Analysis model: gpt-5.5 xhigh

# Headbanger's Ball by Access Denied - Technical Dissection

Subject: `Headbanger's Ball` / `HeadBangers Ball` by Access Denied.

Demozoo lists `Headbanger's Ball` as an MS-DOS demo by Access Denied, released
20 March 1992, with Lord Cyrix credited for code and graphics. Pouet lists it
as a March 1992 MS-DOS demo and notes the remembered visible part: vector balls,
a text scroller, VGA, Sound Blaster, and a SPACE gate after the intro screen.
The Hornet 1992 index carries it as `headbang.zip`, `Headbangers Ball by Access
Denied`.

Release year: 1992

This is a good early-1992 PC demo because it is half asset show and half tight
real-mode loop. The five external `BANG*.DAT` files are simple full-screen VGA
resources, but the main executable is a large Borland real-mode program with a
startup hardware selector, embedded Creative Voice File samples, direct DAC
updates, precomputed ball paths, a shaped vector-ball erase/draw kernel, and a
scroll-text path that feeds the ball scene.

The archive contains no old phone/address list in the public DOC. The analysis
still avoids turning release-note chatter into contact material.

## Sources

- Demozoo production page:
  https://demozoo.org/productions/191574/
- Demozoo screenshots:
  https://demozoo.org/productions/191574/screenshots/
- Pouet production page:
  https://www.pouet.net/prod.php?which=4205
- Scene.org file page:
  https://files.scene.org/view/mirrors/hornet/demos/1992/headbang.zip
- Scene.org download:
  https://files.scene.org/get/mirrors/hornet/demos/1992/headbang.zip

## Visual References

![Headbanger's Ball decoded DAT contact sheet](images/headbangers-ball-dat-contact.png)

The contact sheet above is decoded from the five external DAT files. These are
not emulator screenshots; they are direct resource decodes. The format is:

```text
offset 0x0000..0x02ff   768-byte VGA DAC palette, 256 RGB triples, 0..63 range
offset 0x0300..0xfcff   64,000-byte 320x200 chunky screen
```

Each file is exactly 64,768 bytes:

```text
768 + 320*200 = 64,768
```

The public Demozoo screenshot below shows the main vector-ball/scroller screen,
which the local scripted DOSBox-X run did not reach.

![Headbanger's Ball public Demozoo vector-ball screenshot](images/headbangers-ball-demozoo-02-main.png)

The decoded DAT end screen matches the public Demozoo end screenshot:

![Headbanger's Ball public Demozoo end screenshot](images/headbangers-ball-demozoo-03-end.png)

## Runtime Capture

DOSBox-X 2026.01.02 was run with SDL dummy video/audio, `machine=svga_s3`,
`core=normal`, `cycles=30000`, `nosound=true`, `sbtype=none`, `xms=true`,
`ems=false`, and the public Hornet archive. The scripted startup selected the
386/25 MHz path, no Sound Blaster, and sent one SPACE during the intro. Timing
zero is the start of `dx-capture /v HEADBANG.EXE`.

The capture produced an about 29.04-second H.264 stream. Because the process was
killed by the wrapper timeout, `ffmpeg` reported decode warnings near random
access points, but the selected frames below are visually usable.

The scripted run got through the setup and splash/credit sequence. It did not
reach the main vector-ball/scroller loop. Pouet's page notes that SPACE is
needed after the intro screen; the local autotype path was not enough to hit
that gate reliably. The main-loop discussion below is therefore static analysis
plus the public Demozoo still, not a locally timestamped run of the vector-ball
part.

At `00:05.000`, the code credit splash is fading:

![Headbanger's Ball sparse runtime splash sequence](images/headbangers-ball-runtime-sequence.gif)

![Headbanger's Ball runtime frame at 00:05.000 showing the code credit fade](images/headbangers-ball-runtime-00-05-000.png)

At `00:10.000`, the music credit is visible:

![Headbanger's Ball runtime frame at 00:10.000 showing the music credit](images/headbangers-ball-runtime-00-10-000.png)

At `00:15.000`, the scroll-text credit is visible:

![Headbanger's Ball runtime frame at 00:15.000 showing the scroll-text credit](images/headbangers-ball-runtime-00-15-000.png)

The GIF above is assembled directly from those three 320x200 DOSBox-X splash
frames. It is intentionally only splash-sequence coverage; the main
vector-ball/scroller loop remains represented by the public Demozoo still and
static code analysis because the local scripted capture did not reach that gate.

## Runtime-To-Code Concordance

The visual evidence has three different trust levels: decoded local assets, a
local DOSBox-X splash capture, and public Demozoo stills for the part the local
keyboard script did not reach. The table keeps those boundaries explicit.

| Evidence | Code anchor | What it explains |
| --- | --- | --- |
| Decoded DAT contact sheet, including the title/credit/end full screens | DAT loader around `0x7207A`, mode set `INT 10h / AX=0013h`, file read into the `0xFD00`-byte buffer at `b994:b996`, display helper `0x71E47` | The external `BANG*.DAT` files are not compressed part executables. Each is a 768-byte VGA palette followed by a 64,000-byte mode-13h screen, copied directly to `A000h` after the DAC is blacked. |
| Local splash GIF frames at `00:05`, `00:10`, and `00:15` | Same DAT display path plus palette work area `b998h` and the single-color/palette routines at `0x0D61` and `0x71DB2` | The visible splash/credit progression is asset display plus palette work, not the vector-ball renderer. This is why the GIF is correctly described as splash coverage only. |
| Public Demozoo vector-ball/scroller still | Startup speed selector `0x11B1..0x11F9`, ball-count variable `ds:4A64`, main loop `0x162D`, script caller `0x1933` | The main screenshot belongs to the loop gated after the intro. The machine-speed prompt directly changes how many ball objects the loop updates and draws. |
| The smooth bottom scroller in the public main still | Glyph lookup at `0x1673..0x167D`, 8-row shift buffer at `0x168B..0x16AC`, shaded remap/copy at `0x16AE..0x16D1` | Text is not drawn character-at-a-time. Each update inserts one vertical glyph column into an 8-line buffer, then remaps nonzero pixels through a styled source page. |
| The vector-ball positions in the public main still | Precompute routine `0x0C4F`, phase bytes at `9000h`, old phases at `9100h`, x/y offset tables at `8D34h` and `8B34h`, A000h offset tables at `8F34h` and `8F9Ah` | The frame loop does not do expensive geometry for every visible update. It advances phase bytes and turns them into screen offsets with precomputed lookup tables. |
| The round ball silhouettes | Erase kernel `0x174F..0x17DC`, draw kernel `0x17DE..0x1885`, sprite source segment `73A2h:2A80h` | The balls are shaped span sprites. The hard-coded row lengths `9, 13, 15, 17, 17, 19...` are both the mask and the draw program, so the code avoids rectangular masked blits. |
| The stable full-screen timing despite balls and scroller sharing mode 13h | Retrace wait at `03DAh` in the erase path, `rep stosb` erase spans, `rep movsb` draw spans, bottom-band copy at `0x1890..0x18A9` | The renderer touches only old/new ball spans and the bottom text band, synchronized around retrace. Most of the 320x200 framebuffer is not redrawn every update. |
| Sound Blaster prompt and archive size | Fourteen embedded `Creative Voice File` headers, no-sound local capture path, setup prompts for base address and IRQ | The demo has a sample path, but the published local runtime evidence intentionally used no sound. The visual analysis therefore does not infer audio timing from the silent capture. |

That split matters for accuracy: the local GIF proves the splash/DAT display
path, while the main-loop behavior is supported by the public still plus the
static loop disassembly. A later manual run can add timestamps for the main
part without changing the code interpretation above.

## Archive Contents

Examined archive:

```text
headbang.zip  398,105 bytes
SHA-256       c374949711d37dbfd63a8d05d9a4a9d2eb4a0d4bd4bf9cd30d51953f25ef285c
```

Extracted files:

| File | Size | SHA-256 | Role |
| --- | ---: | --- | --- |
| `bang1.dat` | 64,768 | `5cc38f0fe39674af874e9a505b2a1fbc9656f5f0ab128ee7e2ddc38c44d66118` | decoded title/presents screen |
| `bang2.dat` | 64,768 | `e772214afd2c1682647f8efefc1cf913fe0080dc5d6033869c6f9aeade0a7e0f` | decoded subtitle screen |
| `bang3.dat` | 64,768 | `885ea64e4d99bc45983cc1166f7ff3d7a442c2e5beca1cdb2e5cb22501c360ba` | decoded red title screen |
| `bang4.dat` | 64,768 | `1891313def8f6563725a330b9b89a4cb4e028c9760c8063ae2a9233d072d4de3` | decoded credits screen |
| `bang5.dat` | 64,768 | `c2215f88824416e3a6ee8c4a795e4d266eef6c76a4568043802dd679190c8985` | decoded end screen |
| `headbang.doc` | 632 | `5ab18f7dbe48fac3389dec755529d5680f802ecbed2aab7c57291d8aeca96ed7` | release note and credits |
| `headbang.exe` | 508,960 | `a01765bd3d407bc8ac388b403b30675916409687e287e77b92ac8694f259274f` | main demo executable |

The DOC credits the demo as:

```text
Coding:     Lord Cyrix
Graphics:   Lord Cyrix and W.Axl Rose
Music:      Threat To Society
Scroll:     W.Axl Rose
```

## MZ Shape

`HEADBANG.EXE` is not packed as an overlay appended after a small loader. It is
a single large MZ image:

```text
file size:          508,960 bytes
MZ image size:      508,960 bytes
overlay size:             0 bytes
header size:          1,360 bytes
relocations:            330
initial CS:IP:      0000:14c4
initial SS:SP:      81fb:4000
entry file offset:   0x1a14
```

The runtime strings include Borland evidence:

```text
Runtime error
Portions Copyright (c) 1983,90 Borland
```

That matches the program shape: a Borland real-mode runtime plus many far calls
into library code around segment-like addresses such as `722f:` and `71cd:`.
The interesting demo work is still hand-shaped around direct VGA and Sound
Blaster use.

## Startup Control

The first user-visible setup asks for a speed class:

```text
Press A:486  B:386 33Mhz  C:386 25Mz  D:386SX  E:286 12mhz
```

The code maps that key directly to the ball count at `ds:4a64`:

```asm
11b1  cmp al,41h          ; A/a
11b9  mov word [4a64],0019h

11c1  cmp al,42h          ; B/b
11c9  mov word [4a64],0009h

11d1  cmp al,43h          ; C/c
11d9  mov word [4a64],0008h

11e1  cmp al,44h          ; D/d
11e9  mov word [4a64],0007h

11f1  cmp al,45h          ; E/e
11f9  mov word [4a64],0003h
```

So the "CPU speed" selector is not cosmetic. It scales the amount of work in
the vector-ball loop:

```text
A 486        25 balls
B 386/33      9 balls
C 386/25      8 balls
D 386SX       7 balls
E 286/12      3 balls
```

That is a period-correct way to keep the same effect alive across machines:
reduce the object count while keeping the drawing kernel unchanged.

The next prompt asks whether to use Sound Blaster. If yes, the code asks for
base address and IRQ. The executable contains fourteen `Creative Voice File`
headers, so the Sound Blaster path is sample-based rather than only FM music.
Several VOC blocks start with normal Creative Voice File headers:

```text
0x001ca0  Creative Voice File ...
0x003490  Creative Voice File ...
0x00a0e0  Creative Voice File ...
0x010b10  Creative Voice File ...
0x017a40  Creative Voice File ...
...
0x05e5a0  Creative Voice File ...
```

The local capture used the no-sound path to avoid audio hardware negotiation.

## DAT Loader

The executable stores the DAT filenames internally:

```text
bang1.dat
bang2.dat
bang3.dat
bang4.dat
bang5.dat
```

The loader around `0x7207a` switches to mode `13h`, allocates `0xfd00` bytes,
opens the selected DAT, and reads the entire file into that buffer:

```asm
72083  mov ax,0013h
72086  int 10h

720aa  mov ax,fd00h
720ad  push ax
720ae  call 722f:023f       ; allocate 64,768 bytes
720b3  mov [b994],ax
720b6  mov [b996],dx        ; far pointer to DAT buffer

720bf  les di,[b994]
720c5  push fd00h
720cd  call 722f:168a       ; read file into buffer
```

The DAT display helper at `0x71e47` first blanks the DAC, then copies the
screen bytes:

```asm
71e47  push ds
71e48  mov  al,00h
71e4a  mov  dx,03c8h
71e4d  out  dx,al
71e4e  mov  cx,0300h
71e51  mov  dx,03c9h
...
71e5e  mov  al,00h
71e61  out  dx,al
71e62  loop 71e5e           ; black out 768 DAC bytes

71e64  mov  ax,a000h
71e67  mov  es,ax
71e69  mov  cx,fa00h
71e6c  mov  di,0000h
71e6f  mov  si,0300h
71e72  rep  movsb           ; copy 64,000 pixels to A000h
```

Then it preserves the palette from the beginning of the DAT buffer into an
internal palette work area:

```asm
71e79  mov si,0000h
71e7c  mov di,b998h
71e7f  mov cx,0180h
71e82  ...
71e88  lodsw
71e8b  stosw                ; copy 768 palette bytes as 384 words
71e8c  loop 71e82
```

That confirms the decoded DAT layout:

```text
DAT + 0x0000  palette
DAT + 0x0300  screen
```

## Palette Work

There are two palette styles.

The simple single-color writer waits for vertical retrace and writes one RGB
entry:

```asm
0d61  call 0c3f             ; wait retrace
0d64  mov  al,[bp+0a]       ; color index
0d67  mov  dx,03c8h
0d6a  out  dx,al
0d6b  mov  dx,03c9h
0d6e  mov  al,[bp+08]       ; red
0d71  out  dx,al
0d72  mov  al,[bp+06]       ; green
0d75  out  dx,al
0d76  mov  al,[bp+04]       ; blue
0d79  out  dx,al
```

The main part has a palette cycling routine around `0x71db2`. It rotates a
slice of the in-memory palette and streams the changed range back to the DAC:

```asm
71dc0  mov ah,01h
71dc2  int 16h              ; key poll
71dc4  je  71dcc
71dc6  mov ah,00h
71dc8  int 16h              ; consume key and leave

71dcc  mov bx,0030h
71dcf  mov al,[bx+b998h]    ; save first RGB triple
71dd6  inc bx
71dd7  mov al,[bx+b998h]
71dde  inc bx
71ddf  mov al,[bx+b998h]

71de6  mov cx,00f0h
71dec  mov bx,ax
71dee  add bx,0003h
71df1  mov dl,[bx+b998h]
71df8  mov [bx+b998h-3],dl  ; shift palette bytes down by one RGB triple
71dfc  inc ax
71dfd  loop 71dec

71dff  mov bx,011dh
71e02  restore saved triple at end of range

71e19  mov dx,03dah
71e1e  in  al,dx            ; wait out of retrace
71e23  in  al,dx            ; wait into retrace

71e28  mov ax,0010h
71e2b  mov dx,03c8h
71e2e  out dx,al            ; start color 16
71e2f  mov dx,03c9h
71e32  mov bx,0030h
71e35  mov cx,0120h
71e38  mov al,[bx+b998h]
71e3c  out dx,al
71e3d  inc bx
71e3e  loop 71e38
```

`0x120` bytes is 96 RGB entries. It is cheap: the visible color motion is a
palette shift, not a redraw of the full image.

## Ball Path Precompute

Before entering the main loop, `0x0c4f` builds lookup tables. It iterates 256
times and stores two word tables plus one phase byte table:

```asm
0c80  xor ax,ax
0c82  mov [89c0],ax         ; index = 0

0c8b  load current 3-word phase state
0c94  call math helper
0ca1  call math helper
0cb3  call math helper
0cbd  call scale/helper
0cc8  mov [di+8d34h],ax     ; first word table

0cd5  call second math path
0cef  call math helper
0cf4  call math helper
0cff  mov [di+8b34h],ax     ; second word table

0d03  push 0100h
0d06  call random/helper
0d0f  mov [di+9000h],al     ; initial phase byte

0d13  advance phase state
0d33  cmp [89c0],00ffh
0d3b  loop
```

The code later uses these tables as screen-offset pieces. The exact Borland
floating/integer helper internals are less useful than the outcome: expensive
position math is converted into table reads before the frame loop.

## Main Vector-Ball Loop

The central loop starts at `0x162d`. It is passed a pointer to a scroll-text
script. `0x1933` calls it with a sequence of script blocks:

```asm
193d  push ds:4a6d
1942  call 162d
194c  push ds:4b6d
1951  call 162d
...
19f1  push final script pointer
19f6  call 162d
1a0f  jmp  193d             ; repeat until Esc
```

Inside `0x162d`, the script byte stream is consumed one character at a time:

```asm
165d  mov bx,[89c4]
1661  inc bx
1662  mov [89c4],bx
1666  les di,[bp+04]
1669  mov al,es:[bx+di]
166c  cmp al,40h
166e  jne 1673
1670  jmp 18c7              ; '@' terminates this script block
```

`Esc` is polled through BIOS keyboard services at the top of the loop:

```asm
1642  mov ah,01h
1644  int 16h
1646  je  165d
1648  mov ah,00h
164a  int 16h
164c  cmp al,1bh
1650  mov [4a61],1bh        ; exit flag
```

### Scroller Column Builder

The character code indexes an 8-row glyph table:

```asm
1673  xor ah,ah
1675  shl ax,1
1677  shl ax,1
1679  shl ax,1              ; char * 8
167b  mov bx,ax
167d  mov cl,[bx+3d42h]     ; first glyph row byte
```

The code then scrolls an 8-line working buffer left by one byte/column. Each
row moves `0x9f` words, i.e. 318 bytes, then writes the new rightmost column:

```asm
168b  mov cx,0008h
168e  mov di,0c80h
1691  mov si,0c81h

1694  push cx
1695  mov cx,009fh
1698  rep movsw             ; row shifts left by 2 bytes at a time

169a  mov al,00h
169c  shl ah,1              ; next glyph bit into carry
169e  jae 16a6
16a0  pop cx
16a1  push cx
16a2  mov al,cl
16a4  add al,20h            ; colored new glyph pixel
16a6  stosb
16a7  inc di
16a8  add si,0002h
16ab  pop cx
16ac  loop 1694
```

That is not a font blitter drawing whole characters. It inserts one vertical
column of a character per update, which is why the bottom text scrolls smoothly.

After building the small text buffer, it copies and expands it into a larger
working area:

```asm
16ae  mov si,0c80h
16b1  mov di,1680h
16b4  mov cx,0500h
16b7  rep movsw

16b9  mov si,1680h
16bc  mov di,1680h
16bf  mov cx,0a00h
16c4  lodsb
16c5  cmp al,00h
16c7  je  16d0
16ca  add si,0a00h
16ce  lodsb                 ; replace nonzero with styled pixel
16d0  stosb
16d1  loop 16c2
```

The second pass is a remap/styling pass: source nonzero text pixels are turned
into pixels from another table/page. That gives the scroller its shaded look
without a full proportional font renderer.

### Per-Ball Phase Update

Each frame updates two phase arrays: current and previous. The previous array
is kept so the old ball can be erased before the new ball is drawn:

```asm
16d3  push bx
16d4  mov cx,[4a64]         ; number of balls selected at startup
16db  xor bx,bx

16dd  mov dl,[bx+9000h]     ; current phase
16e1  mov [bx+9100h],dl     ; save previous phase
16e5  add dl,[4a66]         ; speed step, usually 1 or 3
16e9  mov [bx+9000h],dl
16ed  inc bx
16ee  loop 16dd
```

Then it converts phase bytes into screen offsets using the precomputed tables:

```asm
16f0  mov cx,[4a64]
16f4  mov bx,cx
16f6  dec bx
16f7  mov bl,[bx+9000h]
16fb  shl bx,1
16fd  mov dx,[bx+8b34h]     ; y-ish offset

1701  mov bx,cx
1703  mov bl,[bx+9000h]
1707  shl bx,1
1709  mov ax,[bx+8d34h]     ; x-ish offset
170d  add dx,ax

1711  mov bx,cx
1713  shl bx,1
1717  mov [bx+8f34h],dx     ; new A000h offset
1719  loop 16f4
```

The previous phase array is converted into a second offset table at `8f9a` by
the equivalent loop at `0x171d..0x1740`.

### Erase Kernel

The erase pass waits for retrace, switches `ES` to `A000h`, and clears the old
ball shapes. The shape is hard-coded as horizontal spans with 320-byte-ish line
strides:

```asm
174f  mov ax,a000h
1752  mov es,ax
1754  mov dx,03dah
1757  mov ah,08h
1759  cli
175a  cld
175b  in  al,dx
175c  and al,ah
175e  jne 175b
1760  in  al,dx
1761  and al,ah
1763  je  1760

1765  mov cx,[4a64]
176d  mov di,[old_offset_for_ball]
1772  mov al,00h

1774  mov cx,0009h
1777  rep stosb
1779  add di,0135h
177d  mov cx,000dh
1780  rep stosb
1782  mov cx,000fh
1785  add di,0132h
1789  rep stosb
178b  mov cx,0011h
178e  add di,0130h
1792  rep stosb
...
17d2  mov cx,0009h
17d5  add di,0135h
17d9  rep stosb
17dc  loop next_ball
```

The span lengths form a small disk:

```text
9, 13, 15, 17, 17,
five rows of 19,
17, 17, 15, 13, 9
```

This is faster and cleaner than masking a rectangular sprite. The old ball is
erased only where the ball actually occupied pixels.

### Draw Kernel

The draw pass repeats the same shape, but copies bytes from a ball sprite in
the data segment instead of writing zero:

```asm
17de  mov cx,[4a64]
17e6  mov di,[new_offset_for_ball]
17eb  push ds
17ec  mov ax,73a2h
17ef  mov ds,ax
17f1  mov si,2a80h          ; ball sprite source

17f4  mov cx,0009h
17f7  rep movsb
17f9  add si,0135h
17fd  add di,0135h
1801  mov cx,000dh
1804  rep movsb
...
1877  mov cx,0009h
187a  add si,0135h
187e  add di,0135h
1882  rep movsb
1884  pop ds
1885  loop next_ball
```

Because erase and draw use the same span program, the sprite has no separate
mask. The hard-coded span geometry is the mask.

### Bottom Band Copy

After balls are drawn, the text band is copied into display memory:

```asm
1890  mov si,1681h
1893  mov di,e741h
1896  mov cx,0008h

1899  push cx
189a  mov cx,00a0h
189d  rep movsw
189f  mov cx,00a0h
18a2  sub si,0140h
18a6  rep movsw
18a8  pop cx
18a9  loop 1899
```

`0x00a0` words is 320 bytes. The loop copies eight 320-byte rows, then backs
the source by one scanline and copies again. This makes the text band a compact
scanline-copy effect rather than a full-screen redraw. The vector balls and the
scroller coexist because most of the screen is touched only by the shaped ball
spans and the bottom text band.

## Main Loop Shape

Putting the pieces together:

```text
startup:
  choose object count by machine class
  optionally configure Sound Blaster
  switch to VGA mode 13h
  show DAT splash screens with palette fades

precompute:
  build 256-entry x/y offset tables
  seed phase bytes for each ball

per visible update:
  poll Esc
  consume one scroll-script byte
  shift 8 rows of text buffer and insert one glyph column
  remap text pixels through a shaded source page
  update ball phase bytes
  build old and new A000h offsets from lookup tables
  wait for vertical retrace
  erase old ball disks with shaped rep stosb spans
  draw new ball disks with shaped rep movsb spans
  copy/mirror the bottom text band
  occasionally advance the music/sample path
```

The important technical point is the object kernel. The balls look like a
vector-ball field, but the inner loop is a tiny span-sprite engine driven by
precomputed motion tables. That is exactly the right tradeoff for March 1992:
spend memory on tables and shaped sprites, then keep the frame loop to `rep`
string instructions, table reads, and one retrace wait.

## Boundaries

The decoded DAT frames and splash timestamps are verified locally. The
vector-ball/scroller screen is verified from the public Demozoo still and from
static analysis of the main loop, but not from a local timestamped main-loop
capture. A manual or more precise keyboard-injection run should be able to
assign exact timestamps to the main part later.
