psp fixes, gamma
[libpicofe.git] / common / emu.c
index 117ec6d..71f6716 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
@@ -452,7 +468,11 @@ int emu_ReadConfig(int game, int no_defaults)
        //scaling_update();\r
        // some sanity checks\r
        if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 4096) currentConfig.CPUclock = 200;\r
+#ifdef PSP\r
+       if (currentConfig.gamma < -4 || currentConfig.gamma >  16) currentConfig.gamma = 0;\r
+#else\r
        if (currentConfig.gamma < 10 || currentConfig.gamma > 300) currentConfig.gamma = 100;\r
+#endif\r
        if (currentConfig.volume < 0 || currentConfig.volume > 99) currentConfig.volume = 50;\r
 #ifdef __GP2X__\r
        // if volume keys are unbound, bind them to volume control\r