1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "mohawk/myst.h"
24 #include "mohawk/myst_areas.h"
25 #include "mohawk/myst_card.h"
26 #include "mohawk/myst_graphics.h"
27 #include "mohawk/cursors.h"
28 #include "mohawk/sound.h"
29 #include "mohawk/video.h"
30 #include "mohawk/myst_stacks/credits.h"
31
32 #include "common/system.h"
33
34 namespace Mohawk {
35 namespace MystStacks {
36
37 // NOTE: Credits Start Card is 10000
38
Credits(MohawkEngine_Myst * vm)39 Credits::Credits(MohawkEngine_Myst *vm) :
40 MystScriptParser(vm, kCreditsStack),
41 _creditsRunning(false),
42 _curImage(0) {
43 setupOpcodes();
44 }
45
~Credits()46 Credits::~Credits() {
47 }
48
setupOpcodes()49 void Credits::setupOpcodes() {
50 // "Stack-Specific" Opcodes
51 REGISTER_OPCODE(100, Credits, o_quit);
52
53 // "Init" Opcodes
54 REGISTER_OPCODE(200, Credits, o_runCredits);
55 }
56
disablePersistentScripts()57 void Credits::disablePersistentScripts() {
58 _creditsRunning = false;
59 }
60
runPersistentScripts()61 void Credits::runPersistentScripts() {
62 if (!_creditsRunning)
63 return;
64
65 if (_vm->getTotalPlayTime() - _startTime >= 7 * 1000) {
66 _curImage++;
67
68 // After the 6th image has shown, it's time to quit
69 if (_curImage == 7) {
70 _vm->quitGame();
71 return;
72 }
73
74 // Draw next image
75 _vm->getCard()->drawBackground();
76 _vm->_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
77
78 _startTime = _vm->getTotalPlayTime();
79 }
80 }
81
getVar(uint16 var)82 uint16 Credits::getVar(uint16 var) {
83 switch(var) {
84 case 0: // Credits Image Control
85 return _curImage;
86 case 1: // Credits Music Control (Good / bad ending)
87 return _globals.ending != kBooksDestroyed;
88 default:
89 return MystScriptParser::getVar(var);
90 }
91 }
92
o_runCredits(uint16 var,const ArgumentsArray & args)93 void Credits::o_runCredits(uint16 var, const ArgumentsArray &args) {
94 // The credits stack does not have all the cursors, reset to the default cursor.
95 _globals.heldPage = kNoPage;
96 _vm->setMainCursor(kDefaultMystCursor);
97
98 // Activate the credits
99 _creditsRunning = true;
100 _curImage = 0;
101 _startTime = _vm->getTotalPlayTime();
102 }
103
104 } // End of namespace MystStacks
105 } // End of namespace Mohawk
106