aboutsummaryrefslogtreecommitdiff
path: root/src/chips/nuked/nukedopl3_174.c
diff options
context:
space:
mode:
authorChristopher Snowhill <kode54@gmail.com>2018-07-29 20:52:26 -0700
committerChristopher Snowhill <kode54@gmail.com>2018-07-29 20:52:26 -0700
commit0f69d504792776967b61f8987ad458c48b4a322f (patch)
tree0884f6008b6433b3f25d454884d8c9f6b9f7fac1 /src/chips/nuked/nukedopl3_174.c
parentb5a38c540d5a2b5b6750a49eb25ca3c7388b099c (diff)
downloadlibADLMIDI-0f69d504792776967b61f8987ad458c48b4a322f.tar.gz
libADLMIDI-0f69d504792776967b61f8987ad458c48b4a322f.tar.bz2
libADLMIDI-0f69d504792776967b61f8987ad458c48b4a322f.zip
Implemented optional soft panning support for the included chip emulators, disabled by default.
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;