From 6c3683fa5e3c086955796ecfc4154ade206e938e Mon Sep 17 00:00:00 2001 From: ds22x <45218067+ds22x@users.noreply.github.com> Date: Mon, 13 Sep 2021 00:18:02 +0200 Subject: [PATCH 1/4] [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). --- libretro/libretro.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index c064d3d..393a34d 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -907,12 +907,6 @@ static void update_overclock(void) } #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) { unsigned orig_value; @@ -1398,8 +1392,10 @@ static void check_variables(void) orig_value = config.left_border; if (!var.value || !strcmp(var.value, "disabled")) 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; + else if (var.value && !strcmp(var.value, "left & right borders")) + config.left_border = 2; if (orig_value != config.left_border) update_viewports = true; } @@ -1453,7 +1449,6 @@ static void check_variables(void) bitmap.viewport.x = (config.overscan & 2) ? 14 : -48; else 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_overscan", "Borders; disabled|top/bottom|left/right|full" }, { "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_render", "Interlaced mode 2 output; single field|double field" }, { "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; update_overclock(); #endif - check_sms_border(); return TRUE; } @@ -2646,7 +2640,6 @@ bool retro_load_game(const struct retro_game_info *info) audio_init(SOUND_FREQUENCY, 0); system_init(); system_reset(); - check_sms_border(); is_running = false; if (system_hw == SYSTEM_MCD) @@ -2792,6 +2785,8 @@ void retro_run(void) { bool updated = false; is_running = true; + int vwoffset = 0; + int bmdoffset = 0; #ifdef HAVE_OVERCLOCK /* 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)); environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated); From 5d31807f957f15b72f8d3ad8bb4c3985ea754fd6 Mon Sep 17 00:00:00 2001 From: ds22x <45218067+ds22x@users.noreply.github.com> Date: Mon, 13 Sep 2021 02:51:26 +0200 Subject: [PATCH 2/4] Remove two unnecessary lines --- libretro/libretro.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index 393a34d..a9ab3c6 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -2847,8 +2847,6 @@ void retro_run(void) } } - 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; From f6976f914b6de9fb30523e3428a2c22c086ef610 Mon Sep 17 00:00:00 2001 From: ds22x <45218067+ds22x@users.noreply.github.com> Date: Mon, 13 Sep 2021 03:08:31 +0200 Subject: [PATCH 3/4] Renamed "Hide Left Border" option to "Hide Side Borders" --- libretro/libretro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index a9ab3c6..7b5adb1 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -2011,7 +2011,7 @@ void retro_set_environment(retro_environment_t cb) { "genesis_plus_gx_lcd_filter", "LCD Ghosting filter; disabled|enabled" }, { "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_left_border", "Hide Master System Left Border; disabled|left border|left & right borders" }, + { "genesis_plus_gx_left_border", "Hide Master System Side Borders; disabled|left border|left & right borders" }, { "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_gun_cursor", "Show Lightgun crosshair; disabled|enabled" }, From 67327481b70138d833cbe67db0e96ef6bc1c66f8 Mon Sep 17 00:00:00 2001 From: ds22x <45218067+ds22x@users.noreply.github.com> Date: Mon, 13 Sep 2021 15:04:42 +0200 Subject: [PATCH 4/4] Add bitmap viewport check --- libretro/libretro.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro/libretro.c b/libretro/libretro.c index 7b5adb1..7d95f53 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -2847,7 +2847,7 @@ void retro_run(void) } } - if ((config.left_border != 0) && (reg[0] & 0x20) && ((system_hw == SYSTEM_MARKIII) || (system_hw & SYSTEM_SMS) || (system_hw == SYSTEM_PBC))) + if ((config.left_border != 0) && (reg[0] & 0x20) && (bitmap.viewport.x = 0) && ((system_hw == SYSTEM_MARKIII) || (system_hw & SYSTEM_SMS) || (system_hw == SYSTEM_PBC))) { bmdoffset = 16; if (config.left_border == 1)