changeset 1361:1679ea04c449

WIP attempt at fixing the minor line -2 glitch in the OD2 Ninja Escape scene
author Michael Pavone <pavone@retrodev.com>
date Sun, 14 May 2017 11:15:56 -0700
parents e1a6e8ee656f
children 83bdd358f3a7
files vdp.c
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Fri May 12 23:34:17 2017 -0700
+++ b/vdp.c	Sun May 14 11:15:56 2017 -0700
@@ -2057,12 +2057,13 @@
 			if (headless) {
 				dst = context->output;
 			} else {
-				dst = ((uint32_t *)(((char *)context->fb) + context->output_pitch * (context->border_top - 2)))
-					+ (context->hslot - BG_START_SLOT) * 2;
+				dst = context->output + (context->hslot - BG_START_SLOT) * 2;
 			}
-			for (int i = 0; i < LINEBUF_SIZE - 2 * (context->hslot - BG_START_SLOT); i++)
+			for (int i = 0; i < LINEBUF_SIZE - 2 * (context->hslot - BG_START_SLOT); i++, dst++)
 			{
-				*(dst++) = bg_color;
+				if (dst >= context->done_output) {
+					*dst = bg_color;
+				}
 			}
 		}
 		context->sprite_index = 0x80;
@@ -2720,11 +2721,13 @@
 			}
 			if (dst >= context->done_output) {
 				*(dst++) = bg_color;
+				context->done_output = dst;
 			} else {
 				dst++;
 			}
 			if (context->hslot == (bg_end_slot-1)) {
 				*(dst++) = bg_color;
+				context->done_output = dst;
 			}
 		}
 		
@@ -2912,6 +2915,9 @@
 				if (reg == REG_BG_COLOR) {
 					value &= 0x3F;
 				}
+				if (reg == REG_MODE_2 && ((value ^ context->regs[reg]) & BIT_DISP_EN)) {
+					printf("Display %s at %d, %d, %d\n", value & BIT_DISP_EN ? "enabled" : "disabled", context->frame, context->vcounter, context->hslot);
+				}
 				/*if (reg == REG_MODE_4 && ((value ^ context->regs[reg]) & BIT_H40)) {
 					printf("Mode changed from H%d to H%d @ %d, frame: %d\n", context->regs[reg] & BIT_H40 ? 40 : 32, value & BIT_H40 ? 40 : 32, context->cycles, context->frame);
 				}*/