GithubHelp home page GithubHelp logo

malleoz / mkw Goto Github PK

View Code? Open in Web Editor NEW

This project forked from em-eight/mkw

0.0 0.0 0.0 6.47 MB

Decompilation of Mario Kart Wii

Shell 0.02% C++ 35.20% Python 5.07% C 59.09% Assembly 0.16% CSS 0.12% Dockerfile 0.03% Jinja 0.31%

mkw's Introduction

mkw

build badge dol progress badge rel progress badge total progress badge

A matching decompilation of Mario Kart Wii. All code in this repository will compile 1:1 to the original game. It produces the following files: mkw_pal.dol: sha1: ac7d72448630ade7655fc8bc5fd7a6543cb53a49 StaticR.rel: sha1: 887bcc076781f5b005cc317a6e3cc8fd5f911300

Accuracy

The primary priority is to maintain absolute code accuracy. To automate verification of this, a special linker setup is used to emplace compiled code back into the original executable, forming a new executable. This new executable is hashed to ensure it matches the original. Once all code is decompiled, this setup will build a new executable from scratch, sampling none of the original.

Code Quality

I have written code to be as readable and maintainable as possible. While the original access modifiers and trivial encapsulations have been lost to the optimizer, I have reconstructed both to minimize unsafe data exposure. Common sense debug assertions have been added, enforcing unchecked preconditions.

Modern C++isms

While the original game was written and compiled as C++03, several modern C++ features have been used to aid readability and increase code quality. All are define'd out when compiling for C++03. For example: strongly typed null pointers with nullptr and the override specifier.

Documentation

Every fully understood piece of reverse engineered data has been documented in a consistent doxygen style, here.

Dependencies

  • DevKitPro (for the ppc-eabi assembler, and gcc dependency files)
  • CodeWarrior compilers (in tools)
  • Ninja
  • Python 3
  • Place a copy of Mario Kart Wii's PAL binaries:
    • artifacts/orig/pal/main.dol
    • artifacts/orig/pal/StaticR.rel

Python Workspace

This build system assumes that a python command is available that points to a compatibly python 3 interpreter

venv

It is recommended to setup a Python virtual environment to simplify workspace setup. A venv saves you from installing dependencies system- or user-wide.

Run the setup steps once:

# Initialize your venv in the ./env dir.
python3 -m venv env
# (Windows only) Allow executing the Activate script.
powershell -ExecutionPolicy Bypass -File ".\env\Scripts\Activate.ps1"

Then, each time you open a terminal, enter the venv:

  • Windows: .\env\Scripts\Activate.ps1
  • Good OSes: source ./env/bin/activate

Install dependencies

pip install -r requirements.txt

Building

If you're building the repository for the first time or any changes were made to the slice definitions, run configure.py --regen_asm to generate the build system. Otherwise, just run ninja. Final results:

  • artifacts/target/pal/main.dol
  • artifacts/target/pal/StaticR.rel

Unit testing

We use pytest.

Symbol dead-stripping

By default, the CodeWarrior linker wants to remove any symbols (e.g. functions) that it considers unused. Due to the unique nature of this build system, this would fail and result in all functions being removed.

To fix this, the gen_lcf.py script places all objects into the FORCEFILES linker directive. This prevents any content from being dead-stripped.

In edge cases require carefully controlled use of the dead-stripping feature. For example: Symbols that were stripped in the initial build retain all string literals. This is very hard to replicate without dead-stripping: Simply commenting out the stripped function would result the string literals from vanishing too.

The dead-stripping feature can be re-enabled by:

  • Setting strip to 1 in the slices CSV
  • Listing all symbols that will not be stripped in the FORCEACTIVE directive in dol.base.lcf (all other symbols get thrown out)

Contributing

Read CONTRIBUTING.md for an in-depth guide for a guide on how this decompilation project works and how to contribute.

pre-commit

This project uses pre-commit ensure code adheres to formatting rules.

To enable, run:

pre-commit install
pre-commit run --all-files

.rel support

Most of Mario Kart Wii's game code is located inside a relocatable module (StaticR.rel for release builds). The decompilation builds this.

mkw's People

Contributors

riptl avatar riidefi avatar em-eight avatar stblr avatar vabold avatar narahiero avatar dependabot[bot] avatar seekyct avatar atisharibeiro avatar gnomeddev avatar swarejonge avatar thodoris1999 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.