changeset 1344:6372de4da179

Fix vscroll latching when full screen vscroll is used in combination with the window plane on the left side of the screen
author Michael Pavone <pavone@retrodev.com>
date Fri, 05 May 2017 22:08:30 -0700
parents 033dda2d4598
children 696a029d09e9
files vdp.c
diffstat 1 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Thu May 04 22:47:51 2017 -0700
+++ b/vdp.c	Fri May 05 22:08:30 2017 -0700
@@ -1052,6 +1052,26 @@
 		v_offset_mask = 0x7;
 		vscroll_shift = 3;
 	}
+	//TODO: Further research on vscroll latch behavior and the "first column bug"
+	if (!column) {
+		if (context->regs[REG_MODE_3] & BIT_VSCROLL) {
+			if (context->regs[REG_MODE_4] & BIT_H40) {
+				//Based on observed behavior documented by Eke-Eke, I'm guessing the VDP
+				//ends up fetching the last value on the VSRAM bus in the H40 case
+				//getting the last latched value should be close enough for now
+				if (!vsram_off) {
+					context->vscroll_latch[0] = context->vscroll_latch[1];
+				}
+			} else {
+				//supposedly it's always forced to 0 in the H32 case
+				context->vscroll_latch[0] = context->vscroll_latch[1] = 0;
+			}
+		} else {
+			context->vscroll_latch[vsram_off] = context->vsram[vsram_off];
+		}
+	} else if (context->regs[REG_MODE_3] & BIT_VSCROLL) {
+		context->vscroll_latch[vsram_off] = context->vsram[column - 2 + vsram_off];
+	}
 	if (!vsram_off) {
 		uint16_t left_col, right_col;
 		if (context->regs[REG_WINDOW_H] & WINDOW_RIGHT) {
@@ -1106,26 +1126,6 @@
 		vscroll <<= 1;
 		vscroll |= 1;
 	}
-	//TODO: Further research on vscroll latch behavior and the "first column bug"
-	if (!column) {
-		if (context->regs[REG_MODE_3] & BIT_VSCROLL) {
-			if (context->regs[REG_MODE_4] & BIT_H40) {
-				//Based on observed behavior documented by Eke-Eke, I'm guessing the VDP
-				//ends up fetching the last value on the VSRAM bus in the H40 case
-				//getting the last latched value should be close enough for now
-				if (!vsram_off) {
-					context->vscroll_latch[0] = context->vscroll_latch[1];
-				}
-			} else {
-				//supposedly it's always forced to 0 in the H32 case
-				context->vscroll_latch[0] = context->vscroll_latch[1] = 0;
-			}
-		} else {
-			context->vscroll_latch[vsram_off] = context->vsram[vsram_off];
-		}
-	} else if (context->regs[REG_MODE_3] & BIT_VSCROLL) {
-		context->vscroll_latch[vsram_off] = context->vsram[column - 2 + vsram_off];
-	}
 	vscroll &= context->vscroll_latch[vsram_off] + line;
 	context->v_offset = vscroll & v_offset_mask;
 	//printf("%s | line %d, vsram: %d, vscroll: %d, v_offset: %d\n",(vsram_off ? "B" : "A"), line, context->vsram[context->regs[REG_MODE_3] & 0x4 ? column : 0], vscroll, context->v_offset);