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
|
/* 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.
*
*/
#ifndef HOPKINS_OBJECTS_H
#define HOPKINS_OBJECTS_H
#include "hopkins/globals.h"
#include "common/scummsys.h"
#include "common/endian.h"
#include "common/str.h"
#define MAX_SPRITE 5
namespace Hopkins {
struct ObjectAuthIcon {
byte _objectFileNum;
byte _idx;
byte _flag1;
byte _flag2;
byte _flag3;
byte _flag4;
byte _flag5;
byte _flag6;
};
struct SpriteItem {
int _animationType;
const byte *_spriteData;
Common::Point _spritePos;
int _zoomFactor;
bool _flipFl;
int _spriteIndex;
int _deltaX;
int _deltaY;
bool _rleFl;
bool _activeFl;
int _destX;
int _destY;
int _width;
int _height;
int _zoomPct;
int _reducePct;
};
struct BobItem {
int _bobMode;
byte *_spriteData;
int _xp;
int _yp;
int _frameIndex;
int _animDataIdx;
int _moveChange1;
int _moveChange2;
bool _disabledAnimationFl;
byte *_animData;
bool _bobMode10;
int _bobModeChange;
int _modeChangeCtr;
int _modeChangeUnused;
bool _disableFl; // Set to true in B_CACHE_OFF()
int _zoomFactor;
bool _flipFl;
bool _isSpriteFl;
bool _activeFl;
int _oldX;
int _oldY;
int _oldWidth;
int _oldHeight;
int _oldX2;
int _zooInmFactor;
int _zoomOutFactor;
};
struct HidingItem {
int _x;
int _y;
int _spriteIndex;
int _width;
int _height;
int _useCount;
byte *_spriteData;
bool _resetUseCount;
int _yOffset;
};
struct LockAnimItem {
bool _enableFl;
int _posX;
};
struct VBobItem {
const byte *_spriteData;
int _displayMode;
int _xp;
int _yp;
int _frameIndex;
byte *_surface;
int _oldX;
int _oldY;
int _oldFrameIndex;
const byte *_oldSpriteData;
};
struct ListeItem {
bool _visibleFl;
int _posX;
int _posY;
int _width;
int _height;
};
/**
* Mode for SortItem records
*/
enum SortMode { SORT_NONE = 0, SORT_BOB = 1, SORT_SPRITE = 2, SORT_HIDING = 3 };
/**
* Structure to represent a pending display of either a Bob, Sprite, or Cache Item.
*/
struct SortItem {
SortMode _sortMode;
int _index;
int _priority;
};
class HopkinsEngine;
class ObjectsManager {
private:
HopkinsEngine *_vm;
int _objectWidth, _objectHeight;
int _oldBorderSpriteIndex;
int _borderSpriteIndex;
byte *_spritePtr;
const byte *_oldSpriteData;
int _verb;
int _oldSpriteIndex;
int _oldFrameIndex;
int _oldDirectionSpriteIdx;
Directions _oldDirection;
Directions _lastDirection;
bool _oldFlipFl;
int _curGestureFile;
byte *_gestureBuf;
int _homeRateCounter;
int _sortedDisplayCount;
SortItem _sortedDisplay[51];
byte *_hidingItemData[6];
HidingItem _hidingItem[25];
bool _hidingActiveFl;
ObjectAuthIcon _objectAuthIcons[300];
int _curObjectFileNum;
byte *_objectDataBuf;
VBobItem _vBob[30];
ListeItem _liste[6];
ListeItem _liste2[35];
void initVBob();
void clearVBob();
void sprite_alone(const byte *objectData, byte *sprite, int objIndex);
void removeObjectDataBuf();
int getOffsetX(const byte *spriteData, int spriteIndex, bool isSize);
int getOffsetY(const byte *spriteData, int spriteIndex, bool isSize);
void capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex);
void setBobInfo(int idx);
void computeHideCounter(int idx);
void initBobVariables(int idx);
void checkHidingItem();
void displayHiding(int idx);
void computeSprite(int idx);
void beforeSort(SortMode sortMode, int index, int priority);
void displayBobAnim();
void displayVBob();
void showSprite(int idx);
void clearSprite();
void setSpriteZoom(int idx, int zoomFactor);
void loadZone(const Common::String &file);
void changeCharacterHead(PlayerCharacter oldCharacter, PlayerCharacter newCharacter);
void goHome2();
void nextVerbIcon();
void handleForest(int screenId, int minX, int maxX, int minY, int maxY, int idx);
void sceneSpecialIni();
void showActionAnimation(const byte *spriteData, const Common::String &actionStr, int speed, bool flipFl);
public:
bool _disableFl;
bool _forestFl;
bool _visibleFl;
bool _saveLoadFl;
bool _forceZoneFl;
bool _changeVerbFl;
bool _helicopterFl;
bool _twoCharactersFl;
bool _changeHeadFl;
bool _priorityFl;
int _jumpVerb;
int _jumpZone;
int _zoneNum;
int _eraseVisibleCounter;
int _curObjectIndex;
int _startSpriteIndex;
int _saveLoadX, _saveLoadY;
int _mapCarPosX, _mapCarPosY;
int _oldCharacterPosX, _oldCharacterPosY;
Common::Point _borderPos;
Common::Point _oldBorderPos;
Common::Point _characterPos;
byte *_forestSprite;
byte *_saveLoadSprite;
byte *_saveLoadSprite2;
byte *_headSprites;
SpriteItem _sprite[6];
BobItem _bob[36];
LockAnimItem _lockedAnims[30];
bool _charactersEnabledFl;
bool _refreshBobMode10Fl;
ObjectsManager(HopkinsEngine *vm);
~ObjectsManager();
void clearAll();
int getWidth(const byte *objectData, int idx);
int getHeight(const byte *objectData, int idx);
byte *loadSprite(const Common::String &file);
void loadLinkFile(const Common::String &file, bool OBSSEUL = false);
void addStaticSprite(const byte *spriteData, Common::Point pos, int idx, int spriteIndex, int zoomFactor, bool flipFl, int deltaX, int deltaY);
void animateSprite(int idx);
void removeSprite(int idx);
void setSpriteX(int idx, int xp);
void setSpriteY(int idx, int yp);
int getSpriteX(int idx);
int getSpriteY(int idx);
void setSpriteIndex(int idx, int spriteIndex);
void displaySprite();
void computeAndSetSpriteSize();
void setFlipSprite(int idx, bool flip);
int getBobAnimDataIdx(int idx);
void initBorder(int zoneIdx);
void nextObjectIcon(int idx);
void takeInventoryObject(int idx);
void handleSpecialGames();
void addObject(int objIndex);
void changeObject(int objIndex);
void removeObject(int objIndex);
void resetBob(int idx);
void hideBob(int idx);
void displayBob(int idx);
void setBobOffset(int idx, int offset);
void setBobAnimDataIdx(int idx, int animIdx);
void setBobAnimation(int idx);
void stopBobAnimation(int idx);
int getBobPosX(int idx);
void handleCityMap();
void clearScreen();
void disableVerb(int idx, int a2);
void enableVerb(int idx, int a2);
void lockAnimX(int idx, int x);
void handleLeftButton();
void handleRightButton();
void setOffsetXY(byte *data, int idx, int xp, int yp, bool isSize);
void setVerb(int id);
void doActionBack(int idx);
void doActionRight(int idx);
void doActionFront(int idx);
void doActionLeft(int idx);
void doActionDiagRight(int idx);
void doActionDiagLeft(int idx);
void loadObjects();
byte *loadObjectFromFile(int objIndex, bool mode);
void resetHidingItems();
void resetHidingUseCount(int idx);
void setHidingUseCount(int idx);
void loadHidingItems(const Common::String &file);
void enableHidingBehavior();
void disableHidingBehavior();
void disableHidingItem(int idx);
void resetHomeRateCounter() { _homeRateCounter = 0; }
void resetOldFrameIndex() { _oldFrameIndex = -1; }
void resetOldDirection() { _oldDirection = DIR_NONE; }
int getObjectWidth() { return _objectWidth; }
int getObjectHeight() { return _objectHeight; }
void showSpecialActionAnimationWithFlip(const byte *spriteData, const Common::String &animationSeq, int speed, bool flipFl);
void showSpecialActionAnimation(const byte *spriteData, const Common::String &animString, int speed);
void checkEventBobAnim(int idx, int animIdx, int animDataIdx, int a4);
void setMultiBobAnim(int idx1, int idx2, int anim1Idx, int anim2Idx);
void loadObjectIniFile();
void quickDisplayBobSprite(int idx);
void initVbob(const byte *src, int idx, int xp, int yp, int frameIndex);
void disableVbob(int idx);
void setAndPlayAnim(int idx, int animIdx, int destPosi, bool animAction);
void sceneControl(const Common::String &backgroundFile, const Common::String &linkFile,
const Common::String &animFile, const Common::String &s4, int soundNum, bool initializeScreen);
void sceneControl2(const Common::String &backgroundFile, const Common::String &linkFile,
const Common::String &animFile, const Common::String &s4, int soundNum, bool initializeScreen);
void goHome();
void paradise();
};
} // End of namespace Hopkins
#endif /* HOPKINS_OBJECTS_H */
|