From abecdf9cbf8dcde923c7053f58b64cb640655df4 Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Mon, 9 Jan 2012 12:26:15 +0100 Subject: [PATCH] MYST3: Add infrastructure for puzzle helpers --- engines/myst3/console.cpp | 1 + engines/myst3/module.mk | 1 + engines/myst3/myst3.cpp | 2 ++ engines/myst3/myst3.h | 3 +-- engines/myst3/puzzles.cpp | 39 ++++++++++++++++++++++++++++++++++ engines/myst3/puzzles.h | 44 +++++++++++++++++++++++++++++++++++++++ engines/myst3/script.cpp | 32 ++++++++++++++++++++++++++++ engines/myst3/script.h | 8 +++++++ 8 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 engines/myst3/puzzles.cpp create mode 100644 engines/myst3/puzzles.h diff --git a/engines/myst3/console.cpp b/engines/myst3/console.cpp index f693ffaafce..899f8113296 100644 --- a/engines/myst3/console.cpp +++ b/engines/myst3/console.cpp @@ -23,6 +23,7 @@ #include "engines/myst3/console.h" #include "engines/myst3/database.h" #include "engines/myst3/inventory.h" +#include "engines/myst3/script.h" #include "engines/myst3/variables.h" namespace Myst3 { diff --git a/engines/myst3/module.mk b/engines/myst3/module.mk index 75c05891ee3..23b9a515fea 100644 --- a/engines/myst3/module.mk +++ b/engines/myst3/module.mk @@ -15,6 +15,7 @@ MODULE_OBJS := \ node.o \ nodecube.o \ nodeframe.o \ + puzzles.o \ scene.o \ script.o \ variables.o diff --git a/engines/myst3/myst3.cpp b/engines/myst3/myst3.cpp index c7c317c02c0..73294149cff 100644 --- a/engines/myst3/myst3.cpp +++ b/engines/myst3/myst3.cpp @@ -32,6 +32,7 @@ #include "engines/engine.h" +#include "engines/myst3/console.h" #include "engines/myst3/database.h" #include "engines/myst3/myst3.h" #include "engines/myst3/nodecube.h" @@ -39,6 +40,7 @@ #include "engines/myst3/variables.h" #include "engines/myst3/cursor.h" #include "engines/myst3/inventory.h" +#include "engines/myst3/script.h" #include "graphics/jpeg.h" #include "graphics/conversion.h" diff --git a/engines/myst3/myst3.h b/engines/myst3/myst3.h index 7601249f62a..f023928770d 100644 --- a/engines/myst3/myst3.h +++ b/engines/myst3/myst3.h @@ -29,11 +29,9 @@ #include "common/random.h" #include "engines/myst3/archive.h" -#include "engines/myst3/console.h" #include "engines/myst3/movie.h" #include "engines/myst3/node.h" #include "engines/myst3/scene.h" -#include "engines/myst3/script.h" namespace Graphics { struct Surface; @@ -62,6 +60,7 @@ class HotSpot; class Cursor; class Inventory; class Database; +class Script; struct NodeData; typedef Common::SharedPtr NodePtr; diff --git a/engines/myst3/puzzles.cpp b/engines/myst3/puzzles.cpp new file mode 100644 index 00000000000..923ebacd88a --- /dev/null +++ b/engines/myst3/puzzles.cpp @@ -0,0 +1,39 @@ +/* ResidualVM - A 3D game interpreter + * + * ResidualVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#include "engines/myst3/puzzles.h" +#include "engines/myst3/myst3.h" + +namespace Myst3 { + +Puzzles::Puzzles(Myst3Engine *vm) : + _vm(vm) { +} + +Puzzles::~Puzzles() { +} + +void Puzzles::run(uint16 id, uint16 arg0, uint16 arg1, uint16 arg3) { + warning("Puzzle %d is not implemented", id); +} + +} /* namespace Myst3 */ diff --git a/engines/myst3/puzzles.h b/engines/myst3/puzzles.h new file mode 100644 index 00000000000..615a52b9f3b --- /dev/null +++ b/engines/myst3/puzzles.h @@ -0,0 +1,44 @@ +/* ResidualVM - A 3D game interpreter + * + * ResidualVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * + */ + +#ifndef PUZZLES_H_ +#define PUZZLES_H_ + +#include "common/scummsys.h" + +namespace Myst3 { + +class Myst3Engine; + +class Puzzles { +public: + Puzzles(Myst3Engine *vm); + virtual ~Puzzles(); + + void run(uint16 id, uint16 arg0 = 0, uint16 arg1 = 0, uint16 arg3 = 0); + +private: + Myst3Engine *_vm; +}; + +} /* namespace Myst3 */ +#endif /* PUZZLES_H_ */ diff --git a/engines/myst3/script.cpp b/engines/myst3/script.cpp index 9e48a12b41e..8eb75988400 100644 --- a/engines/myst3/script.cpp +++ b/engines/myst3/script.cpp @@ -26,12 +26,15 @@ #include "engines/myst3/variables.h" #include "engines/myst3/cursor.h" #include "engines/myst3/inventory.h" +#include "engines/myst3/puzzles.h" namespace Myst3 { Script::Script(Myst3Engine *vm): _vm(vm) { + _puzzles = new Puzzles(_vm); + #define OP_0(op, x) _commands.push_back(Command(op, &Script::x, #x, 0)) #define OP_1(op, x, type1) _commands.push_back(Command(op, &Script::x, #x, 1, type1)) #define OP_2(op, x, type1, type2) _commands.push_back(Command(op, &Script::x, #x, 2, type1, type2)) @@ -161,6 +164,10 @@ Script::Script(Myst3Engine *vm): OP_3(185, drawFramesForVarEachTwoFrames, kVar, kValue, kValue ); OP_3(186, drawFramesForVarStartEndVarEachTwoFrames, kVar, kVar, kVar ); OP_1(187, runScript, kValue ); + OP_1(194, runPuzzle1, kValue ); + OP_2(195, runPuzzle2, kValue, kValue ); + OP_3(196, runPuzzle3, kValue, kValue, kValue ); + OP_4(197, runPuzzle4, kValue, kValue, kValue, kValue ); #undef OP_0 #undef OP_1 @@ -171,6 +178,7 @@ Script::Script(Myst3Engine *vm): } Script::~Script() { + delete _puzzles; } bool Script::run(const Common::Array *script) { @@ -1522,4 +1530,28 @@ void Script::runScript(Context &c, const Opcode &cmd) { _vm->runScriptsFromNode(cmd.args[0], _vm->_vars->getLocationRoom()); } +void Script::runPuzzle1(Context &c, const Opcode &cmd) { + debugC(kDebugScript, "Opcode %d: Run puzzle helper %d", cmd.op, cmd.args[0]); + + _puzzles->run(cmd.args[0]); +} + +void Script::runPuzzle2(Context &c, const Opcode &cmd) { + debugC(kDebugScript, "Opcode %d: Run puzzle helper %d", cmd.op, cmd.args[0]); + + _puzzles->run(cmd.args[0], cmd.args[1]); +} + +void Script::runPuzzle3(Context &c, const Opcode &cmd) { + debugC(kDebugScript, "Opcode %d: Run puzzle helper %d", cmd.op, cmd.args[0]); + + _puzzles->run(cmd.args[0], cmd.args[1], cmd.args[2]); +} + +void Script::runPuzzle4(Context &c, const Opcode &cmd) { + debugC(kDebugScript, "Opcode %d: Run puzzle helper %d", cmd.op, cmd.args[0]); + + _puzzles->run(cmd.args[0], cmd.args[1], cmd.args[2], cmd.args[3]); +} + } /* namespace Myst3 */ diff --git a/engines/myst3/script.h b/engines/myst3/script.h index 1c816a94aa1..5891453c5c2 100644 --- a/engines/myst3/script.h +++ b/engines/myst3/script.h @@ -28,6 +28,7 @@ namespace Myst3 { class Myst3Engine; +class Puzzles; struct Opcode; #define DECLARE_OPCODE(x) void x(Context &c, const Opcode &cmd) @@ -80,6 +81,8 @@ private: }; Myst3Engine *_vm; + Puzzles *_puzzles; + Common::Array _commands; const Command &findCommand(uint16 op); @@ -214,6 +217,11 @@ private: DECLARE_OPCODE(drawFramesForVarEachTwoFrames); DECLARE_OPCODE(drawFramesForVarStartEndVarEachTwoFrames); DECLARE_OPCODE(runScript); + DECLARE_OPCODE(runPuzzle1); + DECLARE_OPCODE(runPuzzle2); + DECLARE_OPCODE(runPuzzle3); + DECLARE_OPCODE(runPuzzle4); + }; } /* namespace Myst3 */