ScummVM API documentation
script.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef SCRIPT_H_
23#define SCRIPT_H_
24
25#include "common/array.h"
26
27namespace Myst3 {
28
29class Myst3Engine;
30class Puzzles;
31struct Opcode;
32
33#define DECLARE_OPCODE(x) void x(Context &c, const Opcode &cmd)
34
35class Script {
36public:
38 virtual ~Script();
39
40 bool run(const Common::Array<Opcode> *script);
41 void runSingleOp(const Opcode &op);
42
43 const Common::String describeOpcode(const Opcode &opcode);
44
45private:
46 struct Context {
47 bool endScript;
48 bool result;
49 const Common::Array<Opcode> *script;
52 };
53
54 typedef void (Script::*CommandProc)(Context &c, const Opcode &cmd);
55
56 enum ArgumentType {
57 kUnknown = 'u',
58 kVar = 'v',
59 kValue = 'i',
60 kEvalValue = 'e',
61 kCondition = 'c'
62 };
63
64 struct Command {
65 Command() : op(0), proc(nullptr), desc(nullptr), signature(nullptr) { }
66 Command(uint16 o, CommandProc p, const char *d, const char *s) : op(o), proc(p), desc(d), signature(s) { }
67
68 uint16 op;
69 CommandProc proc;
70 const char *desc;
71 const char *signature;
72 };
73
74 Myst3Engine *_vm;
75 Puzzles *_puzzles;
76
77 Common::Array<Command> _commands;
78
79 const Command &findCommand(uint16 op);
80 const Command &findCommandByProc(CommandProc proc);
81 const Common::String describeCommand(uint16 op);
82 const Common::String describeArgument(char type, int16 value);
83
84 void shiftCommands(uint16 base, int32 value);
85
86 void runOp(Context &c, const Opcode &op);
87 void goToElse(Context &c);
88
89 void runScriptForVarDrawTicksHelper(uint16 var, int32 startValue, int32 endValue, uint16 script, int32 numTicks);
90
91 DECLARE_OPCODE(badOpcode);
92 DECLARE_OPCODE(uselessOpcode);
93
94 DECLARE_OPCODE(nodeCubeInit);
95 DECLARE_OPCODE(nodeCubeInitIndex);
96 DECLARE_OPCODE(nodeFrameInit);
97 DECLARE_OPCODE(nodeFrameInitCond);
98 DECLARE_OPCODE(nodeFrameInitIndex);
99 DECLARE_OPCODE(nodeMenuInit);
100 DECLARE_OPCODE(stopWholeScript);
101 DECLARE_OPCODE(spotItemAdd);
102 DECLARE_OPCODE(spotItemAddCond);
103 DECLARE_OPCODE(spotItemAddCondFade);
104 DECLARE_OPCODE(spotItemAddMenu);
105 DECLARE_OPCODE(movieInitLooping);
106 DECLARE_OPCODE(movieInitCondLooping);
107 DECLARE_OPCODE(movieInitCond);
108 DECLARE_OPCODE(movieInitPreloadLooping);
109 DECLARE_OPCODE(movieInitCondPreloadLooping);
110 DECLARE_OPCODE(movieInitCondPreload);
111 DECLARE_OPCODE(movieInitFrameVar);
112 DECLARE_OPCODE(movieInitFrameVarPreload);
113 DECLARE_OPCODE(movieInitOverridePosition);
114 DECLARE_OPCODE(movieInitScriptedPosition);
115 DECLARE_OPCODE(movieInitCondScriptedPosition);
116 DECLARE_OPCODE(movieRemove);
117 DECLARE_OPCODE(movieRemoveAll);
118 DECLARE_OPCODE(movieSetLooping);
119 DECLARE_OPCODE(movieSetNotLooping);
120 DECLARE_OPCODE(waterEffectSetSpeed);
121 DECLARE_OPCODE(waterEffectSetAttenuation);
122 DECLARE_OPCODE(waterEffectSetWave);
123 DECLARE_OPCODE(shakeEffectSet);
124 DECLARE_OPCODE(sunspotAdd);
125 DECLARE_OPCODE(sunspotAddIntensity);
126 DECLARE_OPCODE(sunspotAddVarIntensity);
127 DECLARE_OPCODE(sunspotAddIntensityColor);
128 DECLARE_OPCODE(sunspotAddVarIntensityColor);
129 DECLARE_OPCODE(sunspotAddIntensityRadius);
130 DECLARE_OPCODE(sunspotAddVarIntensityRadius);
131 DECLARE_OPCODE(sunspotAddIntColorRadius);
132 DECLARE_OPCODE(sunspotAddVarIntColorRadius);
133 DECLARE_OPCODE(inventoryAddFront);
134 DECLARE_OPCODE(inventoryAddBack);
135 DECLARE_OPCODE(inventoryRemove);
136 DECLARE_OPCODE(inventoryReset);
137 DECLARE_OPCODE(inventoryAddSaavChapter);
138 DECLARE_OPCODE(varSetZero);
139 DECLARE_OPCODE(varSetOne);
140 DECLARE_OPCODE(varSetTwo);
141 DECLARE_OPCODE(varSetOneHundred);
142 DECLARE_OPCODE(varSetValue);
143 DECLARE_OPCODE(varToggle);
144 DECLARE_OPCODE(varSetOneIfNotZero);
145 DECLARE_OPCODE(varOpposite);
146 DECLARE_OPCODE(varAbsolute);
147 DECLARE_OPCODE(varDereference);
148 DECLARE_OPCODE(varReferenceSetZero);
149 DECLARE_OPCODE(varReferenceSetValue);
150 DECLARE_OPCODE(varRandRange);
151 DECLARE_OPCODE(polarToRectSimple);
152 DECLARE_OPCODE(polarToRect);
153 DECLARE_OPCODE(varSetDistanceToZone);
154 DECLARE_OPCODE(varSetMinDistanceToZone);
155 DECLARE_OPCODE(varRemoveBits);
156 DECLARE_OPCODE(varToggleBits);
157 DECLARE_OPCODE(varCopy);
158 DECLARE_OPCODE(varSetBitsFromVar);
159 DECLARE_OPCODE(varSetBits);
160 DECLARE_OPCODE(varApplyMask);
161 DECLARE_OPCODE(varSwap);
162 DECLARE_OPCODE(varIncrement);
163 DECLARE_OPCODE(varIncrementMax);
164 DECLARE_OPCODE(varIncrementMaxLooping);
165 DECLARE_OPCODE(varAddValueMaxLooping);
166 DECLARE_OPCODE(varDecrement);
167 DECLARE_OPCODE(varDecrementMin);
168 DECLARE_OPCODE(varDecrementMinLooping);
169 DECLARE_OPCODE(varAddValueMax);
170 DECLARE_OPCODE(varSubValueMin);
171 DECLARE_OPCODE(varZeroRange);
172 DECLARE_OPCODE(varCopyRange);
173 DECLARE_OPCODE(varSetRange);
174 DECLARE_OPCODE(varIncrementMaxTen);
175 DECLARE_OPCODE(varAddValue);
176 DECLARE_OPCODE(varArrayAddValue);
177 DECLARE_OPCODE(varAddVarValue);
178 DECLARE_OPCODE(varSubValue);
179 DECLARE_OPCODE(varSubVarValue);
180 DECLARE_OPCODE(varModValue);
181 DECLARE_OPCODE(varMultValue);
182 DECLARE_OPCODE(varMultVarValue);
183 DECLARE_OPCODE(varDivValue);
184 DECLARE_OPCODE(varDivVarValue);
185 DECLARE_OPCODE(varCrossMultiplication);
186 DECLARE_OPCODE(varMinValue);
187 DECLARE_OPCODE(varClipValue);
188 DECLARE_OPCODE(varClipChangeBound);
189 DECLARE_OPCODE(varAbsoluteSubValue);
190 DECLARE_OPCODE(varAbsoluteSubVar);
191 DECLARE_OPCODE(varRatioToPercents);
192 DECLARE_OPCODE(varRotateValue3);
193 DECLARE_OPCODE(ifElse);
194 DECLARE_OPCODE(ifCondition);
195 DECLARE_OPCODE(ifCond1AndCond2);
196 DECLARE_OPCODE(ifCond1OrCond2);
197 DECLARE_OPCODE(ifOneVarSetInRange);
198 DECLARE_OPCODE(ifVarEqualsValue);
199 DECLARE_OPCODE(ifVarNotEqualsValue);
200 DECLARE_OPCODE(ifVar1EqualsVar2);
201 DECLARE_OPCODE(ifVar1NotEqualsVar2);
202 DECLARE_OPCODE(ifVarSupEqValue);
203 DECLARE_OPCODE(ifVarInfEqValue);
204 DECLARE_OPCODE(ifVarInRange);
205 DECLARE_OPCODE(ifVarNotInRange);
206 DECLARE_OPCODE(ifVar1SupEqVar2);
207 DECLARE_OPCODE(ifVar1SupVar2);
208 DECLARE_OPCODE(ifVar1InfEqVar2);
209 DECLARE_OPCODE(ifVarHasAllBitsSet);
210 DECLARE_OPCODE(ifVarHasNoBitsSet);
211 DECLARE_OPCODE(ifVarHasSomeBitsSet);
212 DECLARE_OPCODE(ifHeadingInRange);
213 DECLARE_OPCODE(ifPitchInRange);
214 DECLARE_OPCODE(ifHeadingPitchInRect);
215 DECLARE_OPCODE(ifMouseIsInRect);
216 DECLARE_OPCODE(leverDrag);
217 DECLARE_OPCODE(leverDragPositions);
218 DECLARE_OPCODE(leverDragXY);
219 DECLARE_OPCODE(itemDrag);
220 DECLARE_OPCODE(runScriptWhileDragging);
221 DECLARE_OPCODE(chooseNextNode);
222 DECLARE_OPCODE(goToNodeTransition);
223 DECLARE_OPCODE(goToNodeTrans2);
224 DECLARE_OPCODE(goToNodeTrans1);
225 DECLARE_OPCODE(goToRoomNode);
226 DECLARE_OPCODE(zipToNode);
227 DECLARE_OPCODE(zipToRoomNode);
228 DECLARE_OPCODE(drawTransition);
229 DECLARE_OPCODE(reloadNode);
230 DECLARE_OPCODE(redrawFrame);
231 DECLARE_OPCODE(moviePlay);
232 DECLARE_OPCODE(moviePlaySynchronized);
233 DECLARE_OPCODE(moviePlayFullFrame);
234 DECLARE_OPCODE(moviePlayFullFrameTrans);
235 DECLARE_OPCODE(moviePlayChangeNode);
236 DECLARE_OPCODE(moviePlayChangeNodeTrans);
237 DECLARE_OPCODE(lookAt);
238 DECLARE_OPCODE(lookAtInXFrames);
239 DECLARE_OPCODE(lookAtMovieStart);
240 DECLARE_OPCODE(lookAtMovieStartInXFrames);
241 DECLARE_OPCODE(cameraLimitMovement);
242 DECLARE_OPCODE(cameraFreeMovement);
243 DECLARE_OPCODE(cameraLookAt);
244 DECLARE_OPCODE(cameraLookAtVar);
245 DECLARE_OPCODE(cameraGetLookAt);
246 DECLARE_OPCODE(lookAtMovieStartImmediate);
247 DECLARE_OPCODE(cameraSetFOV);
248 DECLARE_OPCODE(changeNode);
249 DECLARE_OPCODE(changeNodeRoom);
250 DECLARE_OPCODE(changeNodeRoomAge);
251
252 DECLARE_OPCODE(drawXTicks);
253 DECLARE_OPCODE(drawWhileCond);
254 DECLARE_OPCODE(whileStart);
255 DECLARE_OPCODE(whileEnd);
256 DECLARE_OPCODE(runScriptWhileCond);
257 DECLARE_OPCODE(runScriptWhileCondEachXFrames);
258 DECLARE_OPCODE(runScriptForVar);
259 DECLARE_OPCODE(runScriptForVarEachXFrames);
260 DECLARE_OPCODE(runScriptForVarStartVar);
261 DECLARE_OPCODE(runScriptForVarStartVarEachXFrames);
262 DECLARE_OPCODE(runScriptForVarEndVar);
263 DECLARE_OPCODE(runScriptForVarEndVarEachXFrames);
264 DECLARE_OPCODE(runScriptForVarStartEndVar);
265 DECLARE_OPCODE(runScriptForVarStartEndVarEachXFrames);
266 DECLARE_OPCODE(drawFramesForVar);
267 DECLARE_OPCODE(drawFramesForVarEachTwoFrames);
268 DECLARE_OPCODE(drawFramesForVarStartEndVarEachTwoFrames);
269 DECLARE_OPCODE(runScript);
270 DECLARE_OPCODE(runScriptWithVar);
271 DECLARE_OPCODE(runCommonScript);
272 DECLARE_OPCODE(runCommonScriptWithVar);
273 DECLARE_OPCODE(runPuzzle1);
274 DECLARE_OPCODE(runPuzzle2);
275 DECLARE_OPCODE(runPuzzle3);
276 DECLARE_OPCODE(runPuzzle4);
277 DECLARE_OPCODE(ambientLoadNode);
278 DECLARE_OPCODE(ambientReloadCurrentNode);
279 DECLARE_OPCODE(ambientPlayCurrentNode);
280 DECLARE_OPCODE(ambientApply);
281 DECLARE_OPCODE(ambientApplyWithFadeDelay);
282 DECLARE_OPCODE(soundPlayBadClick);
283 DECLARE_OPCODE(soundPlayBlocking);
284 DECLARE_OPCODE(soundPlay);
285 DECLARE_OPCODE(soundPlayVolume);
286 DECLARE_OPCODE(soundPlayVolumeDirection);
287 DECLARE_OPCODE(soundPlayVolumeDirectionAtt);
288 DECLARE_OPCODE(soundStopEffect);
289 DECLARE_OPCODE(soundFadeOutEffect);
290 DECLARE_OPCODE(soundPlayLooping);
291 DECLARE_OPCODE(soundPlayFadeInOut);
292 DECLARE_OPCODE(soundChooseNext);
293 DECLARE_OPCODE(soundRandomizeNext);
294 DECLARE_OPCODE(soundChooseNextAfterOther);
295 DECLARE_OPCODE(soundRandomizeNextAfterOther);
296 DECLARE_OPCODE(ambientSetFadeOutDelay);
297 DECLARE_OPCODE(ambientAddSound1);
298 DECLARE_OPCODE(ambientAddSound2);
299 DECLARE_OPCODE(ambientAddSound3);
300 DECLARE_OPCODE(ambientAddSound4);
301 DECLARE_OPCODE(ambientAddSound5);
302 DECLARE_OPCODE(ambientSetCue1);
303 DECLARE_OPCODE(ambientSetCue2);
304 DECLARE_OPCODE(ambientSetCue3);
305 DECLARE_OPCODE(ambientSetCue4);
306 DECLARE_OPCODE(runAmbientScriptNode);
307 DECLARE_OPCODE(runAmbientScriptNodeRoomAge);
308 DECLARE_OPCODE(runSoundScriptNode);
309 DECLARE_OPCODE(runSoundScriptNodeRoom);
310 DECLARE_OPCODE(runSoundScriptNodeRoomAge);
311 DECLARE_OPCODE(soundStopMusic);
312 DECLARE_OPCODE(movieSetStartupSound);
313 DECLARE_OPCODE(movieSetStartupSoundVolume);
314 DECLARE_OPCODE(movieSetStartupSoundVolumeH);
315 DECLARE_OPCODE(drawOneFrame);
316 DECLARE_OPCODE(cursorHide);
317 DECLARE_OPCODE(cursorShow);
318 DECLARE_OPCODE(cursorSet);
319 DECLARE_OPCODE(cursorLock);
320 DECLARE_OPCODE(cursorUnlock);
321 DECLARE_OPCODE(dialogOpen);
322 DECLARE_OPCODE(newGame);
323};
324
325} // End of namespace Myst3
326
327#endif // SCRIPT_H_
Definition: array.h:52
const T * const_iterator
Definition: array.h:55
Definition: str.h:59
Definition: myst3.h:87
Definition: puzzles.h:33
Definition: script.h:35
Definition: hotspot.h:32