Matching work in sm64dx requires byte-for-byte agreement between the recompiled ROM and the original baserom. Two Python tools make that verification practical:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Project516/sm64dx/llms.txt
Use this file to discover all available pages before exploring further.
diff.py compares the compiled assembly for a specific function or address against the disassembly of the original ROM, and first-diff.py scans the entire binary to find the very first instruction that diverges. Both tools read their configuration from diff_settings.py in the repository root.
diff.py
diff.py disassembles the same region of code from two sources — your freshly built ROM and the original baserom — and prints a colour-coded side-by-side comparison. Differences in register use, immediates, or instruction selection appear immediately, making it straightforward to iterate on a function until it matches.
Configuration
The tool readsdiff_settings.py at startup. The relevant settings for sm64dx are:
diff_settings.py
mapfile tells diff.py how to resolve symbol names to addresses. myimg is the ROM you built and baseimg is the unmodified reference ROM. source_directories controls where the tool looks for C source to annotate the diff.
Version flags
Pass a version flag to target a ROM other than US:| Flag | Version |
|---|---|
-u | United States (default) |
-j | Japan |
-e | Europe (PAL) |
-s | Shindou (Rumble Pak) |
-c | iQue (Chinese) |
Example usage
To diff against the Shindou version, pass
-s and ensure
baserom.sh.z64 is present in the repository root. The diff_settings.py
will automatically point baseimg and mapfile at the Shindou build
artifacts when -s is supplied.first-diff.py
first-diff.py does a linear byte scan of the compiled ROM and the baserom to find the earliest instruction address where the two diverge. This is useful at the start of a matching session when you need to know where to begin, or after a refactor when you want to confirm that your changes have not accidentally broken a previously matched region.
Basic usage
The -d flag
Pass-d to immediately launch diff.py on the result, jumping straight into the side-by-side view at the first differing function:
Why these tools matter
sm64dx aims to produce a ROM that is identical to the original at the binary level. Without assembly diffing, the only signal that something is wrong is a failing byte comparison of the full ROM — which tells you nothing about where or why.diff.py and first-diff.py give you precise, function-level feedback during the decompilation loop, making it feasible to match hundreds of functions systematically rather than hunting for differences by hand.