[Libretro] Rework "Hide Master System Left Border" option

Reworked the option so that now you can hide either 8 pixels on both left and right sides of the screen, or the 8 pixels on the left side only.
Also added a check that makes sure it doesn't cut whenever VDP register $00 bit 5 isn't set, which prevents the option from cutting when it's not necessary (e.g. the title screen of Gangster Town, the half pipe stage of California Games, the Phantasy Star menu screen).
This commit is contained in:
ds22x 2021-09-13 00:18:02 +02:00 committed by GitHub
parent 76a08ebe6a
commit 6c3683fa5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -907,12 +907,6 @@ static void update_overclock(void)
} }
#endif #endif
static void check_sms_border(void)
{
if (config.left_border && (bitmap.viewport.x == 0) && ((system_hw == SYSTEM_MARKIII) || (system_hw & SYSTEM_SMS) || (system_hw == SYSTEM_PBC)))
bitmap.viewport.x = -8;
}
static void check_variables(void) static void check_variables(void)
{ {
unsigned orig_value; unsigned orig_value;
@ -1398,8 +1392,10 @@ static void check_variables(void)
orig_value = config.left_border; orig_value = config.left_border;
if (!var.value || !strcmp(var.value, "disabled")) if (!var.value || !strcmp(var.value, "disabled"))
config.left_border = 0; config.left_border = 0;
else if (var.value && !strcmp(var.value, "enabled")) else if (var.value && !strcmp(var.value, "left border"))
config.left_border = 1; config.left_border = 1;
else if (var.value && !strcmp(var.value, "left & right borders"))
config.left_border = 2;
if (orig_value != config.left_border) if (orig_value != config.left_border)
update_viewports = true; update_viewports = true;
} }
@ -1453,7 +1449,6 @@ static void check_variables(void)
bitmap.viewport.x = (config.overscan & 2) ? 14 : -48; bitmap.viewport.x = (config.overscan & 2) ? 14 : -48;
else else
bitmap.viewport.x = (config.overscan & 2) * 7; bitmap.viewport.x = (config.overscan & 2) * 7;
check_sms_border();
} }
} }
@ -2016,7 +2011,7 @@ void retro_set_environment(retro_environment_t cb)
{ "genesis_plus_gx_lcd_filter", "LCD Ghosting filter; disabled|enabled" }, { "genesis_plus_gx_lcd_filter", "LCD Ghosting filter; disabled|enabled" },
{ "genesis_plus_gx_overscan", "Borders; disabled|top/bottom|left/right|full" }, { "genesis_plus_gx_overscan", "Borders; disabled|top/bottom|left/right|full" },
{ "genesis_plus_gx_gg_extra", "Game Gear extended screen; disabled|enabled" }, { "genesis_plus_gx_gg_extra", "Game Gear extended screen; disabled|enabled" },
{ "genesis_plus_gx_left_border", "Hide Master System Left Border; disabled|enabled" }, { "genesis_plus_gx_left_border", "Hide Master System Left Border; disabled|left border|left & right borders" },
{ "genesis_plus_gx_aspect_ratio", "Core-provided aspect ratio; auto|NTSC PAR|PAL PAR" }, { "genesis_plus_gx_aspect_ratio", "Core-provided aspect ratio; auto|NTSC PAR|PAL PAR" },
{ "genesis_plus_gx_render", "Interlaced mode 2 output; single field|double field" }, { "genesis_plus_gx_render", "Interlaced mode 2 output; single field|double field" },
{ "genesis_plus_gx_gun_cursor", "Show Lightgun crosshair; disabled|enabled" }, { "genesis_plus_gx_gun_cursor", "Show Lightgun crosshair; disabled|enabled" },
@ -2378,7 +2373,6 @@ bool retro_unserialize(const void *data, size_t size)
overclock_delay = OVERCLOCK_FRAME_DELAY; overclock_delay = OVERCLOCK_FRAME_DELAY;
update_overclock(); update_overclock();
#endif #endif
check_sms_border();
return TRUE; return TRUE;
} }
@ -2646,7 +2640,6 @@ bool retro_load_game(const struct retro_game_info *info)
audio_init(SOUND_FREQUENCY, 0); audio_init(SOUND_FREQUENCY, 0);
system_init(); system_init();
system_reset(); system_reset();
check_sms_border();
is_running = false; is_running = false;
if (system_hw == SYSTEM_MCD) if (system_hw == SYSTEM_MCD)
@ -2792,6 +2785,8 @@ void retro_run(void)
{ {
bool updated = false; bool updated = false;
is_running = true; is_running = true;
int vwoffset = 0;
int bmdoffset = 0;
#ifdef HAVE_OVERCLOCK #ifdef HAVE_OVERCLOCK
/* update overclock delay */ /* update overclock delay */
@ -2852,7 +2847,22 @@ void retro_run(void)
} }
} }
video_cb(bitmap.data, vwidth, vheight, 720 * 2); bmdoffset = 0;
vwoffset = 0;
if ((config.left_border != 0) && (reg[0] & 0x20) && ((system_hw == SYSTEM_MARKIII) || (system_hw & SYSTEM_SMS) || (system_hw == SYSTEM_PBC)))
{
bmdoffset = 16;
if (config.left_border == 1)
{
vwoffset = 8;
}
else
{
vwoffset = 16;
}
}
video_cb(bitmap.data + bmdoffset, vwidth - vwoffset, vheight, 720 * 2);
audio_cb(soundbuffer, audio_update(soundbuffer)); audio_cb(soundbuffer, audio_update(soundbuffer));
environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated); environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated);