# HG changeset patch # User Mike Pavone # Date 1370205753 25200 # Node ID 0f8a759f1ff49fdf069eb99e12b8f280cc99ee8f # Parent 5f215603d0017f0c73a9ad53018dc7475f340557 Use signed ints for things that represent signed values in YM2612 core diff -r 5f215603d001 -r 0f8a759f1ff4 ym2612.c --- a/ym2612.c Sun Jun 02 00:00:22 2013 -0700 +++ b/ym2612.c Sun Jun 02 13:42:33 2013 -0700 @@ -261,7 +261,7 @@ //TODO: Modulate phase by LFO if necessary operator->phase_counter += operator->phase_inc; uint16_t phase = operator->phase_counter >> 10 & 0x3FF; - uint16_t mod = 0; + int16_t mod = 0; switch (op % 4) { case 0://Operator 1 @@ -323,7 +323,7 @@ } phase += mod; - uint16_t output = pow_table[sine_table[phase & 0x1FF] + env]; + int16_t output = pow_table[sine_table[phase & 0x1FF] + env]; if (phase & 0x200) { output = -output; } @@ -341,12 +341,12 @@ } chan->output = output; } - int16_t value = context->channels[channel].output & 0x3FE0; - if (value & 0x2000) { - value |= 0xC000; - } if (first_key_on) { - dfprintf(debug_file, "channel %d output: %d\n", channel, value / 2); + int16_t value = context->channels[channel].output & 0x3FE0; + if (value & 0x2000) { + value |= 0xC000; + } + dfprintf(debug_file, "channel %d output: %d\n", channel, value / YM_VOLUME_DIVIDER); } } //puts("operator update done"); diff -r 5f215603d001 -r 0f8a759f1ff4 ym2612.h --- a/ym2612.h Sun Jun 02 00:00:22 2013 -0700 +++ b/ym2612.h Sun Jun 02 13:42:33 2013 -0700 @@ -11,7 +11,7 @@ uint32_t phase_inc; uint32_t phase_counter; uint16_t envelope; - uint16_t output; + int16_t output; uint16_t total_level; uint16_t sustain_level; uint8_t rates[4];