changeset 1029:4263dc9cf86d

Fix implementation of sprite collision flag. Old implementation did not make sense.
author Michael Pavone <pavone@retrodev.com>
date Wed, 11 May 2016 22:43:18 -0700
parents 56b1748a8473
children c7c573f0229e 2c8d76280e43
files vdp.c
diffstat 1 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Wed May 11 01:15:54 2016 -0700
+++ b/vdp.c	Wed May 11 22:43:18 2016 -0700
@@ -185,18 +185,20 @@
 		//printf("Draw Slot %d of %d, Rendering sprite cell from %X to x: %d\n", context->cur_slot, context->sprite_draws, d->address, x);
 		context->cur_slot--;
 		for (uint16_t address = d->address; address != ((d->address+4) & 0xFFFF); address++) {
-			if (x >= 0 && x < 320 && !(context->linebuf[x] & 0xF)) {
-				if (context->linebuf[x] && (context->vdpmem[address] >> 4)) {
+			if (x >= 0 && x < 320) {
+				if (!(context->linebuf[x] & 0xF)) {
+					context->linebuf[x] = (context->vdpmem[address] >> 4) | d->pal_priority;
+				} else if (context->vdpmem[address] >> 4) {
 					context->flags2 |= FLAG2_SPRITE_COLLIDE;
 				}
-				context->linebuf[x] = (context->vdpmem[address] >> 4) | d->pal_priority;
 			}
 			x += dir;
-			if (x >= 0 && x < 320 && !(context->linebuf[x] & 0xF)) {
-				if (context->linebuf[x] && (context->vdpmem[address] & 0xF)) {
+			if (x >= 0 && x < 320) {
+				if (!(context->linebuf[x] & 0xF)) {
+					context->linebuf[x] = (context->vdpmem[address] & 0xF)  | d->pal_priority;
+				} else if (context->vdpmem[address] & 0xF) {
 					context->flags2 |= FLAG2_SPRITE_COLLIDE;
 				}
-				context->linebuf[x] = (context->vdpmem[address] & 0xF)  | d->pal_priority;
 			}
 			x += dir;
 		}