romcollectionbrowser icon indicating copy to clipboard operation
romcollectionbrowser copied to clipboard

Improve savestate handling

Open maloep opened this issue 7 years ago • 0 comments

I updated most of my rom collections to use RetroArch recently. But I don't really like the way RetroArch handles savestates (or I don't fully understand it).

Afaik you have these two options to handle savestates in RetroArch:

  1. You can increment and decrement savestate slots with hotkeys or via the menu and you can save states to these slots. Statefiles are saved as "romname.state", "romname.state1", "romname.state2", ... When you want to go back to a savestate you need to select the slot that you saved the last state and reload this state. The last used slot can be saved with the config file on exit but as I use system specific (and not game specific) config files the last slot for one game will not be the correct slot for the next game. Additionally, you can't launch directly into a savestate via command line (at least I did not find a way). Otherwise RCB could show a list of savestates (maybe enriched with a date and screenshot) for this game and the user could select the correct one.

  2. You can configure RetroArch to auto save/load savestates. Every time you exit a game, a savestate is created. Next time you launch the game this savestate is loaded automatically. Statefiles are saved as "romname.state.auto". Problem with this approach is, that a) you have to rely on one statefile all the time and b) it will save on every exit if you want it or not. (E.g. you accidently launch a game from start and when you exit it overwrites your previous savestate.)

RetroPlayer uses the same auto save/load mechanism (with other filenames), so maybe an RCB approach to handle this situation could be valid for both scenarios (and maybe other emulators with auto load/save).

So, my idea was the following: Configure RetroArch (or any other emulator that works like this) to autoload savestates. Saving states will be done automatically on exit and/or via hotkey during the game. RCB will monitor the savestate directory and when the game exits it will rename all statefiles to a name that the emulator does not understand. On game launch RCB will search for savestates with its own naming scheme, ask the user which state to load and renames the selected state to the original name.

This mechanism can be extended with screenshots taken with the savestate and the date/time when the state was saved.

In pseudo code it could look like this:

if "let RCB manage your save states" == true

  • on game exit (or on RCB start in case of solo mode)
    • search for statefiles via %STATEFILE%
    • Rename "romname.state.auto" to "romname.state.auto.rcb.201801071248"
    • optionally configure a limit of state files and delete older ones?
  • on game launch
    • search for state files via %STATEFILE%.rcb.*
    • create a dialog with all statefiles (including date and screenshot if available)
    • user picks statefile
    • RCB removes .rcb.* from statefile
    • Emulator autoloads statefile

In RCB we may need these additional config options:

  • flag if we want to use this mechanism at all
  • optional: limit of statefiles as we will produce a new statefile for every save

@bruny: let me know what you think about this idea.

maloep avatar Jan 07 '18 17:01 maloep