changeset 1343:033dda2d4598

Fix transition from active to inactive display
author Michael Pavone <pavone@retrodev.com>
date Thu, 04 May 2017 22:47:51 -0700
parents 4ea094d15cce
children 6372de4da179
files vdp.c vdp.h
diffstat 2 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Thu May 04 22:14:12 2017 -0700
+++ b/vdp.c	Thu May 04 22:47:51 2017 -0700
@@ -1541,6 +1541,7 @@
 			}
 		}
 	}
+	context->done_output = dst;
 	context->buf_a_off = (context->buf_a_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK;
 	context->buf_b_off = (context->buf_b_off + SCROLL_BUFFER_DRAW) & SCROLL_BUFFER_MASK;
 }
@@ -1735,6 +1736,7 @@
 			output_line = INVALID_LINE;
 		}
 		context->output = (uint32_t *)(((char *)context->fb) + context->output_pitch * output_line);
+		context->done_output = context->output;
 #ifdef DEBUG_FB_FILL
 		for (int i = 0; i < LINEBUF_SIZE; i++)
 		{
@@ -2710,8 +2712,16 @@
 			} else if (context->regs[REG_MODE_1] & BIT_MODE_4) {
 				bg_color = context->colors[CRAM_SIZE * 3 + 0x10 + (context->regs[REG_BG_COLOR] & 0xF)];
 			}
-			*(dst++) = bg_color;
-			*(dst++) = bg_color;
+			if (dst >= context->done_output) {
+				*(dst++) = bg_color;
+			} else {
+				dst++;
+			}
+			if (dst >= context->done_output) {
+				*(dst++) = bg_color;
+			} else {
+				dst++;
+			}
 			if (context->hslot == (bg_end_slot-1)) {
 				*(dst++) = bg_color;
 			}
--- a/vdp.h	Thu May 04 22:14:12 2017 -0700
+++ b/vdp.h	Thu May 04 22:47:51 2017 -0700
@@ -163,6 +163,7 @@
 	uint8_t     *linebuf;
 	//pointer to current line in framebuffer
 	uint32_t    *output;
+	uint32_t    *done_output;
 	uint32_t    *fb;
 	system_header  *system;
 	uint16_t    cram[CRAM_SIZE];