changeset 1273:6dedaa645843

Fix graphical corruption and sprite flickering introduced into some games by the last change for horizontal border support
author Michael Pavone <pavone@retrodev.com>
date Thu, 09 Mar 2017 19:23:24 -0800
parents be509813b2f2
children 779920729249
files vdp.c
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Tue Mar 07 20:17:12 2017 -0800
+++ b/vdp.c	Thu Mar 09 19:23:24 2017 -0800
@@ -1497,6 +1497,7 @@
 	} else if (context->vcounter == 0xDB) {
 		context->vcounter = 0x1D5;
 	}
+	context->vcounter &= 0x1FF;
 
 	if (context->vcounter > context->inactive_start) {
 		context->hint_counter = context->regs[REG_HINT];
@@ -1517,7 +1518,7 @@
 		}
 		context->vcounter &= 0x1FF;
 	} else {
-		if (context->vcounter == context->inactive_start) {
+		if (context->vcounter == (context->inactive_start & 0x1FF)) {
 			render_framebuffer_updated(context->flags2 & FLAG2_EVEN_FIELD ? FRAMEBUFFER_EVEN: FRAMEBUFFER_ODD, context->h40_lines > (context->inactive_start + context->border_top) / 2 ? LINEBUF_SIZE : (256+HORIZ_BORDER));
 			if (context->double_res) {
 				context->flags2 ^= FLAG2_EVEN_FIELD;
@@ -1526,7 +1527,6 @@
 			context->h40_lines = 0;
 			context->frame++;
 		}
-		context->vcounter &= 0x1FF;
 		uint32_t output_line;
 		if (context->vcounter < context->inactive_start + context->border_bot) {
 			output_line = context->border_top + context->vcounter;