Compiling riidefi/mkw on Windows
The riidefi/mkw repository is a matching decompilation project for Mario Kart Wii that compiles 1:1 to the original game. Setting it up on Windows requires several steps to install dependencies and configure the build environment properly.
Prerequisites
Before starting, you'll need to install the following software:
- Python 3: Required for running the build scripts
- DevKitPro: Needed for the ppc-eabi assembler and gcc dependency files
- Ninja: The build system used by the project
- CodeWarrior compilers: These come with the repository in the
tools directory
- Original PAL binaries: You'll need legal copies of the original game files
Setting Up the Repository
-
First, clone the repository:
git clone https://github.com/riidefi/mkw.git
cd mkw
-
Place a copy of Mario Kart Wii's PAL binaries in the following locations:
artifacts/orig/pal/main.dol
artifacts/orig/pal/StaticR.rel
Python Environment Setup
It's recommended to use a Python virtual environment for this project:
-
Create a new virtual environment:
python -m venv env
-
Allow executing the Activate script (Windows-specific):
powershell -ExecutionPolicy Bypass -File ".\env\Scripts\Activate.ps1"
-
Activate the virtual environment (do this each time you open a new terminal):
.\env\Scripts\Activate.ps1
-
Install the required Python dependencies:
pip install -r requirements.txt
Building the Project
-
If this is your first time building the repository or you've made changes to the slice definitions, generate the build system:
python configure.py --regen_asm
-
Build the project using Ninja:
ninja
-
The final build results will be located at:
artifacts/target/pal/main.dol
artifacts/target/pal/StaticR.rel
Code Quality and Formatting
The project uses pre-commit hooks to ensure code adheres to formatting rules:
-
Install pre-commit hooks:
pre-commit install
-
Run the hooks on all files:
pre-commit run --all-files
Understanding Symbol Dead-Stripping
By default, the CodeWarrior linker would remove any symbols it considers unused. To prevent this, the gen_lcf.py script places all objects into the FORCEFILES linker directive. In special cases where dead-stripping is needed:
- Set
strip to 1 in the slices CSV
- List all symbols that should not be stripped in the
FORCEACTIVE directive in dol.base.lcf
Troubleshooting
If you encounter build errors:
- Make sure all dependencies are correctly installed
- Verify the original PAL binaries are placed in the correct locations
- Check that you're using the correct Python environment
- Ensure the CodeWarrior compilers in the
tools directory are properly set up
For more specific issues, refer to the project's CONTRIBUTING.md file, which provides an in-depth guide on how the decompilation project works and how to contribute[1][11].
Further Development
If you're looking to contribute to the project:
- Read the CONTRIBUTING.md file for detailed guidance
- Understand the code quality principles of the project
- Note that while the original game was written in C++03, the decompilation uses some modern C++ features for readability, which are defined out when compiling for C++03
The primary goal is to maintain absolute code accuracy, with a special linker setup used to verify that the compiled code matches the original game exactly[1][11].