Analysis model: gpt-5.5 xhigh

# Saint by Halcyon and da Jormas - Technical Dissection

`Saint` is Halcyon's 1997 MS-DOS demo with da Jormas: one protected-mode show,
nine separately linked scene engines, a custom executable-as-filesystem shell,
and a deliberately unruly mixture of rendered caves, textured tunnels, treated
video, product-label collage and cut-out characters. The useful fact is not
merely that the demo contains a 3D engine. It contains nine effect programs
inside one 315,531-byte executable, and the outer 2.58 MB file makes another 36
resources look like normal DOS files by intercepting `INT 21h`.

## Identity and evidence

| Item | Recovered fact |
| --- | --- |
| Production | `Saint` by Halcyon and da Jormas |
| Release | 15 August 1997; Assembly 1997 PC demo, disqualified |
| Code | Blitz; additional code by Placidity |
| Graphics / models | Placidity, Croaker, Shrine; meshes by Ren |
| Music | Naks, PAM and Vesuri; three pieces combined for the demo |
| Support code | player by Asmu; PMODE by Tran |
| Original carrier | `saintfin.zip`, 965,610 bytes |
| `saintfin.zip` SHA-256 | `1fdd0fbe8022edeb58a48003561d9c0b6791da3b203381a5d135153902b7c3f0` |
| `SAINT.EXE` | 2,583,609 bytes; SHA-256 `2116cc2ca7eaa04e3c426e027c930adac1c48fca9b18cb9fb80a96a2b69efd1c` |
| Recovered `P.EXE` | 315,531 bytes; SHA-256 `41b448a7f2468dc17525266090187f3ead3190b0565c7410b8ad106a5e92d4a3` |

The party, date and credits agree across the original `README.1ST`, the
[Pouet record](https://www.pouet.net/prod.php?which=296), the
[Demozoo production record](https://demozoo.org/productions/100299/) and the
[Scene.org release archive](https://files.scene.org/get/demos/groups/halcyon/saintfin.zip).
The final archive says it fixes party-version problems and adds Sound Blaster
and 8 MB support. It also says to try keys; that is a real authored interaction
hint, not an inference from the video.

## Runtime boundary

The exact release was booted under DOSBox-X 2026.01.02 with a Pentium-class
fixed-cycle guest, 32 MB, GUS at `240/5/3`, and dummy host audio and video. The
loader entered the show, repeatedly opened its own `SAINT.EXE`, installed its
protected-mode path and continued without a DOS error during the bounded
20-second run. That run proves startup and the self-file path, but the dummy
video driver does not make it visual evidence.

The pictures and continuous GIFs below therefore come from the complete
263.96-second video-only preservation stream linked by Pouet. It was decoded
with `-map 0:v:0 -an`; no audio stream was captured, played or published. The
stream reaches the authored closing `halcyon & da jormas 1997` frame at about
4:16 and holds it through the end. Timestamps below are preservation-stream
timestamps, normally within a second of the visible cue.

## The first executable is only a relocator

The outer MZ header declares a file size of only 2,597 bytes even though the
physical file is 2,583,609 bytes. There are no MZ relocations. The entry stub
copies 171 blocks of sixteen bytes upward, patches the segment word of its own
far jump with the DOS load segment, and enters the relocated unpacker:

```asm
; SAINT.EXE file +20h, loaded at CS=01EFh in the traced run
mov  ax,cs
add  word [cs:0049h],ax      ; 026Eh -> 045Dh in this run
mov  dx,00AAh
add  ax,dx
mov  bx,ax
add  ax,0242h

.move_blocks:
mov  ds,bx
mov  es,ax
xor  si,si
xor  di,di
mov  cx,8
rep  movsw                   ; copy one 16-byte paragraph
dec  bx
dec  ax
dec  dx
jns  .move_blocks

jmp  045Dh:06DAh            ; patched target in the traced load
```

The relocated routine is a bit-coded LZ depacker. `BP` is a sixteen-bit shift
register, `DL` counts remaining bits, literals go through `MOVSB`, and matches
copy from `ES:[DI+BX]`. An all-ones match offset is its terminator:

```asm
.next_bit:
shr  bp,1
dec  dl
jne  .bit_ready
lodsw                         ; DS:SI is compressed input
mov  bp,ax
mov  dl,10h
.bit_ready:
ret

.token:
call .next_bit
jnc  .match
movsb                         ; literal byte
jmp  .token

.match:
call .next_bit
lodsb
mov  bh,0FFh
mov  bl,al
jc   .long_offset
; more bits select the length class
...
mov  al,es:[bx+di]
stosb
loop .copy_match
jmp  .token

.candidate_end:
cmp  bh,bl
jne  .copy_match
pop  bp                       ; FFFFh offset terminates the stream
```

The depacker then processes fifteen relocation records and patches its handoff
from `01CCh:0005h` to `03BBh:0005h`. The recovered 64 KiB segment has SHA-256
`f93f991489f3032cc2d384ad8899dc1b93e16f0b8e38288a013f26a740e3bfc3`.

## BL20 turns the overlay into a filesystem

The unpacked outer program is not the demo renderer. It is a container runtime.
It opens its own executable, calculates the declared MZ end, seeks to file
offset `0A25h`, and decodes only the directory records with XOR `66h`:

```asm
; Decode the directory bytes just read by DOS.
; AX = number of bytes read, DS:DX = destination.
or   ax,ax
jz   .done
push cx
push si
mov  cx,ax
mov  si,dx
.xor:
xor  byte [si],66h
inc  si
loop .xor
pop  si
pop  cx
.done:
ret
```

The decoded directory is a compact repeated record:

```c
struct bl20_entry_on_disk {
    uint32_t length;
    uint32_t file_offset;
    uint8_t  name_length;
    char     name[name_length];
};
// 0xFFFF ends the directory.
```

The loader expands that stream into three parallel 255-entry arrays. Names use
twelve bytes each; lengths and offsets use four bytes each:

```asm
; Find an embedded filename, case-insensitively.
mov  es,020Fh
xor  di,di                   ; names[0]
mov  cx,00FFh
.entry:
push si
push di
.character:
cmp  byte [si],0
je   .found
cmp  byte [si],'$'
je   .found
mov  al,[si]
mov  ah,es:[di+008Dh]
; fold ASCII a-z to A-Z in AL and AH
...
inc  si
inc  di
cmp  ah,al
je   .character
pop  di
pop  si
add  di,12
loop .entry
stc
ret
```

The 37 files are contiguous from offset 3,269 through EOF. Important entries
include `P.EXE` (315,531 bytes), a 493,141-byte `ALKU.MöH`, the 359,880-byte
Scream Tracker 3 module `MUSA2.S3X`, `UKKO.AN` (132,800 bytes), seventeen
320×200/256×256/320×45 RIX3 images, and the `.ER` scene/animation data. The
array relationship is exact: `offset[n+1] == offset[n] + length[n]` for every
entry, and the final `VARJO02.SCX` ends exactly at byte 2,583,609.

The shell hooks `INT 21h` and intercepts DOS open, close, read, seek and execute.
An embedded open returns a synthetic handle; reads clamp the request against
the entry length, add the entry's base offset, seek the real `SAINT.EXE` handle,
and forward the read to DOS:

```asm
; Synthetic handle -> entry index -> current position.
movzx ebx,byte es:[bx+188Dh]
dec   bl
shl   bx,2
mov   eax,es:[bx+148Dh]       ; current position
mov   edx,es:[bx+0C8Dh]       ; file length
sub   edx,eax                 ; remaining bytes
cmp   ecx,edx
jb    .count_ok
mov   cx,dx
.count_ok:

add   eax,es:[bx+108Dh]       ; physical offset in SAINT.EXE
; old INT 21h: AX=4200h seeks the real container handle
...
; old INT 21h reads CX bytes to caller DS:DX
add   es:[bx+148Dh],ax        ; advance virtual position
```

Execution is virtualized too. When `P.EXE` is launched, the loader reads its MZ
header and relocation table through the same private file path, allocates a PSP
and image block, applies relocations, patches a far jump, changes stack, and
enters `0461h:03DBh` in the traced run. The embedded file remains a perfectly
ordinary MZ when carved; no second decryption step is needed.

## P.EXE: PMODE and the real 32-bit entry

`P.EXE` contains Tran's PMODE startup. Its real-mode entry tests 386 flag
behavior, A20, DPMI (`INT 2Fh/1687h`) and VCPI, then has a raw protected-mode
fallback. In that path it loads its GDT/IDT, sets CR0.PE and far-jumps through
selector `20h`:

```asm
lgdt [0C52h]
lidt [0C4Ch]
mov  byte [00000EE5h],89h
mov  eax,cr0
or   al,1
mov  cr0,eax
jmp  0020h:0000021Eh

; protected side
mov  ax,0030h
ltr  ax
jmp  00001067h
```

After saving the real-mode environment and installing its protected-mode
interrupt bridge, the startup jumps to 32-bit file offset `4C0DCh`. This is the
show controller, not a guessed entry found from strings.

## One controller, nine linked scene engines

The controller first allocates aligned buffers, builds a 64-entry nonlinear
intensity table, a cosine table, and a 256×256 pair of product tables. It then
calls nine distinct initializers:

```asm
call 0002D105h
call 00030F45h
call 00034F29h
call 00038603h
call 0003AAB3h
call 0003DA15h
call 00041959h
call 00045893h
call 00048ECBh
```

The scene blocks are not nine entries in a data table. Each contains another
copy of the `halcyon super kolmedee enkine (tm)` loader and its own filenames,
palette callbacks, camera records and private state. Their principal visible
resources identify the copies:

| Engine block | Named inputs in `P.EXE` | Main scene routine |
| --- | --- | --- |
| 1 | `sainlogo.scx`, `txt3.scx`, `12apina.er` | `0002D85Bh` |
| 2 | `s13.scx`, `txt16.scx`, `jornma5.er`, `jornmamo.er` | `0003135Fh` |
| 3 | `s02b.scx`, `txt24.scx`, `tieto6.er`, `tietu.er` | `00035457h` |
| 4 | `kredu.scx`, `txt19c.scx` | `000387F7h` |
| 5 | `txt-a01.scx`, `maaa.er` | `0003AE70h` |
| 6 | `txt-a03.scx`, `muna.er`, `muna2.er` | `0003DEC0h` |
| 7 | `kooso.scx`, `kalamas.er`, `kalalas.er`, `ukko.an`, `s07.scx` | `00041F26h` |
| 8 | `txt25.scx`, `palloa.er`, `pallod.er`, `s15.scx` | `00045D4Ah` |
| 9 | `varjo02.scx` and the closing scene set | `000493BCh` |

The authored order is 1–6, then 8, 9 and 7. The controller clears the 64,000
byte display window between parts and records each part's elapsed timer value:

```c
for (scene = 0; scene != 6; ++scene) {
    clear_64000_bytes();
    saved_clock = timer_ticks;
    run_scene[scene]();
    elapsed[part_count++] = timer_ticks - show_start;
    if (quit_flag == 1) goto finish;
}

reset_timing_phase();
run_scene_8();
run_scene_9();
run_scene_7();
```

That direct call chain is why the demo can change visual grammar abruptly. A
scene owns the machine until it returns; the controller is not switching a
universal renderer every frame.

## Inner loops: palettes, camera splines and framebuffer work

Each engine installs three scene-specific callback pointers at `00007F50h`,
`00007F54h` and `00007F58h`. The first scene, for example, points them at
`2D8ADh`, `2D3D5h` and `2D5A3h`. Its palette construction is concrete rather
than descriptive prose: it blends two 768-byte RGB palettes over 350 steps,
scales VGA components by four, divides by 350, and clamps to 255:

```asm
movzx eax,byte [palette_a+ebp]
movzx ebx,byte [palette_b+ebp]
shl   eax,2
shl   ebx,2
imul  eax,esi
mov   edx,350
sub   edx,esi
imul  ebx,edx
add   eax,ebx
cdq
mov   ebx,350
idiv  ebx
cmp   eax,0
jg    .positive
xor   eax,eax
.positive:
cmp   eax,255
jl    .store
mov   eax,255
.store:
stosb
```

Another first-scene loop builds a complete 256×256 color-combination table.
For each source and intensity pair it adds twice the generated ramp value,
clamps to VGA's six-bit 63, then expands the palette through the common table
builder at `2055Ah`. That precomputation is the reason the fiery tunnel can do
per-pixel lighting with table reads instead of multiplies in its display loop.

The fourth part exposes a useful fixed-point camera interpolator. Each keyframe
record stores two 3-vectors 0x1EC bytes apart. The code forms an eight-step
outer delta (`>>3`), then an inner 2,048-step delta (`>>11`) while keeping the
working vector at eight fractional bits (`>>8`):

```asm
mov eax,[esi+01ECh]
mov ebx,[esi+01F0h]
mov ecx,[esi+01F4h]
sub eax,[esi+00h]
sub ebx,[esi+04h]
sub ecx,[esi+08h]
sar eax,3
sar ebx,3
sar ecx,3                   ; eight coarse camera segments

; Per coarse segment, interpolate between two working endpoints.
sub eax,ebp
sub ebx,esi
sub ecx,edx
sar eax,11
sar ebx,11
sar ecx,11                 ; 2048 inner increments
sar ebp,8
sar esi,8
sar edx,8                  ; feed Q8 camera coordinates
```

Part four also calibrates its timer against two vertical retraces. It waits on
VGA status port `3DAh`, latches PIT channel 0, measures the count, compensates
by `00C0h`, and installs a new divisor. This is a raster-related pacing path,
not evidence that every 3D frame is hard-locked to one refresh:

```asm
mov  dx,03DAh
.not_retrace: in al,dx
test al,08h
jnz  .not_retrace
.retrace: in al,dx
test al,08h
jz   .retrace

in   al,40h
mov  ah,al
in   al,40h
xchg al,ah
neg  ax
sub  ax,00C0h
mov  [pit_divisor],ax
```

At controller level, clearing a part is exactly 64,000 bytes: `3E80h` dwords
from the linear address corresponding to VGA `A0000h`. The small plot helper at
`4CAD8h` decomposes a linear pixel index into row, sixteen-pixel group, plane
and intra-plane byte before writing the color. This is a swizzled/planar helper,
whereas the fast scene paths use their allocated chunky buffers and common
copy routines:

```asm
mov  edi,0A0000h
sub  edi,[linear_base]
mov  ecx,03E80h
xor  eax,eax
rep  stosd                     ; 03E80h dwords = 64,000 bytes

; Address helper: row and plane terms are assembled separately.
mov  eax,edi
shr  eax,4
cdq
mov  ebx,40
idiv ebx
shl  edx,2
add  esi,edx
lea  eax,[eax+eax*4]
shl  eax,7                     ; row * 640
add  esi,eax
```

## Decoded resources and runtime concordance

All seventeen `.SCX` files are uncompressed `RIX3`: four-byte signature,
little-endian width and height, two reserved bytes, 768 six-bit DAC values,
then exactly `width*height` indexed pixels. The contact sheet is a direct local
decode, not a frame grab.

![Locally decoded RIX3 bank: backdrops, cut-outs and 256×256 texture maps](images/saint-halcyon-scx-bank.png)

The bank explains several otherwise strange composites. `S02B.SCX` is the
Chemical Floors product-label overlay; `S15.SCX` is the cow cut-out;
`S07.SCX` is the pale character used in the closing world; and the seven
`TXT*.SCX` files are the 256×256 surfaces named beside their engine copies.

At 0:19–0:28, the first scene wraps its noisy `TXT3` surface around the gem
tunnel while `SAINLOGO.SCX` remains a flat overlay. That separation matches the
resource dimensions and the first engine's two loader paths.

![Gem tunnel and flat Saint title overlay, 0:19–0:28](images/saint-halcyon-gem-tunnel.gif)

At 0:38–0:47, the precomputed palette-combination table is visible as the
vortex changes brightness without losing its texture coordinates.

![Fire-vortex lighting and palette changes, 0:38–0:47](images/saint-halcyon-fire-vortex.gif)

At 1:22–1:32, the second/third scene family combines a moving camera, large
flat geometry and the `S02B` cut-out rather than baking the label into the
texture.

![Chemical Floors scene, 1:22–1:32](images/saint-halcyon-chemical-floors.gif)

At 2:34–2:44, the cow remains a screen-space cut-out while the grid and planet
move in depth. That agrees with the separate `S15.SCX` resource and the scene's
independent 3D/cut-out paths.

![Cow cut-out over the moving wire room and planet, 2:34–2:44](images/saint-halcyon-cow-grid.gif)

At 3:08–3:18, the fourth-scene camera interpolation is easiest to see: the star
stays a scene target while cave walls advance in smooth substeps.

![Interpolated cave camera and star target, 3:08–3:18](images/saint-halcyon-cave-star.gif)

At 3:45–3:55, the final world combines multiple moving surfaces with the
separate pale-character cut-out. It is another engine-owned composition, not a
single decoded animation.

![Closing mushroom-world composition, 3:45–3:55](images/saint-halcyon-mushroom-world.gif)

## What is proved, and what remains open

The self-relocation, LZ depacker, BL20 directory, 37-file boundaries, virtual
DOS handle layer, MZ child loader, PMODE transition, nine initializers, authored
scene-call order, palette loops, camera interpolation and PIT/VGA calibration
are proved by recovered bytes and traced control flow. The SCX assignments are
proved by decoded files and literal filenames beside the matching engine
copies. The GIF concordance is proved by the complete video-only reference.

The `.ER`, `PETE.PAK` and `UKKO.AN` internal record formats still deserve a
separate pass. The evidence already shows which scene opens each file, but this
pass does not pretend every mesh field, animation opcode or face-span routine
has been named. `Saint` is large enough that claiming all nine linked engines
fully decompiled would be less accurate than publishing the recovered
dispatcher, loader, timing and representative inner loops above.
