Fix snapshot save/load: route both through CPU trap to sync registers
machine_write_snapshot reads maincpu_regs.pc to record the current program counter. When called directly from video_canvas_refresh, maincpu_regs is stale — the CPU loop keeps registers as stack-local variables and only syncs them to maincpu_regs inside DO_INTERRUPT via EXPORT_REGISTERS(). The snapshot therefore recorded the wrong PC. On restore (already trap-based), the wrong PC was faithfully written back into reg_pc via IMPORT_REGISTERS(), causing the CPU to resume at a bad address. The game screen looked correct (memory/VIC/SID state all restored) but the CPU never reached the input-polling code, so button presses had no effect. Fix: route machine_write_snapshot through interrupt_maincpu_trigger_trap so DO_INTERRUPT(IK_TRAP) calls EXPORT_REGISTERS() before the trap function, capturing the true current PC before the snapshot is written.
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 405 KiB |
Reference in New Issue
Block a user