Analysis model: gpt-5.5 xhigh, sol high

Last edited: 2026-08-25

# Destroy Megademo (1991) - Technical Dissection

Release year: 1991

Destroy's `Megademo`, also presented internally with the `X-Hausted` name, is
an unusually recoverable early MS-DOS VGA production. It is not one monolithic
effect program. A resident dispatcher decodes a loading page, then executes
five numbered COM payloads in sequence. The most interesting child, `09`, is a
complete vector-ball pipeline: scripted object selection, three Q1.15
rotations, a flawed but record-wide depth-order pass, orthographic projection,
eight-way bit-alignment dispatch, and specialized masked blitters for one
through four VGA bytes. Payload `18` is a second and genuinely different 3D
engine using an exponential depth-scale table, unsigned face ordering, four
edge walks, scanline bounds, and planar filled or hidden-line output.

The analysis below is code-first. The two runtime GIFs identify the pixels
owned by `09` and `18`; neither substitutes for the recovered inner loops.

## Identity And Sources

- Demozoo production page: https://demozoo.org/productions/188039/
- Pouet production page: https://www.pouet.net/prod.php?which=82829
- Scene.org archive: https://files.scene.org/get/mirrors/scenesp.org/compilations/blastersound_bbs/demos/DESTROY.ZIP

Demozoo identifies the production as an MS-DOS demo by Destroy released on 28
January 1991, with Stone credited for code and Pirate for graphics. The decoded
dispatcher repeats the exact date `28.01.91`, says that every part was written
in assembler, requires VGA, and recommends roughly a 16 MHz machine with an
8-bit VGA card or a 12 MHz machine with a 16-bit VGA card.

The archive used here has SHA-256:

```text
39273477be69cf58b0e451d9c984666aee8468eafc237239bec5a8c1da4e20f1  DESTROY.ZIP
d0cd3c4d8186a8a86c49776909e49ed42b9800c9029d3ed6fa5ea9b96b80cc83  MEGADEMO.COM
b6969943349b6a17837ffccdbafc3a56e36efafebc957f16aef0351f2af24f24  09
8447804279bbe0bae4e73fb2974f7e817ca340c0f5f3a60799c63d4c68d6be3b  18
```

The three extracted-file hashes above were compared with streams read directly
from the ZIP and match byte for byte. `09` and `18` are therefore the released
children, not locally patched or reassembled analysis copies.

It contains three date groups. The January production is exactly
`MEGADEMO.COM` plus files `00` through `26`, all timestamped 28 January 1991.
`BOUNCE!.COM` and `27.BNC` through `2E.BNC` belong to the separate March 1991
*Bounce!* intro. Two 1994 files are unrelated additions. The Megademo
dispatcher never names a file above `26`, so none of the later material is
treated as part of this production.

## Direct Silent Runtime

The untouched `MEGADEMO.COM` was run with DOSBox-X 2024.03.01 on a VGA-only,
286-compatible profile at 3,000 fixed cycles. Host sound was disabled with
`nosound=true`; Sound Blaster and GUS devices were absent. PC-speaker emulation
was retained as a possible guest timing source while the host mixer remained
disabled. Static inspection later found no reachable PIT-speaker setup or
speaker-port writes, and the demo text itself says there is no sound.

The five parts wait for keyboard advancement, so an external X11 helper sent
Escape every 25 seconds after the opening. (`09` and `18` actually accept any
new BIOS-buffered key.) It did not patch the demo or inject code into the guest.
The resulting video stream is an uncropped 640x400 ZMBV capture of the 320x200
VGA output doubled vertically:

```text
Capture duration:  163.670 seconds
Video frames:      11,471
Nominal cadence:   70.086 frames/second
Guest launch:      untouched MEGADEMO.COM
Input:             periodic Escape to advance each child
Audio monitoring:  none
```

The capture wrapper wrote a silent PCM stream even though host audio was
disabled. No audio stream is present in the published PNG or GIF derivatives.

The following timeline is deliberately coarse. It was read at five-second
sampling resolution, so it identifies parts without pretending to recover
single-frame transition times:

| Capture time | Visible state | Executed child |
| --- | --- | --- |
| about 00:05-00:45 | Destroy bull/logo and chunky scroller | `03` |
| about 00:52-01:08 | shaded vector-ball objects and lower status strip | `09` |
| about 01:15-01:30 | lightning backdrop and sinus scroller | `13` |
| about 01:40-01:55 | rotating hidden-line cube objects | `18` |
| about 02:10-02:43 | logo reveals, credits, and final greetings | `26` |

This ten-second excerpt is the vector-ball child only. It is a continuous,
uncropped extraction from capture time 00:54 through 01:04, reduced to 10 fps
without changing the 640x400 frame canvas:

![Destroy Megademo shaded green and grey vector-ball lattice rotating above its status scroller](images/destroy-megademo-runtime-vectorballs.gif)

The still below is the exact uncropped frame at capture time 00:58. The grey
and green balls are the two sprite styles carried in each point record; they
are not filled circles generated by the polygon renderer in `18`:

![Destroy Megademo vector-ball lattice at capture time 00:58](images/destroy-megademo-runtime-vectorballs.png)

The second engine needs separate visual evidence. This continuous 100-frame
GIF is capture time `01:40..01:50`, again uncropped at 640x400 and reduced to
10 fps. It shows payload `18`'s red hidden-line objects and the independently
owned blue bottom text plane:

![Destroy Megademo red hidden-line objects above the blue bottom scroller in payload 18](images/destroy-megademo-runtime-polygon-hidden-line.gif?v=direct-20260825)

The two GIFs are not interchangeable illustrations. The grey/green shaded
spheres belong only to `09`'s masked sprite engine; the red edges belong only
to `18`'s software-plane edge/span engine. All 100 frames of the new excerpt
remain inside that second child and contain no host UI or audio.

## Dispatcher And Resource Chain

`MEGADEMO.COM` is 4,139 bytes and begins with a jump from `0100h` to `0D06h`.
At `0D20h..0D29h` it writes the four-byte sentinel `MEGA` to physical address
`0000:0064h`. Every child checks that marker, which prevents the numbered
payloads from being launched accidentally as ordinary standalone COM files.

The dispatcher constructs filename `02`, reads a two-byte rolling checksum and
`05DCh` data bytes, verifies the stream with:

```asm
rol bx,1
xor bl,[di]
```

and XOR-decodes the data bytes with `B7h`. That overlay supplies the text,
resource names, and exact child chain:

| Dispatcher call | Filename |
| --- | --- |
| `0DCAh..0DD4h` | `03` |
| `0DE1h..0DEBh` | `09` |
| `0DF8h..0E02h` | `13` |
| `0E0Fh..0E19h` | `18` |
| `0E26h..0E30h` | `26` |

Each call is a normal DOS `INT 21h`, function `4B00h` EXEC. The parent remains
responsible for the loading page and inter-part transitions; each child owns
its effect-specific assets and returns after its own keyboard condition.

Most numbered resources use one small signed-control RLE grammar:

```text
u16 output_size
repeat until output_size bytes exist:
    s16 control
    if control >= 0:
        copy control + 1 literal bytes
    else:
        repeat the next byte 1 - control times
```

This is a PackBits-like scheme with 16-bit controls. It explains, for example,
why `00` expands from 19,619 bytes to a complete 64,000-byte loading page while
the palette resources expand to only 96 or 768 bytes.

The code-bearing/resource partition is:

| Child | Visible part | Resources |
| --- | --- | --- |
| `03` | bull/logo and scripted chunky scroller | `04` font, `05` palette, `06` logo, `07` command text, shared `08` fade data |
| `09` | vector-ball point objects | `0A` and `0E` ball colors, `0B`/`10`/`11`/`12` palettes, `0C` OR masks, `0D` AND masks, `0F` status strip, `08` fades |
| `13` | lightning/sinus scroller | `14` font, `15` planar background, `16` palette, `17` commands, `08` fades |
| `18` | filled/hidden-line 3D objects | `19`/`1C`/`1D`/`1E` palettes, `1A`/`1B` bottom-strip fields, `08` fades |
| `26` | logo reveals and final circular scroller | `1F`/`20`/`21` prescaled atlases, `22`/`24` palettes, `23` font, `25` text, `08` fades |

## Payload `09`: Scene And Model Grammar

`09` enters at runtime `678Eh`. Its nine six-byte scene records occupy
`0117h..014Ch`:

```text
+0  word motion-script pointer
+2  word model-sequence pointer
+4  word palette/style selector
```

A model begins with a point count followed by fixed ten-byte records:

```text
word point_count
repeat point_count times:
    s16 x
    s16 y
    s16 z
    u16 sphere_style
    u16 size_class
```

The nine scene families use models containing 24 through 72 balls. The first
visible object at runtime `26D5h` contains 64 records. Its coordinate sets are:

```text
x = -2000, -500, 1000, 2500
y = -2000, -500, 1000, 2500
z = -1500, 0, 1500, 3000
```

That is a complete 4x4x4 lattice. Thirty-two records use style 1/class 5 and
thirty-two use style 2/class 9, alternating through a serpentine storage
order. The green/grey alternation visible at 00:58 therefore comes directly
from model metadata, not from a post-process color cycle.

The model-sequence word is itself a counted pointer stream, not just a single
model address. All nine released streams close exactly:

| Scene | Sequence | Entries / distinct models | Balls | Style 1 / 2 | Nonzero size-class histogram |
| ---: | ---: | ---: | ---: | ---: | --- |
| 0 | `07C5h` | 1 / 1 | 64 | 32 / 32 | `{5:32,9:32}` |
| 1 | `07C9h` | 3 / 3 | 62 | 40 / 22 | `{3:3,4:2,5:1,7:35,10:13,11:8}` |
| 2 | `0845h` | 1 / 1 | 37 | 21 / 16 | `{6:37}` |
| 3 | `080Fh` | 26 / 13 | 26 | 5 / 21 | `{1:3,5:2,7:16,9:1,10:4}` |
| 4 | `0849h` | 1 / 1 | 24 | 16 / 8 | `{3:24}` |
| 5 | `07BDh` | 3 / 3 | 62 | 7 / 55 | `{1:1,7:5,8:1,9:21,10:26,11:8}` |
| 6 | `07B9h` | 1 / 1 | 28 | 12 / 16 | `{2:15,3:6,4:3,5:2,6:2}` |
| 7 | `07D1h` | 30 / 15 | 27 | 3 / 24 | `{1:2,3:1,7:8,8:8,10:2,11:1,12:5}` |
| 8 | `084Dh` | 1 / 1 | 72 | 0 / 72 | `{10:72}` |

Scenes 3 and 7 are authored geometric animation, not merely rotation. Scene 3
contains one 14-entry and one 12-entry palindromic pointer sweep; scene 7 uses
corresponding 16-entry and 14-entry sweeps. Each half duplicates its turning
model before walking backward. Scenes 1 and 5 cycle three coordinate sets;
the other five scenes retain one model. Every variant within a scene preserves
the row's style/class histogram, so animation changes positions without
changing that scene's stamp-size workload envelope.

The first motion program starts at `014Dh`. Ordinary commands are eight signed
words:

```text
d_angle_x, d_angle_y, d_angle_z,
d_posttranslate_x, d_posttranslate_y,
d_pretranslate_x, d_pretranslate_y,
iteration_count
```

Each motion program begins with an ordinary-command count word; marker records
do not consume that count. For example, the segment at `0163h` applies X/Y/Z
angle increments `(8,9,11)`, moves X by `-100`, pretranslates X by `50`, and
runs for 60 controller iterations. Embedded marker
`FFFFh` starts a palette fade, `8000h` installs a 320-byte status strip into
all pages, and `8001h` reverses the fade. The controller at
`6A21h..6BCAh` copies an ordinary segment into live words `6761h..676Fh`, wraps
all three angles modulo `0168h` (360 entries), applies translations, and
advances the model sequence.

Model changes are not pointer-only. `6B75h..6BA3h` reads the count, computes
`5 * count` words, and copies every ten-byte record into staging records at
`3CFFh`. `6BD0h..6C1Dh` then creates transformed records at `44CFh`, preserving
style and size beside the writable coordinates; projected X/Y pairs later go
to the separate bank at `4C9Fh`.

The controller's ordering matters. `68BBh` first renders the current state.
`68BEh..68D4h` then compares the BIOS keyboard-buffer tail with the entry-time
value; any change, not specifically Escape, restores the old tail and exits.
Only after a completed frame and key test does the code step an active palette
fade, consume a new marker/command when duration has expired, apply angle and
translation increments, advance/copy the model sequence, and decrement the
iteration counter. Model animation therefore advances once per controller
iteration rather than only at a motion-command boundary.

## Vector-Ball Transform Inner Loop

The live transform begins at `6BD0h`. A first pass copies X/Y/Z and the two
sprite fields, applying the current pretranslation. Three subsequent passes
rotate the coordinates in 2D planes. Sine begins at `63C3h`; cosine is the
same 450-word sequence with a 90-entry phase displacement at `6477h`.

The multiply is signed Q1.15 but avoids a general divide. A representative
fragment from `6C30h` is:

```asm
mov dx,[bp+44D1h]       ; signed coordinate
mov ax,[si+63C3h]       ; signed Q1.15 sine
imul dx                 ; DX:AX = signed 32-bit product
shr ax,1
rcl dx,1
and dx,7FFFh
or  dx,bx               ; restore saved sign bit
```

Across `6C30h..6DF6h`, pairs of this operation implement three plane rotations.
The extraction is stranger than an ordinary signed shift. If `H:L` is the
signed 32-bit product, the recovered result is:

```text
((H << 1) & 7FFFh) | (H & 8000h) | (L & 1)
```

The inserted bit is the product's low bit, not `L` bit 15. The result can
differ from truncating `product >> 15` by as much as two integer units; it is
neither a rounded matrix multiply nor a perfectly conventional Q1.15 shift.

Normalized, the per-point path is:

```text
p = source_position + scripted_pretranslation
p = rotate_Z(p)
p = rotate_Y(p)
p = rotate_X(p)
p += scripted_global_translation
retain sphere_style and size_class in the same 10-byte record
```

The exact signs and application order are:

```text
Z pass, 6C1Fh..6CBCh:
    x1 = x*cos(z) - y*sin(z)
    y1 = x*sin(z) + y*cos(z)

Y pass, 6CBCh..6D59h:
    z2 = z*cos(y) - x1*sin(y)
    x2 = x1*cos(y) + z*sin(y)

X pass, 6D59h..6DF6h:
    y3 = y1*cos(x) - z2*sin(x)
    z3 = y1*sin(x) + z2*cos(x)
```

Pretranslation at `0109h..010Dh` precedes all three passes. Posttranslation at
`0103h..0107h` follows them, with post-Z initialized to `4000h`.

There is no per-point heap, indirection, or floating-point state. The count at
the head of the model bounds every pass, and the renderer steps records by ten
bytes.

### Flawed full-record depth pass and static size bias

`6E31h..6E9Eh` is intended to order the transformed array by increasing Z. On
a swap it does move all five words—X, Y, Z, style, and size—not merely a
coordinate pointer. The comparison is unsigned `JA`, however, and the outer
pivot remains in `AX` after a swap even though the outer record has changed.
The pass is therefore neither a correct general sort nor stable. Exact-loop
emulation gives 20 adjacent Z inversions during the first `(8,9,11)` rotating
state, although the initial lattice happens to emerge in ascending order.

Immediately afterward, `6EA0h..6ED0h` applies a static size-class bias:

```text
delta = 195 * (size_class - 1)       ; shipped classes 1..12
z += delta
y -= 2 * delta
x += floor(3 * delta / 4)
```

The table at `6747h` contains `0,0,195,390,...,2145` for classes `0..12`.
There is no phase, counter, sign change, or mutation: this is not a wobble.
Its X/Y adjustment feeds projection and is plausibly sprite registration, but
that purpose is an inference. Its post-ordering Z adjustment is dead because Z
is never consumed again in that frame.

### Orthographic projection, not perspective

Projection at `6ED2h..6F3Ch` takes the absolute magnitude of signed X and Y,
shifts by seven, restores the sign, and centers the result:

```text
screen_x = 160 + trunc(x / 128)
screen_y = 100 + trunc(y / 128)
```

The absolute-value/restore-sign sequence truncates negative values toward zero;
calling it an arithmetic signed shift would round those values the wrong way.
No `DIV` or `IDIV` perspective calculation exists. Z feeds the flawed ordering
pass but does not shrink a ball. Apparent sphere size is the model's preassigned
`size_class`, so this remains an orthographic vector-ball engine.

### Controller workload by released scene

The hot transform has a useful closed-form ledger. For `n` points, the first
pass copies five words per record and adds the three pretranslations. Every
nonzero rotation axis then executes four signed multiplies per point; the
ordinary three-axis state therefore costs `12*n` `IMUL`s. Posttranslation and
size bias are linear passes, and projection uses fourteen one-bit shifts per
point—seven for X and seven for Y—with no divide.

The depth pass is quadratic regardless of whether it swaps:

```text
comparisons = n * (n - 1) / 2
one swap    = five outer loads + five memory XCHGs + five outer stores
```

Because the pivot in AX is stale after an exchange, the swap count depends on
the authored order and current rotation, but the comparison count does not.
The controller also copies `5*n` model words into staging for the following
iteration. The exact fixed front end is therefore:

| Scene | Balls | Three-axis `IMUL`s | Unsigned depth comparisons | Staging words copied |
| ---: | ---: | ---: | ---: | ---: |
| 0 | 64 | 768 | 2,016 | 320 |
| 1 | 62 | 744 | 1,891 | 310 |
| 2 | 37 | 444 | 666 | 185 |
| 3 | 26 | 312 | 325 | 130 |
| 4 | 24 | 288 | 276 | 120 |
| 5 | 62 | 744 | 1,891 | 310 |
| 6 | 28 | 336 | 378 | 140 |
| 7 | 27 | 324 | 351 | 135 |
| 8 | 72 | 864 | 2,556 | 360 |

The 64-ball lattice shown at `00:58` therefore performs 768 signed transform
multiplies and 2,016 depth comparisons before any sphere mask is dispatched.
The fixed cleanup after drawing is another 3,800 CPU word stores. With all
four VGA planes enabled those stores clear 30,400 plane-bytes, so CPU bus-store
count and affected planar-byte count should not be conflated.

## Shifted Sphere Dispatch And Blitters

Before drawing, `6F53h..6FAFh` subtracts 12 from projected X and Y, looks up
`y * 40` in the table at `622Bh`, divides X by eight for the VGA byte column,
and retains `x & 7` as the alignment selector. Style zero is a skip; styles one
and two choose decoded color sheets `0A` and `0E`. More precisely, style 1
selects `0A`; every other nonzero value selects `0E`.

There is no clipping or rejection. Subtraction can wrap as an unsigned word,
the Y table has only 200 entries, and each selected width kernel writes its
entire descriptor. Safe authored trajectories—not the renderer—keep sphere
footprints inside the page.

The descriptor table at `5F11h` points to eight records per size class:

```text
u16 source_offset
u16 destination_adjustment
u16 bytes_per_scanline
u16 height
```

The eight records are pre-shifted variants for every possible bit alignment.
Classes 1 through 12 have heights `23,21,...,1`; class 0 aliases class 12's
one-pixel descriptors. Destination adjustment is `160 * (class - 1)` bytes,
equivalent to four scanlines per class step. The class-5 records are 15 rows
high and two or three bytes wide depending on shift; class 9 is seven rows high
and one or two bytes wide. This lets dispatch choose a straight-line kernel
instead of shifting sphere bits in the frame loop.

`715Bh..759Fh` contains four specialized width kernels, beginning at `71AEh`,
`726Dh`, `7355h`, and `7466h`. Each handles one, two, three, or four destination
bytes. The compositor has three hardware-dependent phases but six complete
raster traversals:

1. decoded `0C`, with Sequencer map mask 1 and set/reset enabled, performs the
   first plane-0 masked read/modify/write pass;
2. decoded `0D`, with all planes enabled, read-map 3, bit mask `FFh`, and VGA
   logical AND selected, performs the latch-dependent AND pass;
3. `0A` or `0E` cycles map masks `1`, `2`, `4`, `8`, supplying prepared color
   bits through VGA bit-mask and set/reset state in four more traversals.

Source rows advance by `A0h` bytes because four 40-byte plane rows are
interleaved in each prepared sheet; destination rows advance by `28h`, and the
color source base advances by `28h` between planes.

The hot loops directly program VGA Sequencer ports `3C4h/3C5h` and Graphics
Controller ports `3CEh/3CFh`, including read-map, set/reset, bit-mask, and write
mode state. Width specialization removes a per-byte branch from every sphere
row. The tradeoff is code size: four hard-unrolled families replace one compact
generic masked blitter. Because VGA latches participate, reducing this to a
simple software “AND mask then OR color” formula would be less exact than the
shipped port and pass sequence.

### Exact Sphere-Kernel Traffic

For a descriptor covering `N = width * height` VGA byte positions, the six
traversals perform six source reads, six latch reads, and six CPU framebuffer
writes per position. Plane masking makes the physical write count larger: one
plane in the first mask pass, all four in the AND pass, and one plane in each
of the four color passes, for nine plane-write cycles per position.

```text
source reads       = 6*N bytes
VGA reads          = 6*N
CPU VGA writes     = 6*N
plane-write cycles = 9*N
port OUTs          = 36 + 10*N
row traversals     = 6*height
```

The first visible lattice uses only alignments 0, 1, 4, and 6. Its class-5
records are eight alignment-0, eight alignment-1, and sixteen alignment-4
balls; its class-9 records split eight each across alignments 0, 1, 4, and 6.
The descriptor widths therefore resolve exactly as follows:

| Group | Balls | Sum of `N` | VGA reads | CPU VGA writes | Plane writes | Port `OUT`s |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| Class 5, 15 rows, 2/3 bytes wide | 32 | 1,200 | 7,200 | 7,200 | 10,800 | 13,152 |
| Class 9, 7 rows, 1/2 bytes wide | 32 | 336 | 2,016 | 2,016 | 3,024 | 4,512 |
| **First 64-ball lattice** | **64** | **1,536** | **9,216** | **9,216** | **13,824** | **17,664** |

The descriptor table also closes the whole release, not only that photographed
lattice. Summing `N=width*height` across each scene's fixed class histogram
gives the following exact alignment-dependent bounds. They include every
nonzero-style ball. The lower and upper endpoints choose the narrowest or
widest descriptor available for each class; they bound the machine code but do
not assert that one authored frame realizes all extrema simultaneously.

| Scene | Balls | Sum of `N` | CPU VGA writes (`6N`) | Plane-write cycles (`9N`) | Port `OUT`s (`36*balls+10N`) |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 0 | 64 | 1,184..1,888 | 7,104..11,328 | 10,656..16,992 | 14,144..21,184 |
| 1 | 62 | 1,162..1,708 | 6,972..10,248 | 10,458..15,372 | 13,852..19,312 |
| 2 | 37 | 962..1,443 | 5,772..8,658 | 8,658..12,987 | 10,952..15,762 |
| 3 | 26 | 646..948 | 3,876..5,688 | 5,814..8,532 | 7,396..10,416 |
| 4 | 24 | 1,368..1,824 | 8,208..10,944 | 12,312..16,416 | 14,544..19,104 |
| 5 | 62 | 498..877 | 2,988..5,262 | 4,482..7,893 | 7,212..11,002 |
| 6 | 28 | 1,552..2,037 | 9,312..12,222 | 13,968..18,333 | 16,528..21,378 |
| 7 | 27 | 533..699 | 3,198..4,194 | 4,797..6,291 | 6,302..7,962 |
| 8 | 72 | 360..720 | 2,160..4,320 | 3,240..6,480 | 6,192..9,792 |

This exposes a useful non-obvious result: point count is not raster cost.
Scene 8 transforms and compares the most records, yet its 72 class-10 balls
have the lowest possible framebuffer traffic. Scene 6 has only 28 points but
its larger class-2..6 stamps produce the highest descriptor-position sum and
port-output ceiling. Size classes, alignment, and the six-pass compositor—not
the number of projected centers alone—set the raster load.

Page presentation and clearing then add twelve port outputs, one port input,
and the 3,800 CPU word stores described below. These totals separate CPU VGA
writes from physical plane writes; treating either one as “pixels drawn” would
misrepresent the latch-and-mask pipeline.

## Page Flip And Old-Frame Cleanup

Payload `09` uses VGA mode `0Dh`, 320x200 with four planar color bits. Four
8,192-byte physical pages are addressed through segments `A000h`, `A200h`,
`A400h`, and `A600h`. Mode setup leaves display start `0000h` and draw segment
`A400h`. At `6FB5h..6FD3h`, display start and draw segment advance independently
and without a retrace wait:

```text
draw this iteration:      A400, A600, A000, A200, ...
display after CRTC write: A200, A400, A600, A000, ...
clear for next draw:      A600, A000, A200, A400, ...
```

A rendered page is therefore queued and becomes visible on the following
controller iteration, not immediately after its own draw pass.

After the display flip, `6FD8h..6FE2h` clears exactly `0ED8h` words:

```text
0ED8h words * 2 = 7,600 VGA byte addresses per plane
7,600 / 40 addresses per planar scanline = 190 scanlines
four planes = 30,400 cleared plane-bytes
```

The bottom ten scanlines are left intact, but the status bitmap owns only rows
190 through 197: `0A0h` words, or 320 bytes, are copied to byte offset `1DB0h`
in every page. Rows 198 and 199 are preserved but are not written by that
routine.

This establishes the cleanup mechanism precisely: the demo clears the entire
top 190 rows of the next page before reusing it. It does **not** retain a list
of old ball rectangles and does not selectively restore the background under
each old sphere. A first-frame flag at `4FFEh` suppresses the initial draw into
`A400h`; avoiding an uninitialized presentation is a plausible purpose, not a
symbol-backed fact.

The complete frame is therefore:

```text
transform every staged 10-byte point record through Z, Y, then X
run the unsigned stale-pivot full-record depth pass
apply the static size-class X/Y bias
project X/Y with truncation toward zero and center at 160,100
for each resulting record:
    choose style, size class, and x&7 descriptor
    call the specialized 1/2/3/4-byte latch-aware planar compositor
advance CRTC display start to the page drawn one iteration earlier
rotate draw segment and clear rows 0..189 of the next page
preserve status rows 190..197 plus untouched rows 198..199
check for any new BIOS key; then update fade/script/model/motion state
```

### Child Exit And Allocation Cleanup

Any new BIOS-buffered key branches to `774Ch`; allocation and file-open errors
use the same target. The child then issues DOS function `49h` for nine saved
segments, closes the saved resource handle, and terminates with function `4Ch`.
It does not restore text mode: control returns to the resident dispatcher,
which owns the between-part presentation and launches the next child. The
termination call sets AH only, so it does not deliberately publish a stable
AL error status.

This is full resource teardown rather than process-exit leakage, although an
early failure can reach the list before every segment slot or handle has been
successfully filled. DOS rejects any invalid free/close and the code ignores
those carry results before terminating. No custom IRQ, PIT, or speaker state
needs restoration in this child.

## Payload `18`: A Separate Polygon Engine

The objects visible around 01:40-01:55 are not produced by the vector-ball
code. Child `18`, entering at runtime `4469h`, has nine ten-byte scene records:

```text
+0  point-array pointer
+2  face-array pointer
+4  motion-script pointer
+6  palette selector
+8  renderer mode
```

The complete scene directory is:

| Scene | Points | Faces | Script | Palette | Renderer |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 0 | `021Bh` | `071Bh` | `1473h` | 4 | 2 |
| 1 | `02C1h` | `04B1h` | `0E95h` | 3 | 2 |
| 2 | `037Fh` | `09D9h` | `11EBh` | 2 | 2 |
| 3 | `0171h` | `0BBDh` | `13C5h` | 2 | 1 |
| 4 | `027Dh` | `05DFh` | `0FD5h` | 1 | 1 |
| 5 | `044Fh` | `0B07h` | `0CF7h` | 4 | 1 |
| 6 | `0317h` | `08E7h` | `10BFh` | 2 | 1 |
| 7 | `03EDh` | `07B9h` | `1317h` | 1 | 1 |
| 8 | `02C1h` | `04B1h` | `0D83h` | 3 | 1 |

Point arrays hold a count and six-byte signed XYZ vertices. Face arrays hold a
count and twelve-byte records:

```text
u16 vertex[4]
u16 color
u16 depth_scratch
```

Renderer mode is scene-level. The face color is a three-bit value consumed by
mode 1 and ignored by mode 2. Repeated indices let the uniform four-index record
encode triangles or line-like faces as well as quadrilaterals. The loader at
`44B3h..44D5h` deliberately copies `count + 1` face records; every array ends
with a `0,0,0,0,0,FFFFh` guard that participates in sorting but is not drawn.

### Table-scaled projection

The transform at `4716h` uses local sine/cosine tables at `3639h` and `36EDh`.
Source points at `1A45h` pass through pretranslation, XY, XZ, and YZ rotations,
then posttranslation into `1EF5h`:

```text
x1 = cZ*x0 - sZ*y0
y1 = cZ*y0 + sZ*x0
z1 = z0

x2 = cY*x1 + sY*z1
y2 = y1
z2 = cY*z1 - sY*x1

x3 = x2
y3 = cX*y2 - sX*z2
z3 = cX*z2 + sX*y2
```

The code ranges are `4716h..4750h` for source plus pretranslation,
`4751h..47E5h` for XY, `47E6h..487Ah` for XZ, `487Bh..490Fh` for YZ, and
`4910h..494Ah` for posttranslation. Motion updates angles at `010Fh`, `0111h`,
and `0113h`, while transform applies them in reverse storage order: `0113h`,
`0111h`, then `010Fh`.

Projection at `4955h..49FBh` is different from `09`:

```text
if signed z < 0:
    screen = (160,100)
else:
    q = unsigned(z) >> 5
    if z bit 4 = 0:
        scale = T[q]
    else:
        scale = (T[q] >> 1) + (T[q+1] >> 1)
    screen_x = 160 +/- high16((abs(x) >> 4) * scale)
    screen_y = 100 +/- high16((abs(y) >> 4) * scale)
```

The interpolation is the sum of two independently truncated halves, which can
differ from `(T[q] + T[q+1]) >> 1`. The 1,024 words start at `39BDh`; the last
word starts at `41BBh` and ends at `41BCh`. Their exact 2,048-byte SHA-256 is
`26facc23bf6ed3bf0042c570d23e2c84356c19a1258988ce1f6dcd3fd54db8c6`.
Every word is strictly greater than its predecessor:

| `q` | `T[q]` |
| ---: | ---: |
| 0 | 0 |
| 1 | 12 |
| 16 | 207 |
| 32 | 423 |
| 64 | 884 |
| 128 | 1,930 |
| 256 | 4,627 |
| 512 | 13,660 |
| 768 | 31,294 |
| 1,023 | 65,535 |

An exhaustive numerical reconstruction identifies an exponential/geometric
curve rather than a reciprocal table:

```text
T(q) ~= 65535 *
        (exp(2.6732498842466246 * q / 1023) - 1) /
        (exp(2.6732498842466246) - 1)
```

Nearest-integer evaluation matches 821 words exactly; the other 203 differ by
one, and the maximum real-valued error is 1.396 table units. That proves the
curve class closely enough to reproduce the table numerically, but not the
author's original expression, floating-point precision, or quantizer.

There is no table-index clamp. Signed-positive Z bounds `q` to 1,023, but
interpolation for `z >= 32752` would read `T[1024]`. Authored coordinates must
avoid that case.

### Face sorting, edge walking, and spans

`4A11h..4A6Bh` does not compute a signed arithmetic average. Logical shifts
produce this pairwise, truncating unsigned key:

```text
key = (((u16(z0) >> 1) + (u16(z1) >> 1)) >> 1)
    + (((u16(z2) >> 1) + (u16(z3) >> 1)) >> 1)
```

Negative Z words consequently behave as large unsigned values. `4A79h..4AF4h`
uses unsigned `JA` and swaps all six words when the current key is greater,
ordering ascending unsigned depth. It is not stable: nonadjacent exchanges can
move equal-key records past one another even though equal records are not
directly exchanged. The trailing `FFFFh` guard normally remains last.

The exact edge arrays are `left[200]` at `26D5h..2863h` and `right[200]` at
`2865h..29F3h`; `4D6Eh..4D7Ah` initializes all 400 words to `FFFFh`. Four calls
at `4D8Fh`, `4DA6h`, `4DBDh`, and `4DD4h` enter the walker at `54CDh`:

```text
steps = max(abs(x1-x0), abs(y1-y0))
repeat steps times:
    left[y]  = min(left[y], x)
    right[y] = max(right[y], x)
    advance Bresenham error and current x/y
```

Each nonzero edge records its start and excludes its terminal endpoint. The
following closed edge contributes that shared vertex; a zero-length edge uses
a special one-point path. Minimum and maximum vertex Y then bound an inclusive
scanline loop. Exact masks are:

```text
29F5h  FF 7F 3F 1F 0F 07 03 01   left endpoints
29FDh  80 C0 E0 F0 F8 FC FE FF   right endpoints
3631h  80 40 20 10 08 04 02 01   single pixels
34A1h  200-word y*40 offset table
```

Neither walker nor span path clips X or Y. `BP=2*y` directly indexes the
200-row arrays, and complete spans can run outside 0..319. The arrays are an
authored-content contract, not a clipping implementation.

The guard changes the sort arithmetic in a measurable way. If a scene declares
`m` drawable faces, the copied array has `m+1` records and each of the `m`
ordinary outer records compares against every following record, including the
guard. The fixed comparison count is therefore `m*(m+1)/2`, while rasterization
still performs exactly `4*m` edge-walker calls. With all three rotation axes
active, the point transform performs twelve signed multiplies per vertex:

| Scene | Vertices | Faces | Transform `IMUL`s | Face-key comparisons | Edge walks |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 0 | 16 | 12 | 192 | 78 | 48 |
| 1 | 14 | 24 | 168 | 300 | 96 |
| 2 | 18 | 24 | 216 | 300 | 96 |
| 3 | 28 | 25 | 336 | 325 | 100 |
| 4 | 11 | 12 | 132 | 78 | 48 |
| 5 | 16 | 14 | 192 | 105 | 56 |
| 6 | 17 | 19 | 204 | 190 | 76 |
| 7 | 16 | 24 | 192 | 300 | 96 |
| 8 | 14 | 24 | 168 | 300 | 96 |

Span length remains geometry-dependent, but the reconstruction/upload floor is
fixed. `4D49h` clears three 8,000-byte RAM planes with 12,000 word stores, and
`52EAh` copies another `3 * 4,000 = 12,000` words into the selected VGA page.
That is 24,000 software-buffer bytes cleared and 24,000 planar bytes uploaded
every frame before counting edge or span read/modify/write traffic.

Renderer mode 1, reached through `4F27h`, consumes the low three face-color
bits destructively. For each software plane it OR-fills the inclusive span when
the bit is one and AND-clears it when zero. This is opaque three-plane color
replacement, not transparency. Mode 2, at `4E2Ch`, clears each face interior
from software plane 0 and then ORs its four edges back through the separate line
walker at `539Fh`; planes 1 and 2 remain clear and face color is ignored. Later
faces erase covered earlier lines before redrawing their own outline—the
hidden-line result shown in the new GIF. No stipple renderer exists in these
two modes.

Three 8,000-byte software planes are cleared every frame at `4D49h`, uploaded
with Sequencer map masks `1`, `2`, and `4` at `52EAh`, and displayed through
three VGA pages. The exact frame pipeline is:

```text
transform and project every vertex
calculate unsigned face keys and reorder complete face records
clear all 3 * 8,000 software-plane bytes
rasterize every face into those software planes
upload planes 0..2 to the selected VGA page
write CRTC start high byte to display that page
advance the upload segment for the next frame
```

The initial upload segment is `A200h`, so cadence is `A200h/20h`,
`A400h/40h`, `A000h/00h`, then repeat. Old geometry disappears through full
software reconstruction and overwrite, not a hardware-page clear or selective
repair. There is no `03DAh` read in active frame path `4716h..4BBFh`; the CRTC
write at `4B9Ah..4BAAh` is unsynchronized and may occur during active display.

The blue bottom text is independent of geometry. `45F0h..4628h` composites
resources `1A` and `1B` into plane 3 at offset `1DB0h`, 320 bytes spanning rows
190..197, on all three hardware pages. Geometry uploads touch only planes 0, 1,
and 2. The runtime's red edges are mode-2 plane-0 pixels colored by the scene
palette; the blue strip is not polygon output.

## Other Parts: Their Actual Inner Loops

### `03`: chunky strip compositor

The opening child enters at `2D53h` and uses mode `13h`, not a vector
landscape. It shifts a twelve-row, 320-byte-wide text band with an overlapping
`rep movsw`, `CX=0780h`, at `31E3h..31F7h`, then inserts one new glyph column
across all twelve rows at `3200h..321Bh`. Resource `07`, decoded with XOR
`CDh`, contains control bytes for pauses, wave tables, directions, and return
paths. CRTC start-address writes at `2F48h..2F61h` move the composed strip.

### `13`: 16-row sinus scroller over lightning art

The third child enters at `8814h`. Resource `17` calls it a “hot
sinus-scroller,” and decoded resource `15` is the lightning/noise background
seen in the runtime. The core band is 16 rows by 40 bytes of 1bpp source data.

At `8C4Dh`, each of the sixteen rows is shifted one bit through all forty bytes
with fully unrolled rotate-through-carry instructions. `8C18h` shifts a
320-word displacement history; `8C95h` injects one new font column at the right
edge; `8CE8h` rotates each row independently left or right according to its
displacement value. The later eight-way, sixteen-row remapper at `8F13h`
expands 38 source bytes, or 304 active pixels, into plane-specific output. This
is a scanline distortion/compositor, not a 3D point field or line engine.

### `26`: prescaled reveals and a CRTC text ring

The final child enters at `1673h`. Resources `1F`, `20`, and `21` already
contain multiple sizes of the PIRATE logo, credits, and STONE logo. The copy
loops at `188Bh..18C5h` and `1938h..1972h` select and reveal those stored
variants; there is no runtime image scaler to analyze.

The final text path is more interesting. Resource `25` is XOR-decoded with
`C7h`, parsed one character/command at a time, and rendered from atlas `23`
into a circular 16 KiB screen ring. The CRTC start address advances by `50h`
bytes per frame at `1F32h..1F47h` and `208Ah..209Dh`, making the display scroll
through the ring without copying the full screen on every step.

## Timing And Negative Findings

Reads involving segment `0040h` and offset `001Ch` are keyboard-buffer-tail
checks, not PIT timing or audio code. In both 3D children the saved tail is
compared after a complete frame; any newly buffered BIOS key causes the child
to restore the old value and return, effectively discarding the trigger.

Neither geometry loop is retrace-synchronized. Payload `09` polls `03DAh` only
inside palette setup/fade paths (`68F4h..6A08h`, `7098h`, `70C4h`, `710Eh`),
not around its page advance at `6FB5h`. Payload `18` polls retrace during scene
palette setup and startup fades (`451Dh..452Ch`, `4C4Ch..4D09h`), but not in
active frame path `4716h..4BBFh`. Both CRTC page changes can occur during
active display.

Static inspection found:

- no reachable `DIV`/`IDIV` perspective path in either 3D child;
- no dedicated starfield—the smallest class-12 vector balls can be one pixel,
  but remain ordinary model records;
- no PIT channel `40h`, `42h`, or `43h` programming;
- no speaker-port `61h` output;
- no timer-vector installation for music;
- no clipping in either 3D renderer;
- no selective old-ball or old-polygon restoration;
- no stipple path in payload `18`'s two renderer modes.

Those negatives matter because they prevent familiar later-demo mechanisms
from being projected backward onto the code. `09` is an orthographic
sprite-object renderer with a flawed unsigned depth pass and pre-shifted planar
masks. `18` is an exponentially table-scaled, unsigned-face-key scanline
renderer. Their broad common ground is fixed-point rotation, record-wide depth
reordering attempts, planar VGA pages, and page-based cleanup.

## What Is Proven And What Is Not

Proven directly from the release binaries are the archive partition, dispatcher
chain, RLE grammar, child/resource ownership, model and face record layouts,
loop bounds, fixed-point multiply extraction, projection formulas, exact
compare/exchange behavior, descriptor sizes, planar port usage, page cadence,
clear sizes, edge tables, endpoint semantics, and span-fill paths. The direct
silent capture separately verifies `09`'s shaded vector-ball pixels and `18`'s
red hidden-line/blue-strip composition.

No original source code is available in the examined package, and no symbol
names were recovered. Routine names in this article are descriptive labels.
The depth table is numerically reconstructable as a normalized exponential to
within one rounded word, but its exact original generator and quantization
remain unknown, as does the authoring tool used for the pre-shifted sphere
sheets and model records. Exhaustive scripted extrema are also not proven.
Those limits do not obscure the frame loops—or the lack of clipping: the
shipped machine code is specific enough to reconstruct how each visible point,
edge, span, page, strip, and cleanup pass is produced.
