ScummVM API documentation
kyra_v2.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 KYRA_KYRA_V2_H
23#define KYRA_KYRA_V2_H
24
25#include "kyra/kyra_v1.h"
26#include "kyra/gui/gui_v1.h"
27#include "kyra/graphics/wsamovie.h"
28#include "kyra/engine/item.h"
29
30#include "common/list.h"
31#include "common/hashmap.h"
32
33namespace Kyra {
34
36 uint16 index;
37 uint16 delay;
38};
39
41 Item itemIndex;
42 uint8 numFrames;
43 const FrameControl *frames;
44};
45
47 uint16 currentFrame;
48 uint32 nextFrameTime;
49};
50
51class Screen_v2;
52
54friend class Debugger_v2;
55friend class GUI_v2;
56public:
57 struct EngineDesc {
58 // Generic shape related
59 int itemShapeStart;
60 const uint8 *characterFrameTable;
61
62 // Scene script
63 int firstAnimSceneScript;
64
65 // Animation script specific
66 int animScriptFrameAdd;
67
68 // Item specific
69 Item maxItemId;
70 };
71
72 KyraEngine_v2(OSystem *system, const GameFlags &flags, const EngineDesc &desc);
73 ~KyraEngine_v2() override;
74
75 void pauseEngineIntern(bool pause) override;
76
77 virtual Screen_v2 *screen_v2() const = 0;
78
79 void delay(uint32 time, bool update = false, bool isMainLoop = false) override;
80
81 const EngineDesc &engineDesc() const { return _desc; }
82protected:
83 EngineDesc _desc;
84
85 // run
86 uint32 _pauseStart;
87 bool _runFlag;
88 bool _showOutro;
89
90 virtual void update() = 0;
91 virtual void updateWithText() = 0;
92
93 // detection
94 int _lang;
95 const int _numLang;
96 int _langIntern;
97 int _scriptLang;
98
99 // Input
100 virtual int inputSceneChange(int x, int y, int unk1, int unk2) = 0;
101
102 // Animator
103 struct AnimObj {
104 uint16 index;
105 uint16 type;
106 bool enabled;
107 uint16 needRefresh;
108 uint16 specialRefresh;
109 uint16 animFlags;
110 uint16 flags;
111 int16 xPos1, yPos1;
112 uint8 *shapePtr;
113 uint16 shapeIndex1;
114 uint16 animNum;
115 uint16 shapeIndex3;
116 uint16 shapeIndex2;
117 int16 xPos2, yPos2;
118 int16 xPos3, yPos3;
119 int16 width, height;
120 int16 width2, height2;
121 uint16 palette;
122 AnimObj *nextObject;
123 };
124
125 void allocAnimObjects(int actors, int anims, int items);
126 AnimObj *_animObjects;
127
128 AnimObj *_animActor;
129 AnimObj *_animAnims;
130 AnimObj *_animItems;
131
132 bool _drawNoShapeFlag;
133 AnimObj *_animList;
134
135 AnimObj *initAnimList(AnimObj *list, AnimObj *entry);
136 AnimObj *addToAnimListSorted(AnimObj *list, AnimObj *entry);
137 AnimObj *deleteAnimListEntry(AnimObj *list, AnimObj *entry);
138
139 virtual void refreshAnimObjects(int force) = 0;
140 void refreshAnimObjectsIfNeed();
141
142 void flagAnimObjsSpecialRefresh();
143 void flagAnimObjsForRefresh();
144
145 virtual void clearAnimObjects() = 0;
146
147 virtual void drawAnimObjects() = 0;
148 virtual void drawSceneAnimObject(AnimObj *obj, int x, int y, int drawLayer) = 0;
149 virtual void drawCharacterAnimObject(AnimObj *obj, int x, int y, int drawLayer) = 0;
150
151 virtual void updateCharacterAnim(int) = 0;
152 virtual void updateSceneAnim(int anim, int newFrame) = 0;
153
154 void addItemToAnimList(int item);
155 void deleteItemAnimEntry(int item);
156
157 virtual void animSetupPaletteEntry(AnimObj *){}
158
159 virtual void setCharacterAnimDim(int w, int h) = 0;
160 virtual void resetCharacterAnimDim() = 0;
161
162 virtual int getScale(int x, int y) = 0;
163
164 uint8 *_screenBuffer;
165
166 // Scene
167 struct SceneDesc {
168 char filename1[10];
169 char filename2[10];
170
171 uint16 exit1, exit2, exit3, exit4;
172 uint8 flags;
173 uint8 sound;
174 };
175
176 SceneDesc *_sceneList;
177 int _sceneListSize;
178 uint16 _currentScene;
179
180 uint16 _sceneExit1, _sceneExit2, _sceneExit3, _sceneExit4;
181 int _sceneEnterX1, _sceneEnterY1, _sceneEnterX2, _sceneEnterY2,
182 _sceneEnterX3, _sceneEnterY3, _sceneEnterX4, _sceneEnterY4;
183 int _specialExitCount;
184 uint16 _specialExitTable[25];
185 bool checkSpecialSceneExit(int num, int x, int y);
186
187 bool _overwriteSceneFacing;
188
189 virtual void enterNewScene(uint16 newScene, int facing, int unk1, int unk2, int unk3) = 0;
190
191 void runSceneScript6();
192
193 EMCData _sceneScriptData;
194 EMCState _sceneScriptState;
195
196 virtual int trySceneChange(int *moveTable, int unk1, int unk2) = 0;
197
198 // Animation
199 virtual void restorePage3() = 0;
200
201 struct SceneAnim {
202 uint16 flags;
203 int16 x, y;
204 int16 x2, y2;
205 int16 width, height;
206 uint16 specialSize;
207 int16 shapeIndex;
208 uint16 wsaFlag;
209 char filename[14];
210 };
211
212 SceneAnim _sceneAnims[16];
213 WSAMovie_v2 *_sceneAnimMovie[16];
214
215 void freeSceneAnims();
216
217 bool _specialSceneScriptState[10];
218 bool _specialSceneScriptStateBackup[10];
219 EMCState _sceneSpecialScripts[10];
220 uint32 _sceneSpecialScriptsTimer[10];
221 int _lastProcessedSceneScript;
222 bool _specialSceneScriptRunFlag;
223
224 void updateSpecialSceneScripts();
225
226 // Sequences
227 EMCData _animationScriptData;
228 EMCState _animationScriptState;
229 Common::Array<const Opcode *> _opcodesAnimation;
230
231 void runAnimationScript(const char *filename, int allowSkip, int resetChar, int newShapes, int shapeUnload);
232
233 int o2a_setAnimationShapes(EMCState *script);
234 int o2a_setResetFrame(EMCState *script);
235
236 char _animShapeFilename[14];
237
238 uint8 *_animShapeFiledata;
239 int _animShapeCount;
240 int _animShapeLastEntry;
241
242 int _animNewFrame;
243 int _animDelayTime;
244
245 int _animResetFrame;
246
247 int _animShapeWidth, _animShapeHeight;
248 int _animShapeXAdd, _animShapeYAdd;
249
250 bool _animNeedUpdate;
251
252 virtual int initAnimationShapes(uint8 *filedata) = 0;
253 void processAnimationScript(int allowSkip, int resetChar);
254 virtual void uninitAnimationShapes(int count, uint8 *filedata) = 0;
255
256 // Shapes
258 ShapeMap _gameShapes;
259
260 uint8 *getShapePtr(int index) const;
261 void addShapeToPool(const uint8 *data, int realIndex, int shape);
262 void addShapeToPool(uint8 *shpData, int index);
263 void remShapeFromPool(int idx);
264
265 int _characterShapeFile;
266 virtual void loadCharacterShapes(int shapes) = 0;
267
268 // pathfinder
269 int _movFacingTable[600];
270 int _pathfinderFlag;
271 bool _smoothingPath;
272
273 int findWay(int curX, int curY, int dstX, int dstY, int *moveTable, int moveTableSize) override;
274
275 bool directLinePassable(int x, int y, int toX, int toY);
276
277 int pathfinderInitPositionTable(int *moveTable);
278 int pathfinderAddToPositionTable(int index, int v1, int v2);
279 int pathfinderInitPositionIndexTable(int tableLen, int x, int y);
280 int pathfinderAddToPositionIndexTable(int index, int v);
281 void pathfinderFinializePath(int *moveTable, int unk1, int x, int y, int moveTableSize);
282
283 int _pathfinderPositionTable[400];
284 int _pathfinderPositionIndexTable[200];
285
286 // items
288 Item id;
289 uint16 sceneId;
290 int16 x;
291 uint8 y;
292 };
293
294 void initItemList(int size);
295
296 Item _hiddenItems[100];
297
298 ItemDefinition *_itemList;
299 int _itemListSize;
300
301 int _itemInHand;
302 int _savedMouseState;
303
304 int findFreeItem();
305 int countAllItems();
306
307 int findItem(uint16 sceneId, Item id);
308 int findItem(Item item);
309
310 void resetItemList();
311 void resetItem(int index);
312
313 virtual void setMouseCursor(Item item) = 0;
314
315 void setHandItem(Item item) override;
316 void removeHandItem() override;
317
318 // character
319 struct Character {
320 uint16 sceneId;
321 int16 dlgIndex;
322 uint8 height;
323 uint8 facing;
324 uint16 animFrame;
325 byte walkspeed;
326 Item inventory[20];
327 int16 x1, y1;
328 int16 x2, y2;
329 int16 x3, y3;
330 };
331
332 Character _mainCharacter;
333 int _mainCharX, _mainCharY;
334 int _charScale;
335
336 void moveCharacter(int facing, int x, int y);
337 int updateCharPos(int *table, int force = 0);
338 void updateCharPosWithUpdate();
339
340 uint32 _updateCharPosNextUpdate;
341
342 virtual int getCharacterWalkspeed() const = 0;
343 virtual void updateCharAnimFrame(int *table) = 0;
344
345 // chat
346 int _vocHigh;
347
348 Common::String _chatText;
349 int _chatObject;
350 uint32 _chatEndTime;
351 int _chatVocHigh, _chatVocLow;
352 bool _chatTextEnabled;
353
354 EMCData _chatScriptData;
355 EMCState _chatScriptState;
356
357 virtual void setDlgIndex(int dlgIndex) = 0;
358
359 virtual void randomSceneChat() = 0;
360
361 // unknown
362 int _unk4, _unk5;
363 bool _unkSceneScreenFlag1;
364 bool _unkHandleSceneChangeFlag;
365
366 // opcodes
367 int o2_getCharacterX(EMCState *script);
368 int o2_getCharacterY(EMCState *script);
369 int o2_getCharacterFacing(EMCState *script);
370 int o2_getCharacterScene(EMCState *script);
371 int o2_setCharacterFacingOverwrite(EMCState *script);
372 int o2_trySceneChange(EMCState *script);
373 int o2_moveCharacter(EMCState *script);
374 int o2_checkForItem(EMCState *script);
375 int o2_defineItem(EMCState *script);
376 int o2_addSpecialExit(EMCState *script);
377 int o2_delay(EMCState *script);
378 int o2_update(EMCState *script);
379 int o2_getShapeFlag1(EMCState *script);
380 int o2_waitForConfirmationClick(EMCState *script);
381 int o2_randomSceneChat(EMCState *script);
382 int o2_setDlgIndex(EMCState *script);
383 int o2_getDlgIndex(EMCState *script);
384 int o2_defineRoomEntrance(EMCState *script);
385 int o2_runAnimationScript(EMCState *script);
386 int o2_setSpecialSceneScriptRunTime(EMCState *script);
387 int o2_defineScene(EMCState *script);
388 int o2_setSpecialSceneScriptState(EMCState *script);
389 int o2_clearSpecialSceneScriptState(EMCState *script);
390 int o2_querySpecialSceneScriptState(EMCState *script);
391 int o2_setHiddenItemsEntry(EMCState *script);
392 int o2_getHiddenItemsEntry(EMCState *script);
393 int o2_disableTimer(EMCState *script);
394 int o2_enableTimer(EMCState *script);
395 int o2_setTimerCountdown(EMCState *script);
396 int o2_setVocHigh(EMCState *script);
397 int o2_getVocHigh(EMCState *script);
398};
399
400} // End of namespace Kyra
401
402#endif
Definition: str.h:59
Definition: debugger.h:68
Definition: gui_v2.h:102
Definition: kyra_v1.h:126
Definition: kyra_v2.h:53
void pauseEngineIntern(bool pause) override
Definition: screen_v2.h:30
Definition: wsamovie.h:112
Definition: system.h:166
Definition: detection.h:27
Definition: kyra_v2.h:46
Definition: script.h:35
Definition: script.h:47
Definition: kyra_v2.h:35
Definition: detection.h:38
Definition: kyra_v2.h:40
Definition: kyra_v2.h:103
Definition: kyra_v2.h:319
Definition: kyra_v2.h:57
Definition: kyra_v2.h:287
Definition: kyra_v2.h:201
Definition: kyra_v2.h:167