changeset 1156:b519965f6394

Clear sprite overflow flag when control port read. Fix vcounter progression in Mode 4
author Michael Pavone <pavone@retrodev.com>
date Thu, 05 Jan 2017 19:15:53 -0800
parents da6a1f156f24
children d5dda22ae6b4
files vdp.c
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Thu Jan 05 00:42:11 2017 -0800
+++ b/vdp.c	Thu Jan 05 19:15:53 2017 -0800
@@ -1373,19 +1373,24 @@
 {
 	context->vcounter++;
 	context->vcounter &= 0x1FF;
-	if (context->flags2 & FLAG2_REGION_PAL) {
-		if (context->latched_mode & BIT_PAL) {
-			if (context->vcounter == 0x10B) {
-				context->vcounter = 0x1D2;
+	uint8_t is_mode_5 = context->regs[REG_MODE_2] & BIT_MODE_5;
+	if (is_mode_5) {
+		if (context->flags2 & FLAG2_REGION_PAL) {
+			if (context->latched_mode & BIT_PAL) {
+				if (context->vcounter == 0x10B) {
+					context->vcounter = 0x1D2;
+				}
+			} else if (context->vcounter == 0x103){
+				context->vcounter = 0x1CA;
 			}
-		} else if (context->vcounter == 0x103){
-			context->vcounter = 0x1CA;
+		} else if (!(context->latched_mode & BIT_PAL) &&  context->vcounter == 0xEB) {
+			context->vcounter = 0x1E5;
 		}
-	} else if (!(context->latched_mode & BIT_PAL) &&  context->vcounter == 0xEB) {
-		context->vcounter = 0x1E5;
+	} else if (context->vcounter == 0xDB) {
+		context->vcounter = 0x1D5;
 	}
 	uint32_t inactive_start = (context->latched_mode & BIT_PAL ? PAL_INACTIVE_START : NTSC_INACTIVE_START);
-	if (!(context->regs[REG_MODE_2] & BIT_MODE_5)) {
+	if (!is_mode_5) {
 		inactive_start = MODE4_INACTIVE_START;
 	}
 	if (!headless) {
@@ -2363,6 +2368,7 @@
 	}
 	if (context->flags & FLAG_DOT_OFLOW) {
 		value |= 0x40;
+		context->flags &= ~FLAG_DOT_OFLOW;
 	}
 	if (context->flags2 & FLAG2_SPRITE_COLLIDE) {
 		value |= 0x20;