mgba-emu / mgba

mGBA Game Boy Advance Emulator
https://mgba.io/
Mozilla Public License 2.0
5.7k stars 786 forks source link

[Libretro] SRAM wrong size if you exit in the BIOS #892

Closed sergiobenrocha2 closed 7 years ago

sergiobenrocha2 commented 7 years ago

Only happens with the Libretro Core

Load a 32 kB SRAM game, like "Castlevania - Aria of Sorrow (USA)" (crc 35536183) or "Fire Emblem (USA, Australia)" (crc 2A524221), then exit while running BIOS. The save file will increase to 128 kB.

Then load again, wait until the game start (after BIOS), it'll decrease the size back to 32 kB as soon as you close retroarch.

Same issue with 0.4.1 / 0.5.2 / 0.6.x (last commit)

endrift commented 7 years ago

this is probably because during the BIOS the emulator doesn’t know how big the save is so it says the maximum possible size until it finds out otherwise. This is to prevent data from accidentally being chopped off or otherwise. 132kB is weird though. It should be 128kB. Did you not divide by 1024?

sergiobenrocha2 commented 7 years ago

it's 128 kB, sorry

endrift commented 7 years ago

Then yeah, I don’t believe this is fixable without a giant database of game information.

sergiobenrocha2 commented 7 years ago

Is it related to libretro "touching" the file even if you or the game don't mess with the save? Using the Qt frontend, it does not touch at all, unless I explicit save it

endrift commented 7 years ago

Not really. Libretro I guess polls for the desired filesize, but it's not known until the game actually boots and polls the savedata.

sergiobenrocha2 commented 7 years ago

Related: https://github.com/ekeeke/Genesis-Plus-GX/issues/19