changeset 415:8c60c8c09a0f

Fix sprite y mask in interlace mode. Fix framebuffer selection when switching out of interlace mode.
author Mike Pavone <pavone@retrodev.com>
date Sun, 23 Jun 2013 10:17:40 -0700
parents 51ee0f117365
children 29c1a0dcf683
files render_sdl.c vdp.c
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/render_sdl.c	Sun Jun 23 09:17:19 2013 -0700
+++ b/render_sdl.c	Sun Jun 23 10:17:40 2013 -0700
@@ -231,20 +231,20 @@
 						switch(gen_color & FBUF_SRC_MASK)
 						{
 						case FBUF_SRC_A:
-							g = 127;
+							g = 127;//plane a = green
 							break;
 						case FBUF_SRC_W:
-							g = 127;
+							g = 127;//window = cyan
 							b = 127;
 							break;
 						case FBUF_SRC_B:
-							b = 127;
+							b = 127;//plane b = blue
 							break;
 						case FBUF_SRC_S:
-							r = 127;
+							r = 127;//sprite = red
 							break;
 						case FBUF_SRC_BG:
-							r = 127;
+							r = 127;//BG = purple
 							b = 127;
 						}
 						if (gen_color & FBUF_BIT_PRIORITY) {
--- a/vdp.c	Sun Jun 23 09:17:19 2013 -0700
+++ b/vdp.c	Sun Jun 23 10:17:40 2013 -0700
@@ -168,7 +168,7 @@
 		uint16_t sat_address = (context->regs[REG_SAT] & 0x7F) << 9;
 		uint16_t address = context->sprite_index * 8 + sat_address;
 		line += ymin;
-		uint16_t y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]) & 0x1FF;
+		uint16_t y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]) & ymask;
 		uint8_t height = ((context->vdpmem[address+2] & 0x3) + 1) * height_mult;
 		//printf("Sprite %d | y: %d, height: %d\n", context->sprite_index, y, height);
 		if (y <= line && line < (y + height)) {
@@ -181,7 +181,7 @@
 		if (context->sprite_index && context->slot_counter)
 		{
 			address = context->sprite_index * 8 + sat_address;
-			y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]) & 0x1FF;
+			y = ((context->vdpmem[address] & 0x3) << 8 | context->vdpmem[address+1]) & ymask;
 			height = ((context->vdpmem[address+2] & 0x3) + 1) * height_mult;
 			//printf("Sprite %d | y: %d, height: %d\n", context->sprite_index, y, height);
 			if (y <= line && line < (y + height)) {
@@ -1350,6 +1350,9 @@
 				}
 				if (reg == REG_MODE_4) {
 					context->double_res = (value & (BIT_INTERLACE | BIT_DOUBLE_RES)) == (BIT_INTERLACE | BIT_DOUBLE_RES);
+					if (!context->double_res) {
+						context->framebuf = context->oddbuf;
+					}
 				}
 			}
 		} else {