Files
psxrecomp/tools/check_pc_dispatch.py
Matthew Stanley e88e9a0233 phase 4: fix mc_flag persistence so multi-sector card reads work
Before: only sector 0 read succeeded; sector ≥1 reads aborted at 2 bytes
because mc_flag was loaded from mc_slots[].flag on every 0x81 select but
never saved back. The clear in MC_CMD lived only in the working static, so
every reselect re-loaded the stale 0x08 ("new card / changed battery") init
value, and the BIOS bailed every multi-sector op as "card was just inserted,
re-init."

After: BIOS shell memcard menu reads the full 15-sector directory area for
both slots. Real save filenames decode (e.g. "BISLPS-01234SAVE00") and per
card icons render in the bottom panes — the Phase 4 success criterion.

Also bundled this session:
- debug_server: B9D0..B9F0 added to always-on wtrace ranges; fn_dump_parse
  default window scoped to 1M most-recent entries (filter scans against the
  full 128M ring used to freeze the debug server thread for many seconds).
- ISSUES.md + diagnostic tools/*.py written during the audit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 16:43:07 -07:00

37 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Check what fn_entries have happened, filter by addr range. Args: addr_lo addr_hi [max]"""
import socket, json, sys
from collections import Counter
addr_lo = int(sys.argv[1], 16) if len(sys.argv) > 1 else 0
addr_hi = int(sys.argv[2], 16) if len(sys.argv) > 2 else 0xFFFFFFFF
max_count = int(sys.argv[3]) if len(sys.argv) > 3 else 100000
def call(d):
s = socket.create_connection(("127.0.0.1", 4370), timeout=120)
s.sendall((json.dumps(d) + "\n").encode())
buf = b""
while True:
c = s.recv(65536)
if not c: break
buf += c
if buf.strip().endswith(b'}'):
try: json.loads(buf.decode()); break
except: continue
s.close()
return json.loads(buf.decode())
r = call({'id': 1, 'cmd': 'fn_entry_dump',
'addr_lo': f'0x{addr_lo:08X}', 'addr_hi': f'0x{addr_hi:08X}',
'max_count': max_count})
entries = r.get('entries', [])
print(f"total fn_entries={r.get('total')} oldest={r.get('oldest')} returned={len(entries)}")
by_func = Counter()
by_func_t1 = {}
for e in entries:
by_func[e['func']] += 1
by_func_t1.setdefault(e['func'], Counter())[e['t1']] += 1
for func, n in by_func.most_common(40):
t1s = by_func_t1[func].most_common(3)
t1str = ' '.join(f"t1={t} ({c})" for t, c in t1s)
print(f" {n:>6}× func={func} {t1str}")