prevnext   » SZS: Wiimms SZS Toolset » wstrt: Wiimms StaticR Tool

wstrt: Wiimms StaticR Tool

Wiimms StaticR Tool : Manipulate the 'main.dol' and 'StaticR.rel' files of Mario Kart Wii.

Contents

1.   Syntax

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

2.   Features of wstrt

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.
DUMP Dump the structure of REL files (e.g. StaticR.rel) and of DOL files (e.g. main.dol) as text. Wildcards and pipe characters are parsed.
HEXDUMP XDUMP Dump the content of DOL files as hex dump and use virtual addresses. Wildcards and pipe characters are parsed. Select parts by --vaddr, --faddr and --sname. Without selectors, the whole file is dumped.
PORT The command expects a list of keywords or hex numbers. Keywords are PAL (default), USA, JAPAN, KOREA, or any abbreviation of them. They select the region for the following addresses. The hex numbers (with or without 0x prefix) are interpreted as addresses. If an address begins with m, M, s or S, then it is interpreted as a file offset for main.dol or staticr.rel. If the number begins with a point (.), then it is interpreted as a cheat code. In this case, the lowest 25 bits are interpreted as address and the highest 7 bits are saved and used for the address output. All addresses are ported to all other regions. The result is printed as colorized table.
WHERE A list of addresses in hex format is expected as input. The segments in which the specified addresses are located is calculated for each region. The result is output as a human and machine readable table.

This command is well suited to converting addresses into file offsets and vice versa.

EXTRACT X Extract the sections of DOL and REL file into a directory. Wildcards and pipe characters are parsed.
TRACKS Show track infos in the order of the 'StaticR.rel' files. If no file is entered, the standard order is used.
ARENAS Show arena infos in the order of the 'StaticR.rel' files. If no file is entered, the standard order is used.
FILES List track and arena file names in machine readable format. Use the order of the entered 'StaticR.rel' files. If no file is entered, the standard order is used.
FIND Find a track or arena by keyword and print one line for each keyword in machine readable format 'type slot' or, if not found, a simple '-'. The name is searched in the entered context (tracks or arenas). If TRACK or ARENA is prefixed by a plus, then a failed search will be continued in the other context. If at least one name is not found, the tool terminates with exit code NOT_EXISTS.
POINTS PTS Print a table with the points assigned to player after a versus or room race for each entered file. If no file is entered, the standard table is used. However, if option --points is set only the resulting table is printed.
ANALYZE ANA Open 'StaticR.rel' and DOL files and analyze them. Wildcards and pipe characters are parsed. The files will be classified using SHA1 checksums.
PATCH Patch 'main.dol' and 'StaticR.rel' files of Mario Kart Wii. Wildcards and pipe characters are parsed. No backup is made.

4.   Options in alphabetic order

Options
Option Param Description
--add-ctcode If source is an original main.dol file of MKWii, then append 2 sections (usually T2 and D8) with CT-CODE. The CTCODE is inserted after sections defined by --add-section and then only, if there are no address collisions.

If --ct-dir is used, then files named rmc[ejp]/boot_code.bin and boot_code.bin for T2, and rmc[ejp]/boot_data.bin and boot_data.bin for D8 are searched.

--add-lecode Add newest LE-CODE starter from 2023-12 to main.dol.
--add-old-lecode Add old LE-CODE starter from 2019-01 to main.dol.
--add-section file Each option call adds the filename to an internal list. Each file must be of type GCT, GCT-TXT, GCH or WCH. All GCT files together are combined with an internal code handler to one section (like a GCH file). GCH and WCH define sections and patches. The defined sections are added and VBI hooks are optionally initialized. Use option --force to allow overlapped sections. Use option --verbose up to 2 times for a log.

If parameter FILE contains at least one wildcard (e.g. "*.GCT"), then FILE is used as search pattern and all found files are added. Quote FILE for this purpose.

If a single file is not found and the filename (not path) contains at least 1 '@' character, then all '@' characters of it are replaced by the region code (one of P,E,J,K) for a second try.

The intention of this option is to add a Gecko Code Handler and cheat codes to a main.dol for automatic execution.

--address addr Use ADDR instead of null as start address for the dump.
--align Try to align the dump, so that the addresses (printed or not) are multiple of bytes-per-line.
--all-ranks [=mode] If set to ON (default without parameter), the server query to Nintendos servers is manipulated, so that the player will find all players in online races independent of their ranking points. Value RESTORE disables this feature and restores Nintendos original query. Value NONE disables this kind of patching (default).
--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.

--allow-user-gch [=mode] This option is only relevant, if main.dol is patched for wiimmfi.de. It is dedicated to custom distribution creators for test purposes. If enabled, a user can load an own instance of Gecko Code Handler and cheat codes and can use them online. If disabled, patching for online modus is disabled if an alternative Gecko Code Handler is detected.

Parameter MODE is optional. If set, OFF disables and ON enables this feature. For mode AUTO (default) it depends on other options.

-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.

--be Use big endian for binary data (default).
-B --brief List only the track file names and suppress table header and footer.
--bt char Reset (str is empty) or replace the second character of 'bt' to create an own online world for battles. The file StaticR.rel will be patched at 4 places.
--bt-region region Same as --region, but only for online battles.
--bytes num Print up to NUM bytes per line instead of 16. The maximum allowed value is 600. The effective number of bytes per line is format dependent (multiple of format size).
--c-syntax Print output in `C' syntax.
--cannon idx,p1,p2,p3,p4 Patch parameters for cannon with index IDX (0..2). Parameters P1..P4 are floating point numbers. Repeat this option for each cannon, that should be modified.
--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.
--clean-dol Remove additional DOL sections, reset entry point and VBI address, and try to restore other patches known by SZS tools. This is done after loading a DOL and before analysing and patching to allow re-patching.
--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.
--ct-dir dir Define a search directory for CT-CODE parts and use the internal copies only, if no valid file is found. Each file is searched without and then with extension '.bz2'. For both cases bzip2 files are detected and decompressed. Only files with correct file type are accepted.

Use this option multiple times to define more than one search directory.

--de Use german track and arena names.
--dec Print integer numbers as decimal numbers.
-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.
--domain dom Define a domain for option --https. The default is 'wiimmfi.de'.
--double Format: Print each 8 bytes as double floating point number.
-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$'.
-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.
--faddr RANGE Comma separated list of file addresses to select the hex-dump ranges. Each element is either ADDRESS (1 byte) or START:END or START#SIZE.
--float Format: Print each 4 bytes as floating point number.
--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! <<<

--format Add '#FORMAT:' info lines.
--gct-addr address If --gct-move is active, a text section is created to manage the code handler. This section is only needed at start and is placed by default at address 0x802c0000 (part of BSS, good address for all 4 regions). This option changes the start address of the section. If address is 0 or invalid, then unused BSS space is searched.
--gct-move [=mode] If a section is of type gecko code handler + cheat code, then make the heap smaller and move the cheat codes before the FST section.

Parameter MODE is optional. If set, OFF disables and ON enables this feature. For mode AUTO (default) this feature is enabled, if the cheat codes are too large (end>0x80003000) or for internal conflicts.

--gct-space size Define the minimal space for the code part of --gct-move. This value is ignored, if it is smaller than the size of the cheat codes. This debug option was only implemented to test the memory allocation by --gct-move with large blocks.
-h --help Stop parsing the command line, print a help message and exit.
--hex Print integer numbers as hexadecimal numbers (default).
--https mode Patch the https strings of REL and DOL files. 'mode' is one of the following keywords:

RESTORE restores the original URLs and domains.

HTTP replaces HTTPS requests by HTTP and sub-domain 'naswii.' by 'nas.'.

DOMAIN replace HTTPS requests by HTTP and the domain 'nintendowifi.net' by a domain specified by option --domain.

SAKE0 same as DOMAIN, but don't replace URLs with SAKE domain.

SAKE1 same as SAKE0, but replace HTTPS of SAKE domains.

-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.
--i1 Format: Print single bytes as integer number (default).
--i2 Format: Print each 2 bytes as integer number.
--i3 Format: Print each 3 bytes as integer number.
--i4 Format: Print each 4 bytes as integer number.
--i5 Format: Print each 5 bytes as integer number.
--i6 Format: Print each 6 bytes as integer number.
--i7 Format: Print each 7 bytes as integer number.
--i8 Format: Print each 8 bytes as integer number.
--le Use little endian for binary data.
--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] This option is completely ignored by wlect. It only exists due to compatibility with the other tools.
-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.
--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.
--meno Patch some 'MenuSingle' and 'MenuMulti' strings of file StaticR.rel for online usage to 'MenO*' (MenuOnline) to distinguish between offline and online races.
--move-d8 Move the CT-CODE section D8 to another place at the middle of binary. It is done automatically, if the original place overlaps other existing sections.
--narrow Suppress the spaces that are usually inserted for readability.
-0 --no-0x Suppress 0x prefix of hex numbers. This is the default for cheat codes.
--no-address Suppress the address column of the dump.
--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-null Ignore data lines with NULL bytes only and print a summary for each NULL block. ('#NULL: ...')
--no-numbers Suppress the numbers column of the dump.
--no-pager Forbid the internal usage of a pager.
--no-text Suppress the text column of the dump.
--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.
--order pujk The parameter is scanned for the first appearance of letters P (for PAL), U (USA), J (JAPAN) and K (KOREA) to define the order of the output. Case is ignored. Missing letters are added automatically. The default is 'PUJK'.
-o --overwrite Overwrite already existing files without warning and ignore option --number.
--pb-mode mode Mode for the patched-by string: OFF disables modifications. RESET resets the string to stars. WIIMMFI defines it only, if patched for Wiimmfi. AUTO (default) defines it only, if patched. ALWAYS defines it always.
--points list This patch option 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.
--port-db file Load the specified update file and replace the internal porting database. If not set, then file port-db.bin is searched in the share path.
-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 --region region If 'region' is an unsigned number, the region for online versus races and for battles is patched to the entered number. If the number is prefixed by the letter 't', a test mode is enabled and the places are patched with ascending numbers. You can patch StaticR.rel and main.dol.

Otherwise a keyword is expected. Official regions are: JAPAN(0), AMERICA(1), EUROPE(2), AUSTRALIA(OCEANIA,3), KOREA(4), TAIWAN(5) and CHINA(6). RESTORE restores the original Nintendo values and NONE disables region patching (default).

See https://wiimmfi.de/reg-list for other regions.

-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.
--small Each call will halve the number of bytes per line. Usually, 16 bytes per lines are reduced to 8, then to 4, 2 and 1. The effective number of bytes per line is format dependent.
--sname LIST Comma separated list of section names to select the hex-dump ranges.
-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.

--trigger num If the number NUM is found and printed, close the current line and start with a new one. If --align is set too, continue the next line with the current column. The trigger works only for integer formats, but not for floats.
-u --update Update only existing files and don't create new files. If set, --overwrite and --remove-dest are ignored.
-U --upper Print digits A-F of hex numbers in upper case. This is the default for cheat codes.
--vaddr RANGE Comma separated list of virtual addresses to select the hex-dump ranges. Each element is either ADDRESS (1 byte) or START:END or START#SIZE.
-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.
--vs char Reset (str is empty) or replace the second character of 'vs' to create an own online world for versus races. The file StaticR.rel will be patched at 4 places.
--vs-region region Same as --region, but only for online versus races.
-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.

--wc24 Exclude 2 strings of file StaticR.rel from --wiimmfi and --domain patch to enable WC24 support.
--wide Each call will round down the current bytes per line value to the next multiple of 16 and then increment it by 16. Usually, 16 bytes per lines are enhanced to 32, then to 48, 64, 80 and so on. The effective number of bytes per line is format dependent.
--width width Define the terminal width (number of columns) for help and some other messages and disable the automatic detection of the terminal width.
--wiimmfi Patch the files for the new custom server. It is a short cut for --https domain --domain wiimmfi.de.
--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.
--zeros Print integer numbers with leading zeros.