X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=common%2Femu.c;h=1bbdf35f72a3432b41539a14c1bebe2a5e6553e0;hb=1ceda4176ff86029e143802e2b5999dd2d091e9c;hp=14cc52aeeea38a5715582d34134b6791c86dcf16;hpb=8d5cb10d611a93fb21139bab7a11e7ff0d2292e6;p=libpicofe.git diff --git a/common/emu.c b/common/emu.c index 14cc52a..1bbdf35 100644 --- a/common/emu.c +++ b/common/emu.c @@ -164,6 +164,9 @@ int emu_cdCheck(int *pregion) unsigned char buf[32]; pm_file *cd_f; int type = 0, region = 4; // 1: Japan, 4: US, 8: Europe + char ext[5]; + + get_ext(romFileName, ext); cd_f = pm_open(romFileName); if (!cd_f) return 0; // let the upper level handle this @@ -235,7 +238,7 @@ char *emu_makeRomId(void) static char id_string[3+0x11+0x11+0x30+16]; int pos, swab = 1; - if (PicoMCD & 1) { + if (PicoAHW & PAHW_MCD) { strcpy(id_string, "CD|"); swab = 0; } @@ -325,14 +328,14 @@ int emu_ReloadRom(void) get_ext(romFileName, ext); } - if ((PicoMCD & 1) && Pico_mcd != NULL) + if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL) Stop_CD(); // check for MegaCD image cd_state = emu_cdCheck(&cd_region); - if (cd_state > 0) + if (cd_state != CIT_NOT_CD) { - PicoMCD |= 1; + PicoAHW |= PAHW_MCD; // valid CD image, check for BIOS.. // we need to have config loaded at this point @@ -346,7 +349,7 @@ int emu_ReloadRom(void) } if (!emu_findBios(cd_region, &used_rom_name)) { // bios_help() ? - PicoMCD &= ~1; + PicoAHW &= ~PAHW_MCD; return 0; } @@ -354,8 +357,8 @@ int emu_ReloadRom(void) } else { - if (PicoMCD & 1) Stop_CD(); - PicoMCD &= ~1; + if (PicoAHW & PAHW_MCD) Stop_CD(); + PicoAHW &= ~PAHW_MCD; } rom = pm_open(used_rom_name); @@ -388,7 +391,7 @@ int emu_ReloadRom(void) } // load config for this ROM (do this before insert to get correct region) - if (!(PicoMCD&1)) + if (!(PicoAHW & PAHW_MCD)) memcpy(id_header, rom_data + 0x100, sizeof(id_header)); if (!cfg_loaded) { ret = emu_ReadConfig(1, 1); @@ -405,8 +408,8 @@ int emu_ReloadRom(void) Pico.m.frame_count = 0; // insert CD if it was detected - if (cd_state > 0) { - ret = Insert_CD(romFileName, cd_state == 2); + if (cd_state != CIT_NOT_CD) { + ret = Insert_CD(romFileName, cd_state); if (ret != 0) { sprintf(menuErrorMsg, "Insert_CD() failed, invalid CD image?"); lprintf("%s\n", menuErrorMsg); @@ -425,9 +428,9 @@ int emu_ReloadRom(void) // additional movie stuff if (movie_data) { if(movie_data[0x14] == '6') - PicoOpt |= 0x20; // 6 button pad - else PicoOpt &= ~0x20; - PicoOpt |= 0x10040; // accurate timing, no VDP fifo timing + PicoOpt |= POPT_6BTN_PAD; // 6 button pad + else PicoOpt &= ~POPT_6BTN_PAD; + PicoOpt |= POPT_DIS_VDP_FIFO|POPT_ACC_TIMING; // accurate timing, no VDP fifo timing if(movie_data[0xF] >= 'A') { if(movie_data[0x16] & 0x80) { PicoRegionOverride = 8; @@ -442,7 +445,7 @@ int emu_ReloadRom(void) } else { - PicoOpt &= ~0x10000; + PicoOpt &= ~POPT_DIS_VDP_FIFO; if(Pico.m.pal) { strcpy(noticeMsg, "PAL SYSTEM / 50 FPS"); } else { @@ -572,6 +575,7 @@ int emu_ReadConfig(int game, int no_defaults) if (currentConfig.CPUclock < 10 || currentConfig.CPUclock > 4096) currentConfig.CPUclock = 200; #ifdef PSP if (currentConfig.gamma < -4 || currentConfig.gamma > 16) currentConfig.gamma = 0; + if (currentConfig.gamma2 < 0 || currentConfig.gamma2 > 2) currentConfig.gamma2 = 0; #else if (currentConfig.gamma < 10 || currentConfig.gamma > 300) currentConfig.gamma = 100; #endif @@ -672,6 +676,12 @@ void emu_textOut16(int x, int y, const char *text) } } +#ifdef PSP +#define MAX_COMBO_KEY 23 +#else +#define MAX_COMBO_KEY 31 +#endif + void emu_findKeyBindCombos(void) { int act, u; @@ -684,15 +694,15 @@ void emu_findKeyBindCombos(void) if (act == 16 || act == 17) continue; // player2 flag if (act > 17) { - for (u = 0; u < 32; u++) + for (u = 0; u <= MAX_COMBO_KEY; u++) if (currentConfig.KeyBinds[u] & (1 << act)) keyc++; } else { - for (u = 0; u < 32; u++) + for (u = 0; u <= MAX_COMBO_KEY; u++) if ((currentConfig.KeyBinds[u] & 0x30000) == 0 && // pl. 1 (currentConfig.KeyBinds[u] & (1 << act))) keyc++; - for (u = 0; u < 32; u++) + for (u = 0; u <= MAX_COMBO_KEY; u++) if ((currentConfig.KeyBinds[u] & 0x30000) == 1 && // pl. 2 (currentConfig.KeyBinds[u] & (1 << act))) keyc2++; if (keyc2 > keyc) keyc = keyc2; @@ -700,7 +710,7 @@ void emu_findKeyBindCombos(void) if (keyc > 1) { // loop again and mark those keys and actions as combo - for (u = 0; u < 32; u++) + for (u = 0; u <= MAX_COMBO_KEY; u++) { if (currentConfig.KeyBinds[u] & (1 << act)) { kb_combo_keys |= 1 << u; @@ -773,11 +783,11 @@ char *emu_GetSaveFName(int load, int is_sram, int slot) if (is_sram) { - romfname_ext(saveFname, (PicoMCD&1) ? "brm/" : "srm/", (PicoMCD&1) ? ".brm" : ".srm"); + romfname_ext(saveFname, (PicoAHW&1) ? "brm/" : "srm/", (PicoAHW&1) ? ".brm" : ".srm"); if (load) { if (try_ropen_file(saveFname)) return saveFname; // try in current dir.. - romfname_ext(saveFname, NULL, (PicoMCD&1) ? ".brm" : ".srm"); + romfname_ext(saveFname, NULL, (PicoAHW & PAHW_MCD) ? ".brm" : ".srm"); if (try_ropen_file(saveFname)) return saveFname; return NULL; // give up } @@ -855,8 +865,9 @@ int emu_SaveLoadGame(int load, int sram) int sram_size; unsigned char *sram_data; int truncate = 1; - if (PicoMCD&1) { - if (PicoOpt&0x8000) { // MCD RAM cart? + if (PicoAHW & PAHW_MCD) + { + if (PicoOpt&POPT_EN_MCD_RAMCART) { sram_size = 0x12000; sram_data = SRam.data; if (sram_data) @@ -873,12 +884,13 @@ int emu_SaveLoadGame(int load, int sram) } if (!sram_data) return 0; // SRam forcefully disabled for this game - if (load) { + if (load) + { sramFile = fopen(saveFname, "rb"); if(!sramFile) return -1; fread(sram_data, 1, sram_size, sramFile); fclose(sramFile); - if ((PicoMCD&1) && (PicoOpt&0x8000)) + if ((PicoAHW & PAHW_MCD) && (PicoOpt&POPT_EN_MCD_RAMCART)) memcpy32((int *)Pico_mcd->bram, (int *)sram_data, 0x2000/4); } else { // sram save needs some special processing