pocomane / MiSTer_Batch_Control

Simple utility to control the MiSTer FPGA from the command line
47 stars 8 forks source link

Add support for Save Game Files #15

Closed InquisitiveCoder closed 2 years ago

InquisitiveCoder commented 2 years ago

While using Super Attract Mode, which uses MBC to load randomly selected ROMs, I noticed that games usually boot up as if their save file didn't exist. This seems to be caused by MBC launching every game with a symlink named ~~~.${ext}. After some testing I confirmed that save files, save states and screenshots all use ~~~ in place of the ROM's original name.

As a result, the core fails to recognize the files that the game would use when launched normally, and any files created when a game is launched through MBC could be overwritten the next time a game for the same core is launched. In theory, keeping the ROM's original name when creating would resolve these issues. As far as I can tell MBC deletes the subdirectory with the symlink after the game is loaded, so I'd expect the symlink to be at the top of the subdirectory regardless of its name. Never mind that last part, I see now that the subdirectory is mounted and unmounted.

pocomane commented 2 years ago

With the mount/unmount method, the rom name is changed just to make more simple the file handling, so it should not be difficult to use the original names.

BUT I do not know if this enough to let the save files works. I will make some experiment in the next days.

InquisitiveCoder commented 2 years ago

Today I changed get_aux_rom_path to use the ROM's name instead of ~~~.${sys->romext} and was able to confirm that save files will load correctly. However, I'm not a C or Linux programmer so it's difficult for me to ensure all files are unlinked and deleted before the next file is mounted.

pocomane commented 2 years ago

Check the new release. It should keep the rom name, but I did not test yet if the save games work.

InquisitiveCoder commented 2 years ago

Saves, save states and screenshots are all getting saved and loaded using the ROM's name as expected. Works perfectly. Thanks for the quick fix!