Commander Keen 1-3 Level format

From ModdingWiki
Jump to navigation Jump to search
Commander Keen 1-3 Level format
File:Commander Keen 1-3 Level format.png
There is no image of a map in this format — upload one!
Format typeMap/level
Map type2D tile-based
Layer count2
Viewport (pixels)320×200
Games

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.

Compressed

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.

Offset Length Name Note
0 4 Decompressed Size always divisible by four
4 Level Data (see below)

Header

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.

Offset Length Name Note
0 2 Level Width
2 2 Level Height
4 2 Number of Planes always 2
6 4 Blank appears to always be zero
10 4 TED Variables ignored
14 2 Plane Size 2(h * w) rounded to the next highest multiple of 16
16 16 Unknown ignored

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.

Offset Length Name
32 Plane Size Tiles
32 + Plane Size Plane Size Sprites

Notes

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.