diff --git a/compress.cpp b/compress.cpp index 9458b6f2..db8340dd 100644 --- a/compress.cpp +++ b/compress.cpp @@ -758,8 +758,6 @@ int process_mp3_parms(int argc, char *argv[], int* i) { encparms.silent = 1; } else if (strcmp(argv[*i], "--help") == 0) { return 0; - } else if (argv[*i][0] == '-') { - return 0; } else { break; } diff --git a/compress_sword1.cpp b/compress_sword1.cpp index b9234b77..c199c863 100644 --- a/compress_sword1.cpp +++ b/compress_sword1.cpp @@ -27,13 +27,12 @@ #define TOTAL_TUNES 269 -char tempOutName[16]; -char inputDir[256]; +const char *tempOutName; typedef struct { char fileName[8]; - bool missing; /* Some of the music files seem to have been removed from the game. */ - /* Try and look for them, but don't warn if they are missing. */ + bool missing; /* Some of the music files seem to have been removed from the game + Try and look for them, but don't warn if they are missing. */ } MusicFile; MusicFile musicNames[TOTAL_TUNES] = { @@ -308,53 +307,6 @@ MusicFile musicNames[TOTAL_TUNES] = { { "RM3D", false } }; -void showhelp(char *exename) { - printf("\nUsage: %s [params] \n", exename); - - printf("\nParams:\n"); - printf(" --mp3 encode to MP3 format (default)\n"); - printf(" --vorbis encode to Vorbis format\n"); - printf(" --flac encode to Flac format\n"); - printf(" --speech-only only encode speech clusters\n"); - printf(" --music-only only encode music files\n"); - printf(" (default: encode both)\n"); - printf("(The above parameters have to be specified first)\n"); - - printf("\nMP3 mode params:\n"); - printf(" -b is the target bitrate(ABR)/minimal bitrate(VBR)\n"); - printf(" (default:%d)\n", minBitrDef); - printf(" -B is the maximum VBR/ABR bitrate (default:%d)\n", maxBitrDef); - printf(" --vbr LAME uses the VBR mode (default)\n"); - printf(" --abr LAME uses the ABR mode\n"); - printf(" -V specifies the value (0 - 9) of VBR quality (0=best) (default:%d)\n", vbrqualDef); - printf(" -q specifies the MPEG algorithm quality (0-9; 0=best) (default:%d)\n", algqualDef); - printf(" --silent the output of LAME is hidden (default:disabled)\n"); - - printf("\nVorbis mode params:\n"); - printf(" -b is the nominal bitrate (default:unset)\n"); - printf(" -m is the minimum bitrate (default:unset)\n"); - printf(" -M is the maximum bitrate (default:unset)\n"); - printf(" -q specifies the value (0 - 10) of VBR quality (10=best)\n"); - printf(" (default:%d)\n", oggqualDef); - printf(" --silent the output of oggenc is hidden (default:disabled)\n"); - - printf("\nFlac mode params:\n"); - printf(" --fast FLAC uses compression level 0\n"); - printf(" --best FLAC uses compression level 8\n"); - printf(" - specifies the value (0 - 8) of compression (8=best)(default:%d)\n", flacCompressDef); - printf(" -b specifies a blocksize of samples (default:%d)\n", flacBlocksizeDef); - printf(" --verify files are encoded and then decoded to check accuracy\n"); - printf(" --silent the output of FLAC is hidden (default:disabled)\n"); - - printf("\n --help this help message\n"); - - printf("\nIf a parameter is not given the default value is used\n"); - printf("If using VBR mode for MP3 -b and -B must be multiples of 8; the maximum is 160!\n"); - printf("\nMake sure the input directory contains the \"MUSIC\" and \"SPEECH\" subdirectories.\n"); - printf("If the input directory is the same as the current directory use '.'\n"); - exit(2); -} - int16 *uncompressSpeech(FILE *clu, uint32 idx, uint32 cSize, uint32 *returnSize) { uint32 resSize, srcPos; int16 *srcData, *dstData, *dstPos; @@ -482,10 +434,14 @@ void convertClu(FILE *clu, FILE *cl3, CompressMode compMode) { free(cowHeader); } -void compressSpeech(CompressMode compMode) { +void compressSpeech(CompressMode compMode, const Filename *inpath, const Filename *outpath) { FILE *clu, *cl3 = NULL; int i; char cluName[256], outName[256]; + char inputDir[256], outDir[256]; + + inpath->getPath(inputDir); + outpath->getPath(outDir); setRawAudioType(true, false, 16); @@ -498,13 +454,13 @@ void compressSpeech(CompressMode compMode) { } else { switch (compMode) { case kMP3Mode: - sprintf(outName, "%s/SPEECH/SPEECH%d.%s", inputDir, i, "CL3"); + sprintf(outName, "%s/SPEECH/SPEECH%d.%s", outDir, i, "CL3"); break; case kVorbisMode: - sprintf(outName, "%s/SPEECH/SPEECH%d.%s", inputDir, i, "CLV"); + sprintf(outName, "%s/SPEECH/SPEECH%d.%s", outDir, i, "CLV"); break; case kFlacMode: - sprintf(outName, "%s/SPEECH/SPEECH%d.%s", inputDir, i, "CLF"); + sprintf(outName, "%s/SPEECH/SPEECH%d.%s", outDir, i, "CLF"); break; default: error("Unknown encoding method"); @@ -528,10 +484,14 @@ void compressSpeech(CompressMode compMode) { unlink(tempOutName); } -void compressMusic(CompressMode compMode) { +void compressMusic(CompressMode compMode, const Filename *inpath, const Filename *outpath) { int i; FILE *inf; char fNameIn[256], fNameOut[256]; + char inputDir[256], outDir[256]; + + inpath->getPath(inputDir); + outpath->getPath(outDir); for (i = 0; i < TOTAL_TUNES; i++) { sprintf(fNameIn, "%s/MUSIC/%s.WAV", inputDir, musicNames[i].fileName); @@ -546,13 +506,13 @@ void compressMusic(CompressMode compMode) { switch (compMode) { case kMP3Mode: - sprintf(fNameOut, "%s/MUSIC/%s.%s", inputDir, musicNames[i].fileName, "MP3"); + sprintf(fNameOut, "%s/MUSIC/%s.%s", outDir, musicNames[i].fileName, "MP3"); break; case kVorbisMode: - sprintf(fNameOut, "%s/MUSIC/%s.%s", inputDir, musicNames[i].fileName, "OGG"); + sprintf(fNameOut, "%s/MUSIC/%s.%s", outDir, musicNames[i].fileName, "OGG"); break; case kFlacMode: - sprintf(fNameOut, "%s/MUSIC/%s.%s", inputDir, musicNames[i].fileName, "FLA"); + sprintf(fNameOut, "%s/MUSIC/%s.%s", outDir, musicNames[i].fileName, "FLA"); break; default: error("Unknown encoding method"); @@ -564,12 +524,14 @@ void compressMusic(CompressMode compMode) { } } -void checkFilesExist(bool checkSpeech, bool checkMusic) { +void checkFilesExist(bool checkSpeech, bool checkMusic, const Filename *inpath) { int i; FILE *testFile; - char fileName[256]; + char fileName[256], inputDir[256]; bool speechFound = false, musicFound = false; + inpath->getPath(inputDir); + if (checkSpeech) { for (i = 1; i <= 2; i++) { sprintf(fileName, "%s/SPEECH/SPEECH%d.CLU", inputDir, i); @@ -617,64 +579,77 @@ void checkFilesExist(bool checkSpeech, bool checkMusic) { } } +const char *helptext = "\nUsage: %s [only] [mode] [mode params] [-o outputdir] \n" + "only can be either:\n" + " --speech-only only encode speech clusters\n" + " --music-only only encode music files\n" + kCompressionAudioHelp; + int main(int argc, char *argv[]) { CompressMode compMode = kMP3Mode; - int i = 1; + Filename inpath, outpath; + int first_arg = 1; + int last_arg = argc - 1; bool compMusic = true, compSpeech = true; - while (i < argc) { - if (!strcmp(argv[i], "--mp3")) - compMode = kMP3Mode; - else if (!strcmp(argv[i], "--vorbis")) - compMode = kVorbisMode; - else if (!strcmp(argv[i], "--flac")) - compMode = kFlacMode; - else if (!strcmp(argv[i], "--speech-only")) - compMusic = false; - else if (!strcmp(argv[i], "--music-only")) - compSpeech = false; - else - break; - i++; + // Should we display some help perhaps? + parseHelpArguments(argv, argc, helptext); + + // Check extra arguments + if(strcmp(argv[first_arg], "--speech-only") == 0) { + compMusic = false; + ++first_arg; + } else if (strcmp(argv[first_arg], "--music-only") == 0) { + compSpeech = false; + ++first_arg; } - switch (compMode) { - case kMP3Mode: - strcpy(tempOutName, TEMP_MP3); - if (!process_mp3_parms(argc, argv, i)) { - showhelp(argv[0]); - } + // compression mode + compMode = process_audio_params(argc, argv, &first_arg); + if(compMode == kNoAudioMode) { + // Unknown mode (failed to parse arguments), display help and exit + printf(helptext, argv[0]); + exit(2); + } + + // Now we try to find the proper output dir + // also make sure we skip those arguments + if (parseOutputDirectoryArguments(&outpath, argv, argc, first_arg)) + first_arg += 2; + else if (parseOutputDirectoryArguments(&outpath, argv, argc, last_arg - 2)) + last_arg -= 2; + + switch(compMode) { + case kMP3Mode: + tempOutName = TEMP_MP3; break; case kVorbisMode: - strcpy(tempOutName, TEMP_OGG); - if (!process_ogg_parms(argc, argv, i)) { - showhelp(argv[0]); - } - + tempOutName = TEMP_OGG; break; case kFlacMode: - strcpy(tempOutName, TEMP_FLAC); - if (!process_flac_parms(argc, argv, i)){ - showhelp(argv[0]); - } - + tempOutName = TEMP_FLAC; break; default: - error("Unknown encoding method"); + // Never happends, avoid warnings + break; } - sprintf(inputDir, argv[argc - 1]); + inpath.setFullPath(argv[first_arg]); + + if(outpath.empty()) + // Extensions change between the in/out files, so we can use the same directory + outpath = inpath; /* Do a quick check to see if we can open any files at all */ - checkFilesExist(compSpeech, compMusic); + checkFilesExist(compSpeech, compMusic, &inpath); if (compSpeech) { - compressSpeech(compMode); + compressSpeech(compMode, &inpath, &outpath); } if (compMusic) { - compressMusic(compMode); + compressMusic(compMode, &inpath, &outpath); } return EXIT_SUCCESS; diff --git a/compress_sword2.cpp b/compress_sword2.cpp index 0738723a..e8453e67 100644 --- a/compress_sword2.cpp +++ b/compress_sword2.cpp @@ -64,10 +64,8 @@ uint32 append_to_file(FILE *f1, const char *filename) { const char *helptext = "\nUsage: %s [params] \n\n" kCompressionAudioHelp; int main(int argc, char *argv[]) { - char output_filename[1024]; FILE *output, *f; - char *ptr; - int i, j; + int j; uint32 indexSize; uint32 totalSize; uint32 length; @@ -87,67 +85,32 @@ int main(int argc, char *argv[]) { first_arg += 2; else if (parseOutputFileArguments(&outpath, argv, argc, last_arg - 2)) last_arg -= 2; - else { - switch(gCompMode) { - case kMP3Mode: - g_output_filename = OUTPUT_MP3; - break; - case kVorbisMode: - g_output_filename = OUTPUT_OGG; - break; - case kFlacMode: - g_output_filename = OUTPUT_FLAC; - break; - default: - printf(helptext, argv[0]); - exit(2); - break; - } - } - i = 1; - - if (strcmp(argv[1], "--mp3") == 0) { - gCompMode = kMP3Mode; - i++; - } - else if (strcmp(argv[1], "--vorbis") == 0) { - gCompMode = kVorbisMode; - i++; - } else if (strcmp(argv[1], "--flac") == 0) { - gCompMode = kFlacMode; - i++; - } - - switch (gCompMode) { + switch(gCompMode) { case kMP3Mode: - tempEncoded = TEMP_MP3; - if (!process_mp3_parms(argc, argv, i)) { - showhelp(argv[0]); - } - + tempEncoded = TEMP_MP3; break; case kVorbisMode: - tempEncoded = TEMP_OGG; - if (!process_ogg_parms(argc, argv, i)) { - showhelp(argv[0]); - } - + tempEncoded = TEMP_OGG; break; case kFlacMode: - tempEncoded = TEMP_FLAC; - if (!process_flac_parms(argc, argv, i)) { - showhelp(argv[0]); - } - + tempEncoded = TEMP_FLAC; + break; + default: + printf(helptext, argv[0]); + exit(2); break; } - i = argc - 1; + inpath.setFullPath(argv[first_arg]); - input = fopen(argv[i], "rb"); + if(outpath.empty()) + // Extensions change between the in/out files, so we can use the same directory + outpath = inpath; + + input = fopen(inpath.getFullPath(), "rb"); if (!input) { - printf("Cannot open file: %s\n", argv[i]); + printf("Cannot open file: %s\n", inpath.getFullPath()); return EXIT_FAILURE; } @@ -175,7 +138,7 @@ int main(int argc, char *argv[]) { writeUint32BE(output_idx, 0xfff0fff0); writeUint32BE(output_idx, 0xfff0fff0); - for (i = 0; i < (int)indexSize; i++) { + for (int i = 0; i < (int)indexSize; i++) { uint32 pos; uint32 enc_length; @@ -263,25 +226,9 @@ int main(int argc, char *argv[]) { fclose(output_idx); fclose(output_snd); - strcpy(output_filename, argv[argc - 1]); - ptr = output_filename + strlen(output_filename) - 1; - - switch (gCompMode) { - case kMP3Mode: - *ptr = '3'; - break; - case kVorbisMode: - *ptr = 'g'; - break; - case kFlacMode: - *ptr = 'f'; - break; - } - - - output = fopen(output_filename, "wb"); + output = fopen(outpath.getFullPath(), "wb"); if (!output) { - printf("Can't open file %s for writing!\n", output_filename); + printf("Can't open file %s for writing!\n", outpath.getFullPath()); return EXIT_FAILURE; } diff --git a/dist/msvc9/compress_tucker.vcproj b/dist/msvc9/compress_tucker.vcproj new file mode 100644 index 00000000..47120d45 --- /dev/null +++ b/dist/msvc9/compress_tucker.vcproj @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dist/msvc9/extract_agos.vcproj b/dist/msvc9/extract_agos.vcproj index bb6184ab..0f993b08 100644 --- a/dist/msvc9/extract_agos.vcproj +++ b/dist/msvc9/extract_agos.vcproj @@ -1,7 +1,7 @@ + + + + diff --git a/dist/msvc9/tools.sln b/dist/msvc9/tools.sln index d70ace11..d33da64e 100644 --- a/dist/msvc9/tools.sln +++ b/dist/msvc9/tools.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 +# Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compress_scumm_san", "compress_scumm_san.vcproj", "{1712DDB9-8BB1-4108-9A06-F86F28409B20}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compress_scumm_bun", "compress_scumm_bun.vcproj", "{C423ACAC-C398-4419-BA32-B77F6A8AC1F9}" @@ -53,6 +53,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "extract_parallaction", "ext EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compress_gob", "compress_gob.vcproj", "{8C4BC409-2EEC-41F5-A017-972F38414289}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compress_tucker", "compress_tucker.vcproj", "{DFBC3A41-17AF-4789-B775-35EFC39118A1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -163,6 +165,10 @@ Global {8C4BC409-2EEC-41F5-A017-972F38414289}.Debug|Win32.Build.0 = Debug|Win32 {8C4BC409-2EEC-41F5-A017-972F38414289}.Release|Win32.ActiveCfg = Release|Win32 {8C4BC409-2EEC-41F5-A017-972F38414289}.Release|Win32.Build.0 = Release|Win32 + {DFBC3A41-17AF-4789-B775-35EFC39118A1}.Debug|Win32.ActiveCfg = Debug|Win32 + {DFBC3A41-17AF-4789-B775-35EFC39118A1}.Debug|Win32.Build.0 = Debug|Win32 + {DFBC3A41-17AF-4789-B775-35EFC39118A1}.Release|Win32.ActiveCfg = Release|Win32 + {DFBC3A41-17AF-4789-B775-35EFC39118A1}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/encode_dxa.cpp b/encode_dxa.cpp index 6ddc3801..27906e37 100644 --- a/encode_dxa.cpp +++ b/encode_dxa.cpp @@ -709,7 +709,7 @@ int main(int argc, char *argv[]) { inpath.setFullPath(argv[first_arg]); if(outpath.empty()) { - // Change extension for output + // Actual change of extension is done later... outpath = inpath; }