X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2Flibretro.c;h=ab8542187a1daf9a3cafc668f905b81138132984;hb=9f2c632c7c04c7c86cf66ba3210b43c3e8394e48;hp=081f8bacf271821a14bd5cdd774f20fbf8ad211b;hpb=915cd7d7a2b7d4c5f3dd53219b36f62184d68c65;p=pcsx_rearmed.git diff --git a/frontend/libretro.c b/frontend/libretro.c index 081f8bac..ab854218 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -15,6 +15,10 @@ #include #endif +#ifdef SWITCH +#include +#endif + #include "../libpcsxcore/misc.h" #include "../libpcsxcore/psxcounters.h" #include "../libpcsxcore/psxmem_map.h" @@ -78,6 +82,7 @@ static bool display_internal_fps = false; static unsigned frame_count = 0; static bool libretro_supports_bitmasks = false; static int show_advanced_gpu_peops_settings = -1; +static int show_advanced_gpu_unai_settings = -1; static unsigned previous_width = 0; static unsigned previous_height = 0; @@ -571,6 +576,8 @@ static void update_controller_port_variable(unsigned port) in_type[port] = PSE_PAD_TYPE_ANALOGPAD; else if (strcmp(var.value, "negcon") == 0) in_type[port] = PSE_PAD_TYPE_NEGCON; + else if (strcmp(var.value, "guncon") == 0) + in_type[port] = PSE_PAD_TYPE_GUNCON; else if (strcmp(var.value, "none") == 0) in_type[port] = PSE_PAD_TYPE_NONE; // else 'default' case, do nothing @@ -1049,6 +1056,20 @@ strcasestr(const char *s, const char*find) } #endif +static void set_retro_memmap(void) +{ + struct retro_memory_map retromap = { 0 }; + struct retro_memory_descriptor mmap = + { + 0, psxM, 0, 0, 0, 0, 0x200000 + }; + + retromap.descriptors = &mmap; + retromap.num_descriptors = 1; + + environ_cb(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &retromap); +} + bool retro_load_game(const struct retro_game_info *info) { size_t i; @@ -1310,6 +1331,8 @@ bool retro_load_game(const struct retro_game_info *info) } } + set_retro_memmap(); + return true; } @@ -1433,6 +1456,7 @@ static void update_variables(bool in_flight) if (strcmp(var.value, "disabled") == 0) { pl_rearmed_cbs.gpu_peops.iUseDither = 0; pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 0; + pl_rearmed_cbs.gpu_unai.dithering = 0; #ifdef __ARM_NEON__ pl_rearmed_cbs.gpu_neon.allow_dithering = 0; #endif @@ -1440,6 +1464,7 @@ static void update_variables(bool in_flight) else if (strcmp(var.value, "enabled") == 0) { pl_rearmed_cbs.gpu_peops.iUseDither = 1; pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 1; + pl_rearmed_cbs.gpu_unai.dithering = 1; #ifdef __ARM_NEON__ pl_rearmed_cbs.gpu_neon.allow_dithering = 1; #endif @@ -1609,6 +1634,16 @@ static void update_variables(bool in_flight) Config.Cdda = 0; } + var.value = NULL; + var.key = "pcsx_rearmed_spuirq"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "disabled") == 0) + Config.SpuIrq = 0; + else + Config.SpuIrq = 1; + } + #ifndef DRC_DISABLE var.value = NULL; var.key = "pcsx_rearmed_nosmccheck"; @@ -1767,6 +1802,96 @@ static void update_variables(bool in_flight) } #endif +#ifdef GPU_UNAI + var.key = "pcsx_rearmed_gpu_unai_ilace_force"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.gpu_unai.ilace_force = 0; + else if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_unai.ilace_force = 1; + } + + var.key = "pcsx_rearmed_gpu_unai_pixel_skip"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.gpu_unai.pixel_skip = 0; + else if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_unai.pixel_skip = 1; + } + + var.key = "pcsx_rearmed_gpu_unai_lighting"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.gpu_unai.lighting = 0; + else if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_unai.lighting = 1; + } + + var.key = "pcsx_rearmed_gpu_unai_fast_lighting"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.gpu_unai.fast_lighting = 0; + else if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_unai.fast_lighting = 1; + } + + var.key = "pcsx_rearmed_gpu_unai_blending"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + if (strcmp(var.value, "disabled") == 0) + pl_rearmed_cbs.gpu_unai.blending = 0; + else if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_unai.blending = 1; + } + + var.key = "pcsx_rearmed_show_gpu_unai_settings"; + var.value = NULL; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + int show_advanced_gpu_unai_settings_prev = show_advanced_gpu_unai_settings; + + show_advanced_gpu_unai_settings = 1; + if (strcmp(var.value, "disabled") == 0) + show_advanced_gpu_unai_settings = 0; + + if (show_advanced_gpu_unai_settings != show_advanced_gpu_unai_settings_prev) + { + unsigned i; + struct retro_core_option_display option_display; + char gpu_unai_option[5][40] = { + "pcsx_rearmed_gpu_unai_blending", + "pcsx_rearmed_gpu_unai_lighting", + "pcsx_rearmed_gpu_unai_fast_lighting", + "pcsx_rearmed_gpu_unai_ilace_force", + "pcsx_rearmed_gpu_unai_pixel_skip", + }; + + option_display.visible = show_advanced_gpu_unai_settings; + + for (i = 0; i < 5; i++) + { + option_display.key = gpu_unai_option[i]; + environ_cb(RETRO_ENVIRONMENT_SET_CORE_OPTIONS_DISPLAY, &option_display); + } + } + } +#endif // GPU_UNAI + if (in_flight) { // inform core things about possible config changes plugin_call_rearmed_cbs(); @@ -1907,6 +2032,93 @@ void retro_run(void) } } + if (in_type[i] == PSE_PAD_TYPE_GUNCON) + { + //ToDo move across to: + //RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X + //RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y + //RETRO_DEVICE_ID_LIGHTGUN_TRIGGER + //RETRO_DEVICE_ID_LIGHTGUN_RELOAD + //RETRO_DEVICE_ID_LIGHTGUN_AUX_A + //RETRO_DEVICE_ID_LIGHTGUN_AUX_B + //Though not sure these are hooked up properly on the Pi + + //ToDo + //Put the controller index back to i instead of hardcoding to 1 when the libretro overlay crash bug is fixed + //This is required for 2 player + + //GUNCON has 3 controls, Trigger,A,B which equal Circle,Start,Cross + + // Trigger + //The 1 is hardcoded instead of i to prevent the overlay mouse button libretro crash bug + if (input_state_cb(1, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_LEFT)){ + in_keystate[i] |= (1 << DKEY_CIRCLE); + } + + // A + if (input_state_cb(1, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_RIGHT)){ + in_keystate[i] |= (1 << DKEY_START); + } + + // B + if (input_state_cb(1, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_MIDDLE)){ + in_keystate[i] |= (1 << DKEY_CROSS); + } + + //The 1 is hardcoded instead of i to prevent the overlay mouse button libretro crash bug + int gunx = input_state_cb(1, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X); + int guny = input_state_cb(1, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y); + + //This adjustment process gives the user the ability to manually align the mouse up better + //with where the shots are in the emulator. + + //Percentage distance of screen to adjust + int GunconAdjustX = 0; + int GunconAdjustY = 0; + + //Used when out by a percentage + float GunconAdjustRatioX = 1; + float GunconAdjustRatioY = 1; + + struct retro_variable var; + var.value = NULL; + var.key = "pcsx_rearmed_gunconadjustx"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + GunconAdjustX = atoi(var.value); + } + + var.value = NULL; + var.key = "pcsx_rearmed_gunconadjusty"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + GunconAdjustY = atoi(var.value); + } + + + var.value = NULL; + var.key = "pcsx_rearmed_gunconadjustratiox"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + GunconAdjustRatioX = atof(var.value); + } + + + var.value = NULL; + var.key = "pcsx_rearmed_gunconadjustratioy"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) || var.value) + { + GunconAdjustRatioY = atof(var.value); + } + + //Mouse range is -32767 -> 32767 + //1% is about 655 + //Use the left analog stick field to store the absolute coordinates + in_analog_left[0][0] = (gunx*GunconAdjustRatioX) + (GunconAdjustX * 655); + in_analog_left[0][1] = (guny*GunconAdjustRatioY) + (GunconAdjustY * 655); + + + } if (in_type[i] == PSE_PAD_TYPE_NEGCON) { // Query digital inputs @@ -2011,7 +2223,7 @@ void retro_run(void) // > NeGcon L in_analog_left[i][1] = get_analog_button(ret, input_state_cb, i, RETRO_DEVICE_ID_JOYPAD_L); } - else + if (in_type[i] != PSE_PAD_TYPE_NEGCON && in_type[i] != PSE_PAD_TYPE_GUNCON) { // Query digital inputs for (j = 0; j < RETRO_PSX_MAP_LEN; j++) @@ -2233,7 +2445,7 @@ void retro_init(void) #ifdef _3DS vout_buf = linearMemAlign(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2, 0x80); -#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && !defined(VITA) +#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && !defined(VITA) && !defined(__SWITCH__) posix_memalign(&vout_buf, 16, VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2); #else vout_buf = malloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2);