comparison ym2612.c @ 374:d42a8a3e4894

Fix YM2612 busy flag
author Mike Pavone <pavone@retrodev.com>
date Sun, 02 Jun 2013 21:12:43 -0700
parents 0f8a759f1ff4
children f6def5cdf1b4
comparison
equal deleted inserted replaced
373:91d28a868551 374:d42a8a3e4894
85 85
86 uint16_t rate_table[64*8]; 86 uint16_t rate_table[64*8];
87 87
88 #define MAX_ENVELOPE 0xFFC 88 #define MAX_ENVELOPE 0xFFC
89 #define YM_DIVIDER 2 89 #define YM_DIVIDER 2
90 #define CYCLE_NEVER 0xFFFFFFFF
90 91
91 uint16_t round_fixed_point(double value, int dec_bits) 92 uint16_t round_fixed_point(double value, int dec_bits)
92 { 93 {
93 return value * (1 << dec_bits) + 0.5; 94 return value * (1 << dec_bits) + 0.5;
94 } 95 }
102 memset(context, 0, sizeof(*context)); 103 memset(context, 0, sizeof(*context));
103 context->audio_buffer = malloc(sizeof(*context->audio_buffer) * sample_limit*2); 104 context->audio_buffer = malloc(sizeof(*context->audio_buffer) * sample_limit*2);
104 context->back_buffer = malloc(sizeof(*context->audio_buffer) * sample_limit*2); 105 context->back_buffer = malloc(sizeof(*context->audio_buffer) * sample_limit*2);
105 context->buffer_inc = (double)sample_rate / (double)(clock_rate/OP_UPDATE_PERIOD); 106 context->buffer_inc = (double)sample_rate / (double)(clock_rate/OP_UPDATE_PERIOD);
106 context->sample_limit = sample_limit*2; 107 context->sample_limit = sample_limit*2;
108 context->write_cycle = CYCLE_NEVER;
107 for (int i = 0; i < NUM_OPERATORS; i++) { 109 for (int i = 0; i < NUM_OPERATORS; i++) {
108 context->operators[i].envelope = MAX_ENVELOPE; 110 context->operators[i].envelope = MAX_ENVELOPE;
109 context->operators[i].env_phase = PHASE_RELEASE; 111 context->operators[i].env_phase = PHASE_RELEASE;
110 } 112 }
111 //some games seem to expect that the LR flags start out as 1 113 //some games seem to expect that the LR flags start out as 1
378 } 380 }
379 } 381 }
380 } 382 }
381 if (context->current_cycle >= context->write_cycle + BUSY_CYCLES) { 383 if (context->current_cycle >= context->write_cycle + BUSY_CYCLES) {
382 context->status &= 0x7F; 384 context->status &= 0x7F;
385 context->write_cycle = CYCLE_NEVER;
383 } 386 }
384 //printf("Done running YM2612 at cycle %d\n", context->current_cycle, to_cycle); 387 //printf("Done running YM2612 at cycle %d\n", context->current_cycle, to_cycle);
385 } 388 }
386 389
387 void ym_address_write_part1(ym2612_context * context, uint8_t address) 390 void ym_address_write_part1(ym2612_context * context, uint8_t address)
598 } 601 }
599 } 602 }
600 } 603 }
601 604
602 context->write_cycle = context->current_cycle; 605 context->write_cycle = context->current_cycle;
606 context->status |= 0x80;
603 } 607 }
604 608
605 uint8_t ym_read_status(ym2612_context * context) 609 uint8_t ym_read_status(ym2612_context * context)
606 { 610 {
607 return context->status; 611 return context->status;