changeset 2513:61645edbe30f

Fix TMS9918A sprite zooming and early clock flag
author Michael Pavone <pavone@retrodev.com>
date Fri, 30 Aug 2024 21:16:46 -0700
parents 9df8dec435b7
children 50cff4c9286e
files vdp.c
diffstat 1 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Thu Aug 29 22:14:33 2024 -0700
+++ b/vdp.c	Fri Aug 30 21:16:46 2024 -0700
@@ -3836,6 +3836,9 @@
 	address = context->vdpmem[mode4_address_map[address] ^ 1] << 3;
 	address |= context->regs[REG_STILE_BASE] << 11 & 0x3800;
 	uint8_t diff = context->vcounter + 1 - context->sprite_info_list[context->sprite_index].y;
+	if (context->regs[REG_MODE_2] & BIT_SPRITE_ZM) {
+		diff >>= 1;
+	}
 	address += diff;
 	context->sprite_draw_list[context->sprite_index].address = address;
 }
@@ -3897,7 +3900,9 @@
 					output = context->sprite_draw_list[i].pal_priority;
 				}
 			}
-			context->sprite_draw_list[i].address <<= 1;
+			if (!(context->regs[REG_MODE_2] & BIT_SPRITE_SZ) || ((x - context->sprite_draw_list[i].x_pos) & 1)) {
+				context->sprite_draw_list[i].address <<= 1;
+			}
 		}
 	}
 	return output;
@@ -4055,7 +4060,12 @@
 
 #define TMS_SPRITE_SCAN_SLOT(slot) \
 	case slot:\
-		if (context->hslot >= (520 - BORDER_LEFT) / 2) { tms_border(context); }\
+		if (context->hslot >= (520 - BORDER_LEFT) / 2) {\
+			tms_border(context);\
+		} else {\
+			tms_sprite_clock(context, 0);\
+			tms_sprite_clock(context, 1);\
+		}\
 		tms_sprite_scan(context);\
 		TMS_CHECK_LIMIT