changeset 1235:5b8245e5f785

Remove trailing whitespace.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Mar 2015 13:40:47 +0200
parents beae399c6473
children b8c9af10b7fd
files tools/auval.c tools/data2inc.c tools/dumpmod.c tools/fontconv.c tools/gentab.c tools/gfxconv.c tools/lib64gfx.c tools/mod2wav.c tools/xm2jss.c
diffstat 9 files changed, 189 insertions(+), 187 deletions(-) [+]
line wrap: on
line diff
--- a/tools/auval.c	Fri Mar 06 13:38:53 2015 +0200
+++ b/tools/auval.c	Fri Mar 06 13:40:47 2015 +0200
@@ -25,7 +25,7 @@
 {
     DMEvalNode *expr;
     DMEvalContext *ctx;
-    
+
     double varTime, varFreq, varKeyTime,
            varKeyTimeRev, varKeyFreq, varUnit;
 
@@ -86,7 +86,7 @@
     case 2:
         dmVerbosity++;
         break;
-    
+
     case 3:
         optVFlags |= SDL_FULLSCREEN;
         break;
@@ -105,7 +105,7 @@
                 optScrWidth = w;
                 optScrHeight = h;
             }
-            else 
+            else
             {
                 dmErrorMsg("Invalid size argument '%s'.\n", optArg);
                 return FALSE;
@@ -148,7 +148,7 @@
     case 10:
         optClipping = FALSE;
         break;
-    
+
     case 11:
         optScale = FALSE;
         break;
@@ -157,7 +157,7 @@
         dmErrorMsg("Unknown option '%s'.\n", currArg);
         return FALSE;
     }
-    
+
     return TRUE;
 }
 
@@ -173,7 +173,7 @@
 int au_editbuf_write(AUEditBuf *buf, ssize_t pos, int ch)
 {
     if (buf->len+1 >= buf->size) return -3;
-    
+
     if (pos < 0)
         return -1;
     else if (pos >= buf->len) {
@@ -189,7 +189,7 @@
 int au_editbuf_insert(AUEditBuf *buf, ssize_t pos, int ch)
 {
     if (buf->len+1 >= buf->size) return -3;
-    
+
     if (pos < 0)
         return -1;
     else if (pos >= buf->len) {
@@ -229,11 +229,11 @@
 AUEditBuf * au_editbuf_new(ssize_t n)
 {
     AUEditBuf *res = dmCalloc(1, sizeof(AUEditBuf));
-    
+
     res->data = (char *) dmMalloc(n);
     res->size = n;
     res->dirty = TRUE;
-    
+
     return res;
 }
 
@@ -260,16 +260,16 @@
 AUEditBuf * au_editbuf_copy(AUEditBuf *src)
 {
     AUEditBuf *res;
-    
+
     if (src == NULL) return NULL;
-    
+
     if ((res = au_editbuf_new(src->size)) == NULL)
         return NULL;
-    
+
     memcpy(res->data, src->data, src->size);
     res->pos = res->len = src->len;
     res->dirty = TRUE;
-    
+
     return res;
 }
 
@@ -278,7 +278,7 @@
 {
     char *str;
     ssize_t siz;
-    
+
     if (buf == NULL)
         return NULL;
 
@@ -495,7 +495,7 @@
         for (i = 0; tmpStr[i] != 0 && i < 512; i++);
         while (--i >= 0 && (tmpStr[i] == '\n' || tmpStr[i] == '\r' || isspace(tmpStr[i])))
             tmpStr[i] = 0;
-        
+
         /* Add to history only if it's not an empty line */
         if (tmpStr[0] != 0)
         {
@@ -552,7 +552,7 @@
     AUAudioData *data = (AUAudioData *) udata;
 
     dmMutexLock(data->mutex);
-    
+
     data->avail = 0;
 
     if (!data->ctx->err)
@@ -570,7 +570,7 @@
             {
                 if (optClipping)
                     value = ((value < -1.0f) ? -1.0f : ((value > 1.0f) ? 1.0f : value));
-                
+
                 value = 128 + (value * 126);
             }
             else
@@ -588,7 +588,7 @@
             if (data->varKeyTime > 1.0f)
                 data->varKeyTime = 1.0f;
         }
-        
+
         if (data->avail >= len && !data->ctx->err)
         {
             memcpy(buf, data->buf, len);
@@ -597,7 +597,7 @@
         else
             dmMemset(buf, 0, len);
     }
-        
+
     dmMutexUnlock(data->mutex);
 }
 
@@ -641,7 +641,7 @@
     /* Initialize evaluator ctx */
     audata.ctx = dmEvalContextNew();
     audata.expr = NULL;
-    
+
     dmEvalContextAddVar(audata.ctx, "t", &audata.varTime);
     dmEvalContextAddVar(audata.ctx, "k", &audata.varKeyTime);
     dmEvalContextAddVar(audata.ctx, "q", &audata.varKeyTimeRev);
@@ -671,7 +671,7 @@
         goto error_exit;
     }
     TTF_SetFontStyle(font, TTF_STYLE_NORMAL);
-    
+
     if (!au_init_video(&screen))
         goto error_exit;
 
@@ -703,7 +703,7 @@
 
     SDL_PauseAudio(0);
     SDL_PauseAudio(1);
-    
+
 
     /* Create visualizer bitmap surface */
     bmp = SDL_CreateRGBSurface(SDL_SWSURFACE, optBMPSize, optBMPSize, 8, 0, 0, 0, 0);
@@ -763,7 +763,7 @@
                         needRedraw |= REDRAW_VISUALIZER;
                         break;
 
-                    
+
                     case SDLK_F6:
                         viewMode = (viewMode + 1) % 2;
                         needRedraw |= REDRAW_VISUALIZER;
@@ -783,7 +783,7 @@
                     case SDLK_ESCAPE:
                         exitFlag = TRUE;
                         break;
-                    
+
                     case SDLK_RETURN:
                         /* Add to history buffer */
                         if (!jazzMode && editBuf->len > 0)
@@ -794,16 +794,16 @@
                                 histBuf[optHistoryLen+1] = NULL;
                                 memmove(&histBuf[2], &histBuf[1], histMax * sizeof(histBuf[0]));
                             }
-                            
+
                             histPos = 0;
                             histBuf[1] = au_editbuf_copy(editBuf);
                             if (histMax < optHistoryLen) histMax++;
-                            
+
                             au_editbuf_insert(editBuf, editBuf->len, 0);
 
                             /* You could do something here with the data ... */
                             //result = handleUserInput(conn, editBuf->data, editBuf->len);
-                            
+
                             au_editbuf_clear(editBuf);
                         }
                         break;
@@ -824,7 +824,7 @@
                             editBuf = au_editbuf_copy(histBuf[histPos]);
                         }
                         break;
-                        
+
                     case SDLK_DOWN: /* Forwards in input history */
                         if (jazzMode)
                             break;
@@ -836,7 +836,7 @@
                             editBuf = au_editbuf_copy(histBuf[histPos]);
                         }
                         break;
-                        
+
                     case SDLK_LEFT:
                         if (jazzMode)
                             break;
@@ -854,7 +854,7 @@
                             au_editbuf_setpos(editBuf, editBuf->pos - 1);
                         }
                         break;
-                    
+
                     case SDLK_RIGHT:
                         if (jazzMode)
                             break;
@@ -886,7 +886,7 @@
 
                         au_editbuf_setpos(editBuf, editBuf->len);
                         break;
-                    
+
                     case SDLK_BACKSPACE:
                         if (jazzMode)
                             break;
@@ -894,21 +894,21 @@
                         au_editbuf_delete(editBuf, editBuf->pos - 1);
                         au_editbuf_setpos(editBuf, editBuf->pos - 1);
                         break;
-                    
+
                     case SDLK_DELETE: /* Delete character */
                         if (jazzMode)
                             break;
 
                         au_editbuf_delete(editBuf, editBuf->pos);
                         break;
-                        
+
                     case SDLK_INSERT: /* Ins = Toggle insert / overwrite mode */
                         if (jazzMode)
                             break;
 
                         insertMode = !insertMode;
                         break;
-                    
+
                     default:
                         if (jazzMode)
                         {
@@ -936,7 +936,7 @@
                                 {
                                     period = 7680 - (note * 64) - (/* finetune */ 128 / 2);
                                     if (period < 1) period = 1;
-                                
+
                                     dmMutexLock(audata.mutex);
                                     audata.varFreq = 8363.0f * pow(2.0f, (4608.0f - (double) period) / 768.0f) / optAudioFreq ;
                                     audata.pos = 0;
@@ -944,7 +944,7 @@
                                     audata.varKeyTime = 0;
                                     audata.varUnit = 0;
                                     dmMutexUnlock(audata.mutex);
-                                
+
                                     audioPlaying = TRUE;
                                     SDL_PauseAudio(!audioPlaying);
                                 }
@@ -969,7 +969,7 @@
                 }
                 needRedraw |= REDRAW_EDITOR | REDRAW_INFO;
                 break;
-            
+
             case SDL_VIDEORESIZE:
                 /* Window resized, reinit video etc */
                 optScrWidth = event.resize.w;
@@ -980,7 +980,7 @@
 
                 needRedraw = REDRAW_ALL;
                 break;
-            
+
             case SDL_VIDEOEXPOSE:
                 /* Window exposed, redraw everything just to be sure */
                 needRedraw = REDRAW_ALL;
@@ -999,9 +999,9 @@
         {
             editBuf->dirty = FALSE;
             editBuf->data[editBuf->len] = 0;
-            
+
             dmMutexLock(audata.mutex);
-            
+
             dmEvalTreeFree(audata.expr);
             audata.expr = NULL;
             audata.ctx->err = dmEvalParseExpr(audata.ctx, editBuf->data, &audata.expr);
@@ -1016,7 +1016,7 @@
 
             dmMutexUnlock(audata.mutex);
         }
-        
+
         /* Check if visualizer needs redrawing
          */
         if (audata.pos != audata.oldpos)
@@ -1037,7 +1037,7 @@
             /* Clear the surface, draw copyright etc */
             int fh = TTF_FontHeight(font);
             int eh = screen->h - fh * 4;
-            
+
             if (needRedraw & REDRAW_INFO)
             {
                 dmFillBox3D(screen, 0, 0, screen->w - 1, fh + 5, dmMapRGB(screen, 50, 50, 150),
@@ -1074,7 +1074,7 @@
                         dmScaledBlitSurfaceAny(bmp, 5, fh * 2 + 15, screen->w - 10, eh - fh * 2 - 30, screen, DMD_NONE);
                         vms = "bitmap";
                         break;
-                    
+
                     default:
                         vms = "?";
                 }
@@ -1085,7 +1085,7 @@
                     );
             }
 
-            /* Draw the function editor box */                
+            /* Draw the function editor box */
             if (needRedraw & REDRAW_EDITOR)
             {
                 dmMutexLock(audata.mutex);
@@ -1096,7 +1096,7 @@
 
                 au_draw_editbuf(screen, font, fontcol, 5, eh - 10, screen->w - 10, eh - 15, editBuf,
                     dmMapRGB(screen, 0, 0, 150));
-                
+
                 if (audata.ctx->err && audata.ctx->errStr != NULL)
                     dmDrawTTFTextConst(screen, font, fontcol, 5, screen->h - fh, audata.ctx->errStr);
 
@@ -1109,7 +1109,7 @@
             SDL_Flip(screen);
             needRedraw = 0;
         }
-        
+
         SDL_Delay(50);
     }
 
--- a/tools/data2inc.c	Fri Mar 06 13:38:53 2015 +0200
+++ b/tools/data2inc.c	Fri Mar 06 13:40:47 2015 +0200
@@ -63,7 +63,7 @@
         "[options] [sourcefile] [destfile]");
 
     dmArgsPrintHelp(stdout, optList, optListN, 0);
-    
+
     printf(
     "\n"
     "To convert a data file to a C structure using 'Uint8' as type:\n"
--- a/tools/dumpmod.c	Fri Mar 06 13:38:53 2015 +0200
+++ b/tools/dumpmod.c	Fri Mar 06 13:40:47 2015 +0200
@@ -44,7 +44,7 @@
 BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
 {
     (void) optArg;
-    
+
     switch (optN)
     {
         case 0:
@@ -80,7 +80,7 @@
             dmErrorMsg("Unknown argument '%s'.\n", currArg);
             return FALSE;
     }
-    
+
     return TRUE;
 }
 
@@ -94,7 +94,7 @@
         dmErrorMsg("Gay error '%s'!\n", currArg);
         return FALSE;
     }
-    
+
     return TRUE;
 }
 
@@ -162,7 +162,7 @@
                 fprintf(f, "%.2x ", n->instrument + 1); // Because FT2 is 1-based and we use 0 internally
             else
                 fprintf(f, ".. ");
-            
+
             if (n->volume == jsetNotSet)
                 fprintf(f, ".. ");
             else if (n->volume >= 0x00 && n->volume <= 0x40)
@@ -185,7 +185,7 @@
                 }
                 fprintf(f, "%c%x ", c, (n->volume & 0x0f));
             }
-            
+
             if (n->effect >= 0 && n->effect < jmpNMODEffectTable)
                 fprintf(f, "%c", jmpMODEffectTable[n->effect]);
             else if (n->effect == jsetNotSet)
@@ -268,7 +268,7 @@
         printEnvelope(f, &inst->volumeEnv, "Volume");
         printEnvelope(f, &inst->panningEnv, "Panning");
     }
-    
+
     if (dmVerbosity >= 2)
     {
         int n;
@@ -353,7 +353,7 @@
 void printGeneralInfo(FILE *f, JSSModule *m)
 {
     int i;
-    
+
     if (!m)
         return;
 
@@ -372,14 +372,14 @@
         "Tempo...........: %d bpm\n"
         "Flags...........: %x ",
         m->defSpeed, m->defTempo, m->defFlags);
-    
+
     if (m->defFlags & jmdfAmigaPeriods) fprintf(f, "[Amiga periods] ");
     if (m->defFlags & jmdfAmigaLimits)  fprintf(f, "[Amiga limits] ");
     if (m->defFlags & jmdfStereo)       fprintf(f, "[stereo] ");
     if (m->defFlags & jmdfFT2Replay)    fprintf(f, "[FT2 replay] ");
     if (m->defFlags & jmdfST300Slides)  fprintf(f, "[ST300 slides] ");
     if (m->defFlags & jmdfByteLStart)   fprintf(f, "[ByteStart] ");
-    
+
     fprintf(f, "\n"
         "Restart pos.....: %d (order)\n"
         "IntVersion......: %x\n"
@@ -428,7 +428,7 @@
         result = dmf_create_stdio_stream(stdin, &file);
     else
         result = dmf_create_stdio(optFilename, "rb", &file);
-    
+
     if (result != DMERR_OK)
     {
         dmErrorMsg("Error opening input file '%s', #%d: %s\n",
--- a/tools/fontconv.c	Fri Mar 06 13:38:53 2015 +0200
+++ b/tools/fontconv.c	Fri Mar 06 13:40:47 2015 +0200
@@ -95,7 +95,7 @@
                         optArg);
                     return FALSE;
                 }
-                
+
                 optColor.r = colR;
                 optColor.g = colG;
                 optColor.b = colB;
@@ -107,7 +107,7 @@
             dmErrorMsg("Unknown argument '%s'.\n", currArg);
             return FALSE;
     }
-    
+
     return TRUE;
 }
 
@@ -124,7 +124,7 @@
         dmErrorMsg("Too many filename arguments, '%s'\n", currArg);
         return FALSE;
     }
-    
+
     return TRUE;
 }
 
@@ -136,10 +136,10 @@
 
     if (image->w < width || width < 2 || image->h < height || height < 2)
         return DMERR_INVALID_ARGS;
-    
+
     xglyphs = image->w / width;
     yglyphs = image->h / height;
-    
+
     if ((font = dmNewBitmapFont(xglyphs * yglyphs, width, height)) == NULL)
         return DMERR_MALLOC;
 
@@ -147,7 +147,7 @@
         image->w, image->h,
         width, height,
         xglyphs, yglyphs, xglyphs * yglyphs);
-    
+
     nglyph = 0;
     for (yc = 0; yc < yglyphs; yc++)
     for (xc = 0; xc < xglyphs; xc++)
@@ -158,7 +158,7 @@
             image->format->Gmask,
             image->format->Bmask,
             image->format->Amask);
-        
+
         if (glyph == NULL)
         {
             dmFreeBitmapFont(font);
@@ -170,12 +170,12 @@
         r.y = yc * height;
         r.w = width;
         r.h = height;
-        
+
         SDL_BlitSurface(image, &r, glyph, NULL);
-        
+
         font->glyphs[nglyph++] = glyph;
     }
-    
+
     *pfont = font;
     return DMERR_OK;
 }
@@ -299,7 +299,7 @@
     }
     initTTF = TRUE;
 #endif
-    
+
     // Open the source file
     if ((res = dmf_create_stdio(optInFilename, "rb", &inFile)) != DMERR_OK)
     {
@@ -322,7 +322,7 @@
             optSplitWidth, optSplitHeight);
 
         TTF_SetFontStyle(ttf, TTF_STYLE_NORMAL);
-        
+
         if ((font = dmNewBitmapFont(256, optSplitWidth - 1, optSplitHeight+4)) == NULL)
         {
             goto error_exit;
@@ -364,7 +364,7 @@
         dmErrorMsg("No font loaded.\n");
         goto error_exit;
     }
-    
+
     dmMsg(1, "Outputting a DMFONT format bitmap font.\n");
 
     if ((res = dmf_create_stdio(optOutFilename, "wb", &outFile)) != DMERR_OK)
@@ -389,10 +389,10 @@
     if (initTTF)
         TTF_Quit();
 #endif
-    
+
     dmf_close(inFile);
     dmFreeBitmapFont(font);
     SDL_FreeSurface(fontbmap);
-    
+
     return 0;
 }
--- a/tools/gentab.c	Fri Mar 06 13:38:53 2015 +0200
+++ b/tools/gentab.c	Fri Mar 06 13:40:47 2015 +0200
@@ -100,15 +100,15 @@
         case 1:
             dmVerbosity++;
             break;
-        
+
         case 2:
             optOutFilename = optArg;
             break;
-        
+
         case 3:
             optObjectName = optArg;
             break;
-        
+
         case 4:
             {
                 int tmp;
@@ -192,7 +192,7 @@
         dmErrorMsg("No transformation type set, perhaps try --help\n");
         return -1;
     }
-    
+
     if (optObjectName == NULL)
     {
         dmErrorMsg("Object name not specified, try --help\n");
@@ -209,7 +209,7 @@
             optOutFilename, err, dmErrorStr(err));
         return -2;
     }
-    
+
 
     // Generate table
     dmLerpInit(&ctx, optStartValue, optEndValue, optNSteps);
@@ -225,7 +225,7 @@
     for (n = 0, step = 0; step < optNSteps; step++)
     {
         DMFloat t = ((DMFloat) step * optSOmega) / (DMFloat) optNSteps, delta, value;
-        
+
         switch (optTransType)
         {
             case MT_SIN:           delta = sin(t * 2 * DM_PI); break;
@@ -236,12 +236,12 @@
             case MT_SMOOTH1_CLAMP: delta = dmLerp1Clamp(&ctx, step); break;
             case MT_SCURVE_CLAMP:  delta = dmLerpSCurveClamp(&ctx, step); break;
             case MT_SIN_SCURVE:    delta = dmLerpSCurveClamp(&ctx, step); break;
-            
+
             default: delta = 0;
         }
-        
+
         value = optSOffset + delta * optSAmplitude;
-        
+
         // Print the value
         if (n == 0)
             fprintf(outFile, "\t.byte ");
@@ -258,7 +258,7 @@
     }
     if (n > 0)
         fprintf(outFile, "\n");
-    
+
     fprintf(outFile, "\n");
 
     return 0;
--- a/tools/gfxconv.c	Fri Mar 06 13:38:53 2015 +0200
+++ b/tools/gfxconv.c	Fri Mar 06 13:40:47 2015 +0200
@@ -184,7 +184,7 @@
     "  Ext | I | O | Description\n"
     "------+---+---+-----------------------------------------------\n"
     );
-    
+
     for (i = 0; i < nconvFormatList; i++)
     {
         DMConvFormat *fmt = &convFormatList[i];
@@ -363,11 +363,11 @@
         }
         value->triplet = FALSE;
     }
-    
+
     // Trim whitespace
     split++;
     while (*split && isspace(*split)) split++;
-    
+
     // Parse destination value
     if (!dmGetIntVal(split, &value->to))
     {
@@ -430,7 +430,7 @@
             return FALSE;
         }
     }
-    
+
     return TRUE;
 }
 
@@ -455,7 +455,7 @@
         start = end + 1;
     }
 
-    return TRUE;   
+    return TRUE;
 }
 
 
@@ -477,7 +477,7 @@
     {
         char *start = line;
         while (*start && isspace(*start)) start++;
-        
+
         if (*start != 0 && *start != ';')
         {
             if (!dmParseMapOptionMapItem(line, &values[*nvalue], nmax, "mapping file"))
@@ -531,7 +531,7 @@
                         dmErrorMsg("Invalid input format '%s'.\n", optArg);
                         return FALSE;
                 }
-            
+
                 char *tmp = strchr(optArg, ':');
                 if (tmp != NULL)
                 {
@@ -552,7 +552,7 @@
                                 return FALSE;
                             }
                             break;
-                        
+
                         case FFMT_BITMAP:
                             if (!dmGetC64FormatByExt(tmp, &optInFormat, &optInSubFormat))
                             {
@@ -565,7 +565,7 @@
                 }
             }
             break;
-        
+
         case 2:
             optInMulticolor = TRUE;
             break;
@@ -573,7 +573,7 @@
         case 3:
             optOutFilename = optArg;
             break;
-        
+
         case 4:
             if (!dmGetIntVal(optArg, &optInSkip))
             {
@@ -772,7 +772,7 @@
 void dmPrintByte(FILE *out, int byte, int format, BOOL multicolor)
 {
     int i;
-    
+
     if (multicolor)
     {
         for (i = DM_ASC_NBITS; i; i -= 2)
@@ -914,7 +914,7 @@
                     found = TRUE;
                 }
             }
-            
+
             if (!found)
             {
                 dmMsg(3, "No RGBA match found for map index %d, #%02x%02x%02x%02x\n",
@@ -932,7 +932,7 @@
         }
     }
 
-    
+
     // Fill in the rest
     if (optRemapRemove)
     {
@@ -971,7 +971,7 @@
         if (mapping[index] + 1 > ncolors)
             ncolors = mapping[index] + 1;
     }
-    
+
     // Copy palette entries
     for (index = 0; index < image->ncolors; index++)
     {
@@ -1103,7 +1103,7 @@
             {
                 FILE *fp;
                 char *dataFilename;
-                
+
                 // Form data file filename
                 dataFilename = dm_strdup_fext(filename, "%s.inc");
                 if (dataFilename == NULL)
@@ -1413,7 +1413,7 @@
                     bufSize, dataOffs);
                 error = TRUE;
             }
-            
+
             fprintf(outFile, "---- : -------------- #%d\n", itemCount);
 
             switch (optInFormat)
@@ -1459,12 +1459,12 @@
                 dmErrorMsg("Single-image output requires count to be set (-n).\n");
                 goto error;
             }
-            
+
             outIWidth = optPlanedWidth;
             outIHeight = (optItemCount / optPlanedWidth);
             if (optItemCount % optPlanedWidth)
                 outIHeight++;
-            
+
             outImage = dmImageAlloc(outWidthPX * outIWidth, outIHeight * outHeight);
         }
 
@@ -1472,7 +1472,7 @@
         outImage->pal      = dmC64Palette;
         outImage->ncolors  = C64_NCOLORS;
         outImage->ctransp  = 255;
-        
+
         while (!feof(inFile) && (optItemCount < 0 || itemCount < optItemCount))
         {
             dmMemset(bufData, 0, bufSize);
@@ -1499,7 +1499,7 @@
                     dmErrorMsg("Could not allocate memory for filename template?\n");
                     goto error;
                 }
-                
+
                 ret = dmWriteImage(optOutFilename, outImage, &optSpec, optOutSubFormat, TRUE);
                 if (ret != DMERR_OK)
                 {
@@ -1517,7 +1517,7 @@
                     outY++;
                 }
             }
-            
+
             itemCount++;
         }
 
@@ -1530,7 +1530,7 @@
                     ret, dmErrorStr(ret));
             }
         }
-        
+
         dmImageFree(outImage);
     }
     else
@@ -1634,7 +1634,7 @@
             dmMsg(1,"Probed %s format image, type %d, %s\n",
                 cfmt->name, cfmt->type, cfmt->fext);
         }
-        
+
         if (res == DMERR_OK)
             optInFormat = FFMT_BITMAP;
         else
@@ -1671,10 +1671,10 @@
             optInSkip, optInSkip, dmErrorStr(res));
         goto error;
     }
-    
+
     int inFormat = dmGetConvFormat(optInFormat, optInSubFormat),
         outFormat = dmGetConvFormat(optOutFormat, optOutSubFormat);
-    
+
     if (inFormat != -1 && outFormat != -1)
     {
         char *inFmtName = convFormatList[inFormat].name,
@@ -1695,7 +1695,7 @@
         case FFMT_CHAR:
             dmDumpSpritesAndChars(inFile);
             break;
-        
+
         case FFMT_BITMAP:
             {
                 DMImage *outImage = NULL;
@@ -1743,7 +1743,7 @@
                         dmErrorMsg("Unsupported output format for bitmap/image conversion.\n");
                         break;
                 }
-                
+
                 dmImageFree(outImage);
             }
             break;
@@ -1768,7 +1768,7 @@
 
                 if (res != DMERR_OK || outImage == NULL)
                     break;
-                
+
                 switch (optOutFormat)
                 {
                     case FFMT_IMAGE:
@@ -1790,7 +1790,7 @@
                     dmErrorMsg("Error writing output (%s), probably unsupported output format for bitmap/image conversion.\n",
                         dmErrorStr(res));
                 }
-                
+
                 dmImageFree(outImage);
             }
             break;
--- a/tools/lib64gfx.c	Fri Mar 06 13:38:53 2015 +0200
+++ b/tools/lib64gfx.c	Fri Mar 06 13:40:47 2015 +0200
@@ -1215,7 +1215,7 @@
         return DMERR_INVALID_DATA;
 
     // Allocate memory
-    if ((*img = dmC64ImageAlloc((*fmt)->width, (*fmt)->height, 
+    if ((*img = dmC64ImageAlloc((*fmt)->width, (*fmt)->height,
         (*fmt)->ch_width, (*fmt)->ch_height)) == NULL)
         return DMERR_MALLOC;
 
--- a/tools/mod2wav.c	Fri Mar 06 13:38:53 2015 +0200
+++ b/tools/mod2wav.c	Fri Mar 06 13:40:47 2015 +0200
@@ -49,13 +49,13 @@
 BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
 {
     (void) optArg;
-    
+
     switch (optN)
     {
         case 0:
             dmPrintBanner(stdout, dmProgName,
                 "[options] [sourcefile] [destfile]");
-                
+
             dmArgsPrintHelp(stdout, optList, optListN, 0);
             exit(0);
             break;
@@ -63,7 +63,7 @@
         case 2:
             dmVerbosity++;
             break;
-        
+
         case 3:
             optOutFormat = JSS_AUDIO_S16;
             break;
@@ -101,7 +101,7 @@
             dmErrorMsg("Unknown argument '%s'.\n", currArg);
             return FALSE;
     }
-    
+
     return TRUE;
 }
 
@@ -118,7 +118,7 @@
         dmErrorMsg("Too many filename arguments (only source and dest needed) '%s'\n", currArg);
         return FALSE;
     }
-    
+
     return TRUE;
 }
 
@@ -148,10 +148,10 @@
         dmErrorMsg("Input or output file not specified. Try --help.\n");
         return 1;
     }
-    
+
     // Initialize miniJSS
     jssInit();
-    
+
     // Open the source file
     if ((result = dmf_create_stdio(optInFilename, "rb", &inFile)) != DMERR_OK)
     {
@@ -216,32 +216,32 @@
         dmErrorMsg("Could not allocate mixing buffer\n");
         return 5;
     }
-    
+
     dmMsg(1, "Using fmt=%d, bits=%d, channels=%d, freq=%d [%d / sample]\n",
         optOutFormat, jvmGetSampleRes(dev), optOutChannels, optOutFreq,
         sampSize);
-    
+
     // Initialize player
     if ((plr = jmpInit(dev)) == NULL)
     {
         dmErrorMsg("jmpInit() returned NULL.\n");
         return 6;
     }
-    
+
     // Set callback
     jvmSetCallback(dev, jmpExec, plr);
-    
+
     // Initialize playing
     jmpSetModule(plr, mod);
     if (optStartOrder >= 0)
-    { 
+    {
         dmMsg(1, "Starting from song order #%d\n", optStartOrder);
     } else
         optStartOrder = 0;
 
     jmpPlayOrder(plr, optStartOrder);
     jvmSetGlobalVol(dev, 150);
-    
+
     if (optMuteOChannels > 0 && optMuteOChannels <= mod->nchannels)
     {
         int i;
@@ -249,7 +249,7 @@
             jvmMute(dev, i, TRUE);
         jvmMute(dev, optMuteOChannels - 1, FALSE);
     }
-    
+
     // Open output file
     if ((outFile = fopen(optOutFilename, "wb")) == NULL)
     {
@@ -266,7 +266,7 @@
         dmMsg(1, "Rendering module (%d seconds) ...\n", optPlayTime);
     else
         dmMsg(1, "Rendering module ...\n");
-    
+
     optPlayTime *= optOutFreq;
     dataTotal = 0;
     dataWritten = 1;
@@ -275,7 +275,7 @@
         size_t writeLen = bufLen;
         if (optUsePlayTime && (writeLen + dataTotal) > optPlayTime)
             writeLen = optPlayTime - dataTotal;
-        
+
         if (writeLen > 0)
         {
             jvmRenderAudio(dev, mb, writeLen);
@@ -291,20 +291,20 @@
             }
             dataTotal += dataWritten;
         }
-        
+
         if (optUsePlayTime && dataTotal >= optPlayTime)
             break;
     }
-    
+
     // Write the correct header
     if (fseek(outFile, 0L, SEEK_SET) != 0)
     {
         dmErrorMsg("Error rewinding to header position!\n");
         return 9;
     }
-    
+
     dmWriteWAVHeader(outFile, jvmGetSampleRes(dev), optOutFreq, optOutChannels, dataTotal);
-    
+
     // Done!
     fclose(outFile);
 
--- a/tools/xm2jss.c	Fri Mar 06 13:38:53 2015 +0200
+++ b/tools/xm2jss.c	Fri Mar 06 13:40:47 2015 +0200
@@ -69,10 +69,10 @@
 
     printf("\n"
     "Pattern storage modes:\n");
-    
+
     for (i = 1; i < PATMODE_LAST; i++)
         printf("  %d = %s\n", i, patModeTable[i-1]);
-    
+
     printf(
     "\n"
     "Sample data conversion flags (summative):\n"
@@ -87,7 +87,7 @@
 BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
 {
     (void) optArg;
-    
+
     switch (optN)
     {
     case 0:
@@ -125,7 +125,7 @@
         dmErrorMsg("Unknown argument '%s'.\n", currArg);
         return FALSE;
     }
-    
+
     return TRUE;
 }
 
@@ -143,7 +143,7 @@
         dmErrorMsg("Too many filename arguments specified, '%s'.\n", currArg);
         return FALSE;
     }
-    
+
     return TRUE;
 }
 
@@ -207,14 +207,14 @@
         JSSERROR(DMERR_BOUNDS, DMERR_BOUNDS, "Note value out of bounds %d > 0x7f.\n", tmp);
 
     JSPUTBYTE(tmp & 0x7f);
-    
+
     JSCONVPUT(pnote->instrument, "Instrument");
     JSCONVPUT(pnote->volume, "Volume");
     JSCONVPUT(pnote->effect, "Effect");
-    
+
     tmp = (pnote->param != jsetNotSet) ? pnote->param : 0;
     JSPUTBYTE(tmp);
-    
+
     return DMERR_OK;
 }
 
@@ -229,7 +229,7 @@
     int qcomp = 0;
 
     // Determine what would get stored,
-    // aka actually how much space we use    
+    // aka actually how much space we use
     JSCOMP(pnote->note,       JM_COMP_NOTE);
     JSCOMP(pnote->instrument, JM_COMP_INSTRUMENT);
     JSCOMP(pnote->volume,     JM_COMP_VOLUME);
@@ -239,12 +239,12 @@
         qflags |= JM_COMP_PARAM;
         qcomp++;
     }
-    
+
     if (qcomp < 4)
     {
         // Okay, it's less than 4 bytes, so use compressed
         JSPUTBYTE(qflags | 0x80);
-        
+
         if (pnote->note != jsetNotSet)
         {
             Uint8 tmp = (pnote->note != jsetNoteOff) ? pnote->note : 127;
@@ -252,7 +252,7 @@
                 JSSERROR(DMERR_BOUNDS, DMERR_BOUNDS, "Note value out of bounds %d > 0x7f.\n", tmp);
             JSPUTBYTE(tmp);
         }
-        
+
         JSCOMPPUT(JM_COMP_INSTRUMENT, pnote->instrument, "Instrument");
         JSCOMPPUT(JM_COMP_VOLUME, pnote->volume, "Volume");
         JSCOMPPUT(JM_COMP_EFFECT, pnote->effect, "Effect");
@@ -276,7 +276,7 @@
 {
     int row, channel;
     *patSize = 0;
-    
+
     for (row = 0; row < pattern->nrows; row++)
     for (channel = 0; channel < pattern->nchannels; channel++)
     {
@@ -289,7 +289,7 @@
             return res;
         }
     }
-    
+
     return DMERR_OK;
 }
 
@@ -300,7 +300,7 @@
 {
     int row, channel;
     *patSize = 0;
-    
+
     for (channel = 0; channel < pattern->nchannels; channel++)
     for (row = 0; row < pattern->nrows; row++)
     {
@@ -313,7 +313,7 @@
             return res;
         }
     }
-    
+
     return DMERR_OK;
 }
 
@@ -326,7 +326,7 @@
 {
     int row, channel;
     *patSize = 0;
-    
+
     for (row = 0; row < pattern->nrows; row++)
     for (channel = 0; channel < pattern->nchannels; channel++)
     {
@@ -339,7 +339,7 @@
             return res;
         }
     }
-    
+
     return DMERR_OK;
 }
 
@@ -350,7 +350,7 @@
 {
     int row, channel;
     *patSize = 0;
-    
+
     for (channel = 0; channel < pattern->nchannels; channel++)
     for (row = 0; row < pattern->nrows; row++)
     {
@@ -363,7 +363,7 @@
             return res;
         }
     }
-    
+
     return DMERR_OK;
 }
 
@@ -382,7 +382,7 @@
     Uint8 tmp;
     int row, channel;
     *patSize = 0;
-    
+
     JSFOREACHNOTE1;
     if (pnote->note == jsetNotSet)
         tmp = 0;
@@ -397,24 +397,24 @@
 
     JSPUTBYTE(tmp);
     JSFOREACHNOTE2;
-    
+
     JSFOREACHNOTE1;
     JSCONVPUT(pnote->instrument, "Instrument");
     JSFOREACHNOTE2;
-    
+
     JSFOREACHNOTE1;
     JSCONVPUT(pnote->volume, "Volume");
     JSFOREACHNOTE2;
-    
+
     JSFOREACHNOTE1;
     JSCONVPUT(pnote->effect, "Effect");
     JSFOREACHNOTE2;
-    
+
     JSFOREACHNOTE1;
     tmp = (pnote->param != jsetNotSet) ? pnote->param : 0;
     JSPUTBYTE(tmp);
     JSFOREACHNOTE2;
-    
+
     return DMERR_OK;
 }
 
@@ -425,13 +425,13 @@
 static void jssCopyEnvelope(JSSMODEnvelope *je, JSSEnvelope *e)
 {
     int i;
-    
+
     je->flags   = e->flags;
     je->npoints = e->npoints;
     je->sustain = e->sustain;
     je->loopS   = e->loopS;
     je->loopE   = e->loopE;
-    
+
     for (i = 0; i < e->npoints; i++)
     {
         je->points[i].frame = e->points[i].frame;
@@ -508,14 +508,16 @@
         JSSPattern *pat = m->patterns[pattern];
         JSSMODPattern patHead;
         size_t finalSize = 0;
-        
+
         if (pat == NULL)
             JSSERROR(DMERR_NULLPTR, DMERR_NULLPTR,
             "Pattern #%d was NULL.\n", pattern);
+
         if (pat->nrows > jsetMaxRows)
             JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA,
             "Pattern #%d has %d rows > %d max.\n",
             pattern, pat->nrows, jsetMaxRows);
+
         switch (patMode)
         {
             case PATMODE_RAW_HORIZ:
@@ -572,7 +574,7 @@
     {
         JSSMODExtInstrument jssE;
         JSSExtInstrument *einst = m->extInstruments[instr];
-        
+
         dmMemset(&jssE, 0, sizeof(jssE));
 
         if (einst)
@@ -584,7 +586,7 @@
                 int snum = einst->sNumForNotes[i];
                 jssE.sNumForNotes[i] = (snum != jsetNotSet) ? snum + 1: 0;
             }
-            
+
             jssCopyEnvelope(&jssE.volumeEnv, &(einst->volumeEnv));
             jssCopyEnvelope(&jssE.panningEnv, &(einst->panningEnv));
             jssE.vibratoType  = einst->vibratoType;
@@ -593,7 +595,7 @@
             jssE.fadeOut      = einst->fadeOut;
         } else
             JSSWARNING(DMERR_NULLPTR, DMERR_NULLPTR, "Extended instrument #%d NULL!\n", instr);
-        
+
         // Write to file
         totalSize += sizeof(jssE);
         if (fwrite(&jssE, sizeof(jssE), 1, outFile) != 1)
@@ -626,9 +628,9 @@
             jssI.hasData      = (inst->data != NULL) ? TRUE : FALSE;
             jssI.convFlags    = (inst->flags & jsf16bit) ? flags16 : flags8;
         }
-        else 
+        else
             JSSWARNING(DMERR_NULLPTR, DMERR_NULLPTR, "Instrument #%d NULL!\n", instr);
-        
+
         // Write to file
         totalSize += sizeof(jssI);
         if (fwrite(&jssI, sizeof(jssI), 1, outFile) != 1)
@@ -636,7 +638,7 @@
              "Could not write JSSMOD instrument #%d to file!\n", instr);
     }
     dmMsg(1," * %d Instrument headers, %d bytes.\n", m->ninstruments, totalSize);
-    
+
     // Write sample data
     for (totalSize = instr = 0; instr < m->ninstruments; instr++)
     if (m->instruments[instr])
@@ -655,7 +657,7 @@
                 jssEncodeSample8(inst->data, inst->size, flags8);
                 res = fwrite(inst->data, sizeof(Uint8), inst->size, outFile);
             }
-            
+
             totalSize += inst->size;
             if (res != (size_t) inst->size)
                 JSSERROR(DMERR_FWRITE, DMERR_FWRITE,
@@ -663,7 +665,7 @@
         }
     }
     dmMsg(1," * %d samples, %d bytes.\n", m->ninstruments, totalSize);
-    
+
     return DMERR_OK;
 }
 
@@ -698,7 +700,7 @@
     r->norders          = m->norders;
     for (i = 0; i < jsetNChannels; i++)
         r->defPanning[i] = m->defPanning[i];
-    
+
     // Initialize values
     for (i = 0; i <= jsetMaxInstruments; i++)
     {
@@ -707,7 +709,7 @@
         mapExtInstruments[i]  = jsetNotSet;
         mapInstruments[i]     = jsetNotSet;
     }
-    
+
     for (i = 0; i <= jsetMaxPatterns; i++)
     {
         usedPatterns[i] = FALSE;
@@ -728,10 +730,10 @@
             {
                 int row, channel;
                 JSSNote *n = p->data;
-                
+
                 // Mark this pattern as used
                 usedPatterns[pattern] = TRUE;
-                
+
                 // Check all notes in this pattern to see what instruments are used
                 for (row = 0; row < p->nrows; row++)
                 for (channel = 0; channel < p->nchannels; channel++, n++)
@@ -760,12 +762,12 @@
         {
             dmErrorMsg("Order 0x%x has invalid pattern number 0x%x, changing to empty!\n",
                 i, pattern);
-            
+
             // Fix it.
             m->orderList[i] = jsetMaxPatterns;
         }
     }
-    
+
     //
     // Find used sample instruments
     //
@@ -812,7 +814,7 @@
             dmErrorMsg("Pattern 0x%x used but is NULL.\n", i);
             continue;
         }
-        
+
         mapPatterns[i] = r->npatterns;
         r->patterns[r->npatterns] = m->patterns[i];
         (r->npatterns)++;
@@ -823,8 +825,8 @@
 
     dmMsg(1, "%d used patterns (%d unused).\n",
         r->npatterns, unused);
-    
-    
+
+
     //
     // Re-map instruments
     //
@@ -867,7 +869,7 @@
     dmPrint(2, "\n");
     dmMsg(1, "Total of %d [16-bit] + %d [8-bit] samples = %d instruments (%d unused).\n",
         n16, n8, r->ninstruments, unused);
-    
+
     //
     // Re-map ext.instruments
     //
@@ -938,7 +940,7 @@
         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++)
         {
@@ -974,7 +976,7 @@
             }
         }
     }
-    
+
     //
     // Remap orders list
     //
@@ -1039,12 +1041,12 @@
     // Check stripping settings
     if (optStripExtInstr) optStripInstr = TRUE;
     if (optStripInstr) optStripSamples = TRUE;
-    
+
     // Remove samples
     if (optStripSamples)
     {
         int i;
-        
+
         dmMsg(1, "Stripping samples...\n");
         for (i = 0; i < sm->ninstruments; i++)
         {
@@ -1057,7 +1059,7 @@
     if (optStripInstr)
     {
         int i;
-        
+
         dmMsg(1, "Stripping instruments...\n");
         for (i = 0; i < sm->ninstruments; i++)
         {
@@ -1071,7 +1073,7 @@
     if (optStripExtInstr)
     {
         int i;
-        
+
         dmMsg(1, "Stripping ext.instruments...\n");
         for (i = 0; i < sm->nextInstruments; i++)
         {
@@ -1099,13 +1101,13 @@
 
     dmMsg(1, "Writing JSSMOD-format file [patMode=0x%04x, samp8=0x%02x, samp16=0x%02x]\n",
         optPatternMode, optSampMode8, optSampMode16);
-    
+
     result = jssSaveJSSMOD(outFile, dm, optPatternMode, optSampMode8, optSampMode16);
 
     dmFree(sm);
 
     fclose(outFile);
-    
+
     if (result != 0)
     {
         dmErrorMsg(