changeset 2669:c6bc66b16392

Less broken Sega CD emulation with new 68K core
author Michael Pavone <pavone@retrodev.com>
date Sat, 08 Mar 2025 11:45:58 -0800
parents b0b6c6042103
children 9bcfdc1b56bd
files segacd.c
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/segacd.c	Sat Mar 08 11:45:25 2025 -0800
+++ b/segacd.c	Sat Mar 08 11:45:58 2025 -0800
@@ -17,6 +17,10 @@
 #define REFRESH_INTERVAL 259
 #define REFRESH_DELAY 2
 
+#ifdef NEW_CORE
+#define int_num int_priority
+#endif
+
 enum {
 	GA_SUB_CPU_CTRL,
 	GA_MEM_MODE,
@@ -592,6 +596,12 @@
 		if (mask < 5) {
 			if (cd->gate_array[GA_INT_MASK] & BIT_MASK_IEN5) {
 				cdc_cycle = lc8951_next_interrupt(&cd->cdc);
+#ifdef NEW_CORE
+				//should this maybe happen with the old core too?
+				if (cdc_cycle == cd->cdc.cycle) {
+					cdc_cycle = context->cycles;
+				}
+#endif
 				//CDC interrupts only generated on falling edge of !INT signal
 				if (cd->cdc_int_ack) {
 					if (cdc_cycle > cd->cdc.cycle) {
@@ -643,11 +653,11 @@
 	}
 	if (context->cycles >= context->sync_cycle) {
 		context->should_return = 1;
-		context->target_cycle = context->cycles;
+		context->target_cycle = context->cycles + 1;
 		return;
 	}
 	if (context->status & M68K_STATUS_TRACE || context->trace_pending) {
-		context->target_cycle = context->cycles;
+		context->target_cycle = context->cycles + 1;
 		return;
 	}
 	context->target_cycle = context->sync_cycle < context->int_cycle ? context->sync_cycle : context->int_cycle;
@@ -662,6 +672,9 @@
 			}
 		}
 	}
+	if (context->target_cycle <= context->cycles) {
+		context->target_cycle = context->cycles + 1;
+	}
 }
 
 static uint16_t sub_gate_read16(uint32_t address, void *vcontext)