diff options
author | Bastien Bouclet | 2016-08-13 08:57:06 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-03 08:50:10 +0200 |
commit | 9ab0d53cd3d8008b55d64cea832191f5ef2155ce (patch) | |
tree | 457dfd8bfaf5da2816acab8f49eb800484c6f115 /engines | |
parent | ab9b241e50a54384635f3bc35dbb775e0fa3a909 (diff) | |
download | scummvm-rg350-9ab0d53cd3d8008b55d64cea832191f5ef2155ce.tar.gz scummvm-rg350-9ab0d53cd3d8008b55d64cea832191f5ef2155ce.tar.bz2 scummvm-rg350-9ab0d53cd3d8008b55d64cea832191f5ef2155ce.zip |
MOHAWK: Add console commands to dump Riven cards and stacks to stdout
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mohawk/console.cpp | 28 | ||||
-rw-r--r-- | engines/mohawk/console.h | 3 | ||||
-rw-r--r-- | engines/mohawk/riven_card.cpp | 82 | ||||
-rw-r--r-- | engines/mohawk/riven_card.h | 6 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.cpp | 19 | ||||
-rw-r--r-- | engines/mohawk/riven_scripts.h | 3 | ||||
-rw-r--r-- | engines/mohawk/riven_stack.cpp | 21 | ||||
-rw-r--r-- | engines/mohawk/riven_stack.h | 6 |
8 files changed, 166 insertions, 2 deletions
diff --git a/engines/mohawk/console.cpp b/engines/mohawk/console.cpp index 417d9dd63f..3f6f241a23 100644 --- a/engines/mohawk/console.cpp +++ b/engines/mohawk/console.cpp @@ -379,11 +379,13 @@ bool MystConsole::Cmd_QuickTest(int argc, const char **argv) { RivenConsole::RivenConsole(MohawkEngine_Riven *vm) : GUI::Debugger(), _vm(vm) { registerCmd("changeCard", WRAP_METHOD(RivenConsole, Cmd_ChangeCard)); registerCmd("curCard", WRAP_METHOD(RivenConsole, Cmd_CurCard)); + registerCmd("dumpCard", WRAP_METHOD(RivenConsole, Cmd_DumpCard)); registerCmd("var", WRAP_METHOD(RivenConsole, Cmd_Var)); registerCmd("playSound", WRAP_METHOD(RivenConsole, Cmd_PlaySound)); registerCmd("playSLST", WRAP_METHOD(RivenConsole, Cmd_PlaySLST)); registerCmd("stopSound", WRAP_METHOD(RivenConsole, Cmd_StopSound)); registerCmd("curStack", WRAP_METHOD(RivenConsole, Cmd_CurStack)); + registerCmd("dumpStack", WRAP_METHOD(RivenConsole, Cmd_DumpStack)); registerCmd("changeStack", WRAP_METHOD(RivenConsole, Cmd_ChangeStack)); registerCmd("hotspots", WRAP_METHOD(RivenConsole, Cmd_Hotspots)); registerCmd("zipMode", WRAP_METHOD(RivenConsole, Cmd_ZipMode)); @@ -542,6 +544,32 @@ bool RivenConsole::Cmd_ZipMode(int argc, const char **argv) { return true; } +bool RivenConsole::Cmd_DumpCard(int argc, const char **argv) { + if (argc != 1) { + debugPrintf("Usage: dumpCard\n"); + return true; + } + + _vm->getCard()->dump(); + + debugPrintf("Card dump complete.\n"); + + return true; +} + +bool RivenConsole::Cmd_DumpStack(int argc, const char **argv) { + if (argc != 1) { + debugPrintf("Usage: dumpStack\n"); + return true; + } + + _vm->getStack()->dump(); + + debugPrintf("Stack dump complete.\n"); + + return true; +} + bool RivenConsole::Cmd_DumpScript(int argc, const char **argv) { if (argc < 4) { debugPrintf("Usage: dumpScript <stack> <CARD or HSPT> <card>\n"); diff --git a/engines/mohawk/console.h b/engines/mohawk/console.h index dc40049a89..0cae87da51 100644 --- a/engines/mohawk/console.h +++ b/engines/mohawk/console.h @@ -82,7 +82,8 @@ private: bool Cmd_ChangeStack(int argc, const char **argv); bool Cmd_Hotspots(int argc, const char **argv); bool Cmd_ZipMode(int argc, const char **argv); - bool Cmd_RunAllBlocks(int argc, const char **argv); + bool Cmd_DumpCard(int argc, const char **argv); + bool Cmd_DumpStack(int argc, const char **argv); bool Cmd_DumpScript(int argc, const char **argv); bool Cmd_ListZipCards(int argc, const char **argv); bool Cmd_GetRMAP(int argc, const char **argv); diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp index 0b3d96f981..e82e00b7ac 100644 --- a/engines/mohawk/riven_card.cpp +++ b/engines/mohawk/riven_card.cpp @@ -450,6 +450,69 @@ void RivenCard::setCurrentCardVariable() { _vm->_vars["currentcardid"] = _id; } +void RivenCard::dump() const { + debug("== Card =="); + debug("id: %d", _id); + if (_name >= 0) { + debug("name: %s", _vm->getStack()->getName(kCardNames, _name).c_str()); + } else { + debug("name: [no name]"); + } + debug("zipModePlace: %d", _zipModePlace); + debug("globalId: %x", _vm->getStack()->getCardGlobalId(_id)); + debugN("\n"); + + for (uint i = 0; i < _scripts.size(); i++) { + debug("== Script %d ==", i); + debug("type: %s", RivenScript::getTypeName(_scripts[i].type)); + _scripts[i].script->dumpScript(0); + debugN("\n"); + } + + for (uint i = 0; i < _hotspots.size(); i++) { + debug("== Hotspot %d ==", i); + _hotspots[i]->dump(); + } + + for (uint i = 0; i < _pictureList.size(); i++) { + const Common::Rect &rect = _pictureList[i].rect; + debug("== Picture %d ==", _pictureList[i].index); + debug("pictureId: %d", _pictureList[i].id); + debug("rect: (%d, %d, %d, %d)", rect.left, rect.top, rect.right, rect.bottom); + debugN("\n"); + } + + for (uint i = 0; i < _waterEffectList.size(); i++) { + debug("== Effect %d ==", _waterEffectList[i].index); + debug("sfxeId: %d", _waterEffectList[i].sfxeId); + debug("u0: %d", _waterEffectList[i].u0); + debugN("\n"); + } + + for (uint i = 0; i < _hotspotEnableList.size(); i++) { + debug("== Hotspot enable %d ==", _hotspotEnableList[i].index); + debug("hotspotId: %d", _hotspotEnableList[i].hotspotId); + debug("enabled: %d", _hotspotEnableList[i].enabled); + debugN("\n"); + } + + for (uint i = 0; i < _soundList.size(); i++) { + debug("== Ambient sound list %d ==", _soundList[i].index); + debug("globalVolume: %d", _soundList[i].globalVolume); + debug("fadeFlags: %d", _soundList[i].fadeFlags); + debug("loop: %d", _soundList[i].loop); + debug("suspend: %d", _soundList[i].suspend); + debug("u0: %d", _soundList[i].u0); + for (uint j = 0; j < _soundList[i].soundIds.size(); j++) { + debug("sound[%d].id: %d", j, _soundList[i].soundIds[j]); + debug("sound[%d].volume: %d", j, _soundList[i].volumes[j]); + debug("sound[%d].balance: %d", j, _soundList[i].balances[j]); + debug("sound[%d].u2: %d", j, _soundList[i].u2[j]); + } + debugN("\n"); + } +} + RivenHotspot::RivenHotspot(MohawkEngine_Riven *vm, Common::ReadStream *stream) : _vm(vm) { loadFromStream(stream); @@ -547,4 +610,23 @@ int16 RivenHotspot::getNameId() const { return _nameResource; } +void RivenHotspot::dump() const { + debug("index: %d", _index); + debug("blstId: %d", _blstID); + debug("name: %s", getName().c_str()); + debug("rect: (%d, %d, %d, %d)", _rect.left, _rect.top, _rect.right, _rect.bottom); + debug("flags: %d", _flags); + debug("mouseCursor: %d", _mouseCursor); + debug("u0: %d", _u0); + debug("u1: %d", _u1); + debugN("\n"); + + for (uint i = 0; i < _scripts.size(); i++) { + debug("=== Hotspot script %d ===", i); + debug("type: %s", RivenScript::getTypeName(_scripts[i].type)); + _scripts[i].script->dumpScript(0); + debugN("\n"); + } +} + } // End of namespace Mohawk diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h index 86cfae0a85..d20f63dfd6 100644 --- a/engines/mohawk/riven_card.h +++ b/engines/mohawk/riven_card.h @@ -117,6 +117,9 @@ public: /** Frame update handler for mouse dragging */ void onMouseDragUpdate(); + /** Write all of the card's data to standard output */ + void dump() const; + private: void loadCardResource(uint16 id); void loadHotspots(uint16 id); @@ -209,6 +212,9 @@ public: /** Get the hotspot's enable list id */ uint16 getBlstId() const; + /** Write all of the hotspot's data to standard output */ + void dump() const; + private: enum { kFlagZip = 1, diff --git a/engines/mohawk/riven_scripts.cpp b/engines/mohawk/riven_scripts.cpp index fabb8c6441..794e8db6cd 100644 --- a/engines/mohawk/riven_scripts.cpp +++ b/engines/mohawk/riven_scripts.cpp @@ -189,6 +189,25 @@ RivenScript &RivenScript::operator+=(const RivenScript &other) { return *this; } +const char *RivenScript::getTypeName(uint16 type) { + static const char *names[] = { + "MouseDown", + "MouseDrag", + "MouseUp", + "MouseEnter", + "MouseInside", + "MouseLeave", + "CardLoad", + "CardLeave", + "CardUnknown", + "CardOpen", + "CardUpdate" + }; + + assert(type < ARRAYSIZE(names)); + return names[type]; +} + RivenScriptPtr &operator+=(RivenScriptPtr &lhs, const RivenScriptPtr &rhs) { *lhs += *rhs; return lhs; diff --git a/engines/mohawk/riven_scripts.h b/engines/mohawk/riven_scripts.h index 0d575d7adc..304c2f312f 100644 --- a/engines/mohawk/riven_scripts.h +++ b/engines/mohawk/riven_scripts.h @@ -90,6 +90,9 @@ public: /** Append the commands of the other script to this script */ RivenScript &operator+=(const RivenScript &other); + /** Get a caption for a script type */ + static const char *getTypeName(uint16 type); + private: Common::Array<RivenCommand *> _commands; bool _continueRunning; diff --git a/engines/mohawk/riven_stack.cpp b/engines/mohawk/riven_stack.cpp index bbe00fcf7d..83ebf5751a 100644 --- a/engines/mohawk/riven_stack.cpp +++ b/engines/mohawk/riven_stack.cpp @@ -114,13 +114,32 @@ uint16 RivenStack::getCardStackId(uint32 globalId) const { } uint32 RivenStack::getCurrentCardGlobalId() const { - return _cardIdMap[_vm->getCard()->getId()]; + return getCardGlobalId(_vm->getCard()->getId()); } void RivenStack::setCurrentStackVariable() { _vm->_vars["currentstackid"] = _id; } +uint32 RivenStack::getCardGlobalId(uint16 cardId) const { + return _cardIdMap[cardId]; +} + +void RivenStack::dump() const { + debug("= Stack ="); + debug("id: %d", _id); + debug("name: %s", _vm->getStackName(_id).c_str()); + debugN("\n"); + + for (uint i = 0; i < _cardIdMap.size(); i++) { + if (!_vm->hasResource(ID_CARD, i)) continue; + + RivenCard *card = new RivenCard(_vm, i); + card->dump(); + delete card; + } +} + RivenNameList::RivenNameList() { } diff --git a/engines/mohawk/riven_stack.h b/engines/mohawk/riven_stack.h index 6daf3654e1..33c6f48034 100644 --- a/engines/mohawk/riven_stack.h +++ b/engines/mohawk/riven_stack.h @@ -95,6 +95,12 @@ public: /** Get the global id of the currently active card */ uint32 getCurrentCardGlobalId() const; + + /** Get the global id of a card in the stack */ + uint32 getCardGlobalId(uint16 cardId) const; + + /** Write all of the stack's data including its cards to standard output */ + void dump() const; private: void loadResourceNames(); void loadCardIdMap(); |