diff minijss/jssplr.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 69a5af2eb1ea
children
line wrap: on
line diff
--- a/minijss/jssplr.c	Thu Dec 08 15:56:36 2022 +0200
+++ b/minijss/jssplr.c	Thu Dec 08 15:59:22 2022 +0200
@@ -118,12 +118,12 @@
 }
 
 
-static BOOL jmpExecEnvelope(JSSEnvelope *env, JSSPlayerEnvelope *pe, BOOL keyOff)
+static bool jmpExecEnvelope(JSSEnvelope *env, JSSPlayerEnvelope *pe, bool keyOff)
 {
     int point;
 
     if (!pe->exec)
-        return FALSE;
+        return false;
 
     // Find current point, if not last point
     for (point = 0; point < env->npoints - 1; point++)
@@ -143,7 +143,7 @@
     if (pe->frame >= env->points[env->npoints - 1].frame)
     {
         point = env->npoints - 1;
-        pe->exec = FALSE;
+        pe->exec = false;
         pe->value = env->points[point].value;
     }
     else
@@ -172,7 +172,7 @@
             pe->frame++;
     }
 
-    return TRUE;
+    return true;
 }
 
 
@@ -280,7 +280,7 @@
 static void jmpResetEnvelope(JSSPlayerEnvelope *env)
 {
     env->frame = env->value = 0;
-    env->exec = TRUE;
+    env->exec = true;
 }
 
 
@@ -305,8 +305,8 @@
 
     // Initialize general variables
     mp->patternDelay      = 0;
-    mp->newRowSet         = FALSE;
-    mp->newOrderSet       = FALSE;
+    mp->newRowSet         = false;
+    mp->newOrderSet       = false;
     mp->tick              = jsetNotSet;
     mp->row               = 0;
     mp->lastPatLoopRow    = 0;
@@ -345,7 +345,7 @@
     if (mp->isPlaying)
     {
         jvmRemoveCallback(mp->device);
-        mp->isPlaying = FALSE;
+        mp->isPlaying = false;
     }
 
     JSS_UNLOCK(mp);
@@ -365,7 +365,7 @@
         if (result != DMERR_OK)
             JSSERROR(result,, "Could not initialize callback for player.\n");
 
-        mp->isPlaying = TRUE;
+        mp->isPlaying = true;
     }
 
     JSS_UNLOCK(mp);
@@ -378,16 +378,16 @@
  */
 static void jmpSetNewOrder(JSSPlayer * mp, int order)
 {
-    BOOL orderOK;
+    bool orderOK;
     mp->order = jsetNotSet;
-    orderOK = FALSE;
+    orderOK = false;
 
     while (!orderOK)
     {
         if (order < 0 || order >= mp->module->norders)
         {
             jmpStop(mp);
-            orderOK = TRUE;
+            orderOK = true;
         }
         else
         {
@@ -400,12 +400,12 @@
             if (pattern >= mp->module->npatterns || pattern == jsetOrderEnd)
             {
                 jmpStop(mp);
-                orderOK = TRUE;
+                orderOK = true;
             }
             else
             {
                 // All OK
-                orderOK = TRUE;
+                orderOK = true;
                 mp->pattern = mp->module->patterns[pattern];
                 mp->npattern = pattern;
                 mp->order = order;
@@ -462,7 +462,7 @@
         JSSERROR(result, result, "Could not initialize callback for player.\n");
     }
 
-    mp->isPlaying = TRUE;
+    mp->isPlaying = true;
     return DMERR_OK;
 }
 
@@ -704,7 +704,7 @@
         jmpChangeVolume(chn, channel, -paramY);
 }
 
-static void jmpTriggerNote(JSSPlayer * mp, JSSPlayerChannel *chn, BOOL newExtInstrument);
+static void jmpTriggerNote(JSSPlayer * mp, JSSPlayerChannel *chn, bool newExtInstrument);
 
 
 static void jmpDoMultiRetrigNote(JSSPlayer *mp, JSSPlayerChannel *chn, int channel)
@@ -712,7 +712,7 @@
     if (chn->lastMultiRetrigParamY != 0 &&
        (mp->tick % chn->lastMultiRetrigParamY) == 0)
     {
-        BOOL change = TRUE;
+        bool change = true;
         int volume = chn->volume;
         switch (chn->lastMultiRetrigParamX)
         {
@@ -731,9 +731,9 @@
             case 0xD: volume += 16; break;
             case 0xE: volume  = (volume * 3) / 2; break;
             case 0xF: volume *= 2; break;
-            default: change = FALSE;
+            default: change = false;
         }
-        jmpTriggerNote(mp, chn, FALSE);
+        jmpTriggerNote(mp, chn, false);
         if (change)
             jmpSetVolume(chn, channel, volume);
     }
@@ -766,7 +766,7 @@
             // Loop to specified row
             chn->iPatLoopCount--;
             mp->newRow = chn->iPatLoopRow;
-            mp->newRowSet = TRUE;
+            mp->newRowSet = true;
         }
     }
     else
@@ -813,7 +813,7 @@
  * Separate function used from various places where note
  * triggering is needed (retrig, multi-retrig, etc.)
  */
-static void jmpTriggerNote(JSSPlayer * mp, JSSPlayerChannel *chn, BOOL newExtInstrument)
+static void jmpTriggerNote(JSSPlayer * mp, JSSPlayerChannel *chn, bool newExtInstrument)
 {
     if (chn->nextInstrument >= 0 &&
         chn->nextInstrument < mp->module->nextInstruments &&
@@ -882,7 +882,7 @@
 static void jmpProcessNewRow(JSSPlayer * mp, int channel)
 {
     JSSNote *currNote;
-    BOOL newNote = FALSE, newExtInstrument = FALSE, volumePortaSet = FALSE;
+    bool newNote = false, newExtInstrument = false, volumePortaSet = false;
     char effect;
     int param, paramX, paramY;
     JSSPlayerChannel *chn = &(mp->channels[channel]);
@@ -891,14 +891,14 @@
 
     // Check for a new note/keyoff here
     if (currNote->note == jsetNoteOff)
-        chn->keyOff = TRUE;
+        chn->keyOff = true;
     else
     if (currNote->note >= 0 && currNote->note <= 96)
     {
-        newNote = TRUE;
+        newNote = true;
         chn->oldNote = chn->note;
         chn->note = currNote->note;
-        chn->keyOff = FALSE;
+        chn->keyOff = false;
     }
 
     // Check for new instrument
@@ -909,14 +909,14 @@
          */
         jmpResetEnvelope(&chn->volumeEnv);
         jmpResetEnvelope(&chn->panningEnv);
-        chn->keyOff = FALSE;
+        chn->keyOff = false;
         chn->fadeOutVol = mpMaxFadeoutVol;
 
         JMPSETNDFLAGS(cdfNewPanPos | cdfPlay | cdfNewVolume);
 
         // We save the instrument number here for later use
         chn->nextInstrument = currNote->instrument;
-        newExtInstrument = TRUE;
+        newExtInstrument = true;
     }
 
     if (newNote)
@@ -965,7 +965,7 @@
                 chn->pitch = chn->oldPitch;
                 chn->note = chn->oldNote;
                 JMPUNSETNDFLAGS(cdfNewPitch | cdfPlay);
-                volumePortaSet = TRUE;
+                volumePortaSet = true;
             }
             break;
     }
@@ -1072,8 +1072,8 @@
 
         case 'B':        // Bxx = Pattern Jump : IMPL.VERIFIED
             mp->newOrder = param;
-            mp->newOrderSet = TRUE;
-            mp->jumpFlag = TRUE;
+            mp->newOrderSet = true;
+            mp->jumpFlag = true;
             mp->lastPatLoopRow = 0;
             break;
 
@@ -1087,16 +1087,16 @@
             if (mp->newRow >= mp->pattern->nrows)
                 mp->newRow = 0;
 
-            mp->newRowSet = TRUE;
+            mp->newRowSet = true;
 
             // Now we do some tricky tests
             if (!mp->breakFlag && !mp->jumpFlag)
             {
                 mp->newOrder = mp->order + 1;
-                mp->newOrderSet = TRUE;
+                mp->newOrderSet = true;
             }
 
-            mp->breakFlag = TRUE;
+            mp->breakFlag = true;
             break;
 
         case 'E':         // Exy = Special Effects
@@ -1146,7 +1146,7 @@
 
                 case 0x09:    // E9x - Retrig note
                     if (mp->tick == paramY)
-                        jmpTriggerNote(mp, chn, FALSE);
+                        jmpTriggerNote(mp, chn, false);
                     break;
 
                 case 0x0a:    // EAx - Fine Volumeslide Up
@@ -1209,15 +1209,15 @@
             break;
 
         case 'K':        // Kxx = Key-off (Same as key-off note)
-            chn->keyOff = TRUE;
+            chn->keyOff = true;
             break;
 
         case 'L':        // Lxx = Set Envelope Position
             JMPDEBUG("Set Envelope Position used, NOT verified with FT2");
             chn->panningEnv.frame = param;
             chn->volumeEnv.frame = param;
-            chn->panningEnv.exec = TRUE;
-            chn->volumeEnv.exec = TRUE;
+            chn->panningEnv.exec = true;
+            chn->volumeEnv.exec = true;
             break;
 
         case 'R':        // Rxy = Multi Retrig note
@@ -1347,7 +1347,7 @@
             {
                 case 0x09:    // E9x - Retrig note
                     if (mp->tick == paramY)
-                        jmpTriggerNote(mp, chn, FALSE);
+                        jmpTriggerNote(mp, chn, false);
                     break;
 
                 case 0x0c: // ECx - Set Note Cut
@@ -1403,8 +1403,8 @@
         goto out;
 
     // Clear channel new data flags
-    mp->jumpFlag = FALSE;
-    mp->breakFlag = FALSE;
+    mp->jumpFlag = false;
+    mp->breakFlag = false;
 
     for (int channel = 0; channel < jsetNChannels; channel++)
         mp->channels[channel].newDataFlags = 0;
@@ -1416,7 +1416,7 @@
     {
         // Initialize pattern
         mp->newRow = 0;
-        mp->newRowSet = TRUE;
+        mp->newRowSet = true;
         mp->tick = mp->speed;
         mp->patternDelay = 0;
     }
@@ -1445,7 +1445,7 @@
             if (mp->newRowSet)
             {
                 mp->row = mp->newRow;
-                mp->newRowSet = FALSE;
+                mp->newRowSet = false;
             } else
                 mp->row++;
 
@@ -1456,7 +1456,7 @@
                 if (mp->order != jsetNotSet)
                     jmpSetNewOrder(mp, mp->order + 1);
                 else
-                    mp->isPlaying = FALSE;
+                    mp->isPlaying = false;
 
                 // Check for FT2 quirks
                 if (JMPGETMODFLAGS(mp, jmdfFT2Replay))
@@ -1472,7 +1472,7 @@
             if (mp->newOrderSet)
             {
                 jmpSetNewOrder(mp, mp->newOrder);
-                mp->newOrderSet = FALSE;
+                mp->newOrderSet = false;
             }
 
 //fprintf(stderr, "3: tick=%d, order=%d, iPattern=%d, row=%d\n", mp->tick, mp->order, mp->npattern, mp->row);
@@ -1551,7 +1551,7 @@
 
             if (flags & cdfNewVolume)
             {
-                BOOL init = flags & (cdfNewInstr | cdfPlay);
+                bool init = flags & (cdfNewInstr | cdfPlay);
                 jvmSetVolumeRamp(mp->device, channel,
                     init ? 0 : jvmGetVolume(mp->device, channel),
                     (chn->fadeOutVol * chn->volumeEnv.value * chn->volume) / (16 * 65536),