comparison ym2612.c @ 527:7df7f493b3b6

Fix operator 1 self-feedback
author Michael Pavone <pavone@retrodev.com>
date Wed, 12 Feb 2014 22:14:11 -0800
parents 6a14c5a95648
children 666210adf87b
comparison
equal deleted inserted replaced
526:6fe73296938a 527:7df7f493b3b6
372 int16_t mod = 0; 372 int16_t mod = 0;
373 switch (op % 4) 373 switch (op % 4)
374 { 374 {
375 case 0://Operator 1 375 case 0://Operator 1
376 if (chan->feedback) { 376 if (chan->feedback) {
377 mod = operator->output >> (9-chan->feedback); 377 mod = (chan->op1_old + operator->output) >> (10-chan->feedback);
378 } 378 }
379 break; 379 break;
380 case 1://Operator 3 380 case 1://Operator 3
381 switch(chan->algorithm) 381 switch(chan->algorithm)
382 { 382 {
429 env = MAX_ENVELOPE; 429 env = MAX_ENVELOPE;
430 } 430 }
431 if (first_key_on) { 431 if (first_key_on) {
432 dfprintf(debug_file, "op %d, base phase: %d, mod: %d, sine: %d, out: %d\n", op, phase, mod, sine_table[(phase+mod) & 0x1FF], pow_table[sine_table[phase & 0x1FF] + env]); 432 dfprintf(debug_file, "op %d, base phase: %d, mod: %d, sine: %d, out: %d\n", op, phase, mod, sine_table[(phase+mod) & 0x1FF], pow_table[sine_table[phase & 0x1FF] + env]);
433 } 433 }
434 phase += mod; 434 //if ((channel != 0 && channel != 4) || chan->algorithm != 5) {
435 phase += mod;
436 //}
435 437
436 int16_t output = pow_table[sine_table[phase & 0x1FF] + env]; 438 int16_t output = pow_table[sine_table[phase & 0x1FF] + env];
437 if (phase & 0x200) { 439 if (phase & 0x200) {
438 output = -output; 440 output = -output;
441 }
442 if (op % 4 == 0) {
443 chan->op1_old = operator->output;
439 } 444 }
440 operator->output = output; 445 operator->output = output;
441 //Update the channel output if we've updated all operators 446 //Update the channel output if we've updated all operators
442 if (op % 4 == 3) { 447 if (op % 4 == 3) {
443 if (chan->algorithm < 4) { 448 if (chan->algorithm < 4) {
782 } 787 }
783 break; 788 break;
784 case REG_ALG_FEEDBACK: 789 case REG_ALG_FEEDBACK:
785 context->channels[channel].algorithm = value & 0x7; 790 context->channels[channel].algorithm = value & 0x7;
786 context->channels[channel].feedback = value >> 3 & 0x7; 791 context->channels[channel].feedback = value >> 3 & 0x7;
792 //printf("Algorithm %d, feedback %d for channel %d\n", value & 0x7, value >> 3 & 0x7, channel);
787 break; 793 break;
788 case REG_LR_AMS_PMS: 794 case REG_LR_AMS_PMS:
789 context->channels[channel].pms = (value & 0x7) * 32; 795 context->channels[channel].pms = (value & 0x7) * 32;
790 context->channels[channel].ams = value >> 4 & 0x3; 796 context->channels[channel].ams = value >> 4 & 0x3;
791 context->channels[channel].lr = value & 0xC0; 797 context->channels[channel].lr = value & 0xC0;