Introduction to the Doom Repository
1 General Overview
This tour examines Linux DOOM 1.10
βs architecture, from its build system and platform abstraction layers through its core engine components: memory management, resource loading, rendering, game logic, physics, AI, UI, sound, and networking.
The next steps examine how DOOM
initializes, starting with the build system and following through to the main entry point.
1.0.1 π File: linuxdoom-1.10/Makefile
This Makefile compiles DOOM for Linux, building object files in linux/
and linking them with X11, networking, and math libraries.
1.0.2 π File: README.TXT
(lines 12β20)
The code is currently Linux-only but designed to be portable. The rendering model uses horizontal/vertical constant-Z lines with fixed-band lighting.
1.0.3 π File: linuxdoom-1.10/i_main.c
(lines 34β44)
main
stores command-line args in myargc
/myargv
and calls D_DoomMain()
to hand off control to the engine.
1.0.4 π File: linuxdoom-1.10/d_main.h
D_DoomMain()
handles system startup while D_PostEvent()
processes input events into the game queue.
1.0.5 π File: linuxdoom-1.10/d_main.c
(lines 792β800)
D_DoomMain
is the gameβs initialization function. It sets up all major subsystems and either starts a demo or begins a new game.
1.0.6 π File: linuxdoom-1.10/d_main.c
(lines 352β360)
The main game loop processes input, updates game state, handles sound, and renders each frame. Demo recording can be initialized when the game starts.
1.0.7 π File: linuxdoom-1.10/i_system.c
(lines 76β84)
I_ZoneBase
provides memory for the zone allocator by allocating a block of the requested size. I_AllocLow
allocates zero-initialized memory.
1.0.8 π File: linuxdoom-1.10/i_video.h
(lines 1β8)
Functions that handle platform-specific graphics display, including initialization, shutdown, palette setting, and screen updates.
1.0.9 π File: linuxdoom-1.10/i_sound.h
(lines 1β6)
Declares the core sound system functions for initializing, updating, submitting, and shutting down sound output.
1.0.10 π File: linuxdoom-1.10/i_net.h
(lines 1β6)
Declares network functions I_InitNetwork()
for setup and I_NetCmd()
for multiplayer communication.
The next files show how DOOM isolates platform-specific code into an OS abstraction layer
, handling memory, graphics, sound, and networking on Unix systems.
1.0.11 π File: linuxdoom-1.10/z_zone.h
(lines 30β42)
Memory allocations use purge tags to control when they can be freed. Tags under 100 are protected, while higher tags allow purging.
1.0.12 π File: linuxdoom-1.10/z_zone.c
(lines 93β101)
Z_Init()
uses I_ZoneBase
to reserve a main heap zone and creates one large free block.
1.0.13 π File: linuxdoom-1.10/z_zone.c
(lines 181β191)
Z_Malloc
allocates memory blocks with additional tracking information for Doomβs memory management system.
1.0.14 π File: linuxdoom-1.10/w_wad.h
w_wad.h
defines structures and functions for reading DOOMβs WAD resource files, handling file headers, directory entries, and memory-cached game assets.
Z_Malloc
allocates memory from the heap zone and tracks its lifetime through tags, allowing the system to manage memory for different game resources.
1.0.15 π File: linuxdoom-1.10/p_setup.c
(lines 133β136)
Z_Malloc
allocates memory for the vertexes array used by BSP and rendering code, with PU_LEVEL
tag for lifetime tracking.
1.0.16 π File: linuxdoom-1.10/w_wad.c
(lines 292β300)
Z_Malloc
allocates memory from the heap zone and manages memory lifetime through tags like PU_STATIC
for permanent allocations and PU_LEVEL
for level-specific data that gets freed between maps.
1.0.17 π File: linuxdoom-1.10/doomdata.h
doomdata.h
defines on-disk WAD map structures: mapvertex_t
, mapsidedef_t
, maplinedef_t
, mapsector_t
, mapsubsector_t
, mapseg_t
, mapnode_t
, and mapthing_t
for level geometry and entities.
1.0.18 π File: linuxdoom-1.10/d_main.c
(lines 1020β1022)
Z_Malloc
allocates memory for the gameβs vertex data structure, requesting numvertexes*sizeof(vertex_t)
bytes with the PU_LEVEL
tag.
1.0.19 π File: linuxdoom-1.10/p_setup.c
(lines 136β137)
W_InitMultipleFiles
loads and indexes all specified IWAD/PWAD archives before any other subsystem initialization begins.
W_CacheLumpNum
loads raw lump data into memory and returns a pointer that gets cast to mapvertex_t*
for BSP building.
1.0.20 π File: linuxdoom-1.10/r_main.h
r_main.h
defines renderer functions for initialization, viewport setup, frame rendering, and BSP geometry.
1.0.21 π File: linuxdoom-1.10/r_main.c
(lines 868β875)
This function coordinates the main rendering sequence for the playerβs view, from BSP traversal through final sprite drawing.