Msbt: Difference between revisions

m
Added categories and fixed italics
imported>Zephenryus
(Added msbt File Specification)
 
imported>Zephenryus
m (Added categories and fixed italics)
Line 5: Line 5:


== msbt File Layout ==
== msbt File Layout ==
msbt files are made up of four sections that are aligned to 16-bytes.
msbt files are made up of four sections that are aligned to 16-bytes.
* Header
* Header
* Labels
* Labels
Line 16: Line 14:


=== Header Structure ===
=== Header Structure ===
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 65: Line 62:


== Labels Section ==
== Labels Section ==
The labels section has a header followed by an offset table and finally a string table with meta data regarding the later text section.
The labels section has a header followed by an offset table and finally a string table with meta data regarding the later text section.


=== Labels Section Header ===
=== Labels Section Header ===
The section header includes a signature, table size and padding making the header 16 bytes. Table size is relative to the end of the section header.
The section header includes a signature, table size and padding making the header 16 bytes. Table size is relative to the end of the section header.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 95: Line 89:


=== Labels Section Offset Table ===
=== Labels Section Offset Table ===
Offsets in the offset table are relative to the end of the Labels Section Header (byte `0x10`). The offset table length is defined in the first four bytes of the table.
Offsets in the offset table are relative to the end of the Labels Section Header (byte `0x10`). The offset table length is defined in the first four bytes of the table.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 109: Line 101:
| Offset count
| Offset count
|}
|}
Each entry in the offset table is 8 bytes. 4 bytes indicating the number of null-terminated strings at the offset and an offset relative to the beginning of the offset table.
Each entry in the offset table is 8 bytes. 4 bytes indicating the number of null-terminated strings at the offset and an offset relative to the beginning of the offset table.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 130: Line 120:


=== Labels Section String Table ===
=== Labels Section String Table ===
 
The labels can be determined by iterating through the offset table and reading the number of null-terminated strings from the address. The first byte at the offset indicates the size of the label. One label can contain ''zero'' or more null-terminated strings but will not exceed the indicated total length.
The labels can be determined by iterating through the offset table and reading the number of null-terminated strings from the address. The first byte at the offset indicates the size of the label. One label can contain *zero* or more null-terminated strings but will not exceed the indicated total length.


After each null-terminated string, there are 4 bytes indicating which index in the texts table this label corresponds to. See the text table section for more information.
After each null-terminated string, there are 4 bytes indicating which index in the texts table this label corresponds to. See the text table section for more information.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 147: Line 135:
|-
|-
| 0x01
| 0x01
| *n*
| ''n''
| char[*n*]
| char[''n'']
| String count number of null-terminated strings<ref>A label can contain *zero* or more null-terminated strings</ref>
| String count number of null-terminated strings<ref>A label can contain ''zero'' or more null-terminated strings</ref>
|-
|-
| 0xnn
| 0xnn
Line 158: Line 146:


== Attributes Section ==
== Attributes Section ==
Attributes are not fully understood at this time. The attribute seem to indicate which actor should be attributed with the dialog (A good example is in <code>100enemy.msbt</code> where <code>NPC_GodVoice</code> is referenced).
Attributes are not fully understood at this time. The attribute seem to indicate which actor should be attributed with the dialog (A good example is in <code>100enemy.msbt</code> where <code>NPC_GodVoice</code> is referenced).


Line 164: Line 151:


=== Attributes Section Header ===
=== Attributes Section Header ===
The section header includes a signature, table size and padding making the header 16 bytes. Table size is relative to the end of the section header.
The section header includes a signature, table size and padding making the header 16 bytes. Table size is relative to the end of the section header.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 190: Line 175:


=== Attributes Section Offset Table ===
=== Attributes Section Offset Table ===
Offsets in the offset table are relative to the end of the Attributes Section Header (byte <code>0x10</code>). The first 4 bytes of the table are the number of offsets and the second 4 bytes indicate the size of each offset (or table entry) in bytes.
Offsets in the offset table are relative to the end of the Attributes Section Header (byte <code>0x10</code>). The first 4 bytes of the table are the number of offsets and the second 4 bytes indicate the size of each offset (or table entry) in bytes.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 209: Line 192:
| Attribute data size
| Attribute data size
|}
|}
Each entry in the offset table is a 4-byte relative offset from the beginning of the table.
Each entry in the offset table is a 4-byte relative offset from the beginning of the table.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 225: Line 206:


=== Attributes Section String Table ===
=== Attributes Section String Table ===
The attributes can be determined by iterating through the offset table and a null-terminated string from the address. Strings in this table are UTF-16 (Wii U files are UTF-16-BE encoded) encoded and take up 2 bytes for each character. Strings are terminated with a UTF-16 null character <code>00 00</code> or <code>\u0000</code>.
The attributes can be determined by iterating through the offset table and a null-terminated string from the address. Strings in this table are UTF-16 (Wii U files are UTF-16-BE encoded) encoded and take up 2 bytes for each character. Strings are terminated with a UTF-16 null character <code>00 00</code> or <code>\u0000</code>.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 235: Line 214:
|-
|-
| 0x00
| 0x00
| *n*
| ''n''
| char[2]
| char[2]
| Unicode character
| Unicode character
Line 241: Line 220:


== Texts Section ==
== Texts Section ==
The text section contains a table of strings.
The text section contains a table of strings.


=== Texts Section Header ===
=== Texts Section Header ===
The section header includes a signature, table size and padding making the header 16 bytes. Table size is relative to the end of the section header.
The section header includes a signature, table size and padding making the header 16 bytes. Table size is relative to the end of the section header.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 271: Line 247:


=== Texts Section Offset Table ===
=== Texts Section Offset Table ===
Offsets in the offset table are relative to the end of the Texts Section Header (byte `0x10`). The offset table length is defined in the first four bytes of the table.
Offsets in the offset table are relative to the end of the Texts Section Header (byte `0x10`). The offset table length is defined in the first four bytes of the table.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 285: Line 259:
| Offset count
| Offset count
|}
|}
Each entry in the offset table is a 4-byte relative offset from the beginning of the table.
Each entry in the offset table is a 4-byte relative offset from the beginning of the table.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 301: Line 273:


=== Texts Section String Table ===
=== Texts Section String Table ===
The attributes can be determined by iterating through the offset table. Strings in this table are UTF-16 (Wii U files are UTF-16-BE encoded) encoded and take up 2 bytes for each character.
The attributes can be determined by iterating through the offset table. Strings in this table are UTF-16 (Wii U files are UTF-16-BE encoded) encoded and take up 2 bytes for each character.


String length is determined by reading until the next offset in the table and not exceeding the end of the file. Strings cannot be read as null-terminated strings since many strings will have multiple null characters in them.
String length is determined by reading until the next offset in the table and not exceeding the end of the file. Strings cannot be read as null-terminated strings since many strings will have multiple null characters in them.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 313: Line 283:
|-
|-
| 0x00
| 0x00
| *n*
| ''n''
| char[2]
| char[2]
| Unicode character
| Unicode character
Line 319: Line 289:


=== Text Commands ===
=== Text Commands ===
Some string include interpolation operators or commands within the strings. These commands tell the game to behave in a certain way while displaying the string. Commands include choices, selling items, buying items and interacting with objects.
Some string include interpolation operators or commands within the strings. These commands tell the game to behave in a certain way while displaying the string. Commands include choices, selling items, buying items and interacting with objects.


Commands are indicated in the strings with <code>00 0e</code> or <code>\u000e</code>.
Commands are indicated in the strings with <code>00 0e</code> or <code>\u000e</code>.
{| class="wikitable"
{| class="wikitable"
!Offset (h)
!Offset (h)
Line 340: Line 308:
| Command type
| Command type
|}
|}
For example, in <code>100enemy.msbt</code> the following data appears:
For example, in <code>100enemy.msbt</code> the following data appears:
<pre>  | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |                   
<pre>  | 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |                   
---|-------------------------------------------------|------------------|
---|-------------------------------------------------|------------------|
Line 355: Line 320:
70 | 00 02 00 03 00 04 00 05 02 03 00 00            | ............    |
70 | 00 02 00 03 00 04 00 05 02 03 00 00            | ............    |
</pre>
</pre>
At byte <code>0x68</code> is the command indicator followed by the type of <code>1</code>. Command types of <code>1</code> seem to be variable length. The type (in this instance) is followed by the number of additional Unsigned Shorts <code>6</code> and 6 shorts.
At byte <code>0x68</code> is the command indicator followed by the type of <code>1</code>. Command types of <code>1</code> seem to be variable length. The type (in this instance) is followed by the number of additional Unsigned Shorts <code>6</code> and 6 shorts.


Line 361: Line 325:


The commands are not fully understood at this time, but below is a list of the known command identifiers and variable counts.
The commands are not fully understood at this time, but below is a list of the known command identifiers and variable counts.
{| class="wikitable"
{| class="wikitable"
!Type
!Type
Line 372: Line 335:
|-
|-
| 1
| 1
| *n*
| ''n''
| Variable length. Length is the unsigned short following the type.
| Variable length. Length is the unsigned short following the type.
|-
|-
Line 393: Line 356:


== Compiling the Sections ==
== Compiling the Sections ==
The sections are held together by the indexes in the labels table. The indexes correspond to the attributes table and the texts table. The data can be compiled using the index.
The sections are held together by the indexes in the labels table. The indexes correspond to the attributes table and the texts table. The data can be compiled using the index.


By default the indexes in the labels table are not in order, but the text table is (and possibly the attributes table). Below is the labels table in <code>100enemy.msbt</code>.
By default the indexes in the labels table are not in order, but the text table is (and possibly the attributes table). Below is the labels table in <code>100enemy.msbt</code>.
{| class="wikitable"
{| class="wikitable"
!String Count
!String Count
Line 519: Line 480:
| 2
| 2
|}
|}
And the texts table.
And the texts table.
{| class="wikitable"
{| class="wikitable"
!Index
!Index
Line 562: Line 521:
| Cancel  
| Cancel  
|}
|}
Using the indexes to match the labels to the attributes and texts tables, the following table can be compiled.
Using the indexes to match the labels to the attributes and texts tables, the following table can be compiled.


The empty labels are not fully understood.
The empty labels are not fully understood.
{| class="wikitable"
{| class="wikitable"
!Label
!Label
Line 633: Line 590:
| Cancel
| Cancel
|}
|}
The attribute table is still not fully understood. In this example, there are 8 attribute entries in the table, but they correctly map to the 8 blocks of dialog.
The attribute table is still not fully understood. In this example, there are 8 attribute entries in the table, but they correctly map to the 8 blocks of dialog.
[[Category:File extensions]]
[[Category:File extensions (MSBT)]]
<references />
Anonymous user