changeset 2564:553a0b4888db

More robust sprite overflow regression fix
author Michael Pavone <pavone@retrodev.com>
date Sun, 26 Jan 2025 01:02:18 -0800
parents f51d750b4d06
children eb588f22ec76
files vdp.c
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Sat Jan 25 23:54:13 2025 -0800
+++ b/vdp.c	Sun Jan 26 01:02:18 2025 -0800
@@ -913,8 +913,6 @@
 			context->sprite_draw_list[context->sprite_draws].width = width;
 			context->sprite_draw_list[context->sprite_draws].height = height;
 		}
-	} else if (context->sprite_draws) {
-		context->sprite_draw_list[context->sprite_draws - 1].x_pos = 0;
 	}
 	context->cur_slot++;
 }
@@ -3082,8 +3080,9 @@
 		context->col_1
 	);
 	context->flags &= ~FLAG_MASKED;
-	if (context->sprite_draws) {
-		context->sprite_draw_list[context->sprite_draws - 1].x_pos = 0;
+	while (context->sprite_draws) {
+		context->sprite_draws--;
+		context->sprite_draw_list[context->sprite_draws].x_pos = 0;
 	}
 	render_sprite_cells(context);
 	//164
@@ -3320,8 +3319,9 @@
 			context->col_1
 		);
 		context->flags &= ~FLAG_MASKED;
-		if (context->sprite_draws) {
-			context->sprite_draw_list[context->sprite_draws - 1].x_pos = 0;
+		while (context->sprite_draws) {
+			context->sprite_draws--;
+			context->sprite_draw_list[context->sprite_draws].x_pos = 0;
 		}
 		render_sprite_cells(context);
 		CHECK_LIMIT
@@ -3541,8 +3541,9 @@
 			context->col_1
 		);
 		context->flags &= ~FLAG_MASKED;
-		if (context->sprite_draws) {
-			context->sprite_draw_list[context->sprite_draws - 1].x_pos = 0;
+		while (context->sprite_draws) {
+			context->sprite_draws--;
+			context->sprite_draw_list[context->sprite_draws].x_pos = 0;
 		}
 		render_sprite_cells(context);
 		CHECK_LIMIT