# HG changeset patch # User Matti Hamalainen # Date 1425548160 -7200 # Node ID cdba23d3fd0dcd7cb704816edee6cf8efa71ce73 # Parent d144ebb1cdea9581cfbd51e261551c75e2b0eb31 Version 0x0102 has slightly different pattern header than 0x0104. diff -r d144ebb1cdea -r cdba23d3fd0d minijss/jloadxm.c --- a/minijss/jloadxm.c Thu Mar 05 11:35:02 2015 +0200 +++ b/minijss/jloadxm.c Thu Mar 05 11:36:00 2015 +0200 @@ -244,14 +244,41 @@ // Get the pattern header off_t remainder, pos = dmftell(inFile); - if (!dmf_read_le32(inFile, &xmP.headSize) || - !dmf_read_byte(inFile, &xmP.packing) || - !dmf_read_le16(inFile, &xmP.nrows) || - !dmf_read_le16(inFile, &xmP.size)) + if (!dmf_read_le32(inFile, &xmP.headSize)) JSSERROR(DMERR_FREAD, DMERR_FREAD, - "Could not read pattern header data #%d.\n", + "Could not read pattern header size #%d.\n", index); + if (module->intVersion == 0x0102) + { + Uint8 tmp; + if (xmP.headSize != 4 + 1 + 1 + 2) + JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, + "Invalid pattern #%d header size %d, expected %d bytes.\n", + index, xmP.headSize, 4 + 1 + 1 + 2); + + if (!dmf_read_byte(inFile, &xmP.packing) || + !dmf_read_byte(inFile, &tmp) || + !dmf_read_le16(inFile, &xmP.size)) + JSSERROR(DMERR_FREAD, DMERR_FREAD, + "Could not read pattern header data #%d.\n", + index); + xmP.nrows = tmp; + } + else + { + if (xmP.headSize != 4 + 1 + 2 + 2) + JSSERROR(DMERR_NOT_SUPPORTED, DMERR_NOT_SUPPORTED, + "Invalid pattern #%d header size %d, expected %d bytes.\n", + index, xmP.headSize, 4 + 1 + 2 + 2); + + if (!dmf_read_byte(inFile, &xmP.packing) || + !dmf_read_le16(inFile, &xmP.nrows) || + !dmf_read_le16(inFile, &xmP.size)) + JSSERROR(DMERR_FREAD, DMERR_FREAD, + "Could not read pattern header data #%d.\n", + index); + } // Check the header if (xmP.packing != 0)