Analysis model: gpt-5.5 xhigh, sol high

Last edited: 2026-08-25

# The Party 91 Intro by TRSI and Surprise! Productions - Technical Dissection

Release year: 1991

`Party 91` is a small MS-DOS intro released at The Party 1991 by TRSI and
Surprise! Productions. The DIZ calls it an intro for `TP91` and credits `TRSI
and Suprise! prod.`; the runtime text credits Rick Dangerous and Burning Chrome
as the on-site makers, with a logo by J.O.E.

This is not a later polished multi-part DOS demo. It is more interesting as a
late-1991 PC scene artifact: an MZ executable with a custom tail depacker, three
external data files, direct VGA register work, a compact RLE bitplane decoder,
palette stepping, CRTC scanline timing, and a simple text-page display engine.

The Party 1991 result file does not list a ranked PC intro compo. It lists the
party as held in Aars, Denmark in late December 1991 and gives the main demo
results for the larger party context. So I treat this as a The Party 1991 PC
party intro, not as a ranked PC-compo placement.

Sources:

- Scene.org archive:
  https://archive.scene.org/pub/parties/1991/theparty91/in64/party91.zip
- Scene.org The Party 1991 results:
  https://archive.scene.org/pub/parties/1991/theparty91/info/results.txt
- Demozoo production page:
  https://demozoo.org/productions/2351/
- Demozoo party page:
  https://demozoo.org/parties/59/

## Archive Contents

Unpacked archive:

```text
FONT.P91        3,684 bytes
LOGO.P91        7,396 bytes
PARTY91.EXE     4,203 bytes
THANX.P91      17,689 bytes
FILE_ID.DIZ        63 bytes
```

Hashes used in this pass:

```text
46673a5d84a20deb7bce6f9c2be15e53568d804ec12045863a843b9115bba293  party91.zip
2f32898e6a2516c2ee7800b1d9063569de0ea84beb0095530ca3d1bf7d6cd432  results.txt
274ff0b481ac0d67f1cd8f70f3930e32c1fe0385aa9262372ead030ec6c8197f  FILE_ID.DIZ
0a6bdfc2f1b78a59ade2ee2a0fe58c0741184a6d49286193f48b84b74120ea1b  FONT.P91
1adfe30a923b06449e923ff2838681f18b93d5f1e2d31db5bba93fb645505906  LOGO.P91
8a856c48c10bfde682f2ef080acda248256f70035eb432553f1fef270fafa280  PARTY91.EXE
87ed38d330848bc3e37ea86b682d37fa3861af48a86e4e836f3769aab90f580b  THANX.P91
```

`PARTY91.EXE` is a normal MZ executable according to file type inspection, but
the load image is only the compressed wrapper plus a custom decompressor. The
visible data files are:

- `LOGO.P91`: compressed planar logo data.
- `FONT.P91`: compressed 8x8 glyph sheet.
- `THANX.P91`: compressed full-screen/thanks page image data.

The runtime scroller begins with a welcome line for Surprise!/TRSI and says the
party release was made by Rick Dangerous and Burning Chrome in the night between
December 27 and December 28, 1991. I am only quoting short identifying text here;
the rest is just party context and greetings.

## MZ Wrapper And Packed Entry

The executable has a 32-byte MZ header:

```text
header paragraphs: 0x0002
relocations:       0
file size:         4,203 bytes
load image size:   4,171 bytes
initial CS:IP:     00ef:000e
initial SS:SP:     053f:0080
min alloc:         0x046a paragraphs
max alloc:         0xffff paragraphs
```

The initial CS:IP maps to load-image offset `0x0efe`, file offset `0x0f1e`.
The entry is not the intro proper. It is a short stub that copies the packed
stream upward, then far-returns into relocated decompressor code:

```asm
0efe  push es
0eff  push cs
0f00  pop ds
0f01  mov cx,[000c]
0f05  mov si,cx
0f07  dec si
0f08  mov di,si
0f0a  mov bx,ds
0f0c  add bx,[000a]
0f10  mov es,bx
0f12  std
0f13  rep movsb
0f15  push bx
0f16  mov ax,002b
0f19  push ax
0f1a  lret
```

The useful detail is the direction flag. The stub copies backward from the end
of the packed stream so the decompressor can move itself and its input into a
higher paragraph area without trampling bytes it still needs to read. The far
return then changes both segment and offset in one cheap real-mode operation.

The following decompressor is a bit-coded LZ variant:

- `BP` is the bit bucket.
- `DL` is the remaining bit count.
- Plain bytes are copied with `movsb`.
- Backreferences copy from `ES:[DI+BX]` to `ES:DI`.
- A match length code of zero exits the stream.
- A special length code of one updates the segment base when the output area
  crosses a paragraph boundary large enough to require rebasing.
- The final stub restores the stack and far-jumps through a pointer saved near
  the start of the unpacked image.

The packed entry is small, but it explains why the file is not directly
disassemblable as the final intro. The final runtime is reconstructed from a
DOSBox-X save after the unpacked code has reached its own setup path. The
2026-08-25 pass independently reproduced that handoff with 16-bit segmented
emulation: the wrapper/depacker executes 91,740 instructions before reaching
the restored `loadseg:4E34h` entry with `SS:SP = loadseg+0517h:0100h`.
That removes the old save-state carving as a single point of failure; all
runtime offsets and tables below also occur in the independently restored
image.

## Runtime Capture Map

I used a DOSBox-X save state after `PARTY91.EXE` had unpacked and started.
In that save, the program name is `PARTY91`, the emulated machine is VGA, and
the PSP begins at physical `0x81c8`. The carved runtime image used below starts
at physical `0x82c8`; all offsets in this section are relative to that carved
image.

High-level runtime map:

```text
0000  small palette/helper area
0020  attribute-register / tiny palette helper
0900  decoded font/glyph target area
0914  CRTC phase, raster-record stride/counter, and text cursors
1e60  character-to-glyph offset table
1f64  palette table A
2024  palette table B
20e4  palette table C
21a4  transition palette buffer
24a4  transition palette buffer
27a4  transition palette buffer
2864  transition palette buffer
2b64  text page count and page index
2b6a  40x6 text page stream
301a  sixty 101-byte raster-control records
47c6  DOS memory-block shrink helper
47da  DOS paragraph allocation helper
4860  DOS free-segment helper
486b  ASCIIZ file loader
4933  RLE bitplane-to-chunky image decoder
49d3  retrace-synced DAC upload helper
49f0  palette interpolation helper
4a0b  200-step CRTC record consumer
4a9b  fixed 186-scanline DAC pulse schedule
4d74  8x8 glyph writer
4e10  file names and segment slots
4e34  main runtime entry after unpack
4e80  mode 13h and CRTC setup
4ee6  logo decode
4f0c  font decode
4f34  palette fade toward table B
4f59  palette fade toward table C
4f93  main text/display loop
5094  keypress exit and closing transitions
```

The code/data layout is compact and old-school: there is no separate engine
layer. Segment slots, file names, palettes, text pages, state words, and code
all sit in one real-mode code segment, with external data loaded into allocated
paragraph blocks.

## DOS Memory And File Loading

The memory shrink routine at `47c6` resizes the original DOS block so the
program can allocate clean work areas after itself:

```asm
47c6  mov bx,ss
47c8  mov ax,es
47ca  sub bx,ax
47cc  mov ax,sp
47ce  mov cl,4
47d0  shr ax,cl
47d2  add bx,ax
47d4  inc bx
47d5  mov ah,4ah
47d7  int 21h
47d9  ret
```

The calculation is the usual real-mode executable shrink:

```text
paragraphs from PSP/owner block to SS
+ SP rounded down to paragraphs
+ one extra paragraph
= new DOS block size
```

The allocator at `47da` wraps DOS `int 21h / AH=48h`. On success it stores the
returned segment through `CS:[DI]`. On failure it prints a short "not enough
memory" style message and exits.

```asm
47da  mov ah,48h
47dc  int 21h
47de  jae 47ef
      ; print failure text and terminate
47ef  mov cs:[di],ax
47f2  ret
```

The file loader at `486b` is similarly direct. Its inputs are:

```text
DX = pointer to ASCIIZ filename in CS
DI = pointer to the segment slot where the allocation result is stored
```

It performs:

```text
open file with int 21h / AH=3Dh, AL=92h
seek to end with int 21h / AH=42h, AL=2
use AX as byte length
seek back to start
allocate (length >> 4) + 1 paragraphs
read length bytes with int 21h / AH=3Fh into the allocated segment
close file with int 21h / AH=3Eh
store allocated segment in CS:[DI]
```

The open failure path mutates the terminating zero byte of the filename into a
DOS `$` terminator, prints a small complaint naming the missing file, and exits.
That is a very 1991 way to avoid keeping duplicate filename strings around.

The seek result is formally `DX:AX`, but this loader retains only `AX`; its
file-size path is therefore intentionally limited to less than 64 KiB. It then
allocates `(size >> 4) + 1` paragraphs even when a file would end exactly on a
paragraph. For the shipped files and the separate screen page, the exact
conventional-memory blocks are:

```text
block       bytes used   paragraphs   bytes reserved   slack
LOGO.P91          7396          463             7408      12
FONT.P91          3684          231             3696      12
THANX.P91        17689         1106            17696       7
screen page      64000         4005            64080      80
total            92769         5805            92880     111
```

After the unpacker has installed `SS:SP = loadseg+0517h:0100h`, `47C6h`
shrinks the owner block to `0538h` paragraphs, or 21,376 bytes including the
PSP. The program's resulting conventional-memory ownership is 114,256 bytes.
The free-block helper at `4860h` has no callers; normal `INT 21h/AH=4Ch`
termination releases all four child allocations by PSP ownership.

## External Asset Decode Calls

The main entry at `4e34` loads the three asset files and allocates one extra
screen-sized block:

```asm
4e5c  mov di,4e19h
4e5f  mov dx,4e10h
4e62  call 486b        ; logo.p91

4e65  mov di,4e24h
4e68  mov dx,4e1bh
4e6b  call 486b        ; font.p91

4e6e  mov di,4e30h
4e71  mov dx,4e26h
4e74  call 486b        ; thanx.p91

4e77  mov di,4e32h
4e7a  mov bx,0fa5h
4e7d  call 47da        ; offscreen full page block
```

The sizes match the later decoder calls:

- logo: 56 rows, 320 pixels wide, six bitplanes, destination in VGA memory.
- thanks page: 200 rows, 320 pixels wide, eight bitplanes, destination in the
  allocated page block.
- font: 17 rows of a wider glyph atlas, eight bitplanes, destination at
  `CS:0920`.

The single image decoder at `4933` is parameterized enough to handle all three.
That reuse is the tightest part of the intro.

## RLE Bitplane-To-Chunky Decoder

The decoder at `4933` converts a compressed bitplane stream into 8-bit chunky
pixels. It is not just an RLE expander; it expands bitplanes by setting or
clearing one bit in each destination byte.

Inputs:

```text
DS:SI = compressed source stream
ES:DI = destination
AL    = starting destination bit index
CX    = row count
BP    = destination row width in pixels
BX    = extra row advance in pixels
DX    = number of bitplanes to apply
```

The setup converts pixel widths into byte counts and builds the first bit mask:

```asm
4933  push ax
4934  mov ax,bp
4936  and ax,0007h
4939  shr bp,3
493c  cmp ax,0
493f  je 4944
4941  mov ax,1
4944  add bp,ax        ; ceil(width / 8)
4946  shr bx,3         ; extra x advance, pixels to bytes
4949  pop ax
494a  push cx
494b  mov cl,al
494d  mov al,1
494f  shl al,cl        ; AL = bit to set for this plane
4951  mov ah,al
4953  not ah           ; AH = mask to clear that bit
```

Then it enters a three-level loop:

```text
for every output row:
  save row counters
  for every bitplane requested by DX:
    decode enough RLE packets to fill the row byte count
    advance the destination bit mask to the next plane
  move DI to the next destination row
```

The RLE packet byte at `DS:SI` decides between a literal run and a repeat run:

```asm
495d  xor cx,cx
495f  mov cl,[si]
4961  inc si
4962  cmp cl,7fh
4965  ja 4989
```

Low packet bytes are literals. The count is `packet + 1`; each following source
byte supplies eight pixels for the current destination bitplane:

```asm
4967  inc cx           ; literal byte count = packet + 1
4968  sub bp,cx
496a  push bx
496b  mov bl,[si]
496d  inc si
496e  push cx
496f  mov cx,8
4972  rcl bl,1
4974  jb 497c
4976  and es:[di],ah   ; source bit 0: clear this plane bit
4979  jmp 497f
497c  or es:[di],al    ; source bit 1: set this plane bit
497f  inc di
4980  loop 4972
4982  pop cx
4983  loop 496b
4985  pop bx
4986  jmp 49b1
```

The core is the `rcl bl,1` plus `and/or es:[di]`. One compressed byte turns into
eight chunky pixels, but only touches a single bitplane in each pixel byte.
After all planes have run, those bits combine into normal 8-bit VGA color
indices.

High packet bytes are repeats. The count is `0x101 - packet`; one source byte is
replayed that many times:

```asm
4989  sub cx,0101h
498d  neg cx           ; repeat byte count = 0x101 - packet
498f  sub bp,cx
4991  push bx
4992  mov bl,[si]
4994  mov bh,bl
4996  inc si
4997  push cx
4998  mov cx,8
499b  rcl bl,1
499d  jb 49a5
499f  and es:[di],ah
49a2  jmp 49a8
49a5  or es:[di],al
49a8  inc di
49a9  loop 499b
49ab  mov bl,bh
49ad  pop cx
49ae  loop 4997
49b0  pop bx
```

The repeat path keeps a copy of the repeated source byte in `BH`, restores it
into `BL` for each repeated output byte, and runs the same eight-pixel bit test.

The row/plane tail restores the destination pointer and advances the bit masks:

```asm
49b1  cmp bp,0
49b4  jne 495d         ; more packets needed for this row/plane
49b6  pop bp
49b7  pop di
49b8  pop cx
49b9  shl al,1
49bb  stc
49bc  rcl ah,1
49be  loop 495a        ; next bitplane
```

`AL` moves from bit 0 upward. `AH` is kept as the inverse clear mask, so it has
to rotate in a set bit as the clear position shifts. That is why the code uses
`stc` before `rcl ah,1`.

After all planes for the row are decoded, the destination advances by the
visible row stride and the extra byte advance:

```asm
49c0  push bp
49c1  push bx
49c2  shl bp,3
49c5  shl bx,3
49c8  add di,bp
49ca  add di,bx
49cc  pop bx
49cd  pop bp
49ce  pop ax
49cf  pop cx
49d0  loop 4956        ; next row
49d2  ret
```

Because `BP` and `BX` were byte counts after setup, the shifts rebuild pixel
units before adding to `DI`. For a 320-pixel row, this lands at the next VGA
scanline as expected.

The three calls are fully bounded because every row/plane consumes exactly 40
expanded source bytes. Parsing the shipped streams with those same packet
rules gives:

```text
asset      row-planes  headers  literal/repeat packets  source bytes used  plane bytes  destination RMW
LOGO.P91          336     1443          547 /  896              7384         13440          107520
FONT.P91          136      366          199 /  167              3684          5440           43520
THANX.P91        1600     4152         1256 / 2896             17689         64000          512000
total            2072     5961         2002 / 3959             28757         82880          663040
```

Each plane byte always causes eight destination read/modify/writes; zeros use
`AND` and ones use `OR`. The exact split is 577,283 clears and 85,757 sets.
`LOGO.P91` alone has twelve unused trailing bytes—six `D9 00` repeat packets—
because the call stops after its authored 56x6 row-plane units. `FONT.P91` and
`THANX.P91` are consumed to their final byte. No packet crosses a 40-byte
row-plane boundary, and the longest packet is one complete 40-byte row-plane.

## Mode 13h And CRTC Setup

The display setup starts in BIOS mode 13h, then edits CRTC registers directly:

```asm
4e80  mov ax,0013h
4e83  int 10h

4e85  mov dx,03d4h
4e88  mov ah,0c8h
4e8a  mov al,18h
4e8c  out dx,ax

4e8d  mov al,07h
4e8f  out dx,al
4e90  inc dx
4e91  in al,dx
4e92  and al,0efh
4e94  out dx,al

4e96  mov al,09h
4e98  out dx,al
4e99  inc dx
4e9a  in al,dx
4e9b  and al,0bfh
4e9d  out dx,al
```

The register writes are not a full custom mode set; they are tweaks on top of
mode 13h. Register `18h` is the line compare register. Registers `07h` and
`09h` contain overflow/double-scan-related bits, so clearing those bits helps
prepare the later split/wave behavior.

The code also sets the CRTC display start offset to `0x1f40`:

```asm
4e9e  mov bx,1f40h
4ea1  mov dx,03d4h
4ea4  mov ah,bh
4ea6  mov al,0ch
4ea8  out dx,ax
4ea9  inc al
4eab  mov ah,bl
4ead  out dx,ax
```

Then it unlocks write protection by clearing bit 7 of CRTC register `11h`:

```asm
4eae  mov dx,03d4h
4eb1  mov al,11h
4eb3  out dx,al
4eb4  inc dx
4eb5  in al,dx
4eb6  and al,7fh
4eb8  out dx,al
```

The intro is therefore still a 320x200 256-color program in spirit, but it uses
CRTC start, line compare, and per-scanline register changes to create motion
that is cheaper than redrawing the whole frame.

## Initial Draw Sequence

After the VGA setup, the code uploads an initial 256-entry palette from `1f64`:

```asm
4eb9  push cs
4eba  pop ds
4ebb  mov si,1f64h
4ebe  mov di,0
4ec1  mov cx,0100h
4ec4  call 49d3
```

The logo is decoded straight into VGA memory. The destination `DI=7bc0h` is an
offset inside segment `A000h`; the call requests 56 rows, 320 pixels per row,
and six bitplanes:

```asm
4ecc  push cs:[4e19h]  ; LOGO.P91 segment
4ed1  pop ds
4ed2  mov si,0
4ed5  mov di,7bc0h
4ed8  mov cx,38h
4edb  mov al,0
4edd  mov bp,0140h
4ee0  mov bx,0
4ee3  mov dx,6
4ee6  call 4933
```

`THANX.P91` is decoded into the separately allocated screen-sized page:

```asm
4ee9  push cs:[4e30h]  ; THANX.P91 segment
4eee  pop ds
4eef  mov si,0
4ef2  mov es,cs:[4e32h]
4ef7  mov di,0
4efa  mov cx,00c8h
4efd  mov al,0
4eff  mov bp,0140h
4f02  mov bx,0
4f05  mov dx,8
4f08  call 4933
```

`FONT.P91` is decoded into the code segment at `0920`:

```asm
4f0c  push cs:[4e24h]  ; FONT.P91 segment
4f11  pop ds
4f12  mov si,0
4f15  push cs
4f16  pop es
4f17  mov di,0920h
4f1a  mov cx,11h
4f1d  mov al,0
4f1f  mov bp,0140h
4f22  mov bx,0
4f25  mov dx,8
4f28  call 4933
```

The `FONT.P91` parameters look odd at first because the font only needs 8x8
glyphs, but the destination stride is still 320 bytes. The glyph writer later
uses the atlas as if each glyph row is laid out in a 320-byte-wide sheet.

## DAC Upload And Palette Interpolation

Palette upload at `49d3` waits for a full retrace edge, sets the starting DAC
index, and streams `CX * 3` bytes:

```asm
49d3  mov dx,03dah
49d6  in al,dx
49d7  test al,08h
49d9  jne 49d6
49db  in al,dx
49dc  test al,08h
49de  je 49db

49e0  mov dx,03c8h
49e3  mov ax,di
49e5  out dx,al
49e6  inc dx
49e7  mov ax,cx
49e9  shl cx,1
49eb  add cx,ax
49ed  rep outsb
49ef  ret
```

This is a classic clean-DAC write: wait until outside retrace, then wait until
inside retrace, then stream RGB bytes while the beam is in the safer interval.

The interpolation helper at `49F0h` nudges one palette toward another by a
signed fraction:

```asm
49f0  mov ax,cx
49f2  shl cx,1
49f4  add cx,ax        ; CX = entries * 3
49f6  mov al,[di]      ; target component
49f8  xor ah,ah
49fa  mov dl,[si]      ; current component
49fc  xor dh,dh
49fe  sub ax,dx
4a00  idiv bl
4a02  add dx,ax
4a04  mov [si],dl
4a06  inc si
4a07  inc di
4a08  loop 49f6
4a0a  ret
```

In plain terms:

```text
delta = target - current
current += delta / divisor
```

`BX` is not constant across an outer fade. The caller starts it at the outer
count and decrements it once after every upload, so the divisors descend to
one and the last interpolation lands exactly on its target:

```asm
4f34  mov cx,000ah      ; ten outer steps
4f37  mov bx,000ah      ; divisors 10..1
4f3a  push cx
4f3b  mov cx,0040h      ; 64 entries / 192 components
4f3e  mov si,1f64h      ; mutable palette
4f41  mov di,2024h      ; target
4f44  call 49f0
4f47  mov di,0
4f4a  mov cx,0040h
4f4f  mov si,1f64h
4f52  call 49d3
4f55  dec bx
4f56  pop cx
4f57  loop 4f3a

4f59  mov cx,0028h      ; forty outer steps
4f5c  mov bx,0028h      ; divisors 40..1
4f5f  push cx
4f60  mov cx,0040h
4f63  mov si,2024h
4f66  mov di,20e4h
4f69  call 49f0
      ; upload, decrement BX, and loop as above
```

Only the first 64 entries are faded here. The ten-step stage performs 1,920
signed divisions, 1,920 current-table writes, ten DAC-index writes, and 1,920
DAC-data writes. The forty-step stage performs 7,680 of each component
operation, forty index writes, and 7,680 data writes. Every outer step calls
`49D3h`, so startup also waits for 50 complete retrace edges. Later code sets
entries `FDh` and `FEh` directly for the raster-synchronized text pulses.

## CRTC Scanline Waver

The routine at `4A0Bh` is the most hardware-specific part. Its inputs are not
just an abstract phase: `DI` is a 0..36 scanline threshold and `DS:SI` points
to the 100 offset bytes immediately after that threshold in one selected
101-byte raster record. It first waits for vertical-retrace high and then low,
sets CRTC offset register `13h` to zero, and starts 200 horizontal-status
iterations:

Entry:

```asm
4a0b  mov bp,0001h
4a0e  mov dx,03dah
4a11  in al,dx
4a12  test al,08h
4a14  je 4a11
4a16  in al,dx
4a17  test al,08h
4a19  jne 4a16

4a1b  mov dx,03d4h
4a1e  mov ax,0013h
4a21  out dx,ax        ; CRTC index 13h, value 0

4a22  mov bx,004ah
4a25  add bx,cs:[0914h]
4a2a  mov cx,00c8h
```

Every iteration waits for Input Status 1 bit 0 to become high, writes CRTC
register `04h` (Start Horizontal Retrace), then waits for bit 0 to become low:

```asm
4a2d  mov dx,03dah
4a30  in al,dx
4a31  test al,01h
4a33  je 4a30

4a35  mov dx,03d4h
4a38  mov al,04h
4a3a  out dx,al
4a3b  inc dx
4a3c  mov al,54h
4a3e  mov ah,cs:[bx]
4a41  add al,ah
4a43  out dx,al

4a44  mov dx,03dah
4a47  in al,dx
4a48  test al,01h
4a4a  jne 4a47
```

The table bytes are signed-looking values `FEh..03h`, so eight-bit addition
keeps the programmed retrace start in the narrow range `52h..57h`:

```text
CRTC[04h] = (54h + table[004Ah + phase + scanline]) & FFh
```

The old article misread the following threshold path as pointer addition and
segment wrapping. It actually decrements `DI`, toggles `BP` with `NOT`, and
publishes one record byte every other scanline after the threshold expires:

```asm
4a4c  dec di
4a4d  or  di,di
4a4f  jg  4a60
4a51  not bp            ; 0001h <-> FFFEh
4a53  or  bp,bp
4a55  jl  4a60          ; skip alternate scanlines
4a57  mov dx,03d4h
4a5a  mov al,13h
4a5c  out dx,al
4a5d  inc dx
4a5e  lodsb             ; next record byte: only 00h or 28h
4a5f  out dx,al

4a60  inc bx
4a61  cmp bx,0a72h
4a65  jl  4a6a
4a67  mov bx,004ah
4a6a  loop 4a2d
```

CRTC `13h` is the logical row offset. Every raster-record payload contains only
`00h` and the normal mode-13h value `28h`; changing between them controls
whether later scanlines advance through display memory or reuse an address
step. A threshold of 36 consumes 82 payload bytes; a threshold of zero consumes
all 100. The routine therefore performs 200 `CRTC[04h]` writes and 82..100
dynamic `CRTC[13h]` writes per call, with no framebuffer copy.

At the end, the independent phase advances by two modulo `07D0h` and the
routine restores `CRTC[04h]=54h` and `CRTC[13h]=28h` before one final
horizontal-status cycle:

```asm
4a6c  mov ax,cs:[0914h]
4a70  inc ax
4a71  inc ax
4a72  cmp ax,07d0h
4a75  jl  4a7a
4a77  mov ax,0
4a7a  mov cs:[0914h],ax

4a7e  mov dx,03d4h
4a81  mov ax,5404h
4a85  out dx,ax
4a86  mov ax,2813h
4a89  out dx,ax
```

One call emits 570..606 byte-equivalent CRTC port writes: two for the initial
word write, 400 in the fixed 200-line pair, 164..200 in the dynamic offset
pairs, and four in the final restore. The `04h` phase has 1,000 states; its
table handoff is independent of the 120-iteration raster-record ping-pong
described below.

## Palette Pulse Helper

`4A9Bh` is not an ordinary once-per-frame palette update. It is an unrolled
186-scanline schedule synchronized with status bit 0. The schedule is:

```text
10 scanline waits
7-step DAC-0 blue ramp up + 7-step ramp down
1 scanline wait, force DAC 0 black, then 2 waits
6 copies of: 16-step DAC-FEh cyan ramp + 8 waits
7-step DAC-0 blue ramp up + 7-step ramp down
1 scanline wait, force DAC 0 black
```

One of the six center ramps is:

```asm
4b44  mov cx,0010h
4b47  mov ah,cl
4b49  dec ah
4b4b  shl ah,1
4b4d  shl ah,1
4b4f  add ah,14h

4b52  mov dx,03c8h
4b55  mov al,0feh
4b57  out dx,al
4b58  inc dx
4b59  mov al,02h
4b5b  out dx,al
4b5c  mov al,ah
4b5e  out dx,al
4b5f  mov dx,03dah
4b62  in  al,dx
4b63  test al,01h
4b65  je 4b62
4b67  mov dx,03c9h
4b6a  mov al,ah
4b6c  out dx,al        ; third component after the scanline edge
4b6d  mov dx,03dah
4b70  in  al,dx
4b71  test al,01h
4b73  jne 4b70
4b75  loop 4b47
```

The 16 intensities are `(CX-1)*4+14h`, descending from `50h` to `14h`; values
above the VGA DAC's six-bit range are still written literally and are handled
by the adapter. The top and bottom seven-step ramps use multiples of eight.
One complete call writes 504 bytes to DAC ports: 384 in the six center ramps,
112 in the four seven-step edge ramps, and eight in the two black resets.
Those writes change two existing color indices while the beam advances; no
pixel buffer is touched. Together with `4A0Bh`, one main-loop iteration spends
387 horizontal-status cycles in the two raster helpers before it draws at most
one glyph.

## Glyph Writer

The glyph writer at `4d74` draws an 8x8 character to VGA memory. Inputs:

```text
AL = character code
CX = x position in pixels
DX = y position in pixels
```

It first maps the character code to a glyph offset through the table at `1e60`:

```asm
4d74  mov di,0a000h
4d77  mov es,di
4d79  cmp al,20h
4d7b  jne 4d7f
4d7d  mov al,61h
4d7f  sub al,28h
4d81  mov bx,1e60h
4d84  xor ah,ah
4d86  shl ax,1
4d88  add bx,ax
4d8a  mov si,cs:[bx]
4d8d  add si,0920h
```

Space is special-cased before the `28h` base subtraction. Startup constructs
exactly 80 word offsets: 40 values `0000h..0138h` in steps of eight, then 40
values `0B40h..0C78h`. Those are two 40-glyph atlas bands beginning at decoded
font rows 0 and 9. Mapping space to `61h` selects table index 57 inside that
private range.

Destination offset is `y * 320 + x`, implemented with shifts:

```asm
4d91  shl dx,1
4d93  shl dx,1
4d95  shl dx,1
4d97  shl dx,1
4d99  shl dx,1
4d9b  shl dx,1         ; DX = y * 64
4d9d  mov di,dx
4d9f  shl dx,1
4da1  shl dx,1         ; DX = y * 256
4da3  add di,dx        ; DI = y * 320
4da5  add di,cx        ; DI = y * 320 + x
```

The actual copy is unrolled: copy eight bytes, then add `0x138` to source and
destination. Since `8 + 0x138 = 0x140`, each row advances one 320-byte stride.

```asm
4da7  mov cx,8
4daa  rep movsb
4dac  add di,0138h
4db0  add si,0138h

4db4  mov cx,8
4db7  rep movsb
4db9  add di,0138h
4dbd  add si,0138h

      ; repeated until eight glyph rows have been copied
```

Each call performs exactly eight 8-byte source reads and 64 direct VGA writes.
It has no transparency test: a new page's glyph, including its background
pixels, replaces the previous glyph cell completely. There is no need to clear
the six-row text field between pages.

## Text Page State Machine

The text system is a 40-column by 6-row page renderer. The data begins at
`2b6a`; the state words just before it are:

```text
0914  CRTC[04h] phase, 0..1998 in steps of 2
0916  signed raster-record stride, initially +101
0918  raster half-cycle counter, 0..59
091a  initial threshold-force countdown, initially 60
091c  current column, 0..39
091e  current row, 0..5
2b64  page count, value 5
2b66  current page
2b68  hold delay
2b6a  text pages, 40 * 6 * 5 bytes
301a  60 raster records, 101 bytes each
47c6  first byte after the raster-record bank
```

Each raster record is exactly `delay, offset[100]`. The 60 delay bytes form the
authored sequence `36,36,35,34,34,...,2,2,1,1,0`; every offset byte is either
`00h` or `28h`. The main loop starts `SI` at `301Ah`, walks these records with
the signed 101-byte stride, and repeats each endpoint while reversing:

```asm
4f93  mov si,301ah
4f96  cli                    ; hardware IRQs stay masked in the display loop
4f97  mov ax,cs:[0918h]
4f9b  inc ax
4f9c  cmp ax,003ch
4f9f  jl 4fad
4fa1  neg word cs:[0916h]   ; +101 <-> -101
4fa6  xor ax,ax
4fa8  sub si,cs:[0916h]     ; endpoint compensation
4fad  mov cs:[0918h],ax
4fb1  add si,cs:[0916h]
4fb6  push si
4fb7  lodsb                  ; record threshold; SI now addresses payload
4fb8  xor ah,ah
4fba  mov di,ax

4fbc  mov ax,cs:[091ah]
4fc0  or ax,ax
4fc2  je 4fc7
4fc4  xor di,di             ; force threshold 0 for first 60 iterations
4fc6  dec ax
4fc7  mov cs:[091ah],ax
4fcb  call 4a0b             ; consumes this record's payload
4fce  call 4a9b
```

The record sequence is `1..59,59..0,0..59,...`, a 120-iteration ping-pong.
The initial 60-count state does not blank the screen and does not replace `SI`;
it forces `DI=0`, making `4A0Bh` consume all 100 offset bytes from each selected
record. The independent `0914h` phase has 1,000 states, so the two raster-table
owners realign every 3,000 main-loop iterations.

If the hold delay at `2b68` is nonzero, the loop skips text drawing:

```asm
4fd1  cmp word cs:[2b68h],0
4fd7  je 4fe1
4fd9  dec word cs:[2b68h]
4fde  jmp 5088
```

When it does draw, it computes:

```text
text_offset = 2b6a + row * 40 + column + page * 240
x = column * 8
y = row * 12 + 16
```

The row multiply by 40 uses shifts:

```asm
4fe1  mov ax,cs:[091eh]  ; row
4fe5  shl ax,1           ; *2
4fe7  shl ax,1           ; *4
4fe9  shl ax,1           ; *8
4feb  mov bx,ax
4fed  shl ax,1           ; *16
4fef  shl ax,1           ; *32
4ff1  add bx,ax          ; row * 40
4ff3  add bx,cs:[091ch]  ; + column
4ff8  add bx,2b6ah       ; + page stream base
```

The page multiply by 240 is also shift-only:

```asm
4ffc  mov cx,cs:[2b66h]  ; page
5001  shl cx,1           ; *2
5003  shl cx,1           ; *4
5005  shl cx,1           ; *8
5007  shl cx,1           ; *16
5009  mov dx,cx          ; page * 16
500b  shl cx,1           ; *32
500d  shl cx,1           ; *64
500f  shl cx,1           ; *128
5011  shl cx,1           ; *256
5013  sub cx,dx          ; page * 240
5015  add bx,cx
```

The x/y coordinate math:

```asm
5017  mov cx,cs:[091ch]  ; column
501c  shl cx,1
501e  shl cx,1
5020  shl cx,1           ; x = column * 8

5022  mov dx,cs:[091eh]  ; row
5027  shl dx,1
5029  shl dx,1           ; row * 4
502b  mov ax,dx
502d  shl dx,1           ; row * 8
502f  add dx,ax          ; row * 12
5031  add dx,0010h       ; y = row * 12 + 16

5034  mov al,cs:[bx]
5037  call 4d74
```

Then the cursor advances through columns, rows, and pages:

```asm
503a  inc word cs:[091ch]
503f  cmp word cs:[091ch],0028h
5045  jl 5088

5047  mov word cs:[091ch],0
504e  inc word cs:[091eh]
5053  cmp word cs:[091eh],0006h
5059  jl 5088

505b  mov word cs:[091eh],0
5062  mov word cs:[091ch],0
5069  mov word cs:[2b68h],012ch
5070  mov cx,cs:[2b64h]
5075  inc word cs:[2b66h]
507a  cmp cs:[2b66h],cx
507f  jl 5088
5081  mov word cs:[2b66h],0
```

So the text does not scroll continuously. It types/reveals one glyph at a time
across a 40x6 page, waits for `012Ch` main-loop iterations after a page, then
advances to the next page, wrapping after five pages. One page therefore costs
240 draw iterations plus 300 hold iterations, or 540 total. A complete five-
page cycle is 2,700 iterations and writes 76,800 glyph bytes to VGA. Because
the raster helpers consume about two physical display frames per iteration,
these counters are loop cadences, not promises of one glyph or hold tick per
refresh.

Keyboard polling is DOS function `AH=0Bh`:

```asm
5089  mov ah,0bh
508b  int 21h
508d  or al,al
508f  jne 5094
5091  jmp 4f96
```

No key: loop forever. Any key: enter the closing sequence.

## One Complete Display Iteration

The steady state is now explicit from table selection through presentation:

```text
select one 101-byte raster record on the 120-iteration ping-pong
wait vertical high->low
run 200 horizontal-status steps:
  write CRTC[04h] every step
  write CRTC[13h] on 82..100 alternate steps after the threshold
restore CRTC[04h]=54h and CRTC[13h]=28h
run the fixed 186-scanline DAC schedule: 504 DAC writes
if page hold is zero: copy one 8x8 glyph, 64 source reads + 64 VGA writes
advance page state or decrement the 300-iteration hold
poll DOS keyboard status once
```

The common drawing iteration therefore has 570..606 byte-equivalent CRTC
writes, 504 DAC writes, and 64 VGA writes. A hold iteration has the same raster
traffic and no VGA writes. The loop executes under `CLI`; hardware timer and
device IRQs cannot perturb the beam-raced sections, while its explicit DOS
software interrupts remain callable. This is direct single-page publication:
there is no backbuffer, page flip, object sort, or old-frame repair in the
steady path. Glyph cells overwrite themselves and raster movement comes from
CRTC/DAC state.

## Closing Sequence

On keypress, the intro consumes the key, clears the first 32,000 bytes of VGA
memory, performs several palette transitions, copies the predecoded thanks page
from the allocated block to `A000:0000`, then fades again:

```asm
5094  mov ah,08h
5096  int 21h

5098  mov ax,0a000h
509b  mov es,ax
509d  xor di,di
509f  mov cx,7d00h
50a2  xor al,al
50a4  rep stosb
```

The full-page copy:

```asm
5108  mov ax,cs:[4e32h]
510c  mov ds,ax
510e  mov cx,0fa00h
5111  xor si,si
5113  mov di,si
5115  rep movsb
```

`0xfa00` is 64,000 bytes, exactly one 320x200 mode 13h screen. That is why
`THANX.P91` was decoded into a separate block during startup: the exit can show
the final image with one linear copy instead of doing a decompression pass under
the final fade.

The surrounding transition is exactly bounded:

```text
5098  clear A000:0000..7CFFh                         32,000 VGA writes
50A6  seed three palette bytes with 3Fh
50B8  10 x interpolate/upload 64 entries            1,920 divisions / DAC data writes
50DD  upload one complete 256-entry palette             768 DAC data writes
50EB  restore line-compare 0 and display start 0
5108  copy the predecoded thanks page                64,000 VGA writes
5117  40 x interpolate/upload all 256 entries        30,720 divisions / DAC data writes
513C  wait for a second key with DOS AH=08h
5140  40 x interpolate/upload all 256 entries        30,720 divisions / DAC data writes
5165  BIOS mode 3
516A  DOS terminate
```

Across those three interpolation stages, the closing path performs 63,360
signed component divisions and current-palette writes. Including the one full
upload, it sends 64,128 DAC data bytes, 91 DAC index bytes, and waits for 91
complete vertical-retrace edges. Its fixed framebuffer work is 96,000 writes.
The second blocking key read deliberately holds the final page between the two
40-step fades.

Finally it returns to text mode and exits:

```asm
mov ax,0003h
int 10h
mov ax,4c00h
int 21h
```

## What Each Part Does

The intro divides cleanly into these functional parts:

- MZ entry/depacker: moves the packed stream upward, expands the real runtime,
  and jumps to it.
- DOS setup: shrinks the original executable block, loads external `.P91`
  assets, and allocates 92,880 bytes across four child blocks.
- Image decoder: expands RLE-coded bitplanes into chunky VGA pixels, reusing
  the same packet loop for 2,072 row-plane units and 663,040 destination
  read/modify/writes.
- VGA setup: starts from BIOS mode 13h and edits selected CRTC registers.
- Palette engine: uses descending divisors to land exactly on target tables and
  uploads during complete retrace edges.
- Scanline waver: hands one of sixty 101-byte records into 200 beam-raced CRTC
  updates, while an independent 1,000-state table modulates horizontal retrace.
- Text engine: renders one opaque 8x8 glyph after a fixed 186-scanline DAC
  schedule, then advances five 40x6 pages with exact reveal/hold counters.
- Exit path: clears 32 KB, performs three bounded palette stages, copies the
  already-decoded 64 KB final page, waits for a second key, restores text mode,
  and lets DOS release every owned block.

The core technical identity is not any single visual. It is the combination of
old real-mode DOS file discipline with direct VGA timing and small, reused
inner loops. For 1991 PC demo work, that is the point: it sits between simple
text-mode intros and the more structured multi-effect engines that would become
common in the 1992-1994 PC scene.
