Analysis model: gpt-5.5 xhigh Revision model: GPT-6 Astra (user-reported) Last edited: 2026-09-17

Machines of Madness by Dubius - Technical Dissection

Machines of Madness is Dubius' first-place MS-DOS demo from Assembly 1996. It is remembered as a sequence of dark, texture-heavy 3D worlds: moving light, reflections, a glass bowl, a walking machine, distorted organic pictures and a final industrial scene. The code is more interesting than that summary.

The released program is a protected-mode controller wrapped in PMODE/W. It opens an encoded 4.1 MB container, finds twelve separately compressed executables, expands and runs them one at a time, and leaves the XM player in the outer process as their common clock. Ten of those children carry a full software 3D engine; the first also stages the opening and credit pictures. Two more are specialised 320×200 indexed-image distorters. There is no hardware 3D API and no stored video behind the result.

Release year: 1996

The opening machine moving through Dubius' first 3D world

Sources Checked

Demozoo dates the release to 18 August 1996 and records first place in the Assembly 1996 PC demo competition. The Assembly Archive independently gives it first place. Tonic's own page calls it the winning Assembly 1996 demo and credits Tremor, Nitro, Tonic and the 3D modellers.

Authored Credits

The fixed release note gives the most complete contemporary division of work:

Contributor Authored role
Tremor Vector engine, music player, all code, 3D modelling and keyframing
Nitro Music, 3D modelling and keyframing
Tonic Graphics
Lazur / Pulse Graphics
Sol Fonts, 3D modelling and keyframing
Tran and Daredevil PMODE/W protected-mode runtime

The package also thanks Void / Hysteria for information about 3D Studio files, mathematics and shadows. The analysis below assigns code only to Tremor because the authored NFO explicitly does so. It does not turn every model or texture into a guessed individual credit.

Original Package And The Later Fix

The original ZIP and executable hashes are:

1397f3174ac43c9bf7a61bc264e464b40d7edadaa03c5b66a3b6a5159a7b6954  machines.zip
e084288a2af4dcdb28b4ff36995d12321fe03ac1becc9c9e5ab82d3562766223  MACHINES.EXE
c739143f4de273951b48477b85439eb3b0be29aea94fae620624b09d19033052  MACHINES.DAT

The small later fix contains a replacement executable but no replacement data archive:

e15fc4e192fe3aebe7561f6d7aac7ddea20d564ff183545d27dd8be837ca4386  machifix.zip
6df07db544ddd122e070f68c05bc730b2c59a5fa389fc93a7e36aee510cef0c7  fixed MACHINES.EXE

That distinction matters. The visual programs, meshes and pictures discussed here come from the one original MACHINES.DAT. The fixed executable changes the controller/player side and expands the release instructions, including an explicit machines s sound-setup option. It does not replace the production's visual payload.

The fixed NFO asks for a 386 and 387 or better, recommends a P75, and lists 5,300 KB of XMS plus 300 KB of base memory. GUS and Sound Blaster are supported. Those are credible requirements for what the recovered code actually does: several children expand to about 370 KB, and the renderer allocates its scene, vertex, face, offscreen and texture stores dynamically.

PMODE/W Is Only The Outer Shell

The original MACHINES.EXE is 17,731 bytes. Its real-mode MZ/PMODE-W portion occupies 10,032 bytes and identifies PMODE/W 1.22. The PMW1 protected-mode payload expands to a 17,168-byte container with one 11,966-byte physical code object and 511 relocations. The fixed executable is 18,403 bytes and carries a larger 13,951-byte code object with 516 relocations.

The controller's physical entry jumps to its setup at 070Ch. Its embedded name table immediately reveals the architecture:

momad4_5.xm
machines.exe
momprt01.exe
momprt02.exe
...
momprt12.exe

After video and player setup, the loop at 090Ch calls the child loader twelve times, advancing the name pointer by 13 bytes after each return. The effects are therefore not twelve branches inside one monolithic executable. They are twelve independent MZ images stored inside the data archive.

The 21-Byte Archive Directory

MACHINES.DAT begins with 74 fixed-size directory records. Each record is exactly 21 bytes:

bytes 00..03  encoded payload offset
bytes 04..07  encoded stored length
bytes 08..20  encoded 13-byte lower-case member name

The lookup at controller 00C4h walks these records from the start for every request. Before comparing a name, it lower-cases and pads it to 13 bytes, then transforms its three dwords with add/XOR/rotate operations. On a match, the first two record dwords are undone with rotate-right, subtraction and XOR. The decoded offsets line up exactly: the first child's payload begins at 0612h, and its length lands on the second child's offset at 110B8h.

The member data has another layer. Routine 05E0h generates an XOR stream from two stored 32-bit floating-point constants. The initial x87 value depends on the directory-record number and requested dword position; each subsequent dword adds the smaller constant and XORs the stored bytes with the current single-precision representation. This is an archive obfuscator, not video compression or texture synthesis.

DubiouslyCompressedFile And Its LZW Decoder

Every momprtNN.exe member begins, after that XOR pass, with:

DubiouslyCompressedFile!

The following two dwords give expanded and packed sizes. Controller 0FF2h first reads only this 32-byte header, allocates the packed and expanded blocks, then reads and decodes the full member.

The decoder at 129Ch is a compact LZW-family implementation:

The twelve results validate the decoder against every authored size:

Child DAT offset Stored bytes Expanded MZ bytes Principal authored resource
momprt01 000612h 68,262 368,131 wrd38.3ds, mom2.gif, four credit PCXs
momprt02 0110B8h 68,471 369,891 bowl.3ds
momprt03 021C2Fh 68,450 369,891 kumm02.3ds
momprt04 032791h 5,703 12,104 tumult.gif distortion
momprt05 033DD8h 68,837 370,115 abc5.3ds
momprt06 044ABDh 68,742 370,083 mvp4_3.3ds
momprt07 055743h 68,624 370,019 huu2.3ds
momprt08 066353h 68,837 370,115 skrev02.3ds
momprt09 077038h 68,502 370,019 18.3ds
momprt10 087BCEh 5,169 13,336 second tumult.gif distortion
momprt11 088FFFh 69,734 371,299 tali.3ds, crf3f1.pcx greetings strip
momprt12 09A065h 68,817 370,147 sahaa03.3ds

These are real MZ files with a deliberately simple load shape: a 512-byte header, zero relocation entries, zero CS:IP and a flat image starting at address zero. The outer controller allocates a selector, copies the expanded image below its header, sets segment limits and jumps directly to offset zero. It passes a far return address, archive state and player/shared-state selectors in registers. That is why extracting a child and typing its name at DOS is not equivalent to running it through the production.

The Authored Visual Inventory

The archive names are not speculative labels. They occur in the corresponding child code and match the encoded directory entries. Directly descrambling the members produces valid PCX, GIF87a and Autodesk 3D Studio chunks.

Resource Directly parsed content
wrd38.3ds 28 meshes, 2,218 vertices, 4,090 faces
bowl.3ds 1 mesh, 382 vertices, 760 faces
kumm02.3ds 25 meshes, 469 vertices, 838 faces
abc5.3ds 19 meshes, 601 vertices, 880 faces
mvp4_3.3ds 3 meshes, 30 vertices, 48 faces
huu2.3ds 15 meshes, 176 vertices, 268 faces
skrev02.3ds 14 meshes, 508 vertices, 964 faces
18.3ds 19 meshes, 266 vertices, 456 faces
tali.3ds 24 meshes, 962 vertices, 1,808 faces
sahaa03.3ds 45 meshes, 428 vertices, 676 faces
mom2.gif one 640×480 indexed GIF image
tumult.gif one 320×256 indexed GIF image
cred1.pcx .. cred4.pcx four 320×200 indexed credit pictures
crf3f1.pcx 1000×32 indexed greetings strip
s_x_text.pcx 256×256 indexed texture

The glass bowl scene rendered from its single 760-face mesh

The two GIF files are single authored pictures, not GIF animations. Motion in the published runtime GIFs comes from the demo's live output. The distinction is important: tumult.gif is an input surface to a calculated distortion, and mom2.gif is an image staged by the opening child.

One Engine Repeated Across Ten Children

The large children share the same runtime and renderer, while their scene data, controller code and end addresses vary. After the common DPMI, keyboard and video setup, each jumps near 24F00h into its scene controller. Child 1, for example, allocates buffers, initializes loaders and raster backends, reads wrd38.3ds, installs the active display function, and enters a frame loop.

The object walk at child-1 252E8h is a useful map of that frame:

  1. Read one scene-object pointer from the active list.
  2. Skip objects disabled by the low flag bit.
  3. Build object and camera transforms with x87 matrices.
  4. Transform every 12-byte (x,y,z) vertex through 32310h.
  5. Transform normals and light vectors through a second matrix path.
  6. Calculate per-face or per-vertex light values.
  7. Dispatch each visible polygon through a material-specific preparation and rasterizer function.
  8. Run flag-controlled offscreen reflection/shadow passes.
  9. Present the indexed frame and clear the next buffer.

The live scene-object records are 0E2h bytes apart. Polygon records are variable length: a vertex count byte is followed by index and attribute data. The controller advances to the next record with vertex_count * 8 + 11h, which is why triangles, quads and larger clipped polygons share one list.

FPU Geometry, Integer Pixels

The renderer draws a sharp line between geometry and spans. Object, camera, normal and plane calculations use the 387 stack. Vertex transforms load three floats, multiply through the active matrix, and store transformed coordinates to three separate arrays.

Several stores appear in the static file as offsets 11111111h. They are not broken addresses. Initialisation patches those displacement fields with the current x, y and z array bases. The same self-modification appears in the pixel kernels, where screen, texture, shade and lookup-table bases are written directly into unrolled instructions. The frame loop therefore avoids repeated pointer loads at the price of requiring writable code.

Once a polygon reaches a filler such as 48A0Ah, the code:

The simple shaded filler at 48C58h contains 32 repeated pairs of:

mov byte [edi + patched_framebuffer_base], bh
add ebx, eax

It handles the remainder by entering partway through that unrolled block, then runs whole 32-pixel groups. More complex fillers use 16-pixel blocks and carry fixed-point texture coordinates, light indices and destination values in register bytes. The expensive divides stay at polygon edges and scanline setup; the inner pixels are adds, byte extraction, table reads and stores.

A Material Dispatcher, Not One Texture Mapper

At 259F9h, the sorted polygon list supplies a material index. A table lookup at 25A1Eh selects one of many preparation paths. Those paths pack different per-vertex records into a scratch area at 438B8h before calling specialist fillers:

The affine texture path beginning at 4BC70h is especially direct. It patches the texture pointer into seventeen copies of the pixel instruction, patches the active lookup/output addresses, computes u/v slopes at each edge with the FPU, and converts the horizontal deltas to integer accumulators. In its inner block, the high bytes of the two accumulators form a 256×256 texture address; the code samples the indexed texel, optionally passes it through another table, writes one byte and adds the two coordinate steps.

This is why the production can use several surface styles in one scene without a hardware renderer. It is a family of generated/self-patched software spans, not one general C loop with a switch inside every pixel.

Moving light, textured walls and reflective surfaces in an interior scene

The Six-View Reflection Pass

The reflective-world code at child-1 26AEBh is unusually legible. When an object carries the relevant flag, it saves the active renderer state, changes the target to 64×64, and loops exactly six times. Each pass:

After six renders, the code restores the original frame state and copies non-zero pixels into the reflective material's 65,536-byte map. The six directions and six 64×64 targets are a software cube environment map. The round bowl and other glossy surfaces are therefore sampling a live rendering of their surroundings, not merely scrolling a painted chrome texture.

A second flag path at 2711Ch builds another offscreen target from a face plane, transforms the rest of the scene through a derived matrix, and renders into the material-owned buffer. The code and the credited shadow work establish a real secondary planar render pass; the precise artistic use depends on the active scene and material, so it is safer to describe the mechanism than label every dark patch as one algorithm.

The 64,000-Pixel Distortion Children

Children 4 and 10 are much smaller because they omit the full 3D engine. Both load the same 320×256 tumult.gif, set indexed VGA modes directly and build coordinate tables around a 320×200 output.

Child 4's main inner loop starts at 1B75h with ECX=FA00h: exactly 64,000 destination pixels. Per pixel it reads one precomputed dword, uses its low byte to index a 256-entry sine-fold table, adds the moving row phase, masks to 17 bits, then replaces the low byte with the lookup result. The earlier pseudocode instead added that result while retaining the original low byte; that was not equivalent to the recovered instructions. The corrected loop is:

for 64,000 pixels:
    packed = coordinate_map[pixel]
    x      = sine_fold[packed.low_byte]
    row    = (packed + phase) & 0x1ff00
    output[pixel] = source[row | x]

The decisive instructions are in the original child image:

1B75: mov eax,[esi]             ; packed coordinate
1B77: add esi,4
1B7A: mov dl,al                 ; preserve original lookup index
1B7C: add eax,ebp               ; row phase
1B7E: inc edi
1B7F: and eax,1ffffh
1B84: mov al,[edx+1624h]        ; REPLACE bits 0..7, do not add
1B8A: dec ecx
1B8B: mov al,[ebx+eax]          ; sample 128 KiB working texture
1B8E: mov [edi],al
1B90: jnz 1B75h

EDX is cleared before the loop, so DL indexes only 256 entries. EBP comes from (rounded_phase & 511) << 8, giving a 512-row, 256-byte-pitch address domain in the 0x20000-byte working allocation—not the stored GIF's 320-byte row layout. For example, packed 1234h, phase zero, and lookup result 56h select source offset 1256h; the old pseudocode selected 128Ah. It could even construct offsets above 1FFFFh, unlike the actual low-byte replacement. This is an error in the reconstruction, not an out-of-bounds access observed in the demo.

The loop reads 256,000 coordinate-map bytes, 64,000 lookup bytes and 64,000 source bytes, then writes 64,000 consecutive VGA bytes. EDI starts one byte before the target and is incremented before each store; the first write is at A0000h, not A0001h. The final two moves preserve DEC ECX's flags for the loop branch.

The surrounding controller updates the phase from the shared XM tick counter, rebuilds the 256-entry sine-fold table on every traversal of the frame loop, and streams the authored palette through ports 3C8h/3C9h. At 1AEFh..1B30h, each table entry starts from the x87-rounded integer i + amplitude*sin(angle), takes its absolute magnitude, divides by 256, and reflects the remainder when the quotient is odd. Thus the final fold is r or 255-r, not a simple modulo-256 wrap. The angle advances by 2*pi / [1618h] for each entry. Child 10 uses the same 64,000-pixel shape with two independently animated lookup tables. The liquid face/bump interludes are thus table-driven indexed resamplers; they are not embedded movie frames.

The 2026-09-17 bounded verification used original MOMPRT04.EXE, SHA-256 b9b4a531b88183a82ac73c663ca0b046a8c2341f3a4ea8cf1149375e726a0c64. The flat bytes are exactly that executable with its 512-byte MZ header removed. Four row-phase cases executed the original loop with synthetic coordinate, lookup and texture data. All 256,000 writes matched in address, size, value and order, along with complete output images and final pointer/count state. The former pseudocode disagreed on more than 63,700 of 64,000 synthetic pixels in each case. That comparison demonstrates non-equivalence, not an error rate measured on the authored imagery. No replacement runtime capture was made.

The authored Tumult picture passing through the live 64,000-pixel resampler

The XM Is A Shared Process Clock

The outer controller keeps momad4_5.xm open inside MACHINES.DAT, initializes the player once, and passes its shared state to each child. The children read the current order at shared offset 19DAh and row at 19E9h. Examples in the recovered code include waits for 18h:32h, 1Ah:2Dh, 32h:00h, 35h:39h and 3Ah:32h.

When that shared pointer is absent, the same code falls back to a monotonically updated dword, which is useful for development but not how the release is normally sequenced. This architecture explains both clean transitions and the cost of slow hardware: every visual child has its own authored checkpoints, while the music/player remains continuous outside it.

Direct Runtime Check

The verified run paired the fixed executable with the original data archive under DOSBox-X 2026.01.02. It used an emulated GUS because the player supplies the production's timing state. On the host, SDL_AUDIODRIVER=dummy discarded all samples. No audio was played, recorded or published.

The DOSBox window was captured externally at five frames per second into FFV1 lossless video with -an. This avoided DOSBox-X's H.264 capture path and created no audio stream. Published motion excerpts are GIFs made from that video-only source. The run confirms the authored sequence, mode changes, palette output and calculated movement; the code and recovered assets establish how those pictures are produced.

Stone geometry and animated camera work in a later full-engine child

The  machine and the 1000-pixel greetings strip

What The Inner Loops Explain

The production's characteristic look follows directly from its constraints:

What looked extravagant in 1996 was carefully partitioned. The outer program is a loader and clock. The large children spend floating-point work on geometry and preparation, then reduce spans to patched integer kernels. Reflection is rendered at 64×64 in six directions. Distortion is one indexed resample per pixel. Machines of Madness earns its scale by arranging several narrow, purpose-built loops rather than asking one universal renderer to do everything.

Boundaries And Reproducibility