euan-forrester / save-file-converter

Converter for retro console save files to and from MiSTer, flash cartridges, Nintendo Switch Online, and save states from online emulation websites. Convert files found around the Internet: All common formats for NES/SNES/GBA/N64/TG16/SMS/Genesis/Neo Geo/PS1 supported. Decrypt PSP saves.
https://savefileconverter.com
GNU General Public License v3.0
138 stars 5 forks source link

Added support for converting save states from some online emulators to in-game saves #275

Closed euan-forrester closed 7 months ago

euan-forrester commented 7 months ago

There are various sites which allow people to play retro games right in their browser. These sites appear to get their emulators (and ROMs) from a small number of places, which seem to tend to use the same underlying emulators. These sites tend to only allow the downloading of save states, as opposed to in-game saves.

Unlike save states for more conventional emulators, these sites are incentivized to not change their save state format because that would invalidate their users' saves and they would lose users. Furthermore, it turns out that the in-game save is contained within some of these save states.

I was able to find in-game saves inside GBA and SNES save states. So far I can't find it within Genesis save states, and it also appears that at least 2 different emulators are used for Genesis emulation on these sites. I polled the users in the Discord channel who had recently asked for this feature, and they didn't have any additional platforms to suggest so we'll launch with these 2 for now.

The trickiness comes from the GBA save states requiring to know the file size before performing conversion: different save types are stored at different offsets in the save state. This lead to some complexity in the UI code to ensure that users can click on UI elements in any order and not mess up their conversion, regardless of whether they are doing a SNES or GBA file.

Also some online emulator sites compress several save states into a single file, while others only allow downloading a single file at once. So an OnlineEmulatorWrapper class was created to first decompress the file if necessary then hand off the actual conversion to a separate class.