diff options
author | Michael Pavone <pavone@retrodev.com> | 2017-03-28 09:39:54 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2017-03-28 09:39:54 -0700 |
commit | ee4dc11142649262163a85aad31775a02031b818 (patch) | |
tree | f66b0abdc1182af42e2e54c041ac75bff38c3a92 | |
parent | 15be1a3421956600cf3a773b96bf7aaf8f092d04 (diff) |
Fix exit trace mode edge case. Call do_sync if trace mode bit is changed in eori sr
-rw-r--r-- | genesis.c | 2 | ||||
-rw-r--r-- | m68k_core_x86.c | 11 | ||||
-rw-r--r-- | trans.c | 2 |
3 files changed, 9 insertions, 6 deletions
@@ -83,7 +83,7 @@ static void adjust_int_cycle(m68k_context * context, vdp_context * v_context) old_int_cycle = context->int_cycle; }*/ - if (context->status & M68K_STATUS_TRACE) { + if (context->status & M68K_STATUS_TRACE || context->trace_pending) { context->target_cycle = context->current_cycle; return; } diff --git a/m68k_core_x86.c b/m68k_core_x86.c index 9bcfd4d..7935c4f 100644 --- a/m68k_core_x86.c +++ b/m68k_core_x86.c @@ -2231,7 +2231,7 @@ void translate_m68k_eori_ccr_sr(m68k_options *opts, m68kinst *inst) } if (inst->op == M68K_EORI_SR) { xor_irdisp(code, inst->src.params.immed >> 8, opts->gen.context_reg, offsetof(m68k_context, status), SZ_B); - if (inst->src.params.immed & 0x700) { + if (inst->src.params.immed & 0x8700) { //set int pending flag in case we trigger an interrupt as a result of the mask change mov_irdisp(code, INT_PENDING_SR_CHANGE, opts->gen.context_reg, offsetof(m68k_context, int_pending), SZ_B); call(code, opts->do_sync); @@ -2929,17 +2929,20 @@ void init_m68k_opts(m68k_options * opts, memmap_chunk * memmap, uint32_t num_chu add_ir(code, 16-sizeof(void*), RSP, SZ_PTR); uint32_t adjust_size = code->cur - opts->gen.handle_cycle_limit_int; code->cur = opts->gen.handle_cycle_limit_int; - bt_irdisp(code, 7, opts->gen.context_reg, offsetof(m68k_context, status), SZ_B); - code_ptr no_trace = code->cur + 1; - jcc(code, CC_NC, no_trace); + //handle trace mode cmp_irdisp(code, 0, opts->gen.context_reg, offsetof(m68k_context, trace_pending), SZ_B); code_ptr do_trace = code->cur + 1; jcc(code, CC_NZ, do_trace); + bt_irdisp(code, 7, opts->gen.context_reg, offsetof(m68k_context, status), SZ_B); + code_ptr no_trace = code->cur + 1; + jcc(code, CC_NC, no_trace); mov_irdisp(code, 1, opts->gen.context_reg, offsetof(m68k_context, trace_pending), SZ_B); *no_trace = code->cur - (no_trace + 1); + //handle interrupts cmp_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, int_cycle), opts->gen.cycles, SZ_D); code_ptr do_int = code->cur + 2; jcc(code, CC_NC, do_int+512);//force 32-bit displacement + //handle component synchronization cmp_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, sync_cycle), opts->gen.cycles, SZ_D); skip_sync = code->cur + 1; jcc(code, CC_C, code->cur + 2); @@ -24,7 +24,7 @@ m68k_context * sync_components(m68k_context * context, uint32_t address) if (context->current_cycle > 0x80000000) { context->current_cycle -= 0x80000000; } - if (context->status & 0x80) { + if (context->status & M68K_STATUS_TRACE || context->trace_pending) { context->target_cycle = context->current_cycle; } return context; |