diff vdp.c @ 494:8ac0eb05642c

Initial implementation of sprite overflow and sprite collision status register flags
author Mike Pavone <pavone@retrodev.com>
date Mon, 07 Oct 2013 10:02:08 -0700
parents 1f3450d1129f
children 27345a67225d
line wrap: on
line diff
--- a/vdp.c	Fri Oct 04 20:16:18 2013 -0700
+++ b/vdp.c	Mon Oct 07 10:02:08 2013 -0700
@@ -156,10 +156,16 @@
 		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)) {
+					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)) {
+					context->flags2 |= FLAG2_SPRITE_COLLIDE;
+				}
 				context->linebuf[x] = (context->vdpmem[address] & 0xF)  | d->pal_priority;
 			}
 			x += dir;
@@ -1539,6 +1545,14 @@
 	if (context->flags2 & FLAG2_VINT_PENDING) {
 		value |= 0x80;
 	}
+	if (context->flags & FLAG_DOT_OFLOW) {
+		value |= 0x40;
+	}
+	if (context->flags2 & FLAG2_SPRITE_COLLIDE) {
+		value |= 0x20;
+		//TODO: Test when this is actually cleared
+		context->flags2 &= ~FLAG2_SPRITE_COLLIDE;
+	}
 	if ((context->regs[REG_MODE_4] & BIT_INTERLACE) && context->framebuf == context->oddbuf) {
 		value |= 0x10;
 	}
@@ -1557,7 +1571,6 @@
 		value |= 0x1;
 	}
 	//printf("status read at cycle %d returned %X\n", context->cycles, value);
-	//TODO: Sprite overflow, sprite collision, odd frame flag
 	return value;
 }