X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=pcsx_rearmed.git;a=blobdiff_plain;f=frontend%2Flibretro.c;h=5bc544380aa6eaced1b5cfa425810bf968531d98;hp=c14f00fed5fb6b29405d49329c4f3959c195d097;hb=215ff9e69c0b845f24e7a3aa9faeef06d9276145;hpb=55e5626b063b3fbfc29576c2ee6b826d4f22d3d2 diff --git a/frontend/libretro.c b/frontend/libretro.c index c14f00fe..5bc54438 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1,5 +1,5 @@ /* - * (C) notaz, 2012 + * (C) notaz, 2012,2014,2015 * * This work is licensed under the terms of the GNU GPLv2 or later. * See the COPYING file in the top-level directory. @@ -19,6 +19,7 @@ #include "../libpcsxcore/cdriso.h" #include "../libpcsxcore/cheat.h" #include "../plugins/dfsound/out.h" +#include "../plugins/dfsound/spu_config.h" #include "../plugins/dfinput/externals.h" #include "cspace.h" #include "main.h" @@ -32,6 +33,7 @@ static retro_input_poll_t input_poll_cb; static retro_input_state_t input_state_cb; static retro_environment_t environ_cb; static retro_audio_sample_batch_t audio_batch_cb; +static struct retro_rumble_interface rumble; static void *vout_buf; static int vout_width, vout_height; @@ -39,7 +41,6 @@ static int vout_doffs_old, vout_fb_dirty; static bool vout_can_dupe; static bool duping_enable; -static int samples_sent, samples_to_send; static int plugins_opened; static int is_pal_mode; @@ -51,7 +52,7 @@ extern char McdDisable[2]; int in_type1, in_type2; int in_a1[2] = { 127, 127 }, in_a2[2] = { 127, 127 }; int in_keystate; -int in_enable_vibration; +int in_enable_vibration = 1; /* PSX max resolution is 640x512, but with enhancement it's 1024x512 */ #define VOUT_MAX_WIDTH 1024 @@ -196,8 +197,10 @@ void pl_timing_prepare(int is_pal) is_pal_mode = is_pal; } -void plat_trigger_vibrate(int is_strong) +void plat_trigger_vibrate(int pad, int low, int high) { + rumble.set_rumble_state(pad, RETRO_RUMBLE_STRONG, high << 8); + rumble.set_rumble_state(pad, RETRO_RUMBLE_WEAK, low ? 0xffff : 0x0); } void pl_update_gun(int *xn, int *yn, int *xres, int *yres, int *in) @@ -216,16 +219,13 @@ static void snd_finish(void) static int snd_busy(void) { - if (samples_to_send > samples_sent) - return 0; /* give more samples */ - else - return 1; + return 0; } static void snd_feed(void *buf, int bytes) { - audio_batch_cb(buf, bytes / 4); - samples_sent += bytes / 4; + if (audio_batch_cb != NULL) + audio_batch_cb(buf, bytes / 4); } void out_register_libretro(struct out_driver *drv) @@ -241,11 +241,12 @@ void out_register_libretro(struct out_driver *drv) void retro_set_environment(retro_environment_t cb) { static const struct retro_variable vars[] = { - { "frameskip", "Frameskip; 0|1|2|3" }, - { "region", "Region; Auto|NTSC|PAL" }, - { "pad1type", "Pad 1 Type; standard|analog" }, + { "pcsx_rearmed_frameskip", "Frameskip; 0|1|2|3" }, + { "pcsx_rearmed_region", "Region; Auto|NTSC|PAL" }, + { "pcsx_rearmed_pad1type", "Pad 1 Type; standard|analog" }, + { "pcsx_rearmed_pad2type", "Pad 2 Type; standard|analog" }, #ifndef DRC_DISABLE - { "rearmed_drc", "Dynamic recompiler; enabled|disabled" }, + { "pcsx_rearmed_drc", "Dynamic recompiler; enabled|disabled" }, #endif #ifdef __ARM_NEON__ { "pcsx_rearmed_neon_interlace_enable", "Enable interlacing mode(s); disabled|enabled" }, @@ -253,6 +254,8 @@ void retro_set_environment(retro_environment_t cb) { "pcsx_rearmed_neon_enhancement_no_main", "Enhanced resolution speed hack; disabled|enabled" }, #endif { "pcsx_rearmed_duping_enable", "Frame duping; on|off" }, + { "pcsx_rearmed_spu_reverb", "Sound: Reverb; on|off" }, + { "pcsx_rearmed_spu_interpolation", "Sound: Interpolation; simple|gaussian|cubic|off" }, { NULL, NULL }, }; @@ -280,7 +283,7 @@ void retro_get_system_info(struct retro_system_info *info) { memset(info, 0, sizeof(*info)); info->library_name = "PCSX-ReARMed"; - info->library_version = "r19"; + info->library_version = "r20"; info->valid_extensions = "bin|cue|img|mdf|pbp|toc|cbn|m3u"; info->need_fullpath = true; } @@ -300,8 +303,9 @@ void retro_get_system_av_info(struct retro_system_av_info *info) /* savestates */ size_t retro_serialize_size(void) { - // it's currently 4380651 bytes, but have some reserved for future - return 0x430000; + // it's currently 4380651-4397047 bytes, + // but have some reserved for future + return 0x440000; } struct save_fp { @@ -598,7 +602,7 @@ static void extract_directory(char *buf, const char *path, size_t size) } } -#ifdef __QNX__ +#if defined(__QNX__) || defined(_WIN32) /* Blackberry QNX doesn't have strcasestr */ /* @@ -948,13 +952,13 @@ static void update_variables(bool in_flight) struct retro_variable var; var.value = NULL; - var.key = "frameskip"; + var.key = "pcsx_rearmed_frameskip"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) pl_rearmed_cbs.frameskip = atoi(var.value); var.value = NULL; - var.key = "region"; + var.key = "pcsx_rearmed_region"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) { @@ -968,7 +972,7 @@ static void update_variables(bool in_flight) } var.value = NULL; - var.key = "pad1type"; + var.key = "pcsx_rearmed_pad1type"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) { @@ -977,6 +981,16 @@ static void update_variables(bool in_flight) in_type1 = PSE_PAD_TYPE_ANALOGPAD; } + var.value = NULL; + var.key = "pcsx_rearmed_pad2type"; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + in_type2 = PSE_PAD_TYPE_STANDARD; + if (strcmp(var.value, "analog") == 0) + in_type2 = PSE_PAD_TYPE_ANALOGPAD; + } + #ifdef __ARM_NEON__ var.value = "NULL"; var.key = "pcsx_rearmed_neon_interlace_enable"; @@ -1025,7 +1039,7 @@ static void update_variables(bool in_flight) #ifndef DRC_DISABLE var.value = NULL; - var.key = "rearmed_drc"; + var.key = "pcsx_rearmed_drc"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) { @@ -1045,6 +1059,32 @@ static void update_variables(bool in_flight) } #endif + var.value = "NULL"; + var.key = "pcsx_rearmed_spu_reverb"; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "off") == 0) + spu_config.iUseReverb = false; + else if (strcmp(var.value, "on") == 0) + 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; + } + if (in_flight) { // inform core things about possible config changes plugin_call_rearmed_cbs(); @@ -1088,8 +1128,6 @@ void retro_run(void) stop = 0; psxCpu->Execute(); - samples_to_send += is_pal_mode ? 44100 / 50 : 44100 / 60; - video_cb((vout_fb_dirty || !vout_can_dupe || !duping_enable) ? vout_buf : NULL, vout_width, vout_height, vout_width * 2); vout_fb_dirty = 0; @@ -1160,7 +1198,7 @@ void retro_init(void) const char *bios[] = { "scph1001", "scph5501", "scph7001" }; const char *dir; char path[256]; - int i, ret, level; + int i, ret; bool found_bios = false; ret = emu_core_preinit(); @@ -1204,20 +1242,19 @@ void retro_init(void) environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&msg); } - level = 1; - environ_cb(RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL, &level); - environ_cb(RETRO_ENVIRONMENT_GET_CAN_DUPE, &vout_can_dupe); environ_cb(RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE, &disk_control); + environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble); /* 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. */ -#ifdef __ARM_ARCH_7A__ +#if !defined(__arm__) || defined(__ARM_ARCH_7A__) cycle_multiplier = 175; #else cycle_multiplier = 200; #endif + pl_rearmed_cbs.gpu_peops.iUseDither = 1; McdDisable[0] = 0; McdDisable[1] = 1;