ScummVM API documentation
pc_props.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  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 3 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program. If not, see <http://www.gnu.org/licenses/>.
24  *
25  */
26 
27 #ifndef ICB_PC_PROPS_H
28 #define ICB_PC_PROPS_H
29 
30 #include "engines/icb/common/px_staticlayers.h" // for types + defines
31 #include "engines/icb/common/px_types.h"
32 
33 namespace ICB {
34 
35 #define PCPROP_SCHEMA 3
36 #define PCPROP_ID MKTAG('p', 'o', 'r', 'P')
37 
38 #define PCINTERACTIBLE_SCHEMA 2
39 #define PCINTERACTIBLE_ID MKTAG('k', 'c', 'a', 'T')
40 
41 #define PCSETFILE_ID_ICB MKTAG('t', 'n', 'i', 'm')
42 #define PCSETFILE_ID_ELDORADO MKTAG('t', 'n', 'i', 'p')
43 
44 typedef struct _pcSetHeader {
45  uint32 id;
46  uint32 cameraOffset;
47  uint32 lightOffset;
48  uint32 propOffset;
49  uint32 layerOffset;
50  uint32 backgroundOffset;
51  uint32 interactiblesOffset;
52 } _pcSetHeader;
53 
55 private:
56  char name[32];
57  int32 width;
58  int32 height;
59  int32 x;
60  int32 y;
61  uint8 *mask;
62 
63 public:
64  pcInteractible(uint8 *interactiblePtr) {
65  uint8 *ptr = interactiblePtr;
66 
67  memcpy(name, ptr, 32);
68  ptr += 32;
69 
70  width = (int32)READ_LE_U32(ptr);
71  ptr += 4;
72 
73  height = (int32)READ_LE_U32(ptr);
74  ptr += 4;
75 
76  x = (int32)READ_LE_U32(ptr);
77  ptr += 4;
78 
79  y = (int32)READ_LE_U32(ptr);
80  ptr += 4;
81 
82  mask = ptr;
83  }
84 };
85 
87 private:
88  uint32 id;
89  uint32 schema;
90  uint32 mapping;
91  uint32 quantity;
92  pcInteractible **interactibles;
93 
94 public:
95  pcInteractibleFile() : id(PCINTERACTIBLE_ID), schema(PCINTERACTIBLE_SCHEMA), mapping(0), quantity(0), interactibles(nullptr) {}
96 
97  pcInteractibleFile(uint8 *interactibleData) {
98  uint8 *ptr = interactibleData;
99 
100  id = READ_LE_U32(ptr);
101  ptr += 4;
102 
103  schema = READ_LE_U32(ptr);
104  ptr += 4;
105 
106  mapping = READ_LE_U32(ptr);
107  ptr += 4;
108 
109  quantity = READ_LE_U32(ptr);
110  ptr += 4;
111 
112  interactibles = new pcInteractible *[quantity];
113  for (uint32 i = 0; i < quantity; i++) {
114  interactibles[i] = new pcInteractible(interactibleData + READ_LE_U32(ptr));
115  ptr += 4;
116  }
117  }
118 
119  ~pcInteractibleFile() {
120  for (uint32 i = 0; i < quantity; i++) {
121  delete interactibles[i];
122  }
123  delete[] interactibles;
124  interactibles = 0;
125  }
126 
127  uint32 GetID() { return id; }
128  void SetId(uint32 i) { id = i; }
129  uint32 GetQty() { return quantity; }
130  void SetQty(uint32 q) { quantity = q; }
131  pcInteractible *GetInt(uint32 i) { return interactibles[i]; }
132  void SetSchema(uint32 s) { schema = s; }
133  uint32 GetSchema() const {
134  if (id != PCINTERACTIBLE_ID)
135  return 0;
136  else
137  return schema;
138  }
139 };
140 
142 private:
143  uint16 *zPtrs[TILE_COUNT];
144  uint16 *semiPtrs[TILE_COUNT];
145  uint16 nLRBgTiles;
146  uint16 nLRFgTiles;
147  uint16 nHRBgTiles;
148  uint16 nHRFgTiles;
149  uint32 *palettePtr;
150  uint16 bgLRSurfaceWidth;
151  uint16 bgLRSurfaceHeight;
152  uint16 fgLRSurfaceWidth;
153  uint16 fgLRSurfaceHeight;
154  uint16 bgHRSurfaceWidth;
155  uint16 bgHRSurfaceHeight;
156  uint16 fgHRSurfaceWidth;
157  uint16 fgHRSurfaceHeight;
158  uint8 *bgLRRleDataPtr;
159  uint8 *fgLRRleDataPtr;
160  uint8 *bgHRRleDataPtr;
161  uint8 *fgHRRleDataPtr;
162  LRECT *tileRects;
163 public:
164  pcPropRGBState(uint8 *propBasePtr, uint32 dataOffset) {
165  uint8 *ptr = propBasePtr + dataOffset;
166 
167  for (int32 i = 0; i < TILE_COUNT; i++) {
168  zPtrs[i] = 0;
169  if (uint32 offset = READ_LE_U32(ptr)) {
170  zPtrs[i] = (uint16 *)(propBasePtr + offset);
171  }
172  ptr += 4;
173  }
174 
175  for (int32 i = 0; i < TILE_COUNT; i++) {
176  semiPtrs[i] = 0;
177  if (uint32 offset = READ_LE_U32(ptr)) {
178  semiPtrs[i] = (uint16 *)(propBasePtr + offset);
179  }
180  ptr += 4;
181  }
182 
183  nLRBgTiles = READ_LE_U16(ptr);
184  ptr += 2;
185 
186  nLRFgTiles = READ_LE_U16(ptr);
187  ptr += 2;
188 
189  nHRBgTiles = READ_LE_U16(ptr);
190  ptr += 2;
191 
192  nHRFgTiles = READ_LE_U16(ptr);
193  ptr += 2;
194 
195  palettePtr = (uint32 *)(propBasePtr + READ_LE_U32(ptr));
196  ptr += 4;
197 
198  bgLRSurfaceWidth = READ_LE_U16(ptr);
199  ptr += 2;
200 
201  bgLRSurfaceHeight = READ_LE_U16(ptr);
202  ptr += 2;
203 
204  fgLRSurfaceWidth = READ_LE_U16(ptr);
205  ptr += 2;
206 
207  fgLRSurfaceHeight = READ_LE_U16(ptr);
208  ptr += 2;
209 
210  bgHRSurfaceWidth = READ_LE_U16(ptr);
211  ptr += 2;
212 
213  bgHRSurfaceHeight = READ_LE_U16(ptr);
214  ptr += 2;
215 
216  fgHRSurfaceWidth = READ_LE_U16(ptr);
217  ptr += 2;
218 
219  fgHRSurfaceHeight = READ_LE_U16(ptr);
220  ptr += 2;
221 
222  bgLRRleDataPtr = propBasePtr + READ_LE_U32(ptr);
223  ptr += 4;
224 
225  fgLRRleDataPtr = propBasePtr + READ_LE_U32(ptr);
226  ptr += 4;
227 
228  bgHRRleDataPtr = propBasePtr + READ_LE_U32(ptr);
229  ptr += 4;
230 
231  fgHRRleDataPtr = propBasePtr + READ_LE_U32(ptr);
232  ptr += 4;
233 
234  tileRects = (LRECT *)ptr;
235  }
236 
237  uint16 *GetZTileTable(int32 t) { return zPtrs[t]; }
238  uint16 *GetSemiTileTable(int32 t) { return semiPtrs[t]; }
239  uint16 GetLRBgTileQty() { return nLRBgTiles; }
240  uint16 GetLRFgTileQty() { return nLRFgTiles; }
241  uint16 GetHRBgTileQty() { return nHRBgTiles; }
242  uint16 GetHRFgTileQty() { return nHRFgTiles; }
243  uint32 *GetPalette() { return palettePtr; }
244  uint16 GetLRBgSurfaceWidth() { return bgLRSurfaceWidth; }
245  uint16 GetLRBgSurfaceHeight() { return bgLRSurfaceHeight; }
246  uint16 GetLRFgSurfaceWidth() { return fgLRSurfaceWidth; }
247  uint16 GetLRFgSurfaceHeight() { return fgLRSurfaceHeight; }
248  uint16 GetHRBgSurfaceWidth() { return bgHRSurfaceWidth; }
249  uint16 GetHRBgSurfaceHeight() { return bgHRSurfaceHeight; }
250  uint16 GetHRFgSurfaceWidth() { return fgHRSurfaceWidth; }
251  uint16 GetHRFgSurfaceHeight() { return fgHRSurfaceHeight; }
252  uint8 *GetLRBgRlePtr() { return bgLRRleDataPtr; }
253  uint8 *GetLRFgRlePtr() { return fgLRRleDataPtr; }
254  uint8 *GetHRBgRlePtr() { return bgHRRleDataPtr; }
255  uint8 *GetHRFgRlePtr() { return fgHRRleDataPtr; }
256  LRECT *GetTileRects() { return tileRects; }
257 };
258 
259 class pcPropRGB {
260 private:
261  char name[32];
262  uint32 stateQty;
263  pcPropRGBState **states;
264 
265 public:
266  pcPropRGB(uint8 *propBasePtr, uint32 dataOffset) {
267  uint8 *ptr = propBasePtr + dataOffset;
268 
269  memcpy(name, ptr, 32);
270  ptr += 32;
271 
272  stateQty = READ_LE_U32(ptr);
273  ptr += 4;
274 
275  states = new pcPropRGBState *[stateQty];
276  for (uint32 i = 0; i < stateQty; i++) {
277  states[i] = new pcPropRGBState(propBasePtr, READ_LE_U32(ptr));
278  ptr += 4;
279  }
280  }
281 
282  ~pcPropRGB() {
283  for (uint32 i = 0; i < stateQty; i++) {
284  delete states[i];
285  }
286  delete[] states;
287  states = 0;
288  }
289 
290  const char *GetName() const { return name; }
291  uint32 GetStateQty() const { return stateQty; }
292  pcPropRGBState *GetState(uint32 s) { return states[s]; }
293 };
294 
295 class pcPropFile {
296 private:
297  uint32 id;
298  uint32 schema;
299  uint32 mapping;
300  uint32 propQty;
301  pcPropRGB **props;
302 
303 public:
304  pcPropFile(uint8 *propData) {
305  uint8 *ptr = propData;
306 
307  id = READ_LE_U32(ptr);
308  ptr += 4;
309 
310  schema = READ_LE_U32(ptr);
311  ptr += 4;
312 
313  mapping = READ_LE_U32(ptr);
314  ptr += 4;
315 
316  propQty = READ_LE_U32(ptr);
317  ptr += 4;
318 
319  props = new pcPropRGB *[propQty];
320  for (uint32 i = 0; i < propQty; i++) {
321  props[i] = new pcPropRGB(propData, READ_LE_U32(ptr));
322  ptr += 4;
323  }
324  }
325 
326  ~pcPropFile() {
327  for (uint32 i = 0; i < propQty; i++) {
328  delete props[i];
329  }
330  delete[] props;
331  props = 0;
332  }
333 
334  uint32 GetId() const { return id; }
335  uint32 GetPropQty() const { return propQty; }
336  pcPropRGB *GetProp(uint32 p) { return props[p]; }
337  uint32 GetSchema() const {
338  if (id != PCPROP_ID)
339  return 0;
340  else
341  return schema;
342  }
343 };
344 
345 } // End of namespace ICB
346 
347 #endif // #ifndef PC_PROPS_H
Definition: pc_props.h:86
Definition: pc_props.h:259
Definition: actor.h:32
Definition: pc_props.h:141
Definition: pc_props.h:44
Definition: pc_props.h:295
Definition: px_types.h:32
Definition: pc_props.h:54