Mercurial > repos > blastem
changeset 374:d42a8a3e4894
Fix YM2612 busy flag
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 02 Jun 2013 21:12:43 -0700 |
parents | 91d28a868551 |
children | 134ffb72d7a1 |
files | blastem.c ym2612.c |
diffstat | 2 files changed, 7 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/blastem.c Sun Jun 02 21:12:26 2013 -0700 +++ b/blastem.c Sun Jun 02 21:12:43 2013 -0700 @@ -199,6 +199,9 @@ if (mclks >= mclks_per_frame) { ym_run(gen->ym, context->current_cycle); gen->ym->current_cycle -= mclks_per_frame/MCLKS_PER_68K; + if (gen->ym->write_cycle != CYCLE_NEVER) { + gen->ym->write_cycle = gen->ym->write_cycle >= mclks_per_frame/MCLKS_PER_68K ? gen->ym->write_cycle - mclks_per_frame/MCLKS_PER_68K : 0; + } //printf("reached frame end | 68K Cycles: %d, MCLK Cycles: %d\n", context->current_cycle, mclks); vdp_run_context(v_context, mclks_per_frame); psg_run(gen->psg, mclks/MCLKS_PER_PSG);
--- a/ym2612.c Sun Jun 02 21:12:26 2013 -0700 +++ b/ym2612.c Sun Jun 02 21:12:43 2013 -0700 @@ -87,6 +87,7 @@ #define MAX_ENVELOPE 0xFFC #define YM_DIVIDER 2 +#define CYCLE_NEVER 0xFFFFFFFF uint16_t round_fixed_point(double value, int dec_bits) { @@ -104,6 +105,7 @@ context->back_buffer = malloc(sizeof(*context->audio_buffer) * sample_limit*2); context->buffer_inc = (double)sample_rate / (double)(clock_rate/OP_UPDATE_PERIOD); context->sample_limit = sample_limit*2; + context->write_cycle = CYCLE_NEVER; for (int i = 0; i < NUM_OPERATORS; i++) { context->operators[i].envelope = MAX_ENVELOPE; context->operators[i].env_phase = PHASE_RELEASE; @@ -380,6 +382,7 @@ } if (context->current_cycle >= context->write_cycle + BUSY_CYCLES) { context->status &= 0x7F; + context->write_cycle = CYCLE_NEVER; } //printf("Done running YM2612 at cycle %d\n", context->current_cycle, to_cycle); } @@ -600,6 +603,7 @@ } context->write_cycle = context->current_cycle; + context->status |= 0x80; } uint8_t ym_read_status(ym2612_context * context)