Change to the save file handling
I continued the work on the cart_refactor branch, and the structure itself is nearly done (I'll still need to take care of savestates). And, in a typical burst of ADHD-coding, I went and implemented support for NAND save memory, as used by WarioWare DIY and Jam with the Band.

This is when I realized that the current way melonDS handles save files was going to be problematic. Basically, if a save file already exists, melonDS will determine the save memory type from that file's size, instead of using its built-in game list. This was designed in the old days, where we had some wonky heuristics instead of the game list -- the basic idea was that if melonDS failed to determine the correct save memory type, you could provide a known good save file and it would work, bypassing the problem.

Obviously, this is also a double-edged sword. If you happen to have a save file that isn't the correct size, melonDS will pick the wrong save memory type, potentially breaking things. In the end, this strategy now seems to cause more problems than it solves, especially since we have the game list.

The NAND thing was the final nail in the coffin of this strategy. It had been assumed, from some source I don't recall, that the save memory size for NAND was 32MB, and this was nice, because each possible save memory size had only one associated type, no confusion. However, the hardware tests I did showed that the NAND save memory is actually 8MB, and this conflicts with one of the possible FLASH sizes.

(EDIT- I was corrected by another tester. The save memory for WarioWare DIY is 16MB, not 8MB.)

So I ripped the old thing out, and instead made it always rely on the game list to determine the save memory type, regardless of the save file's size. As a bonus, save files that are too big will work too, melonDS will just ignore the extra contents. Which means that, for example, DeSmuME's .dsv files could be used as-is, by just changing the extension to .sav.

If you believe this is going to be a major disadvantage, or see any issue with this, I encourage you to reply to this post.
YoshiBoy says:
Apr 15th 2021
comment
NICOEMU says:
Apr 15th 2021
I agree
GameBoys says:
Apr 16th 2021
i'm not quite understand your explanation, but at least there is a room for improvement.. so just do it we support you
Luke says:
Apr 16th 2021
Is there any chance you could add an option to select save file paths? Files saved in the same folder as the rom are pretty much my only problem with your otherwise amazing emulator.
poudink says:
Apr 16th 2021
Could this cause issues for homebrew/hacks that are absent from the game list?
Generic aka RSDuck says:
Apr 16th 2021
for homebrew no, since homebrew never uses SRAM anyway. It can be problematic for game hacks which change the save file type. Though the way it was handled previously (that you had to manually create a save file of the intended size) wasn't exactly better.
kitty2135 says:
Apr 17th 2021
i'm playing sonic rush adventure and i tried sonic rush with this emu and it works really great in my computer
Anon says:
Apr 24th 2021
On the topic of saves, might I request for a more convenient way of changing save files? Currently in a game like Phantasy Star Zero with 14 different characters, a save file only gives you 3 slots. You would have to carry around 5 different save files and manually swap it in the folder to get to a specific one you want when playing online.
CoupDeKai says:
Jul 22nd 2021
It's been a few months since this was posted, and I apologize if this is considered necromancy... But are the changes mentioned here included in 0.9.2? I realize this was posted before 0.9.2 came out, so it seems likely they are, but the Howto/FAQ page for people new to MelonDS still mentions the importance of save files being the exact correct size.

I'm in the process of converting from desmume today and most of the search results I've found for converting saves make the process seem a lot more involved than here where it's suggested just renaming the file should now work.
CoupDeKai says:
Jul 22nd 2021
I probably could (and should) have just tested it before posting here, yes the FAQ is out of date and MelonDS will handle the secret arcane art of save trimming by itself. Very excellent. For anyone who wanders across this thread in the future looking to convert from desmume, your dsv files are probably in the 'battery' folder and you don't have to rename them.
Post a comment
Name:
DO NOT TOUCH