Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Doom demo (LMP)

From ReverseEngineering.wiki
Format
Developer id Software
Versions version-byte header from v1.4 on; older demos have a shorter header (unverified)
Magic none; byte 0 is the game version (109 for v1.9, 110 in the Linux source release)
Extensions .lmp; also DEMO1-DEMO4 lumps inside IWADs
Endianness little (single bytes only)
On this wiki Facts · Code · Notes · Topics

Recorded-input demo of Software:Doom and Doom II: a short header (game version, skill, episode, map, options, players present) followed by 4 bytes of input per player per tic and an end byte 0x80. Playback re-simulates the game, so a demo only plays correctly on an engine with identical game logic and random number sequence.

Structure

For version 1.4 and later (checked against the 1.10 source and Freedoom demos with version byte 109):

Offset Size Field
0x00 1 version (109 = 1.9, 110 = source release; the engine refuses other values)
0x01 1 skill (0 = I'm too young to die ... 4 = Nightmare)
0x02 1 episode (1 for Doom II)
0x03 1 map
0x04 1 deathmatch
0x05 1 -respawn
0x06 1 -fast
0x07 1 -nomonsters
0x08 1 console player (whose view is shown)
0x09 4 player present flags, one byte per player 1-4

Then, for every tic, one 4-byte record per present player in player order: forward move (signed), side move (signed), turn (signed high byte of the 16-bit angle delta), buttons. A byte 0x80 where the next record would start ends the demo. If player 2 is present, playback runs as a network game.

Pitfalls

  • Turning is stored with only 8 bits; when recording the engine rounds the angle delta and then replays the stored record so that recording and playback stay identical.
  • Data after the 0x80 end byte is ignored by the original engine; source ports use it for their own footers. Freedoom 0.13.0 freedoom2.wad lump DEMO3 has 197 such bytes.
  • A demo records no checksum and no RNG state: playback assumes the level starts with the random index at 0, which the engine guarantees by resetting it on every new game.
  • Unverified: demos from versions before 1.4 have no version byte and a 7-byte header (skill, episode, map, four player flags). Source ports detect them because byte 0 is then a skill value (0-4). Test by parsing a demo lump from a Doom 1.2 IWAD.

Evidence & references

  • linuxdoom-1.10/g_game.c: G_BeginRecording, G_DoPlayDemo, G_ReadDemoTiccmd, G_WriteDemoTiccmd, DEMOMARKER 0x80.
  • Runtime test: the eight DEMO lumps of the Freedoom 0.13.0 IWADs all start with 109 and walk cleanly in 4-byte steps per present player to the 0x80 byte.