changeset 1336:1f097180bed3

Cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 22 Aug 2017 14:46:45 +0300
parents caf414847662
children 04b1bf207636
files tools/xm2jss.c
diffstat 1 files changed, 27 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/tools/xm2jss.c	Tue Aug 22 14:42:31 2017 +0300
+++ b/tools/xm2jss.c	Tue Aug 22 14:46:45 2017 +0300
@@ -273,11 +273,10 @@
     Uint8 *patBuf, const size_t patBufSize,
     size_t *patSize, const JSSPattern *pattern)
 {
-    int row, channel;
     *patSize = 0;
 
-    for (row = 0; row < pattern->nrows; row++)
-    for (channel = 0; channel < pattern->nchannels; channel++)
+    for (int row = 0; row < pattern->nrows; row++)
+    for (int channel = 0; channel < pattern->nchannels; channel++)
     {
         const JSSNote *pnote = &pattern->data[(pattern->nchannels * row) + channel];
         const int res = jssCompressNote(patBuf, patBufSize, patSize, pnote);
@@ -297,11 +296,10 @@
     Uint8 *patBuf, const size_t patBufSize,
     size_t *patSize, const JSSPattern *pattern)
 {
-    int row, channel;
     *patSize = 0;
 
-    for (channel = 0; channel < pattern->nchannels; channel++)
-    for (row = 0; row < pattern->nrows; row++)
+    for (int channel = 0; channel < pattern->nchannels; channel++)
+    for (int row = 0; row < pattern->nrows; row++)
     {
         const JSSNote *pnote = &pattern->data[(pattern->nchannels * row) + channel];
         const int res = jssCompressNote(patBuf, patBufSize, patSize, pnote);
@@ -323,11 +321,10 @@
     Uint8 *patBuf, const size_t patBufSize,
     size_t *patSize, const JSSPattern *pattern)
 {
-    int row, channel;
     *patSize = 0;
 
-    for (row = 0; row < pattern->nrows; row++)
-    for (channel = 0; channel < pattern->nchannels; channel++)
+    for (int row = 0; row < pattern->nrows; row++)
+    for (int channel = 0; channel < pattern->nchannels; channel++)
     {
         const JSSNote *pnote = &pattern->data[(pattern->nchannels * row) + channel];
         const int res = jssConvertNote(patBuf, patBufSize, patSize, pnote);
@@ -347,11 +344,10 @@
     Uint8 *patBuf, const size_t patBufSize,
     size_t *patSize, const JSSPattern *pattern)
 {
-    int row, channel;
     *patSize = 0;
 
-    for (channel = 0; channel < pattern->nchannels; channel++)
-    for (row = 0; row < pattern->nrows; row++)
+    for (int channel = 0; channel < pattern->nchannels; channel++)
+    for (int row = 0; row < pattern->nrows; row++)
     {
         const JSSNote *pnote = &pattern->data[(pattern->nchannels * row) + channel];
         const int res = jssConvertNote(patBuf, patBufSize, patSize, pnote);
@@ -736,7 +732,7 @@
 
 
 /* Scan given pattern for used instruments and channels.
- * Also checks if the pattern is empty.
+ * Also checks if the pattern is empty and convert certain effects.
  */
 void scanPattern(JSSModule *module, JSSPattern *pattern, int npattern, BOOL *usedExtInstruments, BOOL *usedChannels, BOOL *empty)
 {
@@ -764,8 +760,24 @@
             n->effect != jsetNotSet ||
             n->param != jsetNotSet)
         {
+            char effect;
+
             usedChannels[channel] = TRUE;
             *empty = FALSE;
+
+            // Convert certain effects
+            JMPGETEFFECT(effect, n->effect);
+            switch (effect)
+            {
+                case 'C': // Cxx = Set volume
+                    if (n->volume == jsetNotSet)
+                    {
+                        n->volume = n->param;
+                        n->effect = jsetNotSet;
+                        n->param = jsetNotSet;
+                    }
+                    break;
+            }
         }
     }
 }
@@ -1085,15 +1097,12 @@
     //
     for (int i = 0; i < r->npatterns; i++)
     {
-        int row, channel;
         JSSPattern *p = r->patterns[i];
         JSSNote *n = p->data;
 
-        for (row = 0; row < p->nrows; row++)
-        for (channel = 0; channel < p->nchannels; channel++, n++)
+        for (int row = 0; row < p->nrows; row++)
+        for (int channel = 0; channel < p->nchannels; channel++, n++)
         {
-            char effect;
-
             // If not stripping extended instruments, check for
             // the validity of the used instrument and remap
             if (!optStripExtInstr)
@@ -1108,21 +1117,6 @@
                         n->instrument + 1);
                 }
             }
-
-            JMPGETEFFECT(effect, n->effect);
-
-            // Convert certain effects
-            switch (effect)
-            {
-                case 'C': // Cxx = Set volume
-                    if (n->volume == jsetNotSet)
-                    {
-                        n->volume = n->param;
-                        n->effect = jsetNotSet;
-                        n->param = jsetNotSet;
-                    }
-                    break;
-            }
         }
     }