Commander Keen 1-3 Level format
The Commander Keen 1-3 level format was widely used in early id Software games, usually stored in the files LEVELxx.* (Usually with 8 or 16 levels.) The level files are usually compressed with RLEW compression, though earlier games omit this. The file is composed of three sections, the header, and the tile and sprite planes.
The compressed levels start with a dword giving the size of the decompressed level in bytes (always divisible by four) followed by the standard level data in RLEW compressed form. The rest of this page assumes decompressed data and uses offsets relative to the start of Level Data.
|0||4||Decompressed Size||always divisible by four|
|4||Level Data||(see below)|
The level header is 32 bytes long in total. Most of the header is (or was) used by TED v1.5 to load the level and its associated graphics and is not used by games per se. These fields can be left blank and nobody will care, since the original TED is long gone.
The plane size is interesting, since it has to be divisible by 16 because of how some game engines work. It is how many tiles are in each plane.
|4||2||Number of Planes||always 2|
|6||4||Blank||appears to always be zero|
|14||2||Plane Size||2(h * w) rounded to the next highest multiple of 16|
Sprite and tile planes
Each plane is an array of words, padded to plane size bytes with nulls. Each word is a tile, running from left to right, top to bottom. THe first plane is tiles, the second is sprites.
|32 + Plane Size||Plane Size||Sprites|
This format has been reverse engineered several times, always by the Commander Keen 1-3 modding community.
Dangerous Dave in Copyright Infringement appears to be the first game to use this format and has it uncompressed.