shithub: choc

Download patch

ref: 25087a6550170fabe6fc20a549b928a5a9c5e152
parent: 4ce27fe5751a58189202b8ab6c3d11ef59ace56b
author: nukeykt <[email protected]>
date: Sat Jun 11 12:13:28 EDT 2016

opl: Nuked OPL3 v1.7.2

--- a/opl/opl3.c
+++ b/opl/opl3.c
@@ -21,38 +21,8 @@
 //      OPLx decapsulated(Matthew Gambrell, Olli Niemitalo):
 //          OPL2 ROMs.
 //
-// version: 1.7
+// version: 1.7.2
 //
-//  Changelog:
-//
-//  v1.1:
-//      Vibrato's sign fix.
-//  v1.2:
-//      Operator key fix.
-//      Corrected 4-operator mode.
-//      Corrected rhythm mode.
-//      Some small fixes.
-//  v1.2.1:
-//      Small envelope generator fix.
-//      Removed EX_Get function(not used)
-//  v1.3:
-//      Complete rewrite.
-//  v1.4:
-//      New envelope and waveform generator.
-//      Some small fixes.
-//  v1.4.1:
-//      Envelope generator rate calculation fix.
-//  v1.4.2:
-//      Version for ZDoom.
-//  v1.5:
-//      Optimizations.
-//  v1.6:
-//      Improved emulation output.
-//  v1.6.1:
-//      Simple YMF289(OPL3-L) emulation.
-//  v1.7:
-//      Version for Chocolate Doom.
-//
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -537,16 +507,13 @@
     if (!slot->key)
     {
         slot->eg_gen = envelope_gen_num_attack;
-        if ((slot->eg_rate >> 2) != 0x0f)
+        OPL3_EnvelopeUpdateRate(slot);
+        if ((slot->eg_rate >> 2) == 0x0f)
         {
-            slot->eg_gen = envelope_gen_num_attack;
-        }
-        else
-        {
             slot->eg_gen = envelope_gen_num_decay;
+            OPL3_EnvelopeUpdateRate(slot);
             slot->eg_rout = 0x00;
         }
-        OPL3_EnvelopeUpdateRate(slot);
         slot->pg_phase = 0x00;
     }
     slot->key |= type;
@@ -683,7 +650,7 @@
 
 static void OPL3_SlotGenerateZM(opl3_slot *slot)
 {
-    OPL3_SlotGeneratePhase(slot, 0);
+    OPL3_SlotGeneratePhase(slot, (Bit16u)(slot->pg_phase >> 9));
 }
 
 static void OPL3_SlotCalcFB(opl3_slot *slot)
@@ -789,6 +756,8 @@
         {
             chip->channel[chnum].chtype = ch_2op;
             OPL3_ChannelSetupAlg(&chip->channel[chnum]);
+            OPL3_EnvelopeKeyOff(chip->channel[chnum].slots[0], egk_drum);
+            OPL3_EnvelopeKeyOff(chip->channel[chnum].slots[1], egk_drum);
         }
     }
 }
@@ -1084,7 +1053,7 @@
              | (((phase17 >> 2) ^ phase17) & 0x08)) ? 0x01 : 0x00;
     //hh
     phase = (phasebit << 9)
-          | (0x34 << ((phasebit ^ (chip->noise & 0x01) << 1)));
+          | (0x34 << ((phasebit ^ (chip->noise & 0x01)) << 1));
     OPL3_SlotGeneratePhase(channel7->slots[0], phase);
     //tt
     OPL3_SlotGenerateZM(channel8->slots[0]);
--- a/opl/opl3.h
+++ b/opl/opl3.h
@@ -21,7 +21,7 @@
 //      OPLx decapsulated(Matthew Gambrell, Olli Niemitalo):
 //          OPL2 ROMs.
 //
-// version: 1.7
+// version: 1.7.2
 //
 
 #ifndef OPL_OPL3_H