Skip to content

Commit

Permalink
Add horizontal overscan options for 284 and 320 pixels. Fix #88
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jan 13, 2024
1 parent f7ac4e9 commit 67a10be
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 23 deletions.
5 changes: 4 additions & 1 deletion platforms/desktop-shared/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@ void emu_set_overscan(int overscan)
gearsystem->GetVideo()->SetOverscan(Video::OverscanTopBottom);
break;
case 2:
gearsystem->GetVideo()->SetOverscan(Video::OverscanFull);
gearsystem->GetVideo()->SetOverscan(Video::OverscanFull284);
break;
case 3:
gearsystem->GetVideo()->SetOverscan(Video::OverscanFull320);
break;
default:
gearsystem->GetVideo()->SetOverscan(Video::OverscanDisabled);
Expand Down
10 changes: 5 additions & 5 deletions platforms/desktop-shared/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void gui_init(void)
emu_enable_bootrom_sms(config_emulator.sms_bootrom);
emu_enable_bootrom_gg(config_emulator.gg_bootrom);
emu_set_media_slot(config_emulator.media);
emu_set_overscan(config_debug.debug ? false : config_video.overscan);
emu_set_overscan(config_debug.debug ? 0 : config_video.overscan);
emu_disable_ym2413(config_audio.ym2413 == 1);
}

Expand Down Expand Up @@ -650,10 +650,10 @@ static void main_menu(void)

if (ImGui::BeginMenu("Overscan"))
{
ImGui::PushItemWidth(120.0f);
if (ImGui::Combo("##overscan", &config_video.overscan, "Disabled\0Top+Bottom\0Full\0\0"))
ImGui::PushItemWidth(170.0f);
if (ImGui::Combo("##overscan", &config_video.overscan, "Disabled\0Top+Bottom\0Full (284 width)\0Full (320 width)\0\0"))
{
emu_set_overscan(config_debug.debug ? false : config_video.overscan);
emu_set_overscan(config_debug.debug ? 0 : config_video.overscan);
}
ImGui::PopItemWidth();
ImGui::EndMenu();
Expand Down Expand Up @@ -849,7 +849,7 @@ static void main_menu(void)

if (ImGui::MenuItem("Enable", "", &config_debug.debug))
{
emu_set_overscan(config_debug.debug ? false : config_video.overscan);
emu_set_overscan(config_debug.debug ? 0 : config_video.overscan);

if (config_debug.debug)
emu_debug_step();
Expand Down
8 changes: 5 additions & 3 deletions platforms/libretro/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static const struct retro_variable vars[] = {
{ "gearsystem_mapper", "Mapper (restart); Auto|ROM|SEGA|Codemasters|Korean|MSX|Janggun|SG-1000" },
{ "gearsystem_timing", "Refresh Rate (restart); Auto|NTSC (60 Hz)|PAL (50 Hz)" },
{ "gearsystem_aspect_ratio", "Aspect Ratio (restart); 1:1 PAR|4:3 PAR|16:9 PAR" },
{ "gearsystem_overscan", "Overscan; Disabled|Top+Bottom|Full" },
{ "gearsystem_overscan", "Overscan; Disabled|Top+Bottom|Full (284 width)|Full (320 width)" },
{ "gearsystem_bios_sms", "Master System BIOS (restart); Disabled|Enabled" },
{ "gearsystem_bios_gg", "Game Gear BIOS (restart); Disabled|Enabled" },
{ "gearsystem_ym2413", "YM2413 (restart); Auto|Disabled"},
Expand Down Expand Up @@ -436,8 +436,10 @@ static void check_variables(void)
core->GetVideo()->SetOverscan(Video::OverscanDisabled);
else if (strcmp(var.value, "Top+Bottom") == 0)
core->GetVideo()->SetOverscan(Video::OverscanTopBottom);
else if (strcmp(var.value, "Full") == 0)
core->GetVideo()->SetOverscan(Video::OverscanFull);
else if (strcmp(var.value, "Full (284 width)") == 0)
core->GetVideo()->SetOverscan(Video::OverscanFull284);
else if (strcmp(var.value, "Full (320 width)") == 0)
core->GetVideo()->SetOverscan(Video::OverscanFull320);
else
core->GetVideo()->SetOverscan(Video::OverscanDisabled);
}
Expand Down
6 changes: 4 additions & 2 deletions src/GearsystemCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ bool GearsystemCore::GetRuntimeInfo(GS_RuntimeInfo& runtime_info)
runtime_info.screen_width = GS_RESOLUTION_SMS_WIDTH;
runtime_info.screen_height = m_pVideo->IsExtendedMode224() ? GS_RESOLUTION_SMS_HEIGHT_EXTENDED : GS_RESOLUTION_SMS_HEIGHT;

if (m_pVideo->GetOverscan() == Video::OverscanFull)
runtime_info.screen_width = GS_RESOLUTION_SMS_WIDTH + (2 * GS_RESOLUTION_SMS_OVERSCAN_H);
if (m_pVideo->GetOverscan() == Video::OverscanFull284)
runtime_info.screen_width = GS_RESOLUTION_SMS_WIDTH + GS_RESOLUTION_SMS_OVERSCAN_H_284_L + GS_RESOLUTION_SMS_OVERSCAN_H_284_R;
if (m_pVideo->GetOverscan() == Video::OverscanFull320)
runtime_info.screen_width = GS_RESOLUTION_SMS_WIDTH + GS_RESOLUTION_SMS_OVERSCAN_H_320_L + GS_RESOLUTION_SMS_OVERSCAN_H_320_R;
if (m_pVideo->GetOverscan() != Video::OverscanDisabled)
runtime_info.screen_height = GS_RESOLUTION_SMS_HEIGHT + (2 * (m_pCartridge->IsPAL() ? GS_RESOLUTION_SMS_OVERSCAN_V_PAL : GS_RESOLUTION_SMS_OVERSCAN_V));
}
Expand Down
34 changes: 24 additions & 10 deletions src/Video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ void Video::Render24bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GS_Color_Format
{
int x = 0;
int y = 0;
int overscan_h = 0;
int overscan_h_l = 0;
int overscan_v = 0;
int overscan_content_v = 0;
int overscan_content_h = 0;
Expand Down Expand Up @@ -943,19 +943,26 @@ void Video::Render24bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GS_Color_Format
overscan_total_height = overscan_content_v + (overscan_v * 2);
}

if (overscan && (m_Overscan == OverscanFull))
if (overscan && (m_Overscan == OverscanFull320))
{
overscan_content_h = GS_RESOLUTION_MAX_WIDTH;
overscan_h = GS_RESOLUTION_SMS_OVERSCAN_H;
overscan_total_width = overscan_content_h + (overscan_h * 2);
overscan_h_l = GS_RESOLUTION_SMS_OVERSCAN_H_320_L;
overscan_total_width = overscan_content_h + overscan_h_l + GS_RESOLUTION_SMS_OVERSCAN_H_320_R;
}

if (overscan && (m_Overscan == OverscanFull284))
{
overscan_content_h = GS_RESOLUTION_MAX_WIDTH;
overscan_h_l = GS_RESOLUTION_SMS_OVERSCAN_H_284_L;
overscan_total_width = overscan_content_h + overscan_h_l + GS_RESOLUTION_SMS_OVERSCAN_H_284_R;
}

for (int i = 0, j = 0; j < buffer_size; j += 3)
{
u16 src_color = 0;
if (overscan_enabled)
{
bool is_h_overscan = (overscan_h > 0) && (x < overscan_h || x >= (overscan_h + overscan_content_h));
bool is_h_overscan = (overscan_h_l > 0) && (x < overscan_h_l || x >= (overscan_h_l + overscan_content_h));
bool is_v_overscan = (overscan_v > 0) && (y < overscan_v || y >= (overscan_v + overscan_content_v));

if (is_h_overscan || is_v_overscan)
Expand Down Expand Up @@ -994,7 +1001,7 @@ void Video::Render16bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GS_Color_Format
{
int x = 0;
int y = 0;
int overscan_h = 0;
int overscan_h_l = 0;
int overscan_v = 0;
int overscan_content_v = 0;
int overscan_content_h = 0;
Expand Down Expand Up @@ -1040,19 +1047,26 @@ void Video::Render16bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GS_Color_Format
overscan_total_height = overscan_content_v + (overscan_v * 2);
}

if (overscan && (m_Overscan == OverscanFull))
if (overscan && (m_Overscan == OverscanFull320))
{
overscan_content_h = GS_RESOLUTION_MAX_WIDTH;
overscan_h_l = GS_RESOLUTION_SMS_OVERSCAN_H_320_L;
overscan_total_width = overscan_content_h + overscan_h_l + GS_RESOLUTION_SMS_OVERSCAN_H_320_R;
}

if (overscan && (m_Overscan == OverscanFull284))
{
overscan_content_h = GS_RESOLUTION_MAX_WIDTH;
overscan_h = GS_RESOLUTION_SMS_OVERSCAN_H;
overscan_total_width = overscan_content_h + (overscan_h * 2);
overscan_h_l = GS_RESOLUTION_SMS_OVERSCAN_H_284_L;
overscan_total_width = overscan_content_h + overscan_h_l + GS_RESOLUTION_SMS_OVERSCAN_H_284_R;
}

for (int i = 0, j = 0; j < buffer_size; j += 2)
{
u16 src_color = 0;
if (overscan_enabled)
{
bool is_h_overscan = (overscan_h > 0) && (x < overscan_h || x >= (overscan_h + overscan_content_h));
bool is_h_overscan = (overscan_h_l > 0) && (x < overscan_h_l || x >= (overscan_h_l + overscan_content_h));
bool is_v_overscan = (overscan_v > 0) && (y < overscan_v || y >= (overscan_v + overscan_content_v));

if (is_h_overscan || is_v_overscan)
Expand Down
3 changes: 2 additions & 1 deletion src/Video.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class Video
{
OverscanDisabled,
OverscanTopBottom,
OverscanFull
OverscanFull284,
OverscanFull320
};

public:
Expand Down
5 changes: 4 additions & 1 deletion src/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ typedef void (*RamChangedCallback) (void);
#define GS_RESOLUTION_SMS_WIDTH 256
#define GS_RESOLUTION_SMS_HEIGHT 192
#define GS_RESOLUTION_SMS_HEIGHT_EXTENDED 224
#define GS_RESOLUTION_SMS_OVERSCAN_H 32
#define GS_RESOLUTION_SMS_OVERSCAN_H_320_L 32
#define GS_RESOLUTION_SMS_OVERSCAN_H_320_R 32
#define GS_RESOLUTION_SMS_OVERSCAN_H_284_L 13
#define GS_RESOLUTION_SMS_OVERSCAN_H_284_R 15
#define GS_RESOLUTION_SMS_OVERSCAN_V 24
#define GS_RESOLUTION_SMS_OVERSCAN_V_PAL 48

Expand Down

0 comments on commit 67a10be

Please sign in to comment.