# HG changeset patch # User Matti Hamalainen # Date 1509153942 -10800 # Node ID 01d9bd6e88a824eef713eb10bbbec0707b4dc946 # Parent 7acadc08bc722457ef4e3af62ba0d9fa14d7c6e6 Indentation cosmetics. diff -r 7acadc08bc72 -r 01d9bd6e88a8 minijss/jloadxm.c --- a/minijss/jloadxm.c Mon Oct 16 03:22:13 2017 +0300 +++ b/minijss/jloadxm.c Sat Oct 28 04:25:42 2017 +0300 @@ -210,8 +210,8 @@ { // Some data left unparsed JSSWARNING(DMERR_EXTRA_DATA, DMERR_EXTRA_DATA, - "Unparsed data after pattern (%d bytes), possibly broken file.\n", - size); + "Unparsed data after pattern (%d bytes), possibly broken file.\n", + size); } return DMERR_OK; @@ -304,8 +304,8 @@ { // Some data left unparsed JSSWARNING(DMERR_EXTRA_DATA, DMERR_EXTRA_DATA, - "Unparsed data after pattern (%d bytes), possibly broken file.\n", - size); + "Unparsed data after pattern (%d bytes), possibly broken file.\n", + size); } return DMERR_OK; @@ -327,8 +327,8 @@ !dmf_read_byte(inFile, &xmP.packing)) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Could not read pattern header #%d.\n", - index); + "Could not read pattern header #%d.\n", + index); } // Different format versions have slightly different headers @@ -351,31 +351,31 @@ if (headSize != xmP.headSize) { JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, - "Invalid pattern #%d header size %d, expected %d bytes.\n", - index, xmP.headSize, headSize); + "Invalid pattern #%d header size %d, expected %d bytes.\n", + index, xmP.headSize, headSize); } // Read rest of the header if (!ret || !dmf_read_le16(inFile, &xmP.size)) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Could not read pattern header data #%d.\n", - index); + "Could not read pattern header data #%d.\n", + index); } // 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", - index, xmP.packing); + "Pattern #%d packing type unsupported (%d)\n", + index, xmP.packing); } if (xmP.nrows == 0) { JSSERROR(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Pattern #%d has %d rows, invalid data.\n", - index, xmP.nrows); + "Pattern #%d has %d rows, invalid data.\n", + index, xmP.nrows); } if (xmP.size > 0) @@ -466,40 +466,40 @@ if (src->flags & 0xf0) { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Inst#%d/%s-env: Uses unsupported flags values, 0x%02x.\n", - ninstr, name, src->flags); + "Inst#%d/%s-env: Uses unsupported flags values, 0x%02x.\n", + ninstr, name, src->flags); } // Check other values if (src->npoints > XM_MaxEnvPoints) { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Inst#%d/%s-env: npoints > MAX, possibly broken file.\n", - ninstr, name); + "Inst#%d/%s-env: npoints > MAX, possibly broken file.\n", + ninstr, name); dst->npoints = XM_MaxEnvPoints; } if ((dst->flags & jenvfSustain) && src->sustain > src->npoints) { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Inst#%d/%s-env: sustain > npoints (%d > %d), possibly broken file.\n", - ninstr, name, src->sustain, src->npoints); + "Inst#%d/%s-env: sustain > npoints (%d > %d), possibly broken file.\n", + ninstr, name, src->sustain, src->npoints); dst->sustain = src->npoints; } if ((dst->flags & jenvfLooped) && src->loopE > src->npoints) { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Inst#%d/%s-env: loopE > npoints (%d > %d), possibly broken file.\n", - ninstr, name, src->loopE, src->npoints); + "Inst#%d/%s-env: loopE > npoints (%d > %d), possibly broken file.\n", + ninstr, name, src->loopE, src->npoints); dst->loopE = src->npoints; } if ((dst->flags & jenvfLooped) && src->loopS > src->loopE) { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Inst#%d/%s-env: loopS > loopE (%d > %d), possibly broken file.\n", - ninstr, name, src->loopS, src->loopE); + "Inst#%d/%s-env: loopS > loopE (%d > %d), possibly broken file.\n", + ninstr, name, src->loopS, src->loopE); dst->loopS = src->loopE; } } @@ -530,8 +530,8 @@ !dmf_read_str(inFile, &xmS.sampleName, sizeof(xmS.sampleName))) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Error reading instrument sample header #%d/%d [%d]", - neinst, nsample, module->ninstruments); + "Error reading instrument sample header #%d/%d [%d]", + neinst, nsample, module->ninstruments); } if (xmS.size <= 0) @@ -539,15 +539,15 @@ // Allocate sample instrument JSSDEBUG("Allocating sample #%d/%d [%d]\n", - neinst, nsample, module->ninstruments); + neinst, nsample, module->ninstruments); einst->instConvTable[nsample] = module->ninstruments; inst = module->instruments[module->ninstruments] = jssAllocateInstrument(); if (inst == NULL) { JSSERROR(DMERR_MALLOC, DMERR_MALLOC, - "Could not allocate sample #%d/%d [%d]\n", - neinst, nsample, module->ninstruments); + "Could not allocate sample #%d/%d [%d]\n", + neinst, nsample, module->ninstruments); } module->ninstruments++; @@ -555,7 +555,7 @@ if (xmS.volume > XM_MaxSampleVolume) { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Samp #%d/%d: volume > MAX\n", neinst, nsample); + "Samp #%d/%d: volume > MAX\n", neinst, nsample); xmS.volume = XM_MaxSampleVolume; } @@ -590,8 +590,8 @@ if ((xmS.size & 1) || (xmS.loopS & 1) || (xmS.loopL & 1)) { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Samp #%d/%d: size=%d, loopS=%d or loopL=%d not divisible by 2 for 16-bit sample.\n", - neinst, nsample, xmS.size, xmS.loopS, xmS.loopL); + "Samp #%d/%d: size=%d, loopS=%d or loopL=%d not divisible by 2 for 16-bit sample.\n", + neinst, nsample, xmS.size, xmS.loopS, xmS.loopL); } } else @@ -613,16 +613,16 @@ if (inst->loopS >= inst->size) { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Samp #%d/%d: loopS >= size (%d >= %d)\n", - neinst, nsample, inst->loopS, inst->size); + "Samp #%d/%d: loopS >= size (%d >= %d)\n", + neinst, nsample, inst->loopS, inst->size); JSFUNSET(inst->flags, jsfLooped); } if (inst->loopE > inst->size) { JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Samp #%d/%d: loopE > size (%d > %d)\n", - neinst, nsample, inst->loopE, inst->size); + "Samp #%d/%d: loopE > size (%d > %d)\n", + neinst, nsample, inst->loopE, inst->size); JSFUNSET(inst->flags, jsfLooped); } } @@ -639,15 +639,16 @@ (void) ninst; (void) nsample; - JSSDEBUG("desc....: '%s'\n" - "size....: %d\n" - "loopS...: %d\n" - "loopE...: %d\n" - "volume..: %d\n" - "flags...: %x\n", - inst->desc, - inst->size, inst->loopS, inst->loopE, - inst->volume, inst->flags); + JSSDEBUG( + "desc....: '%s'\n" + "size....: %d\n" + "loopS...: %d\n" + "loopE...: %d\n" + "volume..: %d\n" + "flags...: %x\n", + inst->desc, + inst->size, inst->loopS, inst->loopE, + inst->volume, inst->flags); // Allocate memory for sample data bsize = (inst->flags & jsf16bit) ? sizeof(Uint16) : sizeof(Uint8); @@ -656,16 +657,16 @@ if ((inst->data = dmMalloc(bsize)) == NULL) { JSSERROR(DMERR_MALLOC, DMERR_MALLOC, - "Could not allocate %d bytes of sample data for instrument/sample #%d/%d.\n", - bsize, ninst, nsample); + "Could not allocate %d bytes of sample data for instrument/sample #%d/%d.\n", + bsize, ninst, nsample); } // Read sampledata if (dmfread(inst->data, sizeof(Uint8), bsize, inFile) != bsize) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Error reading sample data for instrument #%d/%d, %d bytes.\n", - ninst, nsample, bsize); + "Error reading sample data for instrument #%d/%d, %d bytes.\n", + ninst, nsample, bsize); } // Convert the sample data @@ -748,8 +749,8 @@ !dmf_read_le16(inFile, &xmI1.nsamples)) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Failed to read primary extended instrument header #%d.\n", - neinst); + "Failed to read primary extended instrument header #%d.\n", + neinst); } // If there are samples, there is header #2 @@ -772,8 +773,8 @@ if ((einst = jssAllocateExtInstrument()) == NULL) { JSSERROR(DMERR_MALLOC, DMERR_MALLOC, - "Could not allocate extended instrument #%d.\n", - neinst); + "Could not allocate extended instrument #%d.\n", + neinst); } module->extInstruments[neinst] = einst; @@ -783,16 +784,16 @@ !dmf_read_str(inFile, &xmI2.sNumForNotes, sizeof(xmI2.sNumForNotes))) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Could not read secondary instrument header part #1 for #%d.\n", - neinst); + "Could not read secondary instrument header part #1 for #%d.\n", + neinst); } if (!jssXMLoadEnvelopePoints(inFile, &xmI2.volumeEnv) || !jssXMLoadEnvelopePoints(inFile, &xmI2.panningEnv)) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Could not read envelope point data for instrument #%d.\n", - neinst); + "Could not read envelope point data for instrument #%d.\n", + neinst); } if (!dmf_read_byte(inFile, &xmI2.volumeEnv.npoints) || @@ -813,8 +814,8 @@ !dmf_read_le16(inFile, &xmI2.ARESERVED)) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Could not read secondary instrument header part #2 for #%d.\n", - neinst); + "Could not read secondary instrument header part #2 for #%d.\n", + neinst); } // Skip the extra data after header #2 @@ -841,7 +842,8 @@ default: einst->vibratoType = jvibSine; JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Invalid extinstrument vibrato type %d for inst #%d\n", neinst); + "Invalid extinstrument vibrato type %d for inst #%d\n", + neinst); break; } einst->vibratoSweep = xmI2.vibratoSweep; @@ -871,8 +873,8 @@ { einst->sNumForNotes[i] = jsetNotSet; JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Ext.instrument #%d sNumForNotes[%d] out of range (%d).\n", - neinst, i, tmp); + "Ext.instrument #%d sNumForNotes[%d] out of range (%d).\n", + neinst, i, tmp); } } @@ -894,7 +896,8 @@ { int result = jssXMLoadExtInstrument(inFile, index, module); if (result != 0) - JSSERROR(result, result, "Errors while reading instrument #%d\n", index); + JSSERROR(result, result, "Errors while reading instrument #%d\n", + index); } return DMERR_OK; } @@ -934,61 +937,65 @@ return DMERR_NOT_SUPPORTED; else JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, - "Not a FT2 Extended Module (XM), header signature mismatch!\n"); + "Not a FT2 Extended Module (XM), header signature mismatch!\n"); } if (xmH.unUsed1A != 0x1a) { if (!probe) - JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Possibly modified or corrupted XM [%x]\n", xmH.unUsed1A); + JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, + "Possibly modified or corrupted XM [%x]\n", + xmH.unUsed1A); } if (xmH.norders > XM_MaxOrders) { if (!probe) - JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Number of orders %d > %d, possibly broken module.\n", - xmH.norders, XM_MaxOrders); + JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, + "Number of orders %d > %d, possibly broken module.\n", + xmH.norders, XM_MaxOrders); + xmH.norders = XM_MaxOrders; } if (xmH.norders == 0) { if (!probe) - JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Number of orders was zero.\n"); + JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, + "Number of orders was zero.\n"); } if (xmH.npatterns > XM_MaxPatterns) { if (!probe) - JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Number of patterns %d > %d, possibly broken module.\n", - xmH.npatterns, XM_MaxPatterns); + JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, + "Number of patterns %d > %d, possibly broken module.\n", + xmH.npatterns, XM_MaxPatterns); + xmH.npatterns = XM_MaxPatterns; } if (xmH.npatterns == 0) { if (!probe) - JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Number of patterns was zero.\n"); + JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, + "Number of patterns was zero.\n"); } if (xmH.nchannels <= 0 || xmH.nchannels > XM_MaxChannels) { - JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Number of channels was invalid, %d (should be 1 - %d).\n", - xmH.nchannels, XM_MaxChannels); + if (!probe) + JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, + "Number of channels was invalid, %d (should be 1 - %d).\n", + xmH.nchannels, XM_MaxChannels); } if (xmH.ninstruments <= 0 || xmH.ninstruments > XM_MaxInstruments) { if (!probe) - JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, - "Number of instruments was invalid, %d (should be 1 - %d).\n", - xmH.ninstruments, XM_MaxInstruments); + JSSWARNING(DMERR_INVALID_DATA, DMERR_INVALID_DATA, + "Number of instruments was invalid, %d (should be 1 - %d).\n", + xmH.ninstruments, XM_MaxInstruments); } if (xmH.headSize < XM_HeaderSize) @@ -996,9 +1003,9 @@ if (probe) return DMERR_NOT_SUPPORTED; else - JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, - "XM header size less than %d bytes (%d bytes).\n", - XM_HeaderSize, xmH.headSize); + JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, + "XM header size less than %d bytes (%d bytes).\n", + XM_HeaderSize, xmH.headSize); } switch (xmH.version) @@ -1009,22 +1016,23 @@ default: if (!probe) - JSSWARNING(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, - "Unsupported version of XM format 0x%04x.\n", - xmH.version); + JSSWARNING(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, + "Unsupported version of XM format 0x%04x.\n", + xmH.version); } if (!dmf_read_str(inFile, &xmH.orderList, sizeof(xmH.orderList))) { JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Error reading pattern order list.\n"); + "Error reading pattern order list.\n"); } if (xmH.headSize > 276) { JSSWARNING(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, - "XM header size > %d bytes, skipping the rest.\n", - XM_HeaderSize, xmH.headSize); + "XM header size > %d bytes, skipping the rest.\n", + XM_HeaderSize, xmH.headSize); + dmfseek(inFile, xmH.headSize - XM_HeaderSize, SEEK_CUR); } @@ -1035,7 +1043,7 @@ if ((*pmodule = module = jssAllocateModule()) == NULL) { JSSERROR(DMERR_MALLOC, DMERR_MALLOC, - "Could not allocate memory for module structure.\n"); + "Could not allocate memory for module structure.\n"); } // Convert the module header data