This document explains the format of the maps and the associated graphics
files. It has also a complete listing of all available map values.
This document is meant for people who want to make a C&C scenery editor.
You can also use it to edit manually the maps but IMHO it's a suicide if you
can't see what you are doing.
ABOUT .MIX FILES
First of all I will explain the structure of MIX files, since all the
graphics are in the TEMPERAT, DESERT, and WINTER.MIX files.
Each MIX file contains several internal files that can be extracted. I will
refer to the internal files as just "files".
The MIX file is made up of two parts: the first one is the Header, the
second one is the Body that contains all the files.
The structure of the header is:
(I will use pascal notation here)
Header = record
NumFiles : word; {Number of internal files}
BodyLength : longint; {Length of the body}
Index : array [1..NumFiles] of
record
ID : longint; {ID of file, computed from filename}
Start : longint; {Offset of file in the body}
Size : longint; {Size of the file}
end;
end;
Of course you can't use directly such a structure in pascal because its
length is not fixed.
Note that the offsets are relative to the start of the body so to find the
actual offset in the MIX you have to add the size of the header which is
NumFiles*12+6
Note also that the records in the Index are not in the same order as the
files are physically stored in the MIX. In this document I will always refer
to the record number in the index and not to the file's actual position in
the MIX.
ABOUT THE MAP
All the maps are 64x64 squares large. There are 2 bytes of information for
each square, thus the file is 8192 bytes long.
The two bytes indicate which image should be placed there. The first one
indicates in which of the internal files of TEMPERAT, DESERT or WINTER.MIX
it is. Each of these internal files contains several images; the second byte
tells which of those images should be taken. The images inside one of the
internal files, if put together, form a larger image. It can be a bridge,
a road section, etc. These are called "templates". Thus, each internal file
contains a template. Each template is made of several "tiles" (images).
Each square of the map contains one tile. It's not necessary to put all
the tiles of a template on the map.
There are templates of various sizes: from 1x1 to 6x8.
(I will always write the dimensions as WidthxHeight)
The tile numbers range from 0 to WxH-1.
However there are some tiles, which I call "empty tiles", that don't have
any images associated with them. If you try using them C&C will display
the default terrain for that Theater instead. There are empty tiles
especially in the corners of large templates.
An example may be useful:
The SW-NE bridge in the temperate theater has two empty tiles:
XXOr X - Empty tile O - other tiles
wbbO b - Bridge
Obbw w - Water (This is probably wrong, I can't check now)
rOOO r - road
We can see that in the upper left corner there are two empty tiles.
We can put the values 00 and 01 in our map (as the second byte; the first
would be A5h for the bridge), in that case we'll see some grass there. But
we can replace those two tiles with anything else without disturbing the
rest. What I mean, is that if we changed any other tile, a piece of river
would be missing or a rock could be cut, ruining the map; but if we
replace the empty tiles everything is OK.
So, when we have an empty tile, we can leave it there, or replace it with
anything else. There are two exceptions to this rule however:
1) Sometimes the empty tiles should be water, but if we don't replace them
C&C will show land in the middle of our lake or sea;
2) There are templates containing roads that finish in one of the corners,
so that the next template must have an empty tile in the opposite corner
to stick to the other.
An example might help:
Imagine that we have two road sections like these:
OOrr OOrr
Orrr Orrr
rrrO rrrO
rrOO rrOO
and we want to stick them diagonally:
OOrr
Orrr
rrrO
rrOO
OOrr
Orrr
rrrO
rrOO
Something is obviously missing. We need to add some tiles to fill it like
this:
OOrr
Orrr
rrrO
RrrOO
OOrrR
Orrr
rrrO
rrOO
The solution could be to have two templates like these:
OOOO ROOO
OOOO OOOO
OOOO OOOO
OOOR OOOO
or to have one little template with empty tiles:
RX
XR (Where X are empty tiles)
Now we can put this between the two road sections, replacing the empty
tiles with the corner tiles of the road sections.
There are many road sections like this and I've indicated them with
"(Conn.)" in the table at the end of this document.
ABOUT THE DESERT, TEMPERAT, and WINTER.MIX FILES
These are the files that hold the graphics for the templates. There's one
file inside the MIX for each template, and each file has several tiles
inside.
There are other files inside the MIXes, probably for the trees and other
overlay elements but I don't know the format. If somebody knows their
format, please let me know.
In each MIX there's also a palette, the entries are:
DESERT.MIX entry n. 26
TEMPERAT.MIX entry n. 62
WINTER.MIX entry n. 62
I will now explain the format of the files with map graphics.
First of all there's a header with the following structure:
Header = record
Width : word; {Width of images, always 24 (18h)}
Heigth : word; {Heigth of images, always 24}
NumTil : word; {Number of Tiles (may differ from num. of
Images}
Zero1 : word; {Seems to be always 0000h}
Size : longint; {size of file}
ImgStart : longint; {Offset of first image}
Zero2 : longint; {Seems to be always 00000000h}
ID1 : word; {Always FFFFh}
ID2 : word; {Always 1A0Dh (or 0D1Ah I can't remeber}
Index2 : longint; {Offset of Index2}
Index1 : longint; {Offset of Index1} {I will explain these
later}
end;
The images follow the header but I suppose they could be anywhere.
They are all 24x24 pixel, uncompressed and are one after the other.
Note that the number of images may differ from the number of tiles if
there are some empty tiles. If there are empty tiles, the actual number of
images can be smaller than the number of tiles. To work out the number
of images you can use the formula : (Index1-ImgStart)/(24*24).
However, you won't have to do this if the index is not corrupt.
Index1 has the following format:
Index1 : array [0..NumTil-1] of byte;
where NumTil is the number of tiles.
Each entry in Index1 corresponds to one tile, and indicates which image
(of that file) is associated with it. If the entry is FFh than that tile
is empty.
Index2 is an array of NumImages bytes where NumImages is the real
number of images in the file. However it's always filled with zeros
(sometimes there's a 1 somewhere but I don't know it's meaning).
Note that there's no way to know the dimensions (Width and Height) of the
template. If there are 6 tiles it could be 6x1, 1x6, 3x2, 2x3. I worked out
the dimensions of all templates myself (It's easy, all you have to do is to
try different widths and look at the screen).
For example a procedure that has to display template 61h, tile 3 of the
Desert theater would do:
1) Look in the table and find in which file it is in (entry 168 of
DESERT.MIX)
2) Open that file (seek it inside the MIX)
3) Read the Header
4) Read Index1 and read the 4th byte (for tile 3), let it be N
5) Seek ImgStart+Width*Height*N
6) Read the Image and display it
AND FINALLY THE TABLE
Here is the table of all available map values (template numbers), the
dimensions and the relative entries in the DESERT, WINTER, and TEMPERAT.MIX.
There's also a brief description for those that don't want or don't know
how to write an editor. However, I think that it will be difficult to stick
the templates together without seeing them.
An "x" means that the template doesn't exist in that theater. There are many
templates that exist only in one theater and will show as black holes in the
others (causing the HOM effect). The WINTER and TEMPERATE theaters are
however very similar, and differ only in a few templates.
The roads and cliffs are mostly the same for the three theaters, but be
careful about the river and coast templates because they are not the same.
!! Warning !!
Values from D8h-FEh will cause the game to crash (it just locks up on
my computer)!!!
The value FFh indicates the default terrain (I think the 4x4 template is
used).
Notes:
(0a) There may be some errors in this table because I typed it in a hurry
(you don't know how much time it takes), so if you find any errors
please report them to me.
(0b) The names are taken from the GAME.DAT file. I matched them with the
files in the theater mix files. The complete filenames are the names
above plus an extension that depends on the theater (.DES, .TEM, .WIN).
(1) For Coasts, WD, WU, WL, and WR mean : Water on the bottom
(Down), Top (Up), left and right.
(2) For cliffs and roads the two letters indicate from which to which side
the Road (or cliff) goes. The lowercase letter means up, down, left,
right to indicate in which part of that side it starts.
For Example:
River Wu-Ed :
OOOOO
rOOOO
OrrOO
OOOrr
OOOOO
(3) These templates exist in both the DESERT and the TEMPERATE theaters but
are not the same. I've put a description of both.
(4) For Roads:
Roads T and Y mean that the road splits in the shape of a T or a Y.
E--N+S means it starts from the east edge then splits in two parts, one
going to the north and the other to the south edge
(5) NW or any other corner means that the road ends in that corner and if it
says (Conn.), that means that it has an empty tile in that corner.
So you have to use the (Conn.) templates to stick together the other
ones.
(6) In TEMPERAT.MIX these two files are buggy, they report there are 67h
tiles, but if you look at the index you'll see they all point to the
second image which (I think) is of uniform color. Only the first tile is
ever used.
(7) These three templates don't work in C&C (HOM effect), but their graphics
exist in the DESERT.MIX file. Do not use them !
That's all. I hope this info will be used by somebody to make a scenery
editor.
Report any errors to me. Also, if you have any info about other file formats
please share it with me.