ScummVM API documentation
object.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 SCUMM_OBJECT_H
23 #define SCUMM_OBJECT_H
24 
25 namespace Scumm {
26 
27 static inline int OBJECT_V0(int id, byte type) {
28  assert(id < 256);
29  return (type << 8 | id);
30 }
31 #define OBJECT_V0_ID(obj) (obj & 0xFF)
32 #define OBJECT_V0_TYPE(obj) ((obj >> 8) & 0xFF)
33 
34 enum ObjectV0Type {
35  kObjectV0TypeFG = 0, // foreground object
36  // - with owner/state, might (but has not to) be pickupable
37  // -> with entry in _objectOwner/StateTable
38  // -> all objects in _inventory have this type
39  // - image can be exchanged (background overlay)
40  kObjectV0TypeBG = 1, // background object
41  // - without owner/state, not pickupable (room only)
42  // -> without entry in _objectOwner/StateTable
43  // - image cannot be exchanged (part of background image)
44  kObjectV0TypeActor = 2 // object is an actor
45 };
46 
47 enum ObjectClass {
48  kObjectClassNeverClip = 20,
49  kObjectClassAlwaysClip = 21,
50  kObjectClassIgnoreBoxes = 22,
51  kObjectClassYFlip = 29,
52  kObjectClassXFlip = 30,
53  kObjectClassPlayer = 31, // Actor is controlled by the player
54  kObjectClassUntouchable = 32
55 };
56 
57 enum ObjectStateV2 {
58  kObjectStatePickupable = 1,
59  kObjectStateUntouchable = 2,
60  kObjectStateLocked = 4,
61 
62  // FIXME: Not quite sure how to name state 8. It seems to mark some kind
63  // of "activation state" for the given object. E.g. is a door open?
64  // Is a drawer extended? In addition it is used to toggle the look
65  // of objects that the user can "pick up" (i.e. it is set in
66  // o2_pickupObject together with kObjectStateUntouchable). So in a sense,
67  // it can also mean "invisible" in some situations.
68  kObjectState_08 = 8
69 };
70 
71 struct ObjectData {
72  uint32 OBIMoffset;
73  uint32 OBCDoffset;
74  int16 walk_x, walk_y;
75  uint16 obj_nr;
76  int16 x_pos;
77  int16 y_pos;
78  uint16 width;
79  uint16 height;
80  byte actordir;
81  byte parent;
82  byte parentstate;
83  byte state;
84  byte fl_object_index;
85  byte flags;
86 };
87 
88 #include "common/pack-start.h" // START STRUCT PACKING
89 
90 struct RoomHeader {
91  union {
92  struct {
93  uint16 width, height;
94  uint16 numObjects;
95  } old;
96 
97  struct {
98  uint32 version;
99  uint16 width, height;
100  uint16 numObjects;
101  } v7;
102 
103  struct {
104  uint32 version;
105  uint32 width, height;
106  uint32 numObjects;
107  uint32 numZBuffer;
108  uint32 transparency;
109  } v8;
110  };
111 } PACKED_STRUCT;
112 
113 struct CodeHeader {
114  union {
115  struct {
116  uint16 obj_id;
117  byte x, y, w, h;
118  byte flags;
119  byte parent;
120  int16 walk_x;
121  int16 walk_y;
122  byte actordir;
123  } v5;
124 
125  struct {
126  uint16 obj_id;
127  int16 x, y;
128  uint16 w, h;
129  byte flags, parent;
130  uint16 unk1;
131  uint16 unk2;
132  byte actordir;
133  } v6;
134 
135  struct {
136  uint32 version;
137  uint16 obj_id;
138  byte parent;
139  byte parentstate;
140  } v7;
141 
142  };
143 } PACKED_STRUCT;
144 
145 struct ImageHeader { /* file format */
146  union {
147  struct {
148  uint16 obj_id;
149  uint16 image_count;
150  uint16 unk[1];
151  byte flags;
152  byte unk1;
153  uint16 unk2[2];
154  uint16 width;
155  uint16 height;
156  uint16 hotspot_num;
157  struct {
158  int16 x, y;
159  } hotspot[15];
160  } old;
161 
162  struct {
163  uint32 version;
164  uint16 obj_id;
165  uint16 image_count;
166  int16 x_pos, y_pos;
167  uint16 width, height;
168  byte unk2[3];
169  byte actordir;
170  uint16 hotspot_num;
171  struct {
172  int16 x, y;
173  } hotspot[15];
174  } v7;
175 
176  struct {
177  char name[32];
178  uint32 unk_1[2];
179  uint32 version; // 801 in COMI, 800 in the COMI demo
180  uint32 image_count;
181  uint32 x_pos;
182  uint32 y_pos;
183  uint32 width;
184  uint32 height;
185  uint32 actordir;
186  uint32 flags; // This field is missing in the COMI demo (version == 800) !
187  struct {
188  int32 x, y;
189  } hotspot[15];
190  } v8;
191  };
192 } PACKED_STRUCT;
193 
194 #include "common/pack-end.h" // END STRUCT PACKING
195 
197  const CodeHeader *cdhd;
198  const byte *obcd;
199  const byte *obim;
200  const byte *roomptr;
201 };
202 
203 enum FindObjectWhat {
204  foCodeHeader = 1,
205  foImageHeader = 2,
206  foCheckAlreadyLoaded = 4
207 };
208 
209 } // End of namespace Scumm
210 
211 
212 #endif
Definition: object.h:90
Definition: object.h:145
Definition: object.h:196
Definition: object.h:71
Definition: actor.h:30
Definition: object.h:113