SSBM Decomp
|
This doc is designed to help beginners get into Melee decompilation (and hopefully contribute). We'll also try to answer common questions here and talk about motivations for working on this project.
The goal of this repo is to write C code that, after being compiled, matches the PowerPC assembly 100%. There's a bit of nuance here though. Let’s first take a look at what we’re working with:
The details for what produces these different artifacts is out-of-scope. Here’s what some Melee C code looks like (link):
and its corresponding PowerPC assembly:
So the repo is filled with .s
files and .c
files, where the C code inside the .c
files, each of which are a 100% translation of its corresponding .s
file that used to be in the repo. Note that once we successfully decompile a function, we remove it from the assembly.
No! And even initially, the code doesn’t have to be super-readable as we’re trying to get 100% match rate first.
So you can actually view the above example in an online tool that we use called decomp.me. Here’s a link to that specific decompliation. If you want to try doing this yourself, follow these steps:
When you initially create a new “scratch” in this site, it’ll actually do its best to decompile the assembly you give it (try hitting the “Decompile” button in the link). You’ll notice things it spits out like
which can be translated in kind-of-English as “temp_r31
takes the value at the memory address of arg0 + 0x2c
.” If you don’t know anything about arg0
, you can translate it to sketchy-C
…while this accomplishes the goal of getting a 100% match (you could pretty much do every memory access and set like this), we actually can guess what arg0
is in this case because of the file it’s in. You can do some digging yourself, but that line ends up translating to something like:
Think of the context as a giant header file which you then #include
at the top of your file. To generate context from a local repo, use m2ctx
. Run python3 tools/m2ctx/m2ctx.py -h
for a list of options.
So you want to find some assembly that:
To make sure it’s not already decompiled, take the label (e.g. ftColl_8007B8CC
) and search the repo for instances of it. If you don’t see any C code definitions with implementations, then it at least hasn’t been committed to the repo. You can also use grep
:
You then want to make sure no one is working on it. So search decomp.me for that label, and it’ll flag if anyone has tried decompiling it. If it’s clearly abandoned, it’s probably okay to fork it and try it out.
After you’ve done these steps, follow the above steps for pasting into decomp.me 🙂.
lwzu
zeros out part of the register, but only in 64bit mode).double
s.