changeset 2258:a28e1042f4de

Fix a few of the most glaring TMS9918A issues
author Michael Pavone <pavone@retrodev.com>
date Sun, 18 Dec 2022 15:11:30 -0800
parents 1e626d0ecf9c
children 425b44fd7bf1
files vdp.c
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Sat Dec 17 23:32:34 2022 -0800
+++ b/vdp.c	Sun Dec 18 15:11:30 2022 -0800
@@ -248,7 +248,7 @@
 						0x00, 0x00, 0x08, 0x0C, 0x10, 0x30, 0x01, 0x3C, 0x02, 0x03, 0x05, 0x0F, 0x04, 0x33, 0x15, 0x3F
 					};
 					index = tms_to_sms[index] << 1;
-					index = (index & 0xE) | (index << 1 & 0x80);
+					index = (index & 0xE) | (index << 1 & 0xE0);
 					//TODO: Mode 4 has a separate DAC tap so this isn't quite correct
 					//TODO: blue channel has one of its taps offest on SMS1 and MD
 					b = levels[(index >> 4 & 0xC) | (index >> 6 & 0x2)];
@@ -3611,7 +3611,7 @@
 		address &= 0x2000;
 		address |= context->vcounter << 5 & upper_vcounter_mask;
 		address |= context->col_1 << 3 & pattern_name_mask;
-		address |= context->vcounter & 3;
+		address |= context->vcounter & 7;
 	} else {
 		address |= context->col_1 >> 3;
 	}
@@ -3769,8 +3769,9 @@
 			if (context->sprite_draw_list[i].address & 0x8000) {
 				if (output) {
 					context->flags2 |= FLAG2_SPRITE_COLLIDE;
+				} else {
+					output = context->sprite_draw_list[i].pal_priority;
 				}
-				output = context->sprite_draw_list[i].pal_priority;
 			}
 			context->sprite_draw_list[i].address <<= 1;
 		}