changeset 135:a81c548cf353

Fix 68K->VDP DMA
author Mike Pavone <pavone@retrodev.com>
date Sun, 30 Dec 2012 11:54:25 -0800
parents ab50421b1b7a
children e64554246d11
files render_sdl.c vdp.c
diffstat 2 files changed, 23 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/render_sdl.c	Sun Dec 30 09:55:18 2012 -0800
+++ b/render_sdl.c	Sun Dec 30 11:54:25 2012 -0800
@@ -6,6 +6,7 @@
 
 SDL_Surface *screen;
 uint8_t render_dbg = 0;
+uint8_t debug_pal = 0;
 
 uint32_t last_frame = 0;
 
@@ -122,6 +123,12 @@
 					} else {
 						if (render_dbg == 2) {
 							gen_color = context->cram[(y/30)*8 + x/40];
+						} else if(render_dbg == 3) {
+							if (x & 1) {
+								gen_color = context->cram[ (debug_pal << 4) | (context->vdpmem[(x/8)*32 + (y/8)*32*40 + (x%8)/2 + (y%8)*4] & 0xF) ];
+							} else {
+								gen_color = context->cram[ (debug_pal << 4) | (context->vdpmem[(x/8)*32 + (y/8)*32*40 + (x%8)/2 + (y%8)*4] >> 4) ];
+							}
 						}
 						b = ((gen_color >> 8) & 0xE) * 18;
 						g = ((gen_color >> 4) & 0xE) * 18;
@@ -149,10 +156,15 @@
 		case SDL_KEYDOWN:
 			if (event.key.keysym.sym == SDLK_LEFTBRACKET) {
 				render_dbg++;
-				if (render_dbg == 3) {
+				if (render_dbg == 4) {
 					render_dbg = 0;
 				}
 				render_context(context);
+			} else if(event.key.keysym.sym ==  SDLK_RIGHTBRACKET) {
+				debug_pal++;
+				if (debug_pal == 4) {
+					debug_pal = 0;
+				}
 			}
 			break;
 		case SDL_QUIT:
@@ -189,10 +201,16 @@
 			{
 			case SDLK_LEFTBRACKET:
 				render_dbg++;
-				if (render_dbg == 3) {
+				if (render_dbg == 4) {
 					render_dbg = 0;
 				}
 				break;
+			case SDLK_RIGHTBRACKET:
+				debug_pal++;
+				if (debug_pal == 4) {
+					debug_pal = 0;
+				}
+				break;
 			case SDLK_t:
 				outfile = fopen("state.gst", "wb");
 				fwrite("GST\0\0\0\xE0\x40", 1, 8, outfile);
--- a/vdp.c	Sun Dec 30 09:55:18 2012 -0800
+++ b/vdp.c	Sun Dec 30 11:54:25 2012 -0800
@@ -225,7 +225,6 @@
 					context->vdpmem[context->address ^ 1] = context->dma_val >> 8;
 					context->flags &= ~FLAG_DMA_PROG;
 				} else {
-					context->dma_val = read_dma_value((context->regs[REG_DMASRC_H] << 16) | (context->regs[REG_DMASRC_M] << 8) | context->regs[REG_DMASRC_L]);
 					context->vdpmem[context->address] = context->dma_val;
 					context->flags |= FLAG_DMA_PROG;
 				}
@@ -284,6 +283,9 @@
 		if (!(context->flags & FLAG_DMA_PROG)) {
 			context->address += context->regs[REG_AUTOINC];
 			context->regs[REG_DMASRC_L] += 1;
+			if (!context->regs[REG_DMASRC_L]) {
+				context->regs[REG_DMASRC_M] += 1;
+			}
 			dma_len = ((context->regs[REG_DMALEN_H] << 8) | context->regs[REG_DMALEN_L]) - 1;
 			context->regs[REG_DMALEN_H] = dma_len >> 8;
 			context->regs[REG_DMALEN_L] = dma_len;