diff debug.c @ 799:0b692b5d154b

Merge
author Michael Pavone <pavone@retrodev.com>
date Sun, 26 Jul 2015 13:25:31 -0700
parents 792be135d3af
children cc05444a4a4e
line wrap: on
line diff
--- a/debug.c	Sun Jul 26 13:08:22 2015 -0700
+++ b/debug.c	Sun Jul 26 13:25:31 2015 -0700
@@ -7,6 +7,8 @@
 #include <sys/select.h>
 #endif
 #include "render.h"
+#include "util.h"
+#include "terminal.h"
 
 static bp_def * breakpoints = NULL;
 static bp_def * zbreakpoints = NULL;
@@ -286,6 +288,7 @@
 	static uint16_t branch_t;
 	static uint16_t branch_f;
 	z80inst inst;
+	init_terminal();
 	//Check if this is a user set breakpoint, or just a temporary one
 	bp_def ** this_bp = find_breakpoint(&zbreakpoints, address);
 	if (*this_bp) {
@@ -298,15 +301,12 @@
 		pc = z80_ram + (address & 0x1FFF);
 	} else if (address >= 0x8000) {
 		if (context->bank_reg < (0x400000 >> 15)) {
-			fprintf(stderr, "Entered Z80 debugger in banked memory address %X, which is not yet supported\n", address);
-			exit(1);
+			fatal_error("Entered Z80 debugger in banked memory address %X, which is not yet supported\n", address);
 		} else {
-			fprintf(stderr, "Entered Z80 debugger in banked memory address %X, but the bank is not pointed to a cartridge address\n", address);
-			exit(1);
+			fatal_error("Entered Z80 debugger in banked memory address %X, but the bank is not pointed to a cartridge address\n", address);
 		}
 	} else {
-		fprintf(stderr, "Entered Z80 debugger at address %X\n", address);
-		exit(1);
+		fatal_error("Entered Z80 debugger at address %X\n", address);
 	}
 	for (disp_def * cur = zdisplays; cur; cur = cur->next) {
 		zdebugger_print(context, cur->format_char, cur->param);
@@ -475,6 +475,9 @@
 	static uint32_t branch_t;
 	static uint32_t branch_f;
 	m68kinst inst;
+	
+	init_terminal();
+	
 	sync_components(context, 0);
 	//probably not necessary, but let's play it safe
 	address &= 0xFFFFFF;
@@ -504,8 +507,7 @@
 	} else if(address > 0xE00000) {
 		pc = ram + (address & 0xFFFF)/2;
 	} else {
-		fprintf(stderr, "Entered 68K debugger at address %X\n", address);
-		exit(1);
+		fatal_error("Entered 68K debugger at address %X\n", address);
 	}
 	uint16_t * after_pc = m68k_decode(pc, &inst, address);
 	m68k_disasm(&inst, input_buf);