From c917c95ace2edee38ea6085a3b96e6fd2a8056ca Mon Sep 17 00:00:00 2001 From: Ignacio Sanchez Gines <863613+drhelius@users.noreply.github.com> Date: Sat, 13 Jan 2024 13:06:04 +0100 Subject: [PATCH] Add horizontal overscan options for 284 and 320 pixels --- platforms/desktop-shared/emu.cpp | 11 ++-- platforms/desktop-shared/gui.cpp | 18 +++--- platforms/desktop-shared/gui_debug.cpp | 4 +- platforms/desktop-shared/renderer.cpp | 6 +- platforms/libretro/libretro.cpp | 14 +++-- src/GearcolecoCore.cpp | 14 +++-- src/Video.cpp | 76 +++++++++++++++----------- src/Video.h | 3 +- src/definitions.h | 15 +++-- 9 files changed, 93 insertions(+), 68 deletions(-) diff --git a/platforms/desktop-shared/emu.cpp b/platforms/desktop-shared/emu.cpp index 8db1d3f..05584af 100644 --- a/platforms/desktop-shared/emu.cpp +++ b/platforms/desktop-shared/emu.cpp @@ -47,7 +47,7 @@ static void update_debug_sprite_buffers(void); void emu_init(void) { - int screen_size = GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN; + int screen_size = GC_RESOLUTION_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_HEIGHT_WITH_OVERSCAN; emu_frame_buffer = new u8[screen_size * 3]; @@ -335,7 +335,10 @@ void emu_set_overscan(int overscan) gearcoleco->GetVideo()->SetOverscan(Video::OverscanTopBottom); break; case 2: - gearcoleco->GetVideo()->SetOverscan(Video::OverscanFull); + gearcoleco->GetVideo()->SetOverscan(Video::OverscanFull284); + break; + case 3: + gearcoleco->GetVideo()->SetOverscan(Video::OverscanFull320); break; default: gearcoleco->GetVideo()->SetOverscan(Video::OverscanDisabled); @@ -480,7 +483,7 @@ static void update_debug_background_buffer(void) for (int line = 0; line < 192; line++) { - int line_offset = line * GC_RESOLUTION_MAX_WIDTH; + int line_offset = line * GC_RESOLUTION_WIDTH; int tile_y = line >> 3; int tile_y_offset = line & 7; @@ -517,7 +520,7 @@ static void update_debug_background_buffer(void) for (int line = 0; line < 192; line++) { - int line_offset = line * GC_RESOLUTION_MAX_WIDTH; + int line_offset = line * GC_RESOLUTION_WIDTH; int tile_y = line >> 3; int tile_y_offset = line & 7; region = (tile_y & 0x18) << 5; diff --git a/platforms/desktop-shared/gui.cpp b/platforms/desktop-shared/gui.cpp index e9edb1a..f25ec6d 100644 --- a/platforms/desktop-shared/gui.cpp +++ b/platforms/desktop-shared/gui.cpp @@ -110,7 +110,7 @@ void gui_init(void) if (strlen(bios_path) > 0) emu_load_bios(bios_path); - emu_set_overscan(config_debug.debug ? false : config_video.overscan); + emu_set_overscan(config_debug.debug ? 0 : config_video.overscan); } void gui_destroy(void) @@ -213,7 +213,7 @@ void gui_load_rom(const char* path) { emu_pause(); - for (int i=0; i < (GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN); i++) + for (int i=0; i < (GC_RESOLUTION_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_HEIGHT_WITH_OVERSCAN); i++) { emu_frame_buffer[i] = 0; } @@ -465,10 +465,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(150.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(); @@ -740,7 +740,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(); @@ -1011,8 +1011,8 @@ static void main_window(void) gui_main_window_hovered = ImGui::IsWindowHovered(); } - float tex_h = (float)runtime.screen_width / (float)(GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN); - float tex_v = (float)runtime.screen_height / (float)(GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN); + float tex_h = (float)runtime.screen_width / (float)(GC_RESOLUTION_WIDTH_WITH_OVERSCAN); + float tex_v = (float)runtime.screen_height / (float)(GC_RESOLUTION_HEIGHT_WITH_OVERSCAN); ImGui::Image((void*)(intptr_t)renderer_emu_texture, ImVec2((float)main_window_width, (float)main_window_height), ImVec2(0, 0), ImVec2(tex_h, tex_v)); @@ -1425,7 +1425,7 @@ static void menu_reset(void) { emu_pause(); - for (int i=0; i < (GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN); i++) + for (int i=0; i < (GC_RESOLUTION_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_HEIGHT_WITH_OVERSCAN); i++) { emu_frame_buffer[i] = 0; } diff --git a/platforms/desktop-shared/gui_debug.cpp b/platforms/desktop-shared/gui_debug.cpp index 8964a9f..f585ab4 100644 --- a/platforms/desktop-shared/gui_debug.cpp +++ b/platforms/desktop-shared/gui_debug.cpp @@ -1117,8 +1117,8 @@ static void debug_window_vram_sprites(void) ImVec2 p_screen = ImGui::GetCursorScreenPos(); float screen_scale = 1.0f; - float tex_h = (float)runtime.screen_width / (float)(GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN); - float tex_v = (float)runtime.screen_height / (float)(GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN); + float tex_h = (float)runtime.screen_width / (float)(GC_RESOLUTION_WIDTH_WITH_OVERSCAN); + float tex_v = (float)runtime.screen_height / (float)(GC_RESOLUTION_HEIGHT_WITH_OVERSCAN); ImGui::Image((void*)(intptr_t)renderer_emu_texture, ImVec2(runtime.screen_width * screen_scale, runtime.screen_height * screen_scale), ImVec2(0, 0), ImVec2(tex_h, tex_v)); diff --git a/platforms/desktop-shared/renderer.cpp b/platforms/desktop-shared/renderer.cpp index 309f77a..58e90fc 100644 --- a/platforms/desktop-shared/renderer.cpp +++ b/platforms/desktop-shared/renderer.cpp @@ -45,8 +45,8 @@ static u32 scanlines[16] = { 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF, 0x000000FF}; static const int FRAME_BUFFER_SCALE = 4; -static const int FRAME_BUFFER_WIDTH = GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN * FRAME_BUFFER_SCALE; -static const int FRAME_BUFFER_HEIGHT = GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN * FRAME_BUFFER_SCALE; +static const int FRAME_BUFFER_WIDTH = GC_RESOLUTION_WIDTH_WITH_OVERSCAN * FRAME_BUFFER_SCALE; +static const int FRAME_BUFFER_HEIGHT = GC_RESOLUTION_HEIGHT_WITH_OVERSCAN * FRAME_BUFFER_SCALE; static void init_ogl_gui(void); static void init_ogl_emu(void); @@ -158,7 +158,7 @@ static void init_ogl_emu(void) glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindTexture(GL_TEXTURE_2D, system_texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN, GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN, 0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) emu_frame_buffer); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, GC_RESOLUTION_WIDTH_WITH_OVERSCAN, GC_RESOLUTION_HEIGHT_WITH_OVERSCAN, 0, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*) emu_frame_buffer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); diff --git a/platforms/libretro/libretro.cpp b/platforms/libretro/libretro.cpp index c720fb1..8d1ef69 100644 --- a/platforms/libretro/libretro.cpp +++ b/platforms/libretro/libretro.cpp @@ -99,7 +99,7 @@ static void fallback_log(enum retro_log_level level, const char *fmt, ...) static const struct retro_variable vars[] = { { "gearcoleco_timing", "Refresh Rate (restart); Auto|NTSC (60 Hz)|PAL (50 Hz)" }, { "gearcoleco_aspect_ratio", "Aspect Ratio (restart); 1:1 PAR|4:3 PAR|16:9 PAR" }, - { "gearcoleco_overscan", "Overscan; Disabled|Top+Bottom|Full" }, + { "gearsystem_overscan", "Overscan; Disabled|Top+Bottom|Full (284 width)|Full (320 width)" }, { "gearcoleco_up_down_allowed", "Allow Up+Down / Left+Right; Disabled|Enabled" }, { "gearcoleco_no_sprite_limit", "No Sprite Limit; Disabled|Enabled" }, { "gearcoleco_spinners", "Spinner support; Disabled|Super Action Controller|Wheel Controller|Roller Controller" }, @@ -128,7 +128,7 @@ void retro_init(void) core->Init(GC_PIXEL_RGB565); #endif - frame_buffer = new u8[GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN * 2]; + frame_buffer = new u8[GC_RESOLUTION_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_HEIGHT_WITH_OVERSCAN * 2]; audio_sample_count = 0; @@ -235,8 +235,8 @@ void retro_get_system_av_info(struct retro_system_av_info *info) info->geometry.base_width = runtime_info.screen_width; info->geometry.base_height = runtime_info.screen_height; - info->geometry.max_width = GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN; - info->geometry.max_height = GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN; + info->geometry.max_width = GC_RESOLUTION_WIDTH_WITH_OVERSCAN; + info->geometry.max_height = GC_RESOLUTION_HEIGHT_WITH_OVERSCAN; info->geometry.aspect_ratio = aspect_ratio; info->timing.fps = runtime_info.region == Region_NTSC ? 60.0 : 50.0; info->timing.sample_rate = 44100.0; @@ -516,8 +516,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); } diff --git a/src/GearcolecoCore.cpp b/src/GearcolecoCore.cpp index a05a875..0b6645f 100644 --- a/src/GearcolecoCore.cpp +++ b/src/GearcolecoCore.cpp @@ -200,16 +200,18 @@ void GearcolecoCore::SaveDisassembledROM() bool GearcolecoCore::GetRuntimeInfo(GC_RuntimeInfo& runtime_info) { - runtime_info.screen_width = GC_RESOLUTION_MAX_WIDTH; - runtime_info.screen_height = GC_RESOLUTION_MAX_HEIGHT; + runtime_info.screen_width = GC_RESOLUTION_WIDTH; + runtime_info.screen_height = GC_RESOLUTION_HEIGHT; runtime_info.region = Region_NTSC; if (m_pCartridge->IsReady()) { - if (m_pVideo->GetOverscan() == Video::OverscanFull) - runtime_info.screen_width = GC_RESOLUTION_MAX_WIDTH + (2 * GC_RESOLUTION_OVERSCAN_H); + if (m_pVideo->GetOverscan() == Video::OverscanFull284) + runtime_info.screen_width = GC_RESOLUTION_WIDTH + GC_RESOLUTION_SMS_OVERSCAN_H_284_L + GC_RESOLUTION_SMS_OVERSCAN_H_284_R; + if (m_pVideo->GetOverscan() == Video::OverscanFull320) + runtime_info.screen_width = GC_RESOLUTION_WIDTH + GC_RESOLUTION_SMS_OVERSCAN_H_320_L + GC_RESOLUTION_SMS_OVERSCAN_H_320_R; if (m_pVideo->GetOverscan() != Video::OverscanDisabled) - runtime_info.screen_height = GC_RESOLUTION_MAX_HEIGHT + (2 * (m_pCartridge->IsPAL() ? GC_RESOLUTION_OVERSCAN_V_PAL : GC_RESOLUTION_OVERSCAN_V)); + runtime_info.screen_height = GC_RESOLUTION_HEIGHT + (2 * (m_pCartridge->IsPAL() ? GC_RESOLUTION_OVERSCAN_V_PAL : GC_RESOLUTION_OVERSCAN_V)); runtime_info.region = m_pCartridge->IsPAL() ? Region_PAL : Region_NTSC; return true; } @@ -589,7 +591,7 @@ void GearcolecoCore::Reset() void GearcolecoCore::RenderFrameBuffer(u8* finalFrameBuffer) { - int size = GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN; + int size = GC_RESOLUTION_WIDTH_WITH_OVERSCAN * GC_RESOLUTION_HEIGHT_WITH_OVERSCAN; u16* srcBuffer = (m_pMemory->IsBiosLoaded() ? m_pVideo->GetFrameBuffer() : kNoBiosImage); switch (m_pixelFormat) diff --git a/src/Video.cpp b/src/Video.cpp index c1a5071..227098f 100644 --- a/src/Video.cpp +++ b/src/Video.cpp @@ -60,8 +60,8 @@ Video::~Video() void Video::Init() { - m_pInfoBuffer = new u8[GC_RESOLUTION_MAX_WIDTH * GC_LINES_PER_FRAME_PAL]; - m_pFrameBuffer = new u16[GC_RESOLUTION_MAX_WIDTH * GC_LINES_PER_FRAME_PAL]; + m_pInfoBuffer = new u8[GC_RESOLUTION_WIDTH * GC_LINES_PER_FRAME_PAL]; + m_pFrameBuffer = new u16[GC_RESOLUTION_WIDTH * GC_LINES_PER_FRAME_PAL]; m_pVdpVRAM = new u8[0x4000]; InitPalettes(); Reset(false); @@ -75,7 +75,7 @@ void Video::Reset(bool bPAL) m_VdpBuffer = 0; m_VdpAddress = 0; m_VdpStatus = 0; - for (int i = 0; i < (GC_RESOLUTION_MAX_WIDTH * GC_LINES_PER_FRAME_PAL); i++) + for (int i = 0; i < (GC_RESOLUTION_WIDTH * GC_LINES_PER_FRAME_PAL); i++) { m_pFrameBuffer[i] = 1; m_pInfoBuffer[i] = 0; @@ -112,7 +112,7 @@ bool Video::Tick(unsigned int clockCycles) m_iCycleCounter += clockCycles; ///// VINT ///// - if (m_iRenderLine == GC_RESOLUTION_MAX_HEIGHT) + if (m_iRenderLine == GC_RESOLUTION_HEIGHT) { if (!m_LineEvents.vint && (m_iCycleCounter >= m_Timing[TIMING_VINT])) { @@ -142,7 +142,7 @@ bool Video::Tick(unsigned int clockCycles) ///// END OF LINE ///// if (m_iCycleCounter >= GC_CYCLES_PER_LINE) { - if (m_iRenderLine == GC_RESOLUTION_MAX_HEIGHT) + if (m_iRenderLine == GC_RESOLUTION_HEIGHT) { return_vblank = true; } @@ -271,7 +271,7 @@ void Video::ScanLine(int line) { if (m_bDisplayEnabled) { - if (line < GC_RESOLUTION_MAX_HEIGHT) + if (line < GC_RESOLUTION_HEIGHT) { RenderBackground(line); @@ -281,12 +281,12 @@ void Video::ScanLine(int line) } else { - if (line < GC_RESOLUTION_MAX_HEIGHT) + if (line < GC_RESOLUTION_HEIGHT) { u16 color = m_VdpRegister[7] & 0x0F; - int line_width = line * GC_RESOLUTION_MAX_WIDTH; + int line_width = line * GC_RESOLUTION_WIDTH; - for (int scx = 0; scx < GC_RESOLUTION_MAX_WIDTH; scx++) + for (int scx = 0; scx < GC_RESOLUTION_WIDTH; scx++) { int pixel = line_width + scx; m_pFrameBuffer[pixel] = color; @@ -298,7 +298,7 @@ void Video::ScanLine(int line) void Video::RenderBackground(int line) { - int line_offset = line * GC_RESOLUTION_MAX_WIDTH; + int line_offset = line * GC_RESOLUTION_WIDTH; int name_table_addr = m_VdpRegister[2] << 10; int color_table_addr = m_VdpRegister[3] << 6; @@ -428,7 +428,7 @@ void Video::RenderBackground(int line) void Video::RenderSprites(int line) { int sprite_count = 0; - int line_width = line * GC_RESOLUTION_MAX_WIDTH; + int line_width = line * GC_RESOLUTION_WIDTH; int sprite_size = IsSetBit(m_VdpRegister[1], 1) ? 16 : 8; bool sprite_zoom = IsSetBit(m_VdpRegister[1], 0); if (sprite_zoom) @@ -473,7 +473,7 @@ void Video::RenderSprites(int line) int sprite_shift = (m_pVdpVRAM[sprite_attribute_offset + 3] & 0x80) ? 32 : 0; int sprite_x = m_pVdpVRAM[sprite_attribute_offset + 1] - sprite_shift; - if (sprite_x >= GC_RESOLUTION_MAX_WIDTH) + if (sprite_x >= GC_RESOLUTION_WIDTH) continue; int sprite_tile = m_pVdpVRAM[sprite_attribute_offset + 2]; @@ -484,7 +484,7 @@ void Video::RenderSprites(int line) for (int tile_x = 0; tile_x < sprite_size; tile_x++) { int sprite_pixel_x = sprite_x + tile_x; - if (sprite_pixel_x >= GC_RESOLUTION_MAX_WIDTH) + if (sprite_pixel_x >= GC_RESOLUTION_WIDTH) break; if (sprite_pixel_x < 0) continue; @@ -525,11 +525,11 @@ void Video::Render24bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GC_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; - int overscan_total_width = GC_RESOLUTION_MAX_WIDTH; + int overscan_total_width = GC_RESOLUTION_WIDTH; int overscan_total_height = 0; bool overscan_enabled = false; int overscan_color = (m_VdpRegister[7] & 0x0F) * 3; @@ -539,16 +539,23 @@ void Video::Render24bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GC_Color_Format if (overscan && (m_Overscan != OverscanDisabled)) { overscan_enabled = true; - overscan_content_v = GC_RESOLUTION_MAX_HEIGHT; + overscan_content_v = GC_RESOLUTION_HEIGHT; overscan_v = m_bPAL ? GC_RESOLUTION_OVERSCAN_V_PAL : GC_RESOLUTION_OVERSCAN_V; overscan_total_height = overscan_content_v + (overscan_v * 2); } - if (overscan && (m_Overscan == OverscanFull)) + if (overscan && (m_Overscan == OverscanFull320)) { - overscan_content_h = GC_RESOLUTION_MAX_WIDTH; - overscan_h = GC_RESOLUTION_OVERSCAN_H; - overscan_total_width = overscan_content_h + (overscan_h * 2); + overscan_content_h = GC_RESOLUTION_WIDTH; + overscan_h_l = GC_RESOLUTION_SMS_OVERSCAN_H_320_L; + overscan_total_width = overscan_content_h + overscan_h_l + GC_RESOLUTION_SMS_OVERSCAN_H_320_R; + } + + if (overscan && (m_Overscan == OverscanFull284)) + { + overscan_content_h = GC_RESOLUTION_WIDTH; + overscan_h_l = GC_RESOLUTION_SMS_OVERSCAN_H_284_L; + overscan_total_width = overscan_content_h + overscan_h_l + GC_RESOLUTION_SMS_OVERSCAN_H_284_R; } for (int i = 0, j = 0; j < buffer_size; j += 3) @@ -556,7 +563,7 @@ void Video::Render24bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GC_Color_Format 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) @@ -586,11 +593,11 @@ void Video::Render16bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GC_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; - int overscan_total_width = GC_RESOLUTION_MAX_WIDTH; + int overscan_total_width = GC_RESOLUTION_WIDTH; int overscan_total_height = 0; bool overscan_enabled = false; int overscan_color = m_VdpRegister[7] & 0x0F; @@ -607,16 +614,23 @@ void Video::Render16bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GC_Color_Format if (overscan && (m_Overscan != OverscanDisabled)) { overscan_enabled = true; - overscan_content_v = GC_RESOLUTION_MAX_HEIGHT; + overscan_content_v = GC_RESOLUTION_HEIGHT; overscan_v = m_bPAL ? GC_RESOLUTION_OVERSCAN_V_PAL : GC_RESOLUTION_OVERSCAN_V; overscan_total_height = overscan_content_v + (overscan_v * 2); } - if (overscan && (m_Overscan == OverscanFull)) + if (overscan && (m_Overscan == OverscanFull320)) + { + overscan_content_h = GC_RESOLUTION_WIDTH; + overscan_h_l = GC_RESOLUTION_SMS_OVERSCAN_H_320_L; + overscan_total_width = overscan_content_h + overscan_h_l + GC_RESOLUTION_SMS_OVERSCAN_H_320_R; + } + + if (overscan && (m_Overscan == OverscanFull284)) { - overscan_content_h = GC_RESOLUTION_MAX_WIDTH; - overscan_h = GC_RESOLUTION_OVERSCAN_H; - overscan_total_width = overscan_content_h + (overscan_h * 2); + overscan_content_h = GC_RESOLUTION_WIDTH; + overscan_h_l = GC_RESOLUTION_SMS_OVERSCAN_H_284_L; + overscan_total_width = overscan_content_h + overscan_h_l + GC_RESOLUTION_SMS_OVERSCAN_H_284_R; } for (int i = 0, j = 0; j < buffer_size; j += 2) @@ -624,7 +638,7 @@ void Video::Render16bit(u16* srcFrameBuffer, u8* dstFrameBuffer, GC_Color_Format 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) @@ -717,7 +731,7 @@ Video::Overscan Video::GetOverscan() void Video::SaveState(std::ostream& stream) { - stream.write(reinterpret_cast (m_pInfoBuffer), GC_RESOLUTION_MAX_WIDTH * GC_LINES_PER_FRAME_PAL); + stream.write(reinterpret_cast (m_pInfoBuffer), GC_RESOLUTION_WIDTH * GC_LINES_PER_FRAME_PAL); stream.write(reinterpret_cast (m_pVdpVRAM), 0x4000); stream.write(reinterpret_cast (&m_bFirstByteInSequence), sizeof(m_bFirstByteInSequence)); stream.write(reinterpret_cast (m_VdpRegister), sizeof(m_VdpRegister)); @@ -737,7 +751,7 @@ void Video::SaveState(std::ostream& stream) void Video::LoadState(std::istream& stream) { - stream.read(reinterpret_cast (m_pInfoBuffer), GC_RESOLUTION_MAX_WIDTH * GC_LINES_PER_FRAME_PAL); + stream.read(reinterpret_cast (m_pInfoBuffer), GC_RESOLUTION_WIDTH * GC_LINES_PER_FRAME_PAL); stream.read(reinterpret_cast (m_pVdpVRAM), 0x4000); stream.read(reinterpret_cast (&m_bFirstByteInSequence), sizeof(m_bFirstByteInSequence)); stream.read(reinterpret_cast (m_VdpRegister), sizeof(m_VdpRegister)); diff --git a/src/Video.h b/src/Video.h index b807b85..ffd4418 100644 --- a/src/Video.h +++ b/src/Video.h @@ -32,7 +32,8 @@ class Video { OverscanDisabled, OverscanTopBottom, - OverscanFull + OverscanFull284, + OverscanFull320 }; public: diff --git a/src/definitions.h b/src/definitions.h index 4395764..2369caa 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -89,12 +89,15 @@ typedef void (*RamChangedCallback) (void); #define FLAG_SIGN 0x80 #define FLAG_NONE 0 -#define GC_RESOLUTION_MAX_WIDTH 256 -#define GC_RESOLUTION_MAX_HEIGHT 192 - -#define GC_RESOLUTION_MAX_WIDTH_WITH_OVERSCAN 320 -#define GC_RESOLUTION_MAX_HEIGHT_WITH_OVERSCAN 288 -#define GC_RESOLUTION_OVERSCAN_H 32 +#define GC_RESOLUTION_WIDTH 256 +#define GC_RESOLUTION_HEIGHT 192 + +#define GC_RESOLUTION_WIDTH_WITH_OVERSCAN 320 +#define GC_RESOLUTION_HEIGHT_WITH_OVERSCAN 288 +#define GC_RESOLUTION_SMS_OVERSCAN_H_320_L 32 +#define GC_RESOLUTION_SMS_OVERSCAN_H_320_R 32 +#define GC_RESOLUTION_SMS_OVERSCAN_H_284_L 13 +#define GC_RESOLUTION_SMS_OVERSCAN_H_284_R 15 #define GC_RESOLUTION_OVERSCAN_V 24 #define GC_RESOLUTION_OVERSCAN_V_PAL 48