BIFF files

Description

This is a simple archive format, used both to simplify organization of the files, as well as to group together entire areas. Some BIF files are grouped together because of common functionality; for instance, all the .dlg files are gathered together into a single BIF file in Planescape: Torment. Other bif files, such as AR4800.BIF represent the entirety of an area's terrain (i.e. not its containers, actors, or items). These BIF files contain, typically:

The three (or four) bitmaps, are named xxxxxxHT.BMP, xxxxxxLM.BMP, xxxxxxSR.BMP, and (when there are four bitmaps) xxxxxxLN.BMP.

BIFF file versions

BIFF V1

Overall structure

BIFF V1 Header

OffsetSize (datatype)Description
0x00004 (char array)Signature ('BIFF')
0x00044 (char array)Version ('V1 ')
0x00084 (dword)Number of file entries
0x000c4 (dword)Number of tileset entries
0x00104 (dword)Offset of file entries (from start of file). Tileset entries, if any, immediately follow the file entries.

BIFF V1 File Entries

OffsetSize (datatype)Description
0x00004 (dword)Resource locator (Note: On disk, only bits 0-13 are matched upon. They are matched against the file index in the "resource locator" field from the KEY file resource entries which claim to exist in this BIFF.
0x00044 (dword)Offset to resource data from start of file
0x00084 (dword)Size (in bytes) of this resource (file).
0x000c2 (word)Type of this resource. (See the table of resTypes for a list of which values are applicable to this field
0x000e2 (word)Unknown. Part of the previous field? (Or only used in the memory image?)

BIFF V1 Tileset Entries

OffsetSize (datatype)Description
0x00004 (dword)Resource locator (Note: On disk, only bits 14-19 are matched upon. They are matched against the tileset index in the "resource locator" field from the KEY file resource entries which claim to exist in this BIFF.
0x00044 (dword)Offset to resource data from start of file
0x00084 (dword)Number of tiles in this resource (file).
0x000c4 (dword)Size (in bytes) of each tile in this resource (file).
0x00102 (word)Type of this resource. (These resources are always type 0x3eb -- .tis files, but see the table of resTypes for a list of which values are applicable to this field
0x00122 (word)Unknown. Part of the previous field? (Or only used in the memory image?)

BIFF V1 (compressed)

Overall structure

This format is idential to the SAV file format, except for the first 8 bytes, which are 'BIF V1.0' for these files, and 'SAV V1.0' for SAV files. The data, once uncompressed, is formatted as a normal BIF file, as seen above. Note that the SAV files can hold more than one compressed file. It is unknown whether this occurs also in CBF files. The compressed format is as follows:

Compressed BIFF V1

OffsetSize (datatype)Description
0x00004 (char array)Signature ('BIF ')
0x00044 (char array)Version ('V1.0')
0x00084 (dword)Length of filename
0x000cvariable (ASCIIZ char array)Filename (length specified by previous field)
sizeof(filename)+0x00104 (dword)uncompressed data length
sizeof(filename)+0x00144 (dword)compressed data length
sizeof(filename)+0x0018variable (raw data)compressed data (length in bytes specified by previous field)

BIFC V1.0 (compressed)

Overall structure

The file is broken up into blocks (typically 8192 bytes apiece), which are compressed separately. The blocks are stored one right after another, immediately after the header. Each block consists of an uncompressed size and a compressed size, and then the data, compressed by zlib. Here is some C code which uses zlib to decompress BIFC files.

BIFC V1.0 header

OffsetSize (datatype)Description
0x00004 (char array)Signature ('BIFC')
0x00044 (char array)Version ('V1.0')
0x00084 (dword)Uncompressed BIF size

BIFC V1.0 compressed blocks

OffsetSize (datatype)Description
0x00004 (dword)Decompressed size
0x00044 (dword)Compressed size
0x0008varies (bytes)Compressed data

[ back to index ]