Command & Conquer Tileset Format

From ModdingWiki
Jump to: navigation, search
Command & Conquer Tileset Format
Command & Conquer Tileset Format.png
Format typeTileset
HardwareVGA
Max tile count254
PaletteShared between all tilesets in one theater
Tile names?No
Minimum tile size (pixels)24×24
Maximum tile size (pixels)24×24
Plane count1
Plane arrangementLinear
Transparent pixels?No
Hitmap pixels?No
Metadata?None
Supports sub-tilesets?No
Compressed tiles?No
Hidden data?Yes
Games

The Command & Conquer Tileset Format is an uncompressed tileset containing tiles with dimensions of 24x24. Technically, this tile size can be changed, but the game defines cells as 24x24, so changing it does not seem useful.

A single Command & Conquer "tileset" does not represent an entire map environment; it only contains the terrain tiles of a single piece of terrain. The full collection of tileset files that comprise one map environment are called a "Theater", and are combined into one .mix archive together with its colour palette and the theater-dependent terrain objects, civilian buildings, and fading table files.

File format

Header

Offset Data type Name Description
0x00 UINT16LE TileWidth Tile width. Should always be 24.
0x02 UINT16LE TileHeight Tile height. Should always be 24.
0x04 UINT16LE NrOfTiles Number of tiles. While this is an Int16 value, the game's map format can only access tiles up to index 255. Since tiles can be marked as empty, this value can differ from the number of actual images stored inside the file.
0x06 UINT16LE Zero1 Always zero.
0x08 UINT32LE Size Size of the entire file.
0x0C UINT32LE ImgStart Offset of the first image.
0x10 UINT32LE Zero2 Always zero.
0x14 UINT32LE ID1 Always 0xFFFF.
0x16 UINT32LE ID2 Always 0x0D1A.
0x18 UINT32LE IndexImagesInfo Offset of the images info array; an array containing one byte for each actual image in the file. It is unknown what these bytes mean; they are usually all just 0x00.
0x18 UINT32LE IndexTilesetImages Offset of the index linking each tile to the index of an actual image at ImgStart. This index is a UINT8[NrOfTiles]. Value 0xFF in the index indicates an empty tile.

Generally, the order of the data after the index is:

  1. ImgStart
  2. IndexTilesetImages
  3. IndexImagesInfo

Of course, since these are read from header values, their order has no real effect.

Note that there is no way to know the dimensions (Width and Height) of the full tileset. If there are 6 tiles it could be 6x1, 1x6, 3x2, or 2x3. The game doesn't actually need this information either, since the maps reference the individual tile indices inside the tileset files directly; the only tools that would actually need this information (besides image converters) are map editors.

The game's exe file does contain the dimension information of all tilesets, though, alongside the tilesets' other information, because the map editor used to be built into the game engine, and because the [Template] section in a mission file supports placing terrain tilesets from a mission file. This tileset information is available in the tilesets.ini file in Nyerguds' ini dump of the game's internal data. The Engie File Converter uses this ini file to determine the dimensions of C&C tileset files based on their file name.

Image Data

Since the tileset can contain empty entries, the actual amount of images following the ImgStart location should be determined by taking the maximum value (excluding any 255 values indicating empty tiles) in the the array at IndexTilesetImages, and adding 1 to it. Note that like in the game's fonts, identical images are generally saved only once, with the data referenced in the index multiple times, which further reduces the actual amount of images.

The image data is located at ImgStart. To look up the image data of a specific tile N, first check in the array at IndexTilesetImages what the image index of the tile is. If it is not 0xFF, the image data can be found at:

tileImageStart = ImgStart  + (TileWidth * TileHeight * fileData[IndexTilesetImages + N])

The image data will always be 24x24 bytes, and represents a simple 8-bit indexed image.

Tools

The following tools are able to work with files in this format.

Name PlatformView images in this format? Convert/export to another file/format? Import from another file/format? Access hidden data? Edit metadata? Notes
Engie File Converter WindowsYesYesYesNoN/A Uses internal mapping based on the file name to show the tile in its correct dimensions. Automatically saves tiles containing nothing but colour 0x00 as empty tiles.
XCC Mixer WindowsYesYesNoNoN/A Does not attempt to show the actual shape of the tileset, and just shows a list of tiles.
Mix Manager DOSYesYesYesNoN/A Conversion suite containing PCX2TMP and TMP2PCX tools for converting the tileset files.
RAMix DOSYesYesNoNoN/A Contains a TMP2PCX tool that can visualize the tileset file to adjust dimensions before converting to PCX. Does not contain a tool to convert back; you just have to use the one from Mix Manager.