prevnext   » SZS: Wiimms SZS Toolset » wbmgt: Wiimms BMG Tool

wbmgt: Wiimms BMG Tool

Wiimms BMG Tool : Convert and patch raw and text BMG (message) files.

Contents

1.   Syntax

wbmgt [option]... command [option|parameter|@file]...

2.   Features of wbmgt

Read »Features« for features of the whole toolset.

3.   Commands

VERSION V Print program name and version and exit.
HELP H Print help for commands and options.
CONFIG Show all information about the search for the configuration file and its content.
ARGTEST This debug command accepts all kinds of parameters and prints one line for each parameter. All tools know the ARGTEST command.
EXPAND This debug command accepts (like ARGTEST) all kinds of parameters and prints one line for each parameter. After that, the parameter is treated as a filename with wildcards and all matching files are searched. All tools know the EXPAND command.
TEST This debugging command accepts all options and parameters and prints a list of the internal option values. The command is designed to test the option parameters. The non option parameters are completely ignored.
COLORS Ignore all parameters and print colored text for testing.
ERROR ERR Translate an exit code to a message name. If no exit code is entered, print a table with all error messages. All tools know the ERROR command.
FILETYPE FT Scan the header of the entered files and print file type and path for each file as list. Wildcards and pipe characters are parsed. All tools know the FILETYPE command.
FILEATTRIB FA Print a table with attributes for all known file types. If at least one keyword is entered, only matching file types are printed. A keyword is either a file type (like 'BRRES' or 'BMG') or one of the printed keywords (like 'ARCHIVE' or 'EXTRACT'). All tools know the FILEATTRIB command.
POINTS PTS Print a table with the points assigned to player after a versus or room race.
REGEXP RE Test implementation of regular expressions. PATTERN is the regular expression to find matches. Each STRING is object of the match and replace operation.
EXTRACT Extract BMG section NAME of file SOURCE and write the binary data to standard output. If NAME consists of less than 4 characters, then the first section that starts with these characters is dumped.
SECTIONS List all sections of each binary BMG file. Print offset, size, magic and a short info. If known, print number and size of elements too. Wildcards and pipe characters are parsed.
LIST LS List messages to proof the content. Patches are applied before listing. The lines are cut to fit the terminal width. Wildcards and pipe characters are parsed.
SLOTS Print a slot ordered list with slot number, message id, delta and attributes. Patches are applied before listing. Wildcards and pipe characters are parsed.
DIFF CMP Compare two or more BMG (raw or text) files on string level and report mismatches for each string. If option --dest is set, then each source file is compared with a file in the destination. Patches are applied to all sources before comparing.
CAT Read the entered BMG files (text, binary or szs sub file) and print them as decoded text files to standard output. All BMG files of a single archive (SZS,...) are combined to 1 source. The output of all source files is concatenated. Wildcards and pipe characters are parsed.
MIX Read the entered BMG files (text, binary or szs sub file) and print them as decoded text files to standard output. All BMG files of all archives (SZS,...) are read. The output of all source files is combined and strings of later source files override prior defined strings. Wildcards and pipe characters are parsed.
IDENTIFIER ID Create a simple text BMG with the identifier message 3DEF only with respect to options --le-code and --ct-code. Print the result to standard output.
DECODE DEC Read the entered message files and decode them to text files. All BMG files of a single archive (SZS,...) are concatenated to 1 source. This command is similar to PATCH, but the result is always decoded. The default destination is '%P/%N.txt'. Wildcards and pipe characters are parsed.
ENCODE ENC Read the entered message files and encode them to BMG files. All BMG files of a single archive (SZS,...) are concatenated to 1 source. This command is similar to PATCH, but the result is always encoded. The default destination is '%P/%N.bmg'. Wildcards and pipe characters are parsed.
PATCH PAT Patch the entered files by using the patch list specified by option --patch-bmg. The coding of the source files is not changed. The default destination is '%P/%F'. Wildcards and pipe characters are parsed.

Use wszst patch --patch-bmg ... to patch BMG files within a SZS file.

4.   Options in alphabetic order

Options
Option Param Description
--align size Define an align value for the sub sections in the archive. The value must be a power of 2 and the default value is 32 (0x20)
--allow-all Usually commands accept only options with impact to the command. All other options fire a syntax error. But if --allow-all is set, all commands accept all options.

This makes changing the command of a long command line without removing useless options easier. It also helps to override wrong option permissions.

-A --arenas arenas Define a new arena order. A comma separated list in the format [a=]b or a:=b is expected. 'a' and 'b' are arena names or slot numbers. 'a' is the destination slot and 'b' the assigned arena. If 'a' is omitted, the next slot is used; this means [a=]b,c,d is possible.

Arenas will only be exchanged so that always all arenas are assigned. But if using ':=' the new slots are assigned without exchanging and the old values are lost.

--bmg-colors Force output of '\c{color}' escape sequences with names, even for foreign (not MKWii) BMG files.
--encoding name Force an encoding for new BMG files. Accepted encoding names are CP-1252, UTF-16BE (or UTF-16), SHIFT-JIS, UTF-8 and AUTO for automatic detection (default). Same keywords without minus signs are accepted too.

Mario Kart Wii uses encoding UTF-16BE; the default if no other encoding is defined.

--endian name Force an endian for new BMG files. Accepted values are BIG or BE for big endian, LITTLE or LE for little endian and AUTO for automatic detection (default).

Mario Kart Wii uses big endian; the default if no other endian is defined.

--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 MID1. Suppress the creation, if mode is OFF. Force the creation, if mode is ON. On mode AUTO (default), the source is analysed for the decision.
-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 #BMG file indentification is also suppressed.
--chdir dir Set a new working directory for all following options, for all parameters and for the command execution. This option can be used multiple times, but for parameter parsing and for command execution only the last usage is relevant. Nevertheless, '@param' values are scanned while reading the command line.
--colors [=modus] Define the modus for colored text output. Allowed keywords are: OFF or NO-COLORS to disable colors, AUTO (default) for automatic detection, ON for automatic detection but never OFF, 8-COLORS and 256-COLORS to force 8 or 256 color support. Without parameter, ON is used.

AUTO will enable colorized output only for terminals. AUTO and ON use environment variable TERM to find the correct color modus.

If a command is prefixed by 'C-', then --color=ON is used implicitly as default.

--compatible vers The option expects a version number (format '#.##' or 'v#.##') or a revision number (format 'r#') as parameter. If set, the tools try to create BMG and KMP text files, that are compatible to the entered version of the tools. This may override other legacy options.
--config file Define a configuration file or a directory as source. In later case, file 'wiimms-szs-tools.conf' is searched.

If option is not not set, then file 'wiimms-szs-tools.conf' is searched in different directories. Use command 'wszst CONFIG' to get more details.

-c --const list Define constant values, that are used by the internal encoders and by the numeric options as predefined global variables. This option allows a conditional encoding of text files. It can be used multiple times for multiple definitions.

The parameter is a comma separated list of terms and a term is 'name=expression'. The expression is calculated by the text parser.

--ct-code Enable CT-CODE support.
--de Use german track and arena names.
--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 [1].
-d --dest path Define a destination path (directory/file). The destination - means: write to standard output.

The path may contain escape sequences: %Q is replaced by the fully qualified source name. %P and %F are replaced by the source path or by the filename. %N and %E are replaced by source filename without extension or by the source extension. Finally, %T is replaced by the default extension of the destination format.

A '?' direct behind '%' in %E and %T conversions avoid that the same extension is used twice in row.

-D --DEST path Like --dest, but create the directory path automatically.
-E --esc char Define an alternative escape character for destination files. The default is '%'. For Windows batch files it is a good choice to set '-E$'.
-X --export Enable the export mode and create small and machine readable text files for easy post processing. The option works similar like -HBl11 for BMG text files.
-Y --extended-errors Enable extended error messages. This includes a source file and line reference. Logging level 1 activates it too. --xerr is a short cut.
--filter-bmg list If this option is set, the BMG messages are filtered by this list. Only enabled messages are exported to the output BMG file (binary or text).

The parameter is a list of message ids (short MID, 'Txx' or 'Uxx' or Mxx' or hex number) or message ranges (MID:MID) or one of the keywords NONE, IDENT (=ID), PARAM, CUPS, TRACKS, ARENAS, CHAT, CTCODE (=CT), CTUPS, CTTRACKS, CTARENAS, CTREFS, LECODE (=LE), LEUPS, LETRACKS, LEARENAS, LEREFS, XCODE (=X), XUPS, XTRACKS, XARENAS, XREFS, ALLCODE, ALLUPS, ALLTRACKS, ALLARENAS, ALLREFS, GENERIC or ALL. If an element is preceded by a minus sign, it is removed from the filter list (disabled).

With v2.01a, this option was renamed from --msg to the more meaningful name --filter-bmg. The old name is still available.

--force The tools analyse input files and reject files with invalid data structures. If --force is set, little repairable issues are ignored and a warning is printed.

Option --kmp force does the same, but only for KMP files.

>>> THE RESULT MAY BE INVALID OUTPUT FILES! <<<

--force-attrib attrib Forces, that all attributes are set to this vector.
-h --help Stop parsing the command line, print a help message and exit.
-i --ignore Ignore non existing source files without warning.
--in-order Process the input files in order of the command line and don't delete duplicates.
--le-04x Use format %04x instead of %03x for LE-CODE slots to enable uniform slot numbers if slots >4095 are used.
--le-code [=param] Enable LE-CODE and CT-CODE support. The optional parameter is deprecated and ignored.
-L --logging This debug option enables the logging of internal lists and maps. Set it up to three times to be more verbose.
-l --long Print long numeric message IDs instead of alternative message names like Txx, Uxx or Mxx.
--macro-bmg file Load a BMG file and add the messages to the macro library; already existing entries are replaced. The macro library is accessed by escape sequence \m{MID} as fallback, if the active file has not already defined the message MID by itself.
-M --max-file-size size This security option defines the maximum file size for input files; larger files are ignored with a warning. The default unit is MiB and the default size is 100 MiB (2 GiB for LTA); that should be enough for standard usage.
--max-width maxwidth Define the maximum terminal width (number of columns) for help and some other messages. The default is 120. This option is ignored if --width is set.
--no-attrib Suppress the output of any BMG attributes if creating BMG text files.
--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.
--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.
--no-colors Deactive colorized text. This is the default, if an output file is not a terminal.
-H --no-header Suppress the syntax information section in BMG text files.
--no-pager Forbid the internal usage of a pager.
--no-wildcards Disable wildcard parsing and use each filename exactly as specified.
--number If a file already exist, append a number directly before the file extension to make the filename unique. If other numbered files already exist (ignoring case), use the maximum existing index+1. --num is a short cut.
--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.
-o --overwrite Overwrite already existing files without warning and ignore option --number.
-P --patch-bmg mode[cond][=param] This option specifies a BMG patch mode. Some of the modes need a parameter or a file name of a BMG patch file (raw or text BMG), both separated by an equal sign. Modes with required file names are PRINT, REPLACE, INSERT, OVERWRITE, DELETE, MASK, EQUAL and NOTEQUAL. Modes with text parameter are FORMAT, REGEXP and RM-REGEXP. Standalone modes are ID, ID-ALL, UNICODE, RM-ESCAPES, RM-CUPS, CT-COPY, CT-FORCE-COPY, CT-FILL, LE-COPY, LE-FORCE-COPY, LE-FILL, X-COPY, X-FORCE-COPY and X-FILL. Unique abbreviations are allowed.

The optional condition COND is either '?MID' or '!MID'. In case of '?MID', the patch is only applied if the message id MID already exists. In case of '!MID', the patch is only applied if the message id MID does not exists.

If this option is used multiple times, all patch files will be processed in the entered order. --patch is a short cut.

--points list This option creates the new message 3FF0 to hold a description of the versus points table. It defines a new table for the points assigned to players after a versus or room race. The parameter is a blank or comma and slash (next row) separated list with numbers (points) between 0 and 255 and the following keywords: NINTENDO, LINEAR, WIN, WIN15, WIN25 to select a predefined table; NO-BONUS, BONUS, NULL, ONE as options; N1..N12 to select the row for N players.
-p --preserve Preserve file times (atime+mtime) while converting or copying files.
-q --quiet Be quiet and print only error messages. Multiple use is possible. Previous use of --verbose is reverted. The impact is command dependent. If set at least three times, almost all error messages will be suppressed.
-r --remove-dest Remove already existing files before creating it. If set, --overwrite is ignored. --rm-dest is a short cut.
--repair-magics [=mode] Control the reparing of missing or wrong magics of files and sub-files by analysing file path and file extension. MODE is one of OFF (default), ANALYZE or REPAIR (default, if set without mode). OFF disables this feature, ANALYZE enables it for analysis only, and REPAIR repairs all magics while reading the files. Keyword FNAME can be appended (separated by a comma) to give filename scanning the highest priority.

>>> THE RESULT MAY BE INVALID OUTPUT FILES! <<<

--sections Print in machine readable sections and parameter lines.
-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.
-t --test Run in test mode, modify nothing.

>>> USE THIS OPTION IF UNSURE! <<<

--timing Activate the timing of some operations. Logging level 3 activates them too.
-T --tracks tracks Define a new track order. A comma separated list in the format [a=]b or a:=b is expected. 'a' and 'b' are track names or slot numbers. 'a' is the destination slot and 'b' the assigned track. If 'a' is omitted, the next slot is used; this means [a=]b,c,d is possible.

Tracks will only be exchanged so that always all tracks are assigned. But if using ':=' the new slots are assigned without exchanging and the old values are lost.

-u --update Update only existing files and don't create new files. If set, --overwrite and --remove-dest are ignored.
-v --verbose Be verbose and print more progress information. Multiple use is possible. Previous use of --quiet is reverted. The impact is command dependent.
-V --version Stop parsing the command line, print a version info and exit.
-W --warn list Enable or disable warnings. Parameter 'list' is a comma separated list of keywords. A minus sign before a keyword disables a warning. Each occurrence of the option will only change entered warning and all other warnings are untouched.

Keyword DEFAULT resets the default settings, OFF disables and ALL enables all. The other allowed keywords are: INVALID-OFFSET.

--width width Define the terminal width (number of columns) for help and some other messages and disable the automatic detection of the terminal width.
--x-escapes Use \x{} escapes instead of \z{} escapes.
--xhelp Stop parsing the command line and print a help message with all commands included. Exit after printing.
-z --zero This option affects the exit status of the programs. Instead of an exit status, the value 0 is returned for OK. This happens for notices (-v, status<15), warnings (-vv, status<29), errors (-vvv, status<115) and fatal errors (-vvvv). The exit status for INTERRUPT (112) is never replaced.