Merge pull request #550 from tacoschip/overscan

add more overscan crop options
This commit is contained in:
LibretroAdmin
2023-03-11 09:04:44 +01:00
committed by GitHub
2 changed files with 116 additions and 59 deletions

View File

@@ -88,10 +88,11 @@ static retro_audio_sample_batch_t audio_batch_cb = NULL;
retro_environment_t environ_cb = NULL;
#ifdef PSP
static bool crop_overscan;
#else
static bool crop_overscan_h;
static bool crop_overscan_v;
#endif
static int crop_overscan_h_left;
static int crop_overscan_h_right;
static int crop_overscan_v_top;
static int crop_overscan_v_bottom;
static bool use_raw_palette;
static int aspect_ratio_par;
@@ -1637,13 +1638,8 @@ static float get_aspect_ratio(unsigned width, unsigned height)
void retro_get_system_av_info(struct retro_system_av_info *info)
{
#ifdef PSP
unsigned width = NES_WIDTH - (crop_overscan ? 16 : 0);
unsigned height = NES_HEIGHT - (crop_overscan ? 16 : 0);
#else
unsigned width = NES_WIDTH - (crop_overscan_h ? 16 : 0);
unsigned height = NES_HEIGHT - (crop_overscan_v ? 16 : 0);
#endif
unsigned width = NES_WIDTH - crop_overscan_h_left - crop_overscan_h_right;
unsigned height = NES_HEIGHT - crop_overscan_v_top - crop_overscan_v_bottom;
#ifdef HAVE_NTSC_FILTER
info->geometry.base_width = (use_ntsc ? NES_NTSC_OUT_WIDTH(width) : width);
info->geometry.max_width = (use_ntsc ? NES_NTSC_WIDTH : NES_WIDTH);
@@ -2034,31 +2030,60 @@ static void check_variables(bool startup)
bool newval = (!strcmp(var.value, "enabled"));
if (newval != crop_overscan)
{
crop_overscan_h_left = (newval == true ? 8 : 0);
crop_overscan_h_right = (newval == true ? 8 : 0);
crop_overscan_v_top = (newval == true ? 8 : 0);
crop_overscan_v_bottom = (newval == true ? 8 : 0);
crop_overscan = newval;
audio_video_updated = 1;
}
}
#else
var.key = "fceumm_overscan_h";
var.key = "fceumm_overscan_h_left";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
bool newval = (!strcmp(var.value, "enabled"));
if (newval != crop_overscan_h)
int newval = atoi(var.value);
if (newval != crop_overscan_h_left)
{
crop_overscan_h = newval;
crop_overscan_h_left = newval;
audio_video_updated = 1;
}
}
var.key = "fceumm_overscan_v";
var.key = "fceumm_overscan_h_right";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
bool newval = (!strcmp(var.value, "enabled"));
if (newval != crop_overscan_v)
int newval = atoi(var.value);
if (newval != crop_overscan_h_right)
{
crop_overscan_v = newval;
crop_overscan_h_right = newval;
audio_video_updated = 1;
}
}
var.key = "fceumm_overscan_v_top";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int newval = atoi(var.value);
if (newval != crop_overscan_v_top)
{
crop_overscan_v_top = newval;
audio_video_updated = 1;
}
}
var.key = "fceumm_overscan_v_bottom";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int newval = atoi(var.value);
if (newval != crop_overscan_v_bottom)
{
crop_overscan_v_bottom = newval;
audio_video_updated = 1;
}
}
@@ -2245,16 +2270,8 @@ static int mzx = 0, mzy = 0;
void get_mouse_input(unsigned port, uint32_t *zapdata)
{
bool adjx = false;
bool adjy = false;
int min_width, min_height, max_width, max_height;
#ifdef PSP
adjx = adjy = crop_overscan ? 1 : 0;
#else
adjx = crop_overscan_h ? 1 : 0;
adjy = crop_overscan_v ? 1 : 0;
#endif
max_width = 256;
max_height = 240;
zapdata[2] = 0; /* reset click state */
@@ -2264,10 +2281,10 @@ void get_mouse_input(unsigned port, uint32_t *zapdata)
int mouse_Lbutton;
int mouse_Rbutton;
min_width = (adjx ? 8 : 0) + 1;
min_height = (adjy ? 8 : 0) + 1;
max_width -= (adjx ? 8 : 0);
max_height -= (adjy ? 8 : 0);
min_width = crop_overscan_h_left + 1;
min_height = crop_overscan_v_top + 1;
max_width -= crop_overscan_h_right;
max_height -= crop_overscan_v_bottom;
/* TODO: Add some sort of mouse sensitivity */
mzx += input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
@@ -2292,8 +2309,8 @@ void get_mouse_input(unsigned port, uint32_t *zapdata)
zapdata[2] |= 0x2;
}
else if (zappermode == RetroPointer) {
int offset_x = (adjx ? 0X8FF : 0);
int offset_y = (adjy ? 0X999 : 0);
int offset_x = (crop_overscan_h_left * 0x120) - 1;
int offset_y = (crop_overscan_v_top * 0x133) + 1;
int _x = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
int _y = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_Y);
@@ -2314,8 +2331,8 @@ void get_mouse_input(unsigned port, uint32_t *zapdata)
}
else if (zappermode == RetroCLightgun) /* Crosshair lightgun device */
{
int offset_x = (adjx ? 0X8FF : 0);
int offset_y = (adjy ? 0X999 : 0);
int offset_x = (crop_overscan_h_left * 0x120) - 1;
int offset_y = (crop_overscan_v_top * 0x133) + 1;
int offscreen;
int offscreen_shot;
int trigger;
@@ -2670,10 +2687,10 @@ static void retro_run_blit(uint8_t *gfx)
ps2->coreTexture->PSM = GS_PSM_T8;
ps2->coreTexture->ClutPSM = GS_PSM_CT16;
ps2->coreTexture->Filter = GS_FILTER_LINEAR;
ps2->padding = (struct retro_hw_ps2_insets){ crop_overscan_v ? 8.0f : 0.0f,
crop_overscan_h ? 8.0f : 0.0f,
crop_overscan_v ? 8.0f : 0.0f,
crop_overscan_h ? 8.0f : 0.0f};
ps2->padding = (struct retro_hw_ps2_insets){ (float) crop_overscan_v_top,
(float) crop_overscan_h_left,
(float) crop_overscan_v_bottom,
(float) crop_overscan_h_right };
}
ps2->coreTexture->Clut = (u32*)retro_palette;
@@ -2692,14 +2709,14 @@ static void retro_run_blit(uint8_t *gfx)
NES_WIDTH, burst_phase, NES_WIDTH, NES_HEIGHT,
ntsc_video_out, NES_NTSC_WIDTH * sizeof(uint16));
width = NES_WIDTH - (crop_overscan_h ? 16 : 0);
width = NES_WIDTH - crop_overscan_h_left - crop_overscan_h_right;
width = NES_NTSC_OUT_WIDTH(width);
height = NES_HEIGHT - (crop_overscan_v ? 16 : 0);
height = NES_HEIGHT - crop_overscan_v_top - crop_overscan_v_bottom;
pitch = width * sizeof(uint16_t);
{
int32_t h_offset = crop_overscan_h ? NES_NTSC_OUT_WIDTH(8) : 0;
int32_t v_offset = crop_overscan_v ? 8 : 0;
int32_t h_offset = (crop_overscan_h_left ? NES_NTSC_OUT_WIDTH(crop_overscan_h_left) : 0);
int32_t v_offset = crop_overscan_v_top;
const uint16_t *in = ntsc_video_out + h_offset + NES_NTSC_WIDTH * v_offset;
uint16_t *out = fceu_video_out;
@@ -2715,11 +2732,11 @@ static void retro_run_blit(uint8_t *gfx)
else
#endif /* HAVE_NTSC_FILTER */
{
incr += (crop_overscan_h ? 16 : 0);
width -= (crop_overscan_h ? 16 : 0);
height -= (crop_overscan_v ? 16 : 0);
pitch -= (crop_overscan_h ? 32 : 0);
gfx += (crop_overscan_v ? ((crop_overscan_h ? 8 : 0) + 256 * 8) : (crop_overscan_h ? 8 : 0));
incr += (crop_overscan_h_left + crop_overscan_h_right);
width -= (crop_overscan_h_left + crop_overscan_h_right);
height -= (crop_overscan_v_top + crop_overscan_v_bottom);
pitch -= (crop_overscan_h_left + crop_overscan_h_right) * sizeof(uint16_t);
gfx += (crop_overscan_v_top * 256) + crop_overscan_h_left;
if (use_raw_palette)
{

View File

@@ -161,32 +161,72 @@ struct retro_core_option_v2_definition option_defs[] = {
},
#else
{
"fceumm_overscan_h",
"Crop Horizontal Overscan",
"fceumm_overscan_h_left",
"Crop Horizontal Left Overscan",
NULL,
"Removes 8 pixels from left and right sides of the screen to simulate overscan seen on standard CRT televisions.",
"Removes pixels from left side of the screen to simulate overscan seen on standard CRT televisions.",
NULL,
"video",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ "0", NULL },
{ "4", NULL },
{ "8", NULL },
{ "12", NULL },
{ "16", NULL },
{ NULL, NULL },
},
"disabled",
"0",
},
{
"fceumm_overscan_v",
"Crop Vertical Overscan",
"fceumm_overscan_h_right",
"Crop Horizontal Right Overscan",
NULL,
"Removes 8 pixels from the top and bottom of the screen to simulate overscan seen on standard CRT televisions.",
"Removes pixels from right side of the screen to simulate overscan seen on standard CRT televisions.",
NULL,
"video",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ "0", NULL },
{ "4", NULL },
{ "8", NULL },
{ "12", NULL },
{ "16", NULL },
{ NULL, NULL },
},
"enabled",
"0",
},
{
"fceumm_overscan_v_top",
"Crop Vertical Top Overscan",
NULL,
"Removes pixels from the top of the screen to simulate overscan seen on standard CRT televisions.",
NULL,
"video",
{
{ "0", NULL },
{ "4", NULL },
{ "8", NULL },
{ "12", NULL },
{ "16", NULL },
{ NULL, NULL },
},
"8",
},
{
"fceumm_overscan_v_bottom",
"Crop Vertical Bottom Overscan",
NULL,
"Removes pixels from the bottom of the screen to simulate overscan seen on standard CRT televisions.",
NULL,
"video",
{
{ "0", NULL },
{ "4", NULL },
{ "8", NULL },
{ "12", NULL },
{ "16", NULL },
{ NULL, NULL },
},
"8",
},
#endif /* overscan options */
{