Wing Commander 3 BUN

From XentaxWiki
Jump to: navigation, search

BUN

BUN files are found on the 3DO version of Wing Commander III (in contrast to the PC version which uses TRE files).

Format Specifications

A BUN resource begins as follows:

 bytes 0-3    'FORM'
 bytes 4-7    total length of resource file, minus this 8-byte preamble
 bytes 8-11   'BUND'

Next, the file is comprised of a series of chunks with the following structure:

 bytes 0-3    chunk tag
 bytes 4-7    chunk length, not including 8-byte preamble
 bytes 8..    chunk payload

There are 2 known tags: 'DIR_' and 'FILE'. The 'DIR_' chunk contains a 12-byte record for each 'FILE' chunk in the resource:

 bytes 0-3    this appears to be a checksum/hash of the file; algorithm unknown
 bytes 4-7    absolute offset of 'FILE' chunk payload (not beginning of 'FILE' chunk itself)
 bytes 8-11   length of 'FILE' chunk payload (again, not length of entire 'FILE' chunk)

The remainder of the file is comprised of 'FILE' chunks. If a BUN resource contains 11 files, there will be 12 records in the 'DIR_' chunk and 12 corresponding 'FILE' chunks. Why the extra record? The first 'FILE' chunk contains filename information. The payload of this file chunk contains free-form strings separated by line-feed (ASCII 0xA) characters. The format of this payload appears to be:

compression_type = 0<lf><resource file name><lf><first file path and name><lf><second file path and name><lf> ... <lf><final file path and name>

Note that a directory path often precedes the filename. The rest of the 'FILE' chunks in the file simply have their represented raw file as the chunk payload.

MultiEx BMS Script

Not written yet

Compatible Programs

None yet