A state is taken at the top of Dispatcher::run's loop, where no guest code is on
the host stack: memory, the dispatcher, the kernel (threads, frames, queues,
deadlines), every library's state, the native IOP host (memory, tasks, kernel
objects, RPC servers, mixer, libsd) and sections ports add (state::Sections).
Parked library lambdas become data: Resume records and native deadline kinds,
rebuilt from tables on load; ports can add their own kinds. FreeHost serves
requestSave / requestLoad from any thread, rolls back a failed load, and takes
FreeOptions (gameTag, loadState[Frame], saveState[Frame]). Windows get ten slots:
F5 save, F7 load, F6 / Shift+F6 select, and a Save states tab in F2.
989SND's engine and a playing movie are not covered: a save waits, saying why.
docs/save-states.md tells a port how to use and check it; tests/runtime/state_tests.cpp
covers the archive, files and a dispatcher round trip.
Co-Authored-By: Claude Opus 5.5 <[email protected]>