aboutsummaryrefslogtreecommitdiff
path: root/src/chips/nuked/nukedopl3_174.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/chips/nuked/nukedopl3_174.c')
-rw-r--r--src/chips/nuked/nukedopl3_174.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/chips/nuked/nukedopl3_174.c b/src/chips/nuked/nukedopl3_174.c
index 99eab16..a8b1f40 100644
--- a/src/chips/nuked/nukedopl3_174.c
+++ b/src/chips/nuked/nukedopl3_174.c
@@ -34,7 +34,11 @@
#define RSM_FRAC 10
-/* Channel types */
+#ifndef PI
+#define PI 3.14159265358979323846
+#endif
+
+ /* Channel types */
enum {
ch_2op = 0,
@@ -1222,6 +1226,8 @@ void OPL3v17_Reset(opl3_chip *chip, Bit32u samplerate)
chip->channel[channum].chtype = ch_2op;
chip->channel[channum].cha = ~0;
chip->channel[channum].chb = ~0;
+ chip->channel[channum].chl = ~0;
+ chip->channel[channum].chr = ~0;
OPL3_ChannelSetupAlg(&chip->channel[channum]);
}
chip->noise = 0x306600;
@@ -1230,6 +1236,19 @@ void OPL3v17_Reset(opl3_chip *chip, Bit32u samplerate)
chip->vibshift = 1;
}
+static void OPL3v17_ChannelWritePan(opl3_channel *channel, Bit8u data)
+{
+ channel->chl = (Bit16u)(cos((float)data * (PI / 2.0f / 127.0f)) * 65535.0f);
+ channel->chr = (Bit16u)(sin((float)data * (PI / 2.0f / 127.0f)) * 65535.0f);
+}
+
+void OPL3v17_WritePan(opl3_chip *chip, Bit16u reg, Bit8u v)
+{
+ Bit8u high = (reg >> 8) & 0x01;
+ Bit8u regm = reg & 0xff;
+ OPL3v17_ChannelWritePan(&chip->channel[9 * high + (regm & 0x0f)], v);
+}
+
void OPL3v17_WriteReg(opl3_chip *chip, Bit16u reg, Bit8u v)
{
Bit8u high = (reg >> 8) & 0x01;