Difference between revisions of "BFSAR (File Format)"

From MK8
Jump to navigation Jump to search
(STRG lookup table)
m (Removed broken link)
 
(7 intermediate revisions by 4 users not shown)
Line 8: Line 8:
 
== Header ==
 
== Header ==
 
{| class="wikitable"
 
{| class="wikitable"
! Offset
+
! Offset !! Size !! Type !! Description
! Size
 
! Description
 
 
|-
 
|-
| 0x00
+
| 0x00 || 4 || Char[4] || '''Magic''' ("'''FSAR'''")
| 4
 
| '''Magic''' ("'''FSAR'''")
 
 
|-
 
|-
| 0x04
+
| 0x04 || 2 || UInt16 || '''Endianness'''. 0xFEFF is big endian, 0xFFFE is little endian
| 2
 
| '''Endianness'''. 0xFEFF is big endian, 0xFFFE is little endian
 
 
|-
 
|-
| 0x06
+
| 0x06 || 2 || UInt16 || '''Header size'''. Always 0x0040.
| 2
 
| {{Unknown|'''Header size'''? Always 0x0040}}
 
 
|-
 
|-
| 0x08
+
| 0x08 || 4 || UInt32 || '''Version number'''
| 4
 
| '''Version number'''
 
 
|-
 
|-
| 0x0C
+
| 0x0C || 4 || UInt32 || '''File size''' of the entire file.
| 4
 
| '''File size''' of the entire file.
 
 
|-
 
|-
| 0x10
+
| 0x10 || 2 || UInt16 || '''Section count'''. Always 3.
| 2
 
| {{Unknown|'''Section count'''? Always 0x03.}}
 
 
|-
 
|-
| 0x12
+
| 0x12 || 2 || — || Padding.
| 2
 
| {{Unknown|'''Unknown'''. Always 0.}}
 
 
|-
 
|-
| 0x14
+
| 0x14 || 3 × 12 || [[#Section information|SectionInfo]][3] ||'''Section info'''. 3 structures describing the offsets to and sizes of the bfsar sections.
| 3 × 12
 
| '''Section info'''. 3 structures describing the offsets to and sizes of the bfsar sections.
 
 
|-
 
|-
| 0x38
+
| 0x38 || 8 || ? || {{Unknown|'''Unknown''', possibly alignment. Always 0.}}
| 8
 
| {{Unknown|'''Unknown'''. Always 0.}}
 
 
|}
 
|}
  
 
=== Section information ===
 
=== Section information ===
 
{| class="wikitable"
 
{| class="wikitable"
! Offset
+
! Offset !! Size !! Type || Description
! Size
 
! Description
 
 
|-
 
|-
| 0
+
| 0 || 2 || UInt16 || '''Identifier'''. Specifies which section it describes. 0x2000 is the STRG section, 0x2001 is INFO and 0x2002 is FILE.
| 2
 
| '''Identifier'''. Specifies which section it describes. 0x2000 is the STRG section, 0x2001 is INFO and 0x2002 is FILE.
 
 
|-
 
|-
| 2
+
| 2 || 2 || — || Padding.
| 2
 
| {{Unknown|'''Unknown'''. Always 0.}}
 
 
|-
 
|-
| 4
+
| 4 || 4 || UInt32 || '''Offset'''
| 4
 
| '''Offset'''
 
 
|-
 
|-
| 8
+
| 8 || 4 || UInt32 || '''Size'''
| 4
 
| '''Size'''
 
 
|}
 
|}
  
 
== STRG Section ==
 
== STRG Section ==
This section contains a string table and maybe more.
+
This section contains a string table and data about the string.
 
{| class="wikitable"
 
{| class="wikitable"
! Offset
+
! Offset !! Size !! Description
! Size
 
! Description
 
 
|-
 
|-
| 0x00
+
| 0x00 || 4 || '''ASCII identifier''' ("'''STRG'''")
| 4
 
| '''ASCII identifier''' ("'''STRG'''")
 
 
|-
 
|-
| 0x04
+
| 0x04 || 4 || '''Section size'''
| 4
 
| '''Section size'''
 
 
|-
 
|-
| 0x08
+
| 0x08 || 4 || {{Unknown|'''Unknown'''. Always 0x24000000}}
| 4
 
| {{Unknown|'''Unknown'''. Always 0x24000000}}
 
 
|-
 
|-
| 0x0C
+
| 0x0C || 4 || '''String table offset''', relative to field 0x08 of the STRG section.
| 4
 
| '''String table offset''', relative to field 0x08 of the STRG section.
 
 
|-
 
|-
| 0x10
+
| 0x10 || 4 || {{Unknown|'''Unknown'''. Always 0x24010000}}
| 4
 
| {{Unknown|'''Unknown'''. Always 0x24010000}}
 
 
|-
 
|-
| 0x14
+
| 0x14 || 4 || '''Offset''' to lookup table, relative to field 0x08 of the STRG section.
| 4
 
| {{Unknown|'''Offset''' to lookup table.}}
 
 
|}
 
|}
  
Line 107: Line 63:
 
The string table contains structures that point to null terminated strings. All offsets are relative to the start of the string table. It starts with a string count and then contains:
 
The string table contains structures that point to null terminated strings. All offsets are relative to the start of the string table. It starts with a string count and then contains:
 
{| class="wikitable"
 
{| class="wikitable"
! Offset
+
! Offset !! Size !! Description
! Size
 
! Description
 
 
|-
 
|-
| 0
+
| 0 || 4 || {{Unknown|'''Unknown'''. Always 0x1F010000.}}
| 4
 
| {{Unknown|'''Unknown'''. Always 0x1F010000.}}
 
 
|-
 
|-
| 4
+
| 4 || 4 || '''Offset''' to null terminated string.
| 4
 
| '''Offset''' to null terminated string.
 
 
|-
 
|-
| 8
+
| 8 || 4 || '''Size''' of null terminated string.
| 4
 
| {{Unknown|'''Unknown'''.}}
 
 
|}
 
|}
  
Line 127: Line 75:
 
This table is used to get the string table index and other data for a string. It starts with 8 bytes of data:
 
This table is used to get the string table index and other data for a string. It starts with 8 bytes of data:
 
{| class="wikitable"
 
{| class="wikitable"
! Offset
+
! Offset !! Size !! Description
! Size
 
! Description
 
 
|-
 
|-
| 0
+
| 0x00 || 4 || '''Index''' of the table entry where it starts.
| 4
 
| '''Index''' of the table entry where it starts.
 
 
|-
 
|-
| 4
+
| 0x04 || 4 || {{Unknown|'''Unknown'''. Seems to be some kind of index too. Must be higher than the other index.}}
| 4
+
|-
| {{Unknown|'''Unknown'''. Seems to be some kind of index too. Must be higher than the other index.}}
+
| 0x18 || 4 || '''Count''' of audio names.
 
|}
 
|}
 
And is then followed by 0x14 byte structures:
 
And is then followed by 0x14 byte structures:
 
{| class="wikitable"
 
{| class="wikitable"
! Offset
+
! Offset !! Size !! Description
! Size
 
! Description
 
 
|-
 
|-
| 0x00
+
| 0x00 || 2 || '''Endpoint'''. 0 if this is an entry that links to another list entry. 1 if the string has been found and the entry contains data about it.
| 2
 
| '''Endpoint'''. 0 if this is an entry that links to another list entry. 1 if the string has been found and the entry contains data about it.
 
 
|-
 
|-
| 0x02
+
| 0x02 || 2 || '''String bit'''. This bit in the string that's being searched for decides with which entry the search should continue.
| 2
 
| '''String bit'''. This bit in the string that's being searched for decides with which entry the search should continue.
 
 
|-
 
|-
| 0x04
+
| 0x04 || 4 || This is the table index of the next entry if the string bit is 0.
| 4
 
| This is the table index of the next entry if the string bit is 0.
 
 
|-
 
|-
| 0x08
+
| 0x08 || 4 || This is the index of the next entry if the string bit is 1.
| 4
 
| This is the index of the next entry if the string bit is 1.
 
 
|-
 
|-
| 0x0C
+
| 0x0C || 4 || '''String table index''' if this structure is an endpoint.
| 4
 
| '''String table index''' if this structure is an endpoint.
 
 
|-
 
|-
| 0x10
+
| 0x10 || 1 || '''Data''' about the file. 1 if it's an audio file (SE/WSD/STRM), 2 if it's a WSDSET or SEQSET, 3 is a BANK, 4=PLAYER and 6=GROUP.
| 1
 
| '''Data''' about the file. 1 if it's an audio file (SE/WSD/STRM), 2 if it's a WSDSET or SEQSET, 3 is a BANK, 4=PLAYER and 6=GROUP.
 
 
|-
 
|-
| 0x11
+
| 0x11 || 3 || '''File id'''
| 3
 
| '''File id'''
 
 
|}
 
|}
 +
 +
== INFO Section ==
 +
All offsets in this header are relative to the start of the INFO section + 8.
 +
{| class="wikitable"
 +
! Offset !! Size !! Description
 +
|-
 +
| 0x00 || 4 || '''Magic''' ("'''INFO'''")
 +
|-
 +
| 0x04 || 4 || '''Size''' of INFO section.
 +
|-
 +
| 0x08 || 4 || {{Unknown|'''Unknown'''. Always 0x21000000}}
 +
|-
 +
| 0x0C || 4 || Audio list offset (SE/WSD/STRM)
 +
|-
 +
| 0x10 || 4 || {{Unknown|'''Unknown'''. Always 0x21040000}}
 +
|-
 +
| 0x14 || 4 || Audio set list offset (WSDSET/SEQSET)
 +
|-
 +
| 0x18 || 4 || {{Unknown|'''Unknown'''. Always 0x21010000}}
 +
|-
 +
| 0x1C || 4 || Bank list offset
 +
|-
 +
| 0x20 || 4 || {{Unknown|'''Unknown'''. Always 0x21030000}}
 +
|-
 +
| 0x24 || 4 || {{Unknown|'''Unknown''' offset.}}
 +
|-
 +
| 0x28 || 4 || {{Unknown|'''Unknown'''. Always 0x21050000}}
 +
|-
 +
| 0x2C || 4 || Group list offset
 +
|-
 +
| 0x30 || 4 || {{Unknown|'''Unknown'''. Always 0x21020000}}
 +
|-
 +
| 0x34 || 4 || Player list offset
 +
|-
 +
| 0x38 || 4 || {{Unknown|'''Unknown'''. Always 0x21060000}}
 +
|-
 +
| 0x3C || 4 || {{Unknown|'''Unknown''' offset.}}
 +
|-
 +
| 0x40 || 4 || {{Unknown|'''Unknown'''. Always 0x220B0000}}
 +
|-
 +
| 0x44 || 4 || {{Unknown|'''Unknown''' offset.}}
 +
|}
 +
 +
Each list starts with the amount of list entries and is then followed by these structures:
 +
{| class="wikitable"
 +
! Offset !! Size !! Description
 +
|-
 +
| 0 || 4 || {{Unknown|'''Unknown'''}}
 +
|-
 +
| 4 || 4 || '''Offset'''
 +
|}
 +
 +
== FILE Section ==
 +
FILE contains all of the audio data in the BFSAR.
 +
{| class="wikitable"
 +
! Offset !! Size !! Description
 +
|-
 +
| 0x00 || 4 || '''Magic''' ("'''FILE'''")
 +
|-
 +
| 0x04 || 4 || '''Size''' of FILE section.
 +
|}
 +
 
 +
There isn't a whole lot else to document about the FILE partition, since the data in it will most definitely vary depending on the game.
 +
 
 +
There are multiple FILE partitions, but only 1 of them is the 'main' FILE partition (it's the one you get from the BFSAR header). The 'main' FILE partition contains all of the other sub FILE partitions.
 +
 +
[[Category:File Format]]

Latest revision as of 03:53, 27 February 2018

A BFSAR file is an archive containing sound effects. In NSMBU, it also contains all music streams, but I don't think this is the case for MK8.

Format

I found this information by reverse engineering NSMBU and analyzing the bfsar files of NSMBU, SM3DW and Splatoon. I think the same applies to MK8, but since I don't have MK8's files, I can't assure this.

Header

Offset Size Type Description
0x00 4 Char[4] Magic ("FSAR")
0x04 2 UInt16 Endianness. 0xFEFF is big endian, 0xFFFE is little endian
0x06 2 UInt16 Header size. Always 0x0040.
0x08 4 UInt32 Version number
0x0C 4 UInt32 File size of the entire file.
0x10 2 UInt16 Section count. Always 3.
0x12 2 Padding.
0x14 3 × 12 SectionInfo[3] Section info. 3 structures describing the offsets to and sizes of the bfsar sections.
0x38 8 ? Unknown, possibly alignment. Always 0.

Section information

Offset Size Type Description
0 2 UInt16 Identifier. Specifies which section it describes. 0x2000 is the STRG section, 0x2001 is INFO and 0x2002 is FILE.
2 2 Padding.
4 4 UInt32 Offset
8 4 UInt32 Size

STRG Section

This section contains a string table and data about the string.

Offset Size Description
0x00 4 ASCII identifier ("STRG")
0x04 4 Section size
0x08 4 Unknown. Always 0x24000000
0x0C 4 String table offset, relative to field 0x08 of the STRG section.
0x10 4 Unknown. Always 0x24010000
0x14 4 Offset to lookup table, relative to field 0x08 of the STRG section.

String table

The string table contains structures that point to null terminated strings. All offsets are relative to the start of the string table. It starts with a string count and then contains:

Offset Size Description
0 4 Unknown. Always 0x1F010000.
4 4 Offset to null terminated string.
8 4 Size of null terminated string.

Lookup table

This table is used to get the string table index and other data for a string. It starts with 8 bytes of data:

Offset Size Description
0x00 4 Index of the table entry where it starts.
0x04 4 Unknown. Seems to be some kind of index too. Must be higher than the other index.
0x18 4 Count of audio names.

And is then followed by 0x14 byte structures:

Offset Size Description
0x00 2 Endpoint. 0 if this is an entry that links to another list entry. 1 if the string has been found and the entry contains data about it.
0x02 2 String bit. This bit in the string that's being searched for decides with which entry the search should continue.
0x04 4 This is the table index of the next entry if the string bit is 0.
0x08 4 This is the index of the next entry if the string bit is 1.
0x0C 4 String table index if this structure is an endpoint.
0x10 1 Data about the file. 1 if it's an audio file (SE/WSD/STRM), 2 if it's a WSDSET or SEQSET, 3 is a BANK, 4=PLAYER and 6=GROUP.
0x11 3 File id

INFO Section

All offsets in this header are relative to the start of the INFO section + 8.

Offset Size Description
0x00 4 Magic ("INFO")
0x04 4 Size of INFO section.
0x08 4 Unknown. Always 0x21000000
0x0C 4 Audio list offset (SE/WSD/STRM)
0x10 4 Unknown. Always 0x21040000
0x14 4 Audio set list offset (WSDSET/SEQSET)
0x18 4 Unknown. Always 0x21010000
0x1C 4 Bank list offset
0x20 4 Unknown. Always 0x21030000
0x24 4 Unknown offset.
0x28 4 Unknown. Always 0x21050000
0x2C 4 Group list offset
0x30 4 Unknown. Always 0x21020000
0x34 4 Player list offset
0x38 4 Unknown. Always 0x21060000
0x3C 4 Unknown offset.
0x40 4 Unknown. Always 0x220B0000
0x44 4 Unknown offset.

Each list starts with the amount of list entries and is then followed by these structures:

Offset Size Description
0 4 Unknown
4 4 Offset

FILE Section

FILE contains all of the audio data in the BFSAR.

Offset Size Description
0x00 4 Magic ("FILE")
0x04 4 Size of FILE section.

There isn't a whole lot else to document about the FILE partition, since the data in it will most definitely vary depending on the game.

There are multiple FILE partitions, but only 1 of them is the 'main' FILE partition (it's the one you get from the BFSAR header). The 'main' FILE partition contains all of the other sub FILE partitions.