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 LILLIPUT_SCRIPT_H
23#define LILLIPUT_SCRIPT_H
24
25#include "common/memstream.h"
26#include "common/stack.h"
27#include "common/random.h"
28#include "common/rect.h"
29
30#include "lilliput/stream.h"
31
32namespace Lilliput {
33
34class LilliputEngine;
35
36enum kActionType {
37 kActionNone = 0,
38 kButtonPressed = 1,
39 kButtonReleased = 2,
40 kActionTalk = 3,
41 kActionGoto = 4,
42 kCubeSelected = 5,
43 kCodeEntered = 6
44};
45
46enum kValueType {
47 kNone,
48 kImmediateValue,
49 kCompareOperation,
50 kComputeOperation,
51 kGetValue1,
52 kgetPosFromScript
53};
54
55struct OpCode {
56 const char* _opName;
57 int _numArgs;
58 kValueType _arg1;
59 kValueType _arg2;
60 kValueType _arg3;
61 kValueType _arg4;
62 kValueType _arg5;
63};
64
66 int _mode;
67 int _priority;
68};
69
71public:
72 byte _heroismLevel;
73 byte _speechTimer;
74
75 byte _characterScriptEnabled[40];
76 int8 _interfaceHotspotStatus[20];
77 Common::Point _characterTilePos[40];
78 int8 _characterNextSequence[40];
79 int8 _characterPose[40];
80 byte _interfaceButtonActivationDelay[20];
81 byte _array122C1[40];
82 byte _characterSeek[40];
83 int16 _interactions[40 * 40];
84
85 byte *_barAttrPtr;
86
87 Common::Point _viewportPos;
88 int16 _viewportCharacterTarget;
89 int16 _talkingCharacter;
90 int _heroismBarX;
91 int _heroismBarBottomY;
92
93 Common::Point _sequenceArr[640];
94 byte _characterMapPixelColor[40];
95 int8 _characterLastSequence[40];
96 EvaluatedMode _newEvaluatedModes[32];
97
100
101 void disasmScript(ScriptStream script);
102 void listAllTexts();
103 static Common::String getArgumentString(kValueType type, ScriptStream& script);
104 void runScript(ScriptStream script);
105 void runMenuScript(ScriptStream script);
106private:
107 LilliputEngine *_vm;
108
109 ScriptStream *_currScript;
111
112 byte _byte16F05_ScriptHandler;
113 byte _cubeSet;
114 byte _lastRandomValue;
115 byte _scriptForVal;
116 byte _textVarNumber;
117 byte _speechDisplaySpeed;
118
119 int16 _word16F00_characterId;
120 int _currentSpeechId;
121 int _word18821;
122 int _monitoredCharacter;
123 Common::Point _word1825E;
124
125 char _monitoredAttr[4];
126
127 int handleOpcode(ScriptStream *script);
128 byte handleOpcodeType1(int curWord);
129 void handleOpcodeType2(int curWord);
130
131 void enableCharacterScript(byte index, byte var1, byte *curBufPtr);
132 void skipOpcodes(int var1);
133 void copySequence(int index, byte *buf);
134 void setSequence(int charIdx, int8 seqIdx);
135 void checkSpeechAllowed(bool &forceReturnFl);
136 void decodePackedText(char *buf);
137 void startSpeech(int var);
138 void displayNumber(byte var1, Common::Point pos);
139 byte *getMapPtr(Common::Point val);
140 byte *getCurrentCharacterVarFromScript();
141 void sendSignal(int16 var1, byte var2h, byte characterId, int16 var4);
142 void getSpeechVariant(int speechIndex, int speechVariant);
143 void showSpeech();
144 void formatSpeechString();
145 Common::Point getCharacterTilePos(int index);
146 int getPackedStringStartRelativeIndex(int index);
147
148 int16 getValue1();
149 Common::Point getPosFromScript();
150
151 byte *getCharacterAttributesPtr();
152 byte compareValues(int16 var1, uint16 oper, int16 var2);
153 void computeOperation(byte *bufPtr, uint16 oper, int16 var2);
154
155 //Opcodes Type 1
156 byte OC_checkCharacterGoalPos();
157 byte OC_comparePos();
158 byte OC_checkIsoMap3();
159 byte OC_compareCharacterVariable();
160 byte OC_CompareLastRandomValue();
161 byte OC_getRandom();
162 byte OC_for();
163 byte OC_compCurrentSpeechId();
164 byte OC_checkSaveFlag();
165 byte OC_compScriptForVal();
166 byte OC_isCarrying();
167 byte OC_CompareCharacterVariables();
168 byte OC_compareCoords_1();
169 byte OC_compareCoords_2();
170 byte OC_CompareDistanceFromCharacterToPositionWith();
171 byte OC_compareRandomCharacterId();
172 byte OC_IsCurrentCharacterIndex();
173 byte OC_hasVisibilityLevel();
174 byte OC_hasGainedVisibilityLevel();
175 byte OC_hasReducedVisibilityLevel();
176 byte OC_isHost();
177 byte OC_isSequenceActive();
178 byte OC_isSequenceFinished();
179 byte OC_CompareMapValueWith();
180 byte OC_IsCharacterValid();
181 byte OC_CheckWaitingSignal();
182 byte OC_CurrentCharacterVar0AndVar1Equals();
183 byte OC_CurrentCharacterVar0Equals();
184 byte OC_checkLastInterfaceHotspotIndexMenu13();
185 byte OC_checkLastInterfaceHotspotIndexMenu2();
186 byte OC_CompareNumberOfCharacterWithVar0Equals();
187 byte OC_IsPositionInViewport();
188 byte OC_CompareGameVariables();
189 byte OC_skipNextOpcode();
190 byte OC_CheckCurrentCharacterAttr2();
191 byte OC_CheckCurrentCharacterType();
192 byte OC_CheckCurrentCharacterAttr0And();
193 byte OC_IsCurrentCharacterAttr0LessEqualThan();
194 byte OC_isCarried();
195 byte OC_CheckCurrentCharacterAttr1();
196 byte OC_isCurrentCharacterSpecial();
197 byte OC_CurrentCharacterAttr3Equals1();
198 byte OC_checkCharacterDirection();
199 byte OC_checkLastInterfaceHotspotIndex();
200 byte OC_checkSelectedCharacter();
201 byte OC_checkDelayedReactivation();
202 byte OC_checkTargetReached();
203 byte OC_checkFunctionKeyPressed();
204 byte OC_checkCodeEntered();
205 byte OC_checkViewPortCharacterTarget();
206
207 // Opcodes Type 2
208 void OC_setWord18821();
209 void OC_ChangeIsoMap();
210 void OC_startSpeech();
211 void OC_getComputedVariantSpeech();
212 void OC_getRotatingVariantSpeech();
213 void OC_startSpeechIfMute();
214 void OC_getComputedVariantSpeechIfMute();
215 void OC_startSpeechIfSilent();
216 void OC_ComputeCharacterVariable();
217 void OC_setAttributeToRandom();
218 void OC_setCharacterPosition();
219 void OC_DisableCharacter();
220 void OC_saveAndQuit();
221 void OC_nSkipOpcodes();
222 void OC_startSpeech5();
223 void OC_resetHandleOpcodeFlag();
224 void OC_deleteSavegameAndQuit();
225 void OC_incScriptForVal();
226 void OC_computeChararacterAttr();
227 void OC_setTextVarNumber();
228 void OC_callScript();
229 void OC_callScriptAndReturn();
230 void OC_setCurrentScriptCharacterPos();
231 void OC_initScriptFor();
232 void OC_setCurrentCharacterSequence();
233 void OC_setNextCharacterSequence();
234 void OC_setHost();
235 void OC_changeMapCube();
236 void OC_setCharacterCarry();
237 void OC_dropCarried();
238 void OC_setCurrentCharacter();
239 void OC_sendSeeSignal();
240 void OC_sendHearSignal();
241 void OC_sendVarSignal();
242 void OC_sendBroadcastSignal();
243 void OC_resetWaitingSignal();
244 void OC_enableCurrentCharacterScript();
245 void OC_IncCurrentCharacterVar1();
246 void OC_setCurrentCharacterPos();
247 void OC_setCurrentCharacterBehavior();
248 void OC_changeCurrentCharacterSprite();
249 void OC_getList();
250 void OC_setList();
251 void OC_setCharacterDirectionTowardsPos();
252 void OC_turnCharacterTowardsAnother();
253 void OC_setSeek();
254 void OC_scrollAwayFromCharacter();
255 void OC_skipNextVal();
256 void OC_setCurrentCharacterAttr6();
257 void OC_setCurrentCharacterPose();
258 void OC_setCharacterScriptEnabled();
259 void OC_setCurrentCharacterAttr2();
260 void OC_clearCurrentCharacterAttr2();
261 void OC_setCharacterProperties();
262 void OC_setMonitoredCharacter();
263 void OC_setNewPose();
264 void OC_setCurrentCharacterDirection();
265 void OC_setInterfaceHotspot();
266 void OC_scrollViewPort();
267 void OC_setViewPortPos();
268 void OC_setCurrentCharacterAltitude();
269 void OC_setModePriority();
270 void setMode(EvaluatedMode newMode);
271 void OC_setComputedModePriority();
272 void OC_selectBestMode();
273 void OC_magicPuffEntrance();
274 void OC_spawnCharacterAtPos();
275 void OC_CharacterVariableAddOrRemoveFlag();
276 void OC_PaletteFadeOut();
277 void OC_PaletteFadeIn();
278 void OC_loadAndDisplayCubesGfx();
279 void OC_setCurrentCharacterAttr3();
280 void OC_setArray122C1();
281 void OC_sub18367();
282 void OC_enableCharacterScript();
283 void OC_setRulesBuffer2Element();
284 void OC_setDebugFlag();
285 void OC_setDebugFlag2();
286 void OC_waitForEvent();
287 void OC_disableInterfaceHotspot();
288 void OC_loadFileAerial();
289 void OC_startSpeechIfSoundOff();
290 void OC_sub1844A();
291 void OC_displayNumericCharacterVariable();
292 void OC_displayVGAFile();
293 void OC_startSpeechWithoutSpeeker();
294 void OC_displayTitleScreen();
295 void OC_initGameAreaDisplay();
296 void OC_displayCharacterStatBar();
297 void OC_initSmallAnim();
298 void OC_setCharacterHeroismBar();
299 void OC_setCharacterHome();
300 void OC_setViewPortCharacterTarget();
301 void OC_showObject();
302 void OC_playObjectSound();
303 void OC_startLocationSound();
304 void OC_stopObjectSound();
305 void OC_stopLocationSound();
306 void OC_toggleSound();
307 void OC_playMusic();
308 void OC_stopMusic();
309 void OC_setCharacterMapColor();
310};
311
312} // End of namespace Lilliput
313
314#endif
315
Definition: stack.h:102
Definition: str.h:59
Definition: lilliput.h:83
Definition: script.h:70
Definition: stream.h:29
Definition: console.h:27
Definition: rect.h:144
Definition: script.h:65
Definition: script.h:55