GameMaps Format

From ModdingWiki
Jump to: navigation, search
GameMaps Format
GameMaps Format.png
Format typeMap/level
Map type2D tile-based
Layer count3
Viewport (pixels)Varies by game

The GameMaps Format stores levels in a number of Category:id Software games. The filenames and compression varies somewhat across different games but all files stored in this format were produced by the TED5 level editor.

There are three main varieties of the file format: uncompressed, carmackized, and Huffman compressed. Each variation has its own file naming scheme and pattern of external/internal files.

There are two main components to the format. The game maps proper, which contain the actual level data, and the map headers, which contain both the location of each level's data within the game maps file, and the tile info for the game.

Structure of uncompressed data

The uncompressed format is used by several games including Bio Menace and Wolfenstein 3-D. In this format map data is stored in and map headers in This is the working format saved by TED5 when maps are being edited and can be directly accessed and edited by this utility, allowing changes to be made to the game.

Note that filenames differ and that Wolfenstein 3-D uses GAMEMAPS.WLx and MAPHEAD.WLx files to store data (except for v1.0, which uses MAPTEMP.WLx in place of GAMEMAPS.WLx).

The main indicator of this format being used is that in the unaltered game the map header file is external.

Only the latest Id Software games lacked compression, when file size was no longer an issue.

Map headers (MAPHEAD)

Offset Type Name Description
0 UINT16LE magic Magic word signalling RLEW compression
2 UINT32LE[400] ptr 100 pointers to start of level 0-99 data in the game maps file
402 ! Unknown tileinfo Tileinfo data

The map header file (MAPHEAD) is of varying length and contains three main types of data. The first is the magic word or flag used for RLEW compression, which is always $ABCD. The second is 100 level pointers which give the location of the start of level data in the GAMEMAPS file, relative to the start of that file. A value greater than 0 indicates no level (generally 0, but occasionally -1 (xFFFFFFFF) is used). The third is the tileinfo data, which contains tile properties for each tile used in level creation. (These are masked and unmasked and either 8x8, 16x16 or 32x32.)

Many programs treat the tileinfo as a separate file from the MAPHEAD and it is possible to modify a game in this manner. Indeed, some games such as Wolfenstein 3-D do not have any tileinfo data at all in the map header file (giving a total file length of 402 bytes.) However TED5 works with any tileinfo data in the MAPHEAD.

Map data (GAMEMAPS)

The GAMEMAPS file consists of the string "TED5v1.0" and a number of RLEW compressed chunks of varying length. Each level in the file will have from two to four chunks (usually four) depending on the game, with all levels in a given game having the same number of chunks. These are the level header and 1-3 planes (foreground, background and sprite/info.) The chunks are in no particular order and it is possible to read through the entire file decompressing chunks as they're found.

Chunks are ordered by the MAPHEAD file, which will point to the GAMEMAPS level header chunks which in turn contain pointers to the other GAMEMAPS chunks used by that level.

All level data is in the form of UINT16LE values (or in the case of pointers, UINT32LE.)

Level headers

The header for each level inside the GAMEMAPS file (which is pointed to by MAPHEAD) is 38 bytes long and never RLEW compressed. If the GAMEMAPS file is using Huffman compression, the level header itself is Huffman-compressed. In that case, the size of the compressed level header can be found in the MAPHEAD file. Since the uncompressed level header always has a size of 38 bytes, that size is not stored at the beginning of the compressed data. The header is sometimes followed by a signature "!ID!" string, which would give the header a total size of 42 bytes, but that string is not part of the actual level header.

For the offsets to level planes, a value of 0 indicates the plane does not exist.

Plane 0 is background using unmasked tiles, plane 1 is foreground and uses masked tiles, and plane 2 is sprite/info. Levels must contain a background plane and usually an infoplane.

Offset Type Name Description
0 UINT32LE offPlane0 Offset in GAMEMAPS to beginning of compressed plane 0 data (or 0 if plane is not present)
4 UINT32LE offPlane1 Offset in GAMEMAPS to beginning of compressed plane 1 data (or 0 if plane is not present)
8 UINT32LE offPlane2 Offset in GAMEMAPS to beginning of compressed plane 2 data (or 0 if plane is not present)
12 UINT16LE lenPlane0 Length of compressed plane 0 data (in bytes)
14 UINT16LE lenPlane1 Length of compressed plane 1 data (in bytes)
16 UINT16LE lenPlane2 Length of compressed plane 2 data (in bytes)
18 UINT16LE width Width of level (in tiles)
20 UINT16LE height Height of level (in tiles)
22 char[16] name Internal name for level (used only by editor, not displayed in-game. null-terminated)

Note that for Wolfenstein 3D, a 4-byte signature string ("!ID!") will normally be present directly after the level name. The signature does not appear to be used anywhere, but is useful for distinguishing between v1.0 files (the signature string is missing), and files for v1.1 and later (includes the signature string).

Carmack compression

Carmack compression is the method used to compress later id Software games, when file size was still a concern. It is the most efficient and complex compression method and was created specifically to work with the 16-bit word structure of the GameMaps file. The compression is detailed on its own page.

Carmackized game maps files are external files and the map header is stored internally in the executable. The map header must be extracted and the game maps decompressed before TED5 can access them. TED5 itself can produce carmackized files and external files. Carmackization does not replace the RLEW compression used in uncompressed data, but compresses this data, that is, the data is doubly compressed.

Note that for Wolfenstein 3D v1.0, map files are not carmackized, only RLEW compression is applied.

Huffman compression

Huffman Compression was probably used by earlier versions of TED5 (but possibly not TED5 at all) before carmackization was introduced. It uses the same method to compress its data as is used by id Software games to compress their graphics and sounds. Again this compression method works with RLEW compressed data and has its own page.

Huffman compression is easily detected since it works on the bit level and thus disrupts the word structure of the game data. This is easily seen in a hex editor. Compressed data will not contain the string $00 $00 or indeed even $00 very often. (In contrast, even carmackized data contains both strings hundreds of times.)

There will be two internal files for this format: the map header and the Huffman dictionary (which is always the first dictionary in the executable.) The map header format is also slightly different, being 502 bytes long, the extra 100 bytes being the length of the compressed level headers in the game maps data, which occur immediately after the normal level header offsets and before the tileinfo. Each entry is one octet indicating the decompressed header length in bytes or zero if the level does not exist. (These can be ignored when decompressing since Huffman data can be read until the decompressed level header's fixed size is reached, but if they are omitted when writing the MAPHEAD, the game may experience a buffer overflow when reading the maps.)

Location of internal files

The GAMEMAPS file itself is always external, but in the case of compression, the MAPHEAD is stored internally in the main .exe file. Executables are themselves compressed with either with LZEXE or PKLite. Once the .exe has been decompressed it is a trivial task to find the MAPHEAD as it will start with the UINT16LE value $ABCD (i.e. the byte $CD followed by the byte $AB.) For level editing purposes only the first 402 (or 502) bytes of the file need to be extracted, though it is possible to read the MAPHEAD file to calculate its length.

The following table lists the offsets of the MAPHEAD file for various games, relative to the start of the decompressed game .exe file.

! TODO: Add all known versions of all games

Game Version Location Filename Offset Notes
Bio Menace Freeware External MAPHEAD.BM[123] -
Blake Stone: Aliens of Gold Shareware External MAPHEAD.BS1 -
Blake Stone 2: Planet Strike All External MAPHEAD.VSI -
Catacomb 3-D (3) 1.00 Internal CAT3D.EXE $1C570 After UNLZEXE
Catacomb Abyss (4) 1.13 Internal CATABYSS.EXE $1C510 After UNLZEXE
Catacomb Armageddon (5) 1.01a Internal CATARMA.EXE $1D900 After UNLZEXE
Catacomb Apocalypse (6) 1.00b Internal CATAPOC.EXE $1DD50 After UNLZEXE
Corridor 7 Alien Invasion Demo External MAPHEAD.DMO -
CD Internal CORR7CD.EXE $30D50 File is not compressed
Floppy Internal C7.EXE $24BF0 File is not compressed
Keen 4 Special Demo  ?  ?  ? File is PKLite compressed
1.4 EGA Internal KEEN4E.EXE $24830 After UNLZEXE
Keen 5 1.4 EGA Internal KEEN5E.EXE $25990 After UNLZEXE
Keen 6 1.4 EGA Internal KEEN6.EXE $25080 After UNLZEXE
Commander Keen Dreams 1.13 Internal  ? $1FA50 After UNLZEXE
Noah's Ark 3D All External  ? -
Operation Body Count All External MAPHEAD.BC -
Spear of Destiny All External MAPHEAD.SOD -
Wolfenstein 3-D Shareware External MAPHEAD.WL1 -
Registered External MAPHEAD.WL6 -


  • TED5 can edit the GAMEMAPS format of any games that use it. It is the original editor used to create these files.


This file format was reverse engineered by Andrew Durdin (adurdin). If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)