# id-software/doom architecture

> Architecture diagram of the GitHub repository id-software/doom, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/id-software/doom
- Repository: https://github.com/id-software/doom

## Overview

#### Purpose and Build Entry Points
This is the Linux DOOM 1.10 engine source release, licensed GPL-2.0, requiring externally supplied commercial DOOM WAD game data. The primary executable is built from `linuxdoom-1.10/Makefile`; process startup begins at `linuxdoom-1.10/i_main.c` and transfers into the game driver in `linuxdoom-1.10/d_main.c`. A separate sound-server executable lives in `sndserv/Makefile`.

#### Runtime Orchestration and Game States
`linuxdoom-1.10/d_main.c` initializes subsystems, selects the game state, drives the main loop, and coordinates display updates. `linuxdoom-1.10/g_game.c` implements game progression, demo/save behavior, player command handling, and per-tick game dispatch. Shared global engine state and gameplay definitions form a broad coupling boundary in `linuxdoom-1.10/doomstat.h`, `linuxdoom-1.10/doomdef.h`, and `linuxdoom-1.10/doomdata.h`.

#### Input, Tick, and World Simulation
The engine advances a deterministic tic-based simulation: input events are represented through `linuxdoom-1.10/d_event.h`, player commands through `linuxdoom-1.10/d_ticcmd.h`, and scheduling/network-facing tic flow through `linuxdoom-1.10/d_net.c`. World thinkers and object updates are managed by `linuxdoom-1.10/p_tick.c`, while player movement, collision interactions, monsters, and map specials span `linuxdoom-1.10/p_user.c`, `linuxdoom-1.10/p_map.c`, and `linuxdoom-1.10/p_enemy.c`.

#### Level Data, Memory, and Persistence
WAD files are the primary external content boundary. `linuxdoom-1.10/w_wad.c` loads and looks up named binary lumps; `linuxdoom-1.10/p_setup.c` converts level lumps into runtime map structures. The custom zone allocator in `linuxdoom-1.10/z_zone.c` owns tagged game memory. Save/load serialization is handled by `linuxdoom-1.10/p_saveg.c`; compatibility depends on the game’s binary data layouts.

#### Software Rendering Pipeline
The renderer consumes BSP-organized level geometry and runtime objects. `linuxdoom-1.10/r_main.c` controls view rendering; `linuxdoom-1.10/r_bsp.c` traverses map BSP nodes and subsectors; `linuxdoom-1.10/r_segs.c`, `linuxdoom-1.10/r_plane.c`, and `linuxdoom-1.10/r_things.c` render walls, flats, and sprites. Asset preparation and texture/flat lookup are in `linuxdoom-1.10/r_data.c`; final framebuffer operations pass through `linuxdoom-1.10/v_video.c` and platform video code in `linuxdoom-1.10/i_video.c`.

#### UI, Audio, and Platform Boundary
Menus, HUD, status bar, intermission, and finale are separate presentation layers: `linuxdoom-1.10/m_menu.c`, `linuxdoom-1.10/hu_stuff.c`, and `linuxdoom-1.10/st_stuff.c`. Gameplay emits sound requests through `linuxdoom-1.10/s_sound.c`; Linux platform integration is in `linuxdoom-1.10/i_sound.c`, `linuxdoom-1.10/i_system.c`, and `linuxdoom-1.10/i_net.c`. Sound can be delegated to the companion `sndserv/soundsrv.c`, which reads WAD sound resources via `sndserv/wadread.c`.

#### Multiplayer Transports
The engine-level network protocol and tic synchronization are defined by `linuxdoom-1.10/d_net.c` and `linuxdoom-1.10/i_net.c`. Legacy peer-to-peer transport implementations are maintained separately: IPX setup/network code under `ipx/DOOMNET.C` and `ipx/IPXNET.C`, and serial setup/transport under `sersrc/DOOMNET.C` and `sersrc/PORT.C`. These are distinct from the Linux build and represent platform/transport-specific integration boundaries.

Main entry points: [`linuxdoom-1.10/d_main.c`](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/d_main.c) (Game driver), [`linuxdoom-1.10/g_game.c`](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/g_game.c) (Game progression), [`linuxdoom-1.10/d_net.c`](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/d_net.c) (Tic scheduling), [`linuxdoom-1.10/w_wad.c`](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/w_wad.c) (WAD lump loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Engine Runtime"]
  node_build["Linux engine build<br/>Makefile<br/>[Makefile]"]
  node_startup["Process startup<br/>platform entry<br/>[i_main.c]"]
  node_driver["Game driver<br/>main loop<br/>[d_main.c]"]
  node_game["Game progression<br/>game state<br/>[g_game.c]"]
  node_shared["Shared engine definitions<br/>global state"]
end

subgraph group_simulation["Simulation &amp; Data"]
  node_ticflow["Tic scheduling<br/>network/tick flow<br/>[d_net.c]"]
  node_input["Input events &amp; commands<br/>input protocol"]
  node_world["World simulation<br/>thinkers &amp; gameplay"]
  node_wad[("Commercial DOOM WAD<br/>external game data")]
  node_wadloader["WAD lump loader<br/>content loader<br/>[w_wad.c]"]
  node_levelsetup["Level setup<br/>map loader<br/>[p_setup.c]"]
  node_memory["Zone allocator<br/>tagged memory<br/>[z_zone.c]"]
  node_save["Save/load serialization<br/>persistence<br/>[p_saveg.c]"]
end

subgraph group_rendering["Rendering &amp; UI"]
  node_renderer["View renderer<br/>render coordinator<br/>[r_main.c]"]
  node_bsp["BSP traversal<br/>visibility traversal<br/>[r_bsp.c]"]
  node_draw["World drawing<br/>walls, flats &amp; sprites"]
  node_renderdata["Render asset data<br/>texture/flat lookup<br/>[r_data.c]"]
  node_video["Video output<br/>framebuffer platform layer"]
  node_ui["HUD and menus<br/>presentation UI"]
end

subgraph group_platform["Platform &amp; Transports"]
  node_audio["Audio integration<br/>sound platform layer"]
  node_soundsrv["Sound server<br/>companion executable"]
  node_linuxplatform["Linux system &amp; network<br/>platform integration"]
  node_legacytransport["Legacy IPX &amp; serial<br/>peer transport"]
end

node_build -->|"builds"| node_startup
node_startup -->|"enters"| node_driver
node_driver -->|"drives"| node_game
node_driver -->|"runs tics"| node_ticflow
node_driver -->|"updates display"| node_renderer
node_driver -->|"updates"| node_ui
node_game -->|"dispatches tick"| node_world
node_input -->|"supplies commands"| node_ticflow
node_ticflow -->|"schedules"| node_world
node_shared -.->|"defines state"| node_game
node_shared -.->|"defines data"| node_world
node_wad -->|"binary lumps"| node_wadloader
node_wadloader -->|"provides level lumps"| node_levelsetup
node_levelsetup -->|"builds map"| node_world
node_memory -.->|"owns game memory"| node_world
node_game -->|"saves and loads"| node_save
node_world -->|"runtime geometry &amp; objects"| node_renderer
node_renderer -->|"traverses"| node_bsp
node_bsp -->|"visible geometry"| node_draw
node_renderdata -->|"textures and flats"| node_draw
node_wadloader -->|"assets"| node_renderdata
node_draw -->|"framebuffer"| node_video
node_game -->|"sound requests"| node_audio
node_audio -->|"delegates sound"| node_soundsrv
node_wad -->|"sound resources"| node_soundsrv
node_ticflow -->|"network I/O"| node_linuxplatform
node_legacytransport -.->|"alternate transport"| node_ticflow

click node_build "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/Makefile"
click node_startup "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/i_main.c"
click node_driver "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/d_main.c"
click node_game "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/g_game.c"
click node_ticflow "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/d_net.c"
click node_wadloader "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/w_wad.c"
click node_levelsetup "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/p_setup.c"
click node_memory "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/z_zone.c"
click node_save "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/p_saveg.c"
click node_renderer "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/r_main.c"
click node_bsp "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/r_bsp.c"
click node_renderdata "https://github.com/id-software/doom/blob/master/linuxdoom-1.10/r_data.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_build,node_startup,node_driver,node_game,node_shared toneBlue
class node_ticflow,node_input,node_world,node_wad,node_wadloader,node_levelsetup,node_memory,node_save toneAmber
class node_renderer,node_bsp,node_draw,node_renderdata,node_video,node_ui toneMint
class node_audio,node_soundsrv,node_linuxplatform,node_legacytransport toneRose
```

## Components

### Engine Runtime

- [Linux engine build](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/Makefile): Makefile · Builds the primary executable. · `linuxdoom-1.10/Makefile`
- [Process startup](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/i_main.c): platform entry · `linuxdoom-1.10/i_main.c`
- [Game driver](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/d_main.c): main loop · Initializes subsystems and coordinates game states and display. · `linuxdoom-1.10/d_main.c`
- [Game progression](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/g_game.c): game state · `linuxdoom-1.10/g_game.c`
- **Shared engine definitions**: global state · Global state and binary gameplay definitions.

### Simulation & Data

- [Tic scheduling](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/d_net.c): network/tick flow · `linuxdoom-1.10/d_net.c`
- **Input events & commands**: input protocol
- **World simulation**: thinkers & gameplay · Runs thinker updates, player movement, collisions, enemies, and specials.
- **Commercial DOOM WAD**: external game data · Required external binary game content.
- [WAD lump loader](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/w_wad.c): content loader · `linuxdoom-1.10/w_wad.c`
- [Level setup](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/p_setup.c): map loader · Converts level lumps into runtime map structures. · `linuxdoom-1.10/p_setup.c`
- [Zone allocator](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/z_zone.c): tagged memory · `linuxdoom-1.10/z_zone.c`
- [Save/load serialization](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/p_saveg.c): persistence · `linuxdoom-1.10/p_saveg.c`

### Rendering & UI

- [View renderer](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/r_main.c): render coordinator · `linuxdoom-1.10/r_main.c`
- [BSP traversal](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/r_bsp.c): visibility traversal · `linuxdoom-1.10/r_bsp.c`
- **World drawing**: walls, flats & sprites
- [Render asset data](https://github.com/id-software/doom/blob/master/linuxdoom-1.10/r_data.c): texture/flat lookup · `linuxdoom-1.10/r_data.c`
- **Video output**: framebuffer platform layer
- **HUD and menus**: presentation UI

### Platform & Transports

- **Audio integration**: sound platform layer
- **Sound server**: companion executable · Reads WAD sound resources in a separate process.
- **Linux system & network**: platform integration
- **Legacy IPX & serial**: peer transport · Separate non-Linux transport implementations.

## Connections

- Linux engine build → Process startup: builds
- Process startup → Game driver: enters
- Game driver → Game progression: drives
- Game driver → Tic scheduling: runs tics
- Game driver → View renderer: updates display
- Game driver → HUD and menus: updates
- Game progression → World simulation: dispatches tick
- Input events & commands → Tic scheduling: supplies commands
- Tic scheduling → World simulation: schedules
- Shared engine definitions → Game progression: defines state
- Shared engine definitions → World simulation: defines data
- Commercial DOOM WAD → WAD lump loader: binary lumps
- WAD lump loader → Level setup: provides level lumps
- Level setup → World simulation: builds map
- Zone allocator → World simulation: owns game memory
- Game progression → Save/load serialization: saves and loads
- World simulation → View renderer: runtime geometry & objects
- View renderer → BSP traversal: traverses
- BSP traversal → World drawing: visible geometry
- Render asset data → World drawing: textures and flats
- WAD lump loader → Render asset data: assets
- World drawing → Video output: framebuffer
- Game progression → Audio integration: sound requests
- Audio integration → Sound server: delegates sound
- Commercial DOOM WAD → Sound server: sound resources
- Tic scheduling → Linux system & network: network I/O
- Legacy IPX & serial → Tic scheduling: alternate transport
