Make it so you can select between the old and new crop behavior

This commit is contained in:
ds22x 2021-11-01 17:25:49 +01:00
parent e8609eb9b4
commit 36782b026c
12 changed files with 65 additions and 52 deletions

View File

@ -11,7 +11,7 @@ int line_render_mode;
int filter_mode; int filter_mode;
bool opaque_check; bool opaque_check;
bool semitrans_check; bool semitrans_check;
bool crop_overscan = false; int crop_overscan = 0;
int core_timing_fps_mode = FORCE_PROGRESSIVE_TIMING; int core_timing_fps_mode = FORCE_PROGRESSIVE_TIMING;
bool currently_interlaced = false; bool currently_interlaced = false;

View File

@ -23,7 +23,7 @@ extern int line_render_mode;
extern int filter_mode; extern int filter_mode;
extern bool opaque_check; extern bool opaque_check;
extern bool semitrans_check; extern bool semitrans_check;
extern bool crop_overscan; extern int crop_overscan;
enum core_timing_fps_modes enum core_timing_fps_modes
{ {

View File

@ -3811,17 +3811,18 @@ static void check_variables(bool startup)
var.key = BEETLE_OPT(crop_overscan); var.key = BEETLE_OPT(crop_overscan);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{ {
if (strcmp(var.value, "enabled") == 0) int old_crop_overscan = crop_overscan;
if (strcmp(var.value, "disabled") == 0)
crop_overscan = 0;
else if (strcmp(var.value, "static") == 0)
crop_overscan = 1;
else if (strcmp(var.value, "smart") == 0)
crop_overscan = 2;
if(crop_overscan != old_crop_overscan)
{ {
if (crop_overscan == false) has_new_geometry = true;
has_new_geometry = true; old_crop_overscan = crop_overscan;
crop_overscan = true;
}
else if (strcmp(var.value, "disabled") == 0)
{
if (crop_overscan == true)
has_new_geometry = true;
crop_overscan = false;
} }
} }

View File

@ -1108,15 +1108,16 @@ struct retro_core_option_v2_definition option_defs_us[] = {
BEETLE_OPT(crop_overscan), BEETLE_OPT(crop_overscan),
"Crop Overscan", "Crop Overscan",
NULL, NULL,
"By default, the renderers add padding (pillarboxes on either side of the image for NTSC, on all sides for PAL) to emulate the same black bars generated in analog video output by real PSX hardware. Enabling this option removes that padding.", "By default, the renderers add padding (pillarboxes on either side of the image for NTSC, on all sides for PAL) to emulate the same black bars generated in analog video output by real PSX hardware. Dynamic removes all padding, while Static only removes horizontal padding.",
NULL, NULL,
"video", "video",
{ {
{ "enabled", NULL }, { "disabled", NULL },
{ "disabled", NULL }, { "static", "Static" },
{ "smart", "Dynamic" },
{ NULL, NULL }, { NULL, NULL },
}, },
"enabled" "smart"
}, },
{ {
BEETLE_OPT(image_crop), BEETLE_OPT(image_crop),

View File

@ -520,8 +520,9 @@ struct retro_core_option_v2_definition option_defs_it[] = {
NULL, NULL,
NULL, NULL,
{ {
{ "disabled", NULL }, { "disabled", NULL },
{ "enabled", NULL }, { "static", "Static" },
{ "smart", "Dynamic" },
{ NULL, NULL }, { NULL, NULL },
}, },
NULL NULL

View File

@ -33,7 +33,7 @@
#include "gpu_sprite.cpp" #include "gpu_sprite.cpp"
#include "gpu_line.cpp" #include "gpu_line.cpp"
extern bool crop_overscan; extern int crop_overscan;
extern bool is_monkey_hero; extern bool is_monkey_hero;
/* /*
@ -1484,9 +1484,9 @@ int32_t GPU_Update(const int32_t sys_timestamp)
else else
{ {
const unsigned int FirstVisibleLine = const unsigned int FirstVisibleLine =
GPU.LineVisFirst + (crop_overscan ? GPU.VertStart : (GPU.HardwarePALType ? 20 : 16)); GPU.LineVisFirst + (crop_overscan == 2 ? GPU.VertStart : (GPU.HardwarePALType ? 20 : 16));
const unsigned int VisibleLineCount = const unsigned int VisibleLineCount =
(crop_overscan ? (GPU.VertEnd - GPU.VertStart) - ((GPU.HardwarePALType ? 287 : 239) - GPU.LineVisLast) - GPU.LineVisFirst : GPU.LineVisLast + 1 - GPU.LineVisFirst); //HardwarePALType ? 288 : 240; (crop_overscan == 2 ? (GPU.VertEnd - GPU.VertStart) - ((GPU.HardwarePALType ? 287 : 239) - GPU.LineVisLast) - GPU.LineVisFirst : GPU.LineVisLast + 1 - GPU.LineVisFirst); //HardwarePALType ? 288 : 240;
TIMER_SetHRetrace(false); TIMER_SetHRetrace(false);
@ -1685,7 +1685,7 @@ int32_t GPU_Update(const int32_t sys_timestamp)
// but this value should be lowered in the future if necessary. // but this value should be lowered in the future if necessary.
// Additionally cut off everything after GPU.HorizEnd that shouldn't be // Additionally cut off everything after GPU.HorizEnd that shouldn't be
// in the viewport (the hardware renderers already takes care of this). // in the viewport (the hardware renderers already takes care of this).
int32 dx_start = (crop_overscan && GPU.HorizStart < 938 ? 608 : GPU.HorizStart), dx_end = (crop_overscan && GPU.HorizStart < 938 ? GPU.HorizEnd - GPU.HorizStart + 608 : GPU.HorizEnd - (GPU.HorizStart < 938 ? 0 : 1)); int32 dx_start = (crop_overscan == 2 && GPU.HorizStart < 938 ? 608 : GPU.HorizStart), dx_end = (crop_overscan == 2 && GPU.HorizStart < 938 ? GPU.HorizEnd - GPU.HorizStart + 608 : GPU.HorizEnd - (GPU.HorizStart < 938 ? 0 : 1));
int32 dest_line = int32 dest_line =
((GPU.scanline - FirstVisibleLine) << GPU.espec->InterlaceOn) ((GPU.scanline - FirstVisibleLine) << GPU.espec->InterlaceOn)
+ GPU.espec->InterlaceField; + GPU.espec->InterlaceField;

View File

@ -798,7 +798,7 @@ Renderer::DisplayRect Renderer::compute_display_rect()
// 938 fixes Gunbird (1008) and Mobile Light Force (EU release of Gunbird), // 938 fixes Gunbird (1008) and Mobile Light Force (EU release of Gunbird),
// but this value should be lowerer in the future if necessary. // but this value should be lowerer in the future if necessary.
display_width = (2560/clock_div) - render_state.image_crop; display_width = (2560/clock_div) - render_state.image_crop;
if (render_state.horiz_start < 938) if ((render_state.horiz_start < 938) && (render_state.crop_overscan == 2))
left_offset = floor((render_state.offset_cycles / (double) clock_div) - (render_state.image_crop / 2)); left_offset = floor((render_state.offset_cycles / (double) clock_div) - (render_state.image_crop / 2));
else else
left_offset = floor(((render_state.horiz_start + render_state.offset_cycles - 608) / (double) clock_div) - (render_state.image_crop / 2)); left_offset = floor(((render_state.horiz_start + render_state.offset_cycles - 608) / (double) clock_div) - (render_state.image_crop / 2));
@ -811,7 +811,7 @@ Renderer::DisplayRect Renderer::compute_display_rect()
unsigned display_height; unsigned display_height;
int upper_offset; int upper_offset;
if (render_state.crop_overscan) if (render_state.crop_overscan == 2)
{ {
if (render_state.is_pal) if (render_state.is_pal)
{ {

View File

@ -117,7 +117,7 @@ public:
bool is_pal = false; bool is_pal = false;
bool is_480i = false; bool is_480i = false;
WidthMode width_mode = WidthMode::WIDTH_MODE_320; WidthMode width_mode = WidthMode::WIDTH_MODE_320;
bool crop_overscan = false; int crop_overscan = 0;
unsigned image_crop = 0; unsigned image_crop = 0;
// Experimental horizontal offset feature // Experimental horizontal offset feature
@ -238,7 +238,7 @@ public:
render_state.width_mode = width_mode; render_state.width_mode = width_mode;
} }
void set_horizontal_overscan_cropping(bool crop_overscan) void set_horizontal_overscan_cropping(int crop_overscan)
{ {
render_state.crop_overscan = crop_overscan; render_state.crop_overscan = crop_overscan;
} }

View File

@ -874,13 +874,13 @@ double rsx_common_get_timing_fps(void)
} }
float rsx_common_get_aspect_ratio(bool pal_content, bool crop_overscan, float rsx_common_get_aspect_ratio(bool pal_content, int crop_overscan,
int first_visible_scanline, int last_visible_scanline, int first_visible_scanline, int last_visible_scanline,
int aspect_ratio_setting, bool vram_override, bool widescreen_override, int aspect_ratio_setting, bool vram_override, bool widescreen_override,
int widescreen_hack_aspect_ratio_setting) int widescreen_hack_aspect_ratio_setting)
{ {
// Current assumptions // Current assumptions
// A fixed percentage of width is cropped when crop_overscan is true // A fixed percentage of width is cropped when crop_overscan isn't 0
// aspect_ratio_setting is one of the following: // aspect_ratio_setting is one of the following:
// 0 - Corrected // 0 - Corrected
// 1 - Uncorrected (1:1 PAR) // 1 - Uncorrected (1:1 PAR)

View File

@ -171,7 +171,7 @@ bool rsx_intf_has_software_renderer(void);
double rsx_common_get_timing_fps(void); double rsx_common_get_timing_fps(void);
float rsx_common_get_aspect_ratio(bool pal_content, bool crop_overscan, float rsx_common_get_aspect_ratio(bool pal_content, int crop_overscan,
int first_visible_scanline, int last_visible_scanline, int first_visible_scanline, int last_visible_scanline,
int aspect_ratio_setting, bool vram_override, bool widescreen_override, int aspect_ratio_setting, bool vram_override, bool widescreen_override,
int widescreen_hack_aspect_ratio_setting); int widescreen_hack_aspect_ratio_setting);

View File

@ -319,8 +319,8 @@ struct GlRenderer {
/* Display Mode - GP1(08h) */ /* Display Mode - GP1(08h) */
enum width_modes curr_width_mode; enum width_modes curr_width_mode;
/* When true we perform no horizontal padding */ /* When set we perform no horizontal padding */
bool crop_overscan; int crop_overscan;
/* Experimental offset feature */ /* Experimental offset feature */
int32_t image_offset_cycles; int32_t image_offset_cycles;
@ -1229,13 +1229,15 @@ static bool GlRenderer_new(GlRenderer *renderer, DrawConfig config)
get_variables(&upscaling, &display_vram); get_variables(&upscaling, &display_vram);
var.key = BEETLE_OPT(crop_overscan); var.key = BEETLE_OPT(crop_overscan);
bool crop_overscan = true; int crop_overscan = true;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{ {
if (!strcmp(var.value, "enabled")) if (strcmp(var.value, "disabled") == 0)
crop_overscan = true; crop_overscan = 0;
else if (!strcmp(var.value, "disabled")) else if (strcmp(var.value, "static") == 0)
crop_overscan = false; crop_overscan = 1;
else if (strcmp(var.value, "smart") == 0)
crop_overscan = 2;
} }
int32_t image_offset_cycles = 0; int32_t image_offset_cycles = 0;
@ -1590,7 +1592,7 @@ static GlDisplayRect compute_gl_display_rect(GlRenderer *renderer)
/* Restore old center behaviour is render_state.horiz_start is intentionally very high. /* Restore old center behaviour is render_state.horiz_start is intentionally very high.
* 938 fixes Gunbird (1008) and Mobile Light Force (EU release of Gunbird), * 938 fixes Gunbird (1008) and Mobile Light Force (EU release of Gunbird),
* but this value should be lowerer in the future if necessary. */ * but this value should be lowerer in the future if necessary. */
if (renderer->config.display_area_hrange[0] < 938) if ((renderer->config.display_area_hrange[0] < 938) && (renderer->crop_overscan == 2))
x = floor((offset_cycles / (double) clock_div) - (renderer->image_crop / 2)); x = floor((offset_cycles / (double) clock_div) - (renderer->image_crop / 2));
else else
x = floor(((h_start - 608 + offset_cycles) / (double) clock_div) - (renderer->image_crop / 2)); x = floor(((h_start - 608 + offset_cycles) / (double) clock_div) - (renderer->image_crop / 2));
@ -1605,7 +1607,7 @@ static GlDisplayRect compute_gl_display_rect(GlRenderer *renderer)
uint32_t height; uint32_t height;
int32_t y; int32_t y;
if (renderer->crop_overscan) if (renderer->crop_overscan == 2)
{ {
if (renderer->config.is_pal) if (renderer->config.is_pal)
{ {
@ -1743,13 +1745,15 @@ static bool retro_refresh_variables(GlRenderer *renderer)
get_variables(&upscaling, &display_vram); get_variables(&upscaling, &display_vram);
var.key = BEETLE_OPT(crop_overscan); var.key = BEETLE_OPT(crop_overscan);
bool crop_overscan = true; int crop_overscan = 1;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{ {
if (!strcmp(var.value, "enabled")) if (strcmp(var.value, "disabled") == 0)
crop_overscan = true; crop_overscan = 0;
else if (!strcmp(var.value, "disabled")) else if (strcmp(var.value, "static") == 0)
crop_overscan = false; crop_overscan = 1;
else if (strcmp(var.value, "smart") == 0)
crop_overscan = 2;
} }
int32_t image_offset_cycles; int32_t image_offset_cycles;
@ -2268,7 +2272,7 @@ static struct retro_system_av_info get_av_info(VideoClock std)
bool widescreen_hack = false; bool widescreen_hack = false;
int widescreen_hack_aspect_ratio_setting = 1; int widescreen_hack_aspect_ratio_setting = 1;
bool display_vram = false; bool display_vram = false;
bool crop_overscan = false; int crop_overscan = 0;
int initial_scanline_ntsc = 0; int initial_scanline_ntsc = 0;
int last_scanline_ntsc = 239; int last_scanline_ntsc = 239;
int initial_scanline_pal = 0; int initial_scanline_pal = 0;
@ -2310,8 +2314,12 @@ static struct retro_system_av_info get_av_info(VideoClock std)
var.key = BEETLE_OPT(crop_overscan); var.key = BEETLE_OPT(crop_overscan);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{ {
if (!strcmp(var.value, "enabled")) if (strcmp(var.value, "disabled") == 0)
crop_overscan = true; crop_overscan = 0;
else if (strcmp(var.value, "static") == 0)
crop_overscan = 1;
else if (strcmp(var.value, "smart") == 0)
crop_overscan = 2;
} }
var.key = BEETLE_OPT(initial_scanline); var.key = BEETLE_OPT(initial_scanline);

View File

@ -59,7 +59,7 @@ static dither_mode dither_mode = DITHER_NATIVE;
static bool dump_textures = false; static bool dump_textures = false;
static bool replace_textures = false; static bool replace_textures = false;
static bool track_textures = false; static bool track_textures = false;
static bool crop_overscan; static int crop_overscan;
static int image_offset_cycles; static int image_offset_cycles;
static unsigned image_crop; static unsigned image_crop;
static int initial_scanline; static int initial_scanline;
@ -249,7 +249,7 @@ void rsx_vulkan_refresh_variables(void)
unsigned old_msaa = msaa; unsigned old_msaa = msaa;
bool old_super_sampling = super_sampling; bool old_super_sampling = super_sampling;
bool old_show_vram = show_vram; bool old_show_vram = show_vram;
bool old_crop_overscan = crop_overscan; int old_crop_overscan = crop_overscan;
unsigned old_image_crop = image_crop; unsigned old_image_crop = image_crop;
bool old_widescreen_hack = widescreen_hack; bool old_widescreen_hack = widescreen_hack;
unsigned old_widescreen_hack_aspect_ratio_setting = widescreen_hack_aspect_ratio_setting; unsigned old_widescreen_hack_aspect_ratio_setting = widescreen_hack_aspect_ratio_setting;
@ -344,10 +344,12 @@ void rsx_vulkan_refresh_variables(void)
var.key = BEETLE_OPT(crop_overscan); var.key = BEETLE_OPT(crop_overscan);
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{ {
if (!strcmp(var.value, "enabled")) if (strcmp(var.value, "disabled") == 0)
crop_overscan = true; crop_overscan = 0;
else else if (strcmp(var.value, "static") == 0)
crop_overscan = false; crop_overscan = 1;
else if (strcmp(var.value, "smart") == 0)
crop_overscan = 2;
} }
var.key = BEETLE_OPT(image_offset_cycles); var.key = BEETLE_OPT(image_offset_cycles);