Analysis model: gpt-5.5 xhigh

# 2 Cents by Mental Design - Technical Dissection

Mental Design released *2 Cents* on 7 August 1994 and placed tenth in the
Assembly 1994 PC demo competition. The original archive is unusually useful for
code archaeology: its single 1,468,589-byte executable is an EXOS/FEXOS
container holding the loader, seven executed visual programs, three PCX files,
a music-side executable and the original S3M.

The important point is not merely that the demo contains several effects. The
master loader preserves their exact order, and the recovered inner loops show
three quite different rendering families: fixed-point polygon engines, an
unrolled cellular-field update, and a table-driven tunnel sampler. The direct
runtime GIFs are evidence for that map; the code is the subject.

Release year: 1994

## Artifact And Runtime Proof

| Item | Recovered fact |
|---|---|
| Production | *2 Cents* by Mental Design |
| Release/result | 7 August 1994; 10th at Assembly 1994 PC Demo |
| Platform | MS-DOS, 386-class instructions, VGA mode 13h, Gravis Ultrasound |
| Archive | `2cents.zip`, 598,201 bytes, SHA-256 `7f776033151c06e94f0397bbe2433a65ab8409336312bf638cf4dcd0824b629a` |
| Outer executable | `2CENTS.EXE`, 1,468,589 bytes, SHA-256 `858935e8f93afb2ecfcd6fbb61bae9bbe978a65f85b3549c873b0e362a370889` |
| Container | PKLITE MZ stub followed by `FEXOS ver 1.00 (c) 1993 by Wizard` records |
| Soundtrack | `Stoned Dreams-tune`, S3M, credited by Demozoo to Infinity / Mental Design |
| Direct run | DOSBox-X 2026.01.02, 486 at 40,000 cycles, 16 MiB, GUS 1 MiB at 220h/IRQ 5/DMA 3 |
| Audio boundary | GUS remained present for guest timing; host output was dummy/muted and no audio was captured or published |

The clean lossless capture was made on 16 August 2026. Capture time zero is the
Xvfb stream, including DOSBox-X startup; the authored demo begins around 00:24.
The unmodified release reaches its final tunnel and exits normally. All GIFs
below are continuous crops of that exact silent run, not screenshot slides.

Public identity and result evidence: [Demozoo production](https://demozoo.org/productions/6794/),
[Assembly 1994 results](https://demozoo.org/parties/102/results_file/34/),
[Pouet production](https://www.pouet.net/prod.php?which=15544), and the
[Scene.org archive](https://files.scene.org/get/mirrors/hornet/demos/1994/0-9/2cents.zip).

## The FEXOS Table Is The Scene List

Starting at outer-file offset `0830h`, FEXOS uses fixed 64-byte records. Each
record stores a little-endian payload start at `+3`, inclusive end at `+7`, the
signature `NONET` at `+11`, and a name near `+33`. Carving those ranges gives:

```text
ID    name          outer range          bytes
3E8h  Part_Loader   000B6F..002B0E        8,096
3E9h  Dpic1.pcx     002B0F..00652C       14,878
3EAh  pic2.pcx      00652D..008FE6       10,938
3EBh  pic3.pcx      008FE7..00B5EA        9,732
3ECh  2cintro.exe   00B5EB..0160BC       43,730
3EDh  w16.exe       0160BD..026C2C       68,464
3EEh  w17.exe       026C2D..037C9C       69,744
3EFh  w19.exe       037C9D..047ADC       65,088
3F0h  f9.exe        047ADD..07858C      199,344
3F1h  t26.exe       07858D..09A5F2      139,366
3F2h  f14.exe       09A5F3..0A07E8       25,078 packed
3F3h  a16.exe       0A07E9..0A26BE        7,894 packed
3F4h  snew4.s3m     0A26BF..1668AC      803,310
```

The loader checks that interrupt FFh points to EXOS/Wizard, shrinks its DOS
block, refuses to continue unless more than `6B80h` paragraphs are available,
starts the GUS side, and then makes these calls:

```asm
; Part_Loader load image 007Bh..0120h
mov ax,0000h
mov bx,03EBh
int 0FFh                  ; PCX/title resource

mov ax,0013h
int 10h

mov ax,0000h
mov bx,03ECh
int 0FFh                  ; 2cintro
mov bx,03EDh
int 0FFh                  ; w16
mov bx,03EEh
int 0FFh                  ; w17
mov bx,03EFh
int 0FFh                  ; w19
mov bx,03F0h
int 0FFh                  ; f9
mov bx,03F2h
int 0FFh                  ; f14
mov bx,03F1h
int 0FFh                  ; t26
```

That final `3F2h`, `3F1h` reversal is real. It explains why the polygon objects
appear at the entrance to the tunnel before the object-free tunnel takes over.
Between every call the master drains the BIOS keyboard buffer. On return from
`t26`, it shuts down the GUS path, restores text mode 3 and exits through DOS.

## Why The GUS Must Be At 220h

The release does not search common GUS bases. In the loader's data segment,
`DS:004F` is literally `0220h`; the following words are port offsets `0, 6,
102h, 103h, 104h, 105h, 107h`. Startup adds 220h to all seven:

```asm
; Part_Loader 05BCh
mov ax,[004Fh]            ; 0220h
add [0051h],ax            ; 0220h
add [0053h],ax            ; 0226h
add [0055h],ax            ; 0322h
add [0057h],ax            ; 0323h
add [0059h],ax            ; 0324h
add [005Bh],ax            ; 0325h
add [005Dh],ax            ; 0327h
call gus_probe
call gus_memory_test
cmp ax,2
jl  insufficient_gus_ram
```

The probe writes and reads GUS global/voice registers, including the `BEh` and
`EBh` sentinel pair used by the memory test. Its loop tests as many as eight
memory units and accepts two or more, matching the on-screen requirement of at
least 256 KiB. DOSBox-X defaults to 240h, so the first diagnostic run correctly
failed with “Can't find an UltraSound Card!”. Moving the emulated card to 220h
made the untouched executable run. This is a release assumption, not an
emulator bug.

The timer-side routine at `08F7h` is also recognisably a tracker interpreter.
Every 64 ticks it fetches the next row pointer, expands channel events into
32-byte voice records and handles note, volume and effect fields before writing
GUS registers. `a16.exe` is opened through EXOS service `AX=0100h` during this
setup rather than called as a visual part; `snew4.s3m` remains in the container
as the original S3M. Audio was not auditioned for this analysis.

## The Shared 3D Kernel In w16, w17 And w19

The first three effect executables are separate builds of the same small
real-mode 386 polygon engine. Each frame waits on VGA status port `03DAh`, copies
64,000 bytes to the presentation segment at `A190h`, clears another 64,000-byte
work page with `rep stosd`, advances sine-table pointers and renders the next
frame off-screen.

Their transform is Q10 fixed point. A representative multiply from `w16`
shows the convention directly:

```asm
; w16 0198h, one matrix term
mov  eax,[si+8]
mov  ebx,[0004h]          ; sine/cosine coefficient
imul ebx                  ; EDX:EAX = product
shrd eax,edx,10           ; divide by 1024, keep signed precision
mov  ecx,eax
mov  eax,[si+4]
mov  ebx,[0000h]
imul ebx
shrd eax,edx,10
sub  eax,ecx
```

Projection shifts the rotated coordinate left by eight, performs a signed
divide by camera-space Z, then adds `(160,80)`. Faces are rejected by a signed
2D area test, clipped to X `0..319` and Y `0..159`, assigned an average depth,
and selected back-to-front before rasterisation. The active viewport is thus
320x160 inside mode 13h; the bottom 40 rows stay black in these parts.

The builds differ in their data and controllers:

```text
part  transformed records  phase steps    duration/control
w16   25h = 37             +4,+6,+2       countdown every third frame
w17   03h = 3 groups       +6,+8,+10      01C2h counted steps, every second frame
w19   28h = 40 objects     per-record     Z += 0096h modulo 6E8Ch
```

### w16: linked blocks

`w16` transforms 37 records and keeps 37 depth values. Its nearest-depth scan
starts at `0942h`; after choosing a record it replaces that depth with `4E20h`,
projects the corresponding vertex list, emits visible faces and repeats until
all candidates are exhausted. The object therefore has a stable painter's
order without a general sort routine.

```asm
; w16 007Ch, repeated minimum selection
mov si,0942h
mov bx,si
mov ax,[si]
mov cx,0024h              ; compare the remaining 36 depths
.scan:
  add si,2
  cmp ax,[si]
  jle .keep
  mov ax,[si]
  mov bx,si
.keep:
  dec cx
  jnz .scan
cmp word [bx],03E8h
jge done
mov word [bx],4E20h       ; mark consumed
```

![The w16 linked-block object rotating in the direct silent run at 00:39-00:45.](images/2-cents-linked-object.gif)

### w17: starburst made from polygon groups

`w17` is not a 2D star plotter. Its controller rotates three compound groups
with three different phase speeds, runs the same perspective and backface
pipeline, then lets their many small faces spread across the screen. This is
why the runtime burst has changing facets rather than identical sprites.

```asm
; w17 phase controller, abbreviated
add word [003Ch],6
wrap [003Ch] in 2768h..2FD8h
add word [003Eh],8
wrap [003Eh] in 2768h..2FD8h
add word [0040h],10
wrap [0040h] in 2768h..2FD8h

mov si,0E00h
mov di,0E32h
mov bp,3                 ; three transformed groups
```

![The w17 projected polygon fragments forming the starburst at 00:46-00:52.](images/2-cents-starburst.gif)

### w19: forty objects and a branchless edge writer

`w19` advances 40 records through depth, wrapping at `6E8Ch`. After Q10
rotation, projection subtracts a camera constant `7148h`, divides X and Y by
the resulting depth, and centres at 160/80. Visible faces are depth-sorted and
sent to a scan converter.

The striking optimisation is at `0662h`. Once an edge slope has been reduced
to integer step `BX` and fractional step `AX:DX`, the source repeats this four-
instruction DDA body hundreds of times in-line:

```asm
; w19 0662h onward
mov [di],bp               ; store X for this scanline
add dx,ax                 ; fractional accumulator
adc bp,bx                 ; integer step plus carry
add di,4                  ; next left/right edge slot

; same four instructions repeated, with no loop branch
mov [di],bp
add dx,ax
adc bp,bx
add di,4
```

The edge builder patches a `RET` into that unrolled runway at the required
height, so a short edge does not execute the unused tail. The result is a
branch-free per-scanline edge walk after one divide. This is the inner loop
behind the layered red field, not a framebuffer post-process.

![The w19 depth-sorted red field at 00:53-00:57.](images/2-cents-red-field.gif)

## f9: A 120x120 Relaxation Field Feeding 320x160 Pixels

`f9` changes algorithm completely. Its update begins with `CL=78h` and contains
120 physically repeated cell bodies. At the end, `dec cl / jne 00A4h` repeats
that unrolled row 120 times. The field stride is `0140h` bytes, or 160 words;
the live 120x120 region therefore retains a border around it.

One cell is:

```asm
; f9 00A4h, repeated 120 times per unrolled row
mov ax,[si-2]             ; left
add ax,[si]               ; centre
add ax,[si+2]             ; right
add ax,[si+0140h]         ; next row
shr ax,2                  ; average four neighbours
jz  .store
dec ax                    ; damping/erosion
.store:
mov [si-0140h],ax         ; write one row behind
add si,2
```

At `104Bh`, an integer XOR/add generator seeds 80 two-by-two disturbances into
the field, writing the same value at `DI`, `DI+2`, `DI+140h` and `DI+142h`.
Two precomputed address maps then turn the evolving scalar field into pixels.
Each map contains four 16-bit pointers per output group:

```asm
; f9 002Bh, first 80x80 group map
mov fs,174Bh
xor bx,bx
mov di,1900h
mov ch,50h                ; 80 rows
.row:
  mov cl,50h              ; 80 groups, four pixels each
.group:
  mov si,fs:[bx+6]
  mov ah,[si]
  mov si,fs:[bx+4]
  mov al,[si]
  shl eax,16
  mov si,fs:[bx+2]
  mov ah,[si]
  mov si,fs:[bx]
  mov al,[si]
  mov es:[di],eax         ; four indexed pixels
  add bx,8
  add di,4
```

The first map writes 320x80 pixels; a second map immediately writes the next
320x80. There is no per-pixel multiply or divide in the display loop—only four
pointer reads, a packed dword store, and loop bookkeeping. The precomputed maps
are what bend a small relaxation field into the visible cellular surface.

![The f9 relaxation field and address-map distortion at 00:58-01:07.](images/2-cents-cellular-surface.gif)

## f14: Polygon Objects Composited Into The Tunnel

The packed `f14.exe` restores to a 327,137-byte MZ image. Its entry first moves
four complete 64,000-byte pages between segments, then advances three sine
pointers by `1Eh`, `10h` and `18h`. Five calls to the Q10 transform routine use
different object records. Projection again centres at 160/80, but this build
adds a real depth buffer.

```asm
; f14 4F9B8h, horizontal span inner loop
mov ax,8000h              ; fractional DDA accumulator
.pixel:
  cmp dx,fs:[bx]          ; candidate depth against Z buffer
  jle .skip
  mov fs:[bx],dx          ; accept nearer sample
  mov es:[di],ch          ; write indexed colour
.skip:
  add ax,si
  adc dx,bp               ; interpolate depth
  inc di
  add bx,2
  dec cl
  jnz .pixel
```

`4F867h` performs the signed-area backface test and copies accepted face
records. `4F914h` walks their edges, derives per-scanline endpoints, and calls
the depth-tested span above. This is why the coloured solids can cross and
overlap cleanly while entering the already moving blue corridor.

## t26: A 256x256 Source, 160 Rows, Two Pixels Per Sample

The final executable is the tunnel itself. Initialisation at `21D28h` expands a
256x256 indexed source into segment `0183h`. A piecewise triangular transform
folds values through eight 64-step ranges and masks them with `F8h`; the outer
counter is the deliberately wrapped byte `DL`, so zero means 256 rows.

Each frame then projects three control points with Q9 coefficients (`sar 9`),
builds 200-entry and 160-entry interpolation tables, and combines three moving
phase tables. Its hot sampler renders 160 active rows. Each inner iteration
fetches one texture byte, adds a second table's shade byte, duplicates the
result into AH, and stores a word—320 pixels from 160 samples:

```asm
; t26 21BE8h, reconstructed from the exact loop
rows = 160
while (rows--) {
    source = row_start[row] + phase;
    shade  = shade_start[row];
    for (x = 0; x < 160; ++x) {
        source += source_step[x];
        colour  = texture256[source];
        shade  += shade_step[x];
        colour += shade_table[shade];
        *dst16++ = colour | (colour << 8);  /* horizontal 2x */
    }
}
```

The corresponding instructions are `FS:LODS`-style indexed reads from the
64K texture, `add al,[bx]`, `mov ah,al`, and `mov ES:[di],ax`. The expensive
geometry is moved into short per-frame tables; the 51,200 visible pixels are
produced by a small add/lookup/store loop.

![The f14 object bridge followed by the t26 table-driven tunnel at 01:08-01:14.](images/2-cents-tunnel.gif)

## Intro Debug Records Survived Too

`2cintro.exe` declares a 31,128-byte MZ image but carries a 12,602-byte CodeView
`NB02` block. It preserves the original modules
`ERPCX16.OBJ`, `FADE.OBJ`, `UNPACK.OBJ`, `2cintro.obj` and function names such as
`LoadPCX16`, `StoreLine`, `SetLineCompare`, `SetStartScline`, `Show16Lines` and
`Setvideomode`. The image is Microsoft C plus 16-colour planar PCX/VGA support;
the three carved PCX resources are genuine 640x480 four-plane files.

That evidence supports a bounded conclusion: the opening typography uses a
separate PCX/unpack/fade path and explicit VGA start-line/line-compare control.
It does **not** justify pretending that the C source survived. The CodeView
records provide names and module provenance, while the effect executables above
provide the fully recoverable inner loops.

## Runtime-To-Code Concordance

| Capture interval | Observed scene | Executed record | Code evidence |
|---|---|---|---|
| about 00:24-00:37 | Mental Design / presents / 2 Cents | `2cintro.exe`, ID 3ECh | retained PCX/fade/VGA split symbols |
| 00:38-00:45 | linked grey object | `w16.exe`, ID 3EDh | 37-record Q10 transform and repeated depth selection |
| 00:46-00:52 | blue starburst | `w17.exe`, ID 3EEh | three compound groups, phase steps 6/8/10, polygon pipeline |
| 00:53-00:57 | red radial field | `w19.exe`, ID 3EFh | 40 depth-moving records and self-shortened unrolled DDA edges |
| 00:58-01:07 | cellular/amoeba surface | `f9.exe`, ID 3F0h | 120x120 relaxation pass and paired 80x80 address maps |
| from 01:08 | tunnel with solids | `f14.exe`, ID 3F2h | five Q10 object passes, backface test and Z-buffered spans |
| final phase | blue tunnel without solids | `t26.exe`, ID 3F1h | generated 256x256 source and 320x160 table sampler |

The exact wall-clock lengths vary with emulation speed because the visual
executables count rendered frames. Their order does not vary: it is fixed by
the eight `INT FFh` calls in `Part_Loader`. That is the central archaeological
advantage of this release—the authored route can be proved from both sides,
with a normal observed exit at the end.
