From: notaz Date: Tue, 11 Aug 2009 14:06:36 +0000 (+0000) Subject: always check for .mds and .mds.gz X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=609d0c070d716f8043dc92d04cdf48fc8535fb0b;p=libpicofe.git always check for .mds and .mds.gz git-svn-id: file:///home/notaz/opt/svn/PicoDrive/platform@746 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/common/emu.c b/common/emu.c index 88d80b7..3443c98 100644 --- a/common/emu.c +++ b/common/emu.c @@ -785,44 +785,53 @@ char *emu_get_save_fname(int load, int is_sram, int slot) if (is_sram) { - romfname_ext(saveFname, (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, - (PicoAHW & PAHW_MCD) ? ".brm" : ".srm"); - if (load) { - if (try_ropen_file(saveFname)) return saveFname; - // try in current dir.. - romfname_ext(saveFname, NULL, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm"); - if (try_ropen_file(saveFname)) return saveFname; - return NULL; // give up - } + strcpy(ext, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm"); + romfname_ext(saveFname, (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, ext); + if (!load) + return saveFname; + + if (try_ropen_file(saveFname)) + return saveFname; + + romfname_ext(saveFname, NULL, ext); + if (try_ropen_file(saveFname)) + return saveFname; } else { + const char *ext_main = (currentConfig.EmuOpt & EOPT_GZIP_SAVES) ? ".mds.gz" : ".mds"; + const char *ext_othr = (currentConfig.EmuOpt & EOPT_GZIP_SAVES) ? ".mds" : ".mds.gz"; ext[0] = 0; - if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot); - strcat(ext, (currentConfig.EmuOpt & EOPT_GZIP_SAVES) ? ".mds.gz" : ".mds"); + if (slot > 0 && slot < 10) + sprintf(ext, ".%i", slot); + strcat(ext, ext_main); + + if (!load) { + romfname_ext(saveFname, "mds" PATH_SEP, ext); + return saveFname; + } + else { + romfname_ext(saveFname, "mds" PATH_SEP, ext); + if (try_ropen_file(saveFname)) + return saveFname; - romfname_ext(saveFname, "mds" PATH_SEP, ext); - if (load) { - if (try_ropen_file(saveFname)) return saveFname; romfname_ext(saveFname, NULL, ext); - if (try_ropen_file(saveFname)) return saveFname; - // no gzipped states, search for non-gzipped - if (currentConfig.EmuOpt & EOPT_GZIP_SAVES) - { - ext[0] = 0; - if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot); - strcat(ext, ".mds"); - - romfname_ext(saveFname, "mds"PATH_SEP, ext); - if (try_ropen_file(saveFname)) return saveFname; - romfname_ext(saveFname, NULL, ext); - if (try_ropen_file(saveFname)) return saveFname; - } - return NULL; + if (try_ropen_file(saveFname)) + return saveFname; + + // try the other ext + ext[0] = 0; + if (slot > 0 && slot < 10) + sprintf(ext, ".%i", slot); + strcat(ext, ext_othr); + + romfname_ext(saveFname, "mds"PATH_SEP, ext); + if (try_ropen_file(saveFname)) + return saveFname; } } - return saveFname; + return NULL; } int emu_check_save_file(int slot) diff --git a/common/menu.c b/common/menu.c index a81e1bc..774f05c 100644 --- a/common/menu.c +++ b/common/menu.c @@ -971,7 +971,7 @@ static void draw_savestate_bg(int slot) unsigned short tmp_cram[0x40]; unsigned short tmp_vsram[0x40]; void *tmp_vram; - char *fname; + const char *fname; fname = emu_get_save_fname(1, 0, slot); if (!fname) return;