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

Software:Doom

From ReverseEngineering.wiki
Software
Developer id Software
Publisher id Software (shareware and registered), GT Interactive (The Ultimate Doom, Doom II)
Platforms MS-DOS (original, 32-bit protected mode); Linux (1997 source release); many later ports
Versions 1.0 to 1.9 (DOS, 1993-1995); 1.10 in the Linux source release
License Source code GPL-2.0 (game data proprietary)
Website https://github.com/id-Software/DOOM
On this wiki Facts · Code · Notes · Topics

First-person shooter by id Software (December 1993, MS-DOS). All game data lives in Format:WAD (Doom engine) archives; the engine source was released in 1997 (Linux port, version 1.10) and relicensed under GPL-2.0, so its data structures and algorithms can be read directly instead of reverse engineered.

Overview

The engine (later called id Tech 1) renders a 2D map with floor and ceiling heights through a precomputed BSP tree and runs the game simulation at a fixed 35 tics per second (TICRATE). The same engine and data formats are shared by Doom II, The Ultimate Doom, Final Doom and, with extensions, Heretic, Hexen and Strife; knowledge on this page and on Format:WAD (Doom engine) applies to them unless stated otherwise.

The 1997 source release (directory linuxdoom-1.10 of the id Software repository) is the Linux port. It reports itself as version 110. The DOS sound code is not included: the release notes say a copyrighted third-party sound library was used and had to be removed, and the IPX network driver is shipped separately (ipx/).

Architecture overview

Modules are named by prefix: am_ automap, d_ main loop and networking, f_ finale and screen wipe, g_ game flow (demos, saves), hu_ heads-up text, i_ system interface (video, sound, timer, network), m_ misc (menus, fixed point, random, argv), p_ play simulation, r_ renderer, s_ sound, st_ status bar, w_ WAD access, wi_ intermission, z_ zone allocator.

  • Numbers: almost everything is 16.16 fixed point (fixed_t, FRACUNIT = 0x10000). Angles are 32-bit binary angles (ANG90 = 0x40000000); trigonometry uses lookup tables (finesine with 10240 entries, finetangent 4096, tantoangle 2049) indexed by angle >> 19.
  • Randomness: one fixed 256-byte table, read by two independent indices (see facts). Demo playback and network play rely on it being deterministic.
  • Actors: every monster, item and projectile is a mobj_t driven by a state machine. The tables states (967 entries), mobjinfo (137 types) and sprnames (138 four-letter sprite names) are compiled into the executable (info.c).
  • Input: each tic, each player's input is packed into a ticcmd_t; demos store exactly these commands, network games exchange them.

Formats

Data File Page
All game data (maps, graphics, sounds, music, palettes) .WAD (IWAD, PWAD) Format:WAD (Doom engine)
Recorded demos .LMP, or DEMO1-DEMO4 lumps in the IWAD Format:Doom demo (LMP)
Saved games DOOMSAV0.DSG to DOOMSAV5.DSG Format:Doom savegame (DSG)

Identification

  • The 256-byte random table starts with the bytes 00 08 6D DC DE F1 95 6B 4B F8 FE 8C 10 42 4A 15; finding it in an executable identifies Doom-engine code (any port, console version or derived game) and locates P_Random/M_Random by cross-reference.
  • finesine starts with the 32-bit values 25, 75, 125, 175 (19 00 00 00 4B 00 00 00 7D 00 00 00 AF 00 00 00 little-endian).
  • Error strings such as W_GetNumForName: %s not found! and Demo is from a different game version! survive in most builds and ports.

Modding entry points

  • PWADs loaded with -file override IWAD lumps by name because lump lookup returns the last match (Format:WAD (Doom engine)#Lump lookup).
  • Behaviour that is not in the WAD (monster stats, states, weapon frames, text) is compiled in; DeHackEd-style patches change those tables in the executable. Unverified: the DOS v1.9 executable stores states and mobjinfo with the same 28-byte and 92-byte records as the source; test by searching the executable for the first mobjinfo row (doomednum -1, spawnstate 149, spawnhealth 100 as 32-bit integers).

Code & repositories

  • https://github.com/id-Software/DOOM @ a77dfb96cb91780ca334d0d4cfd86957558007e0 · license: GPL-2.0
    Official id Software source release of Doom (GPL-2.0): the 1997 Linux port, version 1.10 (linuxdoom-1.10), plus the DOS IPX network driver and the DOS assembly inner loops as a README. Reference for the WAD reader (w_wad.c), map lump structures (doomdata.h, p_setup.c), picture and texture formats (r_defs.h, r_data.c), demo and savegame code (g_game.c, p_saveg.c), the RNG (m_random.c), fixed point (m_fixed.c) and the compiled-in state and actor tables (info.c). The DOS sound library code is not included.
    Tested on: Source read at commit a77dfb9; not built. Structure sizes, map lump order, demo layout and palette sizes were checked with a standard-library Python reader against the Freedoom 0.13.0 IWADs (freedoom1.wad, freedoom2.wad). · checked 2026-10-17; last activity 2024-05-24

Pitfalls

  • P_Random (gameplay) and M_Random (menus, effects) share one table but have separate indices; only P_Random must stay in sync for demos. Calling the wrong one in a port desynchronises demos.
  • The source is version 1.10 (Linux); retail DOS releases differ in small ways (version byte 109 for 1.9, DOS-only code paths). Check behaviour against the retail executable before assuming the source matches a given DOS build.
  • Freedoom IWADs are a free, BSD-licensed replacement for the game data and are convenient test samples; they are not byte-identical to the commercial IWADs.

Open questions

  • Which compiler and DOS extender built each retail DOOM.EXE version, and do the states/mobjinfo tables sit at the same file offsets in 1.9 registered and The Ultimate Doom? Unverified lead: Watcom C with the DOS/4GW extender (a linear executable); test by checking the MZ stub and DOS/4GW strings in DOOM.EXE.