summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pavone <pavone@retrodev.com>2013-06-02 13:42:33 -0700
committerMike Pavone <pavone@retrodev.com>2013-06-02 13:42:33 -0700
commit5a5a2c5df628197a5ab4dcce7124d8c0cb9a7d68 (patch)
tree65cc34218e0d5d70dd778ec578409b30c4ec2b9b
parent567f2d8ed44dc59d421bc13c2b58b88a0b77bc31 (diff)
Use signed ints for things that represent signed values in YM2612 core
-rw-r--r--ym2612.c14
-rw-r--r--ym2612.h2
2 files changed, 8 insertions, 8 deletions
diff --git a/ym2612.c b/ym2612.c
index b45aa86..d4cb2fe 100644
--- a/ym2612.c
+++ b/ym2612.c
@@ -261,7 +261,7 @@ void ym_run(ym2612_context * context, uint32_t to_cycle)
//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 @@ void ym_run(ym2612_context * context, uint32_t to_cycle)
}
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 @@ void ym_run(ym2612_context * context, uint32_t to_cycle)
}
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 --git a/ym2612.h b/ym2612.h
index a296659..7c74336 100644
--- a/ym2612.h
+++ b/ym2612.h
@@ -11,7 +11,7 @@ typedef struct {
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];