Analysis model: gpt-5.5 xhigh

# Privtro by Irresistible Works - Technical Dissection

## Scope

`Privtro` is a 1993 MS-DOS intro by Irresistible Works. The package identifies
it as an Assembly 1993 release, with the DIZ/NFO noting that it was finished at
the deadline. Scene.org stores it in the Assembly 1993 PC demo archive as
`privtrop.zip`.

Public references:

- Scene.org archive:
  https://archive.scene.org/pub/parties/1993/assembly93/demo/privtrop.zip
- Scene.org Assembly 1993 demo directory:
  https://archive.scene.org/pub/parties/1993/assembly93/demo/
- Scene.org Assembly 1993 results:
  https://archive.scene.org/pub/parties/1993/assembly93/results.txt

This writeup is based on the scene.org archive, the bundled release notes,
custom unpacking of `PRIVTRO.EXE`, file layout inspection, and static 16-bit
disassembly of the expanded runtime image. It is not a source-level rebuild.

Old personal contact and distribution listings from the release notes are
deliberately omitted.

## Release Notes And Requirements

The NFO describes the package as an intro released at Assembly 1993 and gives a
plain file map:

- `PRIVTRO.EXE`: main executable.
- `PRIVTRO.001`: first picture.
- `PRIVTRO.002`: second picture used in the sphere section.
- `PRIVTRO.003`: font data for the sine scroller.
- `PRIVTRO.004`: palette data for the sine scroller.
- `PRIVTRO.MOD`: 4-channel module, titled `Trancedance`.

The program asks for one of four sound paths: PC speaker, Sound Blaster,
printer-port DAC, or no sound. If DAC output is selected it supports LPT1
through LPT4. It also asks for a playback rate from 4000 Hz to 16000 Hz.

One practical detail is visible only in the code: even though the prompt text
mentions a 286-class low-rate choice, the expanded executable uses 386
operand-size instructions. The clear-screen helper at `0x0000` uses `xor eax,
eax` and `rep stosd`, and the helper at `0x1b74` uses 32-bit multiply/shifts.
That makes a 386-class CPU the realistic floor.

## Examined Files

Archive hash:

```text
beb9139c83e950c5252c65e74e1a3a685e6c3b59f1a5b934c2c35a8e77f956ba  privtrop.zip
```

Extracted files:

```text
FILE_ID.DIZ      191 bytes  short release description
PRIVTRO.001     8829 bytes  320x200x8 PCX picture
PRIVTRO.002    27408 bytes  320x200x8 PCX picture
PRIVTRO.003    22000 bytes  raw 22x20 glyph/font blocks
PRIVTRO.004      768 bytes  raw 256-color VGA palette
PRIVTRO.EXE    16331 bytes  packed MZ executable
PRIVTRO.MOD   109810 bytes  ProTracker M.K. module, title "Trancedance"
PRIVTRO.NFO     1268 bytes  release notes
```

Extracted hashes:

```text
6d0d02049df2bb65f397837771355e509d7f12c47b06423727de131df68eba6f  FILE_ID.DIZ
deb309d80cf9196ed06cc3fc30d5a1bf96944d6474878800644e8d0584ddf720  PRIVTRO.001
98c6da34b49c8b134751651804afc60670fe2b40bc5722ffe626ef992affa01a  PRIVTRO.002
e3d223bdb065e1d8e86fb8d7882d989379e3522d89c10e3cdb21585e8ebcee64  PRIVTRO.003
4d8bb4bffc260734a3f0cf21b99da2bcdb38f032ed0b97688e78acfd94673a16  PRIVTRO.004
0ab7029b323144424e0afde22c55bf84284c65ad5296af1be3d0be421c2b040c  PRIVTRO.EXE
b18e1b5387819d52f9569d93a362b37a544d3f8dbb9c34bfa2c24482883ec549  PRIVTRO.MOD
59797204179d2e1f65c8411357967e007c83af9d361554956fcfa936f6b4e478  PRIVTRO.NFO
```

`PRIVTRO.001` and `PRIVTRO.002` are standard 8-bit single-plane PCX files:
320x200 bounds, 320 bytes per line, and a trailing `0x0c` palette marker.
`PRIVTRO.004` is already in VGA DAC scale, with color components in the
0..63 range.

`PRIVTRO.003` is exactly `50 * 0x1b8` bytes. The runtime treats that as 50
glyph blocks, each `0x1b8` bytes, or 22 columns by 20 rows. Zero bytes are
transparent and non-zero bytes are written directly to the screen.

## MZ Wrapper And Entry Trick

The visible executable is a packed DOS MZ:

```text
File size:         16331 bytes
MZ image size:     16331 bytes
Header size:       96 bytes
Relocations:       1
Entry CS:IP:       fff0:0100
Stack SS:SP:       03fd:0200
Min/max alloc:     116c/116c
```

The `fff0:0100` entry is a packed-program trick. With the DOS load segment
added, that entry lands physically at `PSP:0100`, the start of the loaded
image. The one relocation record patches the immediate word in the startup
memory check, so `mov ax,1549h` becomes relative to the actual load segment.

The first visible stub checks the DOS allocation, moves the stack upward, then
copies `0x18e` bytes from DOS offset `0144h` to a high segment and executes
that copied block with `retf`. That copied block is the real depacker.

## Custom Depacker

The copied depacker starts with a backward copy that moves the packed stream to
a safer high-memory area, then expands it back over the normal program load
area. For this executable, the compressed stream maps to file offset `0x240`.

The depacker's main loop is a compact LZ variant:

```text
read one bit from BP
if bit == 0:
  copy one literal byte, XORed with the current bit-count byte
else:
  decode a match length from the table at copied-depacker offset 0166h
  decode high distance bits from the table at copied-depacker offset 0176h
  read one low distance byte
  copy from the already-expanded output window
```

The literal obfuscation is small but easy to miss:

```asm
lodsb
xor al,dl
stosb
```

`DL` is the remaining-bit counter after the dispatch bit has been consumed.
The counter is reset to `10h` whenever the 16-bit bit buffer is refilled, so it
is not a fixed XOR key.

The end marker is the extended length token with extra byte `ffh`. The trailer
then contains relocation records and the final stack/entry words. A scratch
translation of the depacker produced:

```text
Packed stream offset: 0x240
Packed bytes consumed: 0x3b71
Expanded load image: 0x62f0 bytes
Expanded SHA-256: 337164abcd1a37a9e4ae09d04bf66082dc1190a8b58c7ba81cc164e91830ee34
Relocations: 263
Final entry: 0010:1902
Final stack: 1169:4000
```

The expanded image contains Borland/Turbo Pascal runtime strings and Pascal
short strings, so the intro appears to be a Pascal program with direct
assembler helpers rather than a pure hand-written assembly binary.

## Startup And Audio

The final entry at `0x1902` initializes the Pascal runtime, prints the setup
prompts, reads a sound-device choice, and optionally reads a sample-rate
choice. The selected sample rate is taken from a small word table and stored at
`ds:0xc37e`.

The audio code is a timer-driven MOD player path. The setup around `0x2d2c`
uses DOS interrupt `21h` functions `3508h` and `2508h` to save and install the
IRQ0 handler, programs the PIT through ports `43h` and `40h`, and touches port
`61h` for speaker output. The cleanup path around `0x2dda` restores the
original timer vector and resets the speaker/PIT state.

The module itself is a ProTracker `M.K.` file:

```text
Title:       Trancedance
Song length: 23 positions
Restart:     0
Signature:   M.K.
```

## PCX Loader

The PCX display helper starts at `0x1cc7`. It takes a Pascal short-string
filename, opens it through the Pascal file runtime, and prepares a 256-byte
buffered reader at `0x1bb9`.

The image decoder at `0x1c06` skips to stream offset `0x12c`, which is after
the 128-byte PCX header plus the 172-byte VGA palette area used by older PCX
variants. It then expands normal PCX RLE directly to segment `A000h`:

```asm
call read_byte
if (byte & c0h) == c0h:
  count = byte & 3fh
  value = read_byte()
  repeat value to A000:cursor
else:
  write byte to A000:cursor
```

The loop runs until the screen cursor passes `0xfa00`, the 320x200 mode-13h
screen size. After the bitmap pass, `0x1c8f` reads 768 palette bytes and shifts
each byte right by two before writing it to the caller's palette buffer. That
converts PCX 0..255 RGB components to VGA DAC 0..63 components.

The early intro path uses this helper for `PRIVTRO.001` and `PRIVTRO.002`.
The first picture is shown after mode setup; the second picture becomes the
background for the later sphere/scroller section.

## Palette Ramps

The routines at `0x0c65` and `0x0cd3` implement palette ramping. They operate
on 384 16-bit accumulators at `0x2d28`, add or subtract the 384 step bytes at
`0x2a28`, convert the high accumulator bytes into a 768-byte DAC buffer at
`0x2728`, wait for vertical retrace through port `3dah`, then write the full
palette through ports `3c8h/3c9h`.

That gives smoother fades than incrementing only byte-sized DAC values. The
high byte of each accumulator is what reaches the DAC, while the low byte
preserves fractional fade state across frames.

## Sine Scroller Resources

The main resource routine starts at `0x1219`. It opens `PRIVTRO.003`, reads
`0x55f0` bytes into `ds:3330h`, opens `PRIVTRO.004`, reads `0x300` bytes into
`ds:8920h`, copies that palette data into the working palette area, and closes
the files.

After loading those resources, it precomputes address and motion tables using
the Pascal math runtime. The frame loop then waits for vertical retrace at
`3dah`, erases the previous columns, advances a horizontal phase, shifts a
nine-character pipeline, and redraws the visible glyphs.

Two small routines carry the visible text work:

- `0x119e` clears a 22x20 projected cell by writing zeroes through a
  precomputed screen-offset table.
- `0x1123` draws one glyph from `PRIVTRO.003`.

The draw routine is compact and data-driven:

```asm
si = 3330h + glyph_index * 01b8h
for 20 rows:
  for 22 columns:
    al = [si++]
    if al != 0:
      screen_offset = offset_table[column + phase]
      A000:screen_offset = al
```

The `0x1b8` stride exactly matches the `22 * 20` byte glyph size. The
horizontal phase is kept in `ds:c0b6h`; it is decremented each frame and wraps
at `0x140`, matching the 320-pixel screen width. That is why the renderer
does not blit a flat linear font. It uses a table of projected screen offsets,
then samples sparse 22x20 glyph masks into those offsets.

## Structural Notes

`Privtro` is small, but it is not just a picture viewer. The package combines:

- A custom MZ/LZ executable wrapper.
- A Borland Pascal runtime core.
- Direct mode-13h screen writes and full-DAC palette fades.
- Standard PCX images for the static visual parts.
- A raw 50-glyph font/mask file for the sine scroller.
- A MOD playback path with timer-hooked output routines.

The result is a typical deadline intro design: a high-level Pascal shell for
file and setup work, with small direct VGA/audio routines where frame timing
and byte movement matter.
