changeset 1192:e0fc8967d380

Inefficient fix for overlapping instruction problem that was causing issues with Outrunners
author Michael Pavone <pavone@retrodev.com>
date Tue, 24 Jan 2017 00:15:27 -0800
parents 8dc50e50ced6
children 0e69409634f3
files m68k_core_x86.c
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/m68k_core_x86.c	Tue Jan 24 00:02:03 2017 -0800
+++ b/m68k_core_x86.c	Tue Jan 24 00:15:27 2017 -0800
@@ -2263,11 +2263,13 @@
 	}
 }
 
+#define M68K_MAX_INST_SIZE (2*(1+2+2))
+
 m68k_context * m68k_handle_code_write(uint32_t address, m68k_context * context)
 {
 	m68k_options * options = context->options;
 	uint32_t inst_start = get_instruction_start(options, address);
-	if (inst_start) {
+	while (inst_start && (address - inst_start) < M68K_MAX_INST_SIZE) {
 		code_info *code = &options->gen.code;
 		code_ptr dst = get_native_address(context->options, inst_start);
 		code_info orig = {dst, dst + 128, 0};
@@ -2284,6 +2286,7 @@
 			jmp_r(code, options->gen.scratch1);
 		}
 		jmp(&orig, options->retrans_stub);
+		inst_start = get_instruction_start(options, inst_start - 2);
 	}
 	return context;
 }