BMG (File Format): Difference between revisions
(→Section Types: Document DAT1) |
(Update BMG docs) |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:File formats]] | [[Category:File formats]] | ||
{{WIP}} | |||
'''BMG''' is a file format used to hold text in SMG1. This was replaced by the [[MSBT]] file format in SMG2. Unlike the messages in SMG2, SMG1 uses a single, region specific BMG file (Region/message.arc/message.bmg) to hold ''ALL'' text. | '''BMG''' is a file format used to hold text in SMG1. This was replaced by the [[MSBT]] file format in SMG2. Unlike the messages in SMG2, SMG1 uses a single, region specific BMG file (Region/message.arc/message.bmg) to hold ''ALL'' text. | ||
= Format Specifications = | = Format Specifications = | ||
Below you'll find helpful tables on how | Below you'll find helpful tables on how this file is structured in SMG1 and 3D All Stars, other games that use BMG might be different. | ||
'' | ''All <code>char[]</code> types are in ASCII encoding.'' | ||
== Header == | == Header == | ||
{| class="wikitable" | {| class="wikitable" | ||
! Offset !! Type !! Description | ! Offset !! Type !! Description | ||
|- | |- | ||
| 0x0 || | | 0x0 || char[4] || File magic. "MESG" for SMG1, "GSEM" for 3D All Stars. | ||
|- | |- | ||
| 0x4 || | | 0x4 || char[4] || File magic. "bmg1" for SMG1. "1gmb" for 3D All Stars. | ||
|- | |- | ||
| 0x8 || | | 0x8 || u32 || [[BMG_(File_Format)#FLW1|FLW1 Section]] offset. | ||
|- | |- | ||
| 0x0C || | | 0x0C || u32 || Section count. | ||
|- | |- | ||
| 0x10 || | | 0x10 || u8 || Unknown. Believed to be a definition of encoding in some games. | ||
|- | |- | ||
| 0x11 || | | 0x11 || u8[15] || Padding. | ||
|} | |} | ||
== | == Sections == | ||
All sections start with a section identifier. | |||
{| class="wikitable" | {| class="wikitable" | ||
! Offset !! Type !! Description | ! Offset !! Type !! Description | ||
|- | |- | ||
| 0x0 || | | 0x0 || char[4] || Magic. Relates to the Section Type it is. | ||
|- | |- | ||
| 0x4 || | | 0x4 || u32 || Section Size. | ||
|} | |} | ||
Depending on the <code>Magic</code>, the section can be one of the following types below. | |||
=== INF1 Section === | === INF1 Section === | ||
This section holds message information. | |||
{| class="wikitable" | {| class="wikitable" | ||
! Offset !! Type !! Description | ! Offset !! Type !! Description | ||
|- | |- | ||
| 0x0 || | | 0x0 || u16 || Entry count. | ||
|- | |- | ||
| 0x2 || | | 0x2 || u16 || Entry size. | ||
|- | |- | ||
| 0x4 || | | 0x4 || u8[4] || Padding. | ||
|} | |} | ||
Entries are structured as following: | |||
{| class="wikitable" | |||
!Offset | |||
!Type | |||
!Description | |||
|- | |||
|0x0 | |||
|u32 | |||
|Message data offset. | |||
|- | |||
|0x4 | |||
|u16 | |||
|Camera ID. | |||
|- | |||
|0x6 | |||
|u8 | |||
|Sound ID. | |||
|- | |||
|0x7 | |||
|u8 | |||
|Camera type. (Normal = 0, Event = 1, None = 2) | |||
|- | |||
|0x8 | |||
|u8 | |||
|Talk type. (Normal = 0, Short = 1, Event = 2, Composite = 3, Flow = 4, Null = 5) | |||
|- | |||
|0x9 | |||
|u8 | |||
|Balloon type. (Normal = 0, Unk = 1, Call = 2, Fixed = 3, Signboard = 4, Info = 5, Icon = 6) | |||
|- | |||
|0xA | |||
|u8 | |||
|Area ID. | |||
|- | |||
|0xB | |||
|u8 | |||
|Index into the <code>MessageAlreadyRead</code> [[Progress checks|GameEventValue]]. | |||
|} | |||
=== DAT1 === | === DAT1 === | ||
This section contains null-terminated message data, encoded in BE UTF-16. These messages have custom tags, which the game interprets and replaces with the correct text/visuals. | |||
{| class="wikitable" | {| class="wikitable" | ||
!Offset | |||
!Type | |||
!Description | |||
|- | |||
|0x0 | |||
|wchar_t | |||
|Tag identifier. (Always 0x14) | |||
|- | |||
|0x2 | |||
|u8 | |||
|Tag size. (Including the identifier) | |||
|- | |||
|0x3 | |||
|u8 | |||
|Padding. | |||
|- | |||
|0x4 | |||
|u16 | |||
|Tag type. | |||
|} | |||
''Todo: Document tag types.'' | |||
=== FLW1 === | |||
This section holds flow information. | |||
{| class="wikitable" | |||
|- | |||
! Offset !! Type !! Description | ! Offset !! Type !! Description | ||
|- | |- | ||
| 0x0 || | | 0x0 || u16 || Flow node count. | ||
|- | |||
| 0x2 || u16 || Branch node count. | |||
|- | |||
| 0x4 || u8[4] || Padding. | |||
|} | |} | ||
All flow nodes have 8 bytes in total. The 1st byte defines flow type. | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! Offset !! Type !! Description | ! Offset !! Type !! Description | ||
|- | |- | ||
| 0x0 || | |0x0 | ||
|u8 | |||
|Node type. (Text = 1, Condition = 2, Event = 3) | |||
|- | |||
| 0x1 || u8[7] ||Text node data: | |||
{| class="wikitable" | |||
!Offset | |||
!Type | |||
!Description | |||
|- | |- | ||
| | | 0x1 || u8 || Unknown. | ||
|- | |- | ||
| 0x4 || | |0x2 | ||
|u16 | |||
|Message ID. | |||
|- | |||
|0x4 | |||
|u16 | |||
|Next flow ID. | |||
|- | |||
|0x6 | |||
|u8 | |||
|Validity. (?) | |||
|- | |||
|0x7 | |||
|u8 | |||
|Unknown. | |||
|} | |} | ||
Condition node data: | |||
{| class="wikitable" | |||
!Offset | |||
!Type | |||
!Description | |||
|- | |||
| 0x1 || u8 || Unknown. | |||
|- | |||
|0x2 | |||
|u16 | |||
|Condition type. | |||
|- | |||
|0x4 | |||
|u16 | |||
|Condition argument. | |||
|- | |||
|0x6 | |||
|u16 | |||
|Branch node ID. | |||
If the condition is true, the game will branch into branch node ID. | |||
If the condition is false, the game will branch into branch node ID + 1. | |||
|} | |||
Event node data: | |||
{| class="wikitable" | |||
!Offset | |||
!Type | |||
!Description | |||
|- | |||
| 0x1 || u8 || Event type. | |||
|- | |||
|0x2 | |||
|u16 | |||
|Branch node ID. | |||
|- | |||
|0x4 | |||
|u32 | |||
|Event argument. | |||
|} | |||
|} | |||
This is followed by branch node IDs, an array of <code>u16</code>s that point to flow indices. | |||
=== FLI1 === | === FLI1 === | ||
The purpose of this section is unknown. This is not used/supported in SMG1/3D All Stars. | |||
{| class="wikitable" | |||
! Offset !! Type !! Description | |||
|- | |||
| 0x0 || u16 || Entry count. | |||
|- | |||
| 0x2 || u8 || Entry size. (Always 8) | |||
|- | |||
| 0x3 || u8[5] || Padding. | |||
|} | |||
This is followed by entries with the following structure: | |||
{| class="wikitable" | |||
! Offset !! Type !! Description | |||
|- | |||
| 0x0 || u16 || Unknown. | |||
|- | |||
| 0x2 || u8[2] || Padding. | |||
|- | |||
| 0x4 || u16 || Unknown. | |||
|- | |||
| 0x6 || u8[2] || Padding. | |||
|} | |||
= Labels = | |||
SMG1/3D All Stars BMGs do not have labels inside them. Instead, message labels are set through <code>messageid.tbl</code>, a ''sorted'' BCSV file. | |||
This <code>.tbl</code> file contains 2 fields: | |||
* The <code>MessageId</code> (<code>STRINGOFF</code>) field that contains a label name. | |||
* The <code>Index</code> (<code>LONG</code>) field that contains the label's respective message index. | |||
= Tools = | = Tools = | ||
The following tools can handle SMG1's BMG (some may have 3D All Stars support, but most don't.) | The following tools can handle SMG1's BMG (some may have 3D All Stars support, but most don't.) | ||
* [https://github.com/IonicPixels/Tomato Tomato] (Can convert a BMG + the [[BCSV|TBL]] file to a XML file and vise versa. '''Has 3D All Stars Support''') | |||
* [http://wiki.tockdom.com/wiki/Wiimms_SZS_Tools Wiimms SZS Tools (wbmgt)] (Can convert a BMG to a TXT file. High chance of crashing if you edit with this.) | * [http://wiki.tockdom.com/wiki/Wiimms_SZS_Tools Wiimms SZS Tools (wbmgt)] (Can convert a BMG to a TXT file. High chance of crashing if you edit with this.) | ||
Latest revision as of 14:56, 10 October 2025
| This page is in progress and may contain incomplete information or editor's notes. |
|---|
BMG is a file format used to hold text in SMG1. This was replaced by the MSBT file format in SMG2. Unlike the messages in SMG2, SMG1 uses a single, region specific BMG file (Region/message.arc/message.bmg) to hold ALL text.
Format Specifications
Below you'll find helpful tables on how this file is structured in SMG1 and 3D All Stars, other games that use BMG might be different.
All char[] types are in ASCII encoding.
Header
| Offset | Type | Description |
|---|---|---|
| 0x0 | char[4] | File magic. "MESG" for SMG1, "GSEM" for 3D All Stars. |
| 0x4 | char[4] | File magic. "bmg1" for SMG1. "1gmb" for 3D All Stars. |
| 0x8 | u32 | FLW1 Section offset. |
| 0x0C | u32 | Section count. |
| 0x10 | u8 | Unknown. Believed to be a definition of encoding in some games. |
| 0x11 | u8[15] | Padding. |
Sections
All sections start with a section identifier.
| Offset | Type | Description |
|---|---|---|
| 0x0 | char[4] | Magic. Relates to the Section Type it is. |
| 0x4 | u32 | Section Size. |
Depending on the Magic, the section can be one of the following types below.
INF1 Section
This section holds message information.
| Offset | Type | Description |
|---|---|---|
| 0x0 | u16 | Entry count. |
| 0x2 | u16 | Entry size. |
| 0x4 | u8[4] | Padding. |
Entries are structured as following:
| Offset | Type | Description |
|---|---|---|
| 0x0 | u32 | Message data offset. |
| 0x4 | u16 | Camera ID. |
| 0x6 | u8 | Sound ID. |
| 0x7 | u8 | Camera type. (Normal = 0, Event = 1, None = 2) |
| 0x8 | u8 | Talk type. (Normal = 0, Short = 1, Event = 2, Composite = 3, Flow = 4, Null = 5) |
| 0x9 | u8 | Balloon type. (Normal = 0, Unk = 1, Call = 2, Fixed = 3, Signboard = 4, Info = 5, Icon = 6) |
| 0xA | u8 | Area ID. |
| 0xB | u8 | Index into the MessageAlreadyRead GameEventValue.
|
DAT1
This section contains null-terminated message data, encoded in BE UTF-16. These messages have custom tags, which the game interprets and replaces with the correct text/visuals.
| Offset | Type | Description |
|---|---|---|
| 0x0 | wchar_t | Tag identifier. (Always 0x14) |
| 0x2 | u8 | Tag size. (Including the identifier) |
| 0x3 | u8 | Padding. |
| 0x4 | u16 | Tag type. |
Todo: Document tag types.
FLW1
This section holds flow information.
| Offset | Type | Description |
|---|---|---|
| 0x0 | u16 | Flow node count. |
| 0x2 | u16 | Branch node count. |
| 0x4 | u8[4] | Padding. |
All flow nodes have 8 bytes in total. The 1st byte defines flow type.
| Offset | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x0 | u8 | Node type. (Text = 1, Condition = 2, Event = 3) | |||||||||||||||||||||||||||||||||||||||||||||
| 0x1 | u8[7] | Text node data:
Condition node data:
Event node data:
|
This is followed by branch node IDs, an array of u16s that point to flow indices.
FLI1
The purpose of this section is unknown. This is not used/supported in SMG1/3D All Stars.
| Offset | Type | Description |
|---|---|---|
| 0x0 | u16 | Entry count. |
| 0x2 | u8 | Entry size. (Always 8) |
| 0x3 | u8[5] | Padding. |
This is followed by entries with the following structure:
| Offset | Type | Description |
|---|---|---|
| 0x0 | u16 | Unknown. |
| 0x2 | u8[2] | Padding. |
| 0x4 | u16 | Unknown. |
| 0x6 | u8[2] | Padding. |
Labels
SMG1/3D All Stars BMGs do not have labels inside them. Instead, message labels are set through messageid.tbl, a sorted BCSV file.
This .tbl file contains 2 fields:
- The
MessageId(STRINGOFF) field that contains a label name. - The
Index(LONG) field that contains the label's respective message index.
Tools
The following tools can handle SMG1's BMG (some may have 3D All Stars support, but most don't.)
- Tomato (Can convert a BMG + the TBL file to a XML file and vise versa. Has 3D All Stars Support)
- Wiimms SZS Tools (wbmgt) (Can convert a BMG to a TXT file. High chance of crashing if you edit with this.)