Skip to content

Feature request: Save state undo #196

Description

@meithecatte

Every time I want to use a savestate, I have to doublecheck the key bindings - is shift used to save or load? If I get it wrong, either the saved or the currently running state gets discarded. The problem of potentially destructive features in software is usually solved with undo, and I believe this is also applicable here.

The implementation seems simple on the surface:

  • Before state is saved to slot k, the previous contents st[k], if any, is stored in the undo slot:
if (st[k]) undo = struct undo { k, st[k] };
st[k] = gb_state;
  • When state is loaded from slot k, the running state is stored in the undo slot:
if (st[k]) {
    undo = struct undo { -1, gb_state };
    gb_state = st[k];
}
  • When undo is triggered (proposed keybind: CTRL-Z), the corresponding save state slot is restored to the state stored in the undo slot:
if (undo) {
    if (undo.slot == -1) gb_state = undo.state;
    else st[undo.slot] = undo.state;
}

The impact of this change would be much greater if the feature was adequately advertised. Gambatte notifies the user of a successful state save and load by overlaying a status message in the lower left corner of the screen. Should this mechanism be adopted, appending (Ctrl-Z to undo) to the messages would be a great way to notify the user of this feature.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions