ScummVM API documentation
objects.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 HOPKINS_OBJECTS_H
23 #define HOPKINS_OBJECTS_H
24 
25 #include "hopkins/globals.h"
26 
27 #include "common/scummsys.h"
28 #include "common/endian.h"
29 #include "common/str.h"
30 
31 #define MAX_SPRITE 5
32 namespace Hopkins {
33 
35  byte _objectFileNum;
36  byte _idx;
37  byte _flag1;
38  byte _flag2;
39  byte _flag3;
40  byte _flag4;
41  byte _flag5;
42  byte _flag6;
43 };
44 
45 struct SpriteItem {
46  int _animationType;
47  const byte *_spriteData;
48  Common::Point _spritePos;
49  int _zoomFactor;
50  bool _flipFl;
51  int _spriteIndex;
52  int _deltaX;
53  int _deltaY;
54  bool _rleFl;
55  bool _activeFl;
56  int _destX;
57  int _destY;
58  int _width;
59  int _height;
60  int _zoomPct;
61  int _reducePct;
62 };
63 
64 struct BobItem {
65  int _bobMode;
66  byte *_spriteData;
67  int _xp;
68  int _yp;
69  int _frameIndex;
70  int _animDataIdx;
71  int _moveChange1;
72  int _moveChange2;
73  bool _disabledAnimationFl;
74  byte *_animData;
75  bool _bobMode10;
76  int _bobModeChange;
77  int _modeChangeCtr;
78  int _modeChangeUnused;
79  bool _disableFl; // Set to true in B_CACHE_OFF()
80  int _zoomFactor;
81  bool _flipFl;
82  bool _isSpriteFl;
83  bool _activeFl;
84  int _oldX;
85  int _oldY;
86  int _oldWidth;
87  int _oldHeight;
88  int _oldX2;
89  int _zooInmFactor;
90  int _zoomOutFactor;
91 };
92 
93 struct HidingItem {
94  int _x;
95  int _y;
96  int _spriteIndex;
97  int _width;
98  int _height;
99  int _useCount;
100  byte *_spriteData;
101  bool _resetUseCount;
102  int _yOffset;
103 };
104 
105 struct LockAnimItem {
106  bool _enableFl;
107  int _posX;
108 };
109 
110 struct VBobItem {
111  const byte *_spriteData;
112  int _displayMode;
113  int _xp;
114  int _yp;
115  int _frameIndex;
116  byte *_surface;
117  int _oldX;
118  int _oldY;
119  int _oldFrameIndex;
120  const byte *_oldSpriteData;
121 };
122 
123 struct ListeItem {
124  bool _visibleFl;
125  int _posX;
126  int _posY;
127  int _width;
128  int _height;
129 };
130 
134 enum SortMode { SORT_NONE = 0, SORT_BOB = 1, SORT_SPRITE = 2, SORT_HIDING = 3 };
135 
139 struct SortItem {
140  SortMode _sortMode;
141  int _index;
142  int _priority;
143 };
144 
145 class HopkinsEngine;
146 
148 private:
149  HopkinsEngine *_vm;
150 
151  int _objectWidth, _objectHeight;
152  int _oldBorderSpriteIndex;
153  int _borderSpriteIndex;
154  byte *_spritePtr;
155  const byte *_oldSpriteData;
156  int _verb;
157  int _oldSpriteIndex;
158  int _oldFrameIndex;
159  int _oldDirectionSpriteIdx;
160  Directions _oldDirection;
161  Directions _lastDirection;
162  bool _oldFlipFl;
163  int _curGestureFile;
164  byte *_gestureBuf;
165  int _homeRateCounter;
166  int _sortedDisplayCount;
167  SortItem _sortedDisplay[51];
168  byte *_hidingItemData[6];
169  HidingItem _hidingItem[25];
170  bool _hidingActiveFl;
171  ObjectAuthIcon _objectAuthIcons[300];
172  int _curObjectFileNum;
173  byte *_objectDataBuf;
174 
175  VBobItem _vBob[30];
176  ListeItem _liste[6];
177  ListeItem _liste2[35];
178 
179  void initVBob();
180  void clearVBob();
181 
182  void sprite_alone(const byte *objectData, byte *sprite, int objIndex);
183  void removeObjectDataBuf();
184 
185  int getOffsetX(const byte *spriteData, int spriteIndex, bool isSize);
186  int getOffsetY(const byte *spriteData, int spriteIndex, bool isSize);
187 
188  void capture_mem_sprite(const byte *objectData, byte *sprite, int objIndex);
189  void setBobInfo(int idx);
190  void computeHideCounter(int idx);
191  void initBobVariables(int idx);
192 
193  void checkHidingItem();
194  void displayHiding(int idx);
195  void computeSprite(int idx);
196  void beforeSort(SortMode sortMode, int index, int priority);
197  void displayBobAnim();
198  void displayVBob();
199  void showSprite(int idx);
200  void clearSprite();
201  void setSpriteZoom(int idx, int zoomFactor);
202 
203  void loadZone(const Common::Path &file);
204  void changeCharacterHead(PlayerCharacter oldCharacter, PlayerCharacter newCharacter);
205  void goHome2();
206 
207  void nextVerbIcon();
208  void handleForest(int screenId, int minX, int maxX, int minY, int maxY, int idx);
209 
210  void sceneSpecialIni();
211  void showActionAnimation(const byte *spriteData, const Common::String &actionStr, int speed, bool flipFl);
212 public:
213  bool _disableFl;
214  bool _forestFl;
215  bool _visibleFl;
216  bool _saveLoadFl;
217  bool _forceZoneFl;
218  bool _changeVerbFl;
219  bool _helicopterFl;
220  bool _twoCharactersFl;
221  bool _changeHeadFl;
222  bool _priorityFl;
223  int _jumpVerb;
224  int _jumpZone;
225  int _zoneNum;
226  int _eraseVisibleCounter;
227  int _curObjectIndex;
228  int _startSpriteIndex;
229  int _saveLoadX, _saveLoadY;
230  int _mapCarPosX, _mapCarPosY;
231  int _oldCharacterPosX, _oldCharacterPosY;
232  Common::Point _borderPos;
233  Common::Point _oldBorderPos;
234  Common::Point _characterPos;
235  byte *_forestSprite;
236  byte *_saveLoadSprite;
237  byte *_saveLoadSprite2;
238  byte *_headSprites;
239  SpriteItem _sprite[6];
240  BobItem _bob[36];
241  LockAnimItem _lockedAnims[36];
242  bool _charactersEnabledFl;
243  bool _refreshBobMode10Fl;
244 
246  ~ObjectsManager();
247 
248  void clearAll();
249 
250  int getWidth(const byte *objectData, int idx);
251  int getHeight(const byte *objectData, int idx);
252  byte *loadSprite(const Common::Path &file);
253  void loadLinkFile(const Common::Path &file, bool OBSSEUL = false);
254  void addStaticSprite(const byte *spriteData, Common::Point pos, int idx, int spriteIndex, int zoomFactor, bool flipFl, int deltaX, int deltaY);
255  void animateSprite(int idx);
256  void removeSprite(int idx);
257  void setSpriteX(int idx, int xp);
258  void setSpriteY(int idx, int yp);
259  int getSpriteX(int idx);
260  int getSpriteY(int idx);
261  void setSpriteIndex(int idx, int spriteIndex);
262  void displaySprite();
263  void computeAndSetSpriteSize();
264  void setFlipSprite(int idx, bool flip);
265 
266  int getBobAnimDataIdx(int idx);
267  void initBorder(int zoneIdx);
268  void nextObjectIcon(int idx);
269  void takeInventoryObject(int idx);
270  void handleSpecialGames();
271 
272  void addObject(int objIndex);
273  void changeObject(int objIndex);
274  void removeObject(int objIndex);
275 
276  void resetBob(int idx);
277  void hideBob(int idx);
278  void displayBob(int idx);
279  void setBobOffset(int idx, int offset);
280  void setBobAnimDataIdx(int idx, int animIdx);
281  void setBobAnimation(int idx);
282  void stopBobAnimation(int idx);
283  int getBobPosX(int idx);
284 
285  void handleCityMap();
286  void clearScreen();
287  void disableVerb(int idx, int a2);
288  void enableVerb(int idx, int a2);
289  void lockAnimX(int idx, int x);
290  void handleLeftButton();
291  void handleRightButton();
292  void setOffsetXY(byte *data, int idx, int xp, int yp, bool isSize);
293  void setVerb(int id);
294 
295  void doActionBack(int idx);
296  void doActionRight(int idx);
297  void doActionFront(int idx);
298  void doActionLeft(int idx);
299  void doActionDiagRight(int idx);
300  void doActionDiagLeft(int idx);
301  void loadObjects();
302  byte *loadObjectFromFile(int objIndex, bool mode);
303  void resetHidingItems();
304  void resetHidingUseCount(int idx);
305  void setHidingUseCount(int idx);
306  void loadHidingItems(const Common::Path &file);
307  void enableHidingBehavior();
308  void disableHidingBehavior();
309  void disableHidingItem(int idx);
310 
311  void resetHomeRateCounter() { _homeRateCounter = 0; }
312  void resetOldFrameIndex() { _oldFrameIndex = -1; }
313  void resetOldDirection() { _oldDirection = DIR_NONE; }
314  int getObjectWidth() { return _objectWidth; }
315  int getObjectHeight() { return _objectHeight; }
316 
317  void showSpecialActionAnimationWithFlip(const byte *spriteData, const Common::String &animationSeq, int speed, bool flipFl);
318  void showSpecialActionAnimation(const byte *spriteData, const Common::String &animString, int speed);
319  void checkEventBobAnim(int idx, int animIdx, int animDataIdx, int a4);
320  void setMultiBobAnim(int idx1, int idx2, int anim1Idx, int anim2Idx);
321  void loadObjectIniFile();
322  void quickDisplayBobSprite(int idx);
323  void initVbob(const byte *src, int idx, int xp, int yp, int frameIndex);
324  void disableVbob(int idx);
325  void setAndPlayAnim(int idx, int animIdx, int destPosi, bool animAction);
326 
327  void sceneControl(const Common::Path &backgroundFile, const Common::Path &linkFile,
328  const Common::Path &animFile, const Common::Path &s4, int soundNum, bool initializeScreen);
329  void sceneControl2(const Common::Path &backgroundFile, const Common::Path &linkFile,
330  const Common::Path &animFile, const Common::Path &s4, int soundNum, bool initializeScreen);
331  void goHome();
332  void paradise();
333 };
334 
335 } // End of namespace Hopkins
336 
337 #endif /* HOPKINS_OBJECTS_H */
Definition: objects.h:105
Definition: str.h:59
Definition: objects.h:64
Definition: objects.h:110
Definition: path.h:52
Definition: objects.h:45
Definition: objects.h:147
Definition: rect.h:45
Definition: anim.h:30
Definition: objects.h:139
Definition: objects.h:34
Definition: objects.h:93
Definition: hopkins.h:77
Definition: objects.h:123
SortMode
Definition: objects.h:134