3.0 KiB
Decompiling
This document describes how you can start decompiling code and contribute to the project. Feel free to ask for help if you get stuck or need assistance.
Pick a source file
See the decomp tag in the issue tracker for
a list of delinked source files that are ready to be decompiled. This list grows as more source files are delinked from the
rest of the Assembly code.
You can claim a source file by leaving a comment on its issue, so that GitHub allows us to assign you to it. This indicates that you are currently decompiling that source file.
If you want to unclaim the file, leave another comment so we can be certain that the source file is available to be claimed again. Remember to make a pull request of any notable progress you made on the source file, which can include non-matching functions.
Decompiling a function
Say you've found a function you want to decompile. Here are the steps we recommend for decompiling it:
- Visit decomp.me and start decomping.
- Under the platforms, select "Nintendo DS".
- Select compiler version
2.0sp1p5. - Copy and paste the target assembly for your function, including the
func_startandfunc_endmacros, and the pool constants. For example:
.global func_ov09_0211bf48
thumb_func_start func_ov09_0211bf48
func_ov09_0211bf48: ; 0x0211bf48
ldr r0, _0211bf50 ; =data_ov09_0211f59c
ldrb r0, [r0]
bx lr
nop
thumb_func_end func_ov09_0211bf48
_0211bf50: .word data_ov09_0211f59c
- Run
m2ctx.py include/MyHeader.hpp -cto generate a context and put it in your clipboard.- If no suitable header file exists, make a new one and put any structs and types you need in there.
- Paste the context into decomp.me, and create the scratch.
- Copy the
CC_FLAGSfromMakefileinto the arguments field in decomp.me.- Replace the
-d $(REGION)flag with whichever region you intend to decompile for. You can also delete the flag entirely if the function contains no region differences.
- Replace the
- Decompile the function and try to get a 100% match.
- There's no ARM decompiler in decomp.me yet, but Ghidra does the job quite well. See the Ghidra section for more info.
- If you're unable to get a 100% match, share your decomp.me scratch with other contributors and they may assist you.
- In the worst case, you can also contribute non-matching functions to this project.
The Ghidra project
We use a shared Ghidra project to analyze the game and decompile functions. To gain access to the project, install Ghidra version 10.2.3 and request access from @aetias on Discord.