ScummVM API documentation
idtypes.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  * Based on the original sources
22  * Faery Tale II -- The Halls of the Dead
23  * (c) 1993-1996 The Wyrmkeep Entertainment Co.
24  */
25 
26 #ifndef SAGA2_IDTYPES_H
27 #define SAGA2_IDTYPES_H
28 
29 namespace Saga2 {
30 
31 #define FTA
32 
33 typedef uint32 ChunkID;
34 #define MakeID(a,b,c,d) ((d<<24L)|(c<<16L)|(b<<8L)|a)
35 
36 /* ===================================================================== *
37  ObjectID
38  * ===================================================================== */
39 
40 typedef uint16 ObjectID; // a reference to a script
41 
42 // Some fixed objects
43 
44 const ObjectID Nothing = 0, // a reference to no object
45  ObjectLimbo = 1, // where dead objects go
46  ActorLimbo = 2, // where dead actors go
47  ImportantLimbo = 3, // where dead important objects go
48  ActorBaseID = 0x8000, // high bit set for actors
49  WorldBaseID = 0xF000; // 4K possible worlds
50 
51 /* ===================================================================== *
52  TileID
53  * ===================================================================== */
54 
55 typedef uint16 TileID;
56 
57 const int16 nullID = -1;
58 
59 /* ===================================================================== *
60  PlayerActorID
61  * ===================================================================== */
62 
63 typedef int16 PlayerActorID;
64 
65 /* ===================================================================== *
66  MetaTileID struct
67  * ===================================================================== */
68 
70  int16 map, index;
71 };
72 
73 struct MetaTileID {
74  int16 map; // map number
75  int16 index; // index into metatile array
76 
77  // Default constructor
78  MetaTileID() : map(0), index(0) {}
79 
80  // Copy constructor
81  MetaTileID(const MetaTileID &id) : map(id.map), index(id.index) {}
82 
83  // Constructor
84  MetaTileID(int16 m, int16 i) : map(m), index(i) {}
85 
87  map = mt.map;
88  index = mt.index;
89  }
90 
91  MetaTileID operator = (const MetaTileID &id) {
92  map = id.map;
93  index = id.index;
94  return *this;
95  }
96 
97  bool operator == (const MetaTileID &id) const {
98  return map == id.map && index == id.index;
99  }
100 
101  bool operator != (const MetaTileID &id) const {
102  return map != id.map || index != id.index;
103  }
104 };
105 
106 // ID of NULL meta tile
107 extern const StaticMetaTileID NoMetaTile;
108 
109 /* ===================================================================== *
110  ActiveItemID struct
111  * ===================================================================== */
112 
113 const int kActiveItemIndexMask = 0x1FFF;
114 const int kActiveItemMapMask = 0xE000;
115 const int kActiveItemMapShift = 13;
116 
117 const int16 kActiveItemIndexNullID = 0x1FFF;
118 
120  int16 val;
121 };
122 
123 #include "common/pack-start.h"
124 struct ActiveItemID {
125  int16 val; // ID value --
126  // first 3 bits world number
127  // next 13 bits index
128 
129  // Default constructor
130  ActiveItemID() : val(0) {}
131 
132  // Copy constructor
133  ActiveItemID(const ActiveItemID &id) : val(id.val) {
134  }
135 
136  // Constructor
137  ActiveItemID(int16 idVal) : val(idVal) {}
138 
139  // Constructor
140  ActiveItemID(int16 m, int16 i) :
141  val((m << kActiveItemMapShift) | (i & kActiveItemIndexMask)) {
142  }
143 
145  val = a.val;
146  }
147 
148  ActiveItemID operator = (const ActiveItemID &id) {
149  val = id.val;
150  return *this;
151  }
152 
153  ActiveItemID operator = (int16 idVal) {
154  val = idVal;
155  return *this;
156  }
157 
158  bool operator == (const ActiveItemID &id) const {
159  return val == id.val;
160  }
161 
162  bool operator != (const ActiveItemID &id) const {
163  return val != id.val;
164  }
165 
166  operator int16() {
167  return val;
168  }
169 
170  void setMapNum(int16 m) {
171  val &= ~kActiveItemMapMask;
172  val |= (m << kActiveItemMapShift);
173  }
174 
175  int16 getMapNum() {
176  return (uint16)val >> kActiveItemMapShift;
177  }
178 
179  void setIndexNum(int16 i) {
180  val &= ~kActiveItemIndexMask;
181  val |= i & kActiveItemIndexMask;
182  }
183 
184  int16 getIndexNum() {
185  return val & kActiveItemIndexMask;
186  }
187 } PACKED_STRUCT;
188 #include "common/pack-end.h"
189 
190 // ID of NULL active item
191 extern const StaticActiveItemID NoActiveItem;
192 
193 /* ===================================================================== *
194  Task's and TaskStacks
195  * ===================================================================== */
196 
197 // Task evaluation return types
198 enum TaskResult {
199  kTaskFailed = -1, // Task has ended in failure
200  kTaskNotDone = 0, // Task has not ended yet
201  kTaskSucceeded = 1 // Task has ended in success
202 };
203 
204 typedef int16 TaskID;
205 const TaskID NoTask = -1;
206 
207 typedef int16 TaskStackID;
208 const TaskStackID NoTaskStack = -1;
209 
210 /* ===================================================================== *
211  TimerID
212  * ===================================================================== */
213 
214 typedef int16 TimerID;
215 
216 /* ===================================================================== *
217  SensorID
218  * ===================================================================== */
219 
220 typedef int16 SensorID;
221 
222 /* ===================================================================== *
223  BandID
224  * ===================================================================== */
225 
226 typedef int16 BandID;
227 const BandID NoBand = -1;
228 
229 typedef uint8 gPen; // a pen index number
230 
231 typedef uint16 weaponID;
232 
233 typedef uint32 hResID;
234 
235 typedef uint8 ColorTable[256];
236 
237 #ifndef offsetof
238 #define offsetof(type,field) (uint32)&(((type *)0)->field)
239 #endif
240 
241 #define maxuint8 0xff
242 #define maxint16 0x7fff
243 #define minint16 0x8000
244 #define maxuint16 0xffff
245 #define maxint32 0x7fffffff
246 
247 enum {
248  kActorListID = MKTAG('A', 'C', 'T', 'O')
249 };
250 
251 // number of containers
252 const int kNumViews = 3;
253 
254 enum {
255  kNullWeapon = 0,
256  kMaxWeapons = 256
257 };
258 
259 enum {
260  kActorCount = 575
261 };
262 
263 //
264 // Damage effects - these are the types of damage in the world
265 // Damage being defined as a change in effective vitality
266 // Note that healing is negative damage.
267 //
268 enum effectDamageTypes {
269  // Generic
270  kDamageOther = 0, // Healing, cause wounds
271  // Combat damage
272  kDamageImpact = 1, // hammers, maces
273  kDamageSlash = 2, // swords
274  kDamageProjectile = 3, // arrows, poin-ted sticks
275  // Magic damage
276  kDamageFire = 4, // Yellow
277  kDamageAcid = 5, // Violet
278  kDamageHeat = 6, // Red
279  kDamageCold = 7, // Blue
280  kDamageLightning = 8, // Orange
281  kDamagePoison = 9, // Green
282  // Other magic damage
283  kDamageMental = 10, // dain bramage
284  kDamageToUndead = 11, // undead take this damage
285  kDamageDirMagic = 12, // the plusses on swords etc.
286  // Physiological Damage
287  kDamageStarve = 13, // You must eat!
288  // other
289  kDamageEnergy = 14 // Generally hard to resist - god damage
290 };
291 
292 // Tile metrics
293 
294 enum {
295  kTileWidth = 64,
296  kTileHeight = 32,
297  kTileMaxHeight = 160,
298  kTileDX = (kTileWidth / 2),
299  kTileDY = (kTileHeight / 2),
300  kTileDXShift = 5,
301  kTileDYShift = 4,
302  kTileDXMask = (kTileDX - 1),
303  kTileDYMask = (kTileDY - 1),
304  kMaxTileHeight = 160
305 };
306 
307 // Size of a tile in ( U, V ) coords
308 
309 enum {
310  kTileUVSize = 16,
311  kTileUVShift = 4,
312  kTileZSize = 8,
313  kTileZShift = 3,
314  kTileUVMask = (kTileUVSize - 1)
315 };
316 
317 // Size of a map sector (4 metatiles x 4 metatiles)
318 
319 enum {
320  kSectorSize = kTileUVSize * 8 * 4,
321  kSectorShift = kTileUVShift + 3 + 2,
322  kSectorMask = (kSectorSize - 1)
323 };
324 
325 // Plaftorm metrics
326 enum {
327  kPlatformWidth = 8,
328  kPlatMask = kPlatformWidth - 1,
329  kPlatShift = 3,
330  kPlatUVSize = kTileUVSize * kPlatformWidth
331 };
332 
333 // Metatile metrics
334 enum {
335  kMetaTileWidth = kTileWidth * kPlatformWidth,
336  kMetaTileHeight = kTileHeight * kPlatformWidth,
337  kMetaDX = kMetaTileWidth / 2,
338  kMetaDY = kMetaTileHeight / 2
339 };
340 
341 enum {
342  kSubTileSize = 4,
343  kSubTileMask = kSubTileSize - 1,
344  kSubTileShift = 2,
345  kTileSubSize = 4,
346  kTileSubMask = kTileSubSize - 1,
347  kTileSubShift = 2
348 };
349 
350 // Constants to convert an X,Y into subtile coordinates
351 enum {
352  kSubTileDX = (kTileDX / 4),
353  kSubTileDY = (kTileDY / 4),
354  kSubTileDXShift = (kTileDXShift - 2),
355  kSubTileDYShift = (kTileDYShift - 2)
356 };
357 
358 enum {
359  kSubTileMaskUShift = 4,
360  kSubTileMaskVShift = 1
361 };
362 
363 // Maximum height that a character can climb w/o steps or ladders
364 enum {
365  kMaxStepHeight = 16, // highest climbable step
366  kMaxPickHeight = 64, // highest pickable step
367  kMaxSmoothStep = 8, // highest smoothly climbable
368  kMaxJumpStep = 64 // highest jump character likes
369 };
370 
371 
372 // Save/Load dialog metrics
373 
374 enum {
375  kNumSaveLoadPanels = 3,
376  kNumSaveLoadBtns = 4,
377  kNumSaveLoadTexts = 1,
378 
379  kSLDBoxXSize = 374,
380  kSLDBoxXSzNS = 366,
381  kSLDBoxYSize = 223,
382  kSLDBoxX = (640 - kSLDBoxXSize) / 2,
383  kSLDBoxY = (480 - kSLDBoxYSize) / 3,
384 
385  kSLTPHeight = 38,
386  kSLMDHeight = 122,
387  kSLBTHeight = 63,
388  kSLTPWidth = 374,
389  kSLMDWidth = 374,
390  kSLBTWidth = 374
391 };
392 
393 // Options dialog metrics
394 enum {
395  kNumOptionsPanels = 3,
396  kNumOptionsBtns = 9,
397  kNumOptionsTexts = 8,
398 
399  kOptBoxXSize = 487,
400  kOptBoxXSzNS = 479,
401  kOptBoxYSize = 230,
402  kOptBoxX = (640 - kOptBoxXSize) / 2,
403  kOptBoxY = (480 - kOptBoxYSize) / 3,
404 
405  kOptTPHeight = 39,
406  kOptMDHeight = 90,
407  kOptBTHeight = 101,
408  kOptTPWidth = 487,
409  kOptMDWidth = 487,
410  kOptBTWidth = 487
411 };
412 
413 // buttons
414 enum {
415  kButtonSpace = 3,
416  kButtonYOffset = kOptTPHeight + 7,
417  kPushButtonWidth = 121,
418  kPushButtonHeight = 30,
419 
420  kSliderWidth = 168,
421  kImageHeight = 17,
422 
423  kTextPixelLen = 175,
424  kSmallTextOffset = 80
425 };
426 
427 // Message Dialog Metrics
428 enum {
429  kNumMessagePanels = 1,
430  kNumMessageBtns = 3,
431  kNumMessageTexts = 2,
432  kMesBtnOffset = 14,
433 
434  kMesBoxXSize = 374,
435  kMesBoxXSzNS = 368,
436  kMesBoxYSize = 146,
437  kMesBoxX = (640 - kMesBoxXSize) / 2,
438  kMesBoxY = (480 - kMesBoxYSize) / 3
439 };
440 
441 //Sets Up Tile Map Area
442 enum {
443  kTileRectX = 16 + 4,
444  kTileRectY = 16 + 4,
445  kTileRectWidth = 448 - 8,
446  kTileRectHeight = 428 - 8
447 };
448 
449 // Horribly kludged hard-coded sprite index numbers for bubble sprites
450 enum {
451  kMaxActiveSpells = 8,
452  kBaseBubbleSpriteIndex = 111,
453  kBubbleSpriteCount = 8
454 };
455 
456 enum {
457  kPlayerActors = 3,
458  kMinAutoAggressionVitality = 5,
459  BASE_REC_RATE = 1
460 };
461 
462 enum {
463  kObjectVolumeArraySize = 128
464 };
465 
466 enum {
467  kDefaultReach = 24
468 };
469 
470 // Actor Constants
471 enum {
472  kMaxFactions = 64
473 };
474 
475 } // end of namespace Saga2
476 
477 #endif
Definition: idtypes.h:119
Definition: actor.h:32
Definition: idtypes.h:124
#define MKTAG(a0, a1, a2, a3)
Definition: endian.h:188
Definition: idtypes.h:73
Definition: idtypes.h:69