changeset 1929:c7e3e3ebb64a

Fix regression in Konami games from address/cd latch changes
author Mike Pavone <pavone@retrodev.com>
date Fri, 17 Apr 2020 22:20:08 -0700
parents abc89555f2e0
children 0f135b214927
files vdp.c
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/vdp.c	Thu Apr 16 22:37:43 2020 -0700
+++ b/vdp.c	Fri Apr 17 22:20:08 2020 -0700
@@ -3695,7 +3695,13 @@
 {
 	context->flags &= ~FLAG_PENDING;
 	context->address = context->address_latch;
-	context->cd = context->cd_latch;
+	//It seems like the DMA enable bit doesn't so much enable DMA so much 
+	//as it enables changing CD5 from control port writes
+	if (context->regs[REG_MODE_2] & BIT_DMA_ENABLE) {
+		context->cd = context->cd_latch;
+	} else {
+		context->cd = (context->cd & 0x20) | (context->cd_latch & 0x1F);
+	}
 }
 
 int vdp_control_port_write(vdp_context * context, uint16_t value)
@@ -3706,10 +3712,7 @@
 	}
 	if (context->flags & FLAG_PENDING) {
 		context->address_latch = (context->address_latch & 0x3FFF) | (value << 14 & 0x1C000);
-		//It seems like the DMA enable bit doesn't so much enable DMA so much 
-		//as it enables changing CD5 from control port writes
-		uint8_t preserve = (context->regs[REG_MODE_2] & BIT_DMA_ENABLE) ? 0x3 : 0x23;
-		context->cd_latch = (context->cd_latch & preserve) | ((value >> 2) & ~preserve & 0xFF);
+		context->cd_latch = (context->cd_latch & 0x3) | ((value >> 2) & ~0x3 & 0xFF);
 		clear_pending(context);
 		//Should these be taken care of here or after the first write?
 		context->flags &= ~FLAG_READ_FETCHED;