ScummVM API documentation
mult.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  * This file is dual-licensed.
22  * In addition to the GPLv3 license mentioned above, this code is also
23  * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24  * full text of the license.
25  *
26  */
27 
28 #ifndef GOB_MULT_H
29 #define GOB_MULT_H
30 
31 #include "gob/videoplayer.h"
32 #include "gob/video.h"
33 #include "gob/variables.h"
34 
35 namespace Gob {
36 
37 class Mult {
38 public:
39 
40 #include "common/pack-start.h" // START STRUCT PACKING
41 
42  struct Mult_AnimData {
43  int8 animation;
44  uint8 layer;
45  uint8 frame;
46  int8 animType;
47  int8 order;
48  int8 isPaused;
49  int8 isStatic;
50  int8 maxTick;
51  int8 maxFrame;
52  uint8 newLayer;
53  int8 newAnimation;
54  byte intersected;
55  uint8 newCycle;
56  int8 state;
57  int8 nextState;
58  int8 newState;
59  int8 curLookDir;
60  int8 isBusy;
61  int8 pathExistence;
62  int8 destX;
63  int8 destY;
64  int8 framesLeft;
65  int8 stateType;
66  int8 animTypeBak;
67  int8 redrawAnimation;
68  uint8 redrawLayer;
69  uint8 redrawFrame;
70  uint8 destXBak;
71  uint8 destYBak;
72  int8 gobDestX_maybe;
73  uint8 gobDestY_maybe;
74  uint8 field_1F;
75  uint8 field_20;
76  uint8 field_21;
77  uint8 field_22;
78  } PACKED_STRUCT;
79 
80  struct Mult_GobState {
81  int16 animation; // .
82  int16 layer; // |- [0]
83  int16 dataCount; // '
84  int8 sndItem; // .
85  uint8 sndFrame; // |
86  int16 freq; // |- [1+]
87  int8 repCount; // |
88  uint8 speaker; // '
89  } PACKED_STRUCT;
90 
91  struct Mult_Object {
92  VariableReference *pPosX;
93  VariableReference *pPosY;
94  Mult_AnimData *pAnimData;
95  int16 tick;
96  int16 lastLeft;
97  int16 lastRight;
98  int16 lastTop;
99  int16 lastBottom;
100  Mult_GobState **goblinStates;
101  uint8 goblinX;
102  uint8 goblinY;
103  uint8 destX;
104  uint8 destY;
105  int8 gobDestX;
106  int8 gobDestY;
107  uint8 nearestWayPoint;
108  uint8 nearestDest;
109  int8 needRedraw;
110  int16 newLeft;
111  int16 newTop;
112  int16 newRight;
113  int16 newBottom;
114  int16 spriteDestLeft;
115  int16 spriteDestTop;
116  int16 spriteDestRight;
117  int16 spriteDestBottom;
118  uint32 videoSlot;
119  int16 lastFrameIndex;
120  int16 field_32[3];
121  byte* field_3C;
122  char animName[16];
123  int8 field_50;
124  int16* animVariables;
125  bool ownAnimVariables;
126  } PACKED_STRUCT;
127 
128  struct Mult_StaticKey {
129  int16 frame;
130  int16 layer;
131  } PACKED_STRUCT;
132 
133  struct Mult_AnimKey {
134  uint16 frame;
135  int16 layer;
136  int16 posX;
137  int16 posY;
138  int16 order;
139  } PACKED_STRUCT;
140 
141  struct Mult_TextKey {
142  int16 frame;
143  int16 cmd;
144  char unknown[18];
145  byte script[6];
146  } PACKED_STRUCT;
147 
148  struct Mult_PalKey {
149  int16 frame;
150  int16 cmd;
151  int16 rates[4];
152  int16 unknown0;
153  int16 unknown1;
154  int8 subst[16][4];
155  } PACKED_STRUCT;
156 
158  int16 frame;
159  int16 fade;
160  int16 palIndex;
161  int8 flag;
162  } PACKED_STRUCT;
163 
164  struct Mult_SndKey {
165  int16 frame;
166  int16 cmd;
167  int16 freq;
168  int16 fadeLength;
169  int16 repCount;
170  int16 resId;
171  int16 soundIndex;
172  } PACKED_STRUCT;
173 
174  struct Mult_ImdKey {
175  int16 frame;
176  int16 imdFile;
177  int16 field_4;
178  int16 field_6;
179  uint16 flags;
180  int16 palFrame;
181  int16 lastFrame;
182  int8 palStart;
183  int8 palEnd;
184  } PACKED_STRUCT;
185 
186  struct Mult_Data {
187  int16 palFadeKeysCount;
188  Mult_PalFadeKey *palFadeKeys;
189 
190  int16 palKeysCount;
191  Mult_PalKey *palKeys;
192 
193  int16 staticKeysCount;
194  Mult_StaticKey *staticKeys;
195  int16 staticIndices[10];
196  bool staticLoaded[10];
197  uint8 staticCount;
198 
199  int16 animKeysCount[4];
200  Mult_AnimKey *animKeys[4];
201  int16 animIndices[10];
202  uint8 animCount;
203 
204  bool animLoaded[10];
205  int16 animKeysFrames[4];
206  int16 animKeysStartFrames[4];
207  int16 animKeysStopFrames[4];
208  int16 animKeysIndices[4][4];
209  int8 animDirection;
210 
211  int16 textKeysCount;
212  Mult_TextKey *textKeys;
213 
214  int16 sndKeysCount;
215  Mult_SndKey *sndKeys;
216 
217  int16 sndSlotsCount;
218  int16 sndSlot[60];
219  int16 frameRate;
220 
221  Video::Color fadePal[5][16];
222  int16 animObjs[4][4];
223  int16 palAnimIndices[4];
224  int16 frameStart;
225 
226  int16 imdKeysIndices[4][4];
227 
228  int16 imdKeysCount[4];
229  Mult_ImdKey *imdKeys[4];
230  int16 imdIndices[4];
231  char *imdFiles;
232  char *somepointer10; // ?
233  byte *execPtr;
234  } PACKED_STRUCT;
235 
236 #include "common/pack-end.h" // END STRUCT PACKING
237 
238  // Globals
239 
240  Mult_Data *_multData;
241 
242  int16 _frame;
243 
244  int16 _objCount;
245  Mult_Object *_objects;
246 
247  int16 *_renderData;
248  Mult_Object **_renderObjs;
249 
250  int8 *_orderArray;
251 
252  SurfacePtr _animSurf;
253  int16 _animLeft;
254  int16 _animTop;
255  int16 _animWidth;
256  int16 _animHeight;
257 
258  void initAll();
259  void freeAll();
260  void checkFreeMult();
261  void freeMult(bool freeObjectSprites = false);
262  void zeroMultData();
263  void playMult(int16 startFrame, int16 endFrame, char checkEscape,
264  char handleMouse);
265 
266  int openObjVideo(const Common::String &file, VideoPlayer::Properties &properties, int animation);
267  void closeObjVideo(Mult_Object &object);
268  void clearObjectVideos();
269 
270  virtual void loadMult(int16 resId) = 0;
271  virtual void freeMultKeys() = 0;
272  virtual bool hasMultData(uint16 multIndex) = 0;
273  virtual void setMultData(uint16 multIndex) = 0;
274  virtual void zeroMultData(uint16 multIndex) = 0;
275  virtual void multSub(uint16 multIndex) = 0;
276  virtual void animate() = 0;
277 
278  Mult(GobEngine *vm);
279  virtual ~Mult();
280 
281 protected:
282  int16 _index;
283  int16 _counter;
284  bool _animDataAllocated;
285 
286  Mult_Data *_multDatas[8];
287 
288  bool _doPalSubst;
289 
290  Variables *_animArrayX;
291  Variables *_animArrayY;
292  Mult_AnimData *_animArrayData;
293 
294  int16 _palKeyIndex;
295  Video::Color *_oldPalette;
296  Video::Color _palAnimPalette[256];
297  int16 _palAnimKey;
298  int16 _palAnimRed[4];
299  int16 _palAnimGreen[4];
300  int16 _palAnimBlue[4];
301 
302  char _palFadingRed;
303  char _palFadingGreen;
304  char _palFadingBlue;
305 
306  GobEngine *_vm;
307 
308  void drawText(bool &stop, bool &stopNoClear);
309  void prepPalAnim(bool &stop);
310  void doPalAnim();
311  void doFadeAnim(bool &stop);
312  void doSoundAnim(bool &stop, int16 frame);
313 
314  virtual void playMultInit() = 0;
315  virtual void drawStatics(bool &stop) = 0;
316  virtual void drawAnims(bool &stop) = 0;
317  virtual void newCycleAnim(Mult_Object &animObj) = 0;
318 };
319 
320 class Mult_v1 : public Mult {
321 public:
322  Mult_v1(GobEngine *vm);
323  ~Mult_v1() override {}
324 
325  void loadMult(int16 resId) override;
326  void freeMultKeys() override;
327  bool hasMultData(uint16 multIndex) override;
328  void setMultData(uint16 multIndex) override;
329  void zeroMultData(uint16 multIndex) override;
330  void multSub(uint16 multIndex) override;
331  void animate() override;
332 
333 protected:
334  void playMultInit() override;
335  void drawStatics(bool &stop) override;
336  void drawAnims(bool &stop) override;
337  void newCycleAnim(Mult_Object &animObj) override;
338 };
339 
340 class Mult_v2 : public Mult_v1 {
341 public:
342  Mult_v2(GobEngine *vm);
343  ~Mult_v2() override;
344 
345  void loadMult(int16 resId) override;
346  void freeMultKeys() override;
347  bool hasMultData(uint16 multIndex) override;
348  void setMultData(uint16 multIndex) override;
349  void zeroMultData(uint16 multIndex) override;
350  void multSub(uint16 multIndex) override;
351  void animate() override;
352 
353 protected:
354  void playMultInit() override;
355  void drawStatics(bool &stop) override;
356  void drawAnims(bool &stop) override;
357  void newCycleAnim(Mult_Object &animObj) override;
358 
359  void loadImds(Common::SeekableReadStream &data);
360  void playImd(const char *imdFile, Mult_ImdKey &key, int16 dir, int16 startFrame);
361 
362  void advanceObjects(int16 index);
363  void advanceAllObjects();
364 };
365 
366 } // End of namespace Gob
367 
368 #endif // GOB_MULT_H
Definition: gob.h:163
Definition: str.h:59
Definition: mult.h:164
Definition: mult.h:157
Definition: mult.h:174
Definition: variables.h:33
Definition: mult.h:128
Definition: mult.h:42
Definition: mult.h:148
Definition: mult.h:91
Definition: stream.h:745
Definition: video.h:86
Definition: mult.h:80
Definition: anifile.h:40
Definition: videoplayer.h:70
Definition: variables.h:133
Definition: mult.h:186
Definition: mult.h:320
Definition: mult.h:141
Definition: mult.h:133
Definition: mult.h:37
Definition: mult.h:340