Add a debug console command to Riven for displaying combinations to puzzles.

svn-id: r50338
This commit is contained in:
Matthew Hoops 2010-06-26 19:09:45 +00:00
parent 2b9f4e5068
commit e5e90eb8a8
4 changed files with 32 additions and 1 deletions

View file

@ -28,6 +28,7 @@
#include "mohawk/myst_scripts.h" #include "mohawk/myst_scripts.h"
#include "mohawk/graphics.h" #include "mohawk/graphics.h"
#include "mohawk/riven.h" #include "mohawk/riven.h"
#include "mohawk/riven_external.h"
#include "mohawk/livingbooks.h" #include "mohawk/livingbooks.h"
#include "mohawk/sound.h" #include "mohawk/sound.h"
#include "mohawk/video.h" #include "mohawk/video.h"
@ -307,6 +308,7 @@ RivenConsole::RivenConsole(MohawkEngine_Riven *vm) : GUI::Debugger(), _vm(vm) {
DCmd_Register("dumpScript", WRAP_METHOD(RivenConsole, Cmd_DumpScript)); DCmd_Register("dumpScript", WRAP_METHOD(RivenConsole, Cmd_DumpScript));
DCmd_Register("listZipCards", WRAP_METHOD(RivenConsole, Cmd_ListZipCards)); DCmd_Register("listZipCards", WRAP_METHOD(RivenConsole, Cmd_ListZipCards));
DCmd_Register("getRMAP", WRAP_METHOD(RivenConsole, Cmd_GetRMAP)); DCmd_Register("getRMAP", WRAP_METHOD(RivenConsole, Cmd_GetRMAP));
DCmd_Register("combos", WRAP_METHOD(RivenConsole, Cmd_Combos));
} }
RivenConsole::~RivenConsole() { RivenConsole::~RivenConsole() {
@ -608,6 +610,33 @@ bool RivenConsole::Cmd_GetRMAP(int argc, const char **argv) {
return true; return true;
} }
bool RivenConsole::Cmd_Combos(int argc, const char **argv) {
// In the vain of SCUMM's 'drafts' command, this command will list
// out all combinations needed in Riven, decoded from the variables.
// You'll need to look up the Rebel Tunnel puzzle on your own; the
// solution is constant.
uint32 teleCombo = *_vm->matchVarToString("tcorrectorder");
uint32 prisonCombo = *_vm->matchVarToString("pcorrectorder");
uint32 domeCombo = *_vm->matchVarToString("adomecombo");
DebugPrintf("Telescope Combo:\n ");
for (int i = 0; i < 5; i++)
DebugPrintf("%d ", _vm->_externalScriptHandler->getComboDigit(teleCombo, i));
DebugPrintf("\nPrison Combo:\n ");
for (int i = 0; i < 5; i++)
DebugPrintf("%d ", _vm->_externalScriptHandler->getComboDigit(prisonCombo, i));
DebugPrintf("\nDome Combo:\n ");
for (int i = 1; i <= 25; i++)
if (domeCombo & (1 << (25 - i)))
DebugPrintf("%d ", i);
DebugPrintf("\n");
return true;
}
LivingBooksConsole::LivingBooksConsole(MohawkEngine_LivingBooks *vm) : GUI::Debugger(), _vm(vm) { LivingBooksConsole::LivingBooksConsole(MohawkEngine_LivingBooks *vm) : GUI::Debugger(), _vm(vm) {
DCmd_Register("playSound", WRAP_METHOD(LivingBooksConsole, Cmd_PlaySound)); DCmd_Register("playSound", WRAP_METHOD(LivingBooksConsole, Cmd_PlaySound));
DCmd_Register("stopSound", WRAP_METHOD(LivingBooksConsole, Cmd_StopSound)); DCmd_Register("stopSound", WRAP_METHOD(LivingBooksConsole, Cmd_StopSound));

View file

@ -88,6 +88,7 @@ private:
bool Cmd_DumpScript(int argc, const char **argv); bool Cmd_DumpScript(int argc, const char **argv);
bool Cmd_ListZipCards(int argc, const char **argv); bool Cmd_ListZipCards(int argc, const char **argv);
bool Cmd_GetRMAP(int argc, const char **argv); bool Cmd_GetRMAP(int argc, const char **argv);
bool Cmd_Combos(int argc, const char **argv);
}; };
class LivingBooksConsole : public GUI::Debugger { class LivingBooksConsole : public GUI::Debugger {

View file

@ -1325,7 +1325,7 @@ void RivenExternal::xogehnbooknextpage(uint16 argc, uint16 *argv) {
_vm->_gfx->updateScreen(); _vm->_gfx->updateScreen();
} }
static uint16 getComboDigit(uint32 correctCombo, uint32 digit) { uint16 RivenExternal::getComboDigit(uint32 correctCombo, uint32 digit) {
static const uint32 powers[] = { 100000, 10000, 1000, 100, 10, 1 }; static const uint32 powers[] = { 100000, 10000, 1000, 100, 10, 1 };
return (correctCombo % powers[digit]) / powers[digit + 1]; return (correctCombo % powers[digit]) / powers[digit + 1];
} }

View file

@ -38,6 +38,7 @@ public:
~RivenExternal(); ~RivenExternal();
void runCommand(uint16 argc, uint16 *argv); void runCommand(uint16 argc, uint16 *argv);
uint16 getComboDigit(uint32 correctCombo, uint32 digit);
private: private:
MohawkEngine_Riven *_vm; MohawkEngine_Riven *_vm;