X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Femu.c;h=71f6716a46c1da32982cf366385ba771080c7db3;hb=0480e6c9696e4d4cbd451a91a7ef63d96f60542d;hp=723dfb74050e3d8c79a37a3c72353f694f117925;hpb=11f4e72292ab00c686f2a2288e4f1cda3a0f7abd;p=libpicofe.git diff --git a/common/emu.c b/common/emu.c index 723dfb7..71f6716 100644 --- a/common/emu.c +++ b/common/emu.c @@ -26,7 +26,11 @@ #elif defined(__GIZ__) #include "../gizmondo/giz.h" #define SCREEN_WIDTH 321 - #define SCREEN_BUFFER giz_screen // ? + #define SCREEN_BUFFER giz_screen +#elif defined(PSP) + #include "../psp/psp.h" + #define SCREEN_WIDTH 512 + #define SCREEN_BUFFER psp_screen #endif char *PicoConfigFile = "picoconfig.bin"; @@ -133,6 +137,19 @@ int emu_findBios(int region, char **bios_file) } } +/* check if the name begins with BIOS name */ +static int emu_isBios(const char *name) +{ + int i; + for (i = 0; i < sizeof(biosfiles_us)/sizeof(biosfiles_us[0]); i++) + if (strstr(name, biosfiles_us[i]) != NULL) return 1; + for (i = 0; i < sizeof(biosfiles_eu)/sizeof(biosfiles_eu[0]); i++) + if (strstr(name, biosfiles_eu[i]) != NULL) return 1; + for (i = 0; i < sizeof(biosfiles_jp)/sizeof(biosfiles_jp[0]); i++) + if (strstr(name, biosfiles_jp[i]) != NULL) return 1; + return 0; +} + /* checks if romFileName points to valid MegaCD image * if so, checks for suitable BIOS */ int emu_cdCheck(int *pregion) @@ -281,7 +298,7 @@ int emu_ReloadRom(void) return 0; } - menu_romload_prepare(used_rom_name); + menu_romload_prepare(used_rom_name); // also CD load if(rom_data) { free(rom_data); @@ -297,7 +314,6 @@ int emu_ReloadRom(void) return 0; } pm_close(rom); - menu_romload_end(); // detect wrong files (Pico crashes on very small files), also see if ROM EP is good if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 || @@ -305,6 +321,7 @@ int emu_ReloadRom(void) if (rom_data) free(rom_data); rom_data = 0; sprintf(menuErrorMsg, "Not a ROM selected."); + menu_romload_end(); return 0; } @@ -317,6 +334,7 @@ int emu_ReloadRom(void) lprintf("PicoCartInsert(%p, %d);\n", rom_data, rom_size); if(PicoCartInsert(rom_data, rom_size)) { sprintf(menuErrorMsg, "Failed to load ROM."); + menu_romload_end(); return 0; } @@ -328,13 +346,19 @@ int emu_ReloadRom(void) if (ret != 0) { sprintf(menuErrorMsg, "Insert_CD() failed, invalid CD image?"); lprintf("%s\n", menuErrorMsg); + menu_romload_end(); return 0; } } - // emu_ReadConfig() might have messed currentConfig.lastRomFile - strncpy(currentConfig.lastRomFile, romFileName, sizeof(currentConfig.lastRomFile)-1); - currentConfig.lastRomFile[sizeof(currentConfig.lastRomFile)-1] = 0; + menu_romload_end(); + + if (!emu_isBios(romFileName)) + { + // emu_ReadConfig() might have messed currentConfig.lastRomFile + strncpy(currentConfig.lastRomFile, romFileName, sizeof(currentConfig.lastRomFile)-1); + currentConfig.lastRomFile[sizeof(currentConfig.lastRomFile)-1] = 0; + } if (PicoPatches) { PicoPatchPrepare(); @@ -444,7 +468,11 @@ int emu_ReadConfig(int game, int no_defaults) //scaling_update(); // some sanity checks if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 4096) currentConfig.CPUclock = 200; +#ifdef PSP + if (currentConfig.gamma < -4 || currentConfig.gamma > 16) currentConfig.gamma = 0; +#else if (currentConfig.gamma < 10 || currentConfig.gamma > 300) currentConfig.gamma = 100; +#endif if (currentConfig.volume < 0 || currentConfig.volume > 99) currentConfig.volume = 50; #ifdef __GP2X__ // if volume keys are unbound, bind them to volume control