MYST3: Add a debug command to dump the faces' masks

This commit is contained in:
Bastien Bouclet 2013-01-03 11:03:52 +01:00
parent bbf66ec232
commit 0da347f540
6 changed files with 51 additions and 8 deletions

View File

@ -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 */

View File

@ -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);
};

View File

@ -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:

View File

@ -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,

View File

@ -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() {

View File

@ -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