changeset 177:eb293aa7a671

Cleanup the player logic a bit.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 06 Oct 2012 11:22:38 +0300
parents dfe7e392ea7e
children 63ff0fb944cd
files jssplr.c
diffstat 1 files changed, 21 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/jssplr.c	Sat Oct 06 11:14:51 2012 +0300
+++ b/jssplr.c	Sat Oct 06 11:22:38 2012 +0300
@@ -1149,8 +1149,6 @@
 static void jmpProcessNewRow(JSSPlayer * mp, int channel)
 {
     JSSNote *currNote;
-    JSSExtInstrument *extInst = NULL;
-    JSSInstrument *inst = NULL;
     BOOL newNote = FALSE;
     int tmp, paramX, paramY;
     JSSPlayerChannel *chn = &(mp->channels[channel]);
@@ -1181,50 +1179,41 @@
         // We save the instrument number here for later use
         if (currNote->instrument >= 0 &&
             currNote->instrument < mp->module->nextInstruments)
+        {
             chn->iCExtInstrumentN = currNote->instrument;
+            chn->iCExtInstrument = mp->module->extInstruments[currNote->instrument];
+        }
     }
 
     /* ONLY if newNote was SET NOW and ExtInstrument HAS BEEN set, we can
      * set new pitches, and other things...
      */
-    if (newNote)
+    if (newNote && chn->iCExtInstrument != NULL)
     {
-        if (chn->iCExtInstrumentN != jsetNotSet)
-            extInst = mp->module->extInstruments[chn->iCExtInstrumentN];
-        else
-            extInst = NULL;
+        JSSExtInstrument *extInst = chn->iCExtInstrument;
 
-        if (extInst)
-        {
-            // Set instrument
-            int note = chn->iCNote;
-            chn->iCExtInstrument = extInst;
+        // Get instrument number
+        tmp = extInst->sNumForNotes[chn->iCNote];
 
-            // We set new Instrument ONLY if NEW NOTE has been set
-            if (note != jsetNotSet)
-            {
-                // Get instrument number
-                tmp = extInst->sNumForNotes[note];
+        if (tmp >= 0 && tmp < mp->module->ninstruments)
+        {
+            // Set the new instrument
+            JSSInstrument *inst = mp->module->instruments[tmp];
+            chn->iCInstrumentN = tmp;
+            chn->iCInstrument = inst;
+            chn->iCVolume = inst->volume;
+            chn->iCPanning = inst->EPanning;
+            chn->iCPosition = 0;
 
-                if (tmp >= 0 && tmp < mp->module->ninstruments)
-                {
-                    // Set the new instrument
-                    inst = mp->module->instruments[tmp];
-                    chn->iCInstrumentN = tmp;
-                    chn->iCInstrument = inst;
-                    chn->iCVolume = inst->volume;
-                    chn->iCPanning = inst->EPanning;
-                    chn->iCPosition = 0;
-
-                    // Set NDFlags
-                    JMPSETNDFLAGS(cdfNewInstr | cdfNewPos | cdfNewPanPos | cdfNewVolume);
-                }
-            }
+            // Set NDFlags
+            JMPSETNDFLAGS(cdfNewInstr | cdfNewPos | cdfNewPanPos | cdfNewVolume);
         }
     }
 
-    if (inst)
+    if (newNote && chn->iCInstrument != NULL)
     {
+        JSSInstrument *inst = chn->iCInstrument;
+
         // Save old pitch for later use
         chn->iCOldPitch = chn->iCPitch;