Personal fork so AI-assisted decomp work has a home without disturbing upstream. README explains the fork; AGENTS.md documents the method and forbids ever opening a PR against koopthekoopa/wii-ipl. Matching progress: +9 exact functions, 0 regressions, main.dol still byte-identical (26116613f624061ba99c8d1a299aaa6efa85670d). iplESMisc gains CheckTmdParentalControl, CheckSafeDeleteTitle, NumPrivateContents, checkContentsNum and GetValidTicketIndex, plus the other functions matched in the previous pass. The load-bearing finding, written up in AGENTS.md: MWCC emits a translation unit's string literals in source-token order. A missing function, or an inverted if/else, shifts every later string offset and breaks functions that were never edited. Fixing that pool ordering lifted TMDFile::Open from 99.92 to 99.96 without touching Open. Adds tools/decomp-assist/ with pool_diff.py, ctxdiff.py, disasm_fn.py, export_pyghidra.py and the Ghidra decompilation dump.
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Compact function diff with context: python ctxdiff.py <unit> <symbol> [--full]"""
|
|
import sys
|
|
|
|
sys.path.insert(0, "/home/cole/projects/tests")
|
|
from odiff import dis, sym
|
|
import os
|
|
import itertools
|
|
|
|
os.chdir("/home/cole/projects/tests/wii-ipl")
|
|
|
|
|
|
def main():
|
|
unit, name = sys.argv[1], sys.argv[2]
|
|
so, ss = sym(f"build/43U/src/{unit}.o", name)
|
|
bo, bs = sym(f"build/43U/obj/{unit}.o", name)
|
|
a = dis(f"build/43U/src/{unit}.o", so, ss)
|
|
b = dis(f"build/43U/obj/{unit}.o", bo, bs)
|
|
print(f"src {hex(ss)} base {hex(bs)} insns {len(a)}/{len(b)}")
|
|
if len(a) != len(b):
|
|
import difflib
|
|
sm = difflib.SequenceMatcher(None, [str(x) for x in a], [str(x) for x in b], autojunk=False)
|
|
for tag, i1, i2, j1, j2 in sm.get_opcodes():
|
|
if tag == 'equal':
|
|
continue
|
|
print(f"--- {tag} mine {i1}:{i2} base {j1}:{j2}")
|
|
for k in range(i1, i2):
|
|
print(f" M {k:>4} {a[k][0]} {a[k][1]}")
|
|
for k in range(j1, j2):
|
|
print(f" B {k:>4} {b[k][0]} {b[k][1]}")
|
|
return
|
|
diffs = [i for i, (x, y) in enumerate(zip(a, b)) if x != y]
|
|
print(f"diffs {len(diffs)}: {diffs[:20]}")
|
|
for i, (x, y) in enumerate(zip(a, b)):
|
|
if x != y:
|
|
print(f" {i:>4} M {x[0]} {x[1]}")
|
|
print(f" B {y[0]} {y[1]}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|