changeset 2344:ae073c2167e2

Fix timing of sub CPU level 5 interrupt when main CPU is reading CDC data
author Michael Pavone <pavone@retrodev.com>
date Fri, 06 Oct 2023 00:20:18 -0700
parents 49bd818ec9d8
children c76c81c21ae5
files segacd.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/segacd.c	Sun Oct 01 23:41:19 2023 -0700
+++ b/segacd.c	Fri Oct 06 00:20:18 2023 -0700
@@ -1270,7 +1270,10 @@
 		if (dst == DST_MAIN_CPU) {
 			if (cd->gate_array[GA_CDC_CTRL] & BIT_DSR) {
 				cd->gate_array[GA_CDC_CTRL] &= ~BIT_DSR;
-				lc8951_resume_transfer(&cd->cdc, scd_cycle);
+				//Using the sub CPU's cycle count here is a bit of a hack
+				//needed to ensure the interrupt does not get triggered prematurely
+				//because the sub CPU execution granularity is too high
+				lc8951_resume_transfer(&cd->cdc, cd->m68k->current_cycle);
 			} else {
 				printf("Read of CDC host data with DSR clear at %u\n", scd_cycle);
 			}