ScummVM API documentation
psx_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_PSX_PROPS_H
28 #define ICB_PSX_PROPS_H
29 
30 #include "engines/icb/gfx/psx_pcdefines.h"
31 
32 #define PSXPL_SCHEMA 4
33 #define PSXPL_ID "PLF"
34 
35 #include "engines/icb/gfx/psx_zlayers.h"
36 #include "engines/icb/common/px_bitmap_psx.h"
37 
38 namespace ICB {
39 
40 // schema 0 file format is
41 /*
42  uint32 schema;
43  uint32 propQty;
44  uint32 cmQty;
45  uint32 cmOffsets[nCms]; // cmOffsets[nCms];
46  propcmStruct props[propQty];
47  {
48  char* name;
49  uint32 stateQty;
50  }
51  // This is the actual construction matrix and where the cmOffsets point to
52  cmStruct cm[cmQty];
53  {
54  uint32 propQty; // currently always 1 but is likely to change
55  uint32 propNameOffset;
56  uint32 width; // how many bits in the CM table
57  uint32 stateQty; // how many states
58  uint32 statePtrs[stateQty]; // points to a psxPropLayers struct
59  {
60  int16 xs, xe;
61  int16 ys, ye;
62  uint16 zs, ze;
63  uint16 w, h;
64  uint32 n;
65  uint32 zoverlayOffset; // relative bytes from state start to zoverlay
66  uint32 zOffset; // relative bytes from state start to z data;
67  uint16 palette[256];
68  uint8 rgbData[w*h]
69  uint8 zdata[w*h];
70  psxZOverlay layers[n]
71  {
72  int16 xs, xe;
73  int16 ys, ye;
74  uint16 zs, ze;
75  uint16 dZScale, dZShift;
76  }
77  }
78  }
79 */
80 
81 // schema 1 file format is
82 /*
83  char id[4];
84  uint32 schema;
85  uint32 propQty;
86  uint32 cmQty;
87  uint32 cmOffsets[nCms]; // cmOffsets[nCms];
88  propcmStruct props[propQty];
89  {
90  char* name;
91  uint32 stateQty;
92  }
93  // This is the actual construction matrix and where the cmOffsets point to
94  cmStruct cm[cmQty];
95  {
96  uint32 propQty; // currently always 1 but is likely to change
97  uint32 propNameOffset;
98  uint32 width; // how many bits in the CM table
99  uint32 stateQty; // how many states
100  uint32 statePtrs[stateQty]; // points to a psxPropLayers struct
101  {
102  int16 xs, xe;
103  int16 ys, ye;
104  uint16 zs, ze;
105  uint16 w, h;
106  uint32 n;
107  uint32 zoverlayOffset; // relative bytes from state start to zoverlay
108  uint32 zOffset; // relative bytes from state start to z data;
109  _pxPSXBitmap bitmap; // compress PSX Bitmap format inc. palette
110  uint8 zdata[w*h];
111  psxZOverlay layers[n]
112  {
113  int16 xs, xe;
114  int16 ys, ye;
115  uint16 zs, ze;
116  uint16 dZScale, dZShift;
117  }
118  }
119  }
120 */
121 
122 // schema 2 file format is
123 /*
124  char id[4];
125  uint32 schema;
126  uint32 propQty;
127  uint32 propOffsets[propQty]; // propOffsets[propQty];
128  psxPropInfo propInfo[propQty];
129  {
130  char* name;
131  uint32 stateQty;
132  }
133  psxProp props[propQty];
134  {
135  uint32 stateQty; // how many states
136  uint32 propNameOffset;
137  uint32 statePtrs[stateQty]; // points to a psxPropState struct
138  psxPropState propStates[stateQty];
139  {
140  int16 xs, xe;
141  int16 ys, ye;
142  uint16 zs, ze;
143  uint16 w, h;
144  uint16 nPropRGBsprites;
145  uint16 nBgRGBsprites;
146  _pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette
147  }
148  }
149 */
150 
151 // schema 3 file format is
152 /*
153  char id[4];
154  uint32 schema;
155  uint32 propQty;
156  uint32 propOffsets[propQty]; // propOffsets[propQty];
157  psxPropInfo propInfo[propQty];
158  {
159  char* name;
160  uint32 stateQty;
161  }
162  psxProp props[propQty];
163  {
164  uint32 stateQty; // how many states
165  uint32 propNameOffset;
166  uint32 statePtrs[stateQty]; // points to a psxPropState struct
167  psxPropState propStates[stateQty];
168  {
169  int16 xs, xe;
170  int16 ys, ye;
171  uint16 zs, ze;
172  uint16 w, h;
173  uint16 nPropRGBsprites;
174  uint16 nBgRGBsprites;
175  uint32 zMicroOffset;
176  uint32 propBitmapOffset;
177  psxZMacroFrag zMacro[nPropRGBsprites];
178  psxZMicroFrag zMicro[nMicroFrags];
179  _pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette
180  }
181  }
182 */
183 
184 // schema 4 file format is
185 /*
186  char id[4];
187  uint32 schema;
188  uint32 propQty;
189  uint32 propOffsets[propQty]; // propOffsets[propQty];
190  psxPropInfo propInfo[propQty];
191  {
192  char* name;
193  uint32 stateQty;
194  }
195  psxProp props[propQty];
196  {
197  uint32 stateQty; // how many states
198  uint32 propNameOffset;
199  uint32 statePtrs[stateQty]; // points to a psxPropState struct
200  psxPropState propStates[stateQty];
201  {
202  int16 xs, xe;
203  int16 ys, ye;
204  uint16 zs, ze;
205  uint16 w, h;
206 
207  uint16 nPropZsprites;
208  uint16 nPropFGZsprites;
209  uint16 nPropBGZsprites;
210  uint16 padding;
211 
212  uint16 nPropRGBsprites;
213  uint16 nBgRGBsprites;
214  uint32 zMicroOffset;
215  uint32 propBitmapOffset;
216  psxZMacroFrag zMacro[nPropRGBsprites];
217  psxZMicroFrag zMicro[nMicroFrags];
218  _pxPSXBitmap propBitmap; // compressed PSX Bitmap inc. palette
219  }
220  }
221 */
222 
223 // z information about the macroscopic fragments
224 // (which are the RGB tiles within the psxBitmap structure)
225 // plus hooks into the microscopic z-data information
226 //
227 // These are currently a maximum of 64x64 big
228 typedef struct psxZMacroFrag {
229  uint32 realzs; // in real z-coordinates e.g. not culled z-data for prop drawing order
230  uint16 zs, ze;
231  uint16 microStart;
232  uint16 nMicro;
233 } psxZMacroFrag;
234 
235 // z information about the microscopic fragments
236 // (which are the RGB tiles split into smaller tiles (very simple binary sub-division) until the z-range
237 // within the tile is within a tolerance - and so the microscopic fragment can be drawn at a single z value
238 //
239 // These microscopic tiles use x,y relative to the macroscopic fragment to save on bit storage for x,y
240 // e.g. gets it down to two int's instead of 3 !
241 typedef struct psxZMicroFrag {
242  uint16 zs, ze; // store zs & ze just because otherwise we have a short of padding !
243  uint8 xoff, yoff;
244  uint8 w, h;
245 } psxZMicroFrag;
246 
247 // The most basic information about a prop which current is just its name
248 typedef struct psxPropInfo { char *name; } psxPropInfo;
249 
250 // This structure is overlaid ontop of the prop file which is read
251 // in from disc/CD
252 typedef struct psxProp {
253  uint32 propNameOffset; // pointer to where the name is stored
254  uint32 stateQty; // how many states
255  uint32 statePtrs[1]; // statePtrs[stateQty]
256 } psxProp;
257 
258 typedef struct psxPropState {
259  int16 xs, xe;
260  int16 ys, ye;
261  uint16 zs, ze;
262  uint16 w, h;
263 
264  uint16 nPropZsprites;
265  uint16 nPropFGZsprites;
266  uint16 nPropBGZsprites;
267  uint16 padding;
268 
269  uint16 nPropRGBsprites;
270  uint16 nBgRGBsprites;
271 
272  uint32 zMicroOffset;
273  uint32 propBitmapOffset;
274  psxZMacroFrag zMacro[1];
275 
276  inline psxZMacroFrag *GetZMacroFragPtr(void);
277  inline psxZMicroFrag *GetZMicroFragPtr(void);
278  inline _pxPSXBitmap *GetPropBitmapPtr(void);
279 
280  psxPropState() { ; }
281 
282 private:
283  // Make '=' and copy constructor private to stop accidental assignment.
284  psxPropState(const psxPropState &) { ; }
285  void operator=(const psxPropState &) { ; }
286 
287 } psxPropState;
288 
289 inline psxZMacroFrag *psxPropState::GetZMacroFragPtr(void) { return zMacro; }
290 
291 inline psxZMicroFrag *psxPropState::GetZMicroFragPtr(void) {
292  psxZMicroFrag *zMicro = (psxZMicroFrag *)((uint8 *)this + zMicroOffset);
293  return zMicro;
294 }
295 
296 inline _pxPSXBitmap *psxPropState::GetPropBitmapPtr(void) {
297  _pxPSXBitmap *propBitmap = (_pxPSXBitmap *)((uint8 *)this + propBitmapOffset);
298  return propBitmap;
299 }
300 
301 // Note these cannot be well represented by a C struct
302 // as they are full of variable length arrays
303 typedef struct psxPLfile {
304  char id[4];
305  uint32 schema;
306  uint32 propQty;
307  uint32 propOffsets[1];
308 
309  inline psxProp *GetProp(uint32 prop);
310  inline uint32 GetPropStateQty(uint32 prop);
311  inline char *GetPropName(uint32 prop);
312  inline psxPropState *GetPropState(uint32 prop, uint32 state);
313 } psxPLfile;
314 
315 inline psxProp *psxPLfile::GetProp(uint32 prop) { return (psxProp *)((uint8 *)id + propOffsets[prop]); }
316 
317 inline uint32 psxPLfile::GetPropStateQty(uint32 prop) {
318  psxProp *pProp = GetProp(prop);
319  return pProp->stateQty;
320 }
321 
322 inline char *psxPLfile::GetPropName(uint32 prop) {
323  psxProp *pProp = GetProp(prop);
324  return (id + pProp->propNameOffset);
325 }
326 
327 inline psxPropState *psxPLfile::GetPropState(uint32 prop, uint32 state) {
328  psxProp *pProp = GetProp(prop);
329  return (psxPropState *)((uint8 *)id + pProp->statePtrs[state]);
330 }
331 
332 } // End of namespace ICB
333 
334 #endif // #ifndef PSX_PROPS_H
Definition: actor.h:32
Definition: psx_props.h:258
Definition: psx_props.h:241
Definition: psx_props.h:228
Definition: psx_props.h:303
Definition: psx_props.h:252
Definition: psx_props.h:248