User:Gamma/BMG and BMC
There are two file formats related to text in The Wind Waker: BMG and BMC. The BMG files contain the actual text data, while the BMC files contain RGB color data for changing the font's color. The specs of these two formats are discussed below.
Contents
BMG
The Wind Waker stores all of its main text in zel_00.bmg, located at res/Msg/bmgres.arc, and the Shift-JIS-encoded Katakana text for the game's Hylian textboxes in zel_01.bmg located at res/Msg/bmgresh.arc. Although they are BMG files, they have a slightly different format than that of the BMG files found in Twilight Princess and Super Mario Galaxy. There are three parts to the BMG format that The Wind Waker uses: the file header, the INF1 section, and the DAT1 section.
File Header
Size: 0x20 bytes
Offset | Field Description |
---|---|
0x00 | const string "MESGbmg1" |
0x08 | int fileSize |
0x0C | const int 0x02 |
0x10 | const int 0x01000000 |
0x14 | const int 0x00 |
0x18 | const int 0x00 |
0x1C | const int 0x00 |
The only variable present in the file header is fileSize.
INF1
The INF1 section has a header followed by a specified number of message entries.
INF1 Header
Size: 0x10
Offset | Field Description |
---|---|
0x00 | const string INF1 |
0x04 | int inf1Size |
0x08 | short numMessageEntries |
0x0A | short messageEntrySize |
0x0C | const int 0x00 |
Message Entries
Size: 0x18
Offset | Field Description |
---|---|
0x00 | int dat1TextOffset |
0x04 | short messageID |
0x06 | short unknown1 |
0x08 | short unknown2 |
0x0A | short unknown3 |
0x0C | byte textboxType |
0x0D | byte defaultDrawType |
0x0E | byte textboxPosition |
0x0F | byte itemImageID |
0x10 | byte unknown4 |
0x11 | byte unknown5 |
0x12 | byte unknown6 |
0x13 | byte unknown7 |
0x14 | const short 0x00 |
0x16 | byte numLinesPerBox |
0x17 | const byte 0x00 |
The offset given by dat1TextOffset is the offset of the text data relative to the end of the DAT1 header. It appears that the unknowns are grouping IDs that may or may not be used by the engine. In any case, changing them does not have any visible effect in-game.
DAT1
DAT1 starts with a 0x08-byte-long header, followed by the ASCII-encoded text data. Each individual message is separated by a null terminator. The actual text data starts at offset 0x01 from the end of the header; at 0x00 is a single null terminator used to prevent crashing from undefined text offsets.
DAT1 Header
Size: 0x08
Offset | Field Description |
---|---|
0x00 | const string "DAT1" |
0x04 | int dat1Size |
BMC
The file color.bmc can be found at both res/Msg/bmgres.arc and res/Msg/bmgresh.arc. Both files are identical. They contain RGB data in an array that the game uses to color the font when prompted by the Set Font Color control code. This control code takes an integer as an argument, and this integer is the index of the color settings to use within the color data array. There are two parts to the BMC format: the file header and the CLT1 section.
File Header
Size: 0x20 bytes
Offset | Field Description |
---|---|
0x00 | const string "MGCLbmc1" |
0x08 | const int 0x22 |
0x0C | const int 0x01 |
0x10 | const int 0x00 |
0x14 | const int 0x00 |
0x18 | const int 0x00 |
0x1C | const int 0x00 |
The BMC file header has no variable information.
CLT1
There are two components to the CLT1 section: a header and an array of RGB colors.
CLT1 Header
Size: 0x0C bytes
Offset | Field Description |
---|---|
0x00 | const string "CLT1" |
0x04 | int clt1Size |
0x08 | short numColors |
0x0A | const short 0x00 |
0x0C | ColorArrayElement[numColors] colorArray |
The CLT1 header contains two variables: clt1Size, which is the size of the CLT1 section, and numColors, which is the number of colors within the color array. It should be noted that while numColors is set to 0x0100/256 dec by default, only the first 9 slots of the array contain actual color data. Color 0x09 and beyond are simply white, and can be made into different colors and referenced by the Set Font Color control code.
Color Array Element
Size: 0x04 bytes
Offset | Field Description |
---|---|
0x00 | byte redValue |
0x01 | byte greenValue |
0x02 | byte blueValue |
0x03 | const byte 0xFF |
Each element in the array of colors follows this format. The field at 0x03 is padding, not an alpha value. Changing this value does not change the opacity of the font.