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
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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_GAME_H
#define GOB_GAME_H
#include "sound/mods/infogrames.h"
#include "gob/sound.h"
namespace Gob {
class Game {
public:
#include "common/pack-start.h" // START STRUCT PACKING
struct Collision {
int16 id;
uint16 left;
uint16 top;
uint16 right;
uint16 bottom;
int16 flags;
int16 key;
uint16 funcEnter;
uint16 funcLeave;
uint16 funcSub;
} PACKED_STRUCT;
#define szGame_TotResItem (4 + 2 + 2 + 2)
struct TotResItem {
int32 offset; // if > 0, then offset from end of resource table.
// If < 0, then -offset-1 is index in .IM file table
int16 size;
int16 width;
int16 height;
} PACKED_STRUCT;
#define szGame_TotResTable (2 + 1)
struct TotResTable {
int16 itemsCount;
byte unknown;
TotResItem *items;
byte *dataPtr;
} PACKED_STRUCT;
#define szGame_ExtItem (4 + 2 + 2 + 2)
struct ExtItem {
int32 offset; // offset from the table end
uint16 size;
int16 width; // width & 0x7FFF: width, width & 0x8000: pack flag
int16 height; // not zero
} PACKED_STRUCT;
#define szGame_ExtTable (2 + 1)
struct ExtTable {
int16 itemsCount;
byte unknown;
ExtItem* items;
} PACKED_STRUCT;
#define szGame_TotTextItem (2 + 2)
struct TotTextItem {
int16 offset;
int16 size;
} PACKED_STRUCT;
#define szGame_TotTextTable (2)
struct TotTextTable {
int16 itemsCount;
TotTextItem *items;
byte *dataPtr;
} PACKED_STRUCT;
struct InputDesc {
int16 fontIndex;
int16 backColor;
int16 frontColor;
byte *ptr;
} PACKED_STRUCT;
#include "common/pack-end.h" // END STRUCT PACKING
TotResTable *_totResourceTable;
Collision *_collisionAreas;
Collision *_collStack[5];
bool _foundTotLoc;
TotTextTable *_totTextData;
char _curTotFile[14];
char _curExtFile[14];
byte *_imFileData;
byte *_totFileData;
int16 _extHandle;
SoundDesc _soundSamples[60];
Audio::Infogrames::Instruments *_infIns;
Audio::Infogrames *_infogrames;
Audio::SoundHandle _infHandle;
char _totToLoad[20];
int32 _startTimeKey;
int16 _mouseButtons;
bool _noScroll;
bool _preventScroll;
bool _scrollHandleMouse;
Game(GobEngine *vm);
virtual ~Game();
byte *loadExtData(int16 dataId, int16 *pResWidth, int16 *pResHeight, uint32 *dataSize = 0);
byte *loadTotResource(int16 id, int16 *dataSize = 0);
void capturePush(int16 left, int16 top, int16 width, int16 height);
void capturePop(char doDraw);
void freeSoundSlot(int16 slot);
void evaluateScroll(int16 x, int16 y);
int16 checkKeys(int16 *pMousex, int16 *pMouseY, int16 *pButtons, char handleMouse);
void start(void);
void totSub(int8 flags, const char *newTotFile);
void switchTotSub(int16 index, int16 skipPlay);
virtual void playTot(int16 skipPlay) = 0;
virtual void clearCollisions(void) = 0;
virtual int16 addNewCollision(int16 id, uint16 left, uint16 top,
uint16 right, uint16 bottom, int16 flags, int16 key,
uint16 funcEnter, uint16 funcLeave) = 0;
virtual void collisionsBlock(void) = 0;
virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
InputDesc *inpDesc, int16 *collResId, int16 *collIndex) = 0;
virtual int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
int16 backColor, int16 frontColor, char *str, int16 fontIndex,
char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex) = 0;
virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
int16 *pResId, int16 *pResIndex) = 0;
virtual void prepareStart(void) = 0;
protected:
int16 _lastCollKey;
int16 _lastCollAreaIndex;
int16 _lastCollId;
int16 _activeCollResId;
int16 _activeCollIndex;
byte _handleMouse;
char _forceHandleMouse;
uint32 _menuLevel;
char _tempStr[256];
ExtTable *_extTable;
char _curImaFile[18];
int16 _collStackSize;
int16 _collStackElemSizes[5];
char _shouldPushColls;
// Capture
Common::Rect _captureStack[20];
int16 _captureCount;
char _collStr[256];
// For totSub()
int8 _backupedCount;
int8 _curBackupPos;
int16 _cursorHotspotXArray[5];
int16 _cursorHotspotYArray[5];
TotTextTable *_totTextDataArray[5];
byte *_totFileDataArray[5];
TotResTable *_totResourceTableArray[5];
ExtTable *_extTableArray[5];
int16 _extHandleArray[5];
byte *_imFileDataArray[5];
byte *_variablesArray[5];
char _curTotFileArray[5][14];
byte *_variablesSizesArray[5];
GobEngine *_vm;
int16 adjustKey(int16 key);
byte *loadLocTexts(void);
int32 loadTotFile(const char *path);
void loadExtTable(void);
void loadImFile(void);
void setCollisions(void);
void freeCollision(int16 id);
void collSub(uint16 offset);
void collAreaSub(int16 index, int8 enter);
int16 openLocTextFile(char *locTextFile, int language);
virtual void pushCollisions(char all) = 0;
virtual void popCollisions(void) = 0;
virtual int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex) = 0;
};
class Game_v1 : public Game {
public:
virtual void playTot(int16 skipPlay);
virtual void clearCollisions(void);
virtual int16 addNewCollision(int16 id, uint16 left, uint16 top,
uint16 right, uint16 bottom, int16 flags, int16 key,
uint16 funcEnter, uint16 funcLeave);
virtual void collisionsBlock(void);
virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
InputDesc *inpDesc, int16 *collResId, int16 *collIndex);
virtual int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
int16 backColor, int16 frontColor, char *str, int16 fontIndex,
char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex);
virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
int16 *pResId, int16 *pResIndex);
virtual void prepareStart(void);
Game_v1(GobEngine *vm);
virtual ~Game_v1() {}
protected:
virtual void pushCollisions(char all);
virtual void popCollisions(void);
virtual int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex);
};
class Game_v2 : public Game_v1 {
public:
virtual void playTot(int16 skipPlay);
virtual void clearCollisions(void);
virtual int16 addNewCollision(int16 id, uint16 left, uint16 top,
uint16 right, uint16 bottom, int16 flags, int16 key,
uint16 funcEnter, uint16 funcLeave);
virtual void collisionsBlock(void);
virtual int16 multiEdit(int16 time, int16 index, int16 *pCurPos,
InputDesc *inpDesc, int16 *collResId, int16 *collIndex);
virtual int16 inputArea(int16 xPos, int16 yPos, int16 width, int16 height,
int16 backColor, int16 frontColor, char *str, int16 fontIndex,
char inpType, int16 *pTotTime, int16 *collResId, int16 *collIndex);
virtual int16 checkCollisions(byte handleMouse, int16 deltaTime,
int16 *pResId, int16 *pResIndex);
virtual void prepareStart(void);
Game_v2(GobEngine *vm);
virtual ~Game_v2() {}
protected:
struct CollLast {
int16 key;
int16 id;
int16 areaIndex;
};
CollLast _collLasts[5];
virtual void pushCollisions(char all);
virtual void popCollisions(void);
virtual int16 checkMousePoint(int16 all, int16 *resId, int16 *resIndex);
};
} // End of namespace Gob
#endif // GOB_GAME_H
|