diff --git a/engines/myst3/console.cpp b/engines/myst3/console.cpp index deeaac74ed0..2bc59476d98 100644 --- a/engines/myst3/console.cpp +++ b/engines/myst3/console.cpp @@ -39,6 +39,7 @@ Console::Console(Myst3Engine *vm) : GUI::Debugger(), _vm(vm) { DCmd_Register("extract", WRAP_METHOD(Console, Cmd_Extract)); DCmd_Register("fillInventory", WRAP_METHOD(Console, Cmd_FillInventory)); DCmd_Register("dumpArchive", WRAP_METHOD(Console, Cmd_DumpArchive)); + DCmd_Register("dumpMasks", WRAP_METHOD(Console, Cmd_DumpMasks)); } Console::~Console() { @@ -321,4 +322,41 @@ bool Console::Cmd_DumpArchive(int argc, const char **argv) { return true; } +bool Console::Cmd_DumpMasks(int argc, const char **argv) { + if (argc != 1 && argc != 2) { + DebugPrintf("Extract the masks of the faces of a cube node.\n"); + DebugPrintf("The destination folder, named 'dump', must exist.\n"); + DebugPrintf("Usage :\n"); + DebugPrintf("dumpMasks [node]\n"); + return true; + } + + uint16 nodeId = _vm->_state->getLocationNode(); + + if (argc >= 2) { + nodeId = atoi(argv[1]); + } + + DebugPrintf("Extracting masks for node %d:\n", nodeId); + + for (uint i = 0; i < 6; i++) { + bool water = _vm->_node->dumpFaceMask(nodeId, i, DirectorySubEntry::kWaterEffectMask); + if (water) + DebugPrintf("Face %d: water OK\n", i); + + bool effect2 = _vm->_node->dumpFaceMask(nodeId, i, DirectorySubEntry::kEffect2Mask); + if (effect2) + DebugPrintf("Face %d: effect 2 OK\n", i); + + bool magnet = _vm->_node->dumpFaceMask(nodeId, i, DirectorySubEntry::kMagneticEffectMask); + if (magnet) + DebugPrintf("Face %d: magnet OK\n", i); + + if (!water && !effect2 && !magnet) + DebugPrintf("Face %d: No mask found\n", i); + } + + return true; +} + } /* namespace Myst3 */ diff --git a/engines/myst3/console.h b/engines/myst3/console.h index 71d9c7c5249..c8d9ab9b7af 100644 --- a/engines/myst3/console.h +++ b/engines/myst3/console.h @@ -51,6 +51,7 @@ private: bool Cmd_Go(int argc, const char **argv); bool Cmd_Extract(int argc, const char **argv); bool Cmd_DumpArchive(int argc, const char **argv); + bool Cmd_DumpMasks(int argc, const char **argv); bool Cmd_FillInventory(int argc, const char **argv); }; diff --git a/engines/myst3/directorysubentry.cpp b/engines/myst3/directorysubentry.cpp index 7f1447acf92..a55f01b6d3e 100644 --- a/engines/myst3/directorysubentry.cpp +++ b/engines/myst3/directorysubentry.cpp @@ -91,7 +91,7 @@ void DirectorySubEntry::dumpToFile(Common::SeekableReadStream &inStream, const c case kFrame: sprintf(fileName, "dump/%s-%d-%d.jpg", room, index, _face); break; - case kFaceMask: + case kWaterEffectMask: sprintf(fileName, "dump/%s-%d-%d.mask", room, index, _face); break; case kMovie: diff --git a/engines/myst3/directorysubentry.h b/engines/myst3/directorysubentry.h index 726d86b8e51..5c843a0a243 100644 --- a/engines/myst3/directorysubentry.h +++ b/engines/myst3/directorysubentry.h @@ -50,7 +50,9 @@ class DirectorySubEntry { public: enum ResourceType { kCubeFace = 0, - kFaceMask = 1, + kWaterEffectMask = 1, + kEffect2Mask = 2, + kMagneticEffectMask = 3, kSpotItem = 5, kFrame = 6, kCursor = 7, diff --git a/engines/myst3/node.cpp b/engines/myst3/node.cpp index 4dcce9d9008..03bee387438 100644 --- a/engines/myst3/node.cpp +++ b/engines/myst3/node.cpp @@ -65,7 +65,7 @@ Node::Node(Myst3Engine *vm, uint16 id) : _faces[i] = 0; } -void Node::dumpFaceMask(uint16 index, int face) { +bool Node::dumpFaceMask(uint16 index, int face, DirectorySubEntry::ResourceType type) { static const int32 kMaskSize = 640 * 640; byte *mask = new byte[kMaskSize]; @@ -73,10 +73,10 @@ void Node::dumpFaceMask(uint16 index, int face) { uint32 headerOffset = 0; uint32 dataOffset = 0; - const DirectorySubEntry *maskDesc = _vm->getFileDescription(0, index, face, DirectorySubEntry::kFaceMask); + const DirectorySubEntry *maskDesc = _vm->getFileDescription(0, index, face, type); if (!maskDesc) - return; + return false; Common::MemoryReadStream *maskStream = maskDesc->getData(); @@ -109,10 +109,12 @@ void Node::dumpFaceMask(uint16 index, int face) { delete maskStream; Common::DumpFile outFile; - outFile.open("dump/1-1.masku"); + outFile.open(Common::String::format("dump/%d-%d.masku_%d", index, face, type)); outFile.write(mask, kMaskSize); outFile.close(); delete[] mask; + + return true; } Node::~Node() { diff --git a/engines/myst3/node.h b/engines/myst3/node.h index ffb84d0d0d3..d60ca704bb8 100644 --- a/engines/myst3/node.h +++ b/engines/myst3/node.h @@ -24,6 +24,7 @@ #define MYST3_ROOM_H #include "engines/myst3/gfx.h" +#include "engines/myst3/directorysubentry.h" #include "common/array.h" #include "common/rect.h" @@ -35,7 +36,6 @@ namespace Myst3 { class Texture; class Myst3Engine; class Subtitles; -class DirectorySubEntry; class Face { public: @@ -141,7 +141,7 @@ class Node : Drawable { void loadSubtitles(uint32 id); bool hasSubtitlesToDraw(); - void dumpFaceMask(uint16 index, int face); + bool dumpFaceMask(uint16 index, int face, DirectorySubEntry::ResourceType type); }; } // end of namespace Myst3