changeset 1338:3706b683cd48

Fix sprite rendering for negative line. Fixes remaining visual glitch in the Titancade scene of Overdrive 2
author Michael Pavone <pavone@retrodev.com>
date Mon, 01 May 2017 20:33:59 -0700
parents d092c15246a3
children 35e6a93b4586
files vdp.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Sat Apr 29 16:51:57 2017 -0700
+++ b/vdp.c	Mon May 01 20:33:59 2017 -0700
@@ -555,7 +555,6 @@
 {
 	if (context->sprite_index && ((uint8_t)context->slot_counter) < context->max_sprites_line) {
 		line += 1;
-		line &= 0xFF;
 		uint16_t ymask, ymin;
 		uint8_t height_mult;
 		if (context->double_res) {
@@ -579,6 +578,7 @@
 		}
 		uint16_t address = context->sprite_index * 4;
 		line += ymin;
+		line &= 0x1FF;
 		uint16_t y = ((context->sat_cache[address] & 0x3) << 8 | context->sat_cache[address+1]) & ymask;
 		uint8_t height = ((context->sat_cache[address+2] & 0x3) + 1) * height_mult;
 		//printf("Sprite %d | y: %d, height: %d\n", context->sprite_index, y, height);
@@ -668,7 +668,6 @@
 	if (context->cur_slot < context->slot_counter) {
 		if (context->sprite_draws) {
 			line += 1;
-			line &= 0xFF;
 			//in tiles
 			uint8_t width = ((context->sprite_info_list[context->cur_slot].size >> 2) & 0x3) + 1;
 			//in pixels
@@ -693,7 +692,8 @@
 			uint8_t pal_priority = (tileinfo >> 9) & 0x70;
 			uint8_t row;
 			uint16_t cache_addr = context->sprite_info_list[context->cur_slot].index * 4;
-			int16_t y = ((context->sat_cache[cache_addr] << 8 | context->sat_cache[cache_addr+1]) & ymask) - ymin;
+			line = (line + ymin) & 0x1FF;
+			int16_t y = ((context->sat_cache[cache_addr] << 8 | context->sat_cache[cache_addr+1]) & ymask)/* - ymin*/;
 			if (tileinfo & MAP_BIT_V_FLIP) {
 				row = (y + height - 1) - line;
 			} else {