changeset 2418:cc07f544c620

Fix uninitialized base cycle count in Z80 interp path and do a little other interp path cleanup. Fixes issue with 3x3 Eyes
author Michael Pavone <pavone@retrodev.com>
date Wed, 17 Jan 2024 23:51:37 -0800
parents 9f3008f91bec
children 0871f555eff6
files z80_to_x86.c
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/z80_to_x86.c	Mon Jan 15 17:32:20 2024 -0800
+++ b/z80_to_x86.c	Wed Jan 17 23:51:37 2024 -0800
@@ -325,7 +325,7 @@
 
 void translate_z80inst(z80inst * inst, z80_context * context, uint16_t address, uint8_t interp)
 {
-	uint32_t num_cycles;
+	uint32_t num_cycles = 0;
 	host_ea src_op, dst_op;
 	uint8_t size;
 	z80_options *opts = context->options;
@@ -2861,15 +2861,21 @@
 {
 	z80_options *opts = context->options;
 	code_info * code = &opts->gen.code;
-	check_alloc_code(code, 32);
+	check_alloc_code(code, 64);
 	code_info stub = {code->cur, NULL};
-	//TODO: make this play well with the breakpoint code
+
+	check_cycles_int(&opts->gen, address);
+	if (context->breakpoint_flags[address / 8] & (1 << (address % 8))) {
+		zbreakpoint_patch(context, address, stub.cur);
+	}
+	add_ir(code, 1, opts->regs[Z80_R], SZ_B);
+#ifdef Z80_LOG_ADDRESS
+	log_address(&opts->gen, address, "Z80: %X @ %d\n");
+#endif
 	mov_ir(code, address, opts->gen.scratch1, SZ_W);
 	call(code, opts->read_8);
 	//opcode fetch M-cycles have one extra T-state
 	cycles(&opts->gen, 1);
-	//TODO: increment R
-	check_cycles_int(&opts->gen, address);
 	call(code, opts->gen.save_context);
 	mov_irdisp(code, address, opts->gen.context_reg, offsetof(z80_context, pc), SZ_W);
 	push_r(code, opts->gen.context_reg);