BIFF file format

Applies to:
BG1, BG1: TotS, BG2, BG2: ToB, PST, IWD, IWD:HoW, IWD:TotL, IWD2

File versions
BIF (BG1, IWD1, PST)
BIFC (IWD1)
BIFC 1.0 (BG2)

General Description
This file format is a simple archive format, used mainly both to simplify organization of the files by grouping logically related files together (especially for areas). There is also a gain from having few large files rather than many small files, due to the wastage in the FAT and NTFS file systems. BIF files containing areas typically contain:
  • one or more WED files, detailing tiles and wallgroups
  • one or more TIS files, containing the tileset itself
  • one or more MOS files, containing the minimap graphic
  • 3 or 4 bitmap files which contain one pixel for each tile needed to cover the region

The bitmaps are named xxxxxxHT.BMP, xxxxxxLM.BMP, xxxxxxSR.BMP and optionally xxxxxxLN.BMP.
  • xxxxxxHT.BMP: Height map, detailing altitude of each tile cell in the associated wed file
  • xxxxxxLM.BMP: Light map, detailing the level and colour of illumination each tile cell on the map. Used during daytime
  • xxxxxxLN.BMP: Light map, detailing the level and colour of illumination each tile cell on the map. Used during night-time
  • xxxxxxSR.BMP: Search Map, detailing where characters cannot walk, and the footstep sounds

Overall structure:

Note that the data of the contained files might be after the header, and the file/tileset entries after the contained files. The offset to the file entries and the offset to each contained file should be used to know the exact location of each.



Offset Size (data type) Description
0x0000 4 (char array) Signature ('BIFF')
0x0004 4 (char array) Version ('V1  ')
0x0008 4 (dword) Count of file entries
0x000c 4 (dword) Count of tileset entries
0x0010 4 (dword) Offset (from start of file) to file entries


Offset Size (data type) Description
0x0000 4 (dword) Resource locator
NB: On disk, only bits 0-13 are matched. 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.
0x0004 4 (dword) Offset (from start of file) to resource data
0x0008 4 (dword) Size of this resource
0x000c 2 (word) Type of this resource
0x000e 2 (word) Unknown


Offset Size (data type) Description
0x0000 4 (dword) Resource locator
NB: 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.
0x0004 4 (dword) Offset (from start of file) to resource data
0x0008 4 (dword) Count of tiles in this resource
0x000c 4 (dword) Size of each tile in this resource
0x0010 2 (word) Type of this resource (always 0x3eb - TIS)
0x0012 2 (word) Unknown




BIFC V1 file format
Overall structure:
  • Header
  • Compressed file data
  • This format is identical to the SAV file format, except for the signature and version fields. 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.


    Offset Size (data type) Description
    0x0000 4 (char array) Signature ('BIF ')
    0x0004 4 (char array) Version ('V1.0')
    0x0008 4 (dword) Length of filename
    0x000c (ASCIIZ char array) Filename (length specified by previous field)
    sizeof(filename)+0x000C 4 (dword) Uncompressed data length
    sizeof(filename)+0x0010 4 (dword) Compressed data length
    sizeof(filename)+0x0014 Variable (raw data) Compressed data




    BIFC V1.0 file format
    Overall structure:
    The file is broken up into blocks (usually 8192 bytes each), which are compressed separately. Each block consists of an uncompressed size and a compressed size, and then the zlib compressed data.


    Offset Size (data type) Description
    0x0000 4 (char array) Signature ('BIFC')
    0x0004 4 (char array) Version ('V1.0')
    0x0008 4 (dword) Uncompressed BIF size


    Offset Size (data type) Description
    0x0000 4 (dword) Decompressed size
    0x0004 4 (dword) Compressed size
    0x0008 varies (bytes) Compressed data