Skip to content

Commit

Permalink
gpulib: add a "borderless" option to restore old behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
notaz committed Oct 24, 2023
1 parent af16a7a commit 8f8ade9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
4 changes: 3 additions & 1 deletion frontend/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion frontend/plugin_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
16 changes: 10 additions & 6 deletions plugins/gpulib/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions plugins/gpulib/vout_pl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f8ade9

Please sign in to comment.