Feature request: Save state undo
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 contentsst[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.
Regardless of this feature, just noting that loading a save state can already be reverted using the Rewind feature.
If this feature is still wanted, I think I can make this work. would someone have time to discuss a proposed solution?