From 08024e63a3f5441229ccc1e4189e7a399017a681 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Wed, 12 Feb 2014 22:14:11 -0800 Subject: Fix operator 1 self-feedback --- ym2612.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ym2612.c') diff --git a/ym2612.c b/ym2612.c index 4943cee..9b0bad8 100644 --- a/ym2612.c +++ b/ym2612.c @@ -374,7 +374,7 @@ void ym_run(ym2612_context * context, uint32_t to_cycle) { case 0://Operator 1 if (chan->feedback) { - mod = operator->output >> (9-chan->feedback); + mod = (chan->op1_old + operator->output) >> (10-chan->feedback); } break; case 1://Operator 3 @@ -431,12 +431,17 @@ void ym_run(ym2612_context * context, uint32_t to_cycle) if (first_key_on) { 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]); } - phase += mod; + //if ((channel != 0 && channel != 4) || chan->algorithm != 5) { + phase += mod; + //} int16_t output = pow_table[sine_table[phase & 0x1FF] + env]; if (phase & 0x200) { output = -output; } + if (op % 4 == 0) { + chan->op1_old = operator->output; + } operator->output = output; //Update the channel output if we've updated all operators if (op % 4 == 3) { @@ -784,6 +789,7 @@ void ym_data_write(ym2612_context * context, uint8_t value) case REG_ALG_FEEDBACK: context->channels[channel].algorithm = value & 0x7; context->channels[channel].feedback = value >> 3 & 0x7; + //printf("Algorithm %d, feedback %d for channel %d\n", value & 0x7, value >> 3 & 0x7, channel); break; case REG_LR_AMS_PMS: context->channels[channel].pms = (value & 0x7) * 32; -- cgit v1.2.3