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/cursors.h"
24 #include "mohawk/myst.h"
25 #include "mohawk/myst_graphics.h"
26 #include "mohawk/myst_stacks/demo.h"
27
28 #include "common/system.h"
29
30 namespace Mohawk {
31 namespace MystStacks {
32
Demo(MohawkEngine_Myst * vm)33 Demo::Demo(MohawkEngine_Myst *vm) :
34 Intro(vm, kDemoStack),
35 _returnToMenuRunning(false),
36 _returnToMenuStep(0),
37 _returnToMenuNextTime(0) {
38 setupOpcodes();
39 }
40
~Demo()41 Demo::~Demo() {
42 }
43
setupOpcodes()44 void Demo::setupOpcodes() {
45 // "Stack-Specific" Opcodes
46 OVERRIDE_OPCODE(100, Demo, o_stopIntro);
47 REGISTER_OPCODE(101, Demo, o_fadeFromBlack);
48 REGISTER_OPCODE(102, Demo, o_fadeToBlack);
49
50 // "Init" Opcodes
51 OVERRIDE_OPCODE(201, Demo, o_returnToMenu_init);
52 }
53
disablePersistentScripts()54 void Demo::disablePersistentScripts() {
55 Intro::disablePersistentScripts();
56
57 _returnToMenuRunning = false;
58 }
59
runPersistentScripts()60 void Demo::runPersistentScripts() {
61 Intro::runPersistentScripts();
62
63 if (_returnToMenuRunning) {
64 returnToMenu_run();
65 }
66 }
67
o_stopIntro(uint16 var,const ArgumentsArray & args)68 void Demo::o_stopIntro(uint16 var, const ArgumentsArray &args) {
69 // The original also seems to stop the movies. Not needed with this engine.
70 _vm->_gfx->fadeToBlack();
71 }
72
o_fadeFromBlack(uint16 var,const ArgumentsArray & args)73 void Demo::o_fadeFromBlack(uint16 var, const ArgumentsArray &args) {
74 // FIXME: This glitches when enabled. The backbuffer is drawn to screen,
75 // and then the fading occurs, causing the background to appear for one frame.
76 // _vm->_gfx->fadeFromBlack();
77 }
78
o_fadeToBlack(uint16 var,const ArgumentsArray & args)79 void Demo::o_fadeToBlack(uint16 var, const ArgumentsArray &args) {
80 _vm->_gfx->fadeToBlack();
81 }
82
returnToMenu_run()83 void Demo::returnToMenu_run() {
84 uint32 time = _vm->getTotalPlayTime();
85
86 if (time < _returnToMenuNextTime)
87 return;
88
89 switch (_returnToMenuStep) {
90 case 0:
91 _vm->_gfx->fadeToBlack();
92 _vm->changeToCard(2003, kNoTransition);
93 _vm->_gfx->fadeFromBlack();
94
95 _returnToMenuStep++;
96 break;
97 case 1:
98 _vm->_gfx->fadeToBlack();
99 _vm->changeToCard(2001, kNoTransition);
100 _vm->_gfx->fadeFromBlack();
101 _vm->_cursor->showCursor();
102
103 _returnToMenuStep++;
104 break;
105 default:
106 break;
107 }
108 }
109
o_returnToMenu_init(uint16 var,const ArgumentsArray & args)110 void Demo::o_returnToMenu_init(uint16 var, const ArgumentsArray &args) {
111 // Used on Card 2001, 2002 and 2003
112 _returnToMenuNextTime = _vm->getTotalPlayTime() + 5000;
113 _returnToMenuRunning = true;
114 }
115
116 } // End of namespace MystStacks
117 } // End of namespace Mohawk
118