Port registry + per-call shadow in core/port (from the prototype) #5

Closed
opened 2026-10-28 22:48:00 +00:00 by Gatchan · 1 comment
Owner

Move others/proto/shadow into core/port/ using the LakeSnes instruction hook (no copied frame loop): registry (version, address, name, mode off/shadow/on, bridge, don't-care set, counters), clone, run C on the clone, run the original to its return, compare CPU/WRAM (minus dead stack below S)/VRAM/CGRAM/OAM/PPU regs/APU ports, skip interrupted calls, bridge fallback to the interpreter for unsupported entry states.

First port: battle Rand ($C2:4B5A), validated on US and JP. Prototype result: 13/13 on US, deliberately wrong N/Z caught (9/13).

Move `others/proto/shadow` into `core/port/` using the LakeSnes instruction hook (no copied frame loop): registry (version, address, name, mode off/shadow/on, bridge, don't-care set, counters), clone, run C on the clone, run the original to its return, compare CPU/WRAM (minus dead stack below S)/VRAM/CGRAM/OAM/PPU regs/APU ports, skip interrupted calls, bridge fallback to the interpreter for unsupported entry states. First port: battle `Rand` (`$C2:4B5A`), validated on US and JP. Prototype result: 13/13 on US, deliberately wrong N/Z caught (9/13).
Author
Owner

Done in PR #12 (955f4c0), merged.

  • core/port/port.c: registry + deferred shadow on the LakeSnes instruction hook (no copied frame loop), mode on, bridge fallback.
  • battle/Rand validated: shadow 13/13 US, 16/16 JP over tests/inputs/newgame_first_battle.txt (9500 frames), 0 fallback.
  • ctest release: 5/5 (unit, determinism US/JP, ports US/JP).

Not done here, tracked separately: cheaper clone than a full savestate per call (fine at this call rate), IRQ inside a shadowed call is not detected yet (only frame boundaries), liveness analysis for don't-care declarations.

Done in PR #12 (955f4c0), merged. - `core/port/port.c`: registry + deferred shadow on the LakeSnes instruction hook (no copied frame loop), mode on, bridge fallback. - `battle/Rand` validated: shadow **13/13 US, 16/16 JP** over `tests/inputs/newgame_first_battle.txt` (9500 frames), 0 fallback. - `ctest` release: 5/5 (unit, determinism US/JP, ports US/JP). Not done here, tracked separately: cheaper clone than a full savestate per call (fine at this call rate), IRQ inside a shadowed call is not detected yet (only frame boundaries), liveness analysis for don't-care declarations.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Gatchan/FF6Portage#5
No description provided.