Click to start
CLICK TO START
Inside the executable ↓

The demo was a Python script all along

demoplayer.xbe is a 2.9 MB general-purpose demo engine. It holds no Harry Boterham content at all. It boots an embedded Python 2.2.1 interpreter, runs d:\demos\demo\pompom.py, and gives that script a library of about 90 C++ effect classes to wire together. The reconstruction above follows the same split: the data files supplied the demo, and this page describes the engine.

Built
23 Jul 2005
Xbox SDK
XDK 5849
Scripting
Python 2.2.1
SWIG wrappers
≈1,350

Where the 2.9 MB goes

Each block is one section of the file, sized by its bytes on disk. Orange is the engine's own code, cyan is Microsoft XDK libraries linked in as separate sections, grey is data, and white is dashboard metadata.

SectionContentsOn diskSize
.textEngine code + Python 2.2.1 + libjpeg/libpng/zlib/LZMA1,497 KB
DSOUNDDirectSound (XDK)152 KB
D3DDirect3D 8 for the NV2A GPU (XDK)127 KB
D3DXD3DX helpers (XDK)139 KB
XGRPHXGraphics: swizzling, shader assembly (XDK)141 KB
WMADECWMA decoder: plays the soundtrack109 KB
XMVXMV video player (XDK)161 KB
XPPUSB peripherals: keyboard (XDK)33 KB
.rdataConstants, strings, Python docstrings182 KB
.dataGlobals (411 KB in memory, 173 KB on disk)169 KB
DOLBYDolby Digital encoder microcode28 KB
$$XTINFOTitle name text0 KB
$$XTIMAGEDashboard tile image, 128×12866 KB
.XTLIDTitle ID tables4 KB

The header

Title nameHarry Boterham
Title ID0x00000000, unregistered, as expected for homebrew
SigningDebug key. The entry point (0x00056F7F) and kernel thunk only decode with the dev-kit XOR keys, so it ran on development consoles, not retail ones.
Regions0x80000007: North America, Japan, rest of world, plus the manufacturing flag
Linked23 Jul 2005 00:22 UTC, then imaged into an XBE 3 minutes later
Build pathd:\newcode2\trunk\demoplayer\scripts\Release\demoplayer.exe, a Release build from a version-controlled trunk
Memory3.0 MB image, 64 KB stack, 1 MB heap reserve
KALEIDO logo: a pixelated red K on a grey background
The dashboard tile from the $$XTIMAGE section. It is a swizzled 128×128 X8R8G8B8 texture inside an XPR0 resource, unswizzled here. It shows a KALEIDO logo, not Harry.

How the engine runs a demo

  1. BootThe XBE starts with a loading screen (loading.jpg) and sets up DirectSound and the scheduler (log string: “Setting up scheduler”).
  2. PythonPython 2.2.1 loads its modules from the disc's lib\ folder and runs d:\demos\demo\pompom.py. Debug paths in its object files (.\ceval.c, .\Modules\arraymodule.c) show the interpreter was compiled in.
  3. BindingsThe script imports demoscript, a SWIG-generated module. SWIG “directors” (disown_XMVPlayer and similar) let Python subclass C++ classes and override callback(), which is how layers.py makes the logo flash.
  4. GraphEffects are EffectNodes joined with connectOutput(). Values are animated with damped Sliders, and music cues come from an Event stream.
  5. ScheduleScheduler.schedule(start, end, node, …) puts the final node on the timeline, and each frame it renders the graph through Direct3D 8 using Cg-compiled vertex shaders.

The scripting API

These are the classes exported to Python, taken from SWIG constructor names (new_*). The ones Harry Boterham uses are highlighted. Shader files on disk, such as shaders\fxlib\ripple.xvu, match these class names one-to-one.

3D scenes

Scene SceneProxy SceneEffect llScene llCamera llUserCamera llLight llVertex Rotation Scaling Translation MeshTuple ObjectTuple ObjectDict TextureManager TextureLayer TextureState

Vector and type

PSRenderer PSLayer PSPoint PScontour Path PathPoint PathSet SubPath Typo Font Glyph Bitmap Image ImageSeq ImageTuple

Compositing and filters

Add Subtract Multiply Over Overlay Blender Max XFade RGBMix RGBMap MGGamma MGOverflow Overflow Mosaic Blur RadialBlur MotionBlur Displace Distort Ripple Ripple2 Noise VintageNoise Split Splitter

Generators

Particles PhiParticles IsoParticles Boid Flocking Blob MarchingSquares MSSweep SweepEdge NUGrid TumCyls CylinderSegment HypnoTunnel

Time, sound and control

Scheduler Job Event FileEventGenerator Slider FixedSlider XMVPlayer, plus functions playSong playModule getTime getEvent getLevel getLeftLevel getRightLevel getModuleOrder getModuleRow

What else is linked in

Microsoft XDK 1.0.5849XAPILIB, XBOXKRNL, D3D8, D3DX8, XGRAPHC, DSOUND, XMV, XKBD, LIBCMT, LIBCPMT
Python 2.2.1With cPickle, cStringIO and the array module
ImagesIJG libjpeg 6, libpng, zlib 1.1.4, and an LZMA decoder for .lzma scenes
MusicStreaming WMA (this demo), plus a tracker-module player: the “Extended Module” signature means FastTracker 2 .xm support
VideoXMV playback (shaders\fxlib\countdown.xmv is on the disc)
Audio-reactivegetLevel, getLeftLevel and getRightLevel expose live audio levels to scripts

Odds and ends

  • The engine's C++ namespace is pompom (RTTI .?AVException@pompom@@), the same name as the demo script and the shaders\pompom\ folder.
  • Event objects carry MIDI-style fields (note, channel, velocity, wheel) and a recorded flag, and the USB keyboard library XKBD is linked. Together with the empty recorded_events file, this suggests cues could be tapped in live and saved. That last part is an inference, not confirmed.
  • It references z:\banaan.pck (banana) on the Xbox cache partition, and a d:\demos\demo\particle.png that isn't on the disc.
  • The files are dated 30 Dec 2003, but the XBE's own timestamps say July 2005. The Cg 1.3 compiler that built the scene's shaders is dated January 2005, and the models come from 3ds Max 7, so July 2005 is the real date.

Disassembled: how the overlay reaches the screen

The overlay is the logo, phone text and digits. Its placement was the one thing the data files couldn't explain, so I traced it through the x86 code and the GPU microcode. Five steps lead from a line in h_logo.tris to a pixel:

  1. SWIG settersPSLayer_x_set and its siblings store with movss [eax+N], which gives the object layout: vtable, x +4, y +8, z +0C, rotation +10, r g b +14–1C, scale +20, pivot xyz +24–2C. The constructor at 0x98d30 sets position and pivot to 0 and colour and scale to 1.
  2. .tris parser 0x929b0Each coord x y is converted once at load time:
    X = x × 0.0033333 − 1, Y = y × 0.004 − 2. The constants sit at 0x272f30 and 0x272f34. A 600 × 500 page becomes a 2 × 2 box whose top edge sits on the screen's centre line.
  3. PSRenderer::render 0x77090This is vtable slot 4. It draws the input scene, then calls PSLayer::draw for each layer in the order they were added.
  4. PSLayer::draw 0x98a50It first calls the Python callback(), then builds the matrix from seven D3DX calls:
    Scale(1.2,1) · T(−pivot) · Rz(rotation) · T(pivot) · T(x,y) · Scale(s,s) · Scale(1/1.2,1)
    The 1.2 pair keeps rotations round on a 4:3 screen. Scale is applied after the translation, so it scales about the screen centre, not the layer.
  5. psrenderer.xvuDecoded from NV2A vertex-program microcode:
    dp4 oPos, v0, c80–c83 (the matrix, with no projection), then mul oD0, v3, c93 (vertex colour × the layer's r,g,b), then the standard Xbox viewport epilogue (mul/rcc/mad).

With pompom.py's x = −0.2, y = 0.4, the decoded transform reproduces the surviving screenshot to within one pixel. The digits' bounding box is 211–323 × 182–230 against the original's 211–324 × 182–230.

What this means for the reconstruction

Everything that makes this demo what it is (scene, animation, timing, beat sync, overlays) lives in the data files. The engine behaviour those files depend on (lighting shaders, keyframe time base, overlay transform) is now taken from the original code, not estimated. The approximations left are small: keyframes are interpolated linearly, scale-axis keys are ignored, and the post-demo end screen is a guess.

Method: header and certificate parsed per the XBE format, section and library tables read directly, and strings, RTTI and SWIG symbol names extracted. The overlay path was disassembled with Capstone (x86), and the vertex shader with a small NV2A microcode decoder.