profi200 / open_agb_firm

open_agb_firm is a bare metal app for running GBA homebrew/games using the 3DS builtin GBA hardware.
GNU General Public License v3.0
849 stars 42 forks source link

Add mgba save compatibility option. #178

Open Wrsford opened 2 months ago

Wrsford commented 2 months ago

Supersedes #177 This adds an advanced option (mgbaSaveCompat) to swap save and ROM .ini files to be in the same directory as the ROM. This allows a user to play on mGBA and seamlessly swap over to open_agb without moving saves around.

Neither mGBA nor open_agb allowed configuring save locations, so this would provide the only option for users wanting to be able to swap between them easily.

profi200 commented 2 months ago

Hmm, this is not mGBA specific. Maybe a different name for this option would make sense? Something like "sharedRomAndSaveFolder". If you have a better name let me know.

There is also a small problem with this. EEPROM saves are not compatible between mGBA and oaf. If we share the same folder again switching between mGBA and oaf will corrupt savegames.

Masamune3210 commented 2 months ago

Is eeprom a raw blob or is there a header? Maybe flag those made by oaf?

profi200 commented 2 months ago

It's raw but the byte order is different. Unfortunately the most common format is the byte swapped one. oaf uses the format that preserves byte order. See: https://gist.github.com/profi200/e06794d7561ed552c518b4b0b2f5f2f6#file-gbaeepromsavefix-c-L44

Wrsford commented 2 months ago

My proposed changes to deal with the issues you brought up are:

  1. Change the name of the setting to "sharedRomAndSaveFolder"
  2. Omit applying this setting to games using any EEPROM save type to avoid users losing their save.
  3. Update documentation to note the incompatibility with EEPROM saves.

A longer term fix for the EEPROM would probably require writing both versions of the save and comparing them to see if one updated without the other, then syncing with the newer one. Currently, I don't have the familiarity with the codebase to know if that is possible or to be able to make that change, but I can look into it.

I'll get started, but let me know if you have any objections. Thanks!