Mercurial > repos > blastem
comparison ym2612.c @ 365:3ba3b6656fff
Actually save the shifted phase inc after applying the block shift
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 29 May 2013 21:21:14 -0700 |
parents | 62177cc39049 |
children | fc820ab1394b |
comparison
equal
deleted
inserted
replaced
364:62177cc39049 | 365:3ba3b6656fff |
---|---|
72 1,1,1,2,1,1,1,2, | 72 1,1,1,2,1,1,1,2, |
73 1,2,1,2,1,2,1,2, | 73 1,2,1,2,1,2,1,2, |
74 1,2,2,2,1,2,2,2, | 74 1,2,2,2,1,2,2,2, |
75 }; | 75 }; |
76 | 76 |
77 uint16_t rate_table[64]; | 77 uint16_t rate_table[64*8]; |
78 | 78 |
79 #define MAX_ENVELOPE 0xFFC | 79 #define MAX_ENVELOPE 0xFFC |
80 #define YM_DIVIDER 2 | 80 #define YM_DIVIDER 2 |
81 | 81 |
82 uint16_t round_fixed_point(double value, int dec_bits) | 82 uint16_t round_fixed_point(double value, int dec_bits) |
119 for (int rate = 0; rate < 64; rate++) { | 119 for (int rate = 0; rate < 64; rate++) { |
120 for (int cycle = 0; cycle < 7; cycle++) { | 120 for (int cycle = 0; cycle < 7; cycle++) { |
121 uint16_t value; | 121 uint16_t value; |
122 if (rate < 3) { | 122 if (rate < 3) { |
123 value = 0; | 123 value = 0; |
124 } else if (value >= 60) { | 124 } else if (rate >= 60) { |
125 value = 8; | 125 value = 8; |
126 } else if (value < 8) { | 126 } else if (rate < 8) { |
127 value = rate_table_base[((rate & 6) == 6 ? 16 : 8) + cycle]; | 127 value = rate_table_base[((rate & 6) == 6 ? 16 : 8) + cycle]; |
128 } else if (value < 48) { | 128 } else if (rate < 48) { |
129 value = rate_table_base[(rate & 0x3) * 8 + cycle]; | 129 value = rate_table_base[(rate & 0x3) * 8 + cycle]; |
130 } else { | 130 } else { |
131 value = rate_table_base[32 + (rate & 0x3) * 8 + cycle] << (rate >> 2); | 131 value = rate_table_base[32 + (rate & 0x3) * 8 + cycle] << (rate >> 2); |
132 } | 132 } |
133 rate_table[rate * 8 + cycle] = value; | |
133 } | 134 } |
134 } | 135 } |
135 } | 136 } |
136 } | 137 } |
137 | 138 |
406 //printf("ym_update_phase_inc | channel: %d, op: %d\n", chan_num, op); | 407 //printf("ym_update_phase_inc | channel: %d, op: %d\n", chan_num, op); |
407 //base frequency | 408 //base frequency |
408 ym_channel * channel = context->channels + chan_num; | 409 ym_channel * channel = context->channels + chan_num; |
409 uint32_t inc = channel->fnum; | 410 uint32_t inc = channel->fnum; |
410 if (!channel->block) { | 411 if (!channel->block) { |
411 inc >> 1; | 412 inc >>= 1; |
412 } else { | 413 } else { |
413 inc << (channel->block-1); | 414 inc <<= (channel->block-1); |
414 } | 415 } |
415 //detune | 416 //detune |
416 uint32_t detune = detune_table[channel->keycode][operator->detune & 0x3]; | 417 uint32_t detune = detune_table[channel->keycode][operator->detune & 0x3]; |
417 if (operator->detune & 0x40) { | 418 if (operator->detune & 0x40) { |
418 inc -= detune; | 419 inc -= detune; |
426 inc *= operator->multiple; | 427 inc *= operator->multiple; |
427 } else { | 428 } else { |
428 //0.5 | 429 //0.5 |
429 inc >>= 1; | 430 inc >>= 1; |
430 } | 431 } |
432 //printf("phase_inc for operator %d: %d, block: %d, fnum: %d, detune: %d, multiple: %d\n", op, inc, channel->block, channel->fnum, detune, operator->multiple); | |
431 operator->phase_inc = inc; | 433 operator->phase_inc = inc; |
432 } | 434 } |
433 | 435 |
434 void ym_data_write(ym2612_context * context, uint8_t value) | 436 void ym_data_write(ym2612_context * context, uint8_t value) |
435 { | 437 { |