changeset 371:0f8a759f1ff4

Use signed ints for things that represent signed values in YM2612 core
author Mike Pavone <pavone@retrodev.com>
date Sun, 02 Jun 2013 13:42:33 -0700
parents 5f215603d001
children 5dcf7551bb36
files ym2612.c ym2612.h
diffstat 2 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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");
--- 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];