aboutsummaryrefslogtreecommitdiff
path: root/engines/gob/mult.h
blob: 0b0f6bcf4c0c9368df495bccfeb093cc5cc15a3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2004 Ivan Dubrov
 * Copyright (C) 2004-2006 The ScummVM project
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * $URL$
 * $Id$
 *
 */
#ifndef GOB_MULT_H
#define GOB_MULT_H

#include "gob/gob.h"
#include "gob/sound.h"
#include "gob/video.h"

namespace Gob {

class Mult {
public:

#include "common/pack-start.h"	// START STRUCT PACKING

	struct Mult_AnimData {
		uint8 animation;
		uint8 layer;
		uint8 frame;
		int8 animType;
		int8 order;
		int8 isPaused;
		int8 isStatic;
		int8 maxTick;
		int8 unknown;
		int8 newLayer;
		int8 newAnimation;
		byte intersected;
		uint8 newCycle;
		int8 state;              // New in GOB2
		int8 nextState;          // New in GOB2
		int8 field_F;            // New in GOB2
		int8 curLookDir;         // New in GOB2
		int8 isBusy;             // New in GOB2
		int8 pathExistence;      // New in GOB2
		int8 field_13;           // New in GOB2
		int8 field_14;           // New in GOB2
		int8 field_15;           // New in GOB2
		int8 field_16;           // New in GOB2
		int8 field_17;           // New in GOB2
		int8 somethingAnimation; // New in GOB2
		int8 somethingLayer;     // New in GOB2
		uint8 somethingFrame;     // New in GOB2
	};

	struct Mult_GobState {
		int16 animation; // .
		int16 layer;     // |- [0]
		int16 dataCount; // '
		int8 sndItem;    // .
		uint8 sndFrame;  // |
		int16 freq;      // |- [1+]
		int8 repCount;   // |
		uint8 speaker;   // '
	};

	struct Mult_Object {
		int32 *pPosX;
		int32 *pPosY;
		Mult_AnimData *pAnimData;
		int16 tick;
		int16 lastLeft;
		int16 lastRight;
		int16 lastTop;
		int16 lastBottom;
		Mult::Mult_GobState **goblinStates; // New in GOB2
		int8 goblinX;                       // New in GOB2
		int8 goblinY;                       // New in GOB2
		int8 destX;                         // New in GOB2
		int8 destY;                         // New in GOB2
		int8 gobDestX;                      // New in GOB2
		int8 gobDestY;                      // New in GOB2
		uint8 nearestWayPoint;              // New in GOB2
		uint8 nearestDest;                  // New in GOB2
		int8 field_22;                      // New in GOB2
		int8 someFlag;                      // New in GOB2
		int8 field_24;                      // New in GOB2
		int8 field_25;                      // New in GOB2
		int8 field_26;                      // New in GOB2
		int8 field_27;                      // New in GOB2
		int16 somethingLeft;                // New in GOB2
		int16 somethingTop;                 // New in GOB2
		int16 somethingRight;               // New in GOB2
		int16 somethingBottom;              // New in GOB2
	};

	struct Mult_StaticKey {
		int16 frame;
		int16 layer;
	};

	struct Mult_AnimKey {
		int16 frame;
		int16 layer;
		int16 posX;
		int16 posY;
		int16 order;
	};

	struct Mult_TextKey {
		int16 frame;
		int16 cmd;
		int16 unknown0[9];
		int16 index;
		int16 unknown1[2];
	};

	struct Mult_PalKey {
		int16 frame;
		int16 cmd;
		int16 rates[4];
		int16 unknown0;
		int16 unknown1;
		int8 subst[16][4];
	};

	struct Mult_PalFadeKey {
		int16 frame;
		int16 fade;
		int16 palIndex;
		int8 flag;
	};

	struct Mult_SndKey {
		int16 frame;
		int16 cmd;
		int16 freq;
		int16 fadeLength;
		int16 repCount;
		int16 resId;
		int16 soundIndex;
	};

	struct Mult_SomeKey {
		int16 frame;
		int16 field_2;
		int16 field_4;
		int16 field_6;
		int16 field_8;
		int16 field_A;
		int16 field_C;
		int16 field_E;
	};

	struct Mult_Data {
		int16 palFadeKeysCount;
		Mult_PalFadeKey *palFadeKeys;

		int16 palKeysCount;
		Mult_PalKey *palKeys;

		int16 staticKeysCount;
		Mult_StaticKey *staticKeys;
		int16 staticIndices[10];
		int16 staticLoaded[10];
		int8 staticCount;

		int16 animKeysCount[4];
		Mult_AnimKey *animKeys[4];
		int16 animIndices[10];
		int8 animCount;

		int16 animLoaded[10];
		int16 animKeysFrames[4];
		int16 animKeysStartFrames[4];
		int16 animKeysStopFrames[4];
		int16 animKeysIndices[4][4];
		int8 animDirection;

		int16 textKeysCount;
		Mult_TextKey *textKeys;

		int16 sndKeysCount;
		Mult_SndKey *sndKeys;

		int16 sndSlotsCount;
		int16 sndSlot[60];
		int16 frameRate;      

		Video::Color fadePal[5][16];
		int16 field_124[4][4];
		int16 palAnimIndices[4]; // Not sure here
		int16 frameStart;

		int16 field_17F[4][4];

		int16 someKeysCount[4];
		Mult_SomeKey *someKeys[4];
		int16 someKeysIndices[4];
		char *somepointer09; // ?
		char *somepointer10; // ?
		char *execPtr;
	};

#include "common/pack-end.h"	// END STRUCT PACKING

	// Globals

	Mult_Data *_multData;
	Mult_Data *_multDatas[8];

	Mult_Object *_objects;
	int16 *_renderData;
	Mult_Object **_renderData2;
	int16 _objCount;
	Video::SurfaceDesc *_underAnimSurf;

	int16 _frame;
	char _doPalSubst;
	int16 _counter;

	int32 *_animArrayX;
	int32 *_animArrayY;

	Mult_AnimData *_animArrayData;

	int16 _index;
	int16 _palKeyIndex;
	Video::Color *_oldPalette;

	Video::Color _palAnimPalette[256];
	int16 _palAnimKey;
	int16 _palAnimIndices[4];
	int16 _palAnimRed[4];
	int16 _palAnimGreen[4];
	int16 _palAnimBlue[4];

	char _palFadingRed;
	char _palFadingGreen;
	char _palFadingBlue;

	char _animDataAllocated;

	int8 *_orderArray;

	void zeroMultData(void);
	void checkFreeMult(void);
	void freeAll(void);
	void initAll(void);

	virtual void setMultData(uint16 multindex) = 0;
	virtual void multSub(uint16 multindex) = 0;
	virtual void loadMult(int16 resId) = 0;
	virtual void playMult(int16 startFrame, int16 endFrame, char checkEscape,
				  char handleMouse) = 0;
	virtual void animate(void) = 0;
	virtual void playSound(Snd::SoundDesc * soundDesc, int16 repCount,
				  int16 freq, int16 fadeLength) = 0;
	virtual void freeMult(void) = 0;
	virtual void freeMultKeys(void) = 0;

	Mult(GobEngine *vm);
	virtual ~Mult();

protected:
	Video::Color _fadePal[5][16];
	GobEngine *_vm;

	virtual char drawStatics(char stop) = 0;
	virtual char drawAnims(char stop) = 0;
	virtual void drawText(char *pStop, char *pStopNoClear) = 0;
	virtual char prepPalAnim(char stop) = 0;
	virtual void doPalAnim(void) = 0;
	virtual char doFadeAnim(char stop) = 0;
	virtual char doSoundAnim(char stop, int16 frame) = 0;
};

class Mult_v1 : public Mult {
public:
	Mult_v1(GobEngine *vm);
	virtual ~Mult_v1() {};

	virtual void setMultData(uint16 multindex);
	virtual void multSub(uint16 multindex);
	virtual void loadMult(int16 resId);
	virtual void playMult(int16 startFrame, int16 endFrame, char checkEscape,
				  char handleMouse);
	virtual void animate(void);
	virtual void playSound(Snd::SoundDesc * soundDesc, int16 repCount,
				  int16 freq, int16 fadeLength);
	virtual void freeMult(void);
	virtual void freeMultKeys(void);

protected:
	virtual char drawStatics(char stop);
	virtual char drawAnims(char stop);
	virtual void drawText(char *pStop, char *pStopNoClear);
	virtual char prepPalAnim(char stop);
	virtual void doPalAnim(void);
	virtual char doFadeAnim(char stop);
	virtual char doSoundAnim(char stop, int16 frame);
};

class Mult_v2 : public Mult_v1 {
public:
	Mult_v2(GobEngine *vm);
	virtual ~Mult_v2();

	virtual void setMultData(uint16 multindex);
	virtual void multSub(uint16 multindex);
	virtual void loadMult(int16 resId);
	virtual void playMult(int16 startFrame, int16 endFrame, char checkEscape,
				  char handleMouse);
	virtual void animate(void);
	virtual void playSound(Snd::SoundDesc * soundDesc, int16 repCount,
				  int16 freq, int16 fadeLength);
	virtual void freeMult(void);
	virtual void freeMultKeys(void);

protected:
	virtual char drawStatics(char stop);
	virtual char drawAnims(char stop);
	virtual void drawText(char *pStop, char *pStopNoClear);
	virtual char prepPalAnim(char stop);
	virtual void doPalAnim(void);
	virtual char doFadeAnim(char stop);
	virtual char doSoundAnim(char stop, int16 frame);

	void sub_62DD(int16 index);
	void sub_6A35(void);
	void sub_10C87(Mult_Object *obj);
};

}				// End of namespace Gob

#endif	/* __MULT_H */