ScummVM API documentation
struct.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 TRECISION_STRUCT_H
23 #define TRECISION_STRUCT_H
24 
25 #include "common/stream.h"
26 #include "common/rect.h"
27 #include "common/scummsys.h"
28 #include "common/serializer.h"
29 #include "graphics/surface.h"
30 #include "trecision/defines.h"
31 
32 namespace Trecision {
33 
34 struct SRoom {
35  char _baseName[4]; // Room name
36  uint16 _bkgAnim; // Background animation
37  uint16 _object[MAXOBJINROOM]; // Objects in the room
38  uint16 _sounds[MAXSOUNDSINROOM]; // Sounds of the room
39  uint16 _actions[MAXACTIONINROOM]; // Character actions in the room
40 
41  bool hasExtra() { return _flag & kObjFlagExtra; }
42  bool isDone() { return _flag & kObjFlagDone; }
43  void setExtra(bool on) { if (on) _flag |= kObjFlagExtra; else _flag &= ~kObjFlagExtra; }
44  void setDone(bool on) { if (on) _flag |= kObjFlagDone; else _flag &= ~kObjFlagDone; }
45 
46  void syncGameStream(Common::Serializer &ser);
47  void loadRoom(Common::SeekableReadStreamEndian *stream);
48 
49 private:
50  uint8 _flag; // Room visited or not, extra or not
51 };
52 
53 struct SObject {
54  Common::Rect _rect;
55  Common::Rect _area;
56  int8 _position; // -1 if no position
57  uint16 _name;
58  uint16 _examine;
59  uint16 _action;
60  uint8 _goRoom; // If direction room num - if person num dialog
61  uint8 _nbox; // Which 3d box the object is associated with
62  uint8 _ninv; // ptr inventory
63  uint16 _anim;
64 
65  void readRect(Common::SeekableReadStream *stream);
66  void setFlagDone(bool on) { if (on) _flag |= kObjFlagDone; else _flag &= ~kObjFlagDone; }
67  void setFlagExamine(bool on) { if (on) _flag |= kObjFlagExamine; else _flag &= ~kObjFlagExamine; }
68  void setFlagExtra(bool on) { if (on) _flag |= kObjFlagExtra; else _flag &= ~kObjFlagExtra; }
69  void setFlagPerson(bool on) { if (on) _flag |= kObjFlagPerson; else _flag &= ~kObjFlagPerson; }
70  void setFlagRoomOut(bool on) { if (on) _flag |= kObjFlagRoomOut; else _flag &= ~kObjFlagRoomOut; }
71  void setFlagRoomIn(bool on) { if (on) _flag |= kObjFlagRoomIn; else _flag &= ~kObjFlagRoomIn; }
72  void setFlagTake(bool on) { if (on) _flag |= kObjFlagTake; else _flag &= ~kObjFlagTake; }
73 
74  bool isFlagDone() { return _flag & kObjFlagDone; }
75  bool isFlagExamine() { return _flag & kObjFlagExamine; }
76  bool isFlagExtra() { return _flag & kObjFlagExtra; }
77  bool isFlagPerson() { return _flag & kObjFlagPerson; }
78  bool isFlagRoomIn() { return _flag & kObjFlagRoomIn; }
79  bool isFlagRoomOut() { return _flag & kObjFlagRoomOut; }
80  bool isFlagTake() { return _flag & kObjFlagTake; }
81  bool isFlagUseWith() { return _flag & kObjFlagUseWith; }
82 
83  bool isModeHidden() { return _mode & OBJMODE_HIDDEN; }
84  bool isModeFull() { return _mode & OBJMODE_FULL; }
85  bool isModeMask() { return _mode & OBJMODE_MASK; }
86  bool isModeLim() { return _mode & OBJMODE_LIM; }
87  bool isModeStatus() { return _mode & OBJMODE_OBJSTATUS; }
88 
89  void setModeHidden(bool on) { if (on) _mode |= OBJMODE_HIDDEN; else _mode &= ~OBJMODE_HIDDEN; }
90  void setModeFull(bool on) { if (on) _mode |= OBJMODE_FULL; else _mode &= ~OBJMODE_FULL; }
91  void setModeMask(bool on) { if (on) _mode |= OBJMODE_MASK; else _mode &= ~OBJMODE_MASK; }
92  void setModeLim(bool on) { if (on) _mode |= OBJMODE_LIM; else _mode &= ~OBJMODE_LIM; }
93  void setModeStatus(bool on) { if (on) _mode |= OBJMODE_OBJSTATUS; else _mode &= ~OBJMODE_OBJSTATUS; }
94 
95  void syncGameStream(Common::Serializer &ser);
96  void loadObj(Common::SeekableReadStreamEndian *stream);
97 
98 private:
99  uint8 _flag;
100  uint8 _mode;
101 };
102 
103 struct SInvObject {
104  uint16 _name; // Object name in the inventory
105  uint16 _examine; // Sentence if examined
106  uint16 _action;
107  uint16 _anim;
108 
109  void setFlagExtra(bool on) { if (on) _flag |= kObjFlagExtra; else _flag &= ~kObjFlagExtra; }
110 
111  bool isFlagExtra() { return _flag & kObjFlagExtra; }
112  bool isUseWith() { return _flag & kObjFlagUseWith; }
113 
114  void syncGameStream(Common::Serializer &ser);
115  void loadObj(Common::SeekableReadStreamEndian *stream);
116 
117 private:
118  uint8 _flag;
119 };
120 
121 struct SAtFrame {
122  uint8 _type; //ATFTEXT, ATFSND, ATFEVENT
123  uint8 _area; // 0 1 2 3 4
124  uint16 _numFrame;
125  uint16 _index;
126 };
127 
128 // Shifted left by 1 - 4, depending on the subarea
129 #define SMKANIM_OFF_BASE 16
130 
131 struct SAnim {
132  char _name[14];
133  uint16 _flag; // 1- background 2- icon 3- action 4- active - 4bits per child
134  Common::Rect _area[MAXAREA];
135  uint8 _nbox;
136  SAtFrame _atFrame[MAXATFRAME];
137 
143  void toggleAnimArea(uint8 area, bool show) {
144  assert(area >= 1 && area <= 4);
145  if (show)
146  _flag &= ~(SMKANIM_OFF_BASE << area);
147  else
148  _flag |= (SMKANIM_OFF_BASE << area);
149  }
150 
156  bool isAnimAreaShown(uint8 area) {
157  assert(area >= 1 && area <= 4);
158  return !(_flag & (SMKANIM_OFF_BASE << area));
159  }
160 };
161 
162 struct SSortTable {
163  uint16 _objectId; // Object ID
164  bool _remove; // Whether to copy or remove
165 };
166 
167 class Scheduler;
168 
169 struct SScriptFrame {
170  uint8 _class;
171  uint8 _event;
172 
173  uint8 _u8Param;
174 
175  uint16 _u16Param1;
176  uint16 _u16Param2;
177 
178  uint16 _u32Param;
179 
180  bool _noWait;
181 
182  void clear();
183  void sendFrame(Scheduler *scheduler);
184  bool isEmptyEvent() const { return _class == 0 && _event == 0; }
185 };
186 
187 class TrecisionEngine;
188 
189 struct SDText {
190  Common::Rect _rect;
191  Common::Rect _subtitleRect;
192  uint16 _textColor;
193  Common::String _text;
194  Common::String _drawTextLines[MAXDTEXTLINES];
195 
196  void set(SDText *org);
197  void set(Common::Rect rect, Common::Rect subtitleRect, uint16 textCol, const Common::String &text);
198 
199  void draw(TrecisionEngine *vm, bool hideLastChar = false, Graphics::Surface *externalSurface = nullptr);
200  uint16 calcHeight(TrecisionEngine *vm);
201 };
202 
203 struct STexture {
204  int16 _dx, _dy, _angle;
205  uint8 *_texture;
206 
207  void clear();
208  void set(int16 x, int16 y, uint8 *buffer);
209  bool isActive() { return _active; };
210 
211 private:
212  bool _active;
213 };
214 
215 struct SVertex {
216  float _x, _y, _z;
217  float _nx, _ny, _nz;
218 
219  void clear();
220 };
221 
222 struct SFace {
223  uint16 _a, _b, _c;
224  uint16 _mat;
225 };
226 
227 struct SLight {
228  float _x, _y, _z;
229  float _dx, _dy, _dz;
230  float _inr, _outr;
231  uint8 _hotspot;
232  uint8 _fallOff;
233  int8 _inten;
234  int8 _position;
235 
236  void clear();
237 };
238 
239 struct SCamera {
240  float _ex, _ey, _ez;
241  float _e1[3];
242  float _e2[3];
243  float _e3[3];
244  float _fovX, _fovY;
245 
246  void clear();
247 };
248 
249 } // End of namespace Trecision
250 #endif
Definition: struct.h:34
Definition: str.h:59
Definition: surface.h:67
Definition: struct.h:203
Definition: struct.h:121
Definition: struct.h:162
Definition: struct.h:222
Definition: struct.h:215
Definition: trecision.h:112
Definition: rect.h:144
Definition: struct.h:103
Definition: stream.h:745
Definition: serializer.h:79
bool isAnimAreaShown(uint8 area)
Definition: struct.h:156
Definition: actor.h:29
Definition: struct.h:53
void toggleAnimArea(uint8 area, bool show)
Definition: struct.h:143
Definition: scheduler.h:55
Definition: struct.h:239
Definition: struct.h:169
Definition: stream.h:944
Definition: struct.h:189
Definition: struct.h:131
Definition: struct.h:227