56 KB, ten scenes and one borrowed replayer
“Spiral staircase” is Kaleido's 64k intro for Woest 2002, where it came second. Conqui and mnemonix wrote the code and mnemonix the music; the exe was linked on 1 March 2002 at 12:41 UTC, during the party. Everything above was rebuilt from that exe: the music comes from the embedded XM through a port of the replayer, every texture from the exe's 13 texture scripts, and every mesh, camera and sync point from the disassembly. A video capture was used only to check the result.
Below the player you can follow the sync script against the music, read the unpacked image, take any frame apart into its draw calls next to the capture, step through the texture scripts, and switch two of the intro's own bugs on and off.
- Packed exe
- 56,368 B
- Unpacked image
- 240 KB
- Song
- 76.8 s
- Sync points
- 66
The show, end to end
The frame function (0x40106f) asks MiniFMOD for the order being heard and takes scene = order / 2. Every scene is therefore two patterns, 7.68 s, and every cut is a hard cut on a pattern boundary. At order 20 it calls exit(0). Click a scene to jump there.
Before the first frame the exe builds its nine objects. After each one it clears the screen to a random dark cyan-ish colour, (0, rand()%127, rand()%127), and presents it: the nine-frame flicker at the start of the capture. Those 18 rand() calls are part of the stream the particle systems later draw from, so the reconstruction makes them too.
The score
All sync lives in one function, 0x40126e: a chain of if (order == O && row == R) tests with five setters. It is level-triggered, so a value is written again on every frame while its row plays (60 ms), and the decay starts after the row. The white line follows the player; click to jump.
Hover the score.
| Setter | Object field | Effect | Decay |
|---|---|---|---|
0x403277 flash | obj38+1c | additive full-screen quad, texture 120 layer 1, grey flash·255 | 30 per unit (13.6/s) |
0x403dfb punch | obj30+18 | ring projection fovX = π/(3−p), fovY = π/(4−p); at 2 the rings collapse sideways | 25 per unit |
0x4043e2 sel | obj34+4, +8 | picks the crystal shape and kicks the camera 10° around Y | kick: 10 per unit |
0x404ea6 shake | obj28+c | adds shake·sin(20t) to the staircase look-at target | buggy: one row long, see below |
0x4056f0 wobble | obj3c+4 | rotates the vase background by 5·w·cos(110·uptime) degrees | 1 per unit |
Time inside the parts is timeGetTime()/2200 since PlaySong, so one unit is 2.2 s and has nothing to do with the tempo. The song runs at speed 3, 125 BPM: a row is 0.06 s, a pattern 3.84 s. On the capture the picture is 0.214 s behind the start of the recording and stays there: all 35 cuts and flashes found by scene detection fall within one video frame of the predicted rows.
Unpacking an obsolete UPX
The exe is packed with UPX 0.71 (1999), which current UPX refuses: “packed with an obsolete version and cannot be unpacked”. Instead, tools/unupx.py maps the three sections into Unicorn, points the two imports the stub needs at fake functions, and runs the stub until it jumps into the unpacked code at 0x414524. LoadLibraryA and GetProcAddress return fake handles, so the stub's own import loop writes a recognisable value into every IAT slot, and the 91 imports fall out by name.
The texture generator and the replayer were checked the same way: their agents ran the exe's own functions under Unicorn, with the C runtime and GDI stubbed, and compared the JavaScript ports against them, layer by layer and sample by sample.
| DLL | Imports | Used for |
|---|---|---|
msvcr70.dll | 40 | maths, rand, new; the reason the zip carries the DLL (“don't start complaining…”) |
user32.dll | 20 | window, message loop, the loader's status bar |
gdi32.dll | 12 | drawing Arial text into a DIB for the two text textures |
kernel32.dll | 9 | resources (the texture scripts), the mixer thread |
winmm.dll | 8 | waveOut and timeGetTime |
d3d8.dll | 1 | Direct3DCreate8; the rest goes through COM vtables |
comctl32.dll | 1 | InitCommonControls for the status bar |
Where the bytes go
The unpacked image is 0x3c000 bytes. Code is 88 KB; the song is the biggest single thing in it. Hover or tab through the map: the upper bar is the whole image, the strip below zooms into .text with one tick per function found by the disassembler, coloured by subsystem.
The rich header says Visual C++ 7.0 (build 9466). The 64 functions at 0x4148e5–0x416406 are the C runtime's static initialiser table at 0x419004: each builds one global matrix or material. Strings the loader never shows: “dit is gelukt denk ik” (“I think this worked”), “gore kut zooi”, “balbab”, “FMOD IS KAPOT” (the message box when the song fails to load) and the window title “Scene test”.
A fixed-function engine with one draw call
Every mesh in the intro goes through one dynamic vertex and index buffer of 25,000 entries (FVF 0x152: position, normal, colour, one UV). DrawIndexedPrimitive at 0x407bb4 is the only draw in the program. There are no render targets, no shaders, no gamma ramps and no post-processing: every glow, ray and flash is additive geometry over a black clear.
A scene node carries seven state slots (fog, Z, cull, blend, lighting, material, and one that does nothing), and the device applies only what differs from the current state. Nodes use the world matrix Rz·Rx·Ry plus translation; cameras use T·Rx·Ry·Rz or a left-handed look-at, with a projection that takes two fields of view and no aspect ratio. The WebGL port keeps D3D's row vectors and 0..1 depth and has one shader for the fixed-function path: point lights with the vertex colour as material, linear range fog, texture × diffuse.
| Part | Built from | Address |
|---|---|---|
| Logo rays | 5 metaballs, marching squares on 64×64 cells, each segment extruded toward the camera | 0x40b7db |
| Rings | an open band of 40 triangles, 6 arms × 20 copies | 0x403cbc |
| Staircase | 160 steps of 9°, 0.8 down each; four pillars; the same metaball curtain, hung vertically | 0x40454a |
| Crystal | tetrahedron or octahedron, 4 Sierpinski steps (the middle triangle dropped), a spike on every face | 0x4065af |
| Vase | 4-lobed lathe, 32×30, pulsed and twisted every frame | 0x401e76 |
| Fountain | 3,600 sparks dropped by an emitter circling the vase | 0x402d63 |
| Tunnel | 11 additive 40×40 slices with the cloud texture | 0x40350c |
| Finale | 2,000 cyan sparks pulled into a circling attractor, released and faded on contact | 0x402730 |
Inside one frame
A second copy of the intro and renderer, so the player above is left alone. Pick a moment: left is the reconstruction, right the nearest still from the capture, and below every draw call that frame makes, in order. The jump buttons are the moments with capture stills.
–

Stepping backwards replays the intro from the start, because the particle systems carry state from frame to frame. The vase and the vase background depend on the PC's uptime, so they only match the capture with the fitted value below.
Thirteen texture scripts
The 13 RT_RCDATA resources, 5,792 bytes in all, are programs for a small texture generator (0x40dd53, op table at 0x420bc8). Each works on four 256×256 layers with 28-byte records: an op, a source and destination layer and six parameters. The loader returns one layer, picked by the caller. Pick a script and a step to see the four layers after it; the layer the intro uploads is outlined. The noise ops call srand with their own seed, so they are repeatable; the ports match the exe's own code bit for bit, except text.
Text (op 80) is drawn by GDI with Arial into a DIB and read back with GetPixel: “|KALEIDO|” at height 51, and “spiral”, “staircase”, “mnemonix”, “| conqui” for the end title. The browser draws it with its own Arial, so glyph edges differ. Resources 123 and 128 are never loaded: a glow with a wood swirl, and embossed cells.
The tool they came from: a speculative node editor
The exe only holds the compiled scripts: lists of ops that read and write four layers. The texture tool itself, probably node-based, is not in the exe, so this editor is a guess. To rebuild a graph, each op becomes a node, and its inputs are the nodes that last wrote the layers it reads. Copies (op 63) only move data between layers, so they disappear. Evaluating any of the 13 graphs gives the exe's layers byte for byte. The editor then compiles the graph back to 28-byte records over four layers, putting copies back where a value is still needed.
Compiling also shows how much of each script the intro never uses. For the layer it loads, the KALEIDO logo (129) needs 14 of its 24 records and the crystal clouds (127) need 7 of 18. The rest compute other layers that are thrown away.
Save and load
In this browser
As JSON
Drag a node by its title. Drag from the dot on its right to an input on another node to connect them; drag a wire off an input to disconnect it. With the graph focused, Delete removes the selected node. Ctrl/⌘ Z undoes and Ctrl/⌘ Shift Z redoes. Graphs saved in this browser stay on this device; the JSON box moves them anywhere. Blue wires are the main input, brown ones the second input of a two-input op. Text uses the browser's Arial, as in the texture section above.
The music: MiniFMOD, mirrored
The replayer is not home-made: it is Firelight's MiniFMOD, linked in, playing a 31,399-byte FastTracker 2 module from memory at 0x419114. It outputs 44.1 kHz, 16-bit stereo through one looping 2-second waveOut buffer, refilled in 20 ms blocks by a time-critical thread that polls waveOutGetPosition.
js/xmplayer.js ports it and renders the song before the intro starts, the way a 64k intro precalculates. Run against the exe's own mixer under an emulator, it matches sample for sample. What makes it sound unlike other XM players: linear interpolation on short 8-bit samples (the bright aliasing haze on the capture), 128-frame volume ramps on every note, and stereo mirrored relative to FastTracker 2.
The demo asks for the order and row that are audible: MiniFMOD records them per 20 ms block and returns the block being played, so sync follows what you hear, up to 20 ms early.
| Module | Value |
|---|---|
| Channels, patterns, instruments | 10, 17, 15 (6 with samples) |
| Tempo | speed 6 in the header, F03 on every pattern: speed 3, 125 BPM |
| Order list | 0 1 2 3 4 5 6 6 7 10 11 12 11 12 13 14 13 14 15 16 17 17 |
| Effects used | 0, 1, 2, 3, 8, A, F, R; no envelopes, no volume column |
| Peak | about 21,800 of 32,767: it never clips |
| Never heard | orders 20–21: pattern 17 does not exist, and the exe has exited by then |
Bugs you can switch on
The text file says “we didn't feel like bug fixing anything at the moment”. Most of what follows is reproduced as is; three of them depend on the machine, and you can change the machine here. These controls change the player above and the frame inspector.
- The logo that depends on leftover memory. The title logo gets its own blend object: ONE/ONE with
BLENDOP = 3,D3DBLENDOP_REVSUBTRACT, so the screen becomes rays minus logo. The init at0x4036e8sets the source, destination and op but never the enable byte at+4, so leftover heap memory decides whether the blend is used. On the authors' PC it was non-zero: the letters are cut out of the rays and out of a white metaball shape (node+8) that is drawn first. On the capture machine it was zero, so the logo is drawn opaque on top and the white shape is hidden. The player shows the intended version; untick the box to see the capture's. - No frame limiter, frame-dependent emission. The exe draws as fast as it can (present interval immediate) and its particle systems emit
trunc(rate·Δt)per frame. At 1000 fps that rounds to zero: the staircase sparks and the vase fountain never appear. Set 1000 fps and watch them go. - The vase runs on uptime. Scenes 4 and 5 pass
timeGetTime()/2200to the vase without subtracting the start time, so its pulse and twist depend on how long the PC had been on. Fitting the vase's outline on ten capture frames gives 37,936.6 units: about 23 hours 11 minutes. Solutions every 1,382 units (about 51 minutes) fit almost as well, so this is one of several. The unsigned fix-up there also adds 0.0078 where it means 2³². - The shake that lasts one row. The staircase decays its shake by
(t − t_first)·5, measured from its first frame instead of the previous one. By scene 6 that is about 70 per frame, so every shake is a single-row jolt. - Tunnel colour wraps. Slices closer than 1 get a negative grey level, and the packed
0x00RRGGBBwraps to nearly white. The nearest slice is behind the near plane and clipped. - Half the particles are NaN. The random direction sets
z = ±sqrt(1 − x² − y²)with x and y drawn independently, so about half the time it is the square root of a negative number. Those sparks never show; the port drops them to keep the density. - The ring rotation that never happens. The ring camera writes
RotZ(40t)after the view matrix is built, and the next frame resets it. - One Z buffer, two depth ranges. In scene 5 the tunnel (near 1, far 100) and the vase (near 0.1, far 400) share a Z buffer. It works because the tunnel writes no depth.
Deviations and sources
- The simulation runs at a fixed rate (60 Hz unless changed above) so that seeking is repeatable. The exe ran one step per displayed frame, and the capture machine managed about 30.
rand()is the exe's: MSVC's LCG, seeded 1, shared in the exe's order by the texture scripts, the loading flicker and the particles. Particle detail still differs from the capture, because the original's emission depended on its frame times.- Texture text uses the browser's Arial. Mipmaps are a 2×2 box filter in both; filtering is bilinear with nearest mip, as the exe sets it.
- The staircase sprites inherit lighting and fog from the curtain drawn before them; the port does the same.
- Keys: space pauses, ←/→ seek 5 s, L toggles native 640×480. URL:
?t=17freezes at 17 s,?fps=30,?uptime=…. - Analysis notes live in
work/notes/(engine, effects, texgen, audio). Tools:unupx.py,disasm.py,exemap.py,texgen.pyandtexgen_emu.py,xmrender.pyandxm_emu_reference.py,vasefit.py.