changeset 2127:1bf30397dd45

Fix one more test in mcd-verificator CDC DMA1
author Michael Pavone <pavone@retrodev.com>
date Sat, 12 Mar 2022 22:54:41 -0800
parents da1fae7d5407
children b0dcf5c9f353
files segacd.c
diffstat 1 files changed, 10 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/segacd.c	Fri Mar 11 22:41:04 2022 -0800
+++ b/segacd.c	Sat Mar 12 22:54:41 2022 -0800
@@ -332,11 +332,19 @@
 	return vcontext;
 }
 
+static void cdd_run(segacd_context *cd, uint32_t cycle)
+{
+	cdd_mcu_run(&cd->cdd, cycle, cd->gate_array + GA_CDD_CTRL, &cd->cdc, &cd->fader);
+	lc8951_run(&cd->cdc, cycle);
+}
+
 static uint8_t pcm_read8(uint32_t address, void *vcontext)
 {
 	m68k_context *m68k = vcontext;
 	segacd_context *cd = m68k->system;
 	if (address & 1) {
+		//need to run CD drive because there may be a PCM DMA underway
+		cdd_run(cd, m68k->current_cycle);
 		rf5c164_run(&cd->pcm, m68k->current_cycle);
 		return rf5c164_read(&cd->pcm, address >> 1);
 	} else {
@@ -354,6 +362,8 @@
 	m68k_context *m68k = vcontext;
 	segacd_context *cd = m68k->system;
 	if (address & 1) {
+		//need to run CD drive because there may be a PCM DMA underway
+		cdd_run(cd, m68k->current_cycle);
 		rf5c164_run(&cd->pcm, m68k->current_cycle);
 		rf5c164_write(&cd->pcm, address >> 1, value);
 	}
@@ -392,12 +402,6 @@
 	}
 }
 
-static void cdd_run(segacd_context *cd, uint32_t cycle)
-{
-	cdd_mcu_run(&cd->cdd, cycle, cd->gate_array + GA_CDD_CTRL, &cd->cdc, &cd->fader);
-	lc8951_run(&cd->cdc, cycle);
-}
-
 static uint32_t next_timer_int(segacd_context *cd)
 {
 	if (cd->timer_pending) {