# HG changeset patch # User Matti Hamalainen # Date 1425590938 -7200 # Node ID 96ad216e9b59f0792ec7571bbfa48c927eb555bb # Parent f57dc769bd39141c2e6e4f01dbced135547c07bd Improve some comments. diff -r f57dc769bd39 -r 96ad216e9b59 minijss/jloadxm.c --- a/minijss/jloadxm.c Thu Mar 05 23:22:38 2015 +0200 +++ b/minijss/jloadxm.c Thu Mar 05 23:28:58 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++) {