gpulib: add height adjustment option
authornotaz <notasas@gmail.com>
Fri, 21 Feb 2025 22:01:59 +0000 (00:01 +0200)
committernotaz <notasas@gmail.com>
Fri, 21 Feb 2025 22:03:11 +0000 (00:03 +0200)
libretro/pcsx_rearmed#880

frontend/libretro.c
frontend/libretro_core_options.h
frontend/menu.c
frontend/plugin_lib.h
plugins/gpulib/gpu.c
plugins/gpulib/gpu.h

index e069420..9d1824a 100644 (file)
@@ -2526,6 +2526,13 @@ static void update_variables(bool in_flight)
       pl_rearmed_cbs.screen_centering_y = atoi(var.value);
    }
 
+   var.value = NULL;
+   var.key = "pcsx_rearmed_screen_centering_h_adj";
+   if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
+   {
+      pl_rearmed_cbs.screen_centering_h_adj = atoi(var.value);
+   }
+
    var.value = NULL;
    var.key = "pcsx_rearmed_show_overscan";
    if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
index 0d9379d..8c45758 100644 (file)
@@ -521,6 +521,19 @@ struct retro_core_option_v2_definition option_defs_us[] = {
       },
       "0",
    },
+   {
+      "pcsx_rearmed_screen_centering_h_adj",
+      "(GPU) Manual height adjustment",
+      NULL,
+      "Height adjustment. Only effective when 'Screen centering' is set to 'Manual'.",
+      NULL,
+      "video",
+      {
+         V(-64), V(-48), V(-40), V(-32), V(-24), V(-16), V(-8), V(-7), V(-6), V(-5), V(-4), V(-3), V(-2), V(-1), V(0),
+         { NULL, NULL },
+      },
+      "0",
+   },
 #undef V
 #ifdef GPU_NEON
    {
index ec803ab..ecd6918 100644 (file)
@@ -467,6 +467,7 @@ static const struct {
        CE_INTVAL_P(screen_centering_type),
        CE_INTVAL_P(screen_centering_x),
        CE_INTVAL_P(screen_centering_y),
+       CE_INTVAL_P(screen_centering_h_adj),
        CE_INTVAL_P(show_overscan),
        CE_INTVAL(spu_config.iUseReverb),
        CE_INTVAL(spu_config.iXAPitch),
index 31acae9..ef63cc2 100644 (file)
@@ -112,6 +112,7 @@ struct rearmed_cbs {
        int screen_centering_type_default;
        int screen_centering_x;
        int screen_centering_y;
+       int screen_centering_h_adj;
        int show_overscan;
 };
 
index 83ec764..8c1b8e8 100644 (file)
@@ -141,6 +141,7 @@ static noinline void update_height(struct psx_gpu *gpu)
       break;
     case C_MANUAL:
       y = gpu->state.screen_centering_y;
+      vres += gpu->state.screen_centering_h_adj;
       break;
     default:
       // correct if slightly miscentered
@@ -1026,10 +1027,12 @@ void GPUrearmedCallbacks(const struct rearmed_cbs *cbs)
   if (gpu.state.screen_centering_type != cbs->screen_centering_type
       || gpu.state.screen_centering_x != cbs->screen_centering_x
       || gpu.state.screen_centering_y != cbs->screen_centering_y
+      || gpu.state.screen_centering_h_adj != cbs->screen_centering_h_adj
       || gpu.state.show_overscan != cbs->show_overscan) {
     gpu.state.screen_centering_type = cbs->screen_centering_type;
     gpu.state.screen_centering_x = cbs->screen_centering_x;
     gpu.state.screen_centering_y = cbs->screen_centering_y;
+    gpu.state.screen_centering_h_adj = cbs->screen_centering_h_adj;
     gpu.state.show_overscan = cbs->show_overscan;
     update_width(&gpu);
     update_height(&gpu);
index eb55922..574100b 100644 (file)
@@ -94,8 +94,9 @@ struct psx_gpu {
     uint32_t w_out_old, h_out_old, status_vo_old;
     short screen_centering_type;
     short screen_centering_type_default;
-    int screen_centering_x;
-    int screen_centering_y;
+    short screen_centering_x;
+    short screen_centering_y;
+    int screen_centering_h_adj;
   } state;
   struct {
     int32_t set:3; /* -1 auto, 0 off, 1-3 fixed */