Analysis model: gpt-5.5 xhigh, sol high

Last edited: 2026-08-25

# Coma Demo by The Brain Slayer - Technical Dissection

`Coma Demo` is a 1991 MS-DOS VGA/Sound Blaster intro/demo by The Brain
Slayer. The Hornet 1991 index lists it as `comademo.zip 141923 ** Coma Demo by
The Brain Slayer`.

Release year: 1991

This one is small on disk but unusually dense for the period. The distributed
EXE has an end-of-image unpacker, the UNP-restored program has a second custom
block inflater, and the visible runtime ties together mode `13h`, palette
fades, a border/window reveal, a four-voice sample player, a live player-state
meter, a lower-strip glyph compositor, and direct Sound Blaster DMA playback.

![Direct Coma Demo runtime meter clip; lower historical text strip masked](images/coma-demo-runtime-meter.gif)

This is a direct 8.000-second interval from graphics time `00:05..00:13` of a
fresh run of the original packed executable. The 640x400 DOSBox-X frames are
not cropped or resized. Rows `350..399` are black in all 80 GIF frames to omit
the historical lower text; the static monster/title page and the four live
meter columns remain at their original coordinates. The meter, not the masked
strip, is the moving evidence used below.

![Recovered runtime map](images/coma-demo-runtime-map.png)

The second image is the corrected code-path map. It now reflects the same
player, DMA, callback, meter, glyph, particle, and capture ownership proved in
the article; the direct clip remains the primary visual evidence.

## Runtime-Map-To-Code Concordance

The fresh capture makes the ownership split testable instead of merely
plausible:

```text
static ownership:   monster and right-hand title panel from the copied page
live player output: four green columns at logical x=140..178, y=113..167
separate overlay:   logical y=174..199 glyph buffer and 44-particle field
published evidence: direct graphics 00:05..00:13; lower 50 host rows masked
binary basis:       original packed EXE plus UNP-restored disassembly
```

The map's startup path corresponds to the two unpacking layers:

```text
original raw 228B2h
  -> end-stub B0/B2 token unpacker and relocation/fixup handoff

restored raw 0288h
  -> relocated data segment setup,
     0143h XOR-EAh decode of 0BDEh..142Dh,
     VGA display-combination probe,
     mode 13h setup and partial A000h clear
```

The map's visible-graphics path corresponds to the startup that produces the
now-observed static composition:

```text
001Fh palette table
  -> 048Bh DAC upload, 01C7h fade-up, 0205h fade-down,
     01BDh/1823h retrace waits

0924h bulk copy
  -> E100h-byte copy to A000h, exactly 320x180 bytes

0943h/0988h border reveal
  -> repeated top/bottom spans and one-byte-per-row side edges

0A84h custom block inflater
  -> header copy, CRC/bit table generation, code-length RLE,
     canonical decode tables, bit reader, sliding-window copy
```

The map's later path can now be assigned to the direct frame:

```text
1A1Eh sound/demo entry
  -> Sound Blaster base probe, DSP reset/read,
     four-channel row player, DMA channel 1 setup and IRQ refill

1A96h four-channel event-row parser
  -> four 4-byte events per 16-byte row, period/sample/effect/parameter state

21C1h..2755h lane builders
  -> five ticks per row, four fixed-point source walkers, four 0200h-spaced lanes

1671h four-to-one mixer and DMA handoff
  -> average corresponding bytes, arm the next DMA block, wait with VGA callbacks

1210h/123Eh visible callback
  -> lower-strip state machine and particles, then four player-state columns

04A6h particle overlay
  -> 44 records, guarded erase/advance/plot, 013Fh wrap
```

The direct frame also corrects the earlier interpretation of `1A96h`. It is not
a text-script parser. The four repeated decoders feed four sample voices and
the meter reads their newly self-patched event words. Text belongs to the
independent `07AFh..0910h` callback path.

The executable includes a rude anti-disassembly text marker near the start of
the image. It is not operationally important and is intentionally not quoted
here.

## Sources

- Hornet 1991 demo index:
  https://ftp.scene.org/mirrors/hornet/demos/1991/00_index.txt
- Scene.org archive:
  https://ftp.scene.org/mirrors/hornet/demos/1991/comademo.zip
- Scene.org file page:
  https://files.scene.org/view/mirrors/hornet/demos/1991/comademo.zip

## Archive

The examined archive is `comademo.zip` from the Hornet mirror:

```text
comademo.zip  141923 bytes
```

ZIP contents:

```text
comademo.exe  141923 bytes  1991-04-27 17:04
demosite.com    1104 bytes  1992-10-21 18:43
```

Hashes:

```text
40e8eb9eb46333b91cb6819e26ff8e8da56da1b8648655b172a071c5b0724db6  comademo.zip
fa513e2abbcc06782c6d9e490766454c5dd190618d1d4032c8fb539b31d67395  comademo.exe
ae4377ea5ad7ace3149992f111f8384a81a71b1d658cd2fe453291ab14b26d6f  demosite.com
78b55834791a38785a3977455f265c11898e0daa18a6e186e69fab84462cd96d  comademo-unpacked.exe
```

## Runtime Capture Status

The stable run used the original packed `COMADEMO.EXE`, not a patched or
UNP-restored runtime file:

```text
emulator                 DOSBox-X 2024.03.01 SDL2
machine / CPU            svga_s3 / normal core / 9000 cycles
memory                   16 MiB
guest device             SB16, base 220h, IRQ 7, DMA 1, HDMA 5
host output              disabled; SDL audio dummy and mixer nosound=true
capture command          DX-CAPTURE /V /-A COMADEMO.EXE
action                   host-bounded run, then SIGINT after the useful interval
graphics stream          ZMBV, 640x400, 3,784 frames
graphics rate            2190197/31250 fps, about 70.086304 fps
graphics duration        53.990577 seconds
raw capture SHA-256      e2812d6a5f234191d3d77dd0bb5352bc06309a7198390a463d335b551ac53012
```

`/-A` did not make the private AVI's PCM track inert: a numeric-only
`volumedetect` pass measured `-15.0 dB` mean and `-1.2 dB` maximum. That track
was never monitored or auditioned. The preservation intermediate was therefore
normalized to video-only FFV1 with `-an` before the public GIF was made; no
audio or video file is published.

Observed sequence:

```text
00:00 onward   complete monster/title composition is stable
00:00 onward   four green columns rise and decay independently
00:00 onward   lower text cards and sparse particles update separately
00:05..00:13   exact interval used by the published 80-frame, 10 fps GIF
```

The earlier capture failure was real but configuration-specific, not a property
of the demo. The keyboard path it exposed still matters for exit timing:

```asm
0385: in   al,60h
0387: mov  [0005h],al
...
03B5: in   al,60h
03B7: cmp  al,[0005h]
03BB: je   03A9h
```

The main player performs a similar comparison at `2834h..283Bh`; a changed
port-`60h` byte leaves the row loop and restores the IRQ/DSP/video state.

## MZ Layout And Unpacking

The distributed executable is a packed MZ image with no relocation table. Its
entry point is at the very end of the file, which is the usual sign that the
real program has been packed into the load image and the stub expands it
backwards into its final layout.

Packed executable:

```text
file size        141923 bytes
MZ header            32 bytes
load image       141891 bytes
relocations           0
min alloc         3817h paragraphs
max alloc         FFFFh paragraphs
entry             2288:0012
entry raw         228B2h
stack             2329:0080
```

UNP restores a conventional-looking MZ body:

```text
file size        143824 bytes
MZ header           272 bytes
load image       143552 bytes
relocations          59
min alloc         37AFh paragraphs
max alloc         FFFFh paragraphs
entry             0000:0178
entry raw         0288h
stack             4CBB:E000
relocation table  001Ch
```

Address convention in this note:

```text
0288h, 0A84h, 1A1Eh  raw file offsets in the UNP-restored executable
228B2h               raw file offset in the original packed executable
0279h, 3CBBh         restored relative segment constants before DOS relocation
```

One segmented-address detail matters later. The main program's raw `03A0h`
far call is encoded as `F3h:09DEh`. Adding the `0110h` MZ header gives its raw
target exactly:

```text
0110h + (00F3h * 10h) + 09DEh = 1A1Eh
```

The player therefore executes with `CS = load segment + 00F3h`. Raw file
offsets in that player are not the same thing as live offsets within that
`CS`; the same conversion must be used for interrupt pointers.

The restored executable has a normal relocation table. For example, raw
`028Ch` is a relocation entry, so the literal `0279h` in:

```asm
0288: mov sp,E000h
028B: mov ax,0279h
028E: mov ds,ax
0290: mov es,ax
```

is not a fixed physical segment. DOS adds the program load segment to it. In
plain English: `0279h` means "the demo's data segment, relative to the loaded
EXE", not absolute real-mode segment `0279h`.

## The Original End-Stub

The original entry at raw `228B2h` starts with a compact unpacker. It first
uses the incoming DOS `ES` value to derive the load segment, moves the packed
image backwards, then enters a two-token decompression loop.

Setup shape:

```asm
push cs
pop  ds
mov  ax,es
add  ax,0010h        ; MZ load segment
mov  [0004h],ax
add  ax,[000Ch]
mov  es,ax
mov  cx,[0006h]
mov  di,cx
dec  di
mov  si,di
std
rep  movsb          ; move image backward before expansion
```

The token stream is byte-marker plus word-count:

```text
marker byte -> DL
count word  -> CX

(DL & FEh) == B0h  literal run: read one byte, rep stosb
(DL & FEh) == B2h  raw copy:    rep movsb from stream
(DL & 01h) != 0    last token; apply fixups and jump to restored entry
```

The two inner loops are intentionally tiny:

```asm
; B0 family: repeat one byte
lodsb              ; AL = fill byte
rep  stosb         ; write CX copies backward/forward according to DF state

; B2 family: literal copy
rep  movsb         ; copy CX bytes from packed stream to output
```

If a marker is neither `B0/B1` nor `B2/B3`, the stub prints a packed-file
corruption message and exits. Once the last-token bit is seen, the stub walks a
relocation/fixup table in `1000h`-paragraph chunks, restores `SS:SP`, and jumps
through the restored entry pointer.

## Restored Startup

The real entry at raw `0288h` begins by selecting the relocated data segment,
then decodes an in-place obfuscated code/data range:

```asm
0288: mov sp,E000h
028B: mov ax,0279h
028E: mov ds,ax
0290: mov es,ax
0292: call 0143h
```

The `0143h` helper XORs bytes from `0BDEh` up to `142Dh` with `EAh`:

```asm
0143: mov cx,142Dh
0146: mov si,0BDEh
0149: sub cx,si
014B: mov di,si
014D: cld
014E: lodsb
014F: xor al,0EAh
0151: stosb
0152: loop 014Eh
0154: ret
```

That is a simple anti-static-analysis layer over the second-stage routines and
tables. The important point is that the UNP output is still not fully
deobfuscated until this helper runs.

The VGA probe follows immediately:

```asm
0295: xor bx,bx
0297: mov ax,1A00h
029A: int 10h
029C: xor dx,dx
029E: cmp al,1Ah
02A0: je  02C7h
...
02C8: cmp bl,06h
02CB: jbe 02A2h
```

If `AL != 1Ah` or the display-combination code remains at or below `06h`, it
prints text-mode VGA/monitor error messages and exits. If accepted, it saves the
old video mode and switches to mode `13h`:

```asm
02CD: mov word [000Eh],0140h  ; 320-byte line pitch
02D3: call 0450h              ; INT 10h AH=0Fh, save mode in [0004h]
02D6: mov al,13h
02D8: call 045Bh              ; INT 10h AH=00h, clear A000h range
```

The mode-set helper clears `36B0h` words, or `6D60h` bytes, from `A000:0000`.
That is more than a small title strip but less than a full 64 KB page; later
bulk copies fill the displayed area.

## Palette Helpers

The palette lives at offset `001Fh` in the relocated data segment. The code
uses fixed RGB triplets and the standard VGA DAC ports.

Copy a palette into the local table:

```asm
0479: push es
047A: push ds
047C: push ds
047D: pop  es
047D: lea  di,[001Fh]
0482: movsw
0483: movsb
0484: loop 0482h
```

The loop count is usually `0100h`, and each iteration copies three bytes, so
the result is a 768-byte `R,G,B` DAC table.

Upload to VGA:

```asm
048B: mov cx,[0000h]      ; number of colors
048F: lea si,[001Fh]
0494: xor ax,ax
0496: mov dx,03C8h
0499: out dx,al           ; start at DAC index 0
049A: inc dx              ; 03C9h
049B: lodsb / out dx,al   ; red
049D: lodsb / out dx,al   ; green
049F: lodsb / out dx,al   ; blue
04A1: loop 049Bh
```

Fade up / saturate:

```asm
01C7: mov dl,[001Ah]      ; fade increment
01CB: mov cx,0180h        ; 768 bytes as 384 words
01CE: lea si,[001Fh]
01D2: mov di,si
01D4: lodsw
      add low byte,DL, clamp to 3Fh
      add high byte,DL, clamp to 3Fh
01EF: stosw
01F0: loop 01D4h
```

The helper decrements a delay byte at `001Ch`; when it reaches zero it reloads
from `001Bh` and increments the fade level at `001Ah`. The startup loop waits
for retrace, calls this helper, uploads the palette, and stops when `001Ah`
reaches `3Fh`.

Fade down / count black:

```asm
0205: xor dx,dx
0208: mov cx,0300h
020B: lea si,[001Fh]
0211: lodsb
0212: or  al,al
0214: je  021Bh
0216: dec ax
0217: or  al,al
0219: jne 021Ch
021B: inc dx
021C: stosb
021D: loop 0211h
```

`DX` counts bytes that are already or have just become zero. The exit loop runs
until `DX == 0300h`, meaning the whole 768-byte palette is black.

The retrace wait is the classic VGA status-port loop:

```asm
01BD: mov dx,03DAh
01C0: in  al,dx
01C1: and al,08h
01C3: je  01C0h
01C5: ret
```

There is a second copy of the same retrace wait inside the audio pacing path at
raw `1823h`.

## Picture Expansion And First Copy

The visible setup path repeatedly fills four state words:

```text
[0010h] source offset
[0012h] source segment
[0014h] destination offset
[0016h] destination segment
```

Then it calls the custom block inflater at `0A84h` or the bulk copy helper at
`0924h`.

The first visible full-page copy is:

```asm
030A: mov word [0010h],0000h
0310: mov ax,3CBBh
0313: mov [0012h],ax
0316: mov word [0016h],0A000h
031C: mov word [0014h],0000h
0322: call 0924h
```

`0924h` is a blunt copy loop:

```asm
0924: push ds
0925: push es
0927: mov ax,[0016h]
092A: mov es,ax
092C: mov di,[0014h]
0930: mov si,[0010h]
0934: mov ax,[0012h]
0937: mov ds,ax
093A: mov cx,7080h
093D: rep movsw
```

`7080h` words is `E100h` bytes. At 320 bytes per row, this is exactly 180
mode-13h rows:

```text
E100h / 0140h = 180
```

So the first copied graphics page is a 320x180 region, leaving 20 rows for
other effects or an undisplayed/later-updated area.

## Border Reveal

The `0943h` helper animates a shrinking/inset rectangle over the copied page.
It starts with:

```asm
0943: ax = 0000h   ; left
0946: bx = 0000h   ; top
0949: cx = 0140h   ; right/width endpoint
094C: dx = 00C7h   ; bottom/height endpoint
094F: call 0988h
```

Then each outer frame pushes the current rectangle, draws five inner rectangles
in `10h`-pixel steps, waits for vertical retrace, restores the outer rectangle,
and tightens it by one pixel:

```asm
0956: mov word [0018h],0005h
095C: add ax,0010h
095F: add bx,0010h
0962: sub cx,0010h
0965: sub dx,0010h
0968: call 0988h
096B: dec word [0018h]
096F: cmp word [0018h],0000h
0974: jne 095Ch
0976: call 01BDh
097D: inc ax
097E: inc bx
097F: dec cx
0980: dec dx
0981: cmp dx,00B3h
0985: jne 094Fh
```

The actual rectangle drawer at `0988h` works against `A000h` and a source page
selected by `[0016h]:[0014h]`. Its four inner shapes are:

```text
top edge:    add x and y*320, rep movsb width bytes
right edge:  copy one byte per row, advance by 319 bytes
bottom edge: add x and bottom*320, rep movsb width bytes
left edge:   copy one byte per row, advance by 319 bytes
```

The one-byte-per-row edges are the giveaway:

```asm
09D7: dec si
09D8: dec di
09D9: movsb
09DA: add si,013Fh
09DE: add di,013Fh
09E2: loop 09D9h
```

`013Fh + 1 copied byte = 0140h`, so each iteration advances exactly one
320-byte scanline.

## Custom Compressed Block Inflater

The second-stage inflater starts at `0A84h`. This is the most substantial
non-visual inner loop in the intro. It is closer to a tiny archive inflater
than to a one-off picture RLE routine.

Call setup:

```asm
0A84: push ds
0A85: push es
0A87: push ss
0A88: pop  es
0A8A: mov di,0014h
0A8D: mov cx,2000h
0A90: xor ax,ax
0A92: rep stosw        ; clear 4000h bytes of work/state
```

It stores the compressed input pointer in stack/work variables:

```asm
0A95: mov ax,[0010h]
0A98: mov bx,[0012h]
0A9C: mov ss:[0522h],bx
0AA1: mov ss:[0524h],ax
0AA5: mov ax,[0014h]
0AA8: mov bx,[0016h]
0AAC: mov ss:[0526h],bx
0AB1: mov ss:[0528h],ax
```

Then it runs three phases:

```text
0AC5h  copy compressed block header into work area at 041Eh
0B66h  build a 256-entry CRC/bit-mixing table at 0414h and onward
0B91h  expand the payload into the destination pointer
```

### Header Copy

`0AC5h` reads a length word from the compressed stream, copies that many bytes
to `041Eh`, and saves the byte count consumed at `051Eh`:

```asm
0AD3: mov di,041Eh
0AD7: lodsw             ; CX = header length
0ADB: rep movsb
0ADD: sub si,ss:[0524h]
0AE2: mov ss:[051Eh],si
```

The generic input-copy helper at `0AEAh` takes `CX` bytes from the compressed
stream and writes them to `DS:DX`, advancing `051Eh` by the number of bytes
copied.

### Table Generation

`0B66h` creates a 256-entry table. It walks byte values from `FFh` down to
`00h`, shifts a 32-bit-ish accumulator through `DX:AX`, and conditionally XORs
polynomial constants:

```asm
0B72: mov cx,0008h
0B75: mov dx,bp
0B77: xor ax,ax
0B79: shr ax,1
0B7B: rcr dx,1
0B7D: jae 0B86h
0B7F: xor dx,8320h
0B83: xor ax,EDB8h
0B86: loop 0B79h
0B88: stosw
0B89: xchg ax,dx
0B8A: stosw
```

That table is then used by the verification/update helper at `0B2Bh`/`1006h`.
The final check in `0BB6h..0BC9h` inverts the accumulated value and compares it
against the expected pair stored in the block header. A mismatch drops into
`int3`, so corrupt compressed data traps immediately under a debugger.

### Code-Length RLE

`0CE4h` decodes packed code lengths into tables. Its byte format is nibble
oriented:

```asm
0D01: lodsb
0D02: mov bl,al
0D06: shr bl,4
0D08: inc bx           ; repeat count = high nibble + 1
0D0B: and al,0Fh
0D0D: inc ax           ; code length = low nibble + 1
0D12: rep stosb
```

So one byte can emit up to 16 copies of a code length from 1 to 16. The helper
is used for both the literal table and the distance/length table.

`0DF1h` takes those lengths and builds canonical decode tables:

```text
0E10h..0E1Fh   count symbols of each bit length
0E1Dh..0E20h   prefix sums
0E33h..0E40h   stable sort symbols by length
0E53h..0E64h   generate code bases
0E77h..0E93h   write reversed/rotated bit codes
```

The repeated `shl dx` / `rcr ax` loop at `0E8Ah` is the bit-reversal step that
makes the later bit-reader cheap.

### Main Bit Reader

The bit-reader state is split across `DX`, `DH`, `CH`, `SI`, and `BP`.
`0F75h` is the primitive:

```asm
0F75: sub ch,cl
0F77: jae 0F8Eh
0F79: neg ch
0F7B: sub cl,ch
0F7D: shr dx,cl
0F7F: dec bp
0F80: jns 0F85h
0F82: call 0FC6h       ; refill compressed input
0F85: mov dh,[si]
0F87: inc si
0F88: mov cl,ch
0F8A: mov ch,08h
0F8C: sub ch,cl
0F8E: xor bh,bh
0F90: shr dx,cl
0F92: mov bl,dl
0F94: ret
```

Callers put the number of requested bits in `CL`. If not enough bits remain,
it pulls another byte from `[SI]` into `DH`. The return value is a table index
in `BL`.

The main inflate loop starts at `0F09h`:

```asm
0F09: mov cl,01h
0F0B: call 0F75h
0F0E: jb  0EEAh       ; zero/clear path: literal handling
```

The one-bit branch distinguishes literal-ish output from copy-back output.
When it reaches the copy-back path, it resolves a length and distance, stores
the distance in `5742h`, and then performs the classic sliding-window copy:

```asm
0F57: xchg ax,cx       ; CX = copy length
0F58: push si
0F59: mov si,di
0F5B: sub si,[5742h]
0F5F: dec si           ; source = output - distance - 1
0F60: rep movsb
0F62: xchg ax,cx
0F63: pop si
```

Once the output pointer crosses the flush limit, `0F95h` writes a block to the
destination through `1006h`/`1011h`:

```asm
1018: push dx
1019: pop  si
101A: mov  di,ss:[0528h]
101F: add  di,[0520h]
1023: mov  ax,ss:[0526h]
1027: mov  es,ax
102C: rep  movsb
1038: add  [0520h],cx
```

The emitted bytes therefore go to `[destination segment]:[destination offset +
total bytes already emitted]`, not directly to the current work buffer.

## Four-Channel Rows And Five-Tick Player

The code path at raw `1A1Eh` is the main player entered after the picture is
visible. It clears state, builds volume and period tables, probes and resets the
DSP, prepares two lane buffers and the DMA buffers, enables the speaker, and
hooks the selected IRQ:

```asm
1A23: call 134Bh      ; clear state; build 32 instrument-state offsets
1A29: call 14E5h      ; 65 x 256 volume-translation table + period table
1A2D: call 1860h      ; probe 220h,230h,240h,250h,260h,210h
1A30: call 1483h      ; reset/test DSP
1A42: call 12C7h      ; order, pattern-segment and period/step tables
1A4A: call 13C5h      ; lane/DMA buffer layout
1A4D: call 1431h      ; DSP D1h speaker-enable command
1A56: call 15E9h      ; install selected IRQ vector
```

The volume-table cost at raw `14E5h..1520h` is exact rather than an estimated
setup label. Its outer index runs through all 65 volumes `0..64`; its inner
index runs through all 256 byte values `0..255`. Startup therefore executes
`65 * 256 = 16,640` signed 8-bit multiplies and writes exactly 16,640 translated
bytes at `[1604h+BX]`. The following period-table pass tests 1,023 candidate
indices `1..1023`; candidates above the threshold in `CS:[001Bh]` each perform
one unsigned divide and one word store. These costs happen before the DSP is
permanently hooked, not in the five-tick steady-state loop.

The old analysis called raw `1A96h` a text parser. Its layout proves otherwise.
`[645Ch]` selects an order entry, `[645Eh]` selects one of 64 rows, and shifting
the row by four selects a 16-byte record:

```asm
1A96: mov bl,[645Ch]
1A9A: mov bl,[634Ah+bx]     ; order -> pattern number
1A9E: shl bx,1
1AA0: mov es,[64ADh+bx]     ; pattern segment
1AA4: mov bl,[645Eh]
1AAA: shl bx,4              ; row * 16
```

The row is four consecutive 4-byte channel events at offsets `+0`, `+4`, `+8`
and `+0Ch`. All four decoders at raw `1A96h`, `1C3Dh`, `1DCDh`, and `1F5Dh`
apply the same split:

```text
event word low 12 bits                     period/note value
event word high nibble + byte 2 high nibble  instrument/sample number
byte 2 low nibble                          effect number
byte 3                                     effect parameter
```

The channel families are regular rather than incidental:

```text
period/sample cursor     5764h, 5766h, 5768h, 576Ah
volume 0..64             6464h, 6465h, 6466h, 6467h
signed period delta      5724h, 5726h, 5728h, 572Ah
source phase             5F6Ch, 5F70h, 5F74h, 5F78h families
effect ramp, five words  63D0h, 63DAh, 63E4h, 63EEh
lane source segment      5F7Ch, 5F7Eh, 5F80h, 5F82h
```

The effect jump tables are at `CS:0AF1h`, `0C81h`, `0E11h`, and `0FA1h`, or
raw restored-file offsets `0C01h`, `0D91h`, `0F21h`, and `10B1h` after adding
the 0110h-byte MZ header. For example, raw `1BD2h`/`1BDDh` install
negative/positive period deltas,
`1BE6h` changes volume delta, and `1B73h..1BCEh` derives a five-word ramp from
two parameter-selected period-table entries. The same handler family is
repeated for the other three channels. These are tracker effects applied to
sample resampling state, not glyph commands.

Each event row is divided into exactly five ticks by `[64ABh]`. On every tick,
raw `21C1h..2211h` adds the base delta plus the next word of each channel's
five-word ramp. The four resamplers then run in order at raw
`222Eh..236Bh`, `237Ch..24B9h`, `24CAh..2607h`, and `2618h..2755h`.
Their destinations are four equally sized lanes:

```text
lane 0  [5722h] + 0000h
lane 1  [5722h] + 0200h
lane 2  [5722h] + 0400h
lane 3  [5722h] + 0600h
```

One common-path output byte is instruction-backed:

```asm
lodsb                    ; fetch current source sample
dec si                   ; cancel implicit increment
es xlatb                 ; volume-translate through 1604h + volume*256
stosb / packed stosw     ; write this voice's lane
add dl,dh / adc si,bp    ; advance 8.16-like source phase
```

Effects can select the mirrored `sub/sbb` form. `CX` is the exact chunk length,
so a chunk writes `CX` bytes per lane and `4*CX` lane bytes overall. Raw
`2217h..2227h` caps it at `0200h-[63F8h]`; no voice crosses a 512-byte lane
boundary. Source phase, last translated byte, and direction state are saved
after each voice, then `[63F8h]`, `[5722h]`, and the tick remainder advance by
the same `CX` hand-off.

## Four Lanes To One DMA Block

When `[63F8h]` reaches `0200h`, raw `1671h` combines the lanes into the next
DMA buffer. Its inner iteration reads one word at each of offsets `0000h`,
`0200h`, `0400h`, and `0600h`. It sums the four low bytes separately from the
four high bytes, divides both sums by four, and emits one averaged word:

```asm
16A1: mov ax,[si+0200h]   ; lane 1, two samples
16AD: mov ax,[si+0400h]   ; lane 2
16B9: mov ax,[si+0600h]   ; lane 3
16C5: lodsw               ; lane 0 and advance by two
16CE: shr dx,2            ; average low-byte sum
16D1: shr bx,2            ; average high-byte sum
16D4: mov al,dl
16D6: mov ah,bl
16D8: stosw
```

A full block performs 256 such iterations: 2,048 lane-byte reads and 512 DMA-
buffer byte writes. The alternate branch at raw `16E2h..175Dh` retains the low-
and high-byte sum residuals in `DX` and `BX`, adds the next four samples, clamps
each accumulator to `0..03FCh`, then uses `ror 2`/`adc` for rounded quarter-
scale output. It subtracts `output*4` and carries the remaining quantization
error into the next iteration: clipped, rounded error-feedback mixing rather
than a plain shifted average. Raw `175Fh..1813h` resolves the physical DMA
page/address, saves the exact address and count for the IRQ routine, and starts
the first block when required.

## Visible Callback And Four Meter Columns

The player does useful video work while it waits for the DMA interrupt. Raw
`181Eh` calls raw `1210h`, waits until VGA status port `03DAh` has bit 3 set,
and repeats until `CS:[0007h]` is `FFh`:

```asm
181E: call 1210h
1823: mov dx,03DAh
1826: in  al,dx
1827: and al,08h
1829: jz  1826h
1833: cmp byte cs:[0007h],0FFh
1839: jne 181Eh
```

This waits for a retrace-high observation, not a full low-then-high edge. In
the stable run it drives the visible callback at the captured VGA cadence of
about 70.086 fps while the DMA block is in flight. Raw `1813h` pre-sets the
flag when the first DMA block starts, so that first wait can leave after its
initial callback/retrace observation; later steady-state waits depend on IRQ
completion setting the flag.

Raw `1210h` saves all general and segment registers, selects the relocated
`0279h` data segment, far-calls logical `03FDh`--raw `050Dh` after the 0110h-byte
MZ header--and then calls the meter at raw `123Eh`. The order is therefore:

```text
lower glyph/transition state -> 44 particles -> four meter columns -> retrace wait
```

The meter consumes four six-byte self-modifying records at `CS:01E6h`,
`01ECh`, `01F2h`, and `01F8h`. Their first words are patched by the four event
decoders. A zero event decays the current height by one logical scanline
(`0140h` bytes); a nonzero event raises it by three (`03C0h` bytes). The result
is clamped to `0000h..44C0h`, exactly 0..55 rows.

The four baselines begin at `A000:D14Ch`, logical `(x=140,y=167)`, and advance
10 pixels per channel. Each bar is nine pixels wide:

```text
channel 0  x=140..148    channel 1  x=150..158
channel 2  x=160..168    channel 3  x=170..178
vertical   y=113..167 at the 55-row clamp; y=112 is the unwritten boundary
```

Rising rows receive `0A 05 3F 3F 3F 3F 3F 05 0A`; falling rows receive nine
bytes of palette index `01h`. The loop writes only the changed height. One
ordinary rising voice writes `3*9=27` pixels, one decaying voice writes 9, a
clamped/unchanged voice writes none, and four rising voices can write 108
meter pixels in one callback. Those coordinates double directly to the green
columns visible in the 640x400 GIF.

## Lower-Strip Glyph And Transition Pipeline

Raw `050Dh` owns a separate logical 320x26 strip at VGA offset `D980h`, or
logical rows `174..199`. Its state word `[0AB4h]` has three phases:

```text
state 0  raw 07AFh loads a descriptor or raw 0859h emits one more glyph
state 1  raw 0562h dispatches the selected buffer-to-VGA transition
state 2  decrement [0BDCh], then return to state 0 for the next descriptor
always   raw 04A6h updates all 44 particles after the state-specific work
```

The descriptor stream contains 125 references to 65 distinct records and
loops on a `FFFFh` pointer. Raw `07AFh` recovers a destination offset plus a
row-times-320 term, glyph count, optional clear flag, delay scaled by 16,
horizontal/vertical doubling bits, one of nine transitions, and one of the
14-byte color sequences. It preserves the text pointer and destination across
callbacks and deliberately emits at most one glyph per callback.

Raw `0911h` clears `1040h` words--8,320 bytes--in the `SS:0000h` offscreen
strip. Raw `086Eh` turns one character into an eight-byte, 8x8 source glyph.
The two style bits independently double width and height, giving 8x8, 16x8,
8x16, or 16x16 output. The renderer visits all 8 source rows for all 8 source
columns, writes palette data for set bits and zero for clear bits, and repeats
rows/columns as selected. It therefore performs exactly 64, 128, 128, or 256
offscreen byte writes per glyph; background is replaced, not left transparent.
Raw `08F5h` advances through a 14-byte color sequence and wraps at 14.

The nine-entry transition table at data offset `0BCAh` contains logical IPs;
adding the 0110h-byte MZ header gives these raw routines:

```text
0  raw 0571h  advance immediately
1  raw 078Ch  copy all 8,320 buffered bytes to A000:D980
2  raw 05B6h  copy 26 full 320-byte rows through a 16-entry row-offset pattern
3  raw 05F4h  copy 320 columns x 26 bytes through a 16-entry column pattern
4  raw 0647h  reveal one patterned 26-pixel column per callback
5  raw 06B9h  reveal one left-to-right 26-pixel column per callback
6  raw 06BDh  reveal one right-to-left 26-pixel column per callback
7  raw 071Fh  reveal one 320-byte row per callback from the top
8  raw 0723h  reveal one 320-byte row per callback from the bottom
```

The column reveals run across 320 callback positions; the row reveals run
across 26. Each incremental callback copies exactly 26 or 320 bytes
respectively. This closes the lower strip's lifecycle: glyphs replace pixels in
the private buffer, a selected transition presents that buffer, the hold count
expires, and the next descriptor can clear/rebuild it.

## Star/Particle Overlay

The `04A6h` routine is a compact overlay plotter against the lower part of the
screen:

```asm
04A6: mov ax,A000h
04AA: mov es,ax
04AC: mov di,D980h
04B0: mov cx,002Ch
04B3: lea si,[07F8h]
```

Each 14-byte record contains position/delta/timer/color-ish fields. The inner
loop first erases the previous pixel if it still contains the expected color,
then advances and plots the new position:

```asm
04B9: add di,[si+00h]       ; previous/current x contribution
04BB: add di,[si+04h]       ; y/base contribution
04BE: mov dx,[si+0Ch]       ; color/marker in DL
04C1: cmp es:[di],dl
04C6: mov byte es:[di],00h  ; erase old pixel if matched

04CB: mov bx,[si+02h]
04CE: mov [si+00h],bx
04D0: add di,bx
04D2: add di,[si+04h]
04D5: dec word [si+08h]
04DA: cmp byte es:[di],00h
04E0: mov al,dl
04E2: stosb                ; plot if target empty
```

When the per-record timer expires, it reloads from `[si+0Ah]` and adds
`[si+06h]` to the x delta. Negative x deltas wrap by adding `013Fh`, which is
one less than the 320-byte screen pitch:

```asm
04F4: add bx,[si+06h]
04F7: cmp bx,0000h
04FA: jge 0502h
04FC: mov ax,013Fh
04FF: add ax,bx
0501: xchg ax,bx
0502: mov [si+02h],bx
```

That gives the effect a cheap wraparound drift without division.

The loop bound is exact: `CX=002Ch`, the record stride is `0Eh`, and the pass
therefore consumes 44 records or 616 record bytes. Every record performs one
old-location color probe and one new-location zero probe. It can issue at most
one guarded erase and one guarded plot, so a callback performs 88 probes and
between zero and 88 VGA byte writes. The ownership test matters here: these
pixels are the sparse points in logical rows `174..199`; they do not draw the
monster, title, lower glyph shapes, or meter columns.

## Sound Blaster Probe And DMA

The audio setup is direct Sound Blaster code. There is no high-level driver
abstraction in the relevant path.

Base-port probe:

```asm
1860: mov cs:[0013h],0220h
1867: call 1483h
186A: je  18A6h
186C: mov cs:[0013h],0230h
1873: call 1483h
1878: mov cs:[0013h],0240h
1884: mov cs:[0013h],0250h
1890: mov cs:[0013h],0260h
189C: mov cs:[0013h],0210h
```

The test helper resets the DSP through base+`06h`, then waits for `AAh` from
the read/status path:

```asm
1483: dx = base + 6
148B: out dx,01h
1492: xor al,al
1494: out dx,al
1497: call 1464h       ; wait/read DSP data
149A: cmp al,0AAh
149C: je  14A8h
```

`1464h` polls base+`0Eh` up to `0200h` times until the sign bit says data is
available, then reads from base+`0Ah`.

DMA setup at `13C5h` selects DMA channel 1:

```asm
1424: mov al,05h
1426: out 0Ah,al       ; mask DMA channel 1
1428: mov al,00h
142A: out 0Ch,al       ; clear flip-flop
142C: mov al,49h
142E: out 0Bh,al       ; single-cycle read/write mode for ch1
```

The refill/IRQ-shaped routine at `1564h` acknowledges the PIC, acknowledges the
DSP, writes DMA address/count registers, unmasks channel 1, then sends DSP
command `14h` followed by the low and high count bytes:

```asm
1564: pusha
1565: mov al,20h
1567: out 20h,al       ; EOI
1571: in  al,dx        ; DSP acknowledge/read
1580: mov al,05h
1582: out 0Ah,al       ; mask channel
1586: out 83h,al       ; page register
158A: out 02h,al       ; base low/high
15A6: out 03h,al       ; count low/high
15AC: mov al,01h
15AE: out 0Ah,al       ; unmask channel
15BE: mov al,14h
15C0: out dx,al        ; DSP 8-bit DMA output command
15CE: mov al,cl
15D0: out dx,al
15DE: mov al,ch
15E0: out dx,al
15E8: iret
```

### Resolving The Apparently Different IRQ Address

The vector install helper at raw `15E9h` uses DOS functions `35h` and `25h` to
save and replace the selected IRQ vector (`IRQ + 8`). It puts `CS` in `DS`,
then supplies `DX=0524h`:

```asm
15E9: mov al,cs:[0015h]  ; detected IRQ 2, 3, 5, or 7
15ED: add al,08h         ; master-PIC IRQ -> interrupt vector
15EF: mov ah,35h
15F1: int 21h            ; ES:BX = old handler
15F3: mov cs:[000Dh],bx
15F8: mov cs:[000Fh],es
15FD: push ds
15FE: mov ax,cs
1600: mov ds,ax
1602: mov dx,0524h
160B: mov ah,25h
160D: int 21h            ; install DS:DX
```

That `CS:0524h` target is not generated or copied code. The far-call equation
above proves that it is exactly the refill ISR at restored raw `1564h`:

```text
0110h MZ header + (00F3h * 10h) + 0524h = raw 1564h
```

The first eight bytes at both views are the same
`60 B0 20 E6 20 2E 8B 16` (`pusha; mov al,20h; out 20h,al; mov dx,cs:[13h]`).
The old apparent conflict came from comparing a live offset within relocated
`CS` with a raw file offset. No self-modification is needed to connect the
vector to the routine. The complete handler occupies 133 bytes at raw
`1564h..15E8h`, contains 55 static instructions and no calls, and occurs once
as a full sequence in the restored image. The distributed packed executable
also retains those 133 bytes verbatim at raw `1449h`, further excluding the
custom inflater as their source.

### Refill Cost And Count Semantics

One completed IRQ takes the saved page, offset, and block length from
`CS:[0000h..0004h]`, then performs these device operations:

```text
PIC                    1 OUT: non-specific EOI to 20h
DSP acknowledge        1 IN from base+0Eh
DMA channel 1          7 OUTs: mask, page, address low/high,
                               count low/high, unmask
DSP write-status       at least 3 INs from base+0Ch; more while busy
DSP block command      3 OUTs: 14h, count low, count high
fixed minimum total    11 OUTs and 4 INs per completed block IRQ
```

With no 64-KiB carry and all three DSP-ready polls succeeding immediately,
the path executes 53 instructions. It saves and restores eight general-
register words, reads seven CS-relative state words, writes two state bytes,
and mixes or copies zero samples. Every additional busy iteration in any DSP
poll adds three instructions and one `IN`; the carry path adds two instructions
and one temporary byte write.

The count path has an exact, slightly unusual split. `CX` arrives as the block
length. Raw `1590h` decrements it for a 64-KiB boundary test, then `159Dh`
increments it before writing DMA channel 1's count register. Raw `15B0h`
decrements it again before sending the DSP count. Consequently the DMA
controller receives `N`, while DSP command `14h` receives `N-1`; this is what
the binary does, even though the conventional 8237 count is also normally
`N-1`. The carry path writes `CS:[0006h]=FFh`, but both branches immediately
converge on `CS:[0006h]=00h` at raw `159Eh`, so that flag cannot remain set in
this build.

The mixer alternates the two DMA destinations at `[6402h]` and `[6404h]` by
adding two to `[63FCh]` and masking with three. The separate `[6406h]` and
`[6408h]` words select the two 2,048-byte, four-lane work areas. Thus the IRQ
does no mixing: it only rearms the already mixed block and sets
`CS:[0007h]=FFh`; raw `181Eh..183Bh` observes that flag while running the
visual callback.

For an ordinary full block, `CS:[0004h]` is `0200h`, or 512 samples. The DSP
time constant in `CS:[0017h]` is `D3h`, giving the nominal rate
`1,000,000/(256-211) = 22,222.22` samples/s. A block therefore lasts about
23.04 ms and produces about 43.40 refill interrupts/s. Raw `179Fh..180Dh`
contains a second byte-identical copy of the handler's 111-byte programming
body for the synchronous first-block start; later blocks take the 133-byte ISR
entry with its PIC/DSP acknowledgement and `pusha`/`popa` wrapper.

### Probe, Install, And Exit Lifecycle

IRQ discovery is a temporary four-vector transaction. Raw `1968h` saves the
master PIC mask, masks all eight lines, saves vectors `0Ah`, `0Bh`, `0Dh`, and
`0Fh`, and points them at four tiny handlers. Those handlers record IRQ
`2/3/5/7`, acknowledge the PIC and DSP, and return. Raw `18D3h` starts a tiny
DMA/DSP transfer to provoke the interrupt; `19DEh..1A0Ah` restores all four
vectors, then raw `1A0Ch..1A12h` restores the saved PIC mask and enables
interrupts. The permanent install only happens later at raw `1A56h`.

The normal changed-key exit at raw `2861h` unwinds in this order:

```text
1623h  restore the selected IRQ+8 vector through INT 21h/AH=25h
2878h  send DSP D3h, speaker off
2888h  send DSP D0h, halt 8-bit DMA
163Ah  restore vectors 1, 2, and 3 directly under CLI/STI
1483h  reset/test the DSP
03F3h  later main-program exit: clear the NMI-disable bit and STI
0471h  restore the saved video mode
```

The selected master-PIC mask bit is cleared at install (`IN 21h`, AND with the
inverse of `1 << IRQ`, `OUT 21h`) but is not saved and restored by the normal
player cleanup. The temporary probe's mask handling is balanced; the permanent
hook's vector and DSP state are balanced, but its PIC unmask is not. That is a
small but concrete lifecycle leak on return to DOS.

## Why It Feels More Advanced Than The Size Suggests

The production gets leverage from three layers:

```text
outer EXE packer       removes normal static structure
 inner block inflater   stores picture, sample, pattern and glyph data compactly
row player             four events x five ticks feed four resampling lanes
visible callback       lower-strip transitions, particles, and live meters
```

The visible effects are not as individually exotic as later 1993-1995 demos,
but for April 1991 the engineering is fairly ambitious: a custom compressed
asset stream, direct VGA DAC work, four fixed-point sample walkers, a
four-to-one software mixer, DMA-buffer rotation, retrace-time visual callbacks,
and a separate 8,320-byte glyph/transition buffer are all present in one small
intro-style executable.

The formerly unresolved interrupt-vector target is now closed: live
`CS:0524h` and restored raw `1564h` are two segmented views of the same refill
ISR. Together with raw `181Eh..185Fh`, the complete steady-state chain is now
instruction-backed: event row -> five ticks -> four lanes -> averaged DMA
block -> IRQ rearm -> callback -> lower overlay/particles -> four meter deltas
-> retrace-visible frame. The remaining uncertainty is hardware behavior, not
code ownership: the binary's DMA-count `N` versus DSP-count `N-1` split and
the un-restored PIC mask bit are documented as written rather than silently
normalized to conventional driver practice.
