mGBA Forums

Full Version: mGBA Creates Issues After Re-Injecting Sav Into a NSUI VC Game
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I recently started playing a game of Pokemon Emerald Version on my 3DS running CFW. I created a Virtual Console game of Pokemon Emerald Version using New Super Ultimate Injector and used the save type "Flash 1Mbit (Macronix, ID: 0x09C2) + RTC" to create the .cia. After playing for a few day, I dumped the .sav onto my PC and ran it using mGBA in order to trade Pokemon with myself on another rom. Everything was going great until I tried to inject the .sav back into my VC game of Emerald on my 3DS which gave me an error. After troubleshooting, I discovered that mGBA adds 16 bytes of data onto the end of the .sav to keep it's RTC. Once I discovered this, I was able to edit the data by removing those 16 bytes which allowed me to successfully inject the .sav back into my VC of Emerald.

Fast forward 2 IRL days and I've noticed that my berries aren't growing, but they were growing just fine before I used mGBA. Using PKHex I was able to see that my RTC had not progressed in 2 days. I figured it was the missing code and upon rebooting the .sav in mGBA, the berries have grown and opening it in PKHex shows that the RTC has progressed again.

The issue now is that I cannot inject the .sav the way it is since it has 131,088 bytes of data and it must have exactly 131,072 to be injected back into my VC running Pokemon Emerald. Removing those 16 bytes allows me to inject the .sav but the RTC is disabled which disables many important functions of the game. Sadly, the .sav file is missing data that it not need before.

I have tried checking the "Reset RTC" flags in PKHex does not progress the RTC either. I see my only options as restarting a new game and never touching mGBA again (regrettably) or continuing to play the game on an emulator on my 3DS (which sadly does not run as smoothly or seamlessly as a virtual console title).

Given these symptoms, does the community have any ideas as to what I could try to do to fix my .sav and make it work properly again? I have included my most recent .sav without the 16 bytes that mGBA added. Running it through mGBA makes the RTC work again, but the real solution would be for mGBA to not add these 16 bytes to the .sav in the first place and to emulate an RTC itself.
mGBA *does* emulate the RTC. The problem is that the RTC itself contains the time and the savegame only contains an offset between that time and the time you set in-game. The 16 bytes at the end are the state of the RTC itself, but many other things just assume the RTC data is generated on the fly from whatever the current time is. You cannot tell mGBA not to export this data, because otherwise the data is incomplete and syncing with a real cartridge wouldn't have the time set properly. Though at the moment I think FlashGBX + the GBxCart RW is the only one that supports that data.

Anyway, I don't know how to get the RTC data properly into the GBA VC. It might not be possible. In theory it should be with a custom solution like open_agb_firm, but it doesn't look like it support that.
Thanks for the reply!