melonDS-emu / melonDS

DS emulator, sorta
https://melonds.kuribo64.net
GNU General Public License v3.0
3k stars 499 forks source link

Explorers of Sky stopped saving mid-game #1230

Open Slayer95 opened 2 years ago

Slayer95 commented 2 years ago

Q. Summary? A. I was able to play, save and load the game across several days and gameplay sessions without issue. But I am no longer able to load the save files produced by melonDS.

Q. Version? A. Windows 7 Ultimate SP1. melonDS 0.9.3. Running in Spanish.

Q. Game? A. Pokemon Mystery Dungeon - Explorers of Sky (E).

Q. When? A. After an item storage expansion due to in-game progression (reached Gold rank as Explorer Team)

Q. How? A. Step by step:

  1. Up to that time, 128 KB .sav files were successfully generated and they could be loaded.
  2. When I got to said storage expansion and I tried to save, the game noticed the save failed and the .sav file became 0 KB.
  3. I restarted melonDS.
  4. Afterwards,.sav files could be generated again, but they were corrupted. save process seemed okay but resuming was unavailable in the game menu.
  5. Sometimes, trying to save straight up crashes melonDS.

Q. Savestates to reproduce? A. .ml files: GOOD: https://ufile.io/2ypn3a58 BAD: https://ufile.io/dhs4x582

RSDuck commented 2 years ago

is it the right that the game is frozen when I load your good savestate?

Slayer95 commented 2 years ago

is it the right that the game is frozen when I load your good savestate?

Frozen? No, I don't experience any freezing issues with that one. I am running the EU version in Spanish. I am not aware of what could cause the freeze you mention. Loading ml1.working should lead to the following state:

GOOD

In that menu, pressing A would lead to a successful Save.

PMDEoScasual commented 2 years ago

I have the exact same issue. I detailed something in the IRC chat, but looking at this person's post above, their issue is nearly identical to mine. For me, I am playing the USA version, and on Windows 10 64-bit. I was originally on 0.9.2. So what I did was I dragged the new melonDS executable and replaced the old one. And then, since I had saved in-game, I picked off where I left off. Everything was fine for a while until this issue occured. Thankfully, I made a savestate while playing 0.9.3, so I can at least play part of the game, but without saving, I lose access to the Top Menu, which is the Continue aspect that Slayer95 described above.

I can't say for certain that it's caused by the backpack increase in-game because I recently reached Ultra rank, though I believe the bag upgrade happened pretty close to when this issue started happening. Nonetheless, it looks like they and I have the same issue. I even included a video showing what his images show with how melonDS will straight up crash after saving. The video clip is 1 minute long and shows a video version of what Slayer95 described above. (Link here)

I also noticed something odd. I used savestates to act as a failsafe in case anything bad happened with the save file, and I noticed something peculiar. Between the 0.9.2 to 0.9.3, the savestate file size changed. I don't know if that means anything, but it shrank from 6494 KB to 6366 KB. (Image here).

My fear is that even if this gets fixed, since savestates are emulator version specific, I will effectively lose my progress. So I am stuck between a rock and a hard place. Normally the savestate would be enough, but the thing about Pokemon Dungeon - Explorers of Sky is that the game both has the story and gameplay you see here, but in the Top Menu, when you click Continue, all the special episodes (link to wiki showing special episodes) are included in there as well. I haven't played any of them, and they are unlocked as you play, and since I can't save, I can't access them. So while I can still play the main game that my savestate has, I can't access that content anymore. Which is the dilemma I'm in.

Here is my non-functional .sav file (link here).

Here is my current 0.9.3 savestate file aka .mln file that's keeping my progress going (link here).

Here is my original savestate file aka .mln file, that I made right back when I started the game on the older verison of the emulator (version 0.9.2) (link here).

Lastly, I tried researching myself at first about what it might be, but it seems all issues stemmed from a type of memory called 128K EEPROM, which was corrected back in 2019, so I figured it can't be that. I even tried changing file names, shortening folder paths by putting them closer to root. That didn't help either.

So I did one final thing I could think of. I clicked New Game, and went through to see if a starting a new game would at least make functional .sav file. AND IT DID. So I uploaded here. I have no idea why the New Game saves properly, but maybe at least this provides a comparison of what's happening between my non-functional .sav and the New Game .sav. Also I forgot that this game has 30 minutes of fluff before you get to your first save point, so I really hope this helps in some way. (link here)

If there is anyway I can be of help, let me know.

PMDEoScasual commented 2 years ago

Guys I think I figured it out!

So I did some of my own testing. I opened the .sav files into a hex editor, and it reveals that nearly no information is in the corrupted sav file. The .sav file from the new game had all sorts of information. It had the name of the ROM at the beginning, name of the beginning characters, and the name of the team later down the listed on all sorts of memory addresses. So even if you do manage to get the game to save before crashing, the corrupted .sav file is practically empty. For whatever reason, booting from my savestate and attempting to save results in this error.

So I ran one more test! I went through with playing the new game. And right before I got to a save point, I made a savestate. And then booted from the savestate, and THEN saved the game. Guess what? The .sav file for the new game was perfectly intact. But even odder? The savestate file (aka the .mln) file was 6494 KB! (Remember I mentioned the savestate with my current game is only 6366 KB). So that means that our savestate files must be corrupted! So my guess is that Slayer95 and I both loaded from a savestate at some point, but it was corrupted. So while we are able to play the game, we can't save in-game. I'm guessing that missing 128 KB is the information required for saving, thus resulting in the corrupted .sav files. And to add even more to the idea? Pokemon Dungeon - Explorers of Sky .sav files are 128 KB in size! So I looked at the exact sized. The corrupted savestate? When converted to bytes, it is 6,518,485 bytes. The functional savestate file? 6,649,557 bytes. How big is the difference? 131,072 bytes. How big is the .sav file for the game? 131,072 bytes!

tl;dr So this is what I think happened. Both Slayer95 and I must've gotten unlucky. It has nothing to do with the game itself. What happened is, he and I probably loaded from our corrupted savestates. When we reached a stopping point in-game to save, we ended up overwriting our last functional .sav file with this corrupted save file. Since we only have since messedup savestate and a non-functional .sav file, we are left with our current predicament that the only thing we can play from (the messed up savestate) is the thing that caused this whole mess!

I have no idea if there is a way to salvage this, but this is what I am thinking caused all this. As always, if there is anyway I can help, let me know. When I get a free moment, I'll label all the files, zip them up, and make a post notating them all.

Slayer95 commented 2 years ago

both loaded from a savestate at some point

It seems my savestates in the OP have already expired, but I still keep them in my machine. Indeed, my broken savestate is smaller. savestates

Furthermore, I do recall fat-fingering an F key and thus loading a savestate at some point. Although I can't pinpoint the timeframe in which that happened relative to my side's failure, I think we stumbled upon the exact same issue and I support your hypothesis.

So this issue might be related to #1244 in some sense.

PMDEoScasual commented 2 years ago

It seems my savestates in the OP have already expired, but I still keep them in my machine. Indeed, my broken savestate is smaller. savestates

Oh wow, thank you so much Slayer95! I was desperately trying to find a way to contact you, and I THINK I just sent you an email asking about the two files! So if you get an e-mail from me, just know you already answered my request about the .mln files! So this is good, it seems that the idea of what is breaking is consistent. What I will do next is try to replicate #1244 's conditions and see if the savestates become corrupted over time.

PMDEoScasual commented 2 years ago

FINALLY AFTER HOURS OF TESTING AND NEARLY A MONTH LATER! It seems to be the "Undo state load". I can't pin point the exact steps yet, but it seems that if you use that function, the SAV file gets corrupted to some degree. I don't know why, but my only guess is that in undoing the SaveState, maybe melonDS tries to undo any updates to the SAV file as well? But it undoes it incorrectly, resulting in corruption. If you try to make another savestate, it will then be the messed up with the 6366 KB file size.

Now why would someone use the undo save state load? I noticed that while corrupting the save state is near impossible, it is pretty easy to corrupt the SAV file itself (which doing it in the other ways I found seems to not effect the save state??).

Now as we know, corrupting the SAV file results in the error message above where the game says "Save Failed". So let's say you do this, and choose to go to the main screen. You might have a panic attack when you see your game gone. It might be then that you choose to undo the save state and then reopen your save state. While you get back to your game, if you haven't fixed your SAV file (which all it requires is closing melonDS, deleting the SAV file, opening game, reload the save state, and then save game), you have then potentially sealed your fate because if you save over your save state, it will end up being corrupted. From that point on, you are forever doomed to walk with a game that you can never save, and thus run into our predicament.

I probably need more testing to give the exact steps to replicate, but the fact that I finally generated the error again is great progress.

@Slayer95 Can you verify if you ever used the "Undo state load" function at any point before this corruption occurred?

Slayer95 commented 2 years ago

@Slayer95 Can you verify if you ever used the "Undo state load" function at any point before this corruption occurred?

What? F12?? Come on, I uninstalled No$Gba because pressing Esc closed it no questions asked, but it turns out MelonDS also assigns a common hotkey to such a destructive operation.

So... I really can't tell. See, there is a chance I assumed I had saved a state to slot 12 and then I pressed F12 to load it, or I could have pressed it to take a screenshot...

Slayer95 commented 2 years ago

@PMDEoScasual once you pinpoint the exact steps you should probably open a new issue, and I shall close this one as incomplete.

PMDEoScasual commented 2 years ago

Thanks for the speedy response @Slayer95 ! Ok, so at least it is within the realm of possibility that you used the Undo state load function. I can't pinpoint the exact time myself, but I do recall specifically using the feature once or twice, relatively close to the time of the issue. Sometimes I wouldn't be in a spot where I could save in-game, so my guess is, I lost a battle in-game, used the Undo state load, reloaded the save state, corrupted my game, but didn't notice at the time because I was not near an in-game save area. So I was just using the save state over and over, unaware of the fact that it had become partially corrupted.

Also, if and when I find the exact steps, I will let you know, so you can make the changes here to close this topic!

Voyex commented 1 year ago

Sorry to dig this up but I'm jumping in here to confirm that I have also run into the same issue. I used the "undo state load" button and then saved my savestate. This causes an issue where every save generated by this savestate and it's children are corrupted and cannot save. I had to delete my save file then load a savestate before I used the "undo state load" button. Once in this savestate, I was able to generate saves again.

RSDuck commented 1 year ago

does anyone of you who have this issue also have separate savefiles enabled?