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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/* 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_H
#define MYST_SCRIPTS_H
#include "common/ptr.h"
#include "common/scummsys.h"
#include "common/util.h"
namespace Mohawk {
#define DECLARE_OPCODE(x) void x(uint16 op, uint16 var, uint16 argc, uint16 *argv)
class MohawkEngine_Myst;
class MystResource;
enum MystScriptType {
kMystScriptNone,
kMystScriptNormal,
kMystScriptInit,
kMystScriptExit
};
struct MystScriptEntry {
MystScriptEntry();
~MystScriptEntry();
MystScriptType type;
uint16 u0;
uint16 opcode;
uint16 var;
uint16 argc;
uint16 *argv;
uint16 u1;
};
typedef Common::SharedPtr<Common::Array<MystScriptEntry> > MystScript;
class MystScriptParser {
public:
MystScriptParser(MohawkEngine_Myst *vm);
virtual ~MystScriptParser();
void runScript(MystScript script, MystResource *invokingResource = NULL);
void runOpcode(uint16 op, uint16 var = 0, uint16 argc = 0, uint16 *argv = NULL);
const char *getOpcodeDesc(uint16 op);
MystScript readScript(Common::SeekableReadStream *stream, MystScriptType type);
virtual void disableInitOpcodes() = 0;
virtual void runPersistentOpcodes() = 0;
virtual uint16 getVar(uint16 var);
virtual void toggleVar(uint16 var);
virtual bool setVarValue(uint16 var, uint16 value);
DECLARE_OPCODE(unknown);
DECLARE_OPCODE(o_0_toggleVar);
DECLARE_OPCODE(o_1_setVar);
DECLARE_OPCODE(o_2_changeCardSwitch);
DECLARE_OPCODE(takePage);
DECLARE_OPCODE(opcode_4);
DECLARE_OPCODE(o_6_changeCard);
DECLARE_OPCODE(opcode_9);
DECLARE_OPCODE(o_10_toggleVarNoRedraw);
DECLARE_OPCODE(o_14_drawAreaState);
DECLARE_OPCODE(o_15_redrawAreaForVar);
DECLARE_OPCODE(opcode_16);
DECLARE_OPCODE(o_17_changeCardPush);
DECLARE_OPCODE(o_18_changeCardPop);
DECLARE_OPCODE(o_19_enableAreas);
DECLARE_OPCODE(o_20_disableAreas);
DECLARE_OPCODE(opcode_21);
DECLARE_OPCODE(o_23_toggleAreasActivation);
DECLARE_OPCODE(playSound);
DECLARE_OPCODE(opcode_26);
DECLARE_OPCODE(playSoundBlocking);
DECLARE_OPCODE(opcode_28);
DECLARE_OPCODE(opcode_29_33);
DECLARE_OPCODE(opcode_30);
DECLARE_OPCODE(opcode_31);
DECLARE_OPCODE(opcode_32);
DECLARE_OPCODE(opcode_34);
DECLARE_OPCODE(opcode_35);
DECLARE_OPCODE(changeCursor);
DECLARE_OPCODE(hideCursor);
DECLARE_OPCODE(showCursor);
DECLARE_OPCODE(opcode_39);
DECLARE_OPCODE(changeStack);
DECLARE_OPCODE(opcode_41);
DECLARE_OPCODE(opcode_42);
DECLARE_OPCODE(opcode_43);
DECLARE_OPCODE(opcode_44);
DECLARE_OPCODE(opcode_46);
DECLARE_OPCODE(NOP);
protected:
MohawkEngine_Myst *_vm;
typedef void (MystScriptParser::*OpcodeProcMyst)(uint16 op, uint16 var, uint16 argc, uint16* argv);
struct MystOpcode {
uint16 op;
OpcodeProcMyst proc;
const char *desc;
};
const MystOpcode *_opcodes;
void setupOpcodes();
MystResource *_invokingResource;
uint16 _opcodeCount;
static const uint8 stack_map[];
static const uint16 start_card[];
void varUnusedCheck(uint16 op, uint16 var);
};
}
#undef DECLARE_OPCODE
#endif
|