# HG changeset patch # User Matti Hamalainen # Date 1425627955 -7200 # Node ID 62a76a3d9bc29bda685b85a617dab6b789f0f4a9 # Parent 30c2dbf05841ec44e571c37f1f6061160f3b46ce# Parent 96ad216e9b59f0792ec7571bbfa48c927eb555bb Merged. diff -r 30c2dbf05841 -r 62a76a3d9bc2 minijss/jloadjss.c --- 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; diff -r 30c2dbf05841 -r 62a76a3d9bc2 minijss/jloadxm.c --- 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++) { diff -r 30c2dbf05841 -r 62a76a3d9bc2 minijss/jssmod.h --- 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);