Files
psxrecomp/tools/func_size.py
T
Matthew Stanley 101fd2e1a9 feat: 46 GTE library seeds + DuckStation oracle SW readback + debug tooling
Add 46 seeds for the libgte helper functions at BFC34E00-BFC36D00.
These wrap individual GTE operations (RTPS, RTPT, NCLIP, MVMVA, etc.)
and were never discovered because they're called via JALR function
pointers, not direct JAL. Coverage: 52→114 gte_execute, 166→429
LWC2/SWC2. Emitted functions: 1178→1214. Seeds: 960→1006.

Fix DuckStation oracle VRAM readback by setting
UseSoftwareRendererForReadbacks=true in settings.ini.

Add debug/analysis tools: GTE audit, VRAM stitching, rapid polling,
GPU info, divergence comparison, jump table dumps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-24 00:29:06 -07:00

35 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Check emitted function sizes vs expected ROM span."""
import re, sys
with open('generated/SCPH1001_full.c') as f:
lines = f.readlines()
funcs = []
for i, line in enumerate(lines, 1):
m = re.match(r'^void func_1FC([0-9A-Fa-f]+)\(CPUState\* cpu\) \{', line)
if m:
addr = int(m.group(1), 16) + 0xBFC00000
funcs.append((addr, i))
targets = [0xBFC34EC4, 0xBFC35FD0, 0xBFC36068, 0xBFC362D0, 0xBFC36740, 0xBFC36CF0]
for t in targets:
for i, (addr, lineno) in enumerate(funcs):
if addr == t:
next_line = funcs[i + 1][1] if i + 1 < len(funcs) else len(lines)
code_lines = next_line - lineno
rom_addrs = set()
for li in range(lineno - 1, min(next_line - 1, len(lines))):
m2 = re.search(r'0x(BFC[0-9A-Fa-f]{5}):', lines[li])
if m2:
rom_addrs.add(int(m2.group(1), 16))
if rom_addrs:
lo = min(rom_addrs)
hi = max(rom_addrs)
rom_bytes = hi - lo + 4
else:
lo = hi = rom_bytes = 0
print(f'func_1FC{t - 0xBFC00000:05X}: {code_lines:4d} C lines, '
f'ROM 0x{lo:08X}-0x{hi:08X} ({rom_bytes:5d} bytes = {rom_bytes // 4:4d} insns)')
break