Analysis model: gpt-5.5 xhigh

# Falling - CSG

## Subject

`Falling` is a 1992 MS-DOS VGA demo by CSG. The Hornet 1992 index lists it
as:

```text
falling.zip      260652 ***+  Falling by CSG
```

Release metadata:

- Release year: 1992
- Group: CSG
- Package examined: `falling.zip` from the Hornet 1992 mirror
- Main executable: `falling.exe`
- Sidecar executable: `demosite.com`, a TheDraw-style distro/site screen
- Display path observed: VGA-style 320x200 artwork scaled by DOSBox-X to a
  720x400 capture stream
- Audio setup exposed by the program: Sound Blaster yes/no prompt, with IRQ and
  I/O address choices on the sound path
- Music/data evidence: an `S.T.M.` marker survives in the packed executable,
  consistent with a Scream Tracker STM music payload
- Packer evidence: `LZ91` marker and a custom DOS MZ depacker stub

Sources:

- [Scene.org file page](https://files.scene.org/view/mirrors/hornet/demos/1992/falling.zip)
- [Scene.org archive download](https://files.scene.org/get/mirrors/hornet/demos/1992/falling.zip)
- [Hornet 1992 index](https://files.scene.org/view/mirrors/hornet/demos/1992/00_index.txt)
- [Pouet screenshot referenced by Scene.org](https://content.pouet.net/files/screenshots/00004/00004198.jpg)

The sidecar `demosite.com` and some text screens contain old distro/contact
information. Those details are deliberately omitted here. The public images use
only the non-contact runtime art and credits frames.

## Runtime Capture

![Falling runtime contact sheet](images/falling-runtime-contact.png)

The contact sheet above is from a local DOSBox-X capture:

```text
Emulator:        DOSBox-X 2026.01.02 SDL2
Capture date:    2026-06-19
Machine:         svga_s3
CPU core/cycles: normal, 20000 cycles
Sound:           disabled in emulator; startup prompt answered "n"
Command:         dx-capture /v FALLING.EXE
Capture stream:  MPEG-TS/H.264, 720x400, 35.648000 seconds
Timing zero:     beginning of captured stream, including the prompt
```

The first captured frame is the Sound Blaster prompt and is not published
because it includes the local DOS shell context. The published frames start
after the demo has entered graphics mode.

Representative observed timestamps:

The sequence GIF below is assembled directly from the eight published DOSBox-X
runtime frames. It makes the palette-phase behavior easier to see: the falling
figure and radial field remain fixed while the DAC colors sweep and the bottom
credit strip advances through the presentation/title/coding/graphics states.

![Falling runtime sequence GIF showing palette phase shifts and bottom credit text changes](images/falling-runtime-sequence.gif)

| Timestamp | Screen state |
| --- | --- |
| `00:02.000` | Full-screen falling-man illustration over a circular/radial rainbow field; bottom black strip has only edge labels. |
| `00:06.000` | Same pixel geometry with the color wheel phase shifted; bottom text shows the "proud to present" line. |
| `00:10.000` | The background palette has advanced again; the lower text strip starts the next title/intro line. |
| `00:14.000` | Title text `"FALLING"` appears in the bottom strip while the character art remains fixed. |
| `00:18.000` | Credit strip switches to the coding credit. |
| `00:22.000` | Credit strip advances to the coder name. |
| `00:26.000` | Credit strip switches to the graphics credit. |
| `00:30.000` | Final visible credit state and palette fade/phase shift before the scripted exit. |

The opening effect is intentionally simple but polished. The foreground figure
and background geometry stay locked between frames while the color bands sweep
through them. That strongly points to an indexed VGA picture plus DAC palette
animation/fading rather than a per-frame redrawn tunnel or ray effect. The
bottom strip is a separate text/credit layer: it changes while the main picture
does not move.

## Archive Contents

Examined archive:

```text
ef1979e2e7affad80a2d4f420d022e129e8e8ac80bc88ef700f046e21284dcff  falling.zip
```

Extracted files:

```text
ae4377ea5ad7ace3149992f111f8384a81a71b1d658cd2fe453291ab14b26d6f  demosite.com   1104 bytes
69ce604e075aa1ee6e55e64021088bb2c9d71563258d48b76c5374a5d14c5675  falling.exe  269372 bytes
```

`demosite.com` is a small DOS `.COM` screen. `falling.exe` is a DOS MZ
executable with a very small relocation table and a high-memory unpacker stub.

Important marker offsets inside `falling.exe`:

```text
file offset 0x0036  "LZ91"
file offset 0x03E9  "S.T.M."
```

The clear text visible in the packed stream includes `1992`, the STM marker,
and fragments of the setup/help prompts. The more complete prompt text appears
at runtime: the program asks whether to use Sound Blaster and, on the sound
path, offers IRQ and I/O address choices.

## MZ Header Shape

The executable header:

```text
file size             269372 bytes
MZ header size           160 bytes
load image size       269212 bytes
relocation entries         1
minimum extra alloc    16721 paragraphs
maximum extra alloc    65535 paragraphs
entry point          CS:IP = FFF0:0100
initial stack        SS:SP = 41C4:0200
relocation table     file offset 0x0052
overlay number       0
```

The entry point is the packer trick to notice. DOS loads an EXE image at
`PSP + 10h` paragraphs. With `CS = FFF0h` and `IP = 0100h`, the physical entry
wraps back to `PSP:0100`, exactly where the first byte of the loaded image
lands. So the code at file offset `0x00A0` is reached as `PSP:0100`.

The disassembly snippets below use file offsets from the executable. For the
initial entry stub, the corresponding PSP offset is `file_offset + 60h`.

## Entry Stub And High-Memory Copy

The first job is not yet the demo. It is the LZ91 loader moving a second-stage
depacker to a high memory area and then far-returning into it.

```asm
; file 00A0, runtime PSP:0100
00a0: mov ax,82fbh
00a3: mov dx,41bah
00a6: add ax,0000h
00a9: cmp [0002h],ax       ; PSP top-of-allocation segment
00ad: jae 00c9h            ; not enough memory path
00af: sub ax,0020h
00b2: cli
00b3: mov ss,ax
00b5: sti
00b6: sub ax,0025h
00b9: mov es,ax            ; target segment for copied unpacker
00bb: push ax
00bc: mov cx,0122h
00bf: xor di,di
00c1: push di
00c2: mov si,0144h
00c5: cld
00c6: rep movsw            ; copy 0x244 bytes to high memory
00c8: retf                 ; continue at copied ES:0000
```

The `cmp [0002h], ax` is a DOS PSP check. Word `PSP:0002` is the first segment
beyond the process allocation. If there is not enough room for the requested
high-memory destination, the stub prints a DOS `$`-terminated failure message
and exits through `INT 20h`.

Once copied, the second-stage code uses `DX`, `BP`, `BX`, `SI`, and `DI` as a
sliding decompression machine. The first large copy loop walks backwards by
paragraph blocks and normalizes the source and destination segments.

```asm
0100: shr cx,1
0102: dec si
0103: dec si
0104: mov di,si
0106: sub bp,ax
0108: sub bx,ax
010a: mov es,bp
010c: mov ds,bx
010e: rep movsw
0110: mov ax,1000h
0113: mov ch,80h
0115: dec dh
0117: jne 0106h
0119: cld
011a: mov ds,bp
```

This is not a normal application startup. It is repositioning the packed input
stream and the future output stream so that the decompressor can emit a large
restored executable without being trapped by a single 64 KiB offset window.

## LZ91 Bit Reservoir

The core bit reservoir is compact and very 8086-friendly:

```asm
0123: lodsw
0124: xchg ax,bp
0125: mov dx,0010h
...
015a: lodsw
015b: xchg ax,bp
015c: mov dl,10h
```

`BP` is the current 16-bit bit bucket. `DX`/`DL` is the remaining-bit counter.
Every consumed bit is:

```asm
shr bp,1                  ; next compressed bit goes to carry
dec dx                    ; one fewer bit in the bucket
je  refill                ; fetch another 16-bit word when empty
```

The use of `xchg ax,bp` after `lodsw` is a byte-saver: it loads the next two
compressed bytes from `DS:SI` while preserving the old `AX` value only as much
as the stub needs. The bit order is least-significant-bit first because `shr`
exports bit 0 into carry.

## Literal Loop

The literal path is the shortest possible hot loop: a zero bit means "copy the
next compressed byte literally."

```asm
015e: jb  0168h            ; carry set = match token
0160: movsb                ; carry clear = literal byte
0161: shr bp,1
0163: dec dx
0164: je  015ah            ; refill bit reservoir
0166: jae 0160h            ; keep copying literal bytes while bits are zero
```

This is the fast path the packer wants for incompressible or already dense
regions. Once the decoder sees a `1` bit, it falls into match decoding at
`0168h`.

Important detail: `movsb` reads from the compressed source stream and writes to
the restored executable stream. That means literals and match-control bits
share `DS:SI`; the bit bucket is ahead of the byte stream, so the compressor
has to arrange the stream in the exact interleaved format this stub expects.

## Match-Length Decode

The match path starts by building a small prefix code in `BX`. Each `rcl bx,1`
shifts the just-read carry bit into the low end of the prefix.

```asm
0168: xor cx,cx
016a: xor bx,bx
016c: shr bp,1
016e: dec dx
016f: je  012ah
0171: rcl bx,1
0173: shr bp,1
0175: dec dx
0176: je  0130h
0178: rcl bx,1
017a: cmp bl,02h
017d: jae 01a7h
...
01a2: mov bl,cs:[0206h+bx] ; short length table
01a7: xchg bx,cx           ; CX becomes match length
```

There are several early exits. Very short matches are resolved by the table at
`CS:0206h`; longer prefixes keep reading bits. The key point is that `CX` is
ready before the copy loop because `REP MOVSB` will consume it directly as the
copy count.

Extended length handling is done with a sentinel value:

```asm
0241: mov cl,cs:[0211h+bx]
0246: cmp cl,19h
0249: je  024eh            ; 25 means "read an extra length byte"
024b: jmp 01a9h
024e: lodsb
024f: add cl,al
0251: adc ch,00h
0254: cmp al,0feh
0256: jae 025bh            ; FE/FF are structural markers
```

If the extension byte is below `FEh`, it is just added to the length. `FEh`
triggers segment normalization; `FFh` becomes the end marker after that
normalization block checks it.

## Match-Distance Decode And Copy

After length, the decoder reads a distance prefix. Small distances use a table
for the high byte; all cases read a low byte with `LODSB`.

```asm
01a9: xor bx,bx
01ab: cmp cx,0002h
01ae: je  01dah
01b0: shr bp,1
01b2: dec dx
01b3: je  0148h
01b5: jb  01dah
...
01d5: mov bh,cs:[022ch+bx]
01da: lodsb
01db: mov bl,al
01dd: push si
01de: mov si,di
01e0: sub si,bx            ; source = current output - distance
01e2: cli
01e3: rep movsb es:[si],es:[di]
01e6: sti
01e7: pop si
01e8: jmp 0161h
```

The copy is an in-place LZ back-reference inside the output segment: `SI` is
temporarily changed from compressed-input pointer to output-history pointer,
the bytes are copied from `ES:SI` to `ES:DI`, and then the original compressed
stream pointer is restored with `pop si`.

The `cli`/`sti` pair around `rep movsb` is deliberate. While a match is being
expanded, `DS:SI` has been repurposed and `SI` no longer points at the input
stream. Masking interrupts avoids a resident handler or timer routine observing
the decompressor in this transient state.

## Segment Normalization

The restored program is larger than a comfortable single near pointer stream,
so the depacker periodically rolls the source and destination segments forward.
The marker path starts at `025Bh`:

```asm
025b: push ax
025c: lea bx,[di-2000h]
0260: and di,000fh
0263: add di,2000h
0267: mov cl,04h
0269: shr bx,cl
026b: mov ax,es
026d: add ax,bx
026f: mov es,ax
0271: mov ax,ds
0273: mov bx,si
0275: and si,000fh
0278: shr bx,cl
027a: add ax,bx
027c: mov ds,ax
027e: pop ax
027f: cmp al,0ffh
0281: je  02ach            ; FF = end of packed stream
0283: jmp 0161h            ; FE = normalized, continue decoding
```

This is classic real-mode housekeeping. It keeps `DI` in a controlled low
range, advances `ES` by the number of completed paragraphs, and performs the
same conversion for `DS:SI` on the compressed input side. The `+2000h` bias
keeps the output pointer away from the very bottom of the segment while the
history window still works.

The distinction between `FEh` and `FFh` is also important:

- `FEh` means "normalize segments and continue."
- `FFh` means "normalize, then finish and run the restored executable."

## Relocation Restore And Far Transfer

At the end of the compressed stream, the packer has not merely emitted bytes.
It also restores relocation fixups and the original stack/entry point.

```asm
02ac: pop bx
02ad: mov bp,bx
02af: add bx,0010h         ; convert PSP-like base to load-image base
02b2: xor ax,ax
02b4: lodsb
02b5: xchg ax,cx           ; relocation count group
02b6: jcxz 02c7h
02b8: lodsw
02b9: add ax,bx
02bb: mov es,ax            ; relocation target segment
02be: lodsw
02bf: xchg ax,di
02c0: add es:[di],bx       ; apply segment relocation
02c3: loop 02beh
02c5: jmp 02b2h
02c7: lodsw
02c8: add ax,bx
02ca: cli
02cb: mov ss,ax
02cd: lodsw
02ce: mov sp,ax
02d0: sti
02d1: lodsw
02d2: add bx,ax
02d4: push bx              ; restored CS
02d5: lodsw
02d6: push ax              ; restored IP
02d7: mov es,bp
02d9: mov ds,bp
02db: xor ax,ax
02dd: mov bx,ax
02df: mov cx,ax
02e1: mov dx,ax
02e3: mov bp,ax
02e5: mov si,ax
02e7: mov di,ax
02e9: retf
```

This block is why the packed file still looks like a valid MZ program to DOS.
The first visible EXE is only a carrier. LZ91 reconstructs a second executable
image in memory, applies segment relocations to that restored image, installs
the restored stack, zeroes the general registers, and finally transfers control
with `retf`.

## What The Visible Demo Part Does

The captured sequence is a single opening tableau with timed text changes:

1. Initialize video and ask the sound question in text mode.
2. Enter a VGA graphics mode.
3. Display a full-screen indexed picture: a drawn falling/reaching figure over
   a radial color field.
4. Animate the color field primarily by palette phase/fade changes. The pixel
   geometry of the figure and radial field is stable from frame to frame.
5. Update the bottom black strip with credit/title text while keeping the main
   picture fixed.
6. Fade/phase the palette near the end and return to text/DOS.

The important inner-loop implication is that the expensive work is almost
certainly front-loaded:

- The unpacker restores the whole executable/data image.
- The runtime part copies or decodes the picture once into VGA memory.
- The continuing "motion" can then be done by rewriting the DAC table instead
  of repainting 64,000 pixels every frame.
- The bottom strip is the part that needs regular pixel writes for text.

This matches the capture better than a geometric tunnel interpretation: the
rainbow bands move, but their luminance structure and the figure contours stay
anchored. In mode-13h style indexed VGA, that is exactly what palette animation
is good at.

## Runtime-To-Code Concordance

This is a bounded concordance because the trusted code recovery currently stops
at the MZ/LZ91 carrier and restored-entry transfer. The runtime media still
proves enough to connect the visible effect to the recovered loader and to
separate observed behavior from unresolved post-unpack routines:

- `images/falling-runtime-contact.png` and
  `images/falling-runtime-sequence.gif` come directly from the local DOSBox-X
  capture. They are runtime evidence, not public-video stills or generated
  reconstructions.
- The published frames start after the Sound Blaster prompt, so the media
  deliberately avoids local shell context and sidecar contact material. The
  prompt itself is still proven by runtime observation and by setup text
  fragments surviving in the packed executable.
- The stable falling-man/radial picture across `00:02.000..00:30.000` proves
  that the main 320x200 artwork is not being geometrically redrawn every frame.
  The plausible code model is one initial decode/copy to indexed VGA followed
  by palette/DAC animation.
- The color-wheel phase changes in the GIF prove a timed palette path. The
  exact DAC loop is not yet named because the restored post-`retf` image has not
  been dumped, but mode-13h indexed-color behavior explains the observed
  whole-picture color motion without changing the figure geometry.
- The bottom strip changes independently from the main illustration, so it is a
  separate text/credit layer or masked blit region rather than part of the same
  static bitmap. The runtime frames show title and credit states while the
  figure remains fixed.
- The MZ header and wrapped `FFF0:0100` entry prove that all visible runtime
  code is reached through the carrier, not directly from the DOS MZ entry.
- The high-memory copy at file `00A0h`, the 16-bit bit reservoir, literal path,
  LZ match-length/distance decode, segment normalization, relocation restore,
  and final `retf` prove how the large hidden runtime image is reconstructed
  before the graphics code runs.
- The `S.T.M.` marker in the packed executable plus the runtime sound-device
  prompt support the presence of a Scream Tracker-style music/sound path, even
  though this capture used disabled sound and therefore does not prove audible
  playback.

Evidence boundary: the GIF and frames prove the palette/text behavior; the
disassembly proves the LZ91 carrier and transfer into the restored program.
The actual VGA DAC writer, text-strip blitter, retrace wait, and sound replay
routine still need a post-depacker memory dump before they can be named at
instruction level.

## Reconstruction Limits

For this pass, the byte-for-byte recovered code is the MZ/LZ91 carrier and
depacker. The restored post-`retf` renderer was not preserved as a separate
unpacked file in the repository during this analysis, so the exact VGA DAC and
text-strip routines are described from runtime observation plus surviving
packed strings rather than from named recovered functions.

The practical next step for a deeper second pass would be to break immediately
after the depacker's `retf`, dump the restored memory image, and disassemble
the actual VGA/audio runtime. That would let the palette-write loop, text
blitter, and any retrace wait be named at instruction level instead of inferred
from the capture.
