diff segacd.c @ 2104:ff32a90260c9

Initial support for using debugger on sub CPU
author Michael Pavone <pavone@retrodev.com>
date Fri, 11 Feb 2022 23:21:10 -0800
parents b92c998c6742
children d2989e32c026
line wrap: on
line diff
--- a/segacd.c	Fri Feb 11 22:55:01 2022 -0800
+++ b/segacd.c	Fri Feb 11 23:21:10 2022 -0800
@@ -3,6 +3,8 @@
 #include "cd_graphics.h"
 #include "genesis.h"
 #include "util.h"
+#include "debug.h"
+#include "gdb_remote.h"
 
 #define SCD_MCLKS 50000000
 #define SCD_PERIPH_RESET_CLKS (SCD_MCLKS / 10)
@@ -875,8 +877,13 @@
 {
 	segacd_context *cd = context->system;
 	scd_peripherals_run(cd, context->current_cycle);
-	if (context->int_ack) {
-		printf("int ack %d\n", context->int_ack);
+	if (address && cd->enter_debugger) {
+		genesis_context *gen = cd->genesis;
+		if (gen->header.debugger_type == DEBUGGER_NATIVE) {
+			debugger(context, address);
+		} else {
+			gdb_debug_enter(context, address);
+		}
 	}
 	switch (context->int_ack)
 	{
@@ -907,7 +914,7 @@
 	while (cycle > cd->m68k->current_cycle) {
 		if (m68k_run) {
 			uint32_t start = cd->m68k->current_cycle;
-			cd->m68k->sync_cycle = cycle;
+			cd->m68k->sync_cycle = cd->enter_debugger ? cd->m68k->current_cycle + 1 : cycle;
 			if (cd->need_reset) {
 				cd->need_reset = 0;
 				m68k_reset(cd->m68k);