summaryrefslogtreecommitdiff
path: root/z80_to_x86.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-07-25 18:22:07 -0700
committerMichael Pavone <pavone@retrodev.com>2015-07-25 18:22:07 -0700
commit80ff833dd8ad011b579bff26ac654819e6735bce (patch)
tree14f667ebb4739fd60780890884b98ce43e6b2e74 /z80_to_x86.c
parent7406c8bf64624feff0bf982e4667a194d31f8484 (diff)
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).
Diffstat (limited to 'z80_to_x86.c')
-rw-r--r--z80_to_x86.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/z80_to_x86.c b/z80_to_x86.c
index 23b19b8..7205d16 100644
--- a/z80_to_x86.c
+++ b/z80_to_x86.c
@@ -7,6 +7,7 @@
#include "z80_to_x86.h"
#include "gen_x86.h"
#include "mem.h"
+#include "util.h"
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@@ -256,8 +257,7 @@ void translate_z80_ea(z80inst * inst, host_ea * ea, z80_options * opts, uint8_t
ea->mode = MODE_UNUSED;
break;
default:
- fprintf(stderr, "Unrecognized Z80 addressing mode %d\n", inst->addr_mode & 0x1F);
- exit(1);
+ fatal_error("Unrecognized Z80 addressing mode %d\n", inst->addr_mode & 0x1F);
}
}
@@ -1939,11 +1939,10 @@ void translate_z80inst(z80inst * inst, z80_context * context, uint16_t address,
default: {
char disbuf[80];
z80_disasm(inst, disbuf, address);
- fprintf(stderr, "unimplemented instruction: %s at %X\n", disbuf, address);
FILE * f = fopen("zram.bin", "wb");
fwrite(context->mem_pointers[0], 1, 8 * 1024, f);
fclose(f);
- exit(1);
+ fatal_error("unimplemented Z80 instruction: %s at %X\nZ80 RAM has been saved to zram.bin for debugging", disbuf, address);
}
}
}
@@ -1952,8 +1951,7 @@ uint8_t * z80_interp_handler(uint8_t opcode, z80_context * context)
{
if (!context->interp_code[opcode]) {
if (opcode == 0xCB || (opcode >= 0xDD && (opcode & 0xF) == 0xD)) {
- fprintf(stderr, "Encountered prefix byte %X at address %X. Z80 interpeter doesn't support those yet.", opcode, context->pc);
- exit(1);
+ fatal_error("Encountered prefix byte %X at address %X. Z80 interpeter doesn't support those yet.", opcode, context->pc);
}
uint8_t codebuf[8];
memset(codebuf, 0, sizeof(codebuf));
@@ -1961,8 +1959,7 @@ uint8_t * z80_interp_handler(uint8_t opcode, z80_context * context)
z80inst inst;
uint8_t * after = z80_decode(codebuf, &inst);
if (after - codebuf > 1) {
- fprintf(stderr, "Encountered multi-byte Z80 instruction at %X. Z80 interpeter doesn't support those yet.", context->pc);
- exit(1);
+ fatal_error("Encountered multi-byte Z80 instruction at %X. Z80 interpeter doesn't support those yet.", context->pc);
}
z80_options * opts = context->options;
@@ -2243,7 +2240,7 @@ void translate_z80_stream(z80_context * context, uint32_t address)
if (opts->gen.deferred) {
address = opts->gen.deferred->address;
dprintf("defferred address: %X\n", address);
- }
+ }
} while (opts->gen.deferred);
}
@@ -2749,6 +2746,6 @@ void zremove_breakpoint(z80_context * context, uint16_t address)
opts->gen.code.last = native + 16;
check_cycles_int(&opts->gen, address);
opts->gen.code = tmp_code;
-}
+ }
}