summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-01-24 00:15:27 -0800
committerMichael Pavone <pavone@retrodev.com>2017-01-24 00:15:27 -0800
commit4b979a38ec6db843230c26cfe23f75a5d460fcde (patch)
tree94758861d72404a48c8e67697431cff5a40dd54d
parentb602ca56c16f88ed1ce6465d1cf009154939dce3 (diff)
Inefficient fix for overlapping instruction problem that was causing issues with Outrunners
-rw-r--r--m68k_core_x86.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/m68k_core_x86.c b/m68k_core_x86.c
index 0d68492..17e8daf 100644
--- a/m68k_core_x86.c
+++ b/m68k_core_x86.c
@@ -2263,11 +2263,13 @@ void nop_fill_or_jmp_next(code_info *code, code_ptr old_end, code_ptr next_inst)
}
}
+#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 @@ m68k_context * m68k_handle_code_write(uint32_t address, m68k_context * context)
jmp_r(code, options->gen.scratch1);
}
jmp(&orig, options->retrans_stub);
+ inst_start = get_instruction_start(options, inst_start - 2);
}
return context;
}