diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-11-17 19:55:59 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-11-17 19:55:59 -0800 |
commit | a129e2f5c284fae96a5239d4d48b8f27ed67fbdc (patch) | |
tree | 74edd01f9d7cdb022bd28950b8a63b93a21442b4 /blastem.c | |
parent | 291a31d0fd00649ec57870b31c74605e6cb528ab (diff) |
Fix a bad interaction between the implementation of STOP and the way interrupt cycles are calculated. Prevent addition of refresh delays while VDP has the bus.
Diffstat (limited to 'blastem.c')
-rw-r--r-- | blastem.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -175,6 +175,10 @@ void adjust_int_cycle(m68k_context * context, vdp_context * v_context) context->target_cycle = context->int_cycle < context->sync_cycle ? context->int_cycle : context->sync_cycle; if (context->should_return) { context->target_cycle = context->current_cycle; + } else if (context->target_cycle < context->current_cycle) { + //Changes to SR can result in an interrupt cycle that's in the past + //This can cause issues with the implementation of STOP though + context->target_cycle = context->current_cycle; } /*printf("Cyc: %d, Trgt: %d, Int Cyc: %d, Int: %d, Mask: %X, V: %d, H: %d, HICount: %d, HReg: %d, Line: %d\n", context->current_cycle, context->target_cycle, context->int_cycle, context->int_num, (context->status & 0x7), @@ -241,9 +245,11 @@ m68k_context * sync_components(m68k_context * context, uint32_t address) vdp_context * v_context = gen->vdp; z80_context * z_context = gen->z80; //lame estimation of refresh cycle delay - refresh_counter += context->current_cycle - last_sync_cycle; - context->current_cycle += REFRESH_DELAY * MCLKS_PER_68K * (refresh_counter / (MCLKS_PER_68K * REFRESH_INTERVAL)); - refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); + if (!gen->bus_busy) { + refresh_counter += context->current_cycle - last_sync_cycle; + context->current_cycle += REFRESH_DELAY * MCLKS_PER_68K * (refresh_counter / (MCLKS_PER_68K * REFRESH_INTERVAL)); + refresh_counter = refresh_counter % (MCLKS_PER_68K * REFRESH_INTERVAL); + } uint32_t mclks = context->current_cycle; sync_z80(z_context, mclks); |