From 8f8ade9c6a3da1dd6d254789d50df6b8c2997850 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 24 Oct 2023 21:42:04 +0300 Subject: [PATCH] gpulib: add a "borderless" option to restore old behavior --- frontend/libretro.c | 4 +++- frontend/libretro_core_options.h | 3 ++- frontend/menu.c | 2 +- frontend/plugin_lib.h | 4 +++- plugins/gpulib/gpu.c | 16 ++++++++++------ plugins/gpulib/vout_pl.c | 6 ++++-- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index d74a7b41..5a44e43e 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2293,8 +2293,10 @@ static void update_variables(bool in_flight) { if (strcmp(var.value, "game") == 0) pl_rearmed_cbs.screen_centering_type = 1; - else if (strcmp(var.value, "manual") == 0) + else if (strcmp(var.value, "borderless") == 0) pl_rearmed_cbs.screen_centering_type = 2; + else if (strcmp(var.value, "manual") == 0) + pl_rearmed_cbs.screen_centering_type = 3; else // auto pl_rearmed_cbs.screen_centering_type = 0; } diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index 7758bc10..47835fda 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -439,12 +439,13 @@ struct retro_core_option_v2_definition option_defs_us[] = { "pcsx_rearmed_screen_centering", "(GPU) Screen centering", NULL, - "The PSX has a feature allowing it to shift the image position on screen. Some (mostly PAL) games used this feature in a strange way making the image miscentered and causing borders to appear. With 'Auto' the emulator tries to correct this miscentering automatically. 'Game-controlled' uses the settings supplied by the game. 'Manual' allows to override those values with the settings below.", + "The PSX has a feature allowing it to shift the image position on screen. Some (mostly PAL) games used this feature in a strange way making the image miscentered and causing uneven borders to appear. With 'Auto' the emulator tries to correct this miscentering automatically. 'Game-controlled' uses the settings supplied by the game. 'Manual' allows to override those values with the settings below.", NULL, "video", { { "auto", "Auto" }, { "game", "Game-controlled" }, + { "borderless", "Borderless" }, { "manual", "Manual" }, { NULL, NULL }, }, diff --git a/frontend/menu.c b/frontend/menu.c index 4c72787c..c3acb2d6 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -1266,7 +1266,7 @@ static const char *men_soft_filter[] = { "None", #endif NULL }; static const char *men_dummy[] = { NULL }; -static const char *men_centering[] = { "Auto", "Ingame", "Force", NULL }; +static const char *men_centering[] = { "Auto", "Ingame", "Borderless", "Force", NULL }; static const char h_scaler[] = "int. 2x - scales w. or h. 2x if it fits on screen\n" "int. 4:3 - uses integer if possible, else fractional"; static const char h_cscaler[] = "Displays the scaler layer, you can resize it\n" diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index b5d31143..bafcb6c8 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -114,13 +114,15 @@ struct rearmed_cbs { } gpu_peopsgl; // misc int gpu_caps; - int screen_centering_type; // 0 - auto, 1 - game conrolled, 2 - manual + int screen_centering_type; int screen_centering_x; int screen_centering_y; }; extern struct rearmed_cbs pl_rearmed_cbs; +enum centering_type { C_AUTO = 0, C_INGAME, C_BORDERLESS, C_MANUAL }; + enum gpu_plugin_caps { GPU_CAP_OWNS_DISPLAY = (1 << 0), GPU_CAP_SUPPORTS_2X = (1 << 1), diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index dfd4366b..22571fa2 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -15,8 +15,11 @@ #include "gpu.h" #include "../../libpcsxcore/gpu.h" // meh +#include "../../frontend/plugin_lib.h" +#ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif #ifdef __GNUC__ #define unlikely(x) __builtin_expect((x), 0) #define preload __builtin_prefetch @@ -85,9 +88,9 @@ static noinline void update_width(void) sw /= hdiv; sw = (sw + 2) & ~3; // according to nocash switch (gpu.state.screen_centering_type) { - case 1: + case C_INGAME: break; - case 2: + case C_MANUAL: x = gpu.state.screen_centering_x; break; default: @@ -129,9 +132,12 @@ static noinline void update_height(void) /* nothing displayed? */; else { switch (gpu.state.screen_centering_type) { - case 1: + case C_INGAME: + break; + case C_BORDERLESS: + y = 0; break; - case 2: + case C_MANUAL: y = gpu.state.screen_centering_y; break; default: @@ -950,8 +956,6 @@ void GPUgetScreenInfo(int *y, int *base_hres) *base_hres >>= 1; } -#include "../../frontend/plugin_lib.h" - void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) { gpu.frameskip.set = cbs->frameskip; diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 30245b88..e8f959f6 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -29,9 +29,11 @@ static void check_mode_change(int force) { int w = gpu.screen.hres; int h = gpu.screen.vres; - int w_out = w; - int h_out = h; + int w_out, h_out; + if (gpu.state.screen_centering_type == C_BORDERLESS) + h = gpu.screen.h; + w_out = w, h_out = h; #ifdef RAW_FB_DISPLAY w = w_out = 1024, h = h_out = 512; #endif -- 2.39.5