mgba_load_state
Restore emulator state from a save slot or .ss file to undo changes or jump to a bookmarked state.
Instructions
PURPOSE: Restore the emulator from a previously saved slot or .ss state file. USAGE: Counterpart to mgba_save_state. Use to undo a sequence of writes/inputs (the snapshot/experiment/restore workflow), to jump to a bookmarked game state, or to start each tool-call sequence from a known baseline. EXACTLY ONE of slot or path must be supplied (passing both, or neither, returns an error). To start fresh from console boot instead of a snapshot, use mgba_reset. BEHAVIOR: DESTRUCTIVE TO LIVE STATE: replaces ALL current emulator state (RAM, registers, mapper, audio, frame count, in-flight DMA) with the snapshot's contents. Anything not previously snapshotted is lost (unsaved in-game progress, queued button presses, paused state). The state file/slot MUST come from the same ROM and a compatible mGBA version that produced it — loading mismatched data typically produces a corrupt run or a hard error. Returns an error if neither slot nor path is supplied, the file doesn't exist or isn't a valid mGBA state, the slot is empty or out of range, or the relevant bridge load-state method (loadStateSlot vs loadStateFile) is missing on this build (check capabilities in mgba_get_info). RETURNS: Single line 'Loaded state from PATH' or 'Loaded state from slot N' depending on which form you used.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slot | No | Save state slot number (0-9) to load. Mutually exclusive with `path` — supply exactly one. Loading an empty slot returns an error. Out-of-range slot numbers return an error. | |
| path | No | Absolute filesystem path to an existing .ss state file produced by mgba_save_state (or mGBA's UI) on this same ROM and a compatible mGBA version. Mutually exclusive with `slot` — supply exactly one. Loading mismatched files typically produces a corrupt run or a hard error. Only works on mGBA builds that expose the loadStateFile capability. |