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.
50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
import sys
|
|
from elftools.elf.elffile import ELFFile
|
|
|
|
MINE = 'build/43U/src/src/utility/iplESMisc.o'
|
|
BASE = 'build/43U/obj/src/utility/iplESMisc.o'
|
|
|
|
|
|
def pool(path):
|
|
e = ELFFile(open(path, 'rb'))
|
|
sec = {s.name: s for s in e.iter_sections()}
|
|
d = sec['.data'].data()
|
|
out = []
|
|
off = 0
|
|
while off < len(d):
|
|
end = d.find(b'\x00', off)
|
|
if end < 0:
|
|
break
|
|
s = d[off:end]
|
|
if len(s) >= 4 and all(32 <= c < 127 or c == 0x0a for c in s):
|
|
out.append((off, s.decode('latin1')))
|
|
off = end + 1
|
|
return out
|
|
|
|
|
|
def main():
|
|
mine = pool(sys.argv[1] if len(sys.argv) > 1 else MINE)
|
|
base = pool(sys.argv[2] if len(sys.argv) > 2 else BASE)
|
|
n = min(len(mine), len(base))
|
|
for i in range(n):
|
|
if mine[i][1] != base[i][1]:
|
|
print('FIRST DIVERGENCE at index %d' % i)
|
|
for j in range(max(0, i - 2), min(n, i + 5)):
|
|
mark = '*' if mine[j][1] != base[j][1] else ' '
|
|
print('%s %3d mine=%-8s base=%-8s' % (mark, j, hex(mine[j][0]), hex(base[j][0])))
|
|
print(' M %r' % mine[j][1][:70])
|
|
print(' B %r' % base[j][1][:70])
|
|
print()
|
|
print('mine has %d strings, base has %d' % (len(mine), len(base)))
|
|
return 1
|
|
print('POOL IDENTICAL up to %d (mine=%d base=%d)' % (n, len(mine), len(base)))
|
|
if len(mine) != len(base):
|
|
for j in range(n, max(len(mine), len(base))):
|
|
src = mine if j < len(mine) else base
|
|
print(' extra %3d %r' % (j, src[j][1][:70]))
|
|
return 0
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main())
|