From 381a9d114f057c570618c288db257b8eb2d6393c Mon Sep 17 00:00:00 2001 From: EkeEke Date: Sun, 1 May 2016 20:10:37 +0200 Subject: [PATCH] [Core/VDP] fixed issues caused by screen width change during active display (Golden Axe 3 intro, Ultraverse Prime) --- core/system.c | 11 ++++++++++- core/vdp_ctrl.c | 31 +++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/core/system.c b/core/system.c index e6b4e20..97c3ebf 100644 --- a/core/system.c +++ b/core/system.c @@ -423,6 +423,9 @@ void system_frame_gen(int do_skip) bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1); } + /* active screen width */ + bitmap.viewport.w = 256 + ((reg[12] & 0x01) << 6); + /* check viewport changes */ if (bitmap.viewport.h != bitmap.viewport.oh) { @@ -792,6 +795,9 @@ void system_frame_scd(int do_skip) bitmap.viewport.y = (config.overscan & 1) * 24 * (vdp_pal + 1); } + /* active screen width */ + bitmap.viewport.w = 256 + ((reg[12] & 0x01) << 6); + /* check viewport changes */ if (bitmap.viewport.h != bitmap.viewport.oh) { @@ -1180,7 +1186,10 @@ void system_frame_sms(int do_skip) } } } - + + /* active screen width */ + bitmap.viewport.w = 256 + ((reg[12] & 0x01) << 6); + /* check viewport changes */ if (bitmap.viewport.h != bitmap.viewport.oh) { diff --git a/core/vdp_ctrl.c b/core/vdp_ctrl.c index 9cdbf80..50d43d6 100644 --- a/core/vdp_ctrl.c +++ b/core/vdp_ctrl.c @@ -1932,8 +1932,8 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) /* Update clipping */ window_clip(reg[17], 1); - /* Update active display width & max sprite pixels per line*/ - max_sprite_pixels = bitmap.viewport.w = 320; + /* Update max sprite pixels per line*/ + max_sprite_pixels = 320; } else { @@ -1949,15 +1949,30 @@ static void vdp_reg_w(unsigned int r, unsigned int d, unsigned int cycles) /* Update clipping */ window_clip(reg[17], 0); - /* Update active display width & max sprite pixels per line*/ - max_sprite_pixels = bitmap.viewport.w = 256; + /* Update max sprite pixels per line*/ + max_sprite_pixels = 256; } - /* Active display width modified during HBLANK (Bugs Bunny Double Trouble) */ - if ((v_counter < bitmap.viewport.h) && (reg[1] & 0x40) && (cycles <= (mcycles_vdp + 860))) + if (v_counter >= bitmap.viewport.h) { - /* Redraw entire line */ - render_line(v_counter); + /* Active screen width modified during VBLANK will be applied on upcoming frame */ + bitmap.viewport.w = max_sprite_pixels; + } + else if ((v_counter == 0) && (cycles <= (mcycles_vdp + 860))) + { + /* Active screen width modified during first line HBLANK (Bugs Bunny in Double Trouble) */ + bitmap.viewport.w = max_sprite_pixels; + + /* Redraw first line */ + render_line(0); + } + else + { + /* Screen width changes during active display (Golden Axe 3 intro, Ultraverse Prime) */ + /* should be applied on next frame since backend rendered framebuffer width is fixed */ + /* and can not be modified mid-frame. This is not 100% accurate but games generally */ + /* do this where the screen is blanked so it is likely unnoticeable. */ + bitmap.viewport.changed |= 2; } } break;