ScummVM API documentation
intern_he.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_HE_INTERN_HE_H
23 #define SCUMM_HE_INTERN_HE_H
24 
25 #include "scumm/scumm_v6.h"
26 #ifdef ENABLE_HE
27 #include "scumm/he/wiz_he.h"
28 #endif
29 #include "scumm/actor_he.h" // For HEEraseAuxEntry & HEAnimAuxEntry
30 
31 namespace Common {
32 class SeekableReadStream;
33 class SeekableWriteStream;
34 }
35 
36 namespace Scumm {
37 
38 #define MAGIC_ARRAY_NUMBER 0x33539000
39 
40 class ActorHE;
41 class ResExtractor;
42 #ifdef ENABLE_HE
43 class LogicHE;
44 class MoviePlayer;
45 class Sprite;
46 class CUP_Player;
47 
48 class Moonbase;
49 class Basketball;
50 #endif
51 
53 #ifdef ENABLE_HE
54  friend class Moonbase;
55  friend class Basketball;
56 #endif
57 protected:
58  enum SubOpType {
59  SO_ACTOR_DEFAULT_CLIPPED = 30,
60  SO_BACKGROUND_ON = 218,
61  SO_BACKGROUND_OFF = 219,
62  SO_ROOM_COPY_PALETTE = 220,
63  SO_ROOM_SAVEGAME_BY_NAME = 221,
64  SO_SOUND_START_VOLUME = 222,
65  SO_SOUND_VOLUME_RAMP = 223,
66  SO_SOUND_FREQUENCY = 224,
67  SO_TALKIE = 225,
68  SO_OBJECT_ORDER = 234,
69  SO_ROOM_PALETTE_IN_ROOM = 236,
70  SO_COLOR_LIST = 249,
71  };
72 
73 public:
74  Common::SeekableReadStream *_hInFileTable[17];
75  Common::SeekableWriteStream *_hOutFileTable[17];
76 
77  Common::Rect _defaultActorClipping; // HE specific
78 
79  int _heTimers[16];
80  uint32 _pauseStartTime = 0;
81 
82  int getHETimer(int timer);
83  void setHETimer(int timer);
84  void pauseHETimers(bool pause);
85 
86 #ifdef ENABLE_HE
87 public:
88  Moonbase *_moonbase;
89  Basketball *_basketball;
90 #endif
91 
92 public:
93  ScummEngine_v60he(OSystem *syst, const DetectorResult &dr);
94  ~ScummEngine_v60he() override;
95 
96  Common::Path generateFilename(const int room) const override;
97  void setActorClippingRect(int actor, int x1, int y1, int x2, int y2);
98  bool actorsOverlapInStrip(int actorA, int actorB, int stripNumber);
99 
100  void resetScumm() override;
101 
102 protected:
103  void setupOpcodes() override;
104 
105  void saveLoadWithSerializer(Common::Serializer &s) override;
106 
107  void localizeArray(int slot, byte scriptSlot);
108  void redimArray(int arrayId, int newX, int newY, int d);
109  int readFileToArray(int slot, int32 size);
110  void writeFileFromArray(int slot, int resID);
111 
112  int virtScreenSave(byte *dst, int x1, int y1, int x2, int y2);
113  void virtScreenLoad(int resIdx, int x1, int y1, int x2, int y2);
114 
115  void decodeParseString(int a, int b) override;
116  void swapObjects(int object1, int object2);
117 
118  Common::Path convertFilePath(const byte *src);
119  Common::String convertSavePath(const byte *src);
120  Common::String convertSavePathOld(const byte *src);
121 
122  Common::SeekableReadStream *openFileForReading(const byte *fileName);
123  Common::SeekableReadStream *openSaveFileForReading(const byte *fileName);
124  Common::SeekableWriteStream *openSaveFileForWriting(const byte *fileName);
125  Common::SeekableWriteStream *openSaveFileForAppending(const byte *fileName);
126  void deleteSaveFile(const byte *fileName);
127  void renameSaveFile(const byte *from, const byte *to);
128  void pauseEngineIntern(bool pause) override;
129 
130  Common::SeekableReadStream *openSaveFileForReading(int slot, bool compat, Common::String &fileName) override;
131  Common::SeekableWriteStream *openSaveFileForWriting(int slot, bool compat, Common::String &fileName) override;
132 
133  /* HE version 60 script opcodes */
134  void o60_setState();
135  void o60_roomOps();
136  void o60_actorOps();
137  void o60_kernelSetFunctions();
138  void o60_kernelGetFunctions();
139  void o60_openFile();
140  void o60_closeFile();
141  void o60_deleteFile();
142  void o60_readFile();
143  void o60_rename();
144  void o60_writeFile();
145  void o60_soundOps();
146  void o60_isSoundRunning();
147  void o60_seekFilePos();
148  void o60_localizeArrayToScript();
149  void o60_redimArray();
150  void o60_readFilePos();
151 };
152 
154  friend class ResExtractor;
155  friend class SoundHE;
156 
157 public:
158  // Used in akos.cpp
159  enum HESndFlags {
160  HE_SND_LOOP = 1,
161  HE_SND_APPEND = 2,
162  HE_SND_SOFT_SOUND = 4,
163  HE_SND_QUICK_START = 8,
164  HE_SND_OFFSET = 16,
165  HE_SND_VOL = 32,
166  HE_SND_FREQUENCY = 64,
167  HE_SND_PAN = 128
168  };
169 
170 
171 protected:
172  enum SubOpType {
173  SO_SOFT = 9,
174  SO_IMAGE_LOADED = 18,
175  SO_VARIABLE = 23,
176  SO_SOUND_VOLUME = 25,
177  SO_NOW = 56,
178  SO_PRELOAD_SCRIPT = 120,
179  SO_PRELOAD_SOUND = 121,
180  SO_PRELOAD_COSTUME = 122,
181  SO_PRELOAD_ROOM = 123,
182  SO_UNLOCK_IMAGE = 159,
183  SO_SOUND_ADD = 164,
184  SO_NUKE_IMAGE = 192,
185  SO_LOAD_IMAGE = 201,
186  SO_LOCK_IMAGE = 202,
187  SO_PRELOAD_IMAGE = 203,
188  SO_ROOM_LOADED = 226,
189  SO_COSTUME_LOADED = 227,
190  SO_SOUND_LOADED = 228,
191  SO_SCRIPT_LOADED = 229,
192  SO_SOUND_CHANNEL = 230,
193  SO_AT = 231,
194  SO_SOUND_START = 232,
195  SO_LOCK_FLOBJECT = 233,
196  SO_UNLOCK_FLOBJECT = 235,
197  SO_PRELOAD_FLUSH = 239,
198  SO_PAUSE_MESSAGE = 240,
199  SO_PAUSE_TITLE = 241,
200  SO_PAUSE_OPTION = 242,
201  SO_TITLE_BAR = 243,
202  SO_QUIT_QUIT = 244,
203  SO_SOUND_LOOPING = 245,
204  SO_START_SYSTEM = 250,
205  SO_START_SYSTEM_STRING = 251,
206  SO_RESTART_STRING = 252,
207  SO_RESTART_ARRAY = 253,
208  };
209 
210  ResExtractor *_resExtractor;
211 
212  byte *_heV7DiskOffsets;
213  byte *_heV7RoomOffsets;
214  uint32 *_heV7RoomIntOffsets;
215 
216  int32 _heSndSoundId, _heSndOffset, _heSndChannel, _heSndFlags,
217  _heSndFrequency, _heSndFrequencyShift, _heSndPan, _heSndVol;
218  bool _heSndStartNewSoundFlag;
219 
220  int _numStoredFlObjects;
221  ObjectData *_storedFlObjects;
222 
223 public:
224  ScummEngine_v70he(OSystem *syst, const DetectorResult &dr);
225  ~ScummEngine_v70he() override;
226 
227  Common::Path generateFilename(const int room) const override;
228 
229  void backgroundToForegroundBlit(Common::Rect rect, int dirtybit = 0);
230  void setActorRedrawFlags() override;
231 
232 protected:
233  void allocateArrays() override;
234  int readResTypeList(ResType type) override;
235  uint32 getResourceRoomOffset(ResType type, ResId idx) override;
236  void setupOpcodes() override;
237 
238  void setupScummVars() override;
239  void resetScummVars() override;
240 
241  void saveLoadWithSerializer(Common::Serializer &s) override;
242 
243  void readRoomsOffsets() override;
244  void readGlobalObjects() override;
245  void readIndexBlock(uint32 blocktype, uint32 itemsize) override;
246 
247  void clearRoomObjects() override;
248  void resetRoomObjects() override;
249 
250  int getActorFromPos(int x, int y) override;
251 
252  void loadFlObject(uint object, uint room) override;
253  void storeFlObject(int slot);
254  void restoreFlObjects();
255 
256  void setCursorFromImg(uint img, uint room, uint imgindex) override;
257  void setDefaultCursor() override;
258 
259  void resetActorBgs() override;
260 
261  /* HE version 70 script opcodes */
262  void o70_soundOps();
263  void o70_pickupObject();
264  void o70_getActorRoom();
265  void o70_resourceRoutines();
266  void o70_systemOps();
267  void o70_getStringLen();
268  void o70_isResourceLoaded();
269  void o70_readINI();
270  void o70_writeINI();
271  void o70_createDirectory();
272  void o70_setSystemMessage();
273 
274  byte VAR_NUM_SOUND_CHANNELS;
275 };
276 
277 #ifdef ENABLE_HE
278 
279 #ifdef USE_ENET
280 class Net;
281 #ifdef USE_LIBCURL
282 class Lobby;
283 #endif
284 #endif
285 
286 class ScummEngine_v71he : public ScummEngine_v70he {
287  friend class Wiz;
288  friend class Gdi;
289 
290 protected:
291  enum SubOpType {
292  SO_SET_POLYGON = 246,
293  SO_DELETE_POLYGON = 247,
294  SO_SET_POLYGON_LOCAL = 248,
295  };
296 
297 public:
298  ScummEngine_v71he(OSystem *syst, const DetectorResult &dr);
299  ~ScummEngine_v71he() override;
300 
301  byte *heFindResourceData(uint32 tag, byte *ptr);
302  byte *heFindResource(uint32 tag, byte *ptr);
303  byte *findWrappedBlock(uint32 tag, byte *ptr, int state, bool flagError);
304 
305  Wiz *_wiz;
306  bool _disableActorDrawingFlag = false;
307 
308  virtual int setupStringArray(int size);
309 
310 protected:
311  void setupOpcodes() override;
312 
313  void saveLoadWithSerializer(Common::Serializer &s) override;
314 
315  void redrawBGAreas() override;
316 
317  void processActors() override;
318  void heFlushAuxEraseQueue();
319  virtual void heFlushAuxQueues();
320 
321  void clearDrawQueues() override;
322 
323  int getStringCharWidth(byte chr);
324  void appendSubstring(int dst, int src, int len2, int len);
325 
326  /* HE version 71 script opcodes */
327  void o71_kernelSetFunctions();
328  void o71_copyString();
329  void o71_getStringWidth();
330  void o71_appendString();
331  void o71_concatString();
332  void o71_compareString();
333  void o71_getStringLenForWidth();
334  void o71_getCharIndexInString();
335  void o71_findBox();
336  void o71_polygonOps();
337  void o71_polygonHit();
338 
339  byte VAR_WIZ_TRANSPARENT_COLOR;
340 public:
341  /* Actor AuxQueue stuff (HE) */
342  HEEraseAuxEntry _heAuxEraseActorTable[16];
343  int _heAuxEraseActorIndex = 0;
344  HEAnimAuxEntry _heAuxAnimTable[16];
345  int _heAuxAnimTableIndex = 0;
346 
347  void heQueueEraseAuxActor(ActorHE *a);
348  void heQueueAnimAuxFrame(int actorNum, int subIndex);
349 
350  void buildRemapTable(byte *remapTablePtr, const byte *palDPtr, const byte *palSPtr);
351 };
352 
353 class ScummEngine_v72he : public ScummEngine_v71he {
354  friend class Wiz;
355 
356 protected:
357  enum SubOpType {
358  SO_NONE = 1,
359  SO_BIT = 2, // SO_INT1
360  SO_NIBBLE = 3, // SO_INT4
361  SO_BYTE = 4, // SO_INT8
362  SO_INT = 5, // SO_INT16
363  SO_DWORD = 6, // SO_INT32
364  SO_STRING = 7,
365  SO_ARRAY = 8,
366  SO_SOUND_SIZE = 13,
367  SO_ROOM_SIZE = 14,
368  SO_IMAGE_SIZE = 15,
369  SO_COSTUME_SIZE = 16,
370  SO_SCRIPT_SIZE = 17,
371  SO_CONDITION = 21,
372  SO_FLUSH_OBJECT_DRAW_QUE = 22,
373  SO_TALK_CONDITION = 24,
374  SO_UPDATE_SCREEN = 26,
375  SO_PRIORITY = 43,
376  SO_AT_IMAGE = 62,
377  SO_IMAGE = 63,
378  SO_ACTOR_DEFAULT_CLIPPED = 64,
379  SO_ERASE = 68,
380  SO_COMPLEX_ARRAY_ASSIGNMENT = 126,
381  SO_COMPLEX_ARRAY_COPY_OPERATION = 127,
382  SO_RANGE_ARRAY_ASSIGNMENT = 128,
383  SO_COMPLEX_ARRAY_MATH_OPERATION = 138,
384  SO_FORMATTED_STRING = 194,
385  SO_REC = 195,
386  SO_BAK = 199,
387  SO_BAKREC = 200,
388  SO_UNDIM_ARRAY = 204,
389  };
390 
391 #include "common/pack-start.h" // START STRUCT PACKING
392 
393  struct ArrayHeader {
394  int32 type;
395  int32 acrossMin;
396  int32 acrossMax;
397  int32 downMin;
398  int32 downMax;
399  byte data[1];
400  } PACKED_STRUCT;
401 
402 #include "common/pack-end.h" // END STRUCT PACKING
403 
404  int _stringLength = 1;
405  byte _stringBuffer[4096];
406 
407  WizImageCommand _wizImageCommand;
408  FloodFillCommand _floodFillCommand;
409 
410 public:
411  ScummEngine_v72he(OSystem *syst, const DetectorResult &dr);
412 
413  void resetScumm() override;
414 
415  byte *getStringAddress(ResId idx) override;
416  int setupStringArray(int size) override;
417  virtual int setupStringArrayFromString(const char *cStr);
418  virtual void getStringFromArray(int arrayNumber, char *buffer, int maxLength);
419 
420 protected:
421  void setupOpcodes() override;
422 
423  void setupScummVars() override;
424  void resetScummVars() override;
425  void readArrayFromIndexFile() override;
426 
427  void readMAXS(int blockSize) override;
428 
429  void redrawBGAreas() override;
430  void checkExecVerbs() override;
431 
432  byte *defineArray(int array, int type, int downMin, int downMax, int acrossMin, int acrossMax, bool newArray = false, int *newid = NULL);
433  int readArray(int array, int idx2, int idx1) override;
434  void writeArray(int array, int idx2, int idx1, int value) override;
435  void redimArray(int arrayId, int newDim2start, int newDim2end,
436  int newDim1start, int newDim1end, int type);
437  void checkArrayLimits(int array, int downMin, int downMax, int acrossMin, int acrossMax);
438  void copyArray(int array1, int a1_dim2start, int a1_dim2end, int a1_dim1start, int a1_dim1end,
439  int array2, int a2_dim2start, int a2_dim2end, int a2_dim1start, int a2_dim1end);
440  void getArrayDataPtrAndDataSize(ArrayHeader *ah, int idx2, int idx1, int len1, byte **data, int *size, int *num);
441  int readFileToArray(int slot, int32 size);
442  void writeFileFromArray(int slot, int32 resID);
443  void arrayBlockOperation(
444  int dstVariable, int dstDownMin, int dstDownMax, int dstAcrossMin, int dstAcrossMax,
445  int a2Variable, int a2DownMin, int a2DownMax, int a2AcrossMin, int a2AcrossMax,
446  int a1Variable, int a1DownMin, int a1DownMax, int a1AcrossMin, int a1AcrossMax,
447  int (*op)(int a2, int a1));
448 
449  void decodeParseString(int a, int b) override;
450  void decodeScriptString(byte *dst, bool scriptString = false);
451  void copyScriptString(byte *dst, int dstSize);
452 
453  int findObject(int x, int y, int num, int *args);
454  int getSoundResourceSize(ResId idx);
455 
456  bool handleNextCharsetCode(Actor *a, int *c) override;
457  int convertMessageToString(const byte *msg, byte *dst, int dstSize) override;
458  void fakeBidiString(byte *ltext, bool ignoreVerb, int ltextSize) const override;
459 
460  void debugInput(byte *string);
461 
462  /* HE version 72 script opcodes */
463  void o72_pushDWord();
464  void o72_getScriptString();
465  void o72_isAnyOf();
466  void o72_resetCutscene();
467  void o72_findObjectWithClassOf();
468  void o72_getObjectImageX();
469  void o72_getObjectImageY();
470  void o72_captureWizImage();
471  void o72_getTimer();
472  void o72_setTimer();
473  void o72_getSoundPosition();
474  void o72_startScript();
475  void o72_startObject();
476  void o72_drawObject();
477  void o72_printWizImage();
478  void o72_getArrayDimSize();
479  void o72_getNumFreeArrays();
480  void o72_roomOps();
481  void o72_actorOps();
482  void o72_verbOps();
483  void o72_findObject();
484  void o72_arrayOps();
485  void o72_systemOps();
486  void o72_talkActor();
487  void o72_talkEgo();
488  void o72_dimArray();
489  void o72_dim2dimArray();
490  void o72_traceStatus();
491  void o72_debugInput();
492  void o72_drawWizImage();
493  void o72_kernelGetFunctions();
494  void o72_jumpToScript();
495  void o72_openFile();
496  void o72_readFile();
497  void o72_writeFile();
498  void o72_findAllObjects();
499  void o72_deleteFile();
500  void o72_rename();
501  void o72_getPixel();
502  void o72_pickVarRandom();
503  void o72_redimArray();
504  void o72_readINI();
505  void o72_writeINI();
506  void o72_getResourceSize();
507  void o72_createDirectory();
508  void o72_setSystemMessage();
509 
510  byte VAR_NUM_ROOMS;
511  byte VAR_NUM_SCRIPTS;
512  byte VAR_NUM_SOUNDS;
513  byte VAR_NUM_COSTUMES;
514  byte VAR_NUM_IMAGES;
515  byte VAR_NUM_CHARSETS;
516 
517  byte VAR_SOUND_ENABLED;
518 
519  byte VAR_POLYGONS_ONLY;
520 
521  byte VAR_MOUSE_STATE; // Used in checkExecVerbs();
522  byte VAR_PLATFORM;
523 };
524 
525 class ScummEngine_v80he : public ScummEngine_v72he {
526 protected:
527  int32 _heSndResId = 0;
528 
529  enum SubOpType {
530  SO_CURSOR_IMAGE = 19,
531  SO_CURSOR_COLOR_IMAGE = 20,
532  SO_ADD = 27,
533  SO_ACTOR = 55,
534  SO_BUTTON = 60,
535  };
536 
537  enum LineType {
538  kLTColor = 1,
539  kLTActor = 2,
540  kLTImage = 3
541  };
542 
543 public:
544  ScummEngine_v80he(OSystem *syst, const DetectorResult &dr);
545 
546 protected:
547  void setupOpcodes() override;
548 
549  void setupScummVars() override;
550  void resetScummVars() override;
551 
552  void parseEvent(Common::Event event) override;
553 
554  void initCharset(int charset) override;
555 
556  void clearDrawQueues() override;
557 
558  void drawLine(int x1, int y1, int x, int unk1, int unk2, int type, int id);
559  void drawPixel(int x, int y, int flags);
560 
561  void setDefaultCursor() override;
562 
563  /* HE version 80 script opcodes */
564  void o80_createSound();
565  void o80_getFileSize();
566  void o80_stringToInt();
567  void o80_getSoundVar();
568  void o80_localizeArrayToRoom();
569  void o80_sourceDebug();
570  void o80_readConfigFile();
571  void o80_writeConfigFile();
572  void o80_cursorCommand();
573  void o80_setState();
574  void o80_drawWizPolygon();
575  void o80_drawLine();
576  void o80_pickVarRandom();
577 
578  byte VAR_PLATFORM_VERSION;
579  byte VAR_CURRENT_CHARSET;
580  byte VAR_KEY_STATE;
581  byte VAR_COLOR_DEPTH;
582 };
583 
584 class ScummEngine_v90he : public ScummEngine_v80he {
585  friend class LogicHE;
586 #ifdef USE_ENET
587  friend class Net;
588 #ifdef USE_LIBCURL
589  friend class Lobby;
590 #endif
591 #endif
592  friend class Moonbase;
593  friend class Basketball;
594  friend class MoviePlayer;
595  friend class Sprite;
596  friend class Wiz;
597  friend class ScummEngine_v99he;
598 
599 protected:
600  enum SubOpType {
601  SO_COORD_2D = 28,
602  SO_COORD_3D = 29,
603  SO_XPOS = 30,
604  SO_YPOS = 31,
605  SO_WIDTH = 32,
606  SO_HEIGHT = 33,
607  SO_STEP_DIST_X = 34,
608  SO_STEP_DIST_Y = 35,
609  SO_COUNT = 36,
610  SO_GROUP = 37,
611  SO_DRAW_XPOS = 38,
612  SO_DRAW_YPOS = 39,
613  SO_PROPERTY = 42,
614  SO_PRIORITY = 43,
615  SO_MOVE = 44,
616  SO_FIND = 45,
617  SO_GENERAL_CLIP_STATE = 46,
618  SO_GENERAL_CLIP_RECT = 47,
619  SO_DRAW = 48,
620  SO_LOAD = 49,
621  SO_SAVE = 50,
622  SO_CAPTURE = 51,
623  SO_STATE = 52,
624  SO_ANGLE = 53,
625  SO_SET_FLAGS = 54,
626  SO_INIT = 57,
627  SO_AT_IMAGE = 62,
628  SO_IMAGE = 63,
629  SO_AT = 65,
630  SO_ERASE = 68,
631  SO_TO = 70,
632  SO_STEP_DIST = 77,
633  SO_ANIMATION = 82,
634  SO_PALETTE = 86,
635  SO_SCALE = 92,
636  SO_ANIMATION_SPEED = 97,
637  SO_SHADOW = 98,
638  SO_UPDATE = 124,
639  SO_CLASS = 125,
640  SO_SORT = 129,
641  SO_HISTOGRAM = 130,
642  SO_POLY_POLYGON = 131,
643  SO_CHANNEL = 132,
644  SO_RENDER_RECTANGLE = 133,
645  SO_RENDER_LINE = 134,
646  SO_RENDER_PIXEL = 135,
647  SO_RENDER_FLOOD_FILL = 136,
648  SO_RENDER_INTO_IMAGE = 137,
649  SO_NEW_GENERAL_PROPERTY = 139,
650  SO_MASK = 140,
651  SO_FONT_START = 141,
652  SO_FONT_CREATE = 142,
653  SO_FONT_RENDER = 143,
654  SO_CLOSE = 165,
655  SO_RENDER_ELLIPSE = 189,
656  SO_FONT_END = 196,
657  SO_ACTOR_VARIABLE = 198
658  };
659 
660  struct VideoParameters {
661  byte filename[260];
662  int32 status;
663  int32 flags;
664  int32 number;
665  int32 wizResNum;
666  };
667 
668  VideoParameters _videoParams;
669 
670  int32 _heObject = 0;
671  int32 _heObjectNum = 0;
672  int32 _hePaletteNum = 0;
673 
674  int32 _maxSpriteNum = 0;
675  int32 _minSpriteNum = 0;
676  int32 _curSpriteGroupId = 0;
677 
678  LogicHE *_logicHE = nullptr;
679  MoviePlayer *_moviePlay;
680  Sprite *_sprite;
681 
682 #ifdef USE_ENET
683 public:
684  Net *_net;
685 #ifdef USE_LIBCURL
686  Lobby *_lobby;
687 #endif
688 #endif
689 
690 public:
691  ScummEngine_v90he(OSystem *syst, const DetectorResult &dr);
692  ~ScummEngine_v90he() override;
693 
694 protected:
695  void allocateArrays() override;
696  void setupOpcodes() override;
697 
698  void resetScumm() override;
699 
700  void setupScummVars() override;
701  void resetScummVars() override;
702 
703  void scummLoop(int delta) override;
704  void scummLoop_handleDrawing() override;
705  void runBootscript() override;
706 
707  void processInput() override;
708  void clearClickedStatus() override;
709 
710  void saveLoadWithSerializer(Common::Serializer &s) override;
711 
712  void readMAXS(int blockSize) override;
713  void setResourceOffHeap(int typeId, int resId, int val);
714 
715  void processActors() override;
716  void heFlushAuxQueues() override;
717  const byte *heAuxFindBlock(HEAnimAuxData *auxInfoPtr, int32 id);
718  void heAuxReleaseAuxDataInfo(HEAnimAuxData *auxInfoPtr);
719  void heAuxGetAuxDataInfo(HEAnimAuxData *auxInfoPtr, int whichActor, int auxIndex);
720  bool heAuxProcessFileRelativeBlock(HEAnimAuxData *auxInfoPtr, const byte *dataBlockPtr);
721  bool heAuxProcessDisplacedBlock(HEAnimAuxData *auxInfoPtr, const byte *displacedBlockPtr);
722 
723  void getArrayDim(int array, int *downMin, int *downMax, int *acrossMin, int *acrossMax);
724  void sortArray(int array, int downMin, int downMax, int acrossMin, int acrossMax, int sortOrder);
725 
726 public:
727  int getGroupSpriteArray(int spriteGroupId);
728 
729 protected:
730  uint8 *getHEPaletteIndex(int palSlot);
731  int getHEPaletteColor(int palSlot, int color);
732  int getHEPaletteSimilarColor(int palSlot, int red, int green, int start, int end);
733  int getHEPalette16BitColorComponent(int component, int type);
734  int getHEPaletteColorComponent(int palSlot, int color, int component);
735  void setHEPaletteColor(int palSlot, uint8 color, uint8 r, uint8 g, uint8 b);
736  void setHEPaletteFromPtr(int palSlot, const uint8 *palData);
737  void setHEPaletteFromCostume(int palSlot, int resId);
738  void setHEPaletteFromImage(int palSlot, int resId, int state);
739  void setHEPaletteFromRoom(int palSlot, int resId, int state);
740  void restoreHEPalette(int palSlot);
741  void copyHEPalette(int dstPalSlot, int srcPalSlot);
742  void copyHEPaletteColor(int palSlot, uint8 dstColor, uint16 srcColor);
743 
744  /*
745  * Math functions
746  *
747  * Please do not attempt to revert these to our standard math functions!
748  * These are accurate for the games, ours aren't :-P
749  */
750  int scummMathSin(int angle);
751  int scummMathCos(int angle);
752  int scummMathSqrt(int value);
753  int scummMathDist2D(int x1, int y1, int x2, int y2);
754  int scummMathAngleFromDelta(int dx, int dy);
755  int scummMathAngleOfLineSegment(int x1, int y1, int x2, int y2);
756 
757 
758 protected:
759  /* HE version 90 script opcodes */
760  void o90_dup_n();
761  void o90_min();
762  void o90_max();
763  void o90_sin();
764  void o90_cos();
765  void o90_sqrt();
766  void o90_getAngleFromDelta();
767  void o90_getAngleFromLine();
768  void o90_getActorData();
769  void o90_priorityStartScript();
770  void o90_priorityChainScript();
771  void o90_videoOps();
772  void o90_getVideoData();
773  void o90_wizImageOps();
774  void o90_getDistanceBetweenPoints();
775  void o90_getSpriteInfo();
776  void o90_setSpriteInfo();
777  void o90_getSpriteGroupInfo();
778  void o90_setSpriteGroupInfo();
779  void o90_getWizData();
780  void o90_floodFill();
781  void o90_mod();
782  void o90_shl();
783  void o90_shr();
784  void o90_xor();
785  void o90_findAllObjectsWithClassOf();
786  void o90_getOverlap();
787  void o90_cond();
788  void o90_dim2dim2Array();
789  void o90_redim2dimArray();
790  void o90_getLinesIntersectionPoint();
791  void o90_sortArray();
792  void o90_getObjectData();
793  void o90_getPaletteData();
794  void o90_paletteOps();
795  void o90_fontEnum();
796  void o90_getActorAnimProgress();
797  void o90_kernelGetFunctions();
798  void o90_kernelSetFunctions();
799 
800  byte VAR_NUM_SPRITE_GROUPS;
801  byte VAR_NUM_SPRITES;
802  byte VAR_NUM_PALETTES;
803  byte VAR_NUM_UNK;
804  byte VAR_SPRITE_IMAGE_CHANGE_DOES_NOT_RESET_SETTINGS;
805 
806  byte VAR_U32_VERSION;
807  byte VAR_U32_ARRAY_UNK;
808 
809 #ifdef USE_ENET
810  byte VAR_REMOTE_START_SCRIPT = 98;
811  byte VAR_NETWORK_AVAILABLE = 109;
812  byte VAR_NETWORK_RECEIVE_ARRAY_SCRIPT = 101;
813 
814 public:
815  int networkSessionDialog();
816 #endif
817 };
818 
819 class ScummEngine_v95he : public ScummEngine_v90he {
820 public:
821  ScummEngine_v95he(OSystem *syst, const DetectorResult &dr) : ScummEngine_v90he(syst, dr) {}
822 
823 protected:
824  void resetActorBgs() override;
825  bool prepareForActorErase();
826 };
827 
828 class ScummEngine_v99he : public ScummEngine_v95he {
829 public:
830  ScummEngine_v99he(OSystem *syst, const DetectorResult &dr) : ScummEngine_v95he(syst, dr) {}
831 
832  void resetScumm() override;
833 
834 protected:
835  void resetScummVars() override;
836 
837  void readMAXS(int blockSize) override;
838 
839  void saveLoadWithSerializer(Common::Serializer &s) override;
840 
841  void copyPalColor(int dst, int src) override;
842  void darkenPalette(int redScale, int greenScale, int blueScale, int startColor, int endColor) override;
843  void setPaletteFromPtr(const byte *ptr, int numcolor = -1) override;
844  void setPalColor(int index, int r, int g, int b) override;
845  void updatePalette() override;
846 };
847 
848 class ScummEngine_v100he : public ScummEngine_v99he {
849 friend class AI;
850 friend class Moonbase;
851 friend class LogicHEBasketball;
852 friend class Basketball;
853 
854 // The following engine versions use sub opcodes from this version
855 friend class ScummEngine_v71he;
856 friend class ScummEngine_v72he;
857 friend class ScummEngine_v90he;
858 friend class ScummEngine_v80he;
859 
860 protected:
861  ResType _heResType;
862  int32 _heResId;
863 
864  byte _debugInputBuffer[256];
865  enum SubOpType {
866  // COMMON
867  SO_INIT = 0,
868  SO_ACTOR = 1,
869  SO_ANGLE = 2,
870  SO_ANIMATION = 3,
871  SO_ANIMATION_SPEED = 4,
872  SO_ARRAY = 5,
873  SO_AT = 6,
874  SO_AT_IMAGE = 7,
875  SO_BACKGROUND_OFF = 8,
876  SO_BACKGROUND_ON = 9,
877  SO_CAPTURE = 11,
878  SO_CENTER = 12,
879  SO_CHANNEL = 13,
880  SO_CHARSET_SET = 14, // SO_CHARSET
881  SO_CHARSET_COLOR = 15,
882  SO_CLASS = 16,
883  SO_CLIPPED = 18,
884  SO_CLOSE = 19,
885  SO_COLOR = 20,
886  SO_COLOR_LIST = 21,
887  SO_CONDITION = 22,
888  SO_COORD_2D = 23,
889  SO_COORD_3D = 24,
890  SO_COSTUME = 25,
891  SO_COUNT = 26,
892  SO_DEFAULT = 27,
893  SO_DELETE_POLYGON = 28,
894  SO_DRAW = 29,
895  SO_DRAW_XPOS = 30,
896  SO_DRAW_YPOS = 31,
897  SO_ERASE = 32,
898  SO_FIND = 33,
899  SO_FLOBJECT = 34,
900  SO_FORMATTED_STRING = 35,
901  SO_GENERAL_CLIP_RECT = 36,
902  SO_GENERAL_CLIP_STATE = 37,
903  SO_GROUP = 38,
904  SO_HEIGHT = 39,
905  SO_IMAGE = 40,
906  SO_BIT = 41, // SO_INT1
907  SO_INT = 42, // SO_INT16
908  SO_DWORD = 43, // SO_INT32
909  SO_NIBBLE = 44, // SO_INT4
910  SO_BYTE = 45, // SO_INT8
911  SO_LEFT = 46,
912  SO_LOAD = 47,
913  SO_MASK = 48,
914  SO_MOVE = 49,
915  SO_MUMBLE = 51,
916  SO_NAME = 52,
917  SO_NEW = 53,
918  SO_NEW_GENERAL_PROPERTY = 54,
919  SO_NOW = 55,
920  SO_OVERHEAD = 56,
921  SO_PALETTE = 57,
922  SO_POLY_TO_POLY = 58,
923  SO_PRIORITY = 59,
924  SO_PROPERTY = 60,
925  SO_RESTART = 61,
926  SO_ROOM = 62,
927  SO_ROOM_PALETTE = 63,
928  SO_SAVE = 64,
929  SO_SCALE = 65,
930  SO_SCRIPT = 66,
931  SO_SET_FLAGS = 67,
932  SO_SET_POLYGON = 68,
933  SO_SET_POLYGON_LOCAL = 69,
934  SO_SHADOW = 70,
935  SO_SOUND = 72,
936  SO_STATE = 73,
937  SO_STEP_DIST = 74,
938  SO_STEP_DIST_X = 75,
939  SO_STEP_DIST_Y = 76,
940  SO_STRING = 77,
941  SO_TALKIE = 78,
942  SO_TEXTSTRING = 79,
943  SO_TITLE_BAR = 80,
944  SO_TO = 81,
945  SO_UPDATE = 82,
946  SO_VARIABLE = 83,
947  SO_WIDTH = 84,
948  SO_XPOS = 85,
949  SO_YPOS = 86,
950  SO_ALWAYS_ZCLIP = 87,
951  SO_IMAGE_ZCLIP = 88,
952  SO_NEVER_ZCLIP = 89,
953  SO_BASEOP = 91,
954  SO_END = 92,
955 
956  // ACTOR
957  SO_ACTOR_DEFAULT_CLIPPED = 128,
958  SO_ACTOR_INIT = 129,
959  SO_ACTOR_SOUNDS = 130,
960  SO_ACTOR_WIDTH = 131,
961  SO_ANIMATION_DEFAULT = 132,
962  SO_ELEVATION = 133,
963  SO_FOLLOW_BOXES = 134,
964  SO_IGNORE_BOXES = 135,
965  SO_ACTOR_IGNORE_TURNS_OFF = 136, // SO_IGNORE_TURNS_OFF
966  SO_ACTOR_IGNORE_TURNS_ON = 137, // SO_IGNORE_TURNS_ON
967  SO_INIT_ANIMATION = 138,
968  SO_STAND_ANIMATION = 139,
969  SO_TALK_ANIMATION = 140,
970  SO_TALK_COLOR = 141,
971  SO_TALK_CONDITION = 142,
972  SO_TEXT_OFFSET = 143,
973  SO_WALK_ANIMATION = 144,
974 
975  // ARRAY
976  SO_ASSIGN_2DIM_LIST = 128,
977  SO_ASSIGN_INT_LIST = 129,
978  SO_COMPLEX_ARRAY_ASSIGNMENT = 130,
979  SO_COMPLEX_ARRAY_COPY_OPERATION = 131,
980  SO_COMPLEX_ARRAY_MATH_OPERATION = 132,
981  SO_RANGE_ARRAY_ASSIGNMENT = 133,
982  SO_SORT = 134,
983  SO_UNDIM_ARRAY = 135,
984 
985  // HEAP
986  SO_CLEAR_HEAP = 128,
987  SO_PRELOAD_FLUSH = 129,
988  SO_LOCK = 132,
989  SO_NUKE = 133,
990  SO_OFF_HEAP = 134,
991  SO_ON_HEAP = 135,
992  SO_PRELOAD = 136,
993  SO_UNLOCK = 137,
994 
995  // IMAGE
996  SO_FONT_CREATE = 128,
997  SO_FONT_END = 129,
998  SO_FONT_RENDER = 130,
999  SO_FONT_START = 131,
1000  SO_HISTOGRAM = 132,
1001  SO_RENDER_ELLIPSE = 133,
1002  SO_RENDER_FLOOD_FILL = 134,
1003  SO_RENDER_INTO_IMAGE = 135,
1004  SO_RENDER_LINE = 136,
1005  SO_RENDER_PIXEL = 137,
1006  SO_RENDER_RECTANGLE = 138,
1007 
1008  // CURSOR
1009  SO_CURSOR_IMAGE = 128,
1010  SO_CURSOR_COLOR_IMAGE = 129,
1011  SO_CURSOR_COLOR_PAL_IMAGE = 130,
1012  SO_CURSOR_HOTSPOT = 132,
1013  SO_CURSOR_ON = 134,
1014  SO_CURSOR_OFF = 135,
1015  SO_CURSOR_SOFT_ON = 136,
1016  SO_CURSOR_SOFT_OFF = 137,
1017  SO_USERPUT_ON = 139,
1018  SO_USERPUT_OFF = 140,
1019  SO_USERPUT_SOFT_ON = 141,
1020  SO_USERPUT_SOFT_OFF = 142,
1021 
1022  // ROOM
1023  SO_OBJECT_ORDER = 129,
1024  SO_ROOM_COPY_PALETTE = 130,
1025  SO_ROOM_FADE = 131,
1026  SO_ROOM_INTENSITY = 132,
1027  SO_ROOM_INTENSITY_RGB = 133,
1028  SO_ROOM_NEW_PALETTE = 134,
1029  SO_ROOM_PALETTE_IN_ROOM = 135,
1030  SO_ROOM_SAVEGAME = 136,
1031  SO_ROOM_SAVEGAME_BY_NAME = 137,
1032  SO_ROOM_SCREEN = 138,
1033  SO_ROOM_SCROLL = 139,
1034  SO_ROOM_SHAKE_OFF = 140,
1035  SO_ROOM_SHAKE_ON = 141,
1036  SO_ROOM_TRANSFORM = 142,
1037 
1038  // SCRIPT
1039  SO_BAK = 128,
1040  SO_BAKREC = 129,
1041  SO_REC = 130,
1042 
1043  // SYSTEM
1044  SO_FLUSH_OBJECT_DRAW_QUEUE = 128,
1045  SO_PAUSE_TITLE = 131,
1046  SO_QUIT = 132,
1047  SO_QUIT_QUIT = 133,
1048  SO_RESTART_STRING = 134,
1049  SO_START_SYSTEM_STRING = 135,
1050  SO_UPDATE_SCREEN = 136,
1051 
1052  // SOUND
1053  SO_SOUND_ADD = 128,
1054  SO_SOUND_CHANNEL = 129,
1055  SO_SOUND_FREQUENCY = 130,
1056  SO_SOUND_LOOPING = 131,
1057  SO_SOUND_MODIFY = 132,
1058  SO_SOUND_PAN = 133,
1059  SO_SOUND_START = 134,
1060  SO_SOUND_SOFT = 135,
1061  SO_SOUND_VOLUME = 136,
1062 
1063  // WAIT
1064  SO_WAIT_FOR_ACTOR = 128,
1065  SO_WAIT_FOR_CAMERA = 129,
1066  SO_WAIT_FOR_MESSAGE = 130,
1067  SO_WAIT_FOR_SENTENCE = 131,
1068  };
1069 
1070 public:
1071  ScummEngine_v100he(OSystem *syst, const DetectorResult &dr);
1072  ~ScummEngine_v100he() override;
1073 
1074  void resetScumm() override;
1075 
1076  void setupScummVars() override;
1077  void resetScummVars() override;
1078 
1079 protected:
1080  void setupOpcodes() override;
1081 
1082  void saveLoadWithSerializer(Common::Serializer &s) override;
1083 
1084  void decodeParseString(int a, int b) override;
1085 
1086  /* HE version 100 script opcodes */
1087  void o100_actorOps();
1088  void o100_arrayOps();
1089  void o100_dim2dimArray();
1090  void o100_redim2dimArray();
1091  void o100_dimArray();
1092  void o100_drawLine();
1093  void o100_drawObject();
1094  void o100_floodFill();
1095  void o100_setSpriteGroupInfo();
1096  void o100_resourceRoutines();
1097  void o100_wizImageOps();
1098  void o100_jumpToScript();
1099  void o100_createSound();
1100  void o100_dim2dim2Array();
1101  void o100_paletteOps();
1102  void o100_priorityChainScript();
1103  void o100_priorityStartScript();
1104  void o100_redimArray();
1105  void o100_roomOps();
1106  void o100_setSystemMessage();
1107  void o100_soundOps();
1108  void o100_setSpriteInfo();
1109  void o100_startScript();
1110  void o100_systemOps();
1111  void o100_cursorCommand();
1112  void o100_videoOps();
1113  void o100_wait();
1114  void o100_writeFile();
1115  void o100_debugInput();
1116  void o100_isResourceLoaded();
1117  void o100_getResourceSize();
1118  void o100_getSpriteGroupInfo();
1119  void o100_getPaletteData();
1120  void o100_readFile();
1121  void o100_getSpriteInfo();
1122  void o100_getWizData();
1123  void o100_getVideoData();
1124 
1125 protected:
1126  byte VAR_U32_USER_VAR_A;
1127  byte VAR_U32_USER_VAR_B;
1128  byte VAR_U32_USER_VAR_C;
1129  byte VAR_U32_USER_VAR_D;
1130  byte VAR_U32_USER_VAR_E;
1131  byte VAR_U32_USER_VAR_F;
1132  byte VAR_U32_USER_VAR_G;
1133  byte VAR_U32_USER_VAR_H;
1134 
1135  byte VAR_REMOTE_START_SCRIPT;
1136  byte VAR_NETWORK_AVAILABLE;
1137  byte VAR_NETWORK_RECEIVE_ARRAY_SCRIPT;
1138 
1139 public:
1140  bool mapGeneratorDialog(bool demo);
1141 };
1142 
1143 class ScummEngine_vCUPhe : public Engine {
1144 protected:
1145  CUP_Player *_cupPlayer;
1146  FilenamePattern _filenamePattern;
1147 
1148 public:
1149  ScummEngine_vCUPhe(OSystem *syst, const DetectorResult &dr);
1150  ~ScummEngine_vCUPhe() override;
1151 
1152  Common::Error run() override;
1153 
1154  void parseEvents();
1155 
1156  OSystem *_syst;
1157 
1158  GameSettings _game;
1159 };
1160 
1161 #endif
1162 
1163 
1164 } // End of namespace Scumm
1165 
1166 #endif
Definition: str.h:59
Definition: error.h:84
Definition: actor_he.h:38
Definition: scumm_v6.h:193
Definition: detection.h:117
Definition: ai_main.h:85
Definition: net_main.h:33
Definition: sound_he.h:147
Definition: rect.h:144
Definition: path.h:52
ResType
Definition: scumm.h:256
Definition: stream.h:745
Definition: serializer.h:79
Definition: net_lobby.h:85
Definition: intern_he.h:52
Definition: intern_he.h:153
Definition: actor_he.h:48
Definition: actor_he.h:64
Definition: detection.h:44
Definition: actor_he.h:43
Definition: object.h:64
Definition: events.h:199
Definition: algorithm.h:29
Definition: actor.h:97
Definition: resource_he.h:35
Definition: gfx.h:292
Definition: stream.h:351
Definition: scumm_v6.h:29
Definition: system.h:161
Definition: engine.h:144
Definition: actor.h:30
Definition: detection.h:131