From b27f55bea733c150ca50360b2eb807304253d1fc Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 29 Jun 2024 01:08:41 +0300 Subject: [PATCH] try some overscan display option --- frontend/libretro.c | 12 ++++++++++++ frontend/libretro_core_options.h | 15 +++++++++++++++ frontend/menu.c | 4 ++++ frontend/plugin_lib.h | 1 + plugins/gpulib/gpu.c | 13 ++++++++++--- plugins/gpulib/gpu.h | 1 + 6 files changed, 43 insertions(+), 3 deletions(-) diff --git a/frontend/libretro.c b/frontend/libretro.c index cd6924c1..8cbae419 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2759,6 +2759,18 @@ static void update_variables(bool in_flight) pl_rearmed_cbs.screen_centering_y = atoi(var.value); } + var.value = NULL; + var.key = "pcsx_rearmed_show_overscan"; + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "auto") == 0) + pl_rearmed_cbs.show_overscan = 1; + else if (strcmp(var.value, "hack") == 0) + pl_rearmed_cbs.show_overscan = 2; + else + pl_rearmed_cbs.show_overscan = 0; + } + #ifdef THREAD_RENDERING var.key = "pcsx_rearmed_gpu_thread_rendering"; var.value = NULL; diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index 762bf276..e4995277 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -453,6 +453,21 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "auto", }, + { + "pcsx_rearmed_show_overscan", + "(GPU) Show horizontal overscan", + NULL, + "The PSX can display graphics way into the horizontal borders, even if most screens would crop it. This option tries to display all such graphics. Note that this may result in unusual resolutions that your device might not handle well. The 'Hack' option is intended for the widescreen hacks.", + NULL, + "video", + { + { "disabled", NULL }, + { "auto", "Auto" }, + { "hack", "Hack" }, + { NULL, NULL }, + }, + "disabled", + }, { "pcsx_rearmed_screen_centering", "(GPU) Screen centering", diff --git a/frontend/menu.c b/frontend/menu.c index eb3237e3..9b9af7c8 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -93,6 +93,7 @@ typedef enum MA_OPT_SCANLINES, MA_OPT_SCANLINE_LEVEL, MA_OPT_CENTERING, + MA_OPT_OVERSCAN, } menu_id; static int last_vout_w, last_vout_h, last_vout_bpp; @@ -467,6 +468,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(show_overscan), CE_INTVAL(spu_config.iUseReverb), CE_INTVAL(spu_config.iXAPitch), CE_INTVAL(spu_config.iUseInterpolation), @@ -1280,6 +1282,7 @@ static const char *men_soft_filter[] = { "None", NULL }; static const char *men_dummy[] = { NULL }; static const char *men_centering[] = { "Auto", "Ingame", "Borderless", "Force", NULL }; +static const char *men_overscan[] = { "OFF", "Auto", "Hack", 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" @@ -1376,6 +1379,7 @@ static int menu_loop_cscaler(int id, int keys) static menu_entry e_menu_gfx_options[] = { mee_enum ("Screen centering", MA_OPT_CENTERING, pl_rearmed_cbs.screen_centering_type, men_centering), + mee_enum ("Show overscan", MA_OPT_OVERSCAN, pl_rearmed_cbs.show_overscan, men_overscan), mee_enum_h ("Scaler", MA_OPT_VARSCALER, g_scaler, men_scaler, h_scaler), mee_enum ("Video output mode", MA_OPT_VOUT_MODE, plat_target.vout_method, men_dummy), mee_onoff ("Software Scaling", MA_OPT_SCALER2, soft_scaling, 1), diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index 5733ca24..c7ca247e 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -119,6 +119,7 @@ struct rearmed_cbs { int screen_centering_type_default; int screen_centering_x; int screen_centering_y; + int show_overscan; }; extern struct rearmed_cbs pl_rearmed_cbs; diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index 306c9d2f..dd7d5f32 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -92,6 +92,11 @@ static noinline void update_width(void) x = (x + 1) & ~1; // blitter limitation sw /= hdiv; sw = (sw + 2) & ~3; // according to nocash + + if (gpu.state.show_overscan == 2) // widescreen hack + sw = (sw + 63) & ~63; + if (gpu.state.show_overscan && sw >= hres) + x = 0, hres = sw; switch (type) { case C_INGAME: break; @@ -116,8 +121,8 @@ static noinline void update_width(void) gpu.screen.w = sw; gpu.screen.hres = hres; gpu.state.dims_changed = 1; - //printf("xx %d %d -> %2d, %d / %d\n", - // gpu.screen.x1, gpu.screen.x2, x, sw, hres); + //printf("xx %d %d (%d) -> %2d, %d / %d\n", gpu.screen.x1, + // gpu.screen.x2, gpu.screen.x2 - gpu.screen.x1, x, sw, hres); } static noinline void update_height(void) @@ -979,10 +984,12 @@ void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) gpu.state.screen_centering_type_default = cbs->screen_centering_type_default; 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_y != cbs->screen_centering_y + || 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.show_overscan = cbs->show_overscan; update_width(); update_height(); } diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index 7625c412..bf420b9c 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -81,6 +81,7 @@ struct psx_gpu { uint32_t downscale_enable:1; uint32_t downscale_active:1; uint32_t dims_changed:1; + uint32_t show_overscan:2; uint32_t *frame_count; uint32_t *hcnt; /* hsync count */ struct { -- 2.39.5