Skip to content

Commit

Permalink
try some overscan display option
Browse files Browse the repository at this point in the history
  • Loading branch information
notaz committed Jun 28, 2024
1 parent fde7a31 commit b27f55b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
12 changes: 12 additions & 0 deletions frontend/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions frontend/libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions frontend/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions frontend/plugin_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 10 additions & 3 deletions plugins/gpulib/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions plugins/gpulib/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b27f55b

Please sign in to comment.