Mercurial > repos > blastem
changeset 891:90d54ccf9557
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.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 17 Nov 2015 19:55:59 -0800 |
parents | 12b1a8a32306 |
children | 381a3b2f6065 |
files | blastem.c |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/blastem.c Mon Nov 16 22:00:32 2015 -0800 +++ b/blastem.c Tue Nov 17 19:55:59 2015 -0800 @@ -175,6 +175,10 @@ 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 @@ 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);