# HG changeset patch # User Matti Hamalainen # Date 1425565331 -7200 # Node ID a79edf59d5d81359973eef6e05af6434ea03f3e6 # Parent 5d20c80df290a0a803a908454ce71c938ca5dee2 Improve use of probing in dumpmod, mod2wav and ppl. diff -r 5d20c80df290 -r a79edf59d5d8 tools/dumpmod.c --- a/tools/dumpmod.c Thu Mar 05 16:14:40 2015 +0200 +++ b/tools/dumpmod.c Thu Mar 05 16:22:11 2015 +0200 @@ -438,24 +438,36 @@ // Read module file dmMsg(1, "Reading file: %s\n", optFilename); #ifdef JSS_SUP_XM - dmMsg(1, "* Trying XM...\n"); result = jssLoadXM(file, &mod, TRUE); #endif #ifdef JSS_SUP_JSSMOD - if (result != 0) + dmfreset(file); + if (result != DMERR_OK) { - dmfseek(file, 0L, SEEK_SET); dmMsg(1, "* Trying JSSMOD ...\n"); result = jssLoadJSSMOD(file, &mod, TRUE); + dmfreset(file); + if (result == DMERR_OK) + result = jssLoadJSSMOD(file, &mod, FALSE); + } + else + { + dmMsg(2, "* Trying XM...\n"); + result = jssLoadXM(file, &mod, FALSE); } #endif dmf_close(file); + + // Check for errors, we still might have some data tho if (result != DMERR_OK) { dmErrorMsg("Error loading module file, %d: %s\n", result, dmErrorStr(result)); + } + + // Check if we have anything + if (mod == NULL) return 3; - } // Print out information if (optViewGeneralInfo) diff -r 5d20c80df290 -r a79edf59d5d8 tools/mod2wav.c --- a/tools/mod2wav.c Thu Mar 05 16:14:40 2015 +0200 +++ b/tools/mod2wav.c Thu Mar 05 16:22:11 2015 +0200 @@ -161,26 +161,38 @@ } // Read module file - fprintf(stderr, "Reading file: %s\n", optInFilename); + dmMsg(1, "Reading file: %s\n", optInFilename); #ifdef JSS_SUP_XM - fprintf(stderr, "* Trying XM...\n"); result = jssLoadXM(inFile, &mod, TRUE); #endif #ifdef JSS_SUP_JSSMOD - if (result != 0) + dmfreset(inFile); + if (result != DMERR_OK) { - dmfseek(inFile, 0L, SEEK_SET); dmMsg(1, "* Trying JSSMOD ...\n"); result = jssLoadJSSMOD(inFile, &mod, TRUE); + dmfreset(inFile); + if (result == DMERR_OK) + result = jssLoadJSSMOD(inFile, &mod, FALSE); + } + else + { + dmMsg(2, "* Trying XM...\n"); + result = jssLoadXM(inFile, &mod, FALSE); } #endif dmf_close(inFile); + + // Check for errors, we still might have some data tho if (result != DMERR_OK) { dmErrorMsg("Error loading module file, %d: %s\n", result, dmErrorStr(result)); + } + + // Check if we have anything + if (mod == NULL) return 3; - } // Try to convert it if ((result = jssConvertModuleForPlaying(mod)) != DMERR_OK) diff -r 5d20c80df290 -r a79edf59d5d8 tools/ppl.c --- a/tools/ppl.c Thu Mar 05 16:14:40 2015 +0200 +++ b/tools/ppl.c Thu Mar 05 16:22:11 2015 +0200 @@ -588,15 +588,22 @@ // Read module file dmMsg(1, "Reading file: %s\n", optFilename); #ifdef JSS_SUP_XM - dmMsg(2, "* Trying XM...\n"); result = jssLoadXM(file, &engine.mod, TRUE); #endif #ifdef JSS_SUP_JSSMOD - if (result != 0) + dmfreset(file); + if (result != DMERR_OK) { - dmfseek(file, 0L, SEEK_SET); dmMsg(1, "* Trying JSSMOD ...\n"); result = jssLoadJSSMOD(file, &engine.mod, TRUE); + dmfreset(file); + if (result == DMERR_OK) + result = jssLoadJSSMOD(file, &engine.mod, FALSE); + } + else + { + dmMsg(2, "* Trying XM...\n"); + result = jssLoadXM(file, &engine.mod, FALSE); } #endif dmf_close(file);