changeset 414:51ee0f117365

Fix vscroll calculation in double resultion interlace mode
author Mike Pavone <pavone@retrodev.com>
date Sun, 23 Jun 2013 09:17:19 -0700
parents 36fbbced25c2
children 8c60c8c09a0f
files vdp.c
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Sat Jun 22 21:19:43 2013 -0700
+++ b/vdp.c	Sun Jun 23 09:17:19 2013 -0700
@@ -440,12 +440,12 @@
 
 void read_map_scroll(uint16_t column, uint16_t vsram_off, uint32_t line, uint16_t address, uint16_t hscroll_val, vdp_context * context)
 {
-	/*if (context->double_res) {
+	if (context->double_res) {
 		line *= 2;
 		if (context->framebuf != context->oddbuf) {
 			line++;
 		}
-	}*/
+	}
 	if (!vsram_off) {
 		uint16_t left_col, right_col;
 		if (context->regs[REG_WINDOW_H] & WINDOW_RIGHT) {
@@ -507,14 +507,20 @@
 		vscroll = 0x3FF;
 		break;
 	}
-	/*if (context->double_res) {
+	uint16_t v_offset_mask, vscroll_shift;
+	if (context->double_res) {
 		vscroll <<= 1;
 		vscroll |= 1;
-	}*/
+		v_offset_mask = 0xF;
+		vscroll_shift = 4;
+	} else {
+		v_offset_mask = 0x7;
+		vscroll_shift = 3;
+	}
 	vscroll &= (context->vsram[(context->regs[REG_MODE_3] & BIT_VSCROLL ? column : 0) + vsram_off] + line);
-	context->v_offset = vscroll & 0x7;
+	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);
-	vscroll /= 8;
+	vscroll >>= vscroll_shift;
 	uint16_t hscroll_mask;
 	uint16_t v_mul;
 	switch(context->regs[REG_SCROLL] & 0x3)
@@ -575,9 +581,9 @@
 		add = 0;
 	}
 	if (col & MAP_BIT_V_FLIP) {
-		address +=  28 - 4 * ((context->v_offset << shift) + add);
+		address +=  28 - 4 * context->v_offset/*((context->v_offset << shift) + add)*/;
 	} else {
-		address += 4 * ((context->v_offset << shift) + add);
+		address += 4 * context->v_offset/*((context->v_offset << shift) + add)*/;
 	}
 	uint16_t pal_priority = (col >> 9) & 0x70;
 	int32_t dir;