From 21e263dd25e89210f95dae83e08a025d73e4f707 Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Fri, 30 Jul 2010 21:26:06 +0000 Subject: [PATCH] improved 2-cell vscroll emulation accuracy (fixes Cutie Suzuki no Ringside Angel left-most column) --- HISTORY.txt | 1 + source/render.c | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/HISTORY.txt b/HISTORY.txt index d0ca011..178c4a9 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -28,6 +28,7 @@ of samples per frame and keeping PSG & FM chips in sync. * added support for some undocumented mode register bits * added proper emulation of HV Counter latch: fixes Sunset Riders intro * added pixel-accurate emulation of mid-line display on/off (Nigel Mansell World Championship PAL, Ren & Stimpy's Invention PAL,...) +* improved 2-cell vscroll emulation accuracy (left-most column in Gynoug, Cutie Suzuki no Ringside Angel, Formula One, Kawasaki Superbike Challenge) * improved FIFO timings accuracy: fixes Sol Deace intro * improved sprite masking accuracy (thanks to Nemesis for his test program) * improved sprites processing accuracy: fixes (un)masked sprites in Mickey Mania (3D level), Sonic 2 (VS mode). diff --git a/source/render.c b/source/render.c index 11f9e5b..7d14a1d 100644 --- a/source/render.c +++ b/source/render.c @@ -1083,8 +1083,15 @@ static void render_bg_vs(int line, int width) if(shift) { dst = (uint32 *)&buf[0x10 + shift]; - nt = (uint32 *)&vram[ntbb + (((line >> 3) << pf_shift) & 0x1FC0)]; - v_line = (line & 7) << 3; + +#ifdef LSB_FIRST + v_line = (line + (vs[19] & 0x3FF)) & pf_row_mask; +#else + v_line = (line + ((vs[19] >> 16) & 0x3FF)) & pf_row_mask; +#endif + + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)]; + v_line = (v_line & 7) << 3; atbuf = nt[(index-1) & pf_col_mask]; DRAW_COLUMN(atbuf, v_line) @@ -1145,8 +1152,14 @@ static void render_bg_vs(int line, int width) if(shift) { dst = (uint32 *)&buf[0x10 + shift + (start<<4)]; - nt = (uint32 *)&vram[ntab + (((line >> 3) << pf_shift) & 0x1FC0)]; - v_line = (line & 7) << 3; + +#ifdef LSB_FIRST + v_line = (line + ((vs[19] >> 16) & 0x3FF)) & pf_row_mask; +#else + v_line = (line + (vs[19] & 0x3FF)) & pf_row_mask; +#endif + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & 0x1FC0)]; + v_line = (v_line & 7) << 3; /* Window bug */ if (start) atbuf = nt[index & pf_col_mask]; @@ -1343,8 +1356,14 @@ static void render_bg_im2_vs(int line, int width, int odd) if(shift) { dst = (uint32 *)&buf[0x10 + shift]; - nt = (uint32 *)&vram[ntbb + (((line >> 3) << pf_shift) & 0x1FC0)]; - v_line = (((line & 7) << 1) | odd) << 3; + +#ifdef LSB_FIRST + v_line = (line + ((vs[19] >> 1) & 0x3FF)) & pf_row_mask; +#else + v_line = (line + ((vs[19] >> 17) & 0x3FF)) & pf_row_mask; +#endif + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)]; + v_line = (((v_line & 7) << 1) | odd) << 3; atbuf = nt[(index-1) & pf_col_mask]; DRAW_COLUMN_IM2(atbuf, v_line) @@ -1403,8 +1422,14 @@ static void render_bg_im2_vs(int line, int width, int odd) if(shift) { dst = (uint32 *)&buf[0x10 + shift + (start<<4)]; - nt = (uint32 *)&vram[ntab + (((line >> 3) << pf_shift) & 0x1FC0)]; - v_line = (((line & 7) << 1) | odd) << 3; + +#ifdef LSB_FIRST + v_line = (line + ((vs[19] >> 17) & 0x3FF)) & pf_row_mask; +#else + v_line = (line + ((vs[19] >> 1) & 0x3FF)) & pf_row_mask; +#endif + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & 0x1FC0)]; + v_line = (((v_line & 7) << 1) | odd) << 3; /* Window bug */ if (start) atbuf = nt[index & pf_col_mask];