changeset 28:037963b4c92d

Fix BG plane B render bug
author Mike Pavone <pavone@retrodev.com>
date Sat, 08 Dec 2012 19:42:07 -0800
parents aa1c47fab3f1
children 9477d1289595
files render_sdl.c vdp.c
diffstat 2 files changed, 25 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/render_sdl.c	Sat Dec 08 16:58:11 2012 -0800
+++ b/render_sdl.c	Sat Dec 08 19:42:07 2012 -0800
@@ -73,13 +73,21 @@
         	}
         }
         for (int y = 224; y < 240; y++, buf_32 += (screen->pitch/4 - 320)) {
-        	for (int x = 0; x < 320; x++, buf_32++) {
-        		uint16_t gen_color = context->cram[x/10 + ((y-224)/8)*32];
+        	for (int x = 0; x < 256; x++, buf_32++) {
+        		uint16_t gen_color = context->cram[x/8 + ((y-224)/8)*32];
         		b = ((gen_color >> 8) & 0xE) * 18;
         		g = ((gen_color >> 4) & 0xE) * 18;
         		r = (gen_color& 0xE) * 18;
         		*buf_32 = SDL_MapRGB(screen->format, r, g, b);
         	}
+        	for (int x = 256; x < 320; x++, buf_32++) {
+        		if ((x/8 & 1) ^ (y/8 & 1)) {
+        			b = g = r = 255;
+        		} else {
+        			b = g = r = 0;
+        		}
+        		*buf_32 = SDL_MapRGB(screen->format, r, g, b);
+        	}
         }
     	break;
     }
--- a/vdp.c	Sat Dec 08 16:58:11 2012 -0800
+++ b/vdp.c	Sat Dec 08 19:42:07 2012 -0800
@@ -178,6 +178,7 @@
 		v_mul = 256;
 		break;
 	}
+	/*
 	uint16_t hscroll = (hscroll_val + (column-2) * 8) & hscroll_mask;
 	uint16_t offset = address + ((vscroll * v_mul + hscroll/4) & 0x1FFF);
 	//printf("%s | line: %d, col: %d, x: %d, hs_mask %X, v_mul: %d, scr reg: %X, tbl addr: %X\n", (vsram_off ? "B" : "A"), line, column, hscroll, hscroll_mask, v_mul, context->regs[REG_SCROLL], offset);
@@ -185,6 +186,19 @@
 	hscroll = (hscroll_val + (column-1) * 8) & hscroll_mask;
 	offset = address + ((vscroll * v_mul + hscroll/4) & 0x1FFF);
 	context->col_2 = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1];
+	*/
+	uint16_t hscroll, offset;
+	for (int i = 0; i < 2; i++) {
+		hscroll = (hscroll_val + (column-(2-i)) * 8) & hscroll_mask;
+		offset = address + ((vscroll * v_mul + hscroll/4) & 0x1FFF);
+		//printf("%s | line: %d, col: %d, x: %d, hs_mask %X, v_mul: %d, scr reg: %X, tbl addr: %X\n", (vsram_off ? "B" : "A"), line, column, hscroll, hscroll_mask, v_mul, context->regs[REG_SCROLL], offset);
+		uint16_t col_val = (context->vdpmem[offset] << 8) | context->vdpmem[offset+1];
+		if (i) {
+			context->col_2 = col_val;
+		} else {
+			context->col_1 = col_val;
+		}
+	}
 }
 
 void read_map_scroll_a(uint16_t column, uint32_t line, vdp_context * context)
@@ -288,7 +302,7 @@
 	uint16_t remaining = context->hscroll_a & 0x7;
 	memcpy(context->tmp_buf_a + 8 - remaining, context->tmp_buf_a + 24 - remaining, remaining);
 	remaining = context->hscroll_b & 0x7;
-	memcpy(context->tmp_buf_b + 8 - remaining, context->tmp_buf_a + 24 - remaining, remaining);
+	memcpy(context->tmp_buf_b + 8 - remaining, context->tmp_buf_b + 24 - remaining, remaining);
 }
 
 #define COLUMN_RENDER_BLOCK(column, startcyc) \