1.35a psp bugfix release
[libpicofe.git] / common / emu.c
index 117ec6d..644a502 100644 (file)
@@ -137,6 +137,19 @@ int emu_findBios(int region, char **bios_file)
        }\r
 }\r
 \r
+/* check if the name begins with BIOS name */\r
+static int emu_isBios(const char *name)\r
+{\r
+       int i;\r
+       for (i = 0; i < sizeof(biosfiles_us)/sizeof(biosfiles_us[0]); i++)\r
+               if (strstr(name, biosfiles_us[i]) != NULL) return 1;\r
+       for (i = 0; i < sizeof(biosfiles_eu)/sizeof(biosfiles_eu[0]); i++)\r
+               if (strstr(name, biosfiles_eu[i]) != NULL) return 1;\r
+       for (i = 0; i < sizeof(biosfiles_jp)/sizeof(biosfiles_jp[0]); i++)\r
+               if (strstr(name, biosfiles_jp[i]) != NULL) return 1;\r
+       return 0;\r
+}\r
+\r
 /* checks if romFileName points to valid MegaCD image\r
  * if so, checks for suitable BIOS */\r
 int emu_cdCheck(int *pregion)\r
@@ -340,9 +353,12 @@ int emu_ReloadRom(void)
 \r
        menu_romload_end();\r
 \r
-       // emu_ReadConfig() might have messed currentConfig.lastRomFile\r
-       strncpy(currentConfig.lastRomFile, romFileName, sizeof(currentConfig.lastRomFile)-1);\r
-       currentConfig.lastRomFile[sizeof(currentConfig.lastRomFile)-1] = 0;\r
+       if (!emu_isBios(romFileName))\r
+       {\r
+               // emu_ReadConfig() might have messed currentConfig.lastRomFile\r
+               strncpy(currentConfig.lastRomFile, romFileName, sizeof(currentConfig.lastRomFile)-1);\r
+               currentConfig.lastRomFile[sizeof(currentConfig.lastRomFile)-1] = 0;\r
+       }\r
 \r
        if (PicoPatches) {\r
                PicoPatchPrepare();\r