Battle Isle / History Line library format

From ModdingWiki
Jump to navigation Jump to search
Battle Isle / History Line library format
Format typeArchive
Max files
File Allocation Table (FAT)At the end of the file
Filenames?Yes
Metadata?None
Supports compression?Yes
Supports encryption?No
Supports subdirectories?No
Hidden data?No
Games

Battle Isle and History Line 1914-1918 use library files in the same file format to store bitmap graphics such as terrain and unit graphics. These files are located in the game's LIB subdirectory and also have the *.lib file extension.

Compression

The library files are compressed using TPWM compression. Either the complete archive file is compressed once, or the contained bitmaps are compressed individually.

*.lib file format

The files consist of two sections, the data section and an Idex or FAT to allocate the contained files. The first four bytes of the file contain the offset to the first entry of the index or FAT as UINT32LE.

The index/FAT itself consists of 12 byte entries for each contained file/resource. The structure of the entries is as follows:

Data type Description
char[8] Name of the resource / file name (without extension)
UINT32LE Offset to the resource / file

The order of the graphics in the archives does not correspond to the numbers used to denote terrain and units in the games. There are compagnion files for this, with the same name as the .lib file, but with the extension .dat. These simply contain the names of the graphics in an order that corresponds to the numbering in the game, e.g. in the map files.

Bitmap format

The bitmaps are stored in a separate format, which is minimally different for Battle Isle and History Line 1914-1918:

History Line 1914-1918

There are two different types of bitmaps used in the game: 256 colors / 8 bits per pixel, which are used for terrain tiles and fonts and (16 colors / 4 bits per pixel) for the unit graphics and the black and white photos from the 1st World War. All bitmaps start with a header:

Data type Description
char[8] ID String "INFOILBM" or "ILBM "
UINT8 Background color that should not be displayed
UINT8 Bitmap type (0x50 = 4 bits per pixel, 0x55 = 8 bits per pixel)
UINT16LE Unknown / Padding (always 0)
UINT16LE Unknown / Padding (always 0)
UINT16LE Width of the image in pixels
UINT16LE Height of the image in pixels

This header is followed by the image data. All bitmaps of History Line 1914-1918 use four pixel bitplanes and no further compression like RLE or similar.

Example:

The bitmap for a terrain tile is 24x24 pixels and stored with 8 bpp.

Byte 0 contains the color for pixel 0/0 Byte 1 the one for pixel 4/0 Byte 2 the one for pixel 8/0 Byte 3 the one for pixel 12/0 Byte 4 the one for pixel 16/0 Byte 5 the one for pixel 20/0

Then the next line continues:

Byte 6 stands for pixel 0/1 Byte 7 for pixel 4/1 and so on

If a column is drawn, it is started again at the top, then with pixel 1/0 and so on.

For bitmaps with 4 bpp, such as the units, nibble are used accordingly and one byte stands for two pixels:

Byte 0 contains the colors for pixel 0/0 and 4/0 Byte 1 those for pixel 8/0 and 12/0 etc.

The color palettes can be found as *.pal files in the games main directory. These files simply contain 8 bit RGB values for all 256 colors of a VGA palette. The 8 bpp bitmaps are displayed correctly with these palettes, for the 4 bpp bitmaps different areas of the palette can be used:

Add 32 to each color value in the bitmap of a military unit to draw it as a German unit. Add 48 to draw it as a French unit. Add 64 for the sepia tones of the ancient photos (included in BIGUNIT.LIB).

Battle Isle

The structure of the bitmap resources in Battle Isle is very similar to History Line 1914-1918. However, the ID strings are somewhat different. Unit and terrain graphics also start with "INFO", but the next four characters are a shorthand or abbreviation of the graphic's name. Examples: "INFOBERG" ("Berg" is the German word for mountain) or "INFOFZA0". Larger images, on the other hand, also have an "INFOILBM" ID.

Also, Battle Isle seems to only have 8 bits per pixel bitmaps. Therefore, the meaning of the type byte in the header still needs to be clarified here. The bitmap data itself is encoded in the same way as the 8 bpp bitmaps from History Line 1914-1918.

Credits

This file format was reverse engineered by User:DragonSphere. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)