The GameMaps format is how the levels in a number of Id Software games is stored. The filenames and compression varies somewhat across different games but all files stored in this format were produced by the program TED5 or a close analogue.
There are two main components to the format, the game maps proper, which contain the game level data and the map headers, which contain both the locations of the start of level data in 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 3D. In this format map data is stored in MAPTEMP.xxx and map headers in MAPTHEAD.xxx this is the 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 3D uses GAMEMAPS.WLx and MAPHEAD.xxx files to store data. 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.
0 2 Magic word Magic word for RLEW compression 2 400 Level ptr 100 4-byte pointers to start of level 0-99 data in game maps file 402 ??? Tileinfo Tileinfo data
The map header file is of varying length and contains three main types of data. The first is the magic word or flag used for RLEW compression, it is always $ABCD. The second is 100 level pointers which give the location of the start of level data in the game maps file, relative to the start of that file. A value of 0 indicates no level. The third is the tileinfo data, 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 3D 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.
The game maps file consists of the string 'TED5v1.0.' and a number of RLEW compressed chunks of varying length. Each level in GameMaps will have from two to four chunks (usually four), depending on 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 or 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 map header file, which will point to the level header chunks which in turn contain pointers to the other chunks used by that level. It is possible the string at the start of the file is to avoid the possibility of a level header at the start of the file which would be read as not existing.
All data in game maps file is in the form of words (Or in the case of pointers, dwords.)
The header for each level that is pointed to by MAPHEAD is 42 bytes long and RLEW compressed, though this is difficult to see since the data is so short and nonrepetitive. For the offsets to level planes a value of 0 indicates the plane does not exist.
Plane 1 is background using unmasked tiles, plane 2 is foreground and uses masked tiles. Plane 3 is sprite or info. Levels must contain c background plane and usually an infoplane.
0 4 Offset in GAMEMAPS to beginning of compressed plane 0 data 4 4 Offset in GAMEMAPS to beginning of compressed plane 1 data 8 4 Offset in GAMEMAPS to beginning of compressed plane 2 data 12 2 Length of compressed plane 0 data (in bytes) 14 2 Length of compressed plane 1 data (in bytes) 16 2 Length of compressed plane 2 data (in bytes) 18 2 Width of level (in tiles) 20 2 Height of level (in tiles) 22 16 Internal name for level (used only by editor, not displayed in-game. null-terminated)
Carmack compression is the method used to compress later Id Software games, when file size was an issue. It is the most efficient and complex compression method and was created specifically to work with the word structure of the game maps file. The compression is detailed on its own page.
Carmackized game maps files are external GAMEMAPS.xxx 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 MAPHEAD.xxx files. Carmackization does not replace the RLEW compression used in uncompressed data, but compresses this data, that is, the data is doubly compressed.
Huffman compression was used by earlier versions of TED5 (possibly not TED5 at all.) before carmackization was created. 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 (These can be ignored when decompressing since huffman data can be read until the decompressed level header's fixed size is reached.)
Location of internal files
Game maps are always external, but in the case of compression the map header file is stored internally in the executable. Executables are themselves compressed wither with LZEXE or PKLite. Once decompressed it is a trivial task to find the map header file as it will start with the word $ABCD For level editing purposes only the first 402 (or 502) bytes of the file needs to be extracted, though it is possible to read the maphead file to calculate its length.
The following addresses are in the locations in the decompressed executables for the start of the Map header files. Values are different for different versions.
TODO: Add all known versions of all games.
Biomenace Blake Stone 2: Planet Strike Corridor 7 Demo Noahs Ark 3D Operation Body Count Spear of Destiny Wolfenstein 3D
Catacomb 3-D (1.00): $1C570 from start of file CAT3D.EXE (after file is UNLZEXE) Catacomb 4 Abyss (1.13): $1C510 from start of file CATABYSS.EXE (after file is UNLZEXE) Catacomb 5 Armageddon (1.01a): $1D900 from start of file CATARMA.EXE (after file is UNLZEXE) Catacomb 6 Apocalypse (1.00b): $1DD50 from start of file CATAPOC.EXE (after file is UNLZEXE) Corridor 7 CD (): $30D50 from start of file CORR7CD.EXE (file is not compressed) Corridor 7 Floppy (): $24BF0 from start of file C7.EXE (file is not compressed) Keen 4 (Special Demo): (file is PKLite compressed) Keen 4 (1.4): $24830 Keen 5 (1.4): $25990 Keen 6 (1.4): $25080 (Keen D (1.13): $1FA50)
TED5 This program can edit the GAMEMAPS format of any games that use it. It is the original editor used to crate these files.
This format was reverse engineered by Andrew Durdin (adurdin).
The format is used by other games as well, including Bio Menace, Blake Stone, Catacomb 3D, Catacomb Abyss, Corridor 7, Dangerous Dave 3, Dave Goes Nutz, Noah's Ark 3D, Operation Body Count, Spear of Destiny, and Wolfenstein 3D.