Analysis model: gpt-5.5 xhigh

# Into the Dark by Halcyon - Technical Dissection

`Into the Dark` is Halcyon's first-place MS-DOS demo from Demolition 1996.
Blitz's program is a 32-bit protected-mode show whose seven large scene blocks
own different renderers rather than passing every part through one generic
engine. Croaker's S3M is both soundtrack and timeline: the renderers read the
player's current order and row directly. The result moves from procedural
noise and texture tunnels through a cube field, photographic image processing,
faceted objects and a deliberately unstable-looking light explosion.

Release year: 1996

![The radial-light object late in Into the Dark](images/into-the-dark-halcyon-preview.png?v=deep-20260816)

## Evidence Boundary

- [Demozoo production record, credits and Demolition result](https://demozoo.org/productions/29517/)
- [Pouet production record and preservation links](https://www.pouet.net/prod.php?which=114)
- [Canonical Scene.org release archive](https://files.scene.org/get/demos/groups/halcyon/intodark.zip)
- DOSBox debugger recovery of the complete unpacked program image
- Static 32-bit x86 disassembly of that recovered image
- Independent decoding of the embedded S3M and all nine RIX3 records
- Silent examination of the video-only DOSBox preservation capture linked by
  Pouet

Demozoo dates the production to 23 April 1996 and credits Blitz for code,
Croaker for music, and Ember, Placidity and Shrine for graphics. It records
first place at Demolition 1996. The executable also identifies the music
player as Asmu/Wildlight's code.

The published GIFs are continuous excerpts from the video-only preservation
capture. They establish appearance and sequence, not implementation. No audio
was downloaded, played, retained or published. Addresses below are offsets in
the recovered flat program image; effect names are used only where runtime and
code agree.

## Exact Release And Recovered Image

The release has only four files:

```text
INTODARK.EXE     30015  packed executable
DATAA.DAT      1155296  rotated S3M, RIX3 images and scene data
INFO               413  release note
FILE_ID.DIZ         212  archive description
```

Their useful identities are:

```text
c1775b9a49f7db8097ceca9e4e64b7e699dc52113f387506f61f3bfbc0fd9030  intodark.zip
c594be8914e790538e843b359bbca52a5fd2cdf80730916dc4130387566566ed    30015  INTODARK.EXE
3a05436bbe73a35e29d6fbee4c5d21693fdafc9c5fa38b92346ee2594770b031  1155296  DATAA.DAT
0047c479a2898a9732080e185d28b681ec00071566a48afee7c0927acafe0e7b   128129  recovered image
```

The executable is WWPACK-compressed. The available shareware unpacker disables
its unpack command, so the image was recovered at the actual decompressor exit
instead of guessed from strings. At launch the packed entry is `01ED:0000`.
The stub relocates itself to `2136:003C`, expands forward from load segment
`01ED`, and returns far to the restored entry at relative `CS=1F41h`, `IP=000Eh`.

The decompressor's central grammar is visible in its tiny instruction set:

```asm
; BP/BH carry the bit reservoir
; literal branch
movsb                       ; copy one source byte to output

; match branches decode variable-length distance and length values
mov  esi,edi
sub  esi,decoded_distance
rep  movsb                  ; overlapping back-reference is intentional

; terminal marker
pop  ds
pop  ds
pop  es
retf                        ; restored CS:IP was already on the stack
```

At that `retf`, output ends at `ES:DI = 140E:D271`. Relative to load segment
`01ED`, the inclusive recovered range is `1F481h` bytes, exactly 128,129.
This establishes the image boundary independently of the packer's header.

## Startup Builds A 2.5 MiB 64 KiB-Banked Arena

The main routine begins at `1EE03h`. It asks the allocator for `290000h` bytes
and rounds the result upward to a 64 KiB boundary:

```asm
1EE65  mov  eax,290000h
1EE6A  call allocator
1EE6F  or   eax,0FFFFh
1EE74  inc  eax
1EE75  mov  [1C7C5h],eax       ; arena base
```

Every scene derives its pages by adding whole-bank offsets to this base. A
typical initializer is therefore pointer arithmetic rather than repeated
allocation:

```c
arena = align_up(allocate(0x290000), 0x10000);
page0 = arena + 0x00000;
page1 = arena + 0x10000;
page2 = arena + 0x20000;
/* ... */
radial_field = arena + 0x1f0000;
```

The universal frame operation is exactly one mode-13h page. Routine `1C784h`
copies and then clears 16,000 dwords:

```asm
mov  esi,[backbuffer]
mov  edi,0A0000h
sub  edi,[flat_base]
mov  ecx,3E80h             ; 16000 dwords = 64000 bytes
rep  movsd

mov  edi,[backbuffer]
xor  eax,eax
mov  ecx,3E80h
rep  stosd
```

That repeated `3E80h` constant is the reliable boundary between full pages
and the larger 256 KiB procedural fields used by individual scenes.

## `DATAA.DAT` Starts Rotated, Then Becomes An Ordinary S3M

The first `82386h` bytes look corrupt on disk because every byte is rotated.
The loader undoes it in place:

```asm
mov  edi,[module_buffer]
mov  ecx,[module_length]
.decode:
mov  al,[edi]
ror  al,7                  ; equivalent to 8-bit rotate-left by one
mov  [edi],al
inc  edi
dec  ecx
jnz  .decode
```

After that one-bit rotation the first bytes read `in to the dark`, and the
`SCRM` marker is at the standard offset. Its header is:

```text
orders       34
instruments  27
patterns     31
flags        0040h
tracker      1300h
file format  0002h
global vol   64
speed        6
tempo        153
master vol   48
ultraclick   16
pan flag     FCh
```

The complete order list is short enough to show:

```c
uint8_t order[34] = {
     4,  5,  7,  2,  7,  2,  3,  8,  9,  1,  9, 17,
    10, 11, 10, 19, 12, 13, 23, 14, 24, 25, 26, 27,
    28, 29, 30, 18, 20, 22, 22, 22, 255, 255
};
```

Words at `19DFh` and `19EAh` expose the current order position and row. They
are the demo clock. There is no independent authored millisecond timeline.

## The Top-Level Show Is Seven Explicit Calls

The dispatcher after the opening text is almost unusually readable:

```c
while (music_order() <= 2)
    opening_text_and_palette();

scene_6a44();
scene_a127();
scene_db6b();
scene_f7b1();

do {
    scene_125cc();
    if (music_order() < 0x14 ||
       (music_order() == 0x14 && music_row() < 0x21))
        scene_1c5c3();
} while (music_order() <= 0x14);

scene_17d93();
scene_1a5f0();
```

Each block also polls keyboard port `60h`; Escape sets the shared exit flag at
`1BEB5h`. This is why the music can pace a normal run without taking away an
immediate user exit.

## Scene `6A44h`: Four Noise Planes And A Tunnel Composite

The first large renderer allocates four 64 KiB noise planes. Its 256×256
coordinate map is generated by a deliberately skewed linear combination:

```c
for (int y = 0; y != 256; ++y)
    for (int x = 0; x != 256; ++x)
        map[y][x] = ((y * 0xf4) + (x * 0x0c)) >> 8;
```

It fills a complete 256 KiB field with a two-register generator. This is the
actual loop, translated one-for-one from `6A44h`:

```c
uint32_t a = seed_a;
uint32_t b = seed_b;
for (unsigned i = 0; i != 0x40000; ++i) {
    a += b;
    b += 0xb5f29bf5;
    a = ror32(a, 5);
    b = rol32(b, 9);
    noise[i] = a & 0x0b;
}
```

Four 320-pixel rows at a time are then weighted by a signed table. The machine
code keeps one quarter of the original sample and adds a variable fraction:

```asm
movzx eax,byte [edi]
mov   esi,eax
imul  ebx                  ; signed row factor
sar   eax,4
sar   esi,2
add   eax,esi
mov   [edi],al
```

Perspective limits use `(constant << 8) / z + screen_center`; the runtime
updates sine phases masked with `3FFh`. The final compositor processes packed
pixels and adds two sources to the current page:

```asm
mov eax,[edi]
add eax,[esi]
add eax,[ebp]
mov [edi],eax
```

![The striped tunnel and ribbon part](images/into-the-dark-halcyon-tunnel-1hz.gif?v=deep-20260816)

The continuous excerpt around 41 seconds agrees with the skew map, phase-driven
perspective bounds and additive four-plane composition. The exact assignment
of every stripe to one of the four banks remains an inference; the allocation,
generator and packed add loop are proved by disassembly.

## Scene `A127h`: Cube Instances With A Four-Pixel History Filter

The next block converts a 320×200 source page in place by shifting every pixel
two bits left, duplicates its palette four times, and creates repeated object
records from one coordinate set. Its setup makes ten translated copies of 96
coordinate words, adding `20h` to the translation for each copy.

```c
for (int instance = 0; instance != 10; ++instance) {
    memcpy(instance_xyz[instance], model_xyz, 96 * sizeof(int16_t));
    for (int vertex = 0; vertex != 32; ++vertex)
        instance_xyz[instance][vertex].translation += instance * 0x20;
}
```

Rotation indices are masked to `3FFh` and fetch signed words from the common
sine/cosine tables. The distinctive trail is not a palette trick. `A65Dh`
filters all 64,000 pixels, four at once:

```asm
mov eax,[history]
lea eax,[eax+eax*2]        ; history * 3
add eax,[current]
shr eax,2                  ; (3*history + current) / 4
and eax,3F3F3F3Fh          ; contain each packed 8-bit lane
mov [history],eax
add eax,[overlay]
mov [display],eax
```

```c
for (unsigned q = 0; q != 16000; ++q) {
    uint32_t h = ((history[q] * 3) + current[q]) >> 2;
    h &= 0x3f3f3f3f;
    history[q] = h;
    display[q] = h + overlay[q];
}
```

![Floating cube-field motion](images/into-the-dark-halcyon-cubes-1hz.gif?v=deep-20260816)

That packed recurrence explains why the blocks leave soft persistence without
requiring a second full geometric pass.

## Scene `DB6Bh`: Rotated Objects Over A Half-Average Composite

`DB6Bh` copies another 320×200 resource, multiplies its indices by four, then
builds translated signed-coordinate records from embedded word arrays. Three
angle values are obtained from sine tables and reduced to ten bits:

```asm
movsx eax,word [phase*2+sine]
sar   eax,4
and   eax,3FFh
mov   [angle],eax
```

Its page merge is more controlled than the first scene. For each packed dword
it averages the existing and new object pages, adds a third layer, then masks
all four lanes to six bits:

```asm
mov eax,[edi]
add eax,[esi]
sar eax,1
add eax,[ebp]
and eax,3F3F3F3Fh
mov [edi],eax
```

The alternate branch splits the screen into 100 rows of 80 dwords, but applies
the same recurrence. That proves the visible collage is a layered object/page
composite rather than an already composited animation stored in `DATAA.DAT`.

## Scene `F7B1h`: A Self-Patched Two-Sample Texture Kernel

The fourth renderer reserves six 128 KiB regions and two 64 KiB regions. It
constructs a symmetric 256×256 displacement field using perspective division:

```c
for (int z = 64; z != -64; --z) {
    for (int x = -128; x != 128; ++x) {
        int d = z + 66;
        uint8_t u = (x * 150) / d + 128;
        uint8_t v = (z * 150) / d + 128;
        forward[p]  = (v << 8) | u;
        reverse[q]  = (v << 8) | (255 - u);
    }
}
```

The hot loop at `FBD0h` is self-modifying. Before entry, the setup replaces the
recognizable `12345678h` placeholders with texture bases, colour table bases,
horizontal increments and row corrections. Its useful semantics are:

```c
for (int y = 0; y != 200; ++y) {
    for (int x = 0; x != 320; x += 2) {
        uint16_t uv0 = displacement[(v >> 8) << 8 | (u >> 8)];
        uint8_t  p0  = tex0[uv0] + light0[uv0];
        u += du;
        v += dv;

        uint16_t uv1 = displacement[(v >> 8) << 8 | (u >> 8)];
        uint8_t  p1  = tex1[uv1] + light1[uv1];
        dst[x] = p0;
        dst[x + 1] = p1;
        u += du;
        v += dv;
    }
    u -= row_u_correction;
    v -= row_v_correction;
}
```

The real instruction sequence shows why two pixels are produced per loop:

```asm
mov bh,ah
mov bl,ch
mov dl,[ebx+patched_map0]
mov bx,[ebx*2+patched_table0]
add ecx,ebp
add dl,[ebx+patched_tex0]
add eax,patched_du

mov bh,ah
mov bl,ch
mov dh,[ebx+patched_map1]
mov bx,[ebx*2+patched_table1]
add ecx,ebp
add dh,[ebx+patched_tex1]
mov [edi+esi],dx
```

The scene stays active through music order `0Fh`, row `3Ch`. That hard order/row
gate is the reason its text and distortion phases remain synchronized even on
machines with different rendering speed.

## Nine RIX3 Records Are Textures, Sprites And Photographs

The executable contains both the total data length `11A0E0h` and RIX-bank start
`82386h`. Each RIX record is exactly:

```c
struct Rix3 {
    char     magic[4];       // "RIX3"
    uint16_t width;
    uint16_t height;
    uint16_t flags;          // 00AFh in every record
    uint8_t  palette[768];   // VGA 6-bit RGB
    uint8_t  pixels[width * height];
};
```

The decoded records are:

```text
82386h   256 x 256  blue/purple procedural texture
92690h   320 x 200  dark font/image atlas
A239Ah   320 x 200  portrait
B20A4h   512 x 64   eight radial glow sprites
BA3AEh   256 x 256  pale texture
CA6B8h   256 x 256  blue texture
EA3C2h   256 x 256  soft cloud/displacement map
FA6CCh   320 x 200  monochrome child photograph
10A3D6h  320 x 200  monochrome conflict photograph
```

![All nine locally decoded RIX3 resources](images/into-the-dark-halcyon-rix-resource-bank.png?v=deep-20260816)

`125CCh` cycles eight resource descriptors. At every row divisible by 32 it
advances the descriptor index, wraps at eight, and starts a `400h`-step fade:

```c
if ((music_row() % 32) == 0 && fade == 0) {
    resource = (resource + 1) & 7;
    fade = 0x400;
}
```

Its 320×200 merge expands two indexed source bytes across a packed dword and
adds two independently displaced noise/light pages:

```c
uint8_t a = image[x + 0];
uint8_t b = image[x + 1];
uint32_t pair = a | (a << 8) | (b << 16) | (b << 24);

dst[x / 4]       = pair + noise0[x / 4] + light0[x / 4];
dst[(x / 4)+320] = pair + noise1[x / 4] + light1[x / 4];
```

This accounts for the photographic sequence and for the way flat images break
into noisy moving fields. The separate `1C5C3h` transition scales a 320-wide
texture rectangle with ten fractional bits:

```c
du = ((src_right - src_left) << 10) / (right - left);
dv = ((src_bottom - src_top) << 10) / (bottom - top);

for (int y = top; y < bottom; ++y) {
    uint32_t u = u0;
    for (int x = left; x < right; ++x) {
        *dst++ = texture[(v >> 10) * 320 + (u >> 10)];
        u += du;
    }
    v += dv;
}
```

The left, right, top and bottom limits are perspective divisions around
`(160,100)`, so the image does not merely cross-fade: it moves as a projected
rectangle.

## `17D93h`: Q10 Geometry Meets The Generated Radial-Light Field

Before any scene begins, the main routine generates a 640×400 signed radial
field at arena offset `1F0000h`:

```c
for (int y = 399; y >= 0; --y) {
    for (int x = 639; x >= 0; --x) {
        int dx = x - 320;
        int dy = y - 200;
        int r = isqrt(dx * dx + dy * dy);
        radial[y][x] = (uint8_t)(168 - (r >> 1));
    }
}
```

`17D93h` is the consumer that combines the late geometry, light sprites,
texture pages and this oversized field. Its rotation helper `17723h` reads
three ten-bit sine/cosine pairs and constructs a Q10 matrix. Representative
terms are exactly:

```c
m00 = (cy * cx) >> 10;
m01 = (cy * sx) >> 10;
m02 = sy;
m10 = ((sz * sy * cx) >> 20) + ((cz * -sx) >> 10);
m11 = ((sz * sy * sx) >> 20) + ((cz *  cx) >> 10);
m12 = (sz * -cy) >> 10;
```

Vertices are signed words. Each component is multiplied by matrix terms,
shifted right ten, translated, and stored as an intermediate triple. The face
builder then rejects the wrong signed area and writes visible face records.
The packed face record stores a depth/sort key in its high word and a six-byte
face reference in its low word:

```c
if (signed_screen_area(face) < 0) {
    visible[n++] = (depth_key << 16) | face_offset;
}
```

The radial lookup is sampled by a self-patched screen kernel. At `187F8h`, a
word from a 640-wide work field supplies two coordinates; one byte indexes a
generated 256-entry light table, and the resulting intensity selects the
source texture:

```asm
mov  bx,[esi]
mov  edx,patched_radial_base
add  dl,bh
add  bl,[edx+light_table]
mov  dl,[ebp+ebx]
mov  dh,dl
mov  [edi],dx
```

![The faceted blue ball and its changing light](images/into-the-dark-halcyon-ball-1hz.gif?v=deep-20260816)

![The late radial light burst](images/into-the-dark-halcyon-lightburst-1hz.gif?v=deep-20260816)

The ball around 133 seconds and the bursts beginning around 143 seconds occur
inside this late scene family. The program evidence proves the Q10 object
pipeline, radial-field generation, self-patched sampler and glow-sprite
resource. Associating the exact visible burst with their combination is a
runtime-to-code inference, not a recovered source label.

## The Timer Owns Music Updates And Palette Interpolation

Routine `1C8C0h` hooks the timer and programs PIT channel zero with count
`4100h` (16,640), approximately 71.7 interrupts per second. `1C917h` calibrates
that path against VGA retrace at port `3DAh`.

The callback at `1C810h` increments the shared frame count, updates Asmu's
player through `3B64h`, and performs a complete 768-byte palette interpolation:

```c
for (unsigned i = 0; i != 768; ++i) {
    int from = palette_from[i];
    int to   = palette_to[i];
    outb(0x3c9, from + (((to - from) * blend) >> 10));
}
blend = max(0, blend - 0x80);
```

The same Q10 interpolation appears in scene-local transitions. Palette motion
therefore continues at the timer rate even when a large object frame takes
longer to render.

## `1A5F0h`: A Five-Tap Feedback Ending

The final renderer uses the 256×256 soft map, duplicates two 64 KiB fields and
creates a 256×256 word coordinate table by perspective division. Its main
feedback loop processes four pixels in parallel:

```asm
mov eax,[esi-140h]          ; north
add eax,[esi-4]             ; west
add eax,[esi+4]             ; east
add eax,[esi+140h]          ; south
sar eax,2
and eax,3F3F3F3Fh

mov ebx,[edi]               ; previous frame
lea ebx,[ebx+ebx*2]         ; previous * 3
add eax,ebx
sar eax,2
and eax,3F3F3F3Fh
add eax,[edx]               ; injected source/text layer
mov [output],eax
```

In reconstructed form:

```c
neighbours = (north + west + east + south) >> 2;
neighbours &= 0x3f3f3f3f;
feedback = ((previous * 3) + neighbours) >> 2;
feedback &= 0x3f3f3f3f;
output = feedback + injected_layer;
```

Sine values scaled by `2C6h` and shifted by 12 produce the source displacement.
The addressing terms multiply one component by 320 and combine it with the
other, so the field is a rotated/resampled feedback surface rather than random
snow.

![The closing feedback and textile-like field](images/into-the-dark-halcyon-ending-1hz.gif?v=deep-20260816)

The scene exits after music order `1Fh`, clears all 64,000 VGA bytes, restores
the timer and returns to text mode.

## What The Code Actually Says About Halcyon

The common visual thread is light, but the code does not implement one universal
lighting engine. It builds several specialized approximations:

```text
6A44h   four generated noise planes + additive packed-page composite
A127h   instanced geometry + 3:1 temporal history filter
DB6Bh   rotated object pages + half-average/add/mask composite
F7B1h   self-patched paired-pixel displacement/texture sampler
125CCh  order-row image cycling + displaced packed-pixel merge
17D93h  Q10 mesh pipeline + radial lookup + patched light sampler
1A5F0h  four-neighbour diffusion + 3:1 feedback + injected layer
```

That specialization is why `Into the Dark` remains interesting to dissect.
Several visible parts resemble each other, but their inner loops are materially
different. The unity comes from six-bit packed colour arithmetic, 64 KiB arena
banks, ten-bit phase tables, self-patched constants, and the S3M order/row clock
rather than from a single reusable effect abstraction.
