Beetle/Mednafen PSX Save States

Hi All,

I had a quick question about save state support in Mednafen/Beetle. Everywhere I go I see Mednafen PSX save states listed as “experimental,” “prone to causing catastrophic failure to memory cards if used together”, “dangerous,” etc. Could someone explain what sort of issues could occur and why (and how they are different from any other emulator with save states and save files)?

I’m trying to figure out whether I want to switch over from PCSX-R but losing save state functionality might not be worth it so I want to know at least what I’m in for.

I don’t think anyone else has confirmed this, I tested this and I added the message, since at the time I was doing some work with that core I was able to reproduce the issue every single time with GT2

Earlier on I thought this might be an issue with upstream mednafen but it’s not the case. Using save states alongside regular in-game saves (memory cards) results in data loss for some reason.

I’ve tested this extensively, both with beetle and mednafen cores, and with mednafen 0.9.35 and 0.9.36-UNSTABLE.

Here are the steps to reproduce the issue on the game I found it:

Started GT2 Simulation Mode Do stuff (for consitency, I always did the first license test) Go back to the menu, save data

Then I restarted RA, loaded the data, all good Do the second license test, this time I saved a state at the beginning of the test Fail, Load State and pass Go back to the menu, save data

Then I restarted RA and it said there was no data in the memory card. I tried this on both mednafen (standalone) versions and I never lost any data.

Here is a link to the github issue about this: https://github.com/twinaphex/beetle-psx-libretro/issues/27, of course more testing is always appreciated

Thanks, I’ll try some testing when I get home tonight before I commit to Beetle. I saw a similar note on the Mednafen PSX page here (see the red warning section at the very top) so maybe its an issue introduced upstream in Mednafen 0.9.37:

http://mednafen.sourceforge.net/documentation/psx.html

It doesn’t happen with standalone though at least not for me

Hmm, I’m seeing the same thing. Following the same exact test method (Gran Tourismo 2, First License Test) the save seems to get corrupted after loading from a save state in Retroarch and I can confirm that this does not occur in mednafen-0.9.37.1-win64 as I tried it there as well

At first I thought it might be a problem with the way Retroarch handles the save files as it didn’t look like the Retroarch mcr files held any save files when viewing them in PSXGameEdit, but it looks like the game save is actually saved in the SRM file not the MCR file. The only thing that occurs to me is that maybe it’s a bug in whatever save/loading code is responsible for changing from

Mednafen Save Medhod: [Mednafen/sav]GameName.hash.0.mcr + [Mednafen/sav]GameName.hash.1.mcr

to Retroarch Save Method: [Game Folder]GameName.srm + [Retroarch/System]GameName.hash.1.mcr

Let me know if you need me to explain that more as I’m not entirely sure that makes sense right now. For reference, I uploaded my save files for Retroarch, Mednafen, and PCSX-R with what should be the same data (±different track times) for Gran Tourismo 2 https://www.sendspace.com/file/vyrdz4

Oddly enough I did not see the bug in Ridge Racer IV

I believe there is a core option for setting the save type, whether to use the srm or mcr saves.

Yeah but it still happens with mednafen memory cards

Next thought is that somewhere in the load state process it’s overwriting part of the memory card data.

I noticed two things, first the error only occurs when you load the state–in GT2 I can save game to memory card->save state->load game from memory card with no problem. Second, when you try to load the game after the bug occurs (without resetting the game), GT2 says that it failed due to an error. That means Retroarch isn’t overwriting the entire card/wiping the card, it’s just corrupting the data (somehow by overwriting just part of it?). My guess is either it’s some sort of buffer overflow that’s overwriting part of the save during the load process, or there’s some saving code left mistakenly in the function if the load state function was copied from some other function.

I am not a programmer so I I’m not sure how practical it would be, but since the error has to do with something in the save file getting written over, you might be able to track down the issue by stepping through the load state function while watching the memory card to see when the file gets updated.

I think there is a new savestate interface in mednafen, maybe using that will be safer, gotta wait till someone updates mednafen to the latest version

Nah still happens… worked one or two times then it corrupted the save again It’s just with libretro though, doesn’t happen with standalone

Got it, thanks for confirming.

Hi Radius,

Is this fixed now? I don’ t mean to bug you, I just noticed the commit on git.

Haven’t tested yet

I’m not seeing it on my end using the Gran Tourismo II method or in normal play so far.

Not seeing the problem? or the fix?

Sorry, “not seeing the savestate issue anymore since the fix has been applied.” On the other hand, I haven’t tested extensively. What I did test was Gran Tourismo II and loading/ rapidly re-loading a savestate and then reloading the save file and that seemed to work just fine.

Using RA 1.2.2 on windows 8. Playing through Castlevania: Symphony of the Night, and whenever I try and save my game (pressing up to trigger the save point), the game instantly crashes. Tried switching between .srm and .mcr. No good. Other games (PSX as well as other systems) have save data, so i can’t figure out why this one is being so stubborn.

Castlevania SotN seems to be working fine on my system (Arch Linux 64bit, latest Retroarch/Mednafen Core, NTSC-US Redump Rom). I’d double check your rom if it seems to be the only one having trouble. Here is my memory card file if you want to use it to test with.

Ah, appreciate it. Just figured out the problem though…it’s literally always the reason for any issues I run into…

rewind was on.

Will I be safe if I just make 6 savestates on the same place?