diff options
-rw-r--r-- | engines/mohawk/module.mk | 1 | ||||
-rw-r--r-- | engines/mohawk/myst.cpp | 4 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/credits.cpp | 159 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/credits.h | 64 | ||||
-rw-r--r-- | engines/mohawk/myst_stacks/myst.cpp | 28 |
5 files changed, 228 insertions, 28 deletions
diff --git a/engines/mohawk/module.mk b/engines/mohawk/module.mk index 6d2253d3e5..71c9c55be9 100644 --- a/engines/mohawk/module.mk +++ b/engines/mohawk/module.mk @@ -23,6 +23,7 @@ MODULE_OBJS = \ riven_vars.o \ sound.o \ video.o \ + myst_stacks/credits.o \ myst_stacks/myst.o \ myst_stacks/selenitic.o diff --git a/engines/mohawk/myst.cpp b/engines/mohawk/myst.cpp index f141a5aa68..103d40b1a1 100644 --- a/engines/mohawk/myst.cpp +++ b/engines/mohawk/myst.cpp @@ -39,6 +39,7 @@ #include "mohawk/video.h" // The stacks +#include "mohawk/myst_stacks/credits.h" #include "mohawk/myst_stacks/myst.h" #include "mohawk/myst_stacks/selenitic.h" @@ -375,6 +376,9 @@ void MohawkEngine_Myst::changeToStack(uint16 stack) { _prevStack = _scriptParser; switch (_curStack) { + case kCreditsStack: + _scriptParser = new MystScriptParser_Credits(this); + break; case kSeleniticStack: _scriptParser = new MystScriptParser_Selenitic(this); break; diff --git a/engines/mohawk/myst_stacks/credits.cpp b/engines/mohawk/myst_stacks/credits.cpp new file mode 100644 index 0000000000..f508892ee4 --- /dev/null +++ b/engines/mohawk/myst_stacks/credits.cpp @@ -0,0 +1,159 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM 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 program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#include "mohawk/myst.h" +#include "mohawk/graphics.h" +#include "mohawk/myst_areas.h" +#include "mohawk/sound.h" +#include "mohawk/video.h" +#include "mohawk/myst_stacks/credits.h" + +#include "gui/message.h" + +namespace Mohawk { + +// NOTE: Credits Start Card is 10000 + +#define OPCODE(op, x) { op, &MystScriptParser::x, #x } +#define SPECIFIC_OPCODE(op, x) { op, (OpcodeProcMyst) &MystScriptParser_Credits::x, #x } + +MystScriptParser_Credits::MystScriptParser_Credits(MohawkEngine_Myst *vm) : MystScriptParser(vm) { + setupOpcodes(); + _invokingResource = NULL; +} + +MystScriptParser_Credits::~MystScriptParser_Credits() { +} + +void MystScriptParser_Credits::setupOpcodes() { + // "invalid" opcodes do not exist or have not been observed + // "unknown" opcodes exist, but their meaning is unknown + + static const MystOpcode creditsOpcodes[] = { + // "Standard" Opcodes + OPCODE(0, o_toggleVar), + OPCODE(1, o_setVar), + OPCODE(2, o_changeCardSwitch), + OPCODE(3, o_takePage), + OPCODE(4, o_redrawCard), + // TODO: Opcode 5 Not Present + OPCODE(6, o_goToDest), + OPCODE(7, o_goToDest), + OPCODE(8, o_goToDest), + OPCODE(9, o_triggerMovie), + OPCODE(10, o_toggleVarNoRedraw), + // TODO: Opcode 10 to 11 Not Present + OPCODE(12, o_changeCardSwitch), + OPCODE(13, o_changeCardSwitch), + OPCODE(14, o_drawAreaState), + OPCODE(15, o_redrawAreaForVar), + OPCODE(16, o_changeCardDirectional), + OPCODE(17, o_changeCardPush), + OPCODE(18, o_changeCardPop), + OPCODE(19, o_enableAreas), + OPCODE(20, o_disableAreas), + OPCODE(21, o_directionalUpdate), + OPCODE(22, o_goToDest), + OPCODE(23, o_toggleAreasActivation), + OPCODE(24, o_playSound), + // TODO: Opcode 25 Not Present + OPCODE(26, o_stopSoundBackground), + OPCODE(27, o_playSoundBlocking), + OPCODE(28, o_restoreDefaultRect), + OPCODE(29, o_blitRect), + OPCODE(30, o_changeSound), + OPCODE(31, o_soundPlaySwitch), + OPCODE(32, o_soundResumeBackground), + OPCODE(33, o_blitRect), + OPCODE(34, o_changeCard), + OPCODE(35, o_drawImageChangeCard), + OPCODE(36, o_changeMainCursor), + OPCODE(37, o_hideCursor), + OPCODE(38, o_showCursor), + OPCODE(39, o_delay), + OPCODE(40, o_changeStack), + OPCODE(41, o_changeCardPlaySoundDirectional), + OPCODE(42, o_directionalUpdatePlaySound), + OPCODE(43, o_saveMainCursor), + OPCODE(44, o_restoreMainCursor), + // TODO: Opcode 45 Not Present + OPCODE(46, o_soundWaitStop), + // TODO: Opcodes 47 to 99 Not Present + + // "Stack-Specific" Opcodes + SPECIFIC_OPCODE(100, o_quit), + + // "Init" Opcodes + SPECIFIC_OPCODE(200, o_runCredits), + + OPCODE(0xFFFF, NOP) + }; + + _opcodes = creditsOpcodes; + _opcodeCount = ARRAYSIZE(creditsOpcodes); +} + +void MystScriptParser_Credits::disablePersistentScripts() { + _creditsRunning = false; + _creditsVar = 0; + _baseImageId = 0; + _lastCardTime = 0; +} + +void MystScriptParser_Credits::runPersistentScripts() { + if (!_creditsRunning) + return; + + uint16 curImageIndex = _vm->_varStore->getVar(_creditsVar); + + if (_vm->_system->getMillis() - _lastCardTime >= 7 * 1000) { + // After the 6th image has shown, it's time to quit + if (curImageIndex == 7) + _vm->_system->quit(); + + // Note: The modulus by 6 is because the 6th image is the one at imageBaseId + _vm->_gfx->copyImageToScreen(_baseImageId + curImageIndex % 6, Common::Rect(0, 0, 544, 333)); + _vm->_gfx->updateScreen(); + + _vm->_varStore->setVar(_creditsVar, curImageIndex + 1); + _lastCardTime = _vm->_system->getMillis(); + } +} + +void MystScriptParser_Credits::o_quit(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + _vm->_system->quit(); +} + +void MystScriptParser_Credits::o_runCredits(uint16 op, uint16 var, uint16 argc, uint16 *argv) { + // Activate the credits + _creditsRunning = true; + _creditsVar = var; + _baseImageId = _vm->getCurCard(); + _lastCardTime = _vm->_system->getMillis(); + + _vm->_varStore->setVar(var, 1); +} + +} // End of namespace Mohawk diff --git a/engines/mohawk/myst_stacks/credits.h b/engines/mohawk/myst_stacks/credits.h new file mode 100644 index 0000000000..2c4a79f3f8 --- /dev/null +++ b/engines/mohawk/myst_stacks/credits.h @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM 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 program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program 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 General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef MYST_SCRIPTS_CREDITS_H +#define MYST_SCRIPTS_CREDITS_H + +#include "common/scummsys.h" +#include "common/util.h" +#include "mohawk/myst_scripts.h" + +namespace Mohawk { + +#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv) + +class MohawkEngine_Myst; +struct MystScriptEntry; + +class MystScriptParser_Credits : public MystScriptParser { +public: + MystScriptParser_Credits(MohawkEngine_Myst *vm); + ~MystScriptParser_Credits(); + + void disablePersistentScripts(); + void runPersistentScripts(); + +private: + void setupOpcodes(); + + DECLARE_OPCODE(o_quit); + DECLARE_OPCODE(o_runCredits); + + bool _creditsRunning; + uint16 _creditsVar; + uint16 _baseImageId; + uint32 _lastCardTime; +}; + +} // End of namespace Mohawk + +#undef DECLARE_OPCODE + +#endif diff --git a/engines/mohawk/myst_stacks/myst.cpp b/engines/mohawk/myst_stacks/myst.cpp index e5c5b3a335..791b39f9e4 100644 --- a/engines/mohawk/myst_stacks/myst.cpp +++ b/engines/mohawk/myst_stacks/myst.cpp @@ -324,7 +324,6 @@ void MystScriptParser_Myst::opcode_100(uint16 op, uint16 var, uint16 argc, uint1 } else unknown(op, var, argc, argv); break; - case kCreditsStack: case kMakingOfStack: _vm->_system->quit(); break; @@ -1836,21 +1835,6 @@ void MystScriptParser_Myst::opcode_200_run() { lastImageIndex = curImageIndex; break; - case kCreditsStack: - curImageIndex = _vm->_varStore->getVar(g_opcode200Parameters.var); - - if (_vm->_system->getMillis() - g_opcode200Parameters.lastCardTime >= 7 * 1000) { - // After the 6th image has shown, it's time to quit - if (curImageIndex == 7) - _vm->_system->quit(); - - // Note: The modulus by 6 is because the 6th image is the one at imageBaseId - _vm->_gfx->copyImageToScreen(g_opcode200Parameters.imageBaseId + curImageIndex % 6, Common::Rect(0, 0, 544, 333)); - - _vm->_varStore->setVar(g_opcode200Parameters.var, curImageIndex + 1); - g_opcode200Parameters.lastCardTime = _vm->_system->getMillis(); - } - break; case kMechanicalStack: // Used on Card 6238 (Sirrus' Throne) and Card 6027 (Achenar's Throne) // g_opcode200Parameters.var == 0 for Achenar @@ -1961,18 +1945,6 @@ void MystScriptParser_Myst::opcode_200(uint16 op, uint16 var, uint16 argc, uint1 _vm->_video->playMovie(_vm->wrapMovieFilename("atrwrite", kDniStack), 215, 77); } break; - case kCreditsStack: - if (argc == 0) { - g_opcode200Parameters.var = var; - // TODO: Pass ImageCount, rather than hardcoded in run process? - g_opcode200Parameters.imageBaseId = _vm->getCurCard(); - g_opcode200Parameters.lastCardTime = _vm->_system->getMillis(); - g_opcode200Parameters.enabled = true; - - _vm->_varStore->setVar(var, 1); - } else - unknown(op, var, argc, argv); - break; case kDemoSlidesStack: // Used on Cards... if (argc == 1) { |