You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/posts/building-a-minimal-doom-wad-loader.md
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,6 @@ draft: false
7
7
8
8
I wanted to learn how Doom’s WAD files work, so I wrote a simple loader in C++.
9
9
My goal was just to open a WAD, read its contents, and understand how it’s structured.
10
-
The code isn’t fancy or optimized — it’s just a clean, minimal implementation that does the job.
11
10
12
11
---
13
12
@@ -68,7 +67,7 @@ struct Wad {
68
67
- `directoryMap` lets me look up lumps by name.
69
68
- `data` holds the entire WAD file in memory.
70
69
71
-
Keeping the full file in memory simplifies things — I can slice directly from it when I need lump data, without reopening or seeking through the file again.
70
+
Keeping the full file in memory simplifies things, I can slice directly from it when I need lump data, without reopening or seeking through the file again.
72
71
73
72
---
74
73
@@ -97,7 +96,7 @@ This function does three things:
97
96
2. Allocates a buffer large enough to hold the whole file and reads it.
98
97
3. Seeks back to the beginning for the next read.
99
98
100
-
Resetting the cursor is important — otherwise, the next read (for the header) will start at the end of the file and return garbage.
99
+
Resetting the cursor is important, otherwise the next read (for the header) will start at the end of the file and return garbage.
101
100
102
101
---
103
102
@@ -369,7 +368,7 @@ This version does a few useful things:
369
368
- Prints the WAD header information for quick verification.
370
369
- Lists all lumps and their positions and sizes.
371
370
- Looks up a specific lump (in this case, `PLAYPAL`) and reads it into a vector.
372
-
- Prints the first 32 bytes in hexadecimal — a quick sanity check that I’m reading real data and not zeroes or garbage.
371
+
- Prints the first 32 bytes in hexadecimal: a quick sanity check that I’m reading real data and not zeroes or garbage.
373
372
374
373
It’s not polished, but it’s practical and also very temporary.
375
374
@@ -384,7 +383,7 @@ The loader now:
384
383
- Handles padded 8-character names without breaking map keys.
385
384
- Provides direct access to lump data by name.
386
385
387
-
From here I can start building on it — parsing palettes, maps, textures, or even writing tools that inspect and modify WAD contents.
386
+
From here I can start building on it: parsing palettes, maps, textures, or even writing tools that inspect and modify WAD contents.
388
387
The code is intentionally simple so it’s easy to extend.
0 commit comments