changeset 1180:08c93ebb85b9

Some preliminary code for 0x0102 format pattern support.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 05 Mar 2015 10:29:28 +0200
parents e7a951937374
children 5d3c948ed426
files minijss/jloadxm.c
diffstat 1 files changed, 28 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/minijss/jloadxm.c	Thu Mar 05 10:28:48 2015 +0200
+++ b/minijss/jloadxm.c	Thu Mar 05 10:29:28 2015 +0200
@@ -130,7 +130,7 @@
 
 /* Unpack a XM pattern structure from resource to given JSS pattern
  */
-static int jssXMUnpackPattern(DMResource *inFile, int size, JSSPattern *pattern)
+static int jssXMUnpackPattern104(DMResource *inFile, int size, JSSPattern *pattern)
 {
     JSSNote *pnote;
     int row, channel;
@@ -218,6 +218,23 @@
 }
 
 
+static int jssXMUnpackPattern102(DMResource *inFile, int size, JSSPattern *pattern)
+{
+    }
+
+    // Check the state
+    if (size > 0)
+    {
+        // Some data left unparsed
+        JSSWARNING(DMERR_EXTRA_DATA, DMERR_EXTRA_DATA,
+        "Unparsed data after pattern (%d bytes), possibly broken file.\n",
+        size);
+    }
+
+    return DMERR_OK;
+}
+
+
 /* Convert XM envelope structure to JSS envelope structure
  */
 static int jssXMConvertEnvelope(
@@ -695,7 +712,16 @@
                 JSSERROR(DMERR_MALLOC, DMERR_MALLOC,
                 "Could not allocate memory for pattern #%d\n", index);
 
-            result = jssXMUnpackPattern(inFile, xmP.size, module->patterns[index]);
+            switch (module->intVersion)
+            {
+                case 0x0104:
+                    result = jssXMUnpackPattern104(inFile, xmP.size, module->patterns[index]);
+                    break;
+                case 0x0102:
+                    result = jssXMUnpackPattern102(inFile, xmP.size, module->patterns[index]);
+                    break;
+            }
+
             if (result != 0)
                 JSSERROR(result, result, "Error in unpacking pattern #%d data\n", index);
         }