always check for .mds and .mds.gz
authornotaz <notasas@gmail.com>
Tue, 11 Aug 2009 14:06:36 +0000 (14:06 +0000)
committernotaz <notasas@gmail.com>
Tue, 11 Aug 2009 14:06:36 +0000 (14:06 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@746 be3aeb3a-fb24-0410-a615-afba39da0efa

platform/common/emu.c
platform/common/menu.c

index 88d80b7..3443c98 100644 (file)
@@ -785,44 +785,53 @@ char *emu_get_save_fname(int load, int is_sram, int slot)
 \r
        if (is_sram)\r
        {\r
-               romfname_ext(saveFname, (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP,\r
-                               (PicoAHW & PAHW_MCD) ? ".brm" : ".srm");\r
-               if (load) {\r
-                       if (try_ropen_file(saveFname)) return saveFname;\r
-                       // try in current dir..\r
-                       romfname_ext(saveFname, NULL, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm");\r
-                       if (try_ropen_file(saveFname)) return saveFname;\r
-                       return NULL; // give up\r
-               }\r
+               strcpy(ext, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm");\r
+               romfname_ext(saveFname, (PicoAHW & PAHW_MCD) ? "brm"PATH_SEP : "srm"PATH_SEP, ext);\r
+               if (!load)\r
+                       return saveFname;\r
+\r
+               if (try_ropen_file(saveFname))\r
+                       return saveFname;\r
+\r
+               romfname_ext(saveFname, NULL, ext);\r
+               if (try_ropen_file(saveFname))\r
+                       return saveFname;\r
        }\r
        else\r
        {\r
+               const char *ext_main = (currentConfig.EmuOpt & EOPT_GZIP_SAVES) ? ".mds.gz" : ".mds";\r
+               const char *ext_othr = (currentConfig.EmuOpt & EOPT_GZIP_SAVES) ? ".mds" : ".mds.gz";\r
                ext[0] = 0;\r
-               if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot);\r
-               strcat(ext, (currentConfig.EmuOpt & EOPT_GZIP_SAVES) ? ".mds.gz" : ".mds");\r
+               if (slot > 0 && slot < 10)\r
+                       sprintf(ext, ".%i", slot);\r
+               strcat(ext, ext_main);\r
+\r
+               if (!load) {\r
+                       romfname_ext(saveFname, "mds" PATH_SEP, ext);\r
+                       return saveFname;\r
+               }\r
+               else {\r
+                       romfname_ext(saveFname, "mds" PATH_SEP, ext);\r
+                       if (try_ropen_file(saveFname))\r
+                               return saveFname;\r
 \r
-               romfname_ext(saveFname, "mds" PATH_SEP, ext);\r
-               if (load) {\r
-                       if (try_ropen_file(saveFname)) return saveFname;\r
                        romfname_ext(saveFname, NULL, ext);\r
-                       if (try_ropen_file(saveFname)) return saveFname;\r
-                       // no gzipped states, search for non-gzipped\r
-                       if (currentConfig.EmuOpt & EOPT_GZIP_SAVES)\r
-                       {\r
-                               ext[0] = 0;\r
-                               if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot);\r
-                               strcat(ext, ".mds");\r
-\r
-                               romfname_ext(saveFname, "mds"PATH_SEP, ext);\r
-                               if (try_ropen_file(saveFname)) return saveFname;\r
-                               romfname_ext(saveFname, NULL, ext);\r
-                               if (try_ropen_file(saveFname)) return saveFname;\r
-                       }\r
-                       return NULL;\r
+                       if (try_ropen_file(saveFname))\r
+                               return saveFname;\r
+\r
+                       // try the other ext\r
+                       ext[0] = 0;\r
+                       if (slot > 0 && slot < 10)\r
+                               sprintf(ext, ".%i", slot);\r
+                       strcat(ext, ext_othr);\r
+\r
+                       romfname_ext(saveFname, "mds"PATH_SEP, ext);\r
+                       if (try_ropen_file(saveFname))\r
+                               return saveFname;\r
                }\r
        }\r
 \r
-       return saveFname;\r
+       return NULL;\r
 }\r
 \r
 int emu_check_save_file(int slot)\r
index a81e1bc..774f05c 100644 (file)
@@ -971,7 +971,7 @@ static void draw_savestate_bg(int slot)
        unsigned short tmp_cram[0x40];\r
        unsigned short tmp_vsram[0x40];\r
        void *tmp_vram;\r
-       char *fname;\r
+       const char *fname;\r
 \r
        fname = emu_get_save_fname(1, 0, slot);\r
        if (!fname) return;\r