GAMEMAPS format

Tools, assembly, and file formats.
Post Reply
User avatar
Malvineous
Posts: 113
Joined: Sat Mar 13, 2004 12:54 am
Location: Brisbane, Australia
Contact:

GAMEMAPS format

Post by Malvineous »

Hi all,

I'm looking through the ModdingWiki page on the Gamemaps format and it's a little light on detail.

Is there any information around on:
  • Which games use no compression, Carmackization, RLEW and/or Huffman coding?
  • What format each level plane is in? I could only find the OmniSpeak code online and it looks like each compression algorithm has a uint16 at the start giving the decompressed size (I assume) but it would be good to confirm this. There's no detail on what the uint16 values in the map layer represent or how they map back to map tiles.
  • The RLEW compression page says the RLE code is "usually" 0xFEFE but then on the Gamemaps page it says the RLE flag is 0xABCD. In the OmniSpeak code it almost looks like this isn't a flag but is the RLE code word to use instead of 0xFEFE. Can anyone confirm how this works? Can you change 0xABCD in the Maphead file to use a different RLEW code word in the Gamemaps file?
Many thanks!
User avatar
K1n9_Duk3
Posts: 13
Joined: Tue Jan 19, 2021 9:57 pm

Re: GAMEMAPS format

Post by K1n9_Duk3 »

I think ervery single iteration of the GAMEMAPS format is RLEW-compressed, at least in the original games from the 90s (source code modifications or heavily patched mods could possibly omit that).

The MAPTEMP.* variation of the format should always be RLEW-only, while the GAMEMAPS.* files are usually either Huffman- or Carmack-compressed on top of the RLEW compression.

Huffman-Encoding for the GAMEMAPS file is only used by Keen Dreams and Dangerous Dave 3 & 4.

Rescue Rover 2 (v1.22), despite using the same user interface as Keen Dreams, is already using Carmack-Compression.

During development, any game would have used the MAPTEMP format, just to make playtesting faster and easier. TED5 had options to lauch the game and make it play the level that was currently being edited, and that option only saves to MAPTEMP. Saving to GAMEMAPS was a different menu option entirely ("Carmacize Maps"). I don't think TED5 could even open the compressed GAMEMAPS files.

I know that BioMenace (and the BioHazard beta) are loading the map data from the MAPTEMP files. They also come with GAMEMAPS files, but those are practically empty and there is no MAPHEAD data for them (its maphead would have been in an .OBJ file that was supposed to be linked into the executable when compiling. Some versions of Wolf3D (and other games based on its engine) might also use MAPTEMP instead of GAMEMAPS.

The distinction between Huffmanized and Carmacized maps is relatively easy: If the game has a MAPDICT, it uses Huffman, otherwise it may or may not use Carmack compression. If you want to support mods, then you can't just assume pure RLEW for MAPTEMP files and Carmack/Huffman + RLEW for GAMEMAPS files. Atroxian Realm (as well as the current build of Foray in the Forest) uses Carmack-Compression despite using the MAPTEMP file name. It's better to check the first two UINT16LE values of the compressed level plane data to be sure. If the file is using RLEW only, then the first UINT16LE should match the size of the level plane in bytes (i.e. mapwidth * mapheight * 2). If the file is using Carmack-compression, the second value should match the plane size in bytes.


The fully decompressed map planes are an array of mapwidth * mapheight UINT16LE values, stored as rows, left to right, top to bottom. What each map plane is used for may vary from game to game, but since they were created and edited with TED5, the default visualisation scheme is this: The numbers in plane 0 are tile numbers for the TILE16 tileset. The numbers in plane 1 are tile numbers for the TILE16M tileset. Plane 2 is used as the info layer for most games, so that's where spawn points for the game objects are placed. The infoplane also uses some of the tiles in the TILE16M tileset to display icons in TED5, but there is other data as well, like coordinates that link switches to the spot they are supposed to change when the player uses them. TED5 had an option the change the number of TILE16M values to be reserved as infoplane icons, but this value was stored in a file that usually wouldn't be shipped with the game. Trying to display any infoplane value <= 255 with the corresponding TILE16M tile should be fine, since most games rarely use more than 100-ish icons anyway. Any larger value is usually a link or whatever other data the designers decided to place in the level file.


Id Software used pretty much the same implementation of the RLEW compression scheme from Slordax/Keen 1 up to Wolf3D. In the early games, the RLEW tag is hard-coded to 0xFEFE right inside the RLEW routines. Starting with Keen Dreams, the code was altered and required the caller of the RLEW routines to pass a the desired RLEW tag as a parameter. The RLEW tag for the GAMEMAPS/MAPTEMP file is the UINT16LE value found at the beginning of the MAPHEAD file/data. The games will use that value for RLEW expansion when loading the level data from the maps file.

Saved games in Keen Dreams and Keen 4-6 also use RLEW compression for the level planes (no Huffman- or Carmack-compression, though!) and those Save and Load routines always pass 0xABCD as the RLEW tag, no matter what the MAPHEAD says. Once again, modded games may behave differently.
User avatar
Malvineous
Posts: 113
Joined: Sat Mar 13, 2004 12:54 am
Location: Brisbane, Australia
Contact:

Re: GAMEMAPS format

Post by Malvineous »

This is extremely useful, many thanks! I will put all the info in the ModdingWiki. If you have further details about Carmackization please feel free to update the page.

The Gamemaps page says Wolf3D v1.0 is not compressed, but then later it says v1.0 maps are not Carmackized, only RLEW compressed. Do you know which one is correct? Apparently it uses MAPTEMP.xxx and you have said that MAPTEMP files should always be RLEW-only so it looks like they are compressed just with RLEW but if this is wrong please let me know.
User avatar
K1n9_Duk3
Posts: 13
Joined: Tue Jan 19, 2021 9:57 pm

Re: GAMEMAPS format

Post by K1n9_Duk3 »

I downloaded the shareware version of Wolf3D v1.0 from classicdosgames.com for a quick test. As I suspected, the MAPTEMP.WL1 file is only compressed with RLEW. There's no Carmackization in that version.
Post Reply