Wiimms SZS Tools accept binary and text BMG files as input and can convert each format to each other. Moreover BMG files of both formats can be used to patch other BMG files of both formats (see option --patch-bmg).
This pages describes the syntax of BMG text files and how to convert them to and from binary BMG files used by Nintendo. It also gives usage examples.
A BMG text file is line oriented with support of continuation lines:
All other lines must follow one of the following line formats:
Line Format | |
---|---|
Format | Description |
MID is the Message ID (see below). Define a 32-bit attribute for the message MID without any string. Use a following text assignment to define a text. | |
Define a message ID without any string (NULL pointer). This is different to a message with an empty string. The impact is unknown, but Mario Kart Wii use NULL pointers and emtpy strings. | |
Define a message ID without any string (NULL pointer).
ATTRIB is a attribute vector with any number of byte values.
The ATTRIB must be enclosed by brackets ( This line format is available since v1.40a. |
|
Define a text string for MID. An already existing string is replaced,
but the attribute of an existing string is not changed.
For new messages, the attribute is set to 0x01000000 ( Continuation lines are possible. |
|
Define a text string for MID. An already existing string is replaced.
ATTRIB is a attribute vector with any number of byte values.
The ATTRIB must be enclosed by brackets ( Continuation lines are possible. This line format is available since v1.40a. |
|
This is a text continuation line for a previous text assignment.
Multiple continuation can be used. Spaces and tabs before the '+' are ignored. Maximal 1 space behind the '+' is ignored. A line feed is not included on continuation and must be explicitly defined as part of TEXT. |
|
Message assignment:
Copy attributes and text of message
If This assignment is available since v2.02a. |
On output, always 1 space is printed behind each
If the attribute size is exact 4 bytes,
then it can be printed as single value (
Example:
If using a slash (
Example for an 8 byte attribute:
Mario Kart Wii uses 4 different attributes to select a font. Other attributes will lead into a game freeze.
Attributes used by Mario Kart Wii | |||
---|---|---|---|
ATTRIB32 | ATTRIB (full) |
ATTRIB (short) |
Description |
0x00000000 | [0,0,0,0] | [0] | Value used for count down and for final race strings like "FINISH!". |
0x01000000 | [1,0,0,0] | [1] | Standard font for nearly all messages. |
0x04000000 | [4,0,0,0] | [4] | A special red font (only digits) used for battle and team points. |
0x05000000 | [5,0,0,0] | [5] | A special blue font (only digits) used for battle and team points. |
Escape Sequences | |
---|---|
Syntax | Description |
The backslash itself. | |
ASCII 7 = 0x07 = BEL (bell) | |
ASCII 8 = 0x08 = BS (back space) | |
ASCII 12 = 0x0c = FF (form feed) | |
ASCII 10 = 0x0a = LF (line feed) | |
ASCII 13 = 0x0d = CR (carriage return) | |
ASCII 9 = 0x09 = HT (horizontal tabulator) | |
ASCII 11 = 0x0b = VT (vertical tabulator) | |
Insert a character (16-bit) defined by the octal number |
|
Each parameter is interpreted as message id (
If the message does not exist, the macro library is searched as fallback.
If this fails too, text » This escape sequence is available since v2.02a. |
|
Each parameter is interpreted as message id ( This escape sequence is available since v2.03a. |
|
Insert a character (16-bit) defined by the hexadecimal number |
|
Since v1.44, |
|
This is a short cut for Nintendos escape sequences up to 12 bytes:
|
|
Since v1.44, the tools support also Nintendos escape sequences from 14 to 254 bytes:
|
|
Insert the 32-bit unicode character |
|
Since v1.44, |
|
Insert the 16-bit color
If |
The tools accept escape sequences of format
Colors used by Mario Kart Wii | |||||
---|---|---|---|---|---|
Names | Number | Info | Examples | ||
OFF NONE GRAY GREY |
0x00 | No special color defined. Often grey is used. Only this color is blinking on track selection. | 123 Abc | 123 Abc | 123 Abc |
TRANSP CLEAR |
0x08 | Characters are invisible and only space is reserved. | — | ||
WHITE | 0x02 | — | 123 Abc | 123 Abc | 123 Abc |
RED1 RED |
0x40 | — | 123 Abc | 123 Abc | 123 Abc |
RED2 | 0x20 | — | 123 Abc | 123 Abc | 123 Abc |
RED3 | 0x32 | — | 123 Abc | 123 Abc | 123 Abc |
RED4 | 0x01 | — | 123 Abc | 123 Abc | 123 Abc |
YELLOW | 0x30 | — | 123 Abc | 123 Abc | 123 Abc |
GREEN | 0x33 | — | 123 Abc | 123 Abc | 123 Abc |
BLUE1 BLUE |
0x21 | — | 123 Abc | 123 Abc | 123 Abc |
BLUE2 | 0x31 | — | 123 Abc | 123 Abc | 123 Abc |
YOR0 | 0x10 | Begin of yellow-orange-red (YOR) series. | 123 Abc | 123 Abc | 123 Abc |
YOR1 | 0x11 | — | 123 Abc | 123 Abc | 123 Abc |
YOR2 | 0x12 | — | 123 Abc | 123 Abc | 123 Abc |
YOR3 | 0x13 | — | 123 Abc | 123 Abc | 123 Abc |
YOR4 | 0x14 | — | 123 Abc | 123 Abc | 123 Abc |
YOR5 | 0x15 | — | 123 Abc | 123 Abc | 123 Abc |
YOR6 | 0x16 | — | 123 Abc | 123 Abc | 123 Abc |
YOR7 | 0x17 | End of yellow-orange-red series. | 123 Abc | 123 Abc | 123 Abc |
#BMG <<< The first 4 characters '#BMG' are the magic for a BMG text file. # <<< Don't remove them! # Set the Message ID (MID) a234 to "Hello" a234 = Hello # Standard C escape sequences are allowed: a234 = Hello\nWiimm # Continuation lines and colors are also possible a234 = Hello\n + \c{blue}Wiimm\c{off} # Attributes are specified with ~ a234 ~ 0x01000000 # For track names use the MID alternative 'Tct' # Both related messages will be defined. # For CT-CODE and LE-CODE the third related messages will be defined too. T11 = name of first track # Points for battles; use blue special font (in-line mode for attribute) 76d [5] = \z{a02,1000000000}
A BMG file is decoded into a human and machine readable text file. And encoding means: Create a new BMG binary file from scratch. The source may be a binary or text BMG file.
Commands to decode (examples without options):
wbmgt decode FILE.bmg wbmgt cat FILE.bmg wbmgt mix FILE.bmg wszst bmg FILE.szs wctct bmg CT-FILE
Command to encode (examples without options):
wbmgt encode FILE.txt
The mode describes how to patch the source file by the current patch file. wbmgt supports 8 patching modes with source files, abbreviations are allowed:
Patching Modes with source files | ||||
---|---|---|---|---|
Mode | Copy ... if | |||
only insource |
only inpatch |
source !=patch |
source ==patch |
|
REPLACE | source | — | patch | both |
INSERT | source | patch | source | both |
OVERWRITE | source | patch | patch | both |
DELETE | source | — | — | — |
MASK | — | — | source | both |
EQUAL | — | — | — | both |
NOT-EQUAL | — | — | source | — |
source | — |
There are some more modes, that do not use any source file.
FORMAT=string acts like PRINT=file, but us the same format string for all printings. REGEX replace parts of strings matched by regular expressions. ID and ID-ALL insert the MID of each message to identifiy it while playing.
Modes RM-CUPS, CT-COPY, CT-FORCE-COPY, CT-FILL LE-COPY, LE-FORCE-COPY and LE-FILL support CT-CODE and LE-CODE.
The new string is created like a printf function call. Is a escape sequence is found, it is replaced by its (calculated content). The format of escape sequences is one of:
'%' CONV_LETTER '%' LEN CONV_LETTER '%' BEGIN ':' END CONV_LETTERAn escape sequence starts always with a percent sign and ends with a conversion letter (
The following conversion letters are supported:
Mode
2
Each defined and non empty message is prefixed by a letter representing the SZS filename (examples: T=Titel, E=Event, S=MenuSingle, ...) and the message id as hex number and a colon.
Example:
This mode helps to identify the messages while running the game.
Each defined message including empty messages is prefixed by a letter representing the SZS filename (examples: T=Titel, E=Event, S=MenuSingle, ...) and the message id as hex number and a colon.
Example:
All defined racing cup names in the MID range 23F0–23F7 are removed.
All defined track and arena name message are copied to the messages in the MID range 4000–4029, but only, if the destinaton message is not defined or empty.
All defined track and arena name message are copied to the messages in the MID range 4000–4029. Existing messages are overwritten.
All messages of MID range 4000–40ff, that are not defined or empty,
will be defined and set to the message
The definitions will only be done, if at least one track or arena name message is alrrady defined.
All defined track and arena name message are copied to the messages in the MID range 7000–7029, but only, if the destinaton message is not defined or empty.
All defined track and arena name message are copied to the messages in the MID range 7000–4029. Existing messages are overwritten.
All messages of MID range 7000–7fff, that are not defined or empty,
will be defined and set to the message
The definitions will only be done, if at least one track or arena name message is alrrady defined.
Syntax: @? MID
The command can only used in BMG-Text files. If active (MID>0), then the following message definitions are only used if message MID already exists. Another @? Command sets a new condition. Command @? 0 deactivates this feature.
Only the REPLACE, INSERT and OVERWRITE operations evaluate the condition. The condition is duplicated in text outputs.
In the case of our example, command @? T11 ensures that the track names are only added to the sub-file Common.bmg because this already contains the definition for slot 1.1. Sub-file Menu.bmg is skipped.
This option activates an output filter for BMG messages. Only messages explicitly enabled will reach the output. All other messages are ignored for the output.
Filter Ranges | ||
---|---|---|
Name | MID Range | Description |
NONE | all | Clear the filter at deny all messages. |
ALL | all | Allow all messages. |
IDENT | 3DEF | This modifier is available since v2.00a. A message to identify the MID ranges of cups and tracks.See next section for details. |
PARAM | 3FF0:3FFF IDENT |
A range to submit settings to other tools like mkw-ana. |
CUPS | 23F0:23F7 2489:248A XCUPS XREFS |
Names of racing and battle cups. |
TRACKS | 2454:2473 2490:24AF XTRACKS XREFS |
Names of racing tracks. |
ARENAS | 24B8:24c1 24CC:24d5 XARENAS |
Names of battle arenas. |
CHAT | 1194:11f3 | 96 messages for the online chat. |
CTCODE | 4000:44FD | All messages used by CT-CODE. It overlaps other ranges. |
CTCUPS | 4200:423F | This modifier is available since v2.01a. All cup names used by CT-CODE. |
CTTRACKS | 4000:41FE | All racing track and battle arena names used by CT-CODE. |
CTARENAS | 4020:4029 | This modifier is available since v2.01a. All battle arena names used by CT-CODE. The range is part of |
CTREFS | 4300:44FE | This modifier is available since v2.01a. All cup references (Format |
LECODE | 6800:8FF0 | This modifier is available since v2.00a. All messages used by LE-CODE. It overlaps other ranges. |
LECUPS | 6800:6BFF | This modifier is available since v2.01a. All cup names used by LE-CODE. |
LETRACKS | 7000:7FFF | This modifier is available since v2.00a. All racing track and battle arena names used by LE-CODE. |
LEARENAS | 7020:7029 | This modifier is available since v2.01a. All battle arena names used by LE-CODE. The range is part of |
LEREFS | 8000:8FFF | This modifier is available since v2.01a. All cup references (Format |
XCODE | LECODE or CTCODE |
This modifier is available since v2.00a. If option --le-code is set, it is the same as |
XCUPS | LECUPS or CTCUPS |
This modifier is available since v2.01a. If option --le-code is set, it is the same as |
XTRACKS | LETRACKS or CTTRACKS |
This modifier is available since v2.00a. If option --le-code is set, it is the same as |
XARENAS | LEARENAS or CTARENAS |
This modifier is available since v2.01a. If option --le-code is set, it is the same as |
XREFS | LEREFS or CTREFS |
This modifier is available since v2.01a. If option --le-code is set, it is the same as |
ALLCODE | CTCODE LECODE |
This modifier is available since v2.11a. Shortcut for both CODE variants.. |
ALLCUPS | CUPS CTCUPS LECUPS |
This modifier is available since v2.11a. Shortcut for all cup variants |
ALLTRACKS | TRACKS CTTRACKS LETRACKS |
This modifier is available since v2.11a. Shortcut for all track variants |
ALLARENAS | ARENAS CTARENAS CTTRACKS |
This modifier is available since v2.11a. Shortcut for all arena variants |
ALLREFS | CTREFS LEREFS |
This modifier is available since v2.11a. Shortcut for both REFS variants. |
Options | |||
---|---|---|---|
Option | Param | Description | |
-H | --no-header | Suppress the syntax information section in BMG text files. | |
-B | --brief | If set, the information header in decoded text files is suppressed (for historical reasons same as --no-header). If set at least twice, all comments are suppressed and the output is packed without empty lines. If set 3 times, the |
|
--encoding | name | Force an encoding for new BMG files. Accepted encoding names are
Mario Kart Wii uses encoding |
|
--inf-size | size | Defines the 'INF1' size of new BMG files between 4 and 1000. The first 4 bytes of a INF1 record is an offset into the string pool and the remaining bytes the attributes. Maximal 40 attribute bytes are supported and additional bytes are assumed to be NULL. All BMG files of MKW have a size of 8. | |
--bmg-mid | [mode] | Control the creation of BMG section |
|
--force-attrib | attrib | Forces, that all attributes are set to this vector. | |
--def-attrib | attrib | Define the default attributes for BMG files. If not set, the default attributes are estimated. On text output, strings with default attributes are printed without attribute vector. The usual default attribute for MKW is |
|
--no-attrib | Suppress the output of any BMG attributes if creating BMG text files. | ||
--x-escapes | Use \x{} escapes instead of \z{} escapes. | ||
--old-escapes | To be compatible with v1.43 and earlier, print 1A escape sequences with total size of >12 bytes as single words using \x{}. Also don't use \x{} and \u{} with parameter lists. | ||
-1 | --single-line | If set, don't print continuation lines for BMG text output. If set twice, print only single text lines and suppress attributes like option --no-attrib does it. | |
-l | --long | Print long numeric message IDs instead of alternative message names like Txx, Uxx or Mxx. | |
-X | --export | Enable the export mode and create small and machine readable text files for easy post processing. The option works similar like |
|
--no-bmg-colors | If set, suppress the output of '\c{color}' escape sequences for colors definitions in BMG text output to be compatible with old versions of the tools. | ||
--bmg-colors | Force output of '\c{color}' escape sequences with names, even for foreign (not MKWii) BMG files. | ||
--no-bmg-inline | Print BMG attributes as separate line before the message definition to be compatible with versions until v1.39. The output for the standard value 0x01000000 is always suppressed. This was the default until v1.43. | ||
--compatible | vers | The option expects a version number (format |
A
Example (line breaks added for readability):
21, LE-CODE, v=1, ct=0, le=1, par=3ff0+10, rcup=6800+3fe, bcup=6bfe+2, t1=7000+1000, t2=0+0, a1=7020+a, a2=0+0, ref=8000+1000All numbers are printed in hex.
The following table lists all
Name | Example | Description |
---|---|---|
v | 1 | Version number. |
ct | 0 |
|
le | 1 |
|
par | 3ff0+10 | Message ID range of the parameter block for mkw-ana. |
rcup | 6800+3fe | Message ID range of the names of the racing cups. |
bcup | 6bfe+2 | Message ID range of the names of the battle cups. |
t1 | 7000+1000 | Message ID range of the racing track names (first set). |
t2 | 0+0 | Message ID range of the racing track names (second set). Empty for CT-CODE and LE-CODE. |
a1 | 7020+a | Message ID range of the battle arena names (first set). |
a2 | 0+0 | Message ID range of the battle arena names (second set). Empty for CT-CODE and LE-CODE. |
ref | 8000+1000 | Message ID range of the track-to-cup references. |