Files
psxrecomp/tools/_card_txn_range.py
T
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

24 lines
992 B
Python

"""Dump card_txn entries by txn_seq range."""
import socket, json, sys
seq_lo = int(sys.argv[1]) if len(sys.argv) > 1 else 0
seq_hi = int(sys.argv[2]) if len(sys.argv) > 2 else 999999
s = socket.create_connection(('127.0.0.1', 4370), timeout=30)
s.sendall((json.dumps({'id':1,'cmd':'card_txn_dump','count':32}) + '\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
r = json.loads(buf.decode())
print(f"total_closed={r['total_closed']} open={r['open']}")
for e in r['entries']:
if not (seq_lo <= e['txn_seq'] <= seq_hi): continue
tx = ' '.join(b for b in e['tx'][:18])
rx = ' '.join(b for b in e['rx'][:18])
print(f"\n seq={e['txn_seq']:>3} slot={e['slot']} sec={e['sector']} bytes={e['bytes']:>3} end={e['end_reason']:>14} sf={e['start_func'][-6:]} ef={e['end_func'][-6:]}")
print(f" TX: {tx}")
print(f" RX: {rx}")