changeset 2263:a98b2d0de2f1

Fix TMS9918A first line sprite bug
author Michael Pavone <pavone@retrodev.com>
date Fri, 23 Dec 2022 09:08:47 -0800
parents bc68560b4a04
children c7781cc950e9
files vdp.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Fri Dec 23 06:23:41 2022 -0800
+++ b/vdp.c	Fri Dec 23 09:08:47 2022 -0800
@@ -4317,7 +4317,7 @@
 		line_change = LINE_CHANGE_MODE4;
 		jump_start = 147;
 		jump_dest = 233;
-		if (context->regs[REG_MODE_1] & BIT_MODE_4 || context->type != VDP_GENESIS) {
+		if ((context->regs[REG_MODE_1] & BIT_MODE_4) || context->type != VDP_GENESIS) {
 			active_line = 0x1FF;
 		} else {
 			//never active unless either mode 4 or mode 5 is turned on
@@ -4369,9 +4369,11 @@
 		if (context->hslot == buf_clear_slot) {
 			if (mode_5) {
 				context->cur_slot = max_draws;
-			} else {
+			} else if ((context->regs[REG_MODE_1] & BIT_MODE_4) || context->type == VDP_GENESIS) {
 				context->cur_slot = context->sprite_index = MAX_DRAWS_H32_MODE4-1;
 				context->sprite_draws = MAX_DRAWS_H32_MODE4;
+			} else {
+				context->sprite_draws = 0;
 			}
 			memset(context->linebuf, 0, LINEBUF_SIZE);
 		} else if (context->hslot == index_reset_slot) {
@@ -4398,11 +4400,11 @@
 			if (mode_5) {
 				bg_index = context->regs[REG_BG_COLOR] & 0x3F;
 				bg_color = context->colors[bg_index];
-			} else if (context->regs[REG_MODE_1] & BIT_MODE_4) {
+			} else if ((context->regs[REG_MODE_1] & BIT_MODE_4) || context->type != VDP_GENESIS) {
 				bg_index = 0x10 + (context->regs[REG_BG_COLOR] & 0xF);
 				bg_color = context->colors[MODE4_OFFSET + bg_index];
 			} else {
-				bg_color = render_map_color(0, 0, 0);
+				bg_color = context->colors[0];
 			}
 			if (context->done_composite) {
 				uint8_t pixel = context->compositebuf[dst-context->output];