From b91e37eb86db5083efc8871bbfd782d67d3738bc Mon Sep 17 00:00:00 2001 From: ds22x Date: Sun, 3 Oct 2021 15:24:42 +0200 Subject: [PATCH] Fix some issues with the dynamic overscan cropping --- mednafen/psx/gpu.cpp | 7 ++++++- parallel-psx/renderer/renderer.cpp | 8 +++++++- rsx/rsx_lib_gl.cpp | 9 ++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mednafen/psx/gpu.cpp b/mednafen/psx/gpu.cpp index 11387149..ab7214fa 100644 --- a/mednafen/psx/gpu.cpp +++ b/mednafen/psx/gpu.cpp @@ -1676,7 +1676,12 @@ int32_t GPU_Update(const int32_t sys_timestamp) && GPU.scanline < (FirstVisibleLine + VisibleLineCount)) { int32 fb_x = GPU.DisplayFB_XStart * 2; - int32 dx_start = (crop_overscan ? 608 : GPU.HorizStart), dx_end = GPU.HorizEnd; + // Restore old center behaviour if GPU.HorizStart is intentionally very high. + // 938 fixes Gunbird (1008) and Mobile Light Force (EU release of Gunbird), + // but this value should be lowered in the future if necessary. + // Additionally cut off everything after GPU.HorizEnd that shouldn't be + // in the viewport (the hardware renderers already takes care of this). + int32 dx_start = (crop_overscan && GPU.HorizStart < 938 ? 608 : GPU.HorizStart), dx_end = (crop_overscan && GPU.HorizStart < 938 ? GPU.HorizEnd - GPU.HorizStart + 608 : GPU.HorizEnd - (GPU.HorizStart < 938 ? 0 : 1)); int32 dest_line = ((GPU.scanline - FirstVisibleLine) << GPU.espec->InterlaceOn) + GPU.espec->InterlaceField; diff --git a/parallel-psx/renderer/renderer.cpp b/parallel-psx/renderer/renderer.cpp index 0f35a084..96a8d8db 100644 --- a/parallel-psx/renderer/renderer.cpp +++ b/parallel-psx/renderer/renderer.cpp @@ -794,8 +794,14 @@ Renderer::DisplayRect Renderer::compute_display_rect() if (render_state.crop_overscan) { // Horizontal crop amount is currently hardcoded. Future improvement could allow adjusting this. + // Restore old center behaviour is render_state.horiz_start is intentionally very high. + // 938 fixes Gunbird (1008) and Mobile Light Force (EU release of Gunbird), + // but this value should be lowerer in the future if necessary. display_width = (2560/clock_div) - render_state.image_crop; - left_offset = floor((render_state.offset_cycles / (double) clock_div) - (render_state.image_crop / 2)); + if (render_state.horiz_start < 938) + left_offset = floor((render_state.offset_cycles / (double) clock_div) - (render_state.image_crop / 2)); + else + left_offset = floor(((render_state.horiz_start + render_state.offset_cycles - 608) / (double) clock_div) - (render_state.image_crop / 2)); } else { diff --git a/rsx/rsx_lib_gl.cpp b/rsx/rsx_lib_gl.cpp index 95a02b5b..cbf61719 100644 --- a/rsx/rsx_lib_gl.cpp +++ b/rsx/rsx_lib_gl.cpp @@ -1586,7 +1586,14 @@ static GlDisplayRect compute_gl_display_rect(GlRenderer *renderer) { width = (uint32_t) ((2560/clock_div) - renderer->image_crop); int32_t offset_cycles = renderer->image_offset_cycles; - x = floor((offset_cycles / (double) clock_div) - (renderer->image_crop / 2)); + int32_t h_start = (int32_t) renderer->config.display_area_hrange[0]; + /* Restore old center behaviour is render_state.horiz_start is intentionally very high. + * 938 fixes Gunbird (1008) and Mobile Light Force (EU release of Gunbird), + * but this value should be lowerer in the future if necessary. */ + if (renderer->config.display_area_hrange[0] < 938) + x = floor((offset_cycles / (double) clock_div) - (renderer->image_crop / 2)); + else + x = floor(((h_start - 608 + offset_cycles) / (double) clock_div) - (renderer->image_crop / 2)); } else {