ScummVM API documentation
gamemodule.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 BBVS_GAMEMODULE_H
23 #define BBVS_GAMEMODULE_H
24 
25 #include "common/array.h"
26 #include "common/file.h"
27 #include "common/memstream.h"
28 #include "common/rect.h"
29 #include "common/str.h"
30 
31 namespace Bbvs {
32 
33 const int kInventoryItemCount = 42;
34 const int kInventoryItemSpriteCount = 2 * kInventoryItemCount;
35 const int kDialogItemSpriteCount = 26;
36 const int kGuiSpriteCount = 21;
37 const int kCameraInitsCount = 4;
38 
39 struct Condition {
40  byte cond;
41  byte value1;
42  int16 value2;
43 };
44 
45 struct Conditions {
46  Condition conditions[8];
47 };
48 
49 struct ActionResult {
50  byte kind;
51  byte value1;
52  int16 value2;
53 };
54 
55 struct ActionResults {
56  ActionResult actionResults[8];
57 };
58 
59 struct ActionCommand {
60  uint16 cmd;
61  int16 sceneObjectIndex;
62  uint32 timeStamp;
63  Common::Point walkDest;
64  int32 param;
65 };
66 
67 class ActionCommands : public Common::Array<ActionCommand> {
68 };
69 
70 struct Action {
71  Conditions conditions;
72  ActionResults results;
73  ActionCommands actionCommands;
74 };
75 
77  int16 xOffs, yOffs;
78  int16 width, height;
79 };
80 
81 struct CameraInit {
82  Common::Point cameraPos;
83  byte cameraLinks[8];
84  Common::Rect rects[8];
85 };
86 
88  char name[20];
89  int animIndices[16];
90  int walkSpeed;
91 };
92 
94  Conditions conditions;
95  int sceneObjectIndex;
96  int animIndex;
97  int x, y;
98 };
99 
100 struct BgObject {
101  char name[20];
102  Common::Rect rect;
103 };
104 
105 struct Animation {
106  int frameCount;
107  int *frameSpriteIndices;
108  int16 *frameTicks;
109  Common::Rect *frameRects1;
110  Common::Rect *frameRects2;
111  Animation()
112  : frameCount(0), frameSpriteIndices(0), frameTicks(0), frameRects1(0), frameRects2(0) {
113  }
114  ~Animation() {
115  delete[] frameSpriteIndices;
116  delete[] frameTicks;
117  delete[] frameRects1;
118  delete[] frameRects2;
119  }
120 };
121 
122 struct SceneExit {
123  Common::Rect rect;
124  int newModuleNum;
125 };
126 
127 struct SceneSound {
128  Conditions conditions;
129  uint soundNum;
130 };
131 
132 class GameModule {
133 public:
134  GameModule();
135  ~GameModule();
136 
137  void load(const Common::Path &filename);
138 
139  int getFieldC();
140  int getButtheadObjectIndex();
141 
142  int getGuiSpriteIndex(int index);
143  int getInventoryItemSpriteIndex(int index);
144  int getDialogItemSpriteIndex(int index);
145 
146  int getActionsCount();
147  Action *getAction(int index);
148 
149  InventoryItemInfo *getInventoryItemInfo(int index);
150 
151  CameraInit *getCameraInit(int cameraNum);
152 
153  int getSceneExitsCount();
154  SceneExit *getSceneExit(int index);
155 
156  int getWalkRectsCount();
157  Common::Rect *getWalkRects();
158 
159  int getSceneObjectDefsCount();
160  SceneObjectDef *getSceneObjectDef(int index);
161 
162  int getSceneObjectInitsCount();
163  SceneObjectInit *getSceneObjectInit(int index);
164 
165  int getBgObjectsCount();
166  BgObject *getBgObject(int index);
167 
168  int getBgSpritesCount();
169  int getBgSpriteIndex(int index);
170  int getBgSpritePriority(int index);
171 
172  int getSceneSoundsCount();
173  SceneSound *getSceneSound(int index);
174  uint getSceneSoundIndex(uint soundNum);
175 
176  uint getPreloadSoundsCount();
177  uint getPreloadSound(uint index);
178 
179  Animation *getAnimation(int index);
180 
181 protected:
182 
183  int _bgSpriteCount;
184  int *_bgSpriteIndices;
185  int16 *_bgSpritePriorities;
186 
187  CameraInit _cameraInits[kCameraInitsCount];
188 
189  int _walkRectsCount;
190  Common::Rect *_walkRects;
191 
192  int _sceneExitsCount;
193  SceneExit *_sceneExits;
194 
195  int _bgObjectsCount;
196  BgObject *_bgObjects;
197 
198  int _animationsCount;
199  Animation *_animations;
200 
201  int _sceneObjectDefsCount;
202  SceneObjectDef *_sceneObjectDefs;
203 
204  int _sceneObjectInitsCount;
205  SceneObjectInit *_sceneObjectInits;
206 
207  int _actionsCount;
208  Action *_actions;
209 
210  int _sceneSoundsCount;
211  SceneSound *_sceneSounds;
212 
213  uint _preloadSoundsCount;
214  uint *_preloadSounds;
215 
216  int _guiSpriteIndices[kGuiSpriteCount];
217  int _inventoryItemSpriteIndices[kInventoryItemSpriteCount];
218  InventoryItemInfo _inventoryItemInfos[kInventoryItemCount];
219  int _dialogItemSpriteIndices[kDialogItemSpriteCount];
220 
221  int _fieldC;
222  int _buttheadObjectIndex;
223 
226  Conditions readConditions(Common::SeekableReadStream &s);
227 
228  void unload();
229 
230  void loadBgSprites(Common::SeekableReadStream &s);
231  void loadCameraInits(Common::SeekableReadStream &s);
232  void loadWalkRects(Common::SeekableReadStream &s);
233  void loadSceneExits(Common::SeekableReadStream &s);
234  void loadBgObjects(Common::SeekableReadStream &s);
235  void loadAnimations(Common::SeekableReadStream &s);
236  void loadSceneObjectDefs(Common::SeekableReadStream &s);
237  void loadSceneObjectInits(Common::SeekableReadStream &s);
238  void loadActions(Common::SeekableReadStream &s);
239  void loadGuiSpriteIndices(Common::SeekableReadStream &s);
240  void loadInventoryItemSpriteIndices(Common::SeekableReadStream &s);
241  void loadInventoryItemInfos(Common::SeekableReadStream &s);
242  void loadDialogItemSpriteIndices(Common::SeekableReadStream &s);
243  void loadSceneSounds(Common::SeekableReadStream &s);
244  void loadPreloadSounds(Common::SeekableReadStream &s);
245 
246 };
247 
248 } // End of namespace Bbvs
249 
250 #endif // BBVS_GAMEMODULE_H
Definition: gamemodule.h:100
Definition: array.h:52
Definition: gamemodule.h:127
Definition: rect.h:144
Definition: path.h:52
Definition: stream.h:745
Definition: gamemodule.h:55
Definition: gamemodule.h:39
Definition: bbvs.h:42
Definition: gamemodule.h:70
Definition: gamemodule.h:67
Definition: rect.h:45
Definition: gamemodule.h:49
Definition: gamemodule.h:81
Definition: gamemodule.h:122
Definition: gamemodule.h:105
Definition: gamemodule.h:87
Definition: gamemodule.h:93
Definition: gamemodule.h:76
Definition: gamemodule.h:45
Definition: gamemodule.h:132
Definition: gamemodule.h:59