changeset 1219:62a76a3d9bc2

Merged.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Mar 2015 09:45:55 +0200
parents 30c2dbf05841 (current diff) 96ad216e9b59 (diff)
children fc2ab4dcd046
files minijss/jloadjss.c
diffstat 3 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/minijss/jloadjss.c	Fri Mar 06 09:45:13 2015 +0200
+++ b/minijss/jloadjss.c	Fri Mar 06 09:45:55 2015 +0200
@@ -349,13 +349,14 @@
     *ppModule = module;
 
     // Copy header information
+    module->defFlags        = jssH.defFlags;
+    module->intVersion      = jssH.intVersion;
+
     module->norders         = jssH.norders;
     module->npatterns       = jssH.npatterns;
     module->nchannels       = jssH.nchannels;
     module->nextInstruments = jssH.nextInstruments;
     module->ninstruments    = jssH.ninstruments;
-    module->defFlags        = jssH.defFlags;
-    module->intVersion      = jssH.intVersion;
     module->defRestartPos   = jssH.defRestartPos;
     module->defSpeed        = jssH.defSpeed;
     module->defTempo        = jssH.defTempo;
--- a/minijss/jloadxm.c	Fri Mar 06 09:45:13 2015 +0200
+++ b/minijss/jloadxm.c	Fri Mar 06 09:45:55 2015 +0200
@@ -319,11 +319,10 @@
 
     for (index = 0; index < module->npatterns; index++)
     {
-        // Get the pattern header
         off_t remainder, pos = dmftell(inFile);
         Uint32 headSize;
 
-        // Get the pattern header size
+        // Get the pattern header size and packing
         if (!dmf_read_le32(inFile, &xmP.headSize) ||
             !dmf_read_byte(inFile, &xmP.packing))
             JSSERROR(DMERR_FREAD, DMERR_FREAD,
@@ -334,16 +333,19 @@
         if (module->intVersion == 0x0102)
         {
             Uint8 tmp;
+            // 0x0102 has one byte number of rows
             ret = dmf_read_byte(inFile, &tmp);
             xmP.nrows = ((Uint16) tmp) + 1;
             headSize = 4 + 1 + 1 + 2;
         }
         else
         {
+            // 0x0104 has 16-bit word for nrows
             ret = dmf_read_le16(inFile, &xmP.nrows);
             headSize = 4 + 1 + 2 + 2;
         }
 
+        // Check header size against known values
         if (headSize != xmP.headSize)
         {
             JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED,
@@ -351,6 +353,7 @@
             index, xmP.headSize, headSize);
         }
 
+        // Read rest of the header
         if (!ret || !dmf_read_le16(inFile, &xmP.size))
         {
             JSSERROR(DMERR_FREAD, DMERR_FREAD,
@@ -358,7 +361,7 @@
             index);
         }
 
-        // Check rest of the header data
+        // Sanity-check rest of the header data
         if (xmP.packing != 0)
             JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA,
             "Pattern #%d packing type unsupported (%d)\n",
@@ -391,7 +394,7 @@
                 JSSERROR(ret, ret, "Error in unpacking pattern #%d data\n", index);
         }
 
-        // Skip extra data (if the file is damaged)
+        // Skip extra data if there is any .. shouldn't usually happen tho.
         remainder = xmP.headSize - (dmftell(inFile) - pos);
         if (remainder > 0)
         {
@@ -403,8 +406,8 @@
     // Allocate the empty pattern
     module->patterns[jsetMaxPatterns] = jssAllocatePattern(64, module->nchannels);
 
-    /* Convert song orders list by replacing nonexisting patterns
-     * with pattern number jsetMaxPatterns.
+    /* Convert song orders list by replacing nonexisting
+     * pattern numbers with pattern number jsetMaxPatterns.
      */
     for (index = 0; index < module->norders; index++)
     {
--- a/minijss/jssmod.h	Fri Mar 06 09:45:13 2015 +0200
+++ b/minijss/jssmod.h	Fri Mar 06 09:45:55 2015 +0200
@@ -289,6 +289,7 @@
 
 #endif
 
+
 #ifndef JSS_LIGHT
 char *              jssASCIItoStr(const char *src, const char endByte, const size_t len);
 BOOL                jssEncodeSample8(Uint8 *, const size_t, const int);