How to create an LE-CODE Distribution
Introduction
LE-CODE is a code extension for Mario Kart Wii, written by Leseratte and Wiimm. It is most commonly used to create Custom Track Distributions, but also comes with a variety of additional features including:
- Increased Track slots
- Various Bugfixes
- Speedometer
- Debug Features
- Additional track features including LEX support
- Extended presence flags
- Working Battle Mode (unlike CT-CODE)
- Additional code support
While LE-CODE is a useful and extensive code extension, the documentation surrounding it and the creation of a distribution using it, is lacking in clarity, and is generally unorganised. This page is to serve a quick step-by-step guide to the creation of an LE-CODE distribution primarily targeting *nix operating systems and the command line.
Considerations
This tutorial covers the basics of creating an LE-CODE distribution, however may not the correct method of going about things. Instead it is simply the method that I've found to be the quickest and most straight-forward. Windows users should be able to follow this tutorial to an extent with some adaptation, but it is likely easier to follow with a suitable unix-like environment for Windows (such as msys2) or using the Windows Subsystem for Linux.
Prerequisite files
- A copy of Mario Kart Wii. (in ISO,WBFS,WIA or WDF format)
This should be obtained by dumping a copy of the game that you own using a tool such as CleanRip (also available at OSC).
The region does not matter, assuming you wish to target only the region of your disc.
Preparation
Step 1. Acquiring tools
There are two tool-sets that will be used extensively in this tutorial:
To obtain them, either install them via your package manager, or download the binaries for your system from the website. Each archive contains a simple install script that must be run as root. Either way, you'll primarily be using the tools:
- WIT, used to extract the MKW iso
- WSZST, used to manipulate (including extracting) U8 (SZS) archives, as well as to convert WU8 (wbz) archives.
- WLECT, the LE-CODE tool, used for everything to do with LE-CODE distribution creation.
One may also wish to download the Dolphin Emulator for testing purposes.
Step 2. Preparing tools, and environment
There's going to be lots of files at play here, so it's recommended to keep things organised. Therefore create a directory somewhere sensible that will contain your distribution while it is being prepared. This shall be referred to as the base directory.
Start out by downloading the "Track Prefixes" and "SHA-1 Reference" files from here, using the "Download LIST" button. Place both prefix.txt
and sha1-reference.txt
in your base directory.
Next, your MKW iso image should be extracted. (preferably this should be done at a directory level higher than your base directory, as it will be a useful reference for any future distributions one wished to make).
This is done with: wit extract [mkwii.iso]
Whereby:
extract
performs an extract operation on the file[mkwii.iso]
is a placeholder for the filename of your copy of MKW
Optionally a directory can also be provided as an output destination.
Creating an Auto-add Library
If one wishes to utilise WU8 (.wbz) archives, then an auto-add library must be generated using WSZST. This consists of common subfiles used in tracks by Nintendo, and is created using the "/Race/Course" directory from MKW.
To create the Auto-add library: wszst autoadd [./path_to/Race/Course/]
Whereby:
autoadd
manages the autoadd library[./path_to/Race/Course/]
is the path to /Race/Course. It is likely to begin with /DATA/files.
Once this is complete use wszst autoadd -v
to verify the library, and ensure that "LIST OF MISSED FILES" is blank.
Step 3. Obtaining tracks
The best way to browse for tracks is to use the Custom Mario Kart Wiiki. Find some tracks to your liking, and then download them from either the old CT-Archive, or the new SZS Library. Be aware that the old archive does contain more information, however is no longer updated as of around June 2024. This will provide one with a set of named and/or numbered .wbz files respectively. It is recommended to use these archives as the downloads are smaller, there are no dead links involved, working tracks will actually work (with clean and normalised archives), and a standardised naming system is used. It is worth noting that Wiimm's archive has a strict limit of downloads per hour per IP.
In order to create less work later, any numbered tracks should be renamed with at least the name of the track. (See #Automated Track Naming)
Step 4. Creating a LE-DEF file
A LE-DEF file is an LE-CODE definition file, it defines all the tracks and battle arenas including names, slots etc; as well as the cups they belong to. This can be generated automatically with wlect, and then edited if desired. To generate a starting file: wlect dis ledef=temp.ledef
Whereby:
dis
is shorthand for distribution, the distrib management commandledef=
tells wlect to output a ledef file
The resulting file is well-commented, and can be easily edited via any good text editor. Do read and review the options provided within.
Next, the LE-DEF file must be filled with the downloaded tracks, this can be also be done with: wlect dis temp.ledef prefix.txt "$TRACKDIR/*.wbz" ledef=dist.ledef
Whereby:
temp.ledef
is our starter file from earlierprefix.txt
contains a list of track prefixes"$TRACKDIR/*.wbz"
refers to a directory containing WU8 (.wbz) archives
This will produce a new LE-DEF file containing all the tracks, placed automagically into cups. This should be verified, and can edited to correct filenames and/or track/music slots.
Extra Info
Alternatives
Further Reading
Automated Track Naming
Unfortunately, SZS Library uses system whereby .wbz downloads are simply named based on their track ID, this makes it nigh impossible to identify a track based on its filename. A partial automated workaround is possible using Wiimm's CT archive as a resource for names. Using my wcta_browser, the ID's can be searched, and a proper filename returned.
Example script:
TRACKDIR=""
for i in "$TRACKDIR"/*.wbz;
do i=${i##*/};
mv "$TRACKDIR"/"$i" "$TRACKDIR/$(python wcta_browser.py -i "${i%.wbz}" -p title).wbz";
done
Whereby:
TRACKDIR
refers to a directory containing tracks in the WU8 (.wbz) format
Do backup any files just in case, and be aware that any track not in the archive (ie. newer than June 2024) will be renamed to an error message.
TODO: fix the damn thing add images add alternatives proper language support custom chars author credits