From 80ff833dd8ad011b579bff26ac654819e6735bce Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sat, 25 Jul 2015 18:22:07 -0700 Subject: Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows). --- debug.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'debug.c') diff --git a/debug.c b/debug.c index 74e076b..a70f790 100644 --- a/debug.c +++ b/debug.c @@ -7,6 +7,7 @@ #include #endif #include "render.h" +#include "util.h" static bp_def * breakpoints = NULL; static bp_def * zbreakpoints = NULL; @@ -298,15 +299,12 @@ z80_context * zdebugger(z80_context * context, uint16_t address) 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); @@ -504,8 +502,7 @@ m68k_context * debugger(m68k_context * context, uint32_t address) } 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); -- cgit v1.2.3