aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/debugger.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/engines/mads/debugger.cpp b/engines/mads/debugger.cpp
index 1ff42c5e2b..6bc6cf572d 100644
--- a/engines/mads/debugger.cpp
+++ b/engines/mads/debugger.cpp
@@ -21,6 +21,7 @@
*/
#include "common/file.h"
+#include "mads/compression.h"
#include "mads/mads.h"
#include "mads/debugger.h"
@@ -169,8 +170,10 @@ bool Debugger::Cmd_ShowCodes(int argc, const char **argv) {
}
bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
- if (argc != 2) {
- debugPrintf("Usage: %s <resource>\n", argv[0]);
+ if (argc < 2) {
+ debugPrintf("Usage: %s <resource> <unpack>\n", argv[0]);
+ debugPrintf(" resource: the resource name\n");
+ debugPrintf(" unpack: optional, when specified, the FAB/MADSPACK compressed resource is unpacked\n");
} else {
Common::DumpFile outFile;
Common::File inFile;
@@ -179,10 +182,32 @@ bool Debugger::Cmd_DumpFile(int argc, const char **argv) {
debugPrintf("Specified resource does not exist\n");
} else {
outFile.open(argv[1]);
- byte *data = new byte[inFile.size()];
-
- inFile.read(data, inFile.size());
- outFile.write(data, inFile.size());
+ bool unpack = ((argc >= 3) && !scumm_stricmp(argv[2], "unpack"));
+
+ byte *data;
+ int totalSize = 0;
+
+ if (!unpack) {
+ totalSize = inFile.size();
+ data = new byte[totalSize];
+ inFile.read(data, totalSize);
+ } else {
+ MadsPack dataPack(&inFile);
+ int count = dataPack.getCount();
+ for (int i = 0; i < count; i++) {
+ totalSize += dataPack.getItem(i)._size;
+ }
+ data = new byte[totalSize];
+ byte *ptr = data;
+
+ for (int i = 0; i < count; i++) {
+ Common::SeekableReadStream *readStream = dataPack.getItemStream(i);
+ readStream->read(ptr, readStream->size());
+ ptr += readStream->size();
+ }
+ }
+
+ outFile.write(data, totalSize);
outFile.flush();
delete[] data;