shithub: choc

Download patch

ref: 98e1771a832f0843d1a8be344894c0c77bd5f8fd
parent: 5e064562c09ceb5b93a4ddafe734cdb6c7b081c6
author: khokh2001 <[email protected]>
date: Tue Oct 28 21:37:42 EDT 2014

opl note limitation and octave overflow fixes

--- a/src/i_oplmusic.c
+++ b/src/i_oplmusic.c
@@ -734,10 +734,15 @@
 
     // Avoid possible overflow due to base note offset:
 
-    if (note > 0x7f)
+    while (note < 0)
     {
-        note = voice->note;
+        note += 12;
     }
+    
+    while (note > 95)
+    {
+        note -= 12;
+    }
 
     freq_index = 64 + 32 * note + voice->channel->bend;
 
@@ -770,14 +775,7 @@
 
     if (octave >= 7)
     {
-        if (sub_index < 5)
-        {
-            octave = 7;
-        }
-        else
-        {
-            octave = 6;
-        }
+        octave = 7;
     }
 
     // Calculate the resulting register value to use for the frequency.