Click to start
CLICK TO START
Inside the XBE ↓

One executable, fourteen scenes and a joypad

Polar Bear Alert is Kaleido's party version from the summer of 2004 (the release.nfo ends with “can i go home now?”). It runs on the same “pompom” engine as Harry Boterham, Bi-Won and miChera: default.xbe embeds Python 2.2, runs d:\demos\demo\pompom.py, and the script wires C++ effect classes into a graph that a scheduler draws at 50 Hz.

As in miChera, the timing comes from recorded_events, a joypad performance played in against the music and replayed by the engine. This time it is much busier: 6,338 records, 129 presses of a single button named taptap, and ten different event names that switch cameras, grow ribbons, deform meshes and kick blurs. Below the player you can read the executable, scrub the schedule, and open up any frame to see the effect graph that made it.

Linked
23 Jul 2004
Xbox SDK
XDK 5849
Show length
2:40
Recorded events
6,338

The show, end to end

  1. Loadingdefault.xbe (title “Kaleido Demoplayer”) shows data\demoplayer\loading.jpg while Python starts and the scenes decompress. About 2.9 s on the capture.
  2. pompom.pyThe scheduler runs 156.5 seconds of jobs: the logo, the box shaft, the bear signs, the sweep, the exploding shards, the ship, the glass spheres, the city and the kaleidoscope, then the logo again.
  3. end.pngOnce no job is left the player shows end.png, “the end, made with pompom”, until music.wma runs out half a second later.

Where the bytes go

default.xbe is 2,797,568 bytes, linked on 23 July 2004 at 23:55 UTC, the day the release files are dated. Half of it is Microsoft's: the XDK libraries each get a section of their own. Hover or tab through the map to see what each part is. The strip under it zooms into .text and marks the functions this reconstruction was read from.

Hover a section or a tick.
SectionOn diskLoaded atWhat it is
.text1,440,1240x11000the engine, effect classes, SWIG wrappers, Python 2.2, the C runtime
.rdata171,5200x24cc40constants, strings, vtables, the SWIG method table
.data167,9280x276a60initialised data (405,924 bytes in memory)
DSOUND D3D D3DX XGRPH573,160XDK sound and graphics
WMADEC XMV XPP DOLBY339,184XDK codecs; WMA plays music.wma, XMV is linked but unused
$$XTIMAGE67,5840x2e0da0the dashboard tile, shown on the start screen above

Libraries: XAPILIB, DSOUND, XBOXKRNL, LIBCPMT, LIBCMT, D3D8, D3DX8, XGRAPHC, XKBD and XMV, all 1.0.5849. The debug path is d:\newcode2\trunk\demoplayer\scripts\Release\demoplayer.exe, the same tree miChera's demoplayer was built from five weeks later. script/demoscript.py is the SWIG proxy: 1,165 wrapped functions over 77 classes, from Add and Blur to HypnoTunnel, Flocking and XMVPlayer.

The effects the script uses

Every effect is a node with its own 640×480 render target. A node renders its inputs first and caches its output for the frame, so a node shared by two consumers is drawn once. Each class below was read from its render function and reimplemented in js/fxrender.js.

ClassRenderWhat it does
Scene0x6c3e0Clears, copies its in input if one is connected, then draws a 3ds Max export with its own vertex programs. Other inputs become textures named input_a.png.
Blender0x659b0A luma-keyed crossfade: the blend image's brightness against the scheduler's mix decides, per pixel, whether a or b shows.
Blur0x660d0Downsamples to 320×240 and 160×120 with a spread-sized kernel and mixes back, additively for refBlur.
Over0x6edb0a over b, masked by a's alpha times map's, with a solid fill tinting a.
Multiply0x705f0a × b. Its constructor names it “Mulitply”.
MotionBlur0x72980A target that is never cleared: each frame it becomes 90% of itself plus 10% of the input.
Distort0x89210Shifts each scanline sideways by a random amount. At an amount of 0.1 or below it is a plain copy.
Ripple20x837f0Warps a 40×40 grid around four moving points. The amplitude, waves and scroll fields exist but the shader ignores them.
VintageNoise0x73f60Copies its input and adds a random dust sprite (30% of frames) and one vertical scratch.
MSSweep0x78b70Marching squares over a moving field, then the contour lathed around a scene object into a star-shaped solid, subtracted from the picture.
IsoParticles0x85c404,000 fixed point sprites whose size is the field value of three moving metaballs. No surface is ever built.
Bitmap, Image, ImageSeq0x70da0A Bitmap draws nothing and hands out its texture. ImageSeq copies its input and draws its images; until the first next() it outputs nothing.

Every slider is a FixedSlider, updated by 0x645b0: the value eases towards a target, and the target eases back towards a fixed point, both with per-frame damping. Blur, Over and Multiply update their sliders on every render call, before the frame cache is checked. A node that is rendered twice in a frame therefore moves twice as fast, and the ship's small flicker from 64 s comes from exactly that.

No sync track: a recorded joypad

recorded_events (181,452 bytes) holds 6,338 serialised pompom::Event records, in the same format as miChera's: f32 time, i32 channel, i32 state (0 down, 2 analog, 1 up), f32 value, f32 1.0, i32 button and a length-prefixed name. Only one addMapping line is live in the script (button A as logo). The other names were stored while recording with other mappings, and the script listens for them anyway.

ButtonNamePressesWhenWhat the script does
Alogo111.5–154.9 sshows the next logo image, distorts and unblurs it
Ataptap1299.6–79.5 sgrows a box-shaft ribbon and blacks the boxes; kicks the bear signs
Areset11411.0–137.9 srestarts scene clocks; cycles the box-shaft camera
Abass3035.3–92.1 snext tunnel camera; deforms and blackens the glass sphere
Asweep1435.9–45.3 sreshapes the sweep and flashes it; next sweep camera
Asnare3938.1–79.5 sblur kick on the shards; jolts the ship's clock
Adeform1797.0–112.2 snoise on four city objects
Bnext798.5–111.6 scuts the city camera
Akaleido24114.7–144.3 ssprings the kaleidoscope's curves to random lengths
Breset22131.4, 144.7 srestarts the kaleidoscope's clock
2, 4, 5, 6–82,309 records, mostly analog; nothing reads them

The script also listens for butB, butA_ and reset, which never occur. So the shards never flash black, the sweep never shrinks to its thin form, and the 3dkaleido clock never restarts.

The score

pompom.py ends with a list of jobs: a node, a slot, a start and a duration. The scheduler (0x5a0e0) draws the first active job of each slot. SI_MIX crossfades SI_A and SI_B and only does so while both have a job, which is why some transition jobs (outlined) never show. SI_POST and SI_SUPER are plugged into whatever comes before them. Under the slots are the recorded presses. The white line follows the player; click anywhere to jump the player there and open that frame in the inspector below.

t = –

Inside one frame

This runs a second copy of the simulation and renderer, so the player above is left alone. It steps to the chosen frame and then shows every node that frame draws, starting at the screen and walking back through the inputs. Each card is that node's own render target, with its slot, its live slider values and what is plugged into it.

–

A scene with effects attached lists them under its inputs (effect ← MSSweep); they draw into the scene's own target. Stepping backwards restarts the simulation from 0, because sliders and motion blur carry state from frame to frame.

The fourteen scenes, up close

The .lzma files are LZMA-packed 3ds Max exports: meshes, keyframed cameras and lights, splines, and vertex programs per material. Here they are drawn with the demo's own shaders and draw order but with a camera you control. Drag to orbit, scroll or pinch to zoom, double-click to reframe, or pick one of the scene's cameras. Ribbons draws every spline at full length; untick it to see the scene as the engine loads it.

Drag to orbit · scroll to zoom
0.00 s

Effects attached to a scene (the sweep, the iso particles) and input textures are left out of the viewer; an input_a.png stage shows white.

What is on the disc

demos/demo holds 47 files, 9 MB. Besides pompom.py itself, 28 of them reach the screen or the speakers. The rest are drafts, leftovers and scenes from a longer cut.

Blue gradient backdrop
backdrop1.png behind the tunnel
Dark backdrop
backdrop3.png behind the shards
Tiled pattern
tiling2.png, rippled behind the ship
Noise map
noisemap.tga, Over's mask on the shards
Polar bear alert logo
polarbear.png, the logo
Kaleido logo
kaleido.png, the end logo
Dust sprite
dust1–4.tga, VintageNoise's dust
Film exposure frame
film1.png, loaded, never drawn
StatusFiles
Drawn14 scenes (see above), backdrop1/3, tiling2, noisemap.tga, polarbear, kaleido, dust1–4.tga, line.tga, particle.png, music.wma, recorded_events
Loaded, never scheduledflock.lzma with a Flocking effect over backdrop2.png, bot2.lzma, lafglow.lzma (behind a glowAdder), film1.png as an additive exposure, a Gamma
Only in commented-out codetest.lzma, transsphere.lzma, nog_een_kaleidoscope.lzma (“yet another kaleidoscope”), countdown.xmv
Never referencedbendsplines.pck.lzma, curvegrow.lzma, moremotion.ase.pck.lzma, particles.lzma, tunnel2.lzma, tiling1.png, facemap.png, facemap2.png, noise.png
Missinggreebleball_2.lzma, named only inside a string block the author labelled “#Lelijke kak” (ugly crap)

Checked against a capture of the original

The capture (720×576 PAL MPEG-2, 2:47) runs from the loading screen to past the end. Each pair below is the capture on the left and this reconstruction on the right at the same demo time.

Ten pairs of frames, capture left and reconstruction right: logo, box shaft, bear signs, sweep, shards, ship, glass, city, kaleidoscope, end logo
Demo time 5, 18, 30, 40, 55, 72, 88, 104, 125 and 150 s, read across. Two pairs differ visibly: at 55 s the shards are white on the capture and dark here, and at 125 s the kaleidoscope is brighter here, with its random curve lengths. Demo time 0 sits 2.86 s into the capture's video stream. That offset was measured from camera cuts on recorded presses: reset1 at 11.0 s, next between 98.5 and 103 s, reset2 at 131.4 and 144.7 s. All of them line up at the same offset, so the demo clock runs at 1:1 with the capture.
Loadingloading.jpg is on screen for the first 3.24 s of the stream. The demo's first frames are black, so the loading picture appears to linger over them.
FlickerThe ship's white fill varies by about ±10 levels from frame to frame on the capture. The reconstruction gets the same only when Over's slider is updated on every render call, and Over is rendered twice per frame there.
GlassGeoSphere01's second texture stage is a reflection lookup bound to an empty !DUMMY! slot. Treating it as white turned the sphere into a white blob; the capture shows only its teal tiling2 diffuse, so here an empty stage adds nothing.
RandomnessRibbon lengths, sign sizes, sweep shapes and dust come from frand and the CRT rand(). Their seeds can't be recovered, so those details differ while the timing matches.

Odds and ends

  • A mesh kaleidoscope. 2dkaleido.lzma is a flat disc whose texture coordinates fold one wedge into twelve mirrored segments. The kaleidoscope is geometry; the curves scene is only its texture.
  • “HACK THIS WAS NEEDED FOR POLAR BEAR ALERT”. lib/util.py gives SimpleScene a transforms list just so the road's 20 signs can jump in size on taptap.
  • Point sprites as a mask. The iso particles are never seen directly. They are the mask of transBlend, so the 23–26 s transition dissolves through moving blobs.
  • Subtractive sweep. setBlendMode(1) on the MSSweep makes it reverse-subtract, so a bright star cuts a dark hole through the tunnel.
  • Untouched objects. CustomFlocking, a flock scene, a second bot scene and an exposure sequence are set up near the top of the script and never scheduled. They look like a section that was cut for the party.
  • Seeded randomness. frand is replaced by an MSVC-style LCG with a fixed seed, so the reconstruction is the same on every run and can seek.

Method

Static analysis only. default.xbe was parsed with tools/xbeinfo.py and disassembled with Capstone. Behaviour was read from the code: the scheduler, FixedSlider, Scene render, and the render functions of every effect the script uses. The Python side is a port of pompom.py and lib/util.py (js/sim.js, js/fx.js). The scene format and its NV2A vertex programs were decoded from the files (js/scene.js, js/sceneshader.js). Timing comes from frame-by-frame comparison with the capture.

Keys: space pause, ←/→ 5 s, R restart, L 640×480. URL options: ?skip starts at the demo, ?t= freezes at a demo time, ?show= at a show time, ?seed= changes the random seed.