ScummVM API documentation
scumm_v6.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 SCUMM_SCRIPT_V6_H
23 #define SCUMM_SCRIPT_V6_H
24 
25 #include "scumm/scumm.h"
26 
27 namespace Scumm {
28 
29 class ScummEngine_v6 : public ScummEngine {
30 protected:
31  enum ArrayType {
32  kBitArray = 1,
33  kNibbleArray = 2,
34  kByteArray = 3,
35  kStringArray = 4,
36  kIntArray = 5,
37  kDwordArray = 6
38  };
39 
40  enum SubOpType {
41  SO_AT = 65,
42  SO_COLOR = 66,
43  SO_CLIPPED = 67,
44  SO_CENTER = 69,
45 
46  SO_LEFT = 71,
47  SO_OVERHEAD = 72,
48 
49  SO_MUMBLE = 74,
50  SO_TEXTSTRING = 75,
51  SO_COSTUME = 76,
52  SO_STEP_DIST = 77,
53  SO_SOUND = 78,
54  SO_WALK_ANIMATION = 79,
55  SO_TALK_ANIMATION = 80,
56  SO_STAND_ANIMATION = 81,
57  SO_ANIMATION = 82,
58  SO_DEFAULT = 83,
59  SO_ELEVATION = 84,
60  SO_ANIMATION_DEFAULT = 85,
61  SO_PALETTE = 86,
62  SO_TALK_COLOR = 87,
63  SO_ACTOR_NAME = 88,
64  SO_INIT_ANIMATION = 89,
65 
66  SO_ACTOR_WIDTH = 91,
67  SO_SCALE = 92,
68  SO_NEVER_ZCLIP = 93,
69  SO_ALWAYS_ZCLIP = 94,
70  SO_IGNORE_BOXES = 95,
71  SO_FOLLOW_BOXES = 96,
72  SO_ANIMATION_SPEED = 97,
73  SO_SHADOW = 98,
74  SO_TEXT_OFFSET = 99,
75 
76  SO_LOAD_SCRIPT = 100,
77  SO_LOAD_SOUND = 101,
78  SO_LOAD_COSTUME = 102,
79  SO_LOAD_ROOM = 103,
80  SO_NUKE_SCRIPT = 104,
81  SO_NUKE_SOUND = 105,
82  SO_NUKE_COSTUME = 106,
83  SO_NUKE_ROOM = 107,
84  SO_LOCK_SCRIPT = 108,
85  SO_LOCK_SOUND = 109,
86  SO_LOCK_COSTUME = 110,
87  SO_LOCK_ROOM = 111,
88  SO_UNLOCK_SCRIPT = 112,
89  SO_UNLOCK_SOUND = 113,
90  SO_UNLOCK_COSTUME = 114,
91  SO_UNLOCK_ROOM = 115,
92  SO_CLEAR_HEAP = 116,
93  SO_LOAD_CHARSET = 117,
94  SO_NUKE_CHARSET = 118,
95  SO_LOAD_OBJECT = 119,
96 
97  SO_VERB_IMAGE = 124,
98  SO_VERB_NAME = 125,
99  SO_VERB_COLOR = 126,
100  SO_VERB_HICOLOR = 127,
101  SO_VERB_AT = 128,
102  SO_VERB_ON = 129,
103  SO_VERB_OFF = 130,
104  SO_VERB_DELETE = 131,
105  SO_VERB_NEW = 132,
106  SO_VERB_DIMCOLOR = 133,
107  SO_VERB_DIM = 134,
108  SO_VERB_KEY = 135,
109  SO_VERB_CENTER = 136,
110  SO_VERB_NAME_STR = 137,
111 
112  SO_VERB_IMAGE_IN_ROOM = 139,
113  SO_VERB_BAKCOLOR = 140,
114  SO_SAVE_VERBS = 141,
115  SO_RESTORE_VERBS = 142,
116  SO_DELETE_VERBS = 143,
117  SO_CURSOR_ON = 144,
118  SO_CURSOR_OFF = 145,
119  SO_USERPUT_ON = 146,
120  SO_USERPUT_OFF = 147,
121  SO_CURSOR_SOFT_ON = 148,
122  SO_CURSOR_SOFT_OFF = 149,
123  SO_USERPUT_SOFT_ON = 150,
124  SO_USERPUT_SOFT_OFF = 151,
125 
126  SO_CURSOR_IMAGE = 153,
127  SO_CURSOR_HOTSPOT = 154,
128 
129  SO_CHARSET_SET = 156,
130  SO_CHARSET_COLOR = 157,
131  SO_RESTART = 158,
132  SO_PAUSE = 159,
133  SO_QUIT = 160,
134 
135  SO_WAIT_FOR_ACTOR = 168,
136  SO_WAIT_FOR_MESSAGE = 169,
137  SO_WAIT_FOR_CAMERA = 170,
138  SO_WAIT_FOR_SENTENCE = 171,
139  SO_ROOM_SCROLL = 172,
140  SO_ROOM_SCREEN = 174,
141  SO_ROOM_PALETTE = 175,
142  SO_ROOM_SHAKE_ON = 176,
143  SO_ROOM_SHAKE_OFF = 177,
144  SO_ROOM_INTENSITY = 179,
145  SO_ROOM_SAVEGAME = 180,
146  SO_ROOM_FADE = 181,
147  SO_RGB_ROOM_INTENSITY = 182,
148  SO_ROOM_SHADOW = 183,
149  SO_SAVE_STRING = 184,
150  SO_LOAD_STRING = 185,
151  SO_ROOM_TRANSFORM = 186,
152  SO_CYCLE_SPEED = 187,
153 
154  SO_VERB_INIT = 196,
155  SO_ACTOR_INIT = 197,
156  SO_ACTOR_VARIABLE = 198,
157  SO_INT_ARRAY = 199,
158  SO_BIT_ARRAY = 200,
159  SO_NIBBLE_ARRAY = 201,
160  SO_BYTE_ARRAY = 202,
161  SO_STRING_ARRAY = 203,
162  SO_UNDIM_ARRAY = 204,
163  SO_ASSIGN_STRING = 205,
164 
165  SO_ASSIGN_INT_LIST = 208,
166 
167  SO_ASSIGN_2DIM_LIST = 212,
168  SO_ROOM_NEW_PALETTE = 213,
169  SO_CURSOR_TRANSPARENT = 214,
170  SO_ACTOR_IGNORE_TURNS_ON = 215,
171  SO_ACTOR_IGNORE_TURNS_OFF = 216,
172  SO_NEW = 217,
173 
174  SO_ALWAYS_ZCLIP_FT_DEMO = 225,
175  SO_WAIT_FOR_ANIMATION = 226,
176  SO_ACTOR_DEPTH = 227,
177  SO_ACTOR_WALK_SCRIPT = 228,
178  SO_ACTOR_STOP = 229,
179 
180  SO_ACTOR_FACE = 230,
181  SO_ACTOR_TURN = 231,
182  SO_WAIT_FOR_TURN = 232,
183  SO_ACTOR_WALK_PAUSE = 233,
184  SO_ACTOR_WALK_RESUME = 234,
185  SO_ACTOR_TALK_SCRIPT = 235,
186 
187  SO_BASEOP = 254,
188  SO_END = 255,
189  };
190 
191 #include "common/pack-start.h" // START STRUCT PACKING
192 
193  struct ArrayHeader {
194  int16 dim1;
195  int16 type;
196  int16 dim2;
197  byte data[1];
198  } PACKED_STRUCT;
199 
200 #include "common/pack-end.h" // END STRUCT PACKING
201 
202  struct TextObject {
203  int16 xpos, ypos;
204  byte color;
205  byte charset;
206  byte text[512];
207 
208  void clear() {
209  xpos = 0;
210  ypos = 0;
211  color = 0;
212  charset = 0;
213  for (uint i = 0; i < ARRAYSIZE(text); i++) text[i] = 0;
214  }
215  };
216 
218  struct BlastObject {
219  uint16 number;
220  Common::Rect rect;
221  uint16 scaleX, scaleY;
222  uint16 image;
223  uint16 mode;
224 
225  void clear() {
226  number = 0;
227  rect = Common::Rect();
228  scaleX = 0;
229  scaleY = 0;
230  image = 0;
231  mode = 0;
232  }
233  };
234 
235  int _blastObjectQueuePos;
236  int _blastObjectRectsQueue = 0;
237  BlastObject _blastObjectQueue[200];
238  Common::Rect _blastObjectsRectsToBeRestored[200];
239 
240  // Akos Class
241  struct {
242  int16 cmd;
243  int16 actor;
244  int16 param1;
245  int16 param2;
246  } _akosQueue[32];
247  int16 _akosQueuePos;
248 
249  byte _curActor;
250  int _curVerb;
251  int _curVerbSlot;
252 
253  bool _forcedWaitForMessage;
254  bool _skipVideo;
255 
256 public:
257  ScummEngine_v6(OSystem *syst, const DetectorResult &dr);
258 
259  void resetScumm() override;
260 
261 protected:
262  void setupOpcodes() override;
263 
264  void scummLoop_handleSaveLoad() override;
265  void scummLoop_handleActors() override;
266  void processKeyboard(Common::KeyState lastKeyHit) override;
267 
268  void setupScummVars() override;
269  virtual void decodeParseString(int a, int b);
270  void readArrayFromIndexFile() override;
271 
272  byte *getStringAddress(ResId idx) override;
273  void readMAXS(int blockSize) override;
274 
275  void palManipulateInit(int resID, int start, int end, int time) override;
276  void drawDirtyScreenParts() override;
277 
278  int getStackList(int *args, uint maxnum);
279  int popRoomAndObj(int *room);
280 
281  ArrayHeader *getArray(int array);
282  byte *defineArray(int array, int type, int dim2, int dim1);
283  int findFreeArrayId();
284 public: // FIXME. TODO
285  void nukeArray(int array);
286  void removeBlastObjects();
287  void restoreBlastObjectsRects();
288 
289 protected:
290  virtual int readArray(int array, int index, int base);
291  virtual void writeArray(int array, int index, int base, int value);
292  void shuffleArray(int num, int minIdx, int maxIdx);
293 
294  void setDefaultCursor() override;
295  void setCursorTransparency(int a) override;
296  void setCursorHotspot(int x, int y) override;
297 
298  virtual void setCursorFromImg(uint img, uint room, uint imgindex);
299  void useIm01Cursor(const byte *im, int w, int h);
300  void useBompCursor(const byte *im, int w, int h);
301  void grabCursor(int x, int y, int w, int h);
302  void setCursorFromBuffer(const byte *ptr, int width, int height, int pitch, bool preventScale = false) override;
303  void ditherCursor();
304 
305  virtual void drawBlastTexts() {}
306  virtual void removeBlastTexts() {}
307 
308  void enqueueObject(int objectNumber, int objectX, int objectY, int objectWidth,
309  int objectHeight, int scaleX, int scaleY, int image, int mode);
310  void drawBlastObjects();
311  void drawBlastObject(BlastObject *eo);
312 
313  void restoreBlastObjectRect(Common::Rect r);
314 
315  void clearDrawQueues() override;
316 
317  int getBannerColor(int bannerId) override;
318  const char *getGUIString(int stringId) override;
319  void setSkipVideo(int value) override { _skipVideo = value; }
320  void setUpMainMenuControls() override;
321 
322 public:
323  bool akos_increaseAnims(const byte *akos, Actor *a);
324  bool akos_increaseAnim(Actor *a, int i, const byte *aksq, const uint16 *akfo, int numakfo);
325 protected:
326  void akos_queCommand(byte cmd, Actor *a, int param_1, int param_2);
327  virtual void akos_processQueue();
328 
329  void processActors() override;
330 
331  int getSpecialBox(int x, int y);
332 
333  int getDistanceBetween(bool is_obj_1, int b, int c, bool is_obj_2, int e, int f);
334 
335  /* Version 6 script opcodes */
336  void o6_setBlastObjectWindow();
337  void o6_pushByte();
338  void o6_pushWord();
339  void o6_pushByteVar();
340  void o6_pushWordVar();
341  void o6_byteArrayRead();
342  void o6_wordArrayRead();
343  void o6_byteArrayIndexedRead();
344  void o6_wordArrayIndexedRead();
345  void o6_dup();
346  void o6_pop();
347  void o6_not();
348  void o6_eq();
349  void o6_neq();
350  void o6_gt();
351  void o6_lt();
352  void o6_le();
353  void o6_ge();
354  void o6_add();
355  void o6_sub();
356  void o6_mul();
357  void o6_div();
358  void o6_land();
359  void o6_lor();
360  void o6_writeByteVar();
361  void o6_writeWordVar();
362  void o6_byteArrayWrite();
363  void o6_wordArrayWrite();
364  void o6_byteArrayIndexedWrite();
365  void o6_wordArrayIndexedWrite();
366  void o6_byteVarInc();
367  void o6_wordVarInc();
368  void o6_byteArrayInc();
369  void o6_wordArrayInc();
370  void o6_byteVarDec();
371  void o6_wordVarDec();
372  void o6_byteArrayDec();
373  void o6_wordArrayDec();
374  void o6_if();
375  void o6_ifNot();
376  void o6_jump();
377  void o6_startScript();
378  void o6_startScriptQuick();
379  void o6_startObject();
380  void o6_drawObject();
381  void o6_drawObjectAt();
382  void o6_stopObjectCode();
383  void o6_endCutscene();
384  void o6_cutscene();
385  void o6_stopMusic();
386  void o6_freezeUnfreeze();
387  void o6_cursorCommand();
388  void o6_breakHere();
389  void o6_ifClassOfIs();
390  void o6_setClass();
391  void o6_getState();
392  void o6_setState();
393  void o6_setOwner();
394  void o6_getOwner();
395  void o6_startSound();
396  void o6_stopSound();
397  void o6_startMusic();
398  void o6_stopObjectScript();
399  void o6_panCameraTo();
400  void o6_actorFollowCamera();
401  void o6_setCameraAt();
402  void o6_loadRoom();
403  void o6_stopScript();
404  void o6_walkActorToObj();
405  void o6_walkActorTo();
406  void o6_putActorAtXY();
407  void o6_putActorAtObject();
408  void o6_faceActor();
409  void o6_animateActor();
410  void o6_doSentence();
411  void o6_pickupObject();
412  void o6_loadRoomWithEgo();
413  void o6_getRandomNumber();
414  void o6_getRandomNumberRange();
415  void o6_getActorMoving();
416  void o6_isScriptRunning();
417  void o6_getActorRoom();
418  void o6_getObjectX();
419  void o6_getObjectY();
420  void o6_getObjectOldDir();
421  void o6_getObjectNewDir();
422  void o6_getActorWalkBox();
423  void o6_getActorCostume();
424  void o6_findInventory();
425  void o6_getInventoryCount();
426  void o6_getVerbFromXY();
427  void o6_beginOverride();
428  void o6_endOverride();
429  void o6_setObjectName();
430  void o6_isSoundRunning();
431  void o6_setBoxFlags();
432  void o6_createBoxMatrix();
433  void o6_resourceRoutines();
434  void o6_roomOps();
435  void o6_actorOps();
436  void o6_verbOps();
437  void o6_getActorFromXY();
438  void o6_findObject();
439  void o6_pseudoRoom();
440  void o6_getActorElevation();
441  void o6_getVerbEntrypoint();
442  void o6_arrayOps();
443  void o6_saveRestoreVerbs();
444  void o6_drawBox();
445  void o6_getActorWidth();
446  void o6_wait();
447  void o6_getActorScaleX();
448  void o6_getActorAnimCounter();
449  void o6_soundKludge();
450  void o6_isAnyOf();
451  void o6_systemOps();
452  void o6_isActorInBox();
453  void o6_delay();
454  void o6_delaySeconds();
455  void o6_delayMinutes();
456  void o6_stopSentence();
457  void o6_printLine();
458  void o6_printText();
459  void o6_printDebug();
460  void o6_printSystem();
461  void o6_printActor();
462  void o6_printEgo();
463  void o6_talkActor();
464  void o6_talkEgo();
465  void o6_dimArray();
466  void o6_dummy();
467  void o6_startObjectQuick();
468  void o6_startScriptQuick2();
469  void o6_dim2dimArray();
470  void o6_abs();
471  void o6_distObjectObject();
472  void o6_distObjectPt();
473  void o6_distPtPt();
474  virtual void o6_kernelSetFunctions();
475  void o6_delayFrames();
476  void o6_pickOneOf();
477  void o6_pickOneOfDefault();
478  void o6_jumpToScript();
479  void o6_isRoomScriptRunning();
480  void o6_kernelGetFunctions();
481  void o6_getAnimateVariable();
482  void o6_drawBlastObject();
483  void o6_getActorLayer();
484  void o6_stampObject();
485  void o6_bor();
486  void o6_band();
487  void o6_stopTalking();
488  void o6_findAllObjects();
489  void o6_pickVarRandom();
490  void o6_getDateTime();
491  void o6_getPixel();
492  void o6_setBoxSet();
493  void o6_shuffle();
494 
495  byte VAR_VIDEONAME;
496  byte VAR_RANDOM_NR;
497  byte VAR_STRING2DRAW;
498 
499  byte VAR_TIMEDATE_YEAR;
500  byte VAR_TIMEDATE_MONTH;
501  byte VAR_TIMEDATE_DAY;
502  byte VAR_TIMEDATE_HOUR;
503  byte VAR_TIMEDATE_MINUTE;
504  byte VAR_TIMEDATE_SECOND;
505 };
506 
507 
508 } // End of namespace Scumm
509 
510 #endif
#define ARRAYSIZE(x)
Definition: util.h:91
Definition: scumm_v6.h:193
Definition: rect.h:144
Definition: scumm.h:518
Definition: scumm_v6.h:202
Definition: actor.h:97
Definition: keyboard.h:294
Definition: scumm_v6.h:29
Definition: system.h:161
Definition: actor.h:30
Definition: scumm_v6.h:218
Definition: detection.h:131