ClusterM / retroarch-clover

GNU General Public License v3.0
321 stars 50 forks source link

mGBA Save Games not retaining #80

Open progranadegrinder opened 6 years ago

progranadegrinder commented 6 years ago

This is on the SNES Classic I'm running Pokemon Prism ( a GBC game ) on the mGBA emulator, whenever I save, hit the reset switch, then launch the game again, my save is gone.

NeroSchiz commented 6 years ago

I'm getting the same issue with Mother 3

kaosushijin commented 6 years ago

Having the same experience when testing with Mother 3 (SRAM saves not retaining even after waiting for the 10 second interval)

kaosushijin commented 6 years ago

I am using the 1.0 release and hakchi2 2.21c on an SNES Classic. SRAM saving seems fine for Final Fantasy I+II Dawn of Souls, so it seems to be game-specific.

kaosushijin commented 6 years ago

Also, it appears that hakchi2 is seeing a 68kb save file for Mother 3 in the "S" Save Slot (SRAM) OK! That's all I've got. Let me know if anyone would like me to do any further testing or investigation.

NeroSchiz commented 6 years ago

For Mother 3 I've also tried to use the Save States, and they aren't retaining as well. If your playing Mother 3 and use a Save state, it will retain during that instance of play. As soon as you load another GBA game (I believe this is also any other game as well) it will wipe the save.
@kaosushijin I've also tried waiting the 10 seconds for SRAM and it also did not retain. I haven't tried the newest retroarch 1.0, Ill do that now.

NeroSchiz commented 6 years ago

Saves still lost. Most games other than Mother 3 will retain their saves, like Metroid Zero Mission for instance. Any ideas how to fix this?

kaosushijin commented 6 years ago

I've seen reported elsewhere that leaving the Mother 3 rom uncompressed will resolve the issue, but I haven't been able to test. (32MB is a healthy chunk of available NAND space). NeroSchiz, do you want to test this? progranadegrinder, does leaving your rom uncompressed serve as a workaround for you?

progranadegrinder commented 6 years ago

I never compressed it, I just found the ROM randomly online and am running it from the regular .gbc format.

NeroSchiz commented 6 years ago

Ok, I've made quite a bit of progress @kaosushijin and @progranadegrinder tldr - I think Ive fixed GBA games not saving, at least for Mother 3

Firstly I right clicked Mother 3 in Hakchi and chose to decompress it, then I loaded Mother 3 from within Hakchi and started a new save file. Accessed Retroarch, went into Quick Menu/options/Game Options File and it created one for Mother3(U). This seems to have fixed the issue, although I don't know if Decompressing and creating this file in Game Options have a correlation.

After I got it working I tweaked a few settings in Onscreen Displays to make reading Notifications from Retroarch easier within mGBA. For anyone who is interested, I set onscreen notifications to size 15, X 0.130, Y 0.020 In order to see this easily you need Integer Sizing set to On and have your Aspect Ratio to 3:2, which is Native for GBA games, and also adjust the width or the overlay or just turn them off. I kept them on cause their fancy!

Also, I don't know if this is the newest retroarch @ClusterM uploaded, but save states in the Snes Classic work with GBA and SNES retroarch ran games.

Here's what it looks like!

image

Sorry for super long post! Hopefully all this works for everyone!

kaosushijin commented 6 years ago

I'll play around with the game options file stuff you mentioned with the decompressed rom. I'm glad that you're satisfied, @NeroSchiz .

EDIT: Sorry, originally wrote "compressed rom"

kaosushijin commented 6 years ago

I'm not seeing Game Options under Quick Menu > Options. Maybe this is because we're using different retroarch versions?

NeroSchiz commented 6 years ago

I decompressed the rom, not compressed. I'll look at the path again when I'm home in about 2 hours.

kaosushijin commented 6 years ago

Man, what a mess. I downloaded a fresh Japanese copy, patched it with 1.2 English and then patched the IPS save fix for good measure. I decompressed the ROM and it saves/savestates correctly. So I recompressed the ROM, and tried to load the known good SRAM file and savestate I had made and it doesn't work with either. It honestly seems like it's CREATING the SRAM/savestate correctly, but something about decompressing the ROM into memory is causing it to fail at loading the SRAM/savestate files.

kaosushijin commented 6 years ago

I can create a save state with the compressed rom, and then if I decompress the ROM, I can then load that save state that I made with the compressed rom -_-

kaosushijin commented 6 years ago

On a hunch, I tried to see if I could reproduce this issue with another 256 mbit (32MB) ROM with 64KB SRAM, Riviera: The Promised Land. The same issue is occurring with the compressed ROM. When decompressed, it can load the save file, just like we've experienced with Mother 3. I'm wondering whether a 32MB file is too big for /var/cache or whether there's some odd timeout that's occurring.

There's a new version of mGBA available (0.6.1 is available -- the 1.0 release has 0.5.1) I'm curious if this will be resolved with a new build of the mGBA core for retroarch-clover.

kaosushijin commented 6 years ago

Here's something odd -- In my continued testing, I tried a 32MB game with a 128kb SRAM (Pokemon Mystery Dungeon Red Rescue Team) and that's working properly when compressed. Maybe it's the 32MB/64KB combination in particular with the issue?

kaosushijin commented 6 years ago

The issue also occurs with Kingdom Hearts: Chain of Memories (32MB/64KB) but I wouldn't recommend testing with this since it has a lengthy unskippable intro and tutorial.

kaosushijin commented 6 years ago

I hotswapped the 0.5.1 core with the latest armhf core (0.6.1 abf5a18) and it runs, but it doesn't help with the compressed Mother 3 issue. That's the end of the road for me -- Someone smarter and/or more involved is going to have to take it from here.

P.S. I also swapped in the latest VBA Next armhf core (1.0.2 fe279c0) and the same behavior occurs. Save states work properly within the session (can be created and loaded from). The issue somehow involves how the saves are handed off and restored between gameplay sessions. Good luck!

kaosushijin commented 6 years ago

Final note here, I'm dumping the cmdline output I grabbed from /proc/[pid] of the two retroarch processes. Everything appears in order AFAIK. Replaced NUL characters with spaces for readability.

1:

/bin/sh /bin/retroarch-clover-child mgba /usr/share/games/CLV-A-JNCPK/Mother3.gba.7z --save-data-backing-file /var/lib/clover/profiles/0/CLV-A-JNCPK/cartridge.sram --title-code CLV-A-JNCPK --video-mode crt-filter --decorative-frame-path /usr/share/backgrounds/08_space/08_space_4_3 --load-time-path /var/lib/clover/profiles/0/CLV-A-JNCPK/suspendpoint1//state.time --save-time-path /var/cache/clover//volatile/CLV-A-JNCPK/suspendpoint0/state.time --wait-transition-fd 12 --start-transition-fd 14 --finish-transition-fd 15 --save-screenshot-on-quit /var/cache/clover//volatile/CLV-A-JNCPK/suspendpoint0/state.png --rollback-mode record --rollback-output-dir /var/cache/clover//volatile/CLV-A-JNCPK/suspendpoint0/rollback/ --rollback-input-dir /var/lib/clover/profiles/0/CLV-A-JNCPK/suspendpoint1/rollback/

2:

retroarch -c /etc/libretro/retroarch.cfg -vfL /etc/libretro/core/mgba_libretro.so /usr/share/games/CLV-A-JNCPK/Mother3.gba.7z

I just stared at retroarch-clover-child for a while and I see how it's supposed to unpack things into /var/cache. The issue has to be somewhere in this script. The SRAM and savestates are being properly written (and gzipped in the case of savestates) to /var/lib/clover/profiles/0/$id. It's restoring these values to /var/cache where the issue is occurring. I'll keep reading, but it does seem like the issue is somewhere in how retroarch-clover-child is choosing to either restore or delete these files at runtime.

kaosushijin commented 6 years ago

AHA! I think I get it now. It does have to do with the amount of time that the ROM is being decompressed, and the decompression load vs the CPU speed is not giving the "sleep" command enough time!

OKAY I'VE SOLVED THIS MOTHERFATHER. Normally, when an uncompressed ROM is run, it unpacks the cartridge.sram and gzipped savestate into /var/cache, waits a few seconds for RetroArch to launch and use those files, and then it nukes them. The problem is that with Mother 3 (and a few others), the 7z decompression process takes too long and it nukes the files before RetroArch can use them!!!

I'm going to tweak the sleep values and see if it fixes the issue for me, and then I'll see if I can't share my success with you guys :) retroarch-clover-child just needs a little tweaking.

kaosushijin commented 6 years ago

If you edit /bin/retroarch-clover-child and replace "sleep 3" with "sleep 5" this issue is fixed 👍 💯

@NeroSchiz Please report in and see if this works for you. I can't believe I just spent 5 hours trying to save 20MB.

NeroSchiz commented 6 years ago

oh wow....that's great you figured it out! nice sleuthing 😎 Mother 3 is a bigger file size, so I'm wondering if a universal sleep value of 5 or 6 would be good for all GBA compressed ROMs just as a caution. I can test this tomorrow morning. it's 11:30pm here.

kaosushijin commented 6 years ago

Thanks @NeroSchiz

I think other people have had this issue with N64 saves for a while now as well and I cross-linked them here.

NeroSchiz commented 6 years ago

Yup, that works Just tested. Your 5 hours was not in vain @kaosushijin !!

NeroSchiz commented 6 years ago

you could mark this as solved, at least for GBA games.

kaosushijin commented 6 years ago

@progranadegrinder Are you using Gambatte core? If not, why not?

kaosushijin commented 6 years ago

@NeroSchiz I did a pull request with the patch. Now to see whether @ClusterM will merge for the next version or not.

KMFDManic commented 6 years ago

Fixed in my latest update. I will let MadMonkey know, so this can be merged.

https://github.com/KMFDManic/NESC-SNESC-Modifications/releases/ Personal thanks to @NeroSchiz @kaosushijin for your patience and effort in this scenario:)

rg4lbaby commented 6 years ago

How do I edit /bin/retroarch-clover-child? I tried to edit the file but it says I need an app to do it. I downloaded the latest update but I'm still having trouble in-game saving certain games.

duskshadowbrony commented 6 years ago

@rg4lbaby Not trying to Necro, but since nobody answered you, and not sure if your problem was solved, you can edit it via FTP, if you have retroarch already installed. If you'd rather edit it manually from the hmod folders given here, any advanced text editor (Notepad++, Sublime Text 3) will work.

KMFDManic commented 6 years ago

@duskshadowbrony @NeroSchiz @kaosushijin @rg4lbaby Saves will operate completely differently once I post my next Update. The editing will be unnecessary and it should be universally good.

aros526 commented 6 years ago

Can someone please explain to me the exact steps to change the required files, I'm having this problem with mother 3 on the snes classic

KMFDManic commented 6 years ago

@aros526 What RetroArch are you using?

aros526 commented 6 years ago

RetroArch with cores as well as hackchi2

aros526 commented 6 years ago

@KMFDManic I think I'm suppose to do what kaosushijin was talking about with changing "sleep 3" to "sleep 5," but i'm not sure how to do that.

chrisj88 commented 5 years ago

Can some one leave me instructions for how to find this on the PC version of retroarch? I can't find a bin file or anything named clover-child in the retroarch directory.

KMFDManic commented 5 years ago

@chrisj88 this is no longer an issue. Use mGBA and RetroArch 1.7.5 Xtreme from my current set, if on SNES/NES

If on PC RetroArch, it doesn't work quite the same way. So, this method mainly pertains to the Nintendo Classics.

https://github.com/KMFDManic/NESC-SNESC-Modifications/releases