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.
| Section | Contents | On disk | Size |
|---|---|---|---|
.text | Engine code + Python 2.2.1 + libjpeg/libpng/zlib/LZMA | 1,497 KB | |
DSOUND | DirectSound (XDK) | 152 KB | |
D3D | Direct3D 8 for the NV2A GPU (XDK) | 127 KB | |
D3DX | D3DX helpers (XDK) | 139 KB | |
XGRPH | XGraphics: swizzling, shader assembly (XDK) | 141 KB | |
WMADEC | WMA decoder: plays the soundtrack | 109 KB | |
XMV | XMV video player (XDK) | 161 KB | |
XPP | USB peripherals: keyboard (XDK) | 33 KB | |
.rdata | Constants, strings, Python docstrings | 182 KB | |
.data | Globals (411 KB in memory, 173 KB on disk) | 169 KB | |
DOLBY | Dolby Digital encoder microcode | 28 KB | |
$$XTINFO | Title name text | 0 KB | |
$$XTIMAGE | Dashboard tile image, 128×128 | 66 KB | |
.XTLID | Title ID tables | 4 KB |
The header
| Title name | Harry Boterham |
|---|---|
| Title ID | 0x00000000, unregistered, as expected for homebrew |
| Signing | Debug 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. |
| Regions | 0x80000007: North America, Japan, rest of world, plus the manufacturing flag |
| Linked | 23 Jul 2005 00:22 UTC, then imaged into an XBE 3 minutes later |
| Build path | d:\newcode2\trunk\demoplayer\scripts\Release\demoplayer.exe, a Release build from a version-controlled trunk |
| Memory | 3.0 MB image, 64 KB stack, 1 MB heap reserve |
$$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
- BootThe XBE starts with a loading screen (
loading.jpg) and sets up DirectSound and the scheduler (log string: “Setting up scheduler”). - PythonPython 2.2.1 loads its modules from the disc's
lib\folder and runsd:\demos\demo\pompom.py. Debug paths in its object files (.\ceval.c,.\Modules\arraymodule.c) show the interpreter was compiled in. - BindingsThe script imports
demoscript, a SWIG-generated module. SWIG “directors” (disown_XMVPlayerand similar) let Python subclass C++ classes and overridecallback(), which is howlayers.pymakes the logo flash. - GraphEffects are
EffectNodes joined withconnectOutput(). Values are animated with dampedSliders, and music cues come from anEventstream. - Schedule
Scheduler.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.5849 | XAPILIB, XBOXKRNL, D3D8, D3DX8, XGRAPHC, DSOUND, XMV, XKBD, LIBCMT, LIBCPMT |
|---|---|
| Python 2.2.1 | With cPickle, cStringIO and the array module |
| Images | IJG libjpeg 6, libpng, zlib 1.1.4, and an LZMA decoder for .lzma scenes |
| Music | Streaming WMA (this demo), plus a tracker-module player: the “Extended Module” signature means FastTracker 2 .xm support |
| Video | XMV playback (shaders\fxlib\countdown.xmv is on the disc) |
| Audio-reactive | getLevel, 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 theshaders\pompom\folder. Eventobjects carry MIDI-style fields (note, channel, velocity, wheel) and arecordedflag, and the USB keyboard library XKBD is linked. Together with the emptyrecorded_eventsfile, 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 ad:\demos\demo\particle.pngthat 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:
- SWIG setters
PSLayer_x_setand its siblings store withmovss [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 at0x98d30sets position and pivot to 0 and colour and scale to 1. - .tris parser
0x929b0Eachcoord x yis converted once at load time:X = x × 0.0033333 − 1,Y = y × 0.004 − 2. The constants sit at0x272f30and0x272f34. A 600 × 500 page becomes a 2 × 2 box whose top edge sits on the screen's centre line. - PSRenderer::render
0x77090This is vtable slot 4. It draws the input scene, then callsPSLayer::drawfor each layer in the order they were added. - PSLayer::draw
0x98a50It first calls the Pythoncallback(), 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. - psrenderer.xvuDecoded from NV2A vertex-program microcode:
dp4 oPos, v0, c80–c83(the matrix, with no projection), thenmul 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.