doom

WAD (which, according to the Doom Bible, is an acrostic for "Where's All the Data?" [1]) is the file format used by Doom and all Doom-engine-based games for storing data. A WAD file consists of a header, a directory, and the data lumps that make up the resources stored within the file. A WAD file can be of two types:

A WAD file can be read and/or edited by many tools, such as WAD editors.

Header

A WAD file always starts with a 12-byte header. It contains three values:

wadinfo_t
Position Length Name Description
0x00 4 identification The ASCII characters "IWAD" or "PWAD". Defines whether the WAD is an IWAD or a PWAD.
0x04 4 numlumps An integer specifying the number of lumps in the WAD.
0x08 4 infotableofs An integer holding a pointer to the location of the directory.

All integers are 4 bytes long in x86-style little-endian order. Their values can never exceed 231-1, since Doom reads them as signed ints.

Directory

The directory associates names of lumps with the data that belong to them. It consists of a number of entries, each with a length of 16 bytes. The length of the directory is determined by the number given in the WAD header. The structure of each entry is as follows:

filelump_t
Offset Length Name Content
0x00 4 filepos An integer holding a pointer to the start of the lump's data in the file.
0x04 4 size An integer representing the size of the lump in bytes.
0x08 8 name An ASCII string defining the lump's name. Only the characters A-Z (uppercase), 0-9, and [] - _ should be used in lump names (an exception has to be made for some of the Arch-Vile sprites, which use "\"). When a string is less than 8 bytes long, it should be null-padded to the tight byte.

Tools should not assume the lump-order in the WAD to be sorted by their byte offset into the WAD.

"Virtual" lumps (such as F_START) only exist in the directory, having a size of 0. Their offset value therefore is nonsensical (often 0).

It is possible for more than one lump to have the same offset value, aswell as having offsets that overlap other lump data.

Type of file is not stated in the lump's data.

Typical wad file:

wadfile_t
Header
Lump Data
Names and pointers of Lumps

Lump order

The majority of lumps have no restrictions on where they must be located in WAD files, although there are typically some guidelines to make the file easily readable by other people. For certain lumps, however, the location is crucial.

Map data lumps

A map in Doom is made up of several lumps, each containing specific data required to construct and execute the map. The first lump gives the internal name of the map. In Doom, this had to be in the form ExMy or MAPxx, where x and y could not exceed 4 and 9 respectively (Ultimate Doom), and xx could not exceed 32 (Doom 2/Final Doom). Other than defining the name of the map, the lump is usually empty but can contain data. The DOOM64.WAD file for Doom 64 EX, converted out of the Nintendo 64 ROM content, contains embedded IWADs in MAPxx lumps. In Hexen, they contain version control information; which is not used by the game but was presumably used by Raven Software's editing tools. SMMU introduced using it to store map information and FraggleScript. The level name marks the start of this map. In order to work properly, the following lumps must follow immediately after the the level name:

Notes

The Doom alphas and had noticeably different map formats.

Flats, Sprites, and Patches

These three resources must be located between special marker lumps so that Doom knows what it is looking at. Other than defining the beginning and end of a graphics section, these lumps contain no data and are 0 bytes long.

The markers consist of names X_START and X_END, where X is the first 1 or 2 letters of the appropriate resource. For example, sprites should be located between S_START and S_END markers. SS_START and SS_END are usually used for user WAD files.

These markers are required by DOOM:

Start marker End marker What Used by
F_START F_END Flat delimiters All versions
S_START S_END Sprite delimiters All versions

These markers are found in the official WAD files, but are unused by known DOOM engines:

Start marker End marker Found in What Used by
P_START P_END Patch delimiters All versions
P1_START P1_END inside P_ range Shareware, Heretic or Hexen patches Doom Shareware and up (but not Final Doom), Heretic, Hexen
P2_START P2_END inside P_ range Registered, Heretic or Hexen patches Doom Registered and up (but not Final Doom), Heretic, Hexen
P3_START P3_END inside P_ range Doom2 patches Doom2, but not Final Doom
F1_START F1_END inside F_ range Shareware, Heretic or Hexen flats Doom Shareware and up (but not Final Doom), Heretic, Hexen
F2_START F2_END inside F_ range Registered, Heretic or Hexen flats Doom Registered and up (but not Final Doom), Heretic, Hexen

Patches are not required to have any markers. Some lump management utilities require P_START and P_END.

Miscellaneous

Some lumps are known by their names and apply to the game as a whole. Some of these are:

Uses outside the Doom engine

Due to Doom's popularity and the simplicity of the format, many third party tools were written to manipulate WAD files very early on. This encouraged other game developers to adopt it even for unrelated games. Some even made use of the map format, though the values associated to thing, line, and sector types are usually completely different.

The .wad extension has also been used for different formats. Quake uses the "wad2" format to store various graphic resources, this is an evolution of the Doom wad format with a modified directory entry structure. Half-Life's GoldSrc engine uses the "wad3" format, derived from and compatible with Quake's wad2 format, to store textures. The RTS format, used for RemoteRidicule audio in Build Engine games, is a variant of the WAD format. Also of note is that the Nintendo Wii uses a format also called WAD for many files such as WiiWare games and system files, but this is coincidental; it is an entirely unrelated file format.