diff options
Diffstat (limited to 'engines/zvision/core/console.cpp')
-rw-r--r-- | engines/zvision/core/console.cpp | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp index 4dd10d6f40..b5e542d777 100644 --- a/engines/zvision/core/console.cpp +++ b/engines/zvision/core/console.cpp @@ -52,6 +52,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); registerCmd("location", WRAP_METHOD(Console, cmdLocation)); registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); + registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles)); } bool Console::cmdLoadVideo(int argc, const char **argv) { @@ -78,12 +79,14 @@ bool Console::cmdLoadSound(int argc, const char **argv) { Audio::AudioStream *soundStream = makeRawZorkStream(argv[1], _engine); Audio::SoundHandle handle; _engine->_mixer->playStream(Audio::Mixer::kPlainSoundType, &handle, soundStream, -1, 100, 0, DisposeAfterUse::YES, false, false); - } else if (argc == 4) { int isStereo = atoi(argv[3]); Common::File *file = new Common::File(); - file->open(argv[1]); + if (!_engine->getSearchManager()->openFile(*file, argv[1])) { + warning("File not found: %s", argv[1]); + return true; + } Audio::AudioStream *soundStream = makeRawZorkStream(file, atoi(argv[2]), isStereo == 0 ? false : true); Audio::SoundHandle handle; @@ -103,8 +106,10 @@ bool Console::cmdRawToWav(int argc, const char **argv) { } Common::File file; - if (!file.open(argv[1])) + if (!_engine->getSearchManager()->openFile(file, argv[1])) { + warning("File not found: %s", argv[1]); return true; + } Audio::AudioStream *audioStream = makeRawZorkStream(argv[1], _engine); @@ -133,6 +138,10 @@ bool Console::cmdRawToWav(int argc, const char **argv) { output.writeUint32LE(file.size() * 2); int16 *buffer = new int16[file.size()]; audioStream->readBuffer(buffer, file.size()); +#ifndef SCUMM_LITTLE_ENDIAN + for (int i = 0; i < file.size(); ++i) + buffer[i] = TO_LE_16(buffer[i]); +#endif output.write(buffer, file.size() * 2); delete[] buffer; @@ -205,6 +214,20 @@ bool Console::cmdLocation(int argc, const char **argv) { return true; } +void dumpFile(Common::SeekableReadStream *s, const char *outName) { + byte *buffer = new byte[s->size()]; + s->read(buffer, s->size()); + + Common::DumpFile dumpFile; + dumpFile.open(outName); + + dumpFile.write(buffer, s->size()); + dumpFile.flush(); + dumpFile.close(); + + delete[] buffer; +} + bool Console::cmdDumpFile(int argc, const char **argv) { if (argc != 2) { debugPrintf("Use %s <fileName> to dump a file\n", argv[0]); @@ -217,17 +240,31 @@ bool Console::cmdDumpFile(int argc, const char **argv) { return true; } - byte *buffer = new byte[f.size()]; - f.read(buffer, f.size()); + dumpFile(&f, argv[1]); - Common::DumpFile dumpFile; - dumpFile.open(argv[1]); + return true; +} - dumpFile.write(buffer, f.size()); - dumpFile.flush(); - dumpFile.close(); +bool Console::cmdDumpFiles(int argc, const char **argv) { + Common::String fileName; + Common::SeekableReadStream *in; - delete[] buffer; + if (argc != 2) { + debugPrintf("Use %s <file extension> to dump all files with a specific extension\n", argv[0]); + return true; + } + + SearchManager::MatchList fileList; + _engine->getSearchManager()->listMembersWithExtension(fileList, argv[1]); + + for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) { + fileName = iter->_value.name; + debugPrintf("Dumping %s\n", fileName.c_str()); + + in = iter->_value.arch->createReadStreamForMember(iter->_value.name); + dumpFile(in, fileName.c_str()); + delete in; + } return true; } |