Analysis model: gpt-5.5 xhigh

# The King of the Round Table by Zwilight Tone - Technical Dissection

Release year: 1994

`The King of the Round Table` is Zwilight Tone's MS-DOS intro from The
Gathering 1994. The TG94 result file lists the PC intro competition in score
order with `Das Grelle` first, `The king of the round table` second, and
`Outta time` third.

This pass uses the public Scene.org archive `thekingr.zip`. The intro is a
single packed MZ executable, `ZT.EXE`, with a short text setup asking for Gravis
UltraSound port and IRQ. The shipped note says the intro requires a GUS; there
is no Sound Blaster, PAS, or no-sound path in the visible setup code.

Sources:

- Scene.org archive:
  https://archive.scene.org/pub/parties/1994/thegathering94/in80/thekingr.zip
- Scene.org result file:
  https://archive.scene.org/pub/parties/1994/thegathering94/results.txt
- Scene.org directory entry:
  https://archive.scene.org/pub/parties/1994/thegathering94/in80/

## Archive Contents

Unpacked archive:

```text
FILE_ID.DIZ       201 bytes
ZT.EXE         59,906 bytes
ZT.NFO          1,678 bytes
```

Hashes used for this pass:

```text
d30977efcc735ba1d747f46f5d9c0e4b82b5fb969406a8632cf4d3051be18d34  thekingr.zip
15dafa5b8fa409f8d37e9ce9069a9ee2515af3c0c2ef70cb39bc45cab0207ef8  ZT.EXE
e85b1bfa6c8b475989a586498c0ffe8925550e421fdca0a42d90e880cf30d1e7  FILE_ID.DIZ
fa6fb520a09984b66b8950305dc8cb54054e2141db795c4e2a085b2d00e4c245  ZT.NFO
```

The unpacked RNC payload is:

```text
f07b2abf59fd142beb24a1fbaa32fa691280671ded9302b070975e664d63dbe4  zt_unpacked.bin
size: 169,328 bytes
```

## Packed EXE Shape

`ZT.EXE` has a tiny MZ header followed immediately by an RNC block:

```text
0000: MZ ...
0020: 52 4e 43 01 ...     ; "RNC", method 1
```

Important MZ header values:

```text
header paragraphs: 2
entry CS:IP:       0e6f:000c
entry file offset: 0xe71c
load image bytes:  59,874
```

The RNC header at file offset `0x20` says:

```text
method:        1
unpacked size: 0x29570 bytes
packed size:   0xe6d3 bytes
unpacked CRC:  0x2408
packed CRC:    0x7332
```

The public RNC ProPack tools report this as key-protected. The embedded DOS
stub reveals why: it is a normal method-1 RNC stream, but after the first two
flag bits it reads a 16-bit rotate-XOR key directly from the compressed
bitstream. A standalone unpacker that merely accepts `-k=...` stays 16 bits out
of phase unless it also consumes those key bits.

The useful stub fragment, loaded at `CS:0000` from file offset `0xe710`, is:

```asm
0074  be 11 00        mov si,0011h        ; RNC stream after 18-byte header
0077  ac              lodsb               ; chunk count / chunk byte
...
0089  b0 02           mov al,02h
008b  e8 37 01        call read_bits      ; consume two RNC flag bits
008e  e8 32 01        call read_16_bits
0091  89 46 1a        mov [bp+1a],ax      ; inline key
```

Replaying the first 18 bits of the method-1 stream gives:

```text
first two bits: 2
inline key:     0x1238
```

The literal-copy loop is compact and matches the RNC key behavior:

```asm
00d6  call decode_raw_count
00dc  jcxz no_literals
00de  lodsb
00df  xor al,[bp+1a]      ; low byte of rotate-XOR key
00e2  stosb
00e3  loop 00de
00e5  ror word [bp+1a],1  ; one rotate after the literal run
```

Backreferences use decoded length and offset tables, then copy from already
expanded output:

```asm
00b4  call decode_len
00bb  call decode_offset
00c1  add cx,2            ; RNC match count bias
00c5  inc ax              ; RNC match distance bias
00ca  sub si,ax
00cf  rep movsb           ; copy previous bytes forward
```

After expansion, the stub applies relocation records stored at `CS:029a` and
far-jumps to the original entry. In the raw expanded image, offsets below are
plain file offsets unless a `seg:off` form is shown.

## Startup And Setup

The real entry begins at `0x0000`:

```asm
0000  mov ah,4ah
0002  mov bx,3000h
0005  int 21h             ; resize DOS memory block
0007  call 0301h          ; install INT 21h hook
000a  mov ax,0001h
000d  int 10h             ; 40x25 text setup screen
000f  mov ax,cs
0011  mov ds,ax
0013  mov es,ax
0015  mov ah,09h
0017  mov dx,005ch
001a  int 21h             ; print port menu
```

The GUS port choice maps directly to `0x210..0x260`:

```asm
001c  xor ax,ax
001e  int 16h             ; wait key
0020  cmp al,'1'
0024  cmp al,'6'
0028  sub al,'0'
002a  mov cl,4
002c  shl al,cl           ; 1..6 -> 10h..60h
002e  mov ah,02h          ; AX -> 0210h..0260h
0030  mov di,ax           ; GUS base port
```

The IRQ choice uses a byte table at `0x55`:

```text
02 03 05 07 0b 0c 0f
```

The selected IRQ byte is copied into `SI`, then execution jumps to `0x016f`.
There the code masks keyboard IRQ1, returns to 80x25 text mode, hides the
cursor, clears/fixes a couple of DAC entries, initializes the GUS layer, and
enters the cue loop.

## The INT 21h Virtual File

Before any GUS setup, `0x0301` hooks DOS interrupt `21h`:

```asm
0301  cli
0302  mov ax,3521h
0305  int 21h             ; get old INT 21h vector
0307  mov cs:[032c],bx
030c  mov cs:[032e],es
0311  mov ax,2521h
0316  mov dx,0336h
0319  int 21h             ; install local handler
031b  sti
```

This is not a general file-system hook. It serves one fake file to the GUS
loader. The call at `0x0188` points `DS:DX` at the two bytes `ff 00` and calls
the player init routine:

```asm
0188  push cs
0189  pop ds
018a  mov dx,016dh        ; fake filename marker: ff 00
018d  call 2564:1af3      ; GUS/player init
```

The INT 21h hook recognizes `AH=3Dh` open requests whose first filename word is
`00ffh`, returns fake handle `55aah`, then intercepts `AH=42h` seek and
`AH=3Fh` read for that handle.

The read path is the most interesting part:

```asm
03c8  push es
03c9  push di
03ca  push ds
03cb  push si
03cc  push cx
03cd  mov ax,cx           ; requested length
03cf  mov di,dx           ; destination buffer
03d1  push ds
03d2  pop es
03d4  mov si,0e87h
03d7  mov ds,si
03d9  mov si,0128h
03dc  add si,cs:[0332]    ; virtual file offset
03e2  lodsb
03e3  xor al,54h
03e5  xor al,5ah          ; net XOR = 0x0e
03e7  stosb
03e8  loop 03e2
03eb  add cs:[0332],ax    ; advance virtual offset
03f0  adc cs:[0334],0
```

So the intro embeds the music/module data in its loaded image at
`0e87:0128`, and the DOS hook feeds it to the sound library as if it were a
normal file. The actual transform is just `byte ^ 0x0e`; the two XORs hide it
slightly and keep the hook small.

## Main Cue Loop

After GUS init, the entry calls `0x031d` to restore INT 21h. Then it clears the
cue index at `0e87:d5e8` and loops over a 4-byte table at `0e87:d5ea`.

Raw table entries:

```text
time  ptr
0001  0229
0003  023e
0005  0253
0007  01dd
0009  0253
000b  023e
000d  0229
000f  0202
0011  0229
0013  023e
0015  0253
0017  0202
0019  0253
001b  023e
001d  0229
001f  01dd
0020  0268
003f  026d
0117  029f
0118  02b4
0119  02b4
011b  02cb
011c  02e3
0120  028c
0301  02fb
0401  2189
ffff  ffff
```

The runner is simple:

```asm
01a0  mov ax,0e87h
01a3  mov ds,ax
01a5  mov si,ds:[d5e8]
01a9  cmp word [si+d5ea],ffffh
01ae  je  01c8
01b0  call 2564:1ad2      ; get music time
01b5  cmp ax,[si+d5ea]
01b9  ja  01c1            ; time passed: advance to next entry
01bb  call word [si+d5ec] ; otherwise keep drawing this cue
01bf  jmp 01a0
01c1  add word [d5e8],4
01c6  jmp 01a0
```

The same visual routine is called repeatedly until the music time exceeds its
cue value. That means early entries are not one-shot calls; they are frame
workers.

The final table pointer is exactly `0x2189`, whose first bytes are `cd 03`.
No local install for INT 3 was found. The useful body starts at `0x218b`, so
this is either a leftover breakpoint byte pair that returns harmlessly on the
target setup, or the table intentionally lands two bytes early. I would not
build a stronger claim from static evidence alone.

## Early Text-Mode Pages

The first cue group is mostly direct text/video-memory work.

`0x01dd` clears selected DAC entries and clears `B800:0000`:

```asm
01dd  mov dx,03c8h
01e0  mov al,0
01e2  out dx,al
01e3  inc dx
01e4  out dx,al
01e5  out dx,al
01e6  out dx,al
...
01f3  mov ax,0b800h
01f6  mov es,ax
01f8  mov cx,07d0h
01fb  xor di,di
01fd  xor ax,ax
01ff  rep stosw
```

`0x0202` does the same clear, but swaps which of palette entries 0 and 7 is
bright, giving the white/black flash alternate:

```asm
0202  mov dx,03c8h
0205  mov al,0
0207  out dx,al
0208  inc dx
0209  mov al,1eh
020b  out dx,al
020c  out dx,al
020d  out dx,al
020e  mov dx,03c8h
0211  mov al,7
0213  out dx,al
0214  inc dx
0215  mov al,0
0217  out dx,al
0218  out dx,al
0219  out dx,al
```

`0x0229`, `0x023e`, and `0x0253` copy full 80x25 text pages:

```asm
0229  mov ax,0b800h
022c  mov es,ax
022e  mov ax,1e76h
0231  mov ds,ax
0233  mov cx,07d0h
0236  xor di,di
0238  mov si,0000h
023b  rep movsw           ; 4000 bytes, char+attribute pairs
```

The sister routines use `SI=0fa0h` and `SI=1f40h`, so the segment `1e76h`
contains three full text pages stacked at 4000-byte intervals.

`0x0268` enters mode `05h` and copies a random-looking 16 KB window from
segment `2164h` into `B800h`, using PIT reads as the source offset:

```asm
0268  mov ax,0005h
026b  int 10h
026d  mov ax,0b800h
0270  mov es,ax
0272  mov cx,4000h
0276  mov ax,2164h
0279  mov ds,ax
027b  in  al,40h
027d  mov ah,al
027f  in  al,40h
0284  mov si,ax
0286  xor di,di
0288  rep movsb
```

That is a cheap noise/image burst: no per-pixel math, just copy a shifting
window from prebuilt data.

## Text-Mode Block Logo Routine

The routine at `0x218b` is the last scheduled body. It returns to text mode,
sets nonstandard CRTC values, and draws large block graphics with CP437 full
block `0xdb` plus color attributes.

Setup:

```asm
218b  push cs
218c  pop ds
218d  mov ax,0003h
2190  int 10h
2192  mov dx,03d4h
2195  mov ax,7813h
2198  out dx,ax           ; CRTC index 13h = 78h
2199  mov dx,03d4h
219c  mov ax,140dh
219f  out dx,ax           ; CRTC index 0dh = 14h
```

The two CRTC writes alter text memory addressing/display start behavior. The
routine then uses two draw helpers:

`0x2220` reads 60 bytes of color data as 6 rows by 10 columns and expands each
byte into a 4x2 block:

```asm
2239  mov cx,6
223c  push cx
223d  push di
223e  mov cx,10
2241  lodsb
2242  mov ah,al           ; attribute
2244  mov al,0dbh         ; full block
2246  stosw
2247  stosw
2248  stosw
2249  stosw               ; four columns on row A
224a  add di,01d8h
224e  stosw
224f  stosw
2250  stosw
2251  stosw               ; four columns on row B
2252  add di,01d8h
2256  loop 2241
2258  pop di
2259  add di,8
225c  pop cx
225d  loop 223c
```

Why `0x01d8`? In 80-column text mode one row is 160 bytes. After four `stosw`
stores, `DI` has advanced 8 bytes. `0x01d8 = 472`, so the net movement to the
next block row is `8 + 472 = 480`, exactly three text rows. The helper draws
two rows of four cells, then skips enough to build large coarse pixels.

`0x2265` draws the same 6x10 block, but walks the source backward between calls:

```asm
227f  add si,0ah
2282  mov cx,6
2285  sub si,14h
...
22b0  pop si
22b1  sub si,3ch          ; next call shifts source by 60 bytes
```

That helper is used in a loop to animate two sources converging:

```asm
21c7  mov cx,0dh
21ca  mov si,056bh
21cd  call 2265h
21d0  mov si,04f3h
21d3  call 2265h
21d6  loop 21cah
```

Finally `0x21f8` copies larger rectangular chunks through `rep movsw`, with a
retrace wait before each update:

```asm
21f8  mov dx,03dah
21fb  in  al,dx
21fc  test al,08h
21fe  jne 21fb
2200  cli
2201  in  al,dx
2202  test al,08h
2204  je  2201
2206  sti
2209  mov cx,14h
220d  mov cx,2ch
2210  rep movsw
2212  xor ax,ax
2214  stosw
2215  stosw
2216  add di,0184h
221b  loop 220c
```

This is text mode treated as a chunky block surface: CP437 block glyphs supply
coverage, the high byte supplies color, and `B800h` stores both at once.

## Mode 13h Sine/Gradient Part

Cue `0x02fb` calls far routine `0000:2903`. It sets 320x200x256 mode, blacks the
palette, then enters a frame loop:

```asm
2903  mov ax,0013h
2906  int 10h
290a  mov dx,03c8h
290d  xor al,al
290f  out dx,al
2910  mov cx,0300h
2913  inc dx
2914  out dx,al           ; clear all DAC bytes
2915  loop 2914
2917  mov dx,03d4h
291a  mov ax,0013h
291d  out dx,ax           ; CRTC offset register set to 0
291e  call 2995h
```

The per-frame routine `0x2995` waits for vertical retrace, clears a top strip,
advances a phase word, then draws eight gradient bands from a table:

```asm
2995  cli
2996  mov dx,03dah
2999  in  al,dx
299a  test al,08h
299c  je  2999
299e  mov ax,0a000h
29a1  mov es,ax
29a3  xor di,di
29a5  mov cx,0140h
29a8  rep stosb           ; clear 320 bytes
29aa  add word cs:[25b6],2
29b0  cmp word cs:[25b6],01a4h
29b9  mov word cs:[25b6],0
```

`0x25b8` is a 210-word offset table. Early values are:

```text
0091 008c 0087 0083 007e 007a 0076 0072
006f 006c 006a 0068 0066 0065 0065 0065
0066 0068 006a 006c 0070 0073 0078 007d
```

That is a sine-like offset table, not code. The renderer reads eight entries
spaced 12 bytes apart and draws the same 64-byte gradient at each position,
with base colors `00h,20h,40h,...,e0h`:

```asm
29c0  mov bx,cs:[25b6]
29c5  mov di,cs:[bx+25b8]
29ca  mov al,00h
29cc  call 2a2ch
29cf  add bx,0ch
29d2  mov di,cs:[bx+25b8]
29d7  mov al,20h
29d9  call 2a2ch
...
2a20  mov di,cs:[bx+25b8]
2a25  mov al,0e0h
2a27  call 2a2ch
```

The hot writer at `0x2a2c` is fully unrolled:

```asm
2a2c  sub di,1fh
2a2f  stosb
2a30  stosb
2a31  inc al
2a33  stosb
2a34  stosb
2a35  inc al
...
2aa7  stosb
2aa8  ret
```

It writes pairs of equal color values and increments `AL` every two pixels.
Because the caller changes only the starting `DI` and base `AL`, the inner loop
has no address math besides `STOSB`. This is the classic 64-byte streak writer:
a table supplies motion, and the unrolled body supplies the gradient.

The same routine also does palette activity while it runs:

```asm
2929  mov cx,cs:[2900]
292e  mov si,25b3h
2931  sub si,cx
2933  mov dx,03c8h
2936  mov al,cs:[2902]
293a  out dx,al
293b  inc dx
293c  outs dx,byte ptr ds:[si]   ; six DAC bytes
...
294a  add word cs:[2900],6
2950  dec byte cs:[2902]
2957  dec byte cs:[2902]
```

So there are two motions at once: the screen-offset table moves the bands, and
the DAC update walks a palette source backward while changing the start index.

## Mode 13h Text Printer

After the main cue table exits, the code calls `0000:e82e`. This is a simple
mode 13h BIOS teletype printer with a retrace wait before each byte:

```asm
e82e  mov ax,0013h
e831  int 10h
e833  push cs
e834  pop ds
e835  mov si,e6f6h
e838  mov dx,03dah
e83b  in  al,dx
e83c  test al,08h
e83e  je  e83b
e840  in  al,dx
e841  test al,08h
e843  jne e840
e845  mov ah,0eh
e847  lodsb
e848  cmp al,0ffh
e84a  je  e85bh          ; next byte changes text color
e84c  cmp al,00h
e84e  je  e862h          ; end
e852  mov bl,cs:[e82d]   ; current color
e857  int 10h
e859  jmp e838h
```

The text stream contains inline color markers (`ff color`) and ends with `00`.
The visible strings identify Zwilight Tone, present `ekztasy`, and lead into
the "last techno part."

## Planar Page-Flip Finale

The final jump is `0000:2aaa`. It switches to VGA mode `0Dh` and uses planar
VRAM page offsets as animation frames:

```asm
2aaa  mov ax,000dh
2aad  int 10h
2aaf  mov dx,03c4h
2ab2  mov ah,0fh
2ab4  mov al,02h
2ab6  out dx,ax           ; sequencer map mask: all four planes
2ab9  mov ax,0a000h
2abc  mov es,ax
...
2ada  xor di,di
2adc  mov si,2b6fh
2adf  mov cx,0bb80h
2ae2  rep movsb           ; upload packed planar image/page data
```

Then it calls a tiny page-display helper with different page numbers:

```asm
2ae4  mov bx,3
2ae7  mov cx,3
2aea  call 2b3dh
2aed  mov bx,4
2af0  mov cx,3
2af3  call 2b3dh
2af6  mov bx,5
2af9  mov cx,3
2afc  call 2b3dh
2aff  mov bx,1
...
2b35  jmp 2affh           ; loop pages 1,0,2,3,4,5...
```

`0x2b3d` waits a requested number of vertical frames, toggles two DAC entries,
then sets the CRTC display start address:

```asm
2b3d  mov dx,03dah
2b40  in  al,dx
2b41  test al,08h
2b43  jne 2b40h
2b45  in  al,dx
2b46  test al,08h
2b48  je  2b45h
2b4a  loop 2b40h

2b4c  mov dx,03c8h
2b4f  mov al,0
2b51  out dx,al
2b52  inc dx
2b53  out dx,al
2b54  out dx,al
2b55  out dx,al
2b56  xor al,3fh
2b58  out dx,al
2b59  out dx,al
2b5a  out dx,al

2b5b  mov ax,1f40h
2b5e  mul bx              ; page * 8000
2b62  mov dx,03d4h
2b65  mov al,0ch
2b67  mov ah,bh
2b69  out dx,ax
2b6a  inc ax              ; index 0dh
2b6b  mov ah,bl
2b6d  out dx,ax
```

`0x1f40` is 8000 bytes, the byte span of a 320x200 4-plane mode page. The
visual trick is cheap: upload multiple pages once, then move the CRTC start
address. The CPU does not redraw the animation frame-by-frame; it changes the
visible window into already prepared VRAM.

## GUS Layer

The code treats the sound system as a far-call API in segment `2564h`:

```text
2564:1af3  initialization, called once with DS:DX pointing at fake file marker
2564:1ad2  returns a music time value in AX
2564:1bd2  shutdown, called before DOS exit
```

The player code itself is much larger than the intro glue and includes DOS
allocation, file reads, GUS memory setup, and pattern/sample conversion. The
important integration points for the intro are:

- the INT 21h hook feeds the embedded module bytes;
- the setup menu supplies GUS port in `DI` and IRQ in `SI`;
- the cue loop compares the player time in `AX` with the table at
  `0e87:d5ea`;
- visual routines do not parse pattern data directly.

## What The Intro Is Optimized For

The code is very 1994 PC-intro pragmatic:

- Text pages are pre-rendered and copied with `rep movsw`.
- Large text graphics use CP437 block glyphs instead of bitmap plotting.
- Per-frame animation is usually table + unrolled store loop.
- Palette changes are done through small `03c8h/03c9h` bursts.
- Vertical retrace waits are placed around visible updates instead of using a
  general frame scheduler.
- The finale page-flips by CRTC start address, so the CPU mainly waits and
  pokes two CRTC registers.

The fanciest part is not a single heavy polygon or voxel loop. It is the way the
intro combines a compressed/keyed loader, an embedded fake music file, timed
visual cue dispatch, and several very small VGA/text-mode loops into a compact
GUS-only show.
