by mashley » Wed Apr 30, 2014 5:18 pm
Just to follow up on this, I have succeeded in getting snes9x to remount the filesystem read/write when it saves the game's SRAM. It then saves the file and finally remounts the filesystem read only. In case anybody is interested, this meant adding calls to mount() in CMemory::SaveSRAM(), defined in memmap.cpp. Here's the modified function:
$this->bbcode_second_pass_code('', 'bool8_32 CMemory::SaveSRAM (const char *filename)
{
int size = Memory.SRAMSize ?
(1 << (Memory.SRAMSize + 3)) * 128 : 0;
#ifndef _ZAURUS
if (Settings.SRTC)
{
size += SRTC_SRAM_PAD;
S9xSRTCPreSaveState ();
}
if (Settings.SDD1)
S9xSDD1SaveLoggedData ();
#endif
if (size > 0x20000)
size = 0x20000;
if (size && *Memory.ROMFilename)
{
if (mount(NULL, "/", NULL, MS_MGC_VAL | MS_REMOUNT, NULL) != 0) {
fprintf(stderr, "Could not remount root fs read/write");
return(FALSE);
}
FILE *file;
if ((file = fopen (filename, "wb")))
{
fwrite ((char *) ::SRAM, size, 1, file);
fclose (file);
#if defined(__linux)
chown (filename, getuid (), getgid ());
#endif
if (mount(NULL, "/", NULL, MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL) != 0) {
fprintf(stderr, "Could not remount roof fs read only. %s", strerror(errno));
}
return (TRUE);
}
}
if (mount(NULL, "/", NULL, MS_MGC_VAL | MS_REMOUNT | MS_RDONLY, NULL) != 0) {
fprintf(stderr, "Could not remount roof fs read only (2)");
}
return (FALSE);
}')