diff tools/xm2jss.c @ 2586:9807ae37ad69

Require stdbool.h, we require C11 now.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 08 Dec 2022 15:59:22 +0200
parents d56a0e86067a
children
line wrap: on
line diff
--- a/tools/xm2jss.c	Thu Dec 08 15:56:36 2022 +0200
+++ b/tools/xm2jss.c	Thu Dec 08 15:59:22 2022 +0200
@@ -23,11 +23,11 @@
 
 
 char  *optInFilename = NULL, *optOutFilename = NULL;
-BOOL  optIgnoreErrors = FALSE,
-      optStripExtInstr = FALSE,
-      optStripInstr = FALSE,
-      optStripSamples = FALSE,
-      optOptimize = FALSE;
+bool  optIgnoreErrors = false,
+      optStripExtInstr = false,
+      optStripInstr = false,
+      optStripSamples = false,
+      optOptimize = false;
 
 int   optPatternMode = PATMODE_COMP_HORIZ,
       optSampMode16 = jsampDelta,
@@ -86,7 +86,7 @@
     );
 }
 
-BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
+bool argHandleOpt(const int optN, char *optArg, char *currArg)
 {
     switch (optN)
     {
@@ -105,7 +105,7 @@
             break;
 
         case 10:
-            optIgnoreErrors = TRUE;
+            optIgnoreErrors = true;
             break;
 
         case 12:
@@ -113,29 +113,29 @@
             if (optPatternMode <= 0 || optPatternMode >= PATMODE_LAST)
             {
                 dmErrorMsg("Unknown pattern conversion mode %d\n", optPatternMode);
-                return FALSE;
+                return false;
             }
             break;
 
-        case 14: optStripExtInstr = TRUE; break;
-        case 16: optStripInstr = TRUE; break;
-        case 18: optStripSamples = TRUE; break;
+        case 14: optStripExtInstr = true; break;
+        case 16: optStripInstr = true; break;
+        case 18: optStripSamples = true; break;
 
         case 20: optSampMode8 = atoi(optArg) & JM_SAMPLE_MODE_MASK; break;
         case 22: optSampMode16 = atoi(optArg) & JM_SAMPLE_MODE_MASK; break;
 
-        case 24: optOptimize = TRUE; break;
+        case 24: optOptimize = true; break;
 
         default:
             dmErrorMsg("Unimplemented option argument '%s'.\n", currArg);
-            return FALSE;
+            return false;
     }
 
-    return TRUE;
+    return true;
 }
 
 
-BOOL argHandleFile(char *currArg)
+bool argHandleFile(char *currArg)
 {
     // Was not option argument
     if (!optInFilename)
@@ -146,10 +146,10 @@
     else
     {
         dmErrorMsg("Too many filename arguments specified, '%s'.\n", currArg);
-        return FALSE;
+        return false;
     }
 
-    return TRUE;
+    return true;
 }
 
 
@@ -165,15 +165,15 @@
 /* These functions and the macro mess are meant to make the
  * conversion routines themselves clearer and simpler.
  */
-BOOL jsPutByte(Uint8 *patBuf, size_t patBufSize, size_t *npatBuf, Uint8 val)
+bool jsPutByte(Uint8 *patBuf, size_t patBufSize, size_t *npatBuf, Uint8 val)
 {
     if (*npatBuf >= patBufSize)
-        return FALSE;
+        return false;
     else
     {
         patBuf[*npatBuf] = val;
         (*npatBuf)++;
-        return TRUE;
+        return true;
     }
 }
 
@@ -510,9 +510,9 @@
 #undef JSFOREACHNOTE2
 
 
-static BOOL jssMODWriteEnvelope(DMResource *outFile, const JSSEnvelope *env, const char *name, const int ninst)
+static bool jssMODWriteEnvelope(DMResource *outFile, const JSSEnvelope *env, const char *name, const int ninst)
 {
-    BOOL ok =
+    bool ok =
         dmf_write_byte(outFile, env->flags) &&
         dmf_write_byte(outFile, env->npoints) &&
         dmf_write_byte(outFile, env->sustain) &&
@@ -745,7 +745,7 @@
         }
 
         // Misc data
-        BOOL ok =
+        bool ok =
             dmf_write_byte(outFile, einst->nsamples) &&
             dmf_write_byte(outFile, einst->vibratoType) &&
             dmf_write_le16(outFile, einst->vibratoSweep) &&
@@ -863,11 +863,11 @@
 /* Scan given pattern for used instruments and channels.
  * Also checks if the pattern is empty.
  */
-BOOL jssScanPattern(const JSSModule *module, const JSSPattern *pattern,
-    const int npattern, BOOL *usedExtInstruments, BOOL *usedChannels)
+bool jssScanPattern(const JSSModule *module, const JSSPattern *pattern,
+    const int npattern, bool *usedExtInstruments, bool *usedChannels)
 {
     JSSNote *n = pattern->data;
-    BOOL empty = TRUE;
+    bool empty = true;
 
     // Check all notes in this pattern
     for (int row = 0; row < pattern->nrows; row++)
@@ -879,7 +879,7 @@
         {
             // Is it valid?
             if (n->instrument >= 0 && n->instrument < module->nextInstruments)
-                usedExtInstruments[n->instrument] = TRUE;
+                usedExtInstruments[n->instrument] = true;
             else
             {
                 dmMsg(2, "Pattern 0x%x, row=0x%x, chn=%d has invalid instrument 0x%x\n",
@@ -895,9 +895,9 @@
             n->param != jsetNotSet)
         {
             if (usedChannels != NULL)
-                usedChannels[channel] = TRUE;
+                usedChannels[channel] = true;
 
-            empty = FALSE;
+            empty = false;
         }
     }
 
@@ -907,7 +907,7 @@
 
 /* Check if two given patterns are dupes
  */
-BOOL jssComparePattern(const JSSPattern *pat1, const JSSPattern *pat2)
+bool jssComparePattern(const JSSPattern *pat1, const JSSPattern *pat2)
 {
     return
         pat1->nrows     == pat2->nrows &&
@@ -927,7 +927,7 @@
  */
 JSSModule *jssOptimizeModule(JSSModule *src)
 {
-    BOOL usedPatterns[jsetMaxPatterns + 1],
+    bool usedPatterns[jsetMaxPatterns + 1],
          usedInstruments[jsetMaxInstruments + 1],
          usedExtInstruments[jsetMaxInstruments + 1];
     int  mapExtInstruments[jsetMaxInstruments + 1],
@@ -962,15 +962,15 @@
     // Initialize values
     for (int i = 0; i <= jsetMaxInstruments; i++)
     {
-        usedExtInstruments[i] = FALSE;
-        usedInstruments[i]    = FALSE;
+        usedExtInstruments[i] = false;
+        usedInstruments[i]    = false;
         mapExtInstruments[i]  = jsetNotSet;
         mapInstruments[i]     = jsetNotSet;
     }
 
     for (int i = 0; i <= jsetMaxPatterns; i++)
     {
-        usedPatterns[i] = FALSE;
+        usedPatterns[i] = false;
         mapPatterns[i]  = jsetNotSet;
         dupPatterns[i]  = jsetNotSet;
     }
@@ -989,16 +989,16 @@
             if (pattern != NULL)
             {
                 // Scan for used instruments etc
-                BOOL empty = jssScanPattern(src, pattern, npat, usedExtInstruments, NULL);
+                bool empty = jssScanPattern(src, pattern, npat, usedExtInstruments, NULL);
 
                 // Empty patterns with known number of rows are "removed"
                 if (empty && pattern->nrows == jsetDefaultRows)
                 {
                     src->orderList[norder] = jsetNotSet;
-                    usedPatterns[npat] = FALSE;
+                    usedPatterns[npat] = false;
                 }
                 else
-                    usedPatterns[npat] = TRUE;
+                    usedPatterns[npat] = true;
             }
             else
             {
@@ -1035,7 +1035,7 @@
             int q = eip->sNumForNotes[note];
             if (q >= 0 && q < src->ninstruments)
             {
-                usedInstruments[q] = TRUE;
+                usedInstruments[q] = true;
             }
             else
             {
@@ -1331,7 +1331,7 @@
 
     // Read file
     dmMsg(1, "Reading XM-format file ...\n");
-    res = jssLoadXM(inFile, &src, FALSE);
+    res = jssLoadXM(inFile, &src, false);
     dmf_close(inFile);
     if (res != 0)
     {
@@ -1346,8 +1346,8 @@
     }
 
     // Check stripping settings
-    if (optStripExtInstr) optStripInstr = TRUE;
-    if (optStripInstr) optStripSamples = TRUE;
+    if (optStripExtInstr) optStripInstr = true;
+    if (optStripInstr) optStripSamples = true;
 
     // Remove samples
     if (optStripSamples)