Posted February 09, 2021
Looking through the files in the games directory and working out how to read them for modding I thought I would share the progress made so far. The idea it to enable more parts of the game to be modded.
IMG Files
These IMG files contain all the icons and buttons in the menu all uncompressed bitmaps in hi-colour format, apart from the large title image and the backgrounds which are TGAs.
DWORD unknown (always a value of 100)
DWORD width
DWORD height
folowed by blocks of WORD[width * height]
read until the file end, always seems to have a even multiple of blocks
each word is arranged as a 16 bit (15 bit of colour plus alpha) RGB
format: arrrrrgg gggbbbbb
where a is an unused alpha bit, r is red, g is green and b is blue
images are stacked, so button icons tend to be in the following order:
normal, onhover, onclick
following the used images blocks there seems to be a set of blacks empty blocks of equal size, with the exception of the unit icons where the land raider icon is on the second black block.
TIL Files
TIL files contain the map tiles that are referenced by the map (MPP) files.
TIL contains a 30 byte string header
followed by the number of tiles the file contains DWORD
a tile set type in a second DWORD
followed by a tile set x 1024 WORDS of pixel data
followed by a a tile sets x WORD of single pixel colors
ended with a tile set x byte that is an enum for a tile type
Pixels have the same format as the IMG files. the 1024 pixels are only the tile itself with zero boundary, to print the pixels as an image you need to print the pixels to their location in the tile, the order of the pixels is left to right, top to bottom (e.g. for the flat tile pixel 0 and 1 is the top row, then 2,3,4,5,6,7 for the next row etc...). I've not yet worked out if a byte indicates if a tile is flat or sloped (maybe this is in the map file).
The tile type is one of:
OPEN = 0
ROUGH = 1
ROAD = 2
IMPASSIBLE_TO_VEHICLES = 3
IMPASSIBLE = 5
BUILDING = 6
The tileset types is one of:
HILLS = 2
RIVERS = 0
LVFILE = 3
MPP Files
30 byte string header
a byte of the value 0x1A
15 bytes of some sort of parameter
2 bytes for the map width (always 71)
2 bytes for the map height (always 78, to allow hills in the fore and backgrounds to the playable area)
Followed by up to 14 tileset files slots
8 bytes for the filename (empty slots have the string !EMPTY!
1 byte with unknown purpose
Following is the map data 71 x 78 WORDS
Each WORD contains the following data bits xyiiiiii illltttt
* t is a 4 bit tileset
* l is a 3 bit elevation
* i is a 7 bit tile index
* x is a flag to flip the tile horizontally
* y is a flag to flip the tile vertically
The next WORD at address 0x2BF6 has the number of map features
Each Feature has 34 bytes
8 bytes for name string, followed by as yet unknown attributes.
The next block looks to contain an image for the mini-map
The the final 28 bytes contain the string for the map name.
CEL
CEL files contain all the buildings, weapons, explosions, smoke and vehicles sprites
After a 30 byte header
A DWORD with the filesize
A DWORD for segment intervals (equal to segment_count + 1)
# Each segment interval has a DWORD for a file offset
Following the segment intervals, there are the sprites
Each sprite has a DWORD for segment length, then 5 WORDS:
X_OFFSET
Y_OFFSET
UNKNOWN
SPRITE_WIDTH
SPRITE_HEIGHT
followed by the segment length - 9 (bytes) of run data
a run starts with two WORDS for:
X_INDEX and Y_INDEX in two's complement format
followed a WORD for pixel count
followed by the pixel count number of pixels, in the same 15-bit hi-color RGB format as explained for the IMG files.
A run starts at the position (X_OFFSET + X_INDEX, Y_OFFSET + Y_INDEX) with each following pixel incrementing the x value by one. Pixels that are not part of any run are transparent. The Offset value is used to align animated sprites where their width and height varies in size (e.g. an explosion which as it turns to smoke gets taller)
MEL
MEL files are the sound effects for unit selection, movement, shooting, hits and explosions. These files have a 12 byte header followed by a one channel 16-bit audio played at 22050 samples per second.
MUS
These are the music files, they are just raw audio, no header, and a unknown number of channels (not 1 or 2) with 16-bit audio played at 44.1kHz. The channels are not interlaced with one complete channel as a block, before the track appears to loop
IMG Files
These IMG files contain all the icons and buttons in the menu all uncompressed bitmaps in hi-colour format, apart from the large title image and the backgrounds which are TGAs.
DWORD unknown (always a value of 100)
DWORD width
DWORD height
folowed by blocks of WORD[width * height]
read until the file end, always seems to have a even multiple of blocks
each word is arranged as a 16 bit (15 bit of colour plus alpha) RGB
format: arrrrrgg gggbbbbb
where a is an unused alpha bit, r is red, g is green and b is blue
images are stacked, so button icons tend to be in the following order:
normal, onhover, onclick
following the used images blocks there seems to be a set of blacks empty blocks of equal size, with the exception of the unit icons where the land raider icon is on the second black block.
TIL Files
TIL files contain the map tiles that are referenced by the map (MPP) files.
TIL contains a 30 byte string header
followed by the number of tiles the file contains DWORD
a tile set type in a second DWORD
followed by a tile set x 1024 WORDS of pixel data
followed by a a tile sets x WORD of single pixel colors
ended with a tile set x byte that is an enum for a tile type
Pixels have the same format as the IMG files. the 1024 pixels are only the tile itself with zero boundary, to print the pixels as an image you need to print the pixels to their location in the tile, the order of the pixels is left to right, top to bottom (e.g. for the flat tile pixel 0 and 1 is the top row, then 2,3,4,5,6,7 for the next row etc...). I've not yet worked out if a byte indicates if a tile is flat or sloped (maybe this is in the map file).
The tile type is one of:
OPEN = 0
ROUGH = 1
ROAD = 2
IMPASSIBLE_TO_VEHICLES = 3
IMPASSIBLE = 5
BUILDING = 6
The tileset types is one of:
HILLS = 2
RIVERS = 0
LVFILE = 3
MPP Files
30 byte string header
a byte of the value 0x1A
15 bytes of some sort of parameter
2 bytes for the map width (always 71)
2 bytes for the map height (always 78, to allow hills in the fore and backgrounds to the playable area)
Followed by up to 14 tileset files slots
8 bytes for the filename (empty slots have the string !EMPTY!
1 byte with unknown purpose
Following is the map data 71 x 78 WORDS
Each WORD contains the following data bits xyiiiiii illltttt
* t is a 4 bit tileset
* l is a 3 bit elevation
* i is a 7 bit tile index
* x is a flag to flip the tile horizontally
* y is a flag to flip the tile vertically
The next WORD at address 0x2BF6 has the number of map features
Each Feature has 34 bytes
8 bytes for name string, followed by as yet unknown attributes.
The next block looks to contain an image for the mini-map
The the final 28 bytes contain the string for the map name.
CEL
CEL files contain all the buildings, weapons, explosions, smoke and vehicles sprites
After a 30 byte header
A DWORD with the filesize
A DWORD for segment intervals (equal to segment_count + 1)
# Each segment interval has a DWORD for a file offset
Following the segment intervals, there are the sprites
Each sprite has a DWORD for segment length, then 5 WORDS:
X_OFFSET
Y_OFFSET
UNKNOWN
SPRITE_WIDTH
SPRITE_HEIGHT
followed by the segment length - 9 (bytes) of run data
a run starts with two WORDS for:
X_INDEX and Y_INDEX in two's complement format
followed a WORD for pixel count
followed by the pixel count number of pixels, in the same 15-bit hi-color RGB format as explained for the IMG files.
A run starts at the position (X_OFFSET + X_INDEX, Y_OFFSET + Y_INDEX) with each following pixel incrementing the x value by one. Pixels that are not part of any run are transparent. The Offset value is used to align animated sprites where their width and height varies in size (e.g. an explosion which as it turns to smoke gets taller)
MEL
MEL files are the sound effects for unit selection, movement, shooting, hits and explosions. These files have a 12 byte header followed by a one channel 16-bit audio played at 22050 samples per second.
MUS
These are the music files, they are just raw audio, no header, and a unknown number of channels (not 1 or 2) with 16-bit audio played at 44.1kHz. The channels are not interlaced with one complete channel as a block, before the track appears to loop
Post edited March 02, 2021 by darkshadow42