bardeci / gambatte-dms

Gambatte-DMS is a GB/GBC emulator for handheld devices, using a modified Gambatte core.
GNU General Public License v2.0
66 stars 23 forks source link

Trying to load .sav files for LSDj #4

Closed automata closed 4 years ago

automata commented 4 years ago

I tried to place some .sav files inside the same folder as my LSDj rom, however it's not loaded as expected. Also tried to put it on /home/retrofw/.gambatte/saves with no success.

I was taking a look at the source code and it doesn't seem that anything changed from sinamas original gambatte. I'm able though to load the same .sav files with my own build of x86 gambatte (by sinamas) just by leaving the same .gb and .sav file with same name at same folder.

I also trying to use terminal app on LDK to run it directly with ./gambatte.retrofw lsdj.gb but no success as well. It loads the rom, shows the following output but I can load any sounds from my sav file:

Screenshot from 2020-03-03 17-34-00

Any ideas?

bardeci commented 4 years ago

The save files and savestates must be located in $HOME/.gambatte/saves/. Note that depending on the OS of your device (retrofw, opendingux, etc... the folder used as HOME can be located in different places. For example, in my LDK running RetroFW 2.1 the HOME folder is the root of the "RetroFW" FAT32 partition of the internal sdcard. So when i use a card reader to copy stuff into the sdcard from my PC, i have the save files in E:/.gambatte/saves/ because my PC assigned the letter E: to the RetroFW FAT32 partition of the sdcard. Anyway, if you have executed gambatte at least once, those folders must have already been created in your system in the appropiate place, which by default (in RetroFW 2.X) is the root of the RetroFW FAT32 partition.

Note that ".gambatte" starts with a dot, so it is a "hidden" folder. This means you may not be able to see it from your LDK. But you should be able to see it from Windows. Also note that sometimes that partition hasnt got a letter assigned to it, this means it wont show up as a drive in Windows (the drive label is "RetroFW"). If this happens, you must use a partition manager to assign a letter to that partition, so Windows can detect it as a drive.

Looking at the photo it looks like its fine, but always make sure your save files have the exact same name as the ROM file. So if your ROM file is named "lsdjstress01.gb", then your save file must be named "lsdjstress01.sav", and the savestates should be named "lsdjstress01_0.gqs", "lsdjstress01_1.gqs", "lsdjstress01_2.gqs" etc...

automata commented 4 years ago

Yeah, I tried all of that but with no success. Load screen on LSDj doesn't offer my songs from .sav file. I'll try to compile gambatte myself.

Are you able to open your .sav files on your LDK? Have you tested with LSDj + .sav files?

Thank you!

automata commented 4 years ago

Built gambatte on Ubuntu 18.04 (using Docker) with retrofw buildroot fork. Now I'm able to hack my way through it and add some "debug" messages.

It seems gambatte is able to find the right savepath and load it. However I don't see any of my songs:

Screenshot from 2020-03-05 09-19-05

I'm going to dig more on it.

bardeci commented 4 years ago

I see LSDJ gamepak type is MBC5. A while ago i added a "MBC5 fix" i cherry picked from another repo. The commit is this one: https://github.com/bardeci/dot-matrix-simulator/commit/16f13f28a2fc2d96215b80f2078ce6a369087194 You could try reverting it and checking if your issue is gone.

But i think this is more interesting: A year ago i added another commit i cherry picked from elsewhere. This one enables support for more than 4 SRAM banks, allowing 64KiB and 128KiB saves to be made. Which supposedly was good for LSDJ. The commit is this one: https://github.com/bardeci/dot-matrix-simulator/commit/dc49102b0d4b33f7aba6f4e2707fdc197e55d160 You could try reverting it and checking if your issue is gone. This one has more chances to be the cause of your issue, maybe it created some kind of incompatibility?

Let me know if reverting any of these commits fixes your issue, so i can revert it in my repo too. Greetings!

automata commented 4 years ago

Thank you for your suggestions @bardeci !

While trying to revert and build new bundles, I ended up taking new .sav files and they worked! I was able to load all of them but one. I'm putting .sav files on /home/retrofw/.gambatte/saves and they load beautifully (as long as I provide a .gb file with the same name on any other folder).

I reverted both commits and it kept working, so I guess it's not related with them.

However I have a new issue now: I'm not able to save changes on .sav files from LSDj. I tried to save state from gambatte but that doesn't work neither. Any ideas?

Cheers!

automata commented 4 years ago

OK, totally my bad! I left the USB plugged in and couldn't write more on SD. Removed and rebooted and now I can load and save perfectly!

I guess we can close this issue. Thanks for all the support @bardeci !

bardeci commented 4 years ago

Cool! But then... what was the cause of your initial issue with saves?

bardeci commented 4 years ago

Oh well, i'll mark this as closed.

automata commented 4 years ago

Sorry for the long delay @bardeci.

I'm going to confirm that, but I'm almost sure the whole problem was related with USB cable making SD card fs read-only when left plugged in on charge mode on LDK. I did some tests already, and when on charge mode, I'm not able to save anything on .sav files. I can only save when no USB cable is plugged in.

No error message is displayed when saving files fails, so I just didn't realize that at all.

So just for future reference of people reaching out to this issue: make sure you keep your .sav files at /home/retrofw/.gambatte/saves with the same name of your .gb files and don't let your USB cables plugged in while trying to save changes on .sav files!