6 Resource Loader: Overview
This tour examines DOOM’s WAD resource system through:
- WAD file types and functions in w_wad.h
- Lump loading and caching functions in w_wad.c
- Map data structures in doomdata.h
6.0.1 📂 File: w_wad.h
Defines: - wadinfo_t: WAD file header - filelump_t: directory entries - lumpinfo_t: in-memory lump tracking
The w_wad.c file handles loading and managing WAD files, which store DOOM’s game data in discrete chunks called lumps.
6.0.2 📄 File: w_wad.c (lines 19–21)
Header comment explains the file manages WAD headers, directory reading, and lump I/O.
6.0.3 📄 File: w_wad.c (lines 292–316)
W_InitMultipleFiles loads WAD files into memory for engine access.
6.0.4 📄 File: w_wad.c (lines 141–144)
W_AddFile reads either a WAD or single lump into the resource system.
6.0.5 📄 File: w_wad.c (lines 507–513)
W_CacheLumpName loads a lump by name into memory and returns a pointer to its contents.
6.0.6 📄 File: f_finale.c (lines 598–602)
Uses W_CacheLumpNum to load a sprite patch, then draws it flipped or normally.
6.0.7 📄 File: i_sound.c (line 226)
Loads a sound effect lump into sfx using W_CacheLumpNum.
6.0.8 📄 File: p_setup.c (lines 137–140)
W_CacheLumpNum loads ML_VERTEXES, cast to mapvertex_t *.
6.0.9 📄 File: r_data.c (lines 258–260)
Texture patch is loaded into realpatch via W_CacheLumpNum, and width is read to calculate x2.
6.0.10 📄 File: w_wad.c (lines 351–359)
W_CheckNumForName finds a lump by name, returning its index or -1.
6.0.11 📄 File: w_wad.c (lines 399–404)
W_GetNumForName gets lump index or fails if not found.
doomdata.h defines the data formats used to store map geometry in WAD files.
6.0.12 📄 File: doomdata.h (lines 43–56)
Enum defining the sequence of map data sections in a WAD file.
6.0.13 📄 File: doomdata.h (lines 60–64)
mapvertex_t stores vertex positions from the ML_VERTEXES lump.
6.0.14 📄 File: doomdata.h (lines 69–78)
mapsidedef_t represents a wall side with texture info and sector reference.
6.0.15 📄 File: doomdata.h (lines 84–93)
maplinedef_t represents a map line, with vertex references and wall properties.
6.0.16 📄 File: p_setup.c (lines 144–148)
Loop converts vertex coordinates from integers to fixed-point format.
6.0.17 📄 File: p_setup.c (lines 178–179)
Segs connect to vertices by indexing the vertex array.
6.0.18 📄 File: p_setup.c (lines 184–188)
P_LoadSegs connects segs to linedefs, sidedefs, and front sectors.
6.0.19 📄 File: p_setup.c (lines 514–517)
Subsectors get sector pointers from their first seg’s sidedef.
WAD I/O handles DOOM’s resource loading through lump management and caching, with specialized formats for map data.