changeset 1185:9de9d2c6ebe5

Fix border rendering at end of line 1FE. vdp_inactive will probably need a small fixup for the edge case when we start between when the vcounter is incremented and the line is truly finished.
author Michael Pavone <pavone@retrodev.com>
date Thu, 19 Jan 2017 09:32:34 -0800
parents b1147418254a
children 110251ea369e
files vdp.c
diffstat 1 files changed, 68 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Wed Jan 18 23:43:36 2017 -0800
+++ b/vdp.c	Thu Jan 19 09:32:34 2017 -0800
@@ -1677,6 +1677,16 @@
 	{
 	case 165:
 		if (context->vcounter == 0x1FF) {
+			uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F];
+			uint32_t *dst;
+			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++) = bg_color;
+			*dst = bg_color;
 			external_slot(context);
 		} else {
 			render_sprite_cells(context);
@@ -1684,6 +1694,16 @@
 		CHECK_LIMIT
 	case 166:
 		if (context->vcounter == 0x1FF) {
+			uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F];
+			uint32_t *dst;
+			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++) = bg_color;
+			*dst = bg_color;
 			external_slot(context);
 		} else {
 			render_sprite_cells(context);
@@ -1691,6 +1711,20 @@
 		CHECK_LIMIT
 	//sprite attribute table scan starts
 	case 167:
+		if (context->vcounter == 0x1FF) {
+			uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F];
+			uint32_t *dst;
+			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++) = bg_color;
+			*(dst++) = bg_color;
+			*(dst++) = bg_color;
+			*dst = bg_color;
+		}
 		context->sprite_index = 0x80;
 		context->slot_counter = MAX_SPRITES_LINE;
 		render_sprite_cells( context);
@@ -1844,6 +1878,16 @@
 	{
 	case 133:
 		if (context->vcounter == 0x1FF) {
+			uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F];
+			uint32_t *dst;
+			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++) = bg_color;
+			*dst = bg_color;
 			external_slot(context);
 		} else {
 			render_sprite_cells(context);
@@ -1851,6 +1895,16 @@
 		CHECK_LIMIT
 	case 134:
 		if (context->vcounter == 0x1FF) {
+			uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F];
+			uint32_t *dst;
+			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++) = bg_color;
+			*dst = bg_color;
 			external_slot(context);
 		} else {
 			render_sprite_cells(context);
@@ -1858,6 +1912,20 @@
 		CHECK_LIMIT
 	//sprite attribute table scan starts
 	case 135: //FIXME - Here
+		if (context->vcounter == 0x1FF) {
+			uint32_t bg_color = context->colors[context->regs[REG_BG_COLOR] & 0x3F];
+			uint32_t *dst;
+			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++) = bg_color;
+			*(dst++) = bg_color;
+			*(dst++) = bg_color;
+			*dst = bg_color;
+		}
 		context->sprite_index = 0x80;
 		context->slot_counter = MAX_SPRITES_LINE_H32;
 		render_sprite_cells( context);