Files
psxrecomp/tools/rapid_poll.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

36 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Rapidly poll a RAM address and report unique values seen."""
import socket, json, struct, sys, time
port = int(sys.argv[1])
addr = int(sys.argv[2], 16)
duration = float(sys.argv[3]) if len(sys.argv) > 3 else 5.0
label = sys.argv[4] if len(sys.argv) > 4 else "value"
seen = {}
reads = 0
start = time.time()
while time.time() - start < duration:
try:
s = socket.create_connection(('localhost', port), timeout=1)
cmd = f'{{"cmd":"read_ram","addr":"0x{addr:08X}","len":4}}\n'
s.sendall(cmd.encode())
data = b''
while b'\n' not in data:
data += s.recv(4096)
s.close()
resp = json.loads(data.split(b'\n')[0])
if resp.get('ok'):
raw = bytes.fromhex(resp['hex'])
val = struct.unpack_from('<I', raw, 0)[0]
seen[val] = seen.get(val, 0) + 1
reads += 1
except:
pass
elapsed = time.time() - start
print(f'{label} at 0x{addr:08X}: {reads} reads in {elapsed:.1f}s')
for val, count in sorted(seen.items()):
print(f' 0x{val:08X} ({val:5d}): seen {count} times ({100*count/reads:.1f}%)')