ScummVM API documentation
graphics.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 QUEEN_GRAPHICS_H
23#define QUEEN_GRAPHICS_H
24
25#include "common/util.h"
26#include "queen/structs.h"
27
28namespace Queen {
29
30struct BobSlot {
31 bool active;
33 int16 x, y;
36 bool xflip;
38 uint16 scale;
40 uint16 frameNum;
43
46 struct {
47 int16 speed, speedBak;
48
50 struct {
51 const AnimFrame *buffer;
52 const AnimFrame *curPos;
54
56 struct {
57 bool rebound;
58 uint16 firstFrame, lastFrame;
60
61 } anim;
62
63 bool moving;
65 int16 speed;
67 bool xmajor;
69 int8 xdir, ydir;
71 int16 endx, endy;
72 uint16 dx, dy;
73 uint16 total;
74
75 void curPos(int16 xx, int16 yy);
76 void move(int16 dstx, int16 dsty, int16 spd);
77 void moveOneStep();
78 void animOneStep();
79
80 void animString(const AnimFrame *animBuf);
81 void animNormal(uint16 firstFrame, uint16 lastFrame, uint16 speed, bool rebound, bool xflip);
82
83 void scaleWalkSpeed(uint16 ms);
84
85 void clear();
86 void clear(const Box *defaultBox);
87};
88
89class QueenEngine;
90
91class Graphics {
92public:
93
95 ~Graphics();
96
99
102
105
107 void drawBob(const BobSlot *bs, const BobFrame *bf, const Box *box, int16 x, int16 y);
108
110 void drawInventoryItem(uint32 frameNum, uint16 x, uint16 y);
111
113 void pasteBob(uint16 objNum, uint16 image);
114
116 void shrinkFrame(const BobFrame *bf, uint16 percentage);
117
119 void sortBobs();
120
122 void drawBobs();
123
125 void clearBobs();
126
128 void stopBobs();
129
131 BobSlot *bob(int index);
132
133 void clearBob(int index) { bob(index)->clear(&_defaultBox); }
134
136 void setBobText(const BobSlot *bob, const char *text, int textX, int textY, int color, int flags);
137
139 void handleParallax(uint16 roomNum);
140
141 void setupNewRoom(const char *room, uint16 roomNum, int16 *furniture, uint16 furnitureCount);
142
143 void setBobCutawayAnim(uint16 bobNum, bool xflip, const AnimFrame *af, uint8 frameCount);
144 void fillAnimBuffer(const char *anim, AnimFrame *af);
145 uint16 countAnimFrames(const char *anim);
146 void setupObjectAnim(const GraphicData *gd, uint16 firstImage, uint16 bobNum, bool visible);
147 uint16 setupPersonAnim(const ActorData *ad, const char *anim, uint16 curImage);
148 void resetPersonAnim(uint16 bobNum);
149 void erasePersonAnim(uint16 bobNum);
150 void eraseAllAnims();
151
152 uint16 refreshObject(uint16 obj);
153
154 void setupRoomFurniture(int16 *furniture, uint16 furnitureCount);
155 void setupRoomObjects();
156
157 uint16 setupPerson(uint16 noun, uint16 curImage);
158 uint16 allocPerson(uint16 noun, uint16 curImage);
159
160 uint16 personFrames(uint16 bobNum) const { return _personFrames[bobNum]; }
161 void clearPersonFrames() { memset(_personFrames, 0, sizeof(_personFrames)); }
162 uint16 numFrames() const { return _numFrames; }
163 uint16 numStaticFurniture() const { return _numFurnitureStatic; }
164 uint16 numAnimatedFurniture() const { return _numFurnitureAnimated; }
165 uint16 numFurnitureFrames() const { return _numFurnitureStatic + _numFurnitureAnimatedLen; }
166
167 void putCameraOnBob(int bobNum) { _cameraBob = bobNum; }
168
169 void update(uint16 room);
170
171 enum {
172 ARROW_BOB_UP = 62,
173 ARROW_BOB_DOWN = 63,
174 MAX_BOBS_NUMBER = 64,
175 MAX_STRING_LENGTH = 255,
176 MAX_STRING_SIZE = (MAX_STRING_LENGTH + 1),
177 BOB_SHRINK_BUF_SIZE = 60000
178 };
179
180
181private:
182
183 BobSlot _bobs[MAX_BOBS_NUMBER];
184
186 BobSlot *_sortedBobs[MAX_BOBS_NUMBER];
187
189 uint16 _sortedBobsCount;
190
192 BobFrame _shrinkBuffer;
193
195 AnimFrame _newAnim[17][30];
196
198 AnimFrame _cutAnim[21][30];
199
200 uint16 _personFrames[4];
201
203 uint16 _numFurnitureAnimated;
204
206 uint16 _numFurnitureStatic;
207
209 uint16 _numFurnitureAnimatedLen;
210
212 uint16 _numFrames;
213
215 int _cameraBob;
216
217 QueenEngine *_vm;
218
219 const Box _defaultBox;
220 const Box _gameScreenBox;
221 const Box _fullScreenBox;
222};
223
224class BamScene {
225public:
226
228
229 void playSfx();
230 void prepareAnimation();
231 void updateCarAnimation();
232 void updateFightAnimation();
233
234 void saveState(byte *&ptr);
235 void loadState(uint32 ver, byte *&ptr);
236
237 enum {
238 BOB_OBJ1 = 5,
239 BOB_OBJ2 = 6,
240 BOB_FX = 7
241 };
242
243 enum {
244 F_STOP = 0,
245 F_PLAY = 1,
246 F_REQ_STOP = 2
247 };
248
249 uint16 _flag, _index;
250
251private:
252
253 struct BamDataObj {
254 int16 x, y;
255 int16 frame;
256 };
257
258 struct BamDataBlock {
259 BamDataObj obj1; // truck / Frank
260 BamDataObj obj2; // Rico / robot
261 BamDataObj fx;
262 int16 sfx;
263 };
264
265 BobSlot *_obj1;
266 BobSlot *_obj2;
267 BobSlot *_objfx;
268 bool _screenShaked;
269 const BamDataBlock *_fightData;
270 uint16 _lastSoundIndex;
271
272 QueenEngine *_vm;
273
274 static const BamDataBlock _carData[];
275 static const BamDataBlock _fight1Data[];
276 static const BamDataBlock _fight2Data[];
277 static const BamDataBlock _fight3Data[];
278 static const BamDataBlock _fight4Data[];
279};
280
281} // End of namespace Queen
282
283#endif
Definition: graphics.h:224
void setupArrows()
setup dialog arrows
void setupMouseCursor()
setup mouse cursor
void handleParallax(uint16 roomNum)
handles parallax scrolling for the specified room
void stopBobs()
stop all animating/movings bobs
void drawInventoryItem(uint32 frameNum, uint16 x, uint16 y)
draw an inventory item
void clearBobs()
clear all setup bobs
void drawBobs()
draw all the sorted bobs
void pasteBob(uint16 objNum, uint16 image)
draw a bob directly on the backdrop bitmap
void sortBobs()
animate/move bobs and sort them
BobSlot * bob(int index)
returns a reference to the specified bob
void unpackControlBank()
unpacks control frames (ie. arrows)
void shrinkFrame(const BobFrame *bf, uint16 percentage)
resize a bobframe
void setBobText(const BobSlot *bob, const char *text, int textX, int textY, int color, int flags)
display a text 'near' the specified bob
void drawBob(const BobSlot *bs, const BobFrame *bf, const Box *box, int16 x, int16 y)
draw a bob
Definition: queen.h:87
Definition: formatinfo.h:28
Definition: bankman.h:28
Definition: structs.h:345
Definition: structs.h:537
Definition: structs.h:575
Definition: graphics.h:30
int8 xdir
moving direction
Definition: graphics.h:69
uint16 frameNum
associated BobFrame
Definition: graphics.h:40
struct Queen::BobSlot::@918::@920 normal
normal moving animation
int frameDir
'direction' for the next frame (-1, 1)
Definition: graphics.h:42
struct Queen::BobSlot::@918::@919 string
string based animation
int16 x
current position
Definition: graphics.h:33
uint16 scale
shrinking percentage
Definition: graphics.h:38
int16 speed
moving speed
Definition: graphics.h:47
bool xmajor
move along x axis instead of y
Definition: graphics.h:67
int16 endx
destination point
Definition: graphics.h:71
bool animating
animation stuff
Definition: graphics.h:45
Box box
bounding box
Definition: graphics.h:35
Definition: structs.h:30
Definition: structs.h:147