aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorFilippos Karapetis2014-07-23 02:43:38 +0300
committerFilippos Karapetis2014-07-23 02:47:29 +0300
commit9118f38b299f6ec5bfc6971306f5b99cf0a1fd6c (patch)
tree6fe01eaf13deb89e8dc27843176bf229da0d8496 /engines/mads
parent78258151ea16202ca6fd2587565d477657972a96 (diff)
downloadscummvm-rg350-9118f38b299f6ec5bfc6971306f5b99cf0a1fd6c.tar.gz
scummvm-rg350-9118f38b299f6ec5bfc6971306f5b99cf0a1fd6c.tar.bz2
scummvm-rg350-9118f38b299f6ec5bfc6971306f5b99cf0a1fd6c.zip
MADS: Add support for FAB decompression in the dump_file command
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;