aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-06-07 20:34:02 +0300
committerFilippos Karapetis2015-06-07 20:51:44 +0300
commit0f8f40c11185edd361bedf443f79b64328be6088 (patch)
treecce2c2713b050000b5ff7b53283820202e27f0b4
parent47d905486cea5c98a5da632ad04c537c2c02be16 (diff)
downloadscummvm-rg350-0f8f40c11185edd361bedf443f79b64328be6088.tar.gz
scummvm-rg350-0f8f40c11185edd361bedf443f79b64328be6088.tar.bz2
scummvm-rg350-0f8f40c11185edd361bedf443f79b64328be6088.zip
SHERLOCK: Implement the "dumpfile" debugger command
This can help us debug resources bundled within LIB files
-rw-r--r--engines/sherlock/debugger.cpp30
-rw-r--r--engines/sherlock/debugger.h5
2 files changed, 35 insertions, 0 deletions
diff --git a/engines/sherlock/debugger.cpp b/engines/sherlock/debugger.cpp
index 4d8ea6c447..7a727e8224 100644
--- a/engines/sherlock/debugger.cpp
+++ b/engines/sherlock/debugger.cpp
@@ -39,6 +39,7 @@ Debugger::Debugger(SherlockEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("3do_playmovie", WRAP_METHOD(Debugger, cmd3DO_PlayMovie));
registerCmd("3do_playaudio", WRAP_METHOD(Debugger, cmd3DO_PlayAudio));
registerCmd("song", WRAP_METHOD(Debugger, cmdSong));
+ registerCmd("dumpfile", WRAP_METHOD(Debugger, cmdDumpFile));
}
void Debugger::postEnter() {
@@ -140,4 +141,33 @@ bool Debugger::cmdSong(int argc, const char **argv) {
return false;
}
+bool Debugger::cmdDumpFile(int argc, const char **argv) {
+ if (argc != 2) {
+ debugPrintf("Format: dumpfile <resource name>\n");
+ return true;
+ }
+
+ Common::SeekableReadStream *s = _vm->_res->load(argv[1]);
+ if (!s) {
+ debugPrintf("Invalid resource.\n");
+ return true;
+ }
+
+ byte *buffer = new byte[s->size()];
+ s->read(buffer, s->size());
+
+ Common::DumpFile dumpFile;
+ dumpFile.open(argv[1]);
+
+ dumpFile.write(buffer, s->size());
+ dumpFile.flush();
+ dumpFile.close();
+
+ delete[] buffer;
+
+ debugPrintf("Resource %s has been dumped to disk.\n", argv[1]);
+
+ return true;
+}
+
} // End of namespace Sherlock
diff --git a/engines/sherlock/debugger.h b/engines/sherlock/debugger.h
index 9b12668679..2252f6d8ea 100644
--- a/engines/sherlock/debugger.h
+++ b/engines/sherlock/debugger.h
@@ -65,6 +65,11 @@ private:
*/
bool cmdSong(int argc, const char **argv);
+ /**
+ * Dumps a file to disk
+ */
+ bool cmdDumpFile(int argc, const char **argv);
+
private:
Common::String _3doPlayMovieFile;
};