X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2Flibretro.c;h=e4772848cf2c44c4fdb8abc3cf2d23fc649cb964;hb=de36a5369040b8a76db02d263ed8bb717ebf9157;hp=15c53a3ce1fb94b7ebc9a9374a442ee702dfcdf0;hpb=07ade526c4a0b1ddb316aff1459c1bdff31c267a;p=pcsx_rearmed.git diff --git a/frontend/libretro.c b/frontend/libretro.c index 15c53a3c..e4772848 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -501,7 +501,7 @@ struct rearmed_cbs pl_rearmed_cbs = { void pl_frame_limit(void) { /* called once per frame, make psxCpu->Execute() above return */ - stop = 1; + stop++; } void pl_timing_prepare(int is_pal) @@ -1936,6 +1936,8 @@ static void update_variables(bool in_flight) display_internal_fps = true; } + // + // CPU emulation related config #ifndef DRC_DISABLE var.value = NULL; var.key = "pcsx_rearmed_drc"; @@ -1964,54 +1966,77 @@ static void update_variables(bool in_flight) psxCpu = (Config.Cpu == CPU_INTERPRETER) ? &psxInt : &psxRec; if (psxCpu != prev_cpu) { + prev_cpu->Notify(R3000ACPU_NOTIFY_BEFORE_SAVE, NULL); prev_cpu->Shutdown(); psxCpu->Init(); - psxCpu->Reset(); // not really a reset.. + psxCpu->Reset(); + psxCpu->Notify(R3000ACPU_NOTIFY_AFTER_LOAD, NULL); } } #endif /* !DRC_DISABLE */ - psxCpu->ApplyConfig(); var.value = NULL; - var.key = "pcsx_rearmed_spu_reverb"; + var.key = "pcsx_rearmed_psxclock"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + int psxclock = atoi(var.value); + Config.cycle_multiplier = 10000 / psxclock; + } +#if !defined(DRC_DISABLE) && !defined(LIGHTREC) + var.value = NULL; + var.key = "pcsx_rearmed_nosmccheck"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (strcmp(var.value, "disabled") == 0) - spu_config.iUseReverb = false; - else if (strcmp(var.value, "enabled") == 0) - spu_config.iUseReverb = true; + if (strcmp(var.value, "enabled") == 0) + new_dynarec_hacks |= NDHACK_NO_SMC_CHECK; + else + new_dynarec_hacks &= ~NDHACK_NO_SMC_CHECK; } var.value = NULL; - var.key = "pcsx_rearmed_spu_interpolation"; + var.key = "pcsx_rearmed_gteregsunneeded"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "enabled") == 0) + new_dynarec_hacks |= NDHACK_GTE_UNNEEDED; + else + new_dynarec_hacks &= ~NDHACK_GTE_UNNEEDED; + } + var.value = NULL; + var.key = "pcsx_rearmed_nogteflags"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (strcmp(var.value, "simple") == 0) - spu_config.iUseInterpolation = 1; - else if (strcmp(var.value, "gaussian") == 0) - spu_config.iUseInterpolation = 2; - else if (strcmp(var.value, "cubic") == 0) - spu_config.iUseInterpolation = 3; - else if (strcmp(var.value, "off") == 0) - spu_config.iUseInterpolation = 0; + if (strcmp(var.value, "enabled") == 0) + new_dynarec_hacks |= NDHACK_GTE_NO_FLAGS; + else + new_dynarec_hacks &= ~NDHACK_GTE_NO_FLAGS; } var.value = NULL; - var.key = "pcsx_rearmed_pe2_fix"; + var.key = "pcsx_rearmed_nocompathacks"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "enabled") == 0) + new_dynarec_hacks |= NDHACK_NO_COMPAT_HACKS; + else + new_dynarec_hacks &= ~NDHACK_NO_COMPAT_HACKS; + } +#endif /* !DRC_DISABLE && !LIGHTREC */ + var.value = NULL; + var.key = "pcsx_rearmed_nostalls"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (strcmp(var.value, "disabled") == 0) - Config.RCntFix = 0; - else if (strcmp(var.value, "enabled") == 0) - Config.RCntFix = 1; + if (strcmp(var.value, "enabled") == 0) + Config.DisableStalls = 1; + else + Config.DisableStalls = 0; } - + var.value = NULL; var.key = "pcsx_rearmed_icache_emulation"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (strcmp(var.value, "disabled") == 0) @@ -2020,15 +2045,45 @@ static void update_variables(bool in_flight) Config.icache_emulation = 1; } + psxCpu->ApplyConfig(); + + // end of CPU emu config + // + var.value = NULL; - var.key = "pcsx_rearmed_inuyasha_fix"; + var.key = "pcsx_rearmed_spu_reverb"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (strcmp(var.value, "disabled") == 0) - Config.VSyncWA = 0; + spu_config.iUseReverb = false; else if (strcmp(var.value, "enabled") == 0) - Config.VSyncWA = 1; + spu_config.iUseReverb = true; + } + + var.value = NULL; + var.key = "pcsx_rearmed_spu_interpolation"; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "simple") == 0) + spu_config.iUseInterpolation = 1; + else if (strcmp(var.value, "gaussian") == 0) + spu_config.iUseInterpolation = 2; + else if (strcmp(var.value, "cubic") == 0) + spu_config.iUseInterpolation = 3; + else if (strcmp(var.value, "off") == 0) + spu_config.iUseInterpolation = 0; + } + + var.value = NULL; + var.key = "pcsx_rearmed_spu_thread"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "enabled") == 0) + spu_config.iUseThread = 1; + else + spu_config.iUseThread = 0; } #ifndef _WIN32 @@ -2075,13 +2130,15 @@ static void update_variables(bool in_flight) } var.value = NULL; - var.key = "pcsx_rearmed_spuirq"; + var.key = "pcsx_rearmed_gpu_slow_llists"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { if (strcmp(var.value, "disabled") == 0) - Config.SpuIrq = 0; - else - Config.SpuIrq = 1; + Config.GpuListWalking = 0; + else if (strcmp(var.value, "enabled") == 0) + Config.GpuListWalking = 1; + else // auto + Config.GpuListWalking = -1; } #ifdef THREAD_RENDERING @@ -2267,67 +2324,6 @@ static void update_variables(bool in_flight) GunconAdjustRatioY = atof(var.value); } -#if !defined(DRC_DISABLE) && !defined(LIGHTREC) - var.value = NULL; - var.key = "pcsx_rearmed_nosmccheck"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (strcmp(var.value, "enabled") == 0) - new_dynarec_hacks |= NDHACK_NO_SMC_CHECK; - else - new_dynarec_hacks &= ~NDHACK_NO_SMC_CHECK; - } - - var.value = NULL; - var.key = "pcsx_rearmed_gteregsunneeded"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (strcmp(var.value, "enabled") == 0) - new_dynarec_hacks |= NDHACK_GTE_UNNEEDED; - else - new_dynarec_hacks &= ~NDHACK_GTE_UNNEEDED; - } - - var.value = NULL; - var.key = "pcsx_rearmed_nogteflags"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (strcmp(var.value, "enabled") == 0) - new_dynarec_hacks |= NDHACK_GTE_NO_FLAGS; - else - new_dynarec_hacks &= ~NDHACK_GTE_NO_FLAGS; - } - - /* this probably is safe to change in real-time */ - var.value = NULL; - var.key = "pcsx_rearmed_psxclock"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - int psxclock = atoi(var.value); - cycle_multiplier = 10000 / psxclock; - } - - var.value = NULL; - var.key = "pcsx_rearmed_nocompathacks"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (strcmp(var.value, "enabled") == 0) - new_dynarec_hacks |= NDHACK_NO_COMPAT_HACKS; - else - new_dynarec_hacks &= ~NDHACK_NO_COMPAT_HACKS; - } -#endif /* !DRC_DISABLE && !LIGHTREC */ - - var.value = NULL; - var.key = "pcsx_rearmed_nostalls"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (strcmp(var.value, "enabled") == 0) - Config.DisableStalls = 1; - else - Config.DisableStalls = 0; - } - var.value = NULL; var.key = "pcsx_rearmed_input_sensitivity"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) @@ -2437,17 +2433,19 @@ static void update_input_guncon(int port, int ret) //Mouse range is -32767 -> 32767 //1% is about 655 //Use the left analog stick field to store the absolute coordinates - //Fix cursor to top-left when gun is detected as "offscreen" + + int gunx = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X); + int guny = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y); + + //Have the Libretro API let /libpcsxcore/plugins.c know when the lightgun is pointed offscreen + //Offscreen value is chosen to be well out of range of any possible scaling done via core options if (input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN) || input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_RELOAD)) { - in_analog_left[port][0] = -32767; - in_analog_left[port][1] = -32767; + in_analog_left[port][0] = (65536 - 512) * 64; + in_analog_left[port][1] = (65536 - 512) * 64; } else { - int gunx = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X); - int guny = input_state_cb(port, RETRO_DEVICE_LIGHTGUN, 0, RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y); - in_analog_left[port][0] = (gunx * GunconAdjustRatioX) + (GunconAdjustX * 655); in_analog_left[port][1] = (guny * GunconAdjustRatioY) + (GunconAdjustY * 655); } @@ -2712,12 +2710,6 @@ void retro_run(void) { rebootemu = 0; SysReset(); - if (!Config.HLE && !Config.SlowBoot) - { - // skip BIOS logos - psxRegs.pc = psxRegs.GPR.n.ra; - } - return; } print_internal_fps(); @@ -2815,23 +2807,36 @@ static bool try_use_bios(const char *path) static bool find_any_bios(const char *dirpath, char *path, size_t path_size) { + static const char *substrings[] = { "scph", "psx", "openbios" }; DIR *dir; struct dirent *ent; bool ret = false; + size_t i; dir = opendir(dirpath); if (dir == NULL) return false; - while ((ent = readdir(dir))) + for (i = 0; sizeof(substrings) / sizeof(substrings[0]); i++) { - if ((strncasecmp(ent->d_name, "scph", 4) != 0) && (strncasecmp(ent->d_name, "psx", 3) != 0)) - continue; - - snprintf(path, path_size, "%s%c%s", dirpath, SLASH, ent->d_name); - ret = try_use_bios(path); - if (ret) - break; + const char *substr = substrings[i]; + size_t len = strlen(substr); + rewinddir(dir); + while ((ent = readdir(dir))) + { + if ((strncasecmp(ent->d_name, substr, len) != 0)) + continue; + if (strstr(ent->d_name, "unirom")) + continue; + + snprintf(path, path_size, "%s%c%s", dirpath, SLASH, ent->d_name); + ret = try_use_bios(path); + if (ret) + { + closedir(dir); + return ret; + } + } } closedir(dir); return ret; @@ -3049,9 +3054,9 @@ void retro_init(void) /* Set how much slower PSX CPU runs * 100 (so that 200 is 2 times) * we have to do this because cache misses and some IO penalties * are not emulated. Warning: changing this may break compatibility. */ - cycle_multiplier = 175; + Config.cycle_multiplier = CYCLE_MULT_DEFAULT; #if defined(HAVE_PRE_ARMV7) && !defined(_3DS) - cycle_multiplier = 200; + Config.cycle_multiplier = 200; #endif pl_rearmed_cbs.gpu_peops.iUseDither = 1; pl_rearmed_cbs.gpu_peops.dwActFixes = GPU_PEOPS_OLD_FRAME_SKIP; @@ -3146,3 +3151,5 @@ void SysDLog(const char *fmt, ...) if (log_cb) log_cb(RETRO_LOG_DEBUG, "%s", msg); } + +// vim:sw=3:ts=3:expandtab