diff vdp.c @ 131:8fc8e46be691

Fix bug that was causing DMA fills to lock up under certain circumstances
author Mike Pavone <pavone@retrodev.com>
date Sun, 30 Dec 2012 01:15:16 -0800
parents 004dd46e0a97
children a81c548cf353
line wrap: on
line diff
--- a/vdp.c	Sun Dec 30 00:11:03 2012 -0800
+++ b/vdp.c	Sun Dec 30 01:15:16 2012 -0800
@@ -191,7 +191,7 @@
 		//68K -> VDP
 		case 0:
 		case 0x40:
-			switch(context->cd & 0xF)
+			switch(context->dma_cd & 0xF)
 			{
 			case VRAM_WRITE:
 				if (context->flags & FLAG_DMA_PROG) {
@@ -215,7 +215,7 @@
 			break;
 		//Fill
 		case 0x80:
-			switch(context->cd & 0xF)
+			switch(context->dma_cd & 0xF)
 			{
 			case VRAM_WRITE:
 				//Charles MacDonald's VDP doc says that the low byte gets written first
@@ -243,7 +243,7 @@
 		//Copy
 		case 0xC0:
 			if (context->flags & FLAG_DMA_PROG) {
-				switch(context->cd & 0xF)
+				switch(context->dma_cd & 0xF)
 				{
 				case VRAM_WRITE:
 					context->vdpmem[context->address] = context->dma_val;
@@ -261,7 +261,7 @@
 			} else {
 				//I assume, that DMA copy copies from the same RAM as the destination
 				//but it's possible I'm mistaken
-				switch(context->cd & 0xF)
+				switch(context->dma_cd & 0xF)
 				{
 				case VRAM_WRITE:
 					context->dma_val = context->vdpmem[(context->regs[REG_DMASRC_M] << 8) | context->regs[REG_DMASRC_L]];
@@ -297,6 +297,7 @@
 			if ((context->regs[REG_MODE_2] & BIT_DMA_ENABLE) && (context->cd & DMA_START)) {
 				context->flags |= FLAG_DMA_RUN;
 				context->dma_val = start->value;
+				context->dma_cd = context->cd;
 			} else {
 				switch (context->cd & 0xF)
 				{
@@ -1034,6 +1035,7 @@
 			if((context->regs[REG_DMASRC_H] & 0xC0) != 0x80) {
 				//DMA copy or 68K -> VDP, transfer starts immediately
 				context->flags |= FLAG_DMA_RUN;
+				context->dma_cd = context->cd;
 				if (!(context->regs[REG_DMASRC_H] & 0x80)) {
 					return 1;
 				}