Neverwinter Nights:BIF File Format

From TBotR Wiki

Introduction

A BIF contains multiple resources (files). It does not contain information about each resource's name, and therefore requires its KEY file.

Structure

Header
Variable Resource Table
Fixed Resource Table
Variable Resource Data
Fixed Resource Data

Header

(size 20 bytes)

Offset Value Type Description
0 FileType CHAR [4] "BIFF"
4 Version CHAR [4] "V1 "
8 VariableResourceCount UINT32 Number of variable resources in this file
12 FixedResourceCount UINT32 Number of fixed resources in this file
16 VariableTableOffset UINT32 Byte position of the Variable Resource Table from the beginning of this file. Currently, this value is 20.

Variable Resource Table

(size 16 bytes * VariableResourceCount)

The Variable Resource Table has a number of entries equal to the VariableResourceCount specified in the Header.

Variable Resource Entry

Offset Value Type Description
0 ID UINT32 A unique ID number. It is generated as follows:

Variable ID = (x << 20) + y

x = [Index of this BIF in its Key file's File Table]
y = [Index of this Resource Entry]
(<< means bit shift left)

Note: This ID must match the ID in the corresponding KEY file.

4 Offset UINT32 The location of the variable resource data. This is a byte offset from the beginning of the BIF file into the Variable Resource Data block.
8 FileSize UINT32 File size of this resource. Specifies the number of bytes in the Variable Resource Data block that belong to this resource.
12 ResourceType UINT32 Resource type of this resource

Fixed Resource Table

(size 20 bytes * FixedResourceCount)

NOTE: This block is actually not implemented. Support for Fixed Resources is available, as the offset is left in the BIF header, but there is currently nothing implemented. As a result, there is no existing data type for this. Below is what would conceptually become the Fixed Resource Table.

The Fixed Resource Table has a number of entries equal to the FixedResourceCount specified in the Header. If it has one or more elements, it is located immediately after the end of the Variable Resource Table. If there are no fixed resources, then this block is not present at all and the Variable Resource Data block immediately follows the Variable Resource Table.

Fixed Resource Entry

Offset Value Type Description
0 ID UINT32 A unique ID number. It is generated as follows:

Fixed ID = (x << 20) + (y << 14)

x = [Index of this BIF in its Key file's File Table]
y = {Index of this Resource Entry]
(<< means bit shift left)

Note: This ID must match the ID in the corresponding KEY file.

4 Offset UINT32 The location of the fixed resource data. This is a byte offset from the beginning of the BIF file into the Fixed Resource Data block.
8 PartCount UINT32 Number of parts
12 FileSize UINT32 File size of this resource
16 ResourceType UINT32 Resource type of this resource

Variable Resource Data

The Variable Resource Data block contains raw bytes of data pointed to by the Offset values in the Variable Resource Table.

Fixed Resource Data

Fixed Resource Parts (as defined in the Fixed Resource Table).

Personal tools