Merge pull request #550 from tacoschip/overscan
add more overscan crop options
This commit is contained in:
@@ -88,10 +88,11 @@ static retro_audio_sample_batch_t audio_batch_cb = NULL;
|
|||||||
retro_environment_t environ_cb = NULL;
|
retro_environment_t environ_cb = NULL;
|
||||||
#ifdef PSP
|
#ifdef PSP
|
||||||
static bool crop_overscan;
|
static bool crop_overscan;
|
||||||
#else
|
|
||||||
static bool crop_overscan_h;
|
|
||||||
static bool crop_overscan_v;
|
|
||||||
#endif
|
#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 bool use_raw_palette;
|
||||||
static int aspect_ratio_par;
|
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)
|
void retro_get_system_av_info(struct retro_system_av_info *info)
|
||||||
{
|
{
|
||||||
#ifdef PSP
|
unsigned width = NES_WIDTH - crop_overscan_h_left - crop_overscan_h_right;
|
||||||
unsigned width = NES_WIDTH - (crop_overscan ? 16 : 0);
|
unsigned height = NES_HEIGHT - crop_overscan_v_top - crop_overscan_v_bottom;
|
||||||
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
|
|
||||||
#ifdef HAVE_NTSC_FILTER
|
#ifdef HAVE_NTSC_FILTER
|
||||||
info->geometry.base_width = (use_ntsc ? NES_NTSC_OUT_WIDTH(width) : width);
|
info->geometry.base_width = (use_ntsc ? NES_NTSC_OUT_WIDTH(width) : width);
|
||||||
info->geometry.max_width = (use_ntsc ? NES_NTSC_WIDTH : NES_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"));
|
bool newval = (!strcmp(var.value, "enabled"));
|
||||||
if (newval != crop_overscan)
|
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;
|
crop_overscan = newval;
|
||||||
audio_video_updated = 1;
|
audio_video_updated = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
var.key = "fceumm_overscan_h";
|
var.key = "fceumm_overscan_h_left";
|
||||||
|
|
||||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||||
{
|
{
|
||||||
bool newval = (!strcmp(var.value, "enabled"));
|
int newval = atoi(var.value);
|
||||||
if (newval != crop_overscan_h)
|
if (newval != crop_overscan_h_left)
|
||||||
{
|
{
|
||||||
crop_overscan_h = newval;
|
crop_overscan_h_left = newval;
|
||||||
audio_video_updated = 1;
|
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)
|
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||||
{
|
{
|
||||||
bool newval = (!strcmp(var.value, "enabled"));
|
int newval = atoi(var.value);
|
||||||
if (newval != crop_overscan_v)
|
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;
|
audio_video_updated = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2245,16 +2270,8 @@ static int mzx = 0, mzy = 0;
|
|||||||
|
|
||||||
void get_mouse_input(unsigned port, uint32_t *zapdata)
|
void get_mouse_input(unsigned port, uint32_t *zapdata)
|
||||||
{
|
{
|
||||||
bool adjx = false;
|
|
||||||
bool adjy = false;
|
|
||||||
int min_width, min_height, max_width, max_height;
|
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_width = 256;
|
||||||
max_height = 240;
|
max_height = 240;
|
||||||
zapdata[2] = 0; /* reset click state */
|
zapdata[2] = 0; /* reset click state */
|
||||||
@@ -2264,10 +2281,10 @@ void get_mouse_input(unsigned port, uint32_t *zapdata)
|
|||||||
int mouse_Lbutton;
|
int mouse_Lbutton;
|
||||||
int mouse_Rbutton;
|
int mouse_Rbutton;
|
||||||
|
|
||||||
min_width = (adjx ? 8 : 0) + 1;
|
min_width = crop_overscan_h_left + 1;
|
||||||
min_height = (adjy ? 8 : 0) + 1;
|
min_height = crop_overscan_v_top + 1;
|
||||||
max_width -= (adjx ? 8 : 0);
|
max_width -= crop_overscan_h_right;
|
||||||
max_height -= (adjy ? 8 : 0);
|
max_height -= crop_overscan_v_bottom;
|
||||||
|
|
||||||
/* TODO: Add some sort of mouse sensitivity */
|
/* TODO: Add some sort of mouse sensitivity */
|
||||||
mzx += input_cb(port, RETRO_DEVICE_MOUSE, 0, RETRO_DEVICE_ID_MOUSE_X);
|
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;
|
zapdata[2] |= 0x2;
|
||||||
}
|
}
|
||||||
else if (zappermode == RetroPointer) {
|
else if (zappermode == RetroPointer) {
|
||||||
int offset_x = (adjx ? 0X8FF : 0);
|
int offset_x = (crop_overscan_h_left * 0x120) - 1;
|
||||||
int offset_y = (adjy ? 0X999 : 0);
|
int offset_y = (crop_overscan_v_top * 0x133) + 1;
|
||||||
|
|
||||||
int _x = input_cb(port, RETRO_DEVICE_POINTER, 0, RETRO_DEVICE_ID_POINTER_X);
|
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);
|
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 */
|
else if (zappermode == RetroCLightgun) /* Crosshair lightgun device */
|
||||||
{
|
{
|
||||||
int offset_x = (adjx ? 0X8FF : 0);
|
int offset_x = (crop_overscan_h_left * 0x120) - 1;
|
||||||
int offset_y = (adjy ? 0X999 : 0);
|
int offset_y = (crop_overscan_v_top * 0x133) + 1;
|
||||||
int offscreen;
|
int offscreen;
|
||||||
int offscreen_shot;
|
int offscreen_shot;
|
||||||
int trigger;
|
int trigger;
|
||||||
@@ -2670,10 +2687,10 @@ static void retro_run_blit(uint8_t *gfx)
|
|||||||
ps2->coreTexture->PSM = GS_PSM_T8;
|
ps2->coreTexture->PSM = GS_PSM_T8;
|
||||||
ps2->coreTexture->ClutPSM = GS_PSM_CT16;
|
ps2->coreTexture->ClutPSM = GS_PSM_CT16;
|
||||||
ps2->coreTexture->Filter = GS_FILTER_LINEAR;
|
ps2->coreTexture->Filter = GS_FILTER_LINEAR;
|
||||||
ps2->padding = (struct retro_hw_ps2_insets){ crop_overscan_v ? 8.0f : 0.0f,
|
ps2->padding = (struct retro_hw_ps2_insets){ (float) crop_overscan_v_top,
|
||||||
crop_overscan_h ? 8.0f : 0.0f,
|
(float) crop_overscan_h_left,
|
||||||
crop_overscan_v ? 8.0f : 0.0f,
|
(float) crop_overscan_v_bottom,
|
||||||
crop_overscan_h ? 8.0f : 0.0f};
|
(float) crop_overscan_h_right };
|
||||||
}
|
}
|
||||||
|
|
||||||
ps2->coreTexture->Clut = (u32*)retro_palette;
|
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,
|
NES_WIDTH, burst_phase, NES_WIDTH, NES_HEIGHT,
|
||||||
ntsc_video_out, NES_NTSC_WIDTH * sizeof(uint16));
|
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);
|
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);
|
pitch = width * sizeof(uint16_t);
|
||||||
|
|
||||||
{
|
{
|
||||||
int32_t h_offset = crop_overscan_h ? NES_NTSC_OUT_WIDTH(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 ? 8 : 0;
|
int32_t v_offset = crop_overscan_v_top;
|
||||||
const uint16_t *in = ntsc_video_out + h_offset + NES_NTSC_WIDTH * v_offset;
|
const uint16_t *in = ntsc_video_out + h_offset + NES_NTSC_WIDTH * v_offset;
|
||||||
uint16_t *out = fceu_video_out;
|
uint16_t *out = fceu_video_out;
|
||||||
|
|
||||||
@@ -2715,11 +2732,11 @@ static void retro_run_blit(uint8_t *gfx)
|
|||||||
else
|
else
|
||||||
#endif /* HAVE_NTSC_FILTER */
|
#endif /* HAVE_NTSC_FILTER */
|
||||||
{
|
{
|
||||||
incr += (crop_overscan_h ? 16 : 0);
|
incr += (crop_overscan_h_left + crop_overscan_h_right);
|
||||||
width -= (crop_overscan_h ? 16 : 0);
|
width -= (crop_overscan_h_left + crop_overscan_h_right);
|
||||||
height -= (crop_overscan_v ? 16 : 0);
|
height -= (crop_overscan_v_top + crop_overscan_v_bottom);
|
||||||
pitch -= (crop_overscan_h ? 32 : 0);
|
pitch -= (crop_overscan_h_left + crop_overscan_h_right) * sizeof(uint16_t);
|
||||||
gfx += (crop_overscan_v ? ((crop_overscan_h ? 8 : 0) + 256 * 8) : (crop_overscan_h ? 8 : 0));
|
gfx += (crop_overscan_v_top * 256) + crop_overscan_h_left;
|
||||||
|
|
||||||
if (use_raw_palette)
|
if (use_raw_palette)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -161,32 +161,72 @@ struct retro_core_option_v2_definition option_defs[] = {
|
|||||||
},
|
},
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
"fceumm_overscan_h",
|
"fceumm_overscan_h_left",
|
||||||
"Crop Horizontal Overscan",
|
"Crop Horizontal Left Overscan",
|
||||||
NULL,
|
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,
|
NULL,
|
||||||
"video",
|
"video",
|
||||||
{
|
{
|
||||||
{ "disabled", NULL },
|
{ "0", NULL },
|
||||||
{ "enabled", NULL },
|
{ "4", NULL },
|
||||||
|
{ "8", NULL },
|
||||||
|
{ "12", NULL },
|
||||||
|
{ "16", NULL },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
},
|
},
|
||||||
"disabled",
|
"0",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fceumm_overscan_v",
|
"fceumm_overscan_h_right",
|
||||||
"Crop Vertical Overscan",
|
"Crop Horizontal Right Overscan",
|
||||||
NULL,
|
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,
|
NULL,
|
||||||
"video",
|
"video",
|
||||||
{
|
{
|
||||||
{ "disabled", NULL },
|
{ "0", NULL },
|
||||||
{ "enabled", NULL },
|
{ "4", NULL },
|
||||||
|
{ "8", NULL },
|
||||||
|
{ "12", NULL },
|
||||||
|
{ "16", NULL },
|
||||||
{ NULL, 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 */
|
#endif /* overscan options */
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user