1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/* 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.
*
*/
#include "mohawk/cursors.h"
#include "mohawk/graphics.h"
#include "mohawk/myst.h"
#include "mohawk/myst_stacks/demo.h"
#include "common/system.h"
namespace Mohawk {
namespace MystStacks {
Demo::Demo(MohawkEngine_Myst *vm) : Intro(vm) {
setupOpcodes();
_returnToMenuStep = 0;
}
Demo::~Demo() {
}
#define OPCODE(op, x) _opcodes.push_back(new MystOpcode(op, (OpcodeProcMyst) &Demo::x, #x))
#define OVERRIDE_OPCODE(opcode, x) \
for (uint32 i = 0; i < _opcodes.size(); i++) \
if (_opcodes[i]->op == opcode) { \
_opcodes[i]->proc = (OpcodeProcMyst) &Demo::x; \
_opcodes[i]->desc = #x; \
break; \
}
void Demo::setupOpcodes() {
// "Stack-Specific" Opcodes
OVERRIDE_OPCODE(100, o_stopIntro);
OPCODE(101, o_fadeFromBlack);
OPCODE(102, o_fadeToBlack);
// "Init" Opcodes
OVERRIDE_OPCODE(201, o_returnToMenu_init);
}
#undef OPCODE
#undef OVERRIDE_OPCODE
void Demo::disablePersistentScripts() {
Intro::disablePersistentScripts();
_returnToMenuRunning = false;
}
void Demo::runPersistentScripts() {
Intro::runPersistentScripts();
if (_returnToMenuRunning) {
returnToMenu_run();
}
}
void Demo::o_stopIntro(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Unk", op);
// The original also seems to stop the movies. Not needed with this engine.
_vm->_gfx->fadeToBlack();
}
void Demo::o_fadeFromBlack(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Fade from black", op);
// FIXME: This glitches when enabled. The backbuffer is drawn to screen,
// and then the fading occurs, causing the background to appear for one frame.
// _vm->_gfx->fadeFromBlack();
}
void Demo::o_fadeToBlack(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Fade to black", op);
_vm->_gfx->fadeToBlack();
}
void Demo::returnToMenu_run() {
uint32 time = _vm->_system->getMillis();
if (time < _returnToMenuNextTime)
return;
switch (_returnToMenuStep){
case 0:
_vm->_gfx->fadeToBlack();
_vm->changeToCard(2003, false);
_vm->_gfx->fadeFromBlack();
_returnToMenuStep++;
break;
case 1:
_vm->_gfx->fadeToBlack();
_vm->changeToCard(2001, false);
_vm->_gfx->fadeFromBlack();
_vm->_cursor->showCursor();
_returnToMenuStep++;
break;
default:
break;
}
}
void Demo::o_returnToMenu_init(uint16 op, uint16 var, uint16 argc, uint16 *argv) {
debugC(kDebugScript, "Opcode %d: Return to menu init", op);
// Used on Card 2001, 2002 and 2003
_returnToMenuNextTime = _vm->_system->getMillis() + 5000;
_returnToMenuRunning = true;
}
} // End of namespace MystStacks
} // End of namespace Mohawk
|