Analysis model: gpt-5.5 xhigh, sol high
Last edited: 2026-08-26

# First Demo / Physical by The Physical Crew - Technical Dissection

The production is **First Demo** by **The Physical Crew**, released in 1991.
Demozoo and Pouet agree on that identity and year; Demozoo credits Mr. H with
code and The Loot with graphics and text. `Physical` is the Hornet catalogue
name and the filename of the surviving `physical.zip` distribution. Its four
members carry matching 1993 ZIP timestamps, but those later archive timestamps
do not establish a second release date.

Release year: 1991.

This is a compact real-mode DOS/VGA intro built around three external `.MRH`
payload files. The visible show is one strong effect rather than a multipart
demo: a yellow/blue perspective checker floor, a huge white outline scroller,
and optional 8-bit sample playback through a resistor-ladder D/A converter on
the parallel port.

Private contact details shown at the end of the demo are deliberately omitted.
The public screenshot sheet below excludes that final page.

![First Demo / Physical DOSBox-X runtime contact sheet](images/physical-runtime-contact.png)

The front-page card is text-only; this tiled evidence sheet appears only inside
the article. I did not convert unrelated stills into fake motion, and the
omitted final page should stay omitted.

## Sources

- Demozoo production record:
  https://demozoo.org/productions/295248/
- Pouet production record:
  https://www.pouet.net/prod.php?which=64609
- 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/physical.zip
- Scene.org file page:
  https://files.scene.org/view/mirrors/hornet/demos/1991/physical.zip

## Archive

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

```text
physical.zip  172477 bytes
```

ZIP contents:

```text
DATA1.MRH   209822 bytes  1993-12-27 13:59
DATA2.MRH    35840 bytes  1993-12-27 13:59
FONT.MRH     50400 bytes  1993-12-27 13:59
PCDEMO.EXE   13872 bytes  1993-12-27 13:59
```

Hashes:

```text
25abba2ea91a7dac4b06a9812df3819fc61e19d62da033b6452bbced42e5b1d1  physical.zip
72e501fcc64c60090d9166ae0ee0cc6a43b7efb6c3404671068c6da19c8fbdf5  DATA1.MRH
0858fcb3f37c1caa50c63df6c36aa8550bb52e7e6b506bc961b3200bfe51c4c2  DATA2.MRH
ef52c74f2d2ab3115169a043e0370d5770f5b50f25bb03f764863bf09c7b7ec3  FONT.MRH
dbbacdbbf7a4d96767e45bc839f84016cb907054865290e3160b38a8986c7379  PCDEMO.EXE
```

The payload division is unusually clean. A seventh playback resource is made
in memory rather than read from the archive:

```text
PCDEMO.EXE  code, strings, BIOS wrappers, file/runtime layer, VGA/DAC loops
DATA1.MRH   six XOR-obfuscated sample chunks for the optional DAC music path
DATA2.MRH   4-plane 80x112-byte planar image block, used for the floor
FONT.MRH    30 drawn glyph cells, 1680 bytes each, used by the huge scroller
synthetic 7  4096 bytes of 80h DAC silence, allocated and filled at startup
```

The arithmetic is exact:

```text
DATA1 chunks   DF5Ch + DEAEh + 6F22h + 5FDEh + 46BAh + 5FDAh = 3339Eh
DATA1 size     3339Eh = 209822 bytes
DATA2 size     8C00h  = 80 * 112 * 4 bytes
FONT size      C4E0h  = 30 * 690h = 30 * 1680 bytes
```

## Runtime Capture And Timestamps

The runtime frames were captured with DOSBox-X:

```text
DOSBox-X version       2026.01.02 Commit 59915c1
capture command        dx-capture /v PCDEMO.EXE
selected sound option  0, forget the music
capture format         MPEGTS H.264 + AAC
video stream           720x400, avg_frame_rate 7500/107, about 70.09 fps
capture duration       32.981333 seconds
timing zero            start of the capture command
```

Observed frame points:

```text
00:00.500  black startup/transition
00:02.000  floor initialized, no large letters yet
00:05.000  small white block glyphs appear over the floor
00:10.000  huge outline letters, "VERY" visible
00:15.000  huge scroller continues, "YOU" and following letters visible
00:20.000  huge scroller continues, "HAVE" visible
00:25.000  huge scroller continues, "NEW Y..." visible
00:30.000  final private contact page appears; not included in public sheet
00:32.981  capture ends after the demo exits
```

The no-music path skips the timer/LPT playback setup, but it still exercises
the full VGA visual sequence. Static control flow corrects one misleading
impression from the capture: the graphics loop does not end on its own. It
polls the keyboard through BIOS `INT 16h/AH=01h` before each frame without
consuming the key. A key already pending exits immediately; one arriving after
the poll lets that frame finish and exits on the next iteration. The transition
near `00:30` is therefore the capture/user key boundary, after which the demo
restores the prior video mode and prints its final text pages.

## Runtime-To-Code Concordance

The public contact sheet maps to the visual path of the no-music run. The
`00:02.000` floor-only frame is after the BIOS mode `10h` switch and the
`DATA2.MRH` four-plane upload. `05D0h` performs 448 reads of 80 bytes and 35,840
read-before-write iterations while selecting sequencer map masks `01h`, `02h`,
`04h`, and `08h`. The CPU instruction at `06A9h` is a plain store; Graphics
Controller register 3 is what XORs that byte with the latch loaded by the
preceding read. CRTC line compare is set to scanline 228, so the lower
partition restarts its display address at zero and exposes this checker bitmap
while the upper partition uses the separate circular font page.

The `00:05.000` frame, where small white block glyphs begin to appear, maps to
the first visible use of the huge-font streaming path. `FONT.MRH` is loaded by
`04CEh`; each 1,680-byte glyph is exactly 15 columns by 112 rows. One frame
streams one column, rereading each source byte for the duplicate and performing
224 font-buffer reads plus 224 VGA writes. The second destination is 80
byte-columns ahead in a 161-position ring, so the CRTC can cross the wrap
without a full-screen copy. The script begins with blanks and repeated glyph
index `26`; those initial square outlines and the later letters are products of
the same streamer, not two renderers. The 90-frame address waveform moves the
whole 112-row cell vertically without rescaling it.

The `00:10.000`, `00:15.000`, `00:20.000`, and `00:25.000` frames are later
states of the same CRTC-scrolled surface. The frame loop computes `[0DF2h]`
from the `8000h..8050h` base, the table at `0CA0h`, and an 80-row bias, waits
for retrace at `11BBh..11D1h`, then writes CRTC start-address registers `0Ch`
and `0Dh` at
`11D3h..11F1h`. The visible "VERY", "YOU", "HAVE", and "NEW Y..." fragments
are therefore not separate screens; they are successive hardware-scroll
positions over the streamed font page. The floor remains anchored below it by
the CRTC line-compare split.

The omitted `00:30.000` contact page follows the key-triggered exit from the
visual loop and is not part of the public contact sheet. The no-music capture
also leaves the optional parallel-port DAC ISR unused, but the code path is
still documented separately: choosing ports `0378h`, `0278h`, or `03BCh`
installs the `03CEh` procedure's real IRQ entry at `03D8h` and streams decoded
`DATA1.MRH` bytes to the selected LPT base.

## MZ Layout

`PCDEMO.EXE` is a normal linked MZ executable, not an obvious packed EXE:

```text
file size       13872 bytes
MZ image size   13872 bytes
header size       688 bytes = 002Bh paragraphs
relocations        164
min alloc        043Bh paragraphs
max alloc        A43Bh paragraphs
initial SS:SP    0373h:4000h
initial CS:IP    0000h:0BB7h
entry raw        0E67h
load image size  3380h bytes
```

The high relocation count and the `Runtime error` string point to a compiled
high-level DOS runtime, but the important graphics and DAC work is direct 8086
code. Offsets below are load-image offsets, meaning:

```text
load offset = raw file offset - 02B0h
```

The entry at `0BB7h` calls two runtime initializers, then prints the DAC
schematic/menu, accepts one key, initializes video/assets, and enters the
visual loop:

```asm
0bb7  9a 00 00 aa 01        call far 01AA:0000  ; runtime/init
0bbc  9a 00 00 48 01        call far 0148:0000  ; screen/runtime init
...
0dcc  9a fa 02 48 01        call far 0148:02FA  ; key pending?
0dd7  9a 0c 03 48 01        call far 0148:030C  ; read key
0ddc  a2 d6 0e              mov [0ED6],al
```

The sound option maps directly to the DAC output port variable at `0DF0h`:

```asm
0ddf  cmp byte [0ED6],30h
0de6  mov word [0DF0],0000h   ; 0, no music

0ded  cmp byte [0ED6],31h
0df4  mov word [0DF0],0378h   ; 1, LPT1

0dfc  cmp byte [0ED6],32h
0e03  mov word [0DF0],0278h   ; 2, alternate LPT base

0e0b  cmp byte [0ED6],33h
0e12  mov word [0DF0],03BCh   ; 3, LPT2-style base
```

If the input is not `0`..`3`, the program exits through the runtime termination
path. The visible menu also has an escape option for users who want to build
the parallel-port D/A converter first.

## BIOS Interrupt Wrapper

The local code uses a generic interrupt-call wrapper rather than inlining every
BIOS call. The wrapper entry at `13EBh` takes:

```text
argument 1  interrupt number
argument 2  pointer to a register image
```

It fetches the interrupt vector from the IVT, loads registers from the supplied
buffer, then far-returns into the interrupt handler:

```asm
13eb  push bp
13ec  push ds
13ef  pushf
13f0  mov  bx,0045h
13f3  push cs
13f4  push bx              ; return target after interrupt
13f5  xor  bx,bx
13f7  mov  ds,bx
13f9  mov  bl,[bp+0Ch]     ; interrupt number
13fc  shl  bx,1
13fe  shl  bx,1
1400  lds  bx,[bx]         ; DS:BX = interrupt vector
1402  push ds
1403  push bx
1404  lds  si,[bp+08h]     ; register block
1408  lodsw                ; AX
140a  lodsw -> BX
140d  lodsw -> CX
1410  lodsw -> DX
1413  lodsw -> BP
1416  lodsw -> saved SI
1419  lodsw -> DI
141d  lodsw -> ES
1423  cli
1424  retf                 ; execute selected interrupt handler
```

This is why many mode changes appear in the main code as register-buffer
writes followed by `call far 013E:000B`. For example:

```asm
0e82  mov byte [0D8F],00h
0e87  mov byte [0D8E],10h
0e8c  push 10h
0e8f  push ds:0D8E
0e94  call far 013E:000B
```

That builds `AX=0010h` and calls `int 10h`, switching to VGA/EGA graphics mode
`10h` before the planar setup.

## DATA1 Loader: XOR-Decoded Sample Chunks

The loader opens `DATA1.MRH`, allocates six blocks, reads each chunk, and
XOR-decodes it in place with `55h`.

The six chunk sizes are hardcoded in the caller:

```asm
02b7  load resource 1, size DF5Ch
02c3  load resource 2, size DEAEh
02cf  load resource 3, size 6F22h
02db  load resource 4, size 5FDEh
02e7  load resource 5, size 46BAh
02f3  load resource 6, size 5FDAh
```

The decode loop is inside the generic `load resource` routine:

```asm
01e8  mov ax,[bp+08h]
01eb  dec ax
01ec  mov [bp-04h],ax       ; last byte index
01ef  xor ax,ax

decode_loop:
01fb  inc word [bp-02h]
01fe  mov ax,[bp-02h]
0203  mov al,[bp+0Ah]       ; resource number
0208  shl di,1
020a  shl di,1
020e  les di,[0DC2h+di]     ; resource pointer
0212  add di,dx
0214  mov al,es:[di]
0217  xor al,55h
0219  mov cl,al
022b  les di,[0DC2h+di]
022f  add di,dx
0231  mov es:[di],cl
0234  mov ax,[bp-02h]
0237  cmp ax,[bp-04h]
023a  jne decode_loop
```

The pointer table starts at `0DC2h` and stores far pointers by resource number.
The length table starts at `0EBEh` and stores the loaded chunk length. This
table is later consumed by the DAC sequence builder.

## FONT.MRH: Huge Glyph Stream

`FONT.MRH` is loaded into one contiguous block, but the allocation is one glyph
larger than the file:

```asm
04ce  function load_font
050c  allocate CB70h bytes = 31 * 0690h
0526  ES:DI = allocated block -> stored at [0ED2]
052c  clear all CB70h bytes to zero
053d  open "Font.Mrh"
055a  read C4E0h bytes = 30 * 0690h into [0ED2]
```

The file size is `C4E0h`, and the main loop uses a glyph stride of `0690h`:

```asm
10f8  mov cx,0690h
10fb  imul cx
10fd  mov [0DACh],ax        ; glyph_index * 1680
```

That means the file supplies 30 drawn cells, indices `0..29`, while the code
deliberately manufactures index `30` as a zero-filled thirty-first cell:

```text
30 file glyphs * 1680 bytes per glyph  = 50,400 bytes
31 allocated slots * 1680 bytes        = 52,080 bytes
slot 30                                 = blank space, retained from the clear
```

The frame loop streams one vertical byte-column from the current glyph per
video frame. The visible font is very tall because each glyph column spans 112
rows:

```asm
1133  mov word [0DA8],0001h ; row counter starts at 1

column_loop:
113f  mov ax,[0DACh]
1142  les di,[0ED2h]        ; FONT.MRH buffer
1146  add di,ax
1148  mov dl,es:[di]        ; source byte-column row

114b  mov ax,0A800h
114f  mov di,[0DB0h]
1154  mov es:[di],dl        ; write column into circular page

1157  mov ax,[0DACh]
115a  les di,[0ED2h]
115e  add di,ax
1160  mov dl,es:[di]

1163  mov ax,0A800h
1167  mov di,[0DB2h]
116c  mov es:[di],dl        ; duplicate 80 bytes later for wrap

116f  add word [0DB0h],00A4h
1175  add word [0DB2h],00A4h
117b  inc word [0DACh]
117f  cmp word [0DA8h],0070h
1184  jne column_loop
```

Normalized, the inner loop is:

```c
if (glyph_frame > 14) {
    glyph = script[script_pos++];       /* 0..30 */
    source = glyph * 1680;
    glyph_frame = 0;
}

primary = producer_column;
duplicate = primary + 80;
if (duplicate > 0x00A2)
    duplicate -= 0x00A1;

for (row = 0; row < 112; ++row) {
    vram_a800[primary   + row * 164] = font[source];
    vram_a800[duplicate + row * 164] = font[source]; /* real reread */
    ++source;
}
```

The row pitch is `00A4h` bytes. The second write, at `[0DB2h]`, is initialized
to the same x position plus `50h` bytes. `A2h` remains valid; values from `A3h`
up are wrapped by subtracting `A1h`. That is a standard
circular scrolling trick: write the new column both in the visible column and
in the wrapped duplicate so the CRTC start address can slide without needing a
full-screen memory copy.

The next glyph is selected every 15 frames:

```asm
10e7  cmp word [0DB4h],000Eh
10ee  mov di,[0DB6h]
10f2  mov al,[di+005Ah]     ; next glyph index from text/script table
10f8  mov cx,0690h
10fb  imul cx               ; glyph_index * glyph_stride
1100  mov word [0DB4h],0
1105  inc word [0DB6h]
1109  cmp word [0DB6h],0C44h
1111  mov word [0DB6h],0    ; wrap text pointer
```

`[0DB4h]` starts at `00FFh`, forcing a glyph fetch on the first frame. The fetch
resets it to zero; the end of every frame increments it; and the next fetch
occurs only when the value is greater than 14. The resulting cadence is exact:

```text
15 frames per glyph
112 source rows per frame
2 source reads and 2 VGA writes per row
224 heap reads + 224 addressed VGA writes per frame
all-plane map mask: 224 writes = 896 plane-byte updates per frame
1680 source bytes consumed per glyph
3360 addressed VGA writes = 13,440 plane-byte updates per glyph
```

The script contains `0C44h` = 3,140 glyph indices, all in the valid range
`0..30`. Index `30` occurs 704 times and selects the synthesized blank slot;
the other 2,436 entries select file-backed glyphs. It begins with 16 blanks and
ends with 37, but there is no sentinel. The pointer wraps after
`3,140 * 15 = 47,100` frames, about 11 minutes 12 seconds at the observed 70.09
Hz, so neither the text data nor the glyph cadence provides an automatic exit.

The two source loads at `113Fh` and `1157h` address the same byte. This is
compiled, literal duplication rather than one load reused for both stores.
The destination arithmetic is also more specific than a simple `+50h` copy:

```text
primary column     0051h..00A1h, then wrap to 0051h  (81-frame cycle)
duplicate column   primary + 0050h; if > 00A2h, subtract 00A1h
row pitch          00A4h = 164 bytes
ring coordinates   0002h..00A2h = 161 byte-columns
```

Thus the huge lettering is not a conventional byte-shifted text-mode
scroller. It is a fixed 15-column glyph streamer writing two positions around
a circular planar strip, while the CRTC moves the viewport over that strip.
The horizontal phases are locked. For frame `n`, let `k = n mod 81`; the
viewport's horizontal phase is `(k + 3) mod 81`, the primary destination is
`0051h + k`, and the wrapped destination follows the rule above. Exactly one
of those two destinations lies `004Eh` = 78 visible byte-columns ahead of the
viewport start. One fresh eight-pixel column is therefore written at visible
byte x=78 each frame while the other write retains its off-viewport wrap copy.
The code never copies or shifts the 640-pixel field.

## DATA2.MRH: Four-Plane Floor Upload

`DATA2.MRH` is exactly `80 * 112 * 4` bytes. The loader at `05D0h` opens the
file, then uploads it one VGA plane at a time:

```asm
0606  mov word [bp-84h],0100h ; first map mask value
0614  inc word [bp-86h]       ; plane counter

plane_loop:
0618  mov ax,1803h
061b  mov dx,03CEh
061e  out dx,ax              ; graphics controller setup

062d  mov ax,[bp-84h]
0631  add ax,0002h
0634  mov dx,03C4h
0637  out dx,ax              ; sequencer index 2, map mask in high byte

0640  mov word [bp-88h],0     ; row = 0

row_loop:
064c  read 80 bytes from Data2.Mrh into stack buffer
0666  mov word [bp-8Ah],0     ; x byte = 0

byte_loop:
0672  mov ax,0A000h
0676  mov ax,[bp-88h]
067a  mov cx,00A4h
067d  mul cx
067f  add ax,[bp-8Ah]
0683  mov di,ax
0686  mov al,es:[di]         ; latch/read existing byte
068d  mov di,[bp-8Ah]
0691  mov bl,[bp+di-00E0h]   ; DATA2 byte
0695  mov ax,0A000h
0699  row * 00A4h + x
06a9  mov es:[di],bl
06ac  cmp word [bp-8Ah],004Fh
06b3  cmp word [bp-88h],006Fh
06d6  cmp word [bp-86h],0003h
06dd  jmp plane_loop
```

The upload writes 80 bytes per row and 112 rows per plane. The code doubles the
sequencer map-mask data byte each pass and adds sequencer index 2, producing
the actual output words `0102h`, `0202h`, `0402h`, and `0802h`. The file is
therefore stored as four consecutive plane images.

Normalized, its address and plane loops are:

```c
for (plane = 0, map_mask = 1; plane < 4; ++plane, map_mask <<= 1) {
    set_gc_data_rotate(0x18);            /* XOR, rotate 0 */
    set_sequencer_map_mask(map_mask);
    for (row = 0; row < 112; ++row) {
        read(file, source_row, 80);
        for (x = 0; x < 80; ++x) {
            address = row * 164 + x;
            discard = vram_a000[address]; /* load VGA latches */
            vram_a000[address] = source_row[x];
        }
    }
    restore_gc_and_all_plane_mask();
}
```

This is a latch-assisted XOR upload, not a CPU `XOR` loop. Mode `10h` leaves
Graphics Controller write mode 0 active. At the start of each plane, register 3
receives `18h`: rotate count zero and logical function XOR. Register 7 receives
zero and register 8 receives `FFh`, enabling all eight bits. Every payload
iteration first reads the target address at `0686h` to load all four VGA
latches; the compiler also spills the returned byte to `[BP-008Fh]`, but never
uses that spill. The plain `MOV ES:[DI],BL` at `06A9h` then makes the controller
compute:

```text
selected-plane byte = rotated CPU byte XOR latched destination byte
```

Only one plane accepts the result because Sequencer map mask `01h`, `02h`,
`04h`, or `08h` is active. Mode `10h` has just cleared the page, so the first
and only upload makes the visible result equal to the source byte. The read is
still indispensable: it primes the latch consumed by the hardware XOR.

Exact one-time workload:

```text
4 planes * 112 rows                         = 448 file reads
448 reads * 80 bytes                        = 35,840 payload bytes
CPU-addressed VGA reads                      = 35,840
four latches loaded per CPU VGA read         = 143,360 plane-byte reads
CPU-addressed VGA writes                     = 35,840
one map-masked plane accepts each write      = 35,840 plane-byte writes
4 setup OUTs + 4 restore OUTs per plane     = 32 word OUT instructions
CPU XOR instructions in the byte loop       = 0
```

After each plane, the routine restores normal write behavior before testing
whether another plane remains:

```asm
06ba  mov ax,0F02h
06bd  mov dx,03C4h
06c0  out dx,ax              ; enable all four planes

06c1  mov ax,0003h
06c4  mov dx,03CEh
06c7  out dx,ax

06c8  mov ax,0005h
06cb  mov dx,03CEh
06ce  out dx,ax

06cf  mov ax,0FF08h
06d2  mov dx,03CEh
06d5  out dx,ax
```

The restore leaves Graphics Controller register 7 at zero; that value is
irrelevant to the subsequent write-mode-0 font stores, but this is not a full
register-state restoration.

This floor is not raycast every frame, and it is not column-overwritten by the
text renderer. It is a planar bitmap loaded once into rows `0..111`, columns
`0..79`, of the low display-address region, with `84` unused bytes after each
80-byte source row because the programmed pitch is 164 bytes. A hardware
line-compare split keeps that lower floor partition independent from the upper
circular font page.

## Hardware Split: Why The Floor Stays Still

The setup immediately after mode `10h` programs the split explicitly:

```asm
0eb1  mov ax,0E418h
0eb7  out 03D4h,ax          ; CRTC 18h: line-compare low byte = E4h

0eb8  select CRTC 07h
0ec1  read current value
0eca  and ax,00EFh          ; clear line-compare bit 8
0ed8  write CRTC 07h

0ed9  select CRTC 09h
0ee2  read current value
0eeb  and ax,00BFh          ; clear line-compare bit 9
0ef9  write CRTC 09h

0efa  mov ax,5213h
0f00  out 03D4h,ax          ; CRTC offset = 52h words = 164 bytes
```

The complete line-compare value is therefore 228. Scanlines `0..228` use the
moving upper address; scanline 229 resets the CRTC memory address to zero,
exposing the `DATA2.MRH` floor. In a 350-line mode, the reset leaves 121 lower
scanlines; the resource populates the first 112 rows and the remaining nine
come from the already-cleared page.

Standard mode `10h` CRTC state selects byte addressing. Registers `0Ch/0Dh`
therefore receive byte addresses, while CRTC Offset register `13h=52h`
produces a `2 * 52h = 00A4h` byte row pitch. That shared 164-byte pitch is why
both the floor loader and font streamer advance rows by `00A4h`.

## CRTC Scroll Loop

The visible movement is synchronized to vertical retrace and driven by CRTC
start-address updates:

```asm
11bb  mov dx,03DAh
11be  in  al,dx
11bf  and al,08h
11c3  jne 11c7h
11c5  jmp 11bbh             ; wait until in retrace

11c7  mov dx,03DAh
11ca  in  al,dx
11cb  and al,08h
11cf  je  11d3h
11d1  jmp 11c7h             ; wait until retrace ends

11d3  mov ax,[0DF2h]
11d6  and ax,0FF00h
11d9  add ax,000Ch
11dc  mov dx,03D4h
11df  out dx,ax             ; CRTC start address high byte

11e0  mov ax,[0DF2h]
11e3  and ax,00FFh
11e6  shl ax,8
11eb  add ax,000Dh
11ee  mov dx,03D4h
11f1  out dx,ax             ; CRTC start address low byte
```

The scroll address is computed from a base in the `8000h..8050h` range plus a
90-word table at `0CA0h`. The subtraction is not an arbitrary magic constant:
`3340h = 80 * 00A4h`, an 80-row upward bias in the same pitch used everywhere
else:

```asm
1186  mov ax,[0DAEh]
1189  mov di,[0DBAh]
118d  shl di,1
118f  add ax,[0CA0h+di]
1193  sub ax,3340h
1196  mov [0DF2h],ax

121e  inc word [0DAEh]
1222  cmp word [0DAEh],8050h
122a  mov word [0DAEh],8000h
```

For frame `n`, the exact byte-address formula is:

```text
h(n) = (n + 3) mod 81
S(n) = 4CC0h + h(n) + W[n mod 90]
```

The table index runs `0..89` and wraps, giving a 90-frame vertical cycle. Every
entry of `W` is an exact multiple of `00A4h`; divided by the pitch, the table is
a symmetric `0..49..0` row waveform. Consequently the actual 810-frame
combined cycle spans CRTC byte addresses `4CC2h..6C74h`, while the table itself
moves the 112-row font through a 49-scanline vertical range. It changes the
text's vertical placement, not its scale.

The linear base starts at `8003h`, advances through `8050h`, then cycles over
all 81 values `8000h..8050h`. Its low part is the horizontal phase paired with
the 81-column producer ring. The 90- and 81-frame periods realign only after
their least common multiple, 810 frames. The line-compare reset prevents both
motions from dragging the floor partition.

There is one more per-frame hardware loop after the CRTC writes. The code
resets the Attribute Controller flip-flop through `03DAh`, selects Color Select
register `14h`, and outputs `[0DB8h] >> 1`. `[0DB8h]` runs `0..27`, so values
`0..13` are each held for two frames, a 28-frame color-select cycle. Writing
index `20h` then reenables the display. This is an Attribute Controller update,
not a DAC palette upload.

## Optional DAC Timer ISR

If the selected output port is nonzero, the code builds a 31-entry sample
sequence from the decoded `DATA1.MRH` chunks plus a generated silence block,
installs an interrupt-8 handler, programs the PIT, and outputs bytes to the
chosen parallel port.

The loader's unusual allocate/free/retry loops have a purpose. Every sample
block must have far-pointer offset zero because the ISR treats `BX=0` as the
end condition. If an allocation returns a nonzero offset, the code frees it,
allocates one padding byte, and retries until the next block is normalized at
`segment:0000`. After loading resources 1 through 6, `033Eh..03C3h` uses the
same alignment method to create resource 7 and fills its 4,096 bytes with
unsigned 8-bit midpoint `80h`.

Routine `043Ch` converts a resource number into a four-byte score entry:

```text
word 0  sample segment
word 1  final valid offset = resource length - 1
```

The hardcoded 31-entry score is:

```text
1,1,2,1,1,2,3,3,3,5,7,7,1,1,3,3,3,3,4,6,6,5,7,7,7,7,7,7,7,7,7
```

Thus resources 1 through 6 occur `6,2,7,1,2,2` times respectively, and the
synthetic silence occurs 11 times.

The compiler procedure begins at `03CEh`, but that is deliberately not the
installed interrupt entry. Startup builds `CS:03CEh`, adds `000Ah`, and gives
DOS vector 8 as `CS:03D8h`. Entering at `03D8h` skips the Pascal prologue and
stack-check call at `03CEh..03D7h`, which would be unbalanced on an interrupt
return. The real IRQ path is:

```asm
03d8  pushf                 ; installed IRQ0 entry = procedure + 10 bytes
03d9  push ds
03da  push ax
03db  mov ax,B800h
03de  mov ds,ax
03e0  push si
03e1  push bx
03e2  push es
03e3  push dx
03e4  mov ds,cs:[0080h]     ; restore program data segment

03e9  mov bx,[0DE8h]
03ed  dec bx
03ee  jne output_sample    ; count downward inside current block

03f0  mov bx,[0DEAh]
03f4  dec bx
03f5  mov [0DEAh],bx
03f9  jne load_current

03fb  mov bx,001Fh
03fe  mov [0DEAh],bx
0402  mov bx,[0DECh]
0406  mov [0DEEh],bx        ; restart sequence pointer

load_current:
040a  mov si,[0DEEh]
040e  lodsw
040f  mov [0DE6h],ax        ; sample segment
0412  lodsw
0413  mov [0DEEh],si
0417  mov bx,ax             ; final valid sample offset

output_sample:
0419  mov [0DE8h],bx
041d  mov es,[0DE6h]
0421  mov al,es:[bx]
0424  mov dx,[0DF0h]
0428  out dx,al             ; DAC byte to LPT port
0429  pop dx
042a  pop es
042b  pop bx
042c  pop si
042d  mov al,20h
042f  out 20h,al            ; PIC EOI
0433  sti
0434  pop ax
0435  pop ds
0436  popf
0437  iret
```

Playback is backward within every block. A newly selected entry outputs
`sample[length-1]` immediately; subsequent IRQs decrement `BX` and output down
through `sample[1]`. When `BX` would become zero, the handler selects the next
entry instead, so byte zero is never emitted. One full score pass outputs
811,097 bytes before the 31-entry pointer resets.

The timer setup around `1082h..10AFh` does four things:

```asm
108d  set interrupt vector 08h to CS:03D8h
1093  port 61h = (old | 03h) & 7Fh & FEh
109d  program PIT channel 0, mode 3, divisor 006Fh through ports 43h/40h
10a9  unmask IRQ0 through PIC mask port 21h
```

The port-`61h` expression preserves bits 2 through 6, sets bit 1, and clears
bits 0 and 7; it does not simply enable both speaker/gate bits.

The PIT input clock divided by 111 gives approximately 10,749.4 IRQs and DAC
bytes per second. At that rate the 811,097-byte score lasts about 75.46 seconds
before repeating. The IRQ therefore replaces the normal 18.2 Hz BIOS timer
cadence while music is enabled; the handler sends its own PIC EOI and does not
chain to the displaced BIOS handler, so BIOS clock ticks stop advancing during
playback.

The shutdown path at `1237h..1267h` is conditional on a nonzero output port.
It restores the saved interrupt-8 vector exactly, but the surrounding hardware
reset is conventional rather than a byte-for-byte state restoration. It
programs PIT channel 0 mode 3 with divisor `FFFFh` rather than the saved
divisor, forces port `61h` to `(old & 7Ch) | 02h`, clears PIC mask bit 0, and
leaves the final LPT data byte latched. The no-music path skips all of this.
Both paths then invoke BIOS mode set with the video mode saved at startup and
only afterward print the final text/contact pages. A final read-key call occurs
at `13C7h`; because the frame-loop poll did not consume the exit key, that same
pending key normally gets consumed there immediately. The program then exits
with status zero. DOS process termination reclaims the allocated font and
sample blocks; no matching local free loop is present in this exit path.

The no-music capture path leaves this handler unused, but the binary code is
direct and unambiguous: the demo is prepared to stream 8-bit sample bytes to a
home-built parallel-port DAC.

## Overall Frame Model

The main visual loop is small:

```text
startup:
    print DAC schematic/menu in text mode
    read key
    choose output port 0000h, 0378h, 0278h, or 03BCh
    switch to mode 10h through BIOS int 10h
    adjust CRTC registers 18h, 07h, 09h, and 13h
    allocate/clear 31 font slots, then load 30 FONT.MRH glyphs
    upload DATA2.MRH into four VGA planes
    load/decode six DATA1.MRH chunks and synthesize resource 7 silence
    optionally install timer/DAC ISR

per visible frame:
    poll the keyboard without consuming; any pending key leaves before drawing
    if current glyph column budget exhausted:
        fetch next glyph index from script
        set source offset = glyph_index * 0690h
    for 112 rows:
        read one font byte from FONT.MRH
        write it to A800:current_column
        reread it and write the wrapped duplicate
        advance both destinations by 00A4h
        advance font source by one byte
    compute CRTC start address from horizontal base + row waveform - 80 rows
    wait for retrace high then retrace low
    write CRTC start address high/low registers
    update Attribute Controller color select
    advance 15-frame glyph, 28-frame color, 81-column, and 90-frame wobble state
```

The steady visual workload is therefore only 224 font-buffer reads, 224
addressed VGA writes (896 plane-byte updates through the all-plane mask), two
CRTC word outputs, and three Attribute Controller byte outputs per frame, plus
polling and retrace waits. Every fifteenth frame also fetches one script byte
and performs the signed multiply by `0690h`; there is no per-frame clear,
pixel shift, span rasterizer, or floor redraw. The floor costs 35,840
latch-assisted single-plane writes once at startup. Smooth upper movement comes
from one producer column, its ring duplicate, and VGA start-address hardware;
line compare keeps the checker floor anchored below it.
