Format:DAT (Fallout)
| Magic | none |
|---|---|
| Extensions | .dat |
| Endianness | Fallout 1 big-endian; Fallout 2 as written by the reference reader (native, little-endian on x86) |
| On this wiki | Facts · Code · Notes · Topics |
Archive format of Fallout 1 and 2 (MASTER.DAT, CRITTER.DAT): Fallout 2 uses a little-endian footer plus a flat path table at the end of the file and zlib; Fallout 1 uses a big-endian directory tree at the start of the file and LZSS (whole-file or block-wise).
Overview
The two games share the extension but not the layout. Neither has a magic number. Both are identified by trying to parse them; Fallout 2 ones have the sizes of the path table and of the whole data in the last 8 bytes.
Fallout 2 (flat table at the end)
Read by dbaseOpen in fallout2-ce src/dfile.cc (integers are read with fread of a host int, so little-endian on x86 hosts):
- The last 8 bytes: int32
entriesDataSize(size of the path table, including its leading count) and int32dbaseDataSize. - The table starts at
fileSize - entriesDataSize - 8: int32 entry count, then for each entry: int32 pathLength, path bytes (no terminator), uint8 compressed, int32 uncompressedSize, int32 dataSize (stored bytes), int32 dataOffset. - An entry's data starts at
(fileSize - dbaseDataSize) + dataOffset; the first term is computed so arbitrary data may precede the archive.compressed == 1means the data is a zlib stream (inflateInit, so with the zlib header); any other value is read as stored.
Paths include directories with backslashes (the lookup code builds paths like art\critters\...).
Fallout 1 (tree at the start)
Read by db_init_database with the "assoc" loader in fallout1-ce (src/plib/db/db.cc, src/plib/assoc/assoc.cc). All integers are big-endian (assoc_read_long builds the value from four fgetc bytes, high first):
- An assoc header of four int32: size (directory count), max, datasize, and one ignored word (the in-memory pointer of the original). Then
sizerecords: a 1-byte name length, the name characters, anddatasizeraw bytes. These are the directory names. - For each directory, again an assoc header of four int32 and
sizerecords: 1-byte name length, name characters, then a 16-byte entry of four big-endian int32: flags, offset, length (unpacked size), packed length. - Flags select the codec (see the fact): 0x10 one LZSS stream of packed-length bytes, 0x20 stored, 0x40 a sequence of blocks with 16-bit big-endian size words (high bit set: stored block, else LZSS block). Flags 0 are treated as 0x10.
The LZSS used is the classic 4096-byte ring buffer variant described in the fact.
Unverified
Unverified: that the Fallout 1 assoc loader in fallout1-ce matches the stock MASTER.DAT byte for byte (its code is a reimplementation that keeps the original's function addresses in comments); how fgets in assoc_load treats names that contain a newline (it stops at one).
The repositories are under the Sustainable Use License 1.0; facts only are cited here.
Code & repositories
- https://github.com/alexbatalov/fallout2-ce @
e97087b9582f37075db347a89898887320753f8b· license: LicenseRef-Sustainable-Use-1.0 (declared by the contributor; GitHub's detector did not recognize LICENSE.md)
Fallout 2 Community Edition: src/dfile.cc (Fallout 2 DAT reader), src/db.cc (big-endian helpers) and src/art.cc (FRM reader). Sustainable Use License 1.0: cite facts only, do not copy code.
Tested on: source read, not run: source read at the cited commit, not run · checked 2026-10-19; last activity 2025-02-17; Note: the latest release ships binaries; the wiki links only the source, never the binaries - https://github.com/alexbatalov/fallout1-ce @
0609bcfd0ec40ff0571d0f57fab2821eb461dc8b· license: LicenseRef-Sustainable-Use-1.0 (declared by the contributor; GitHub's detector did not recognize LICENSE.md)
Fallout 1 Community Edition: src/plib/db/db.cc, assoc.cc and lzss.cc (Fallout 1 DAT tree, codecs and LZSS); its art.cc was not read. Sustainable Use License 1.0: cite facts only, do not copy code.
Tested on: source read, not run: source read at the cited commit, not run · checked 2026-10-19; last activity 2025-01-15; Note: the latest release ships binaries; the wiki links only the source, never the binaries