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  * Object Manager data structures
21  */
22 
23 #ifndef TINSEL_OBJECT_H // prevent multiple includes
24 #define TINSEL_OBJECT_H
25 
26 #include "tinsel/dw.h"
27 #include "common/frac.h"
28 #include "common/rect.h"
29 
30 namespace Tinsel {
31 
32 struct PALQ;
33 
34 enum {
36  NUM_OBJECTS = 512,
37 
38  // object flags
39  DMA_WNZ = 0x0001,
40  DMA_CNZ = 0x0002,
41  DMA_RLWA = 0x0002,
42  DMA_CONST = 0x0004,
43  DMA_WA = 0x0008,
44  DMA_FLIPH = 0x0010,
45  DMA_FLIPV = 0x0020,
46  DMA_CLIP = 0x0040,
47  DMA_TRANS = 0x0084,
48  DMA_ABS = 0x0100,
49  DMA_CHANGED = 0x0200,
50  DMA_USERDEF = 0x0400,
51  DMA_GHOST = 0x0080,
52  DMA_3D = 0x0400,
53 
56 };
57 
59 struct IMAGE {
60  short imgWidth;
61  unsigned short imgHeight;
62  short anioffX;
63  short anioffY;
66  short isRLE;
67  short colorFlags;
68 };
69 
71 typedef uint32 FRAME;
72 
73 // object structure
74 struct OBJECT {
77 // char *pOnDispList; ///< pointer to display list byte for background objects
78 // frac_t xVel; ///< x velocity of object
79 // frac_t yVel; ///< y velocity of object
82  int zPos;
84  int flags;
86  short isRLE;
87  short colorFlags;
88  int constant;
89  int width;
90  int height;
95  int oid;
96 
97  void reset() {
98  pNext = nullptr;
99  pSlave = nullptr;
100  //pOnDispList = nullptr;
101  //xVel = 0;
102  //yVel = 0;
103  xPos = 0;
104  yPos = 0;
105  zPos = 0;
106  rcPrev.top = 0;
107  rcPrev.left = 0;
108  rcPrev.bottom = 0;
109  rcPrev.right = 0;
110  flags = 0;
111  pPal = nullptr;
112  constant = 0;
113  width = 0;
114  height = 0;
115  hBits = 0;
116  hImg = 0;
117  hShape = 0;
118  hMirror = 0;
119  oid = 0;
120  }
121 
122  OBJECT() { reset(); }
123 };
124 
125 // object initialisation structure
126 struct OBJ_INIT {
127  SCNHANDLE hObjImg; // objects shape - handle to IMAGE structure
128  int32 objFlags; // objects flags
129  int32 objID; // objects id
130  int32 objX; // objects initial x position
131  int32 objY; // objects initial y position
132  int32 objZ; // objects initial z position
133 };
134 
135 /*----------------------------------------------------------------------*\
136 |* Object Function Prototypes *|
137 \*----------------------------------------------------------------------*/
138 
139 void KillAllObjects(); // kill all objects and place them on free list
140 
141 void FreeObjectList(); // free the object list
142 
143 #ifdef DEBUG
144 void ObjectStats(); // Shows the maximum number of objects used at once
145 #endif
146 
147 OBJECT *AllocObject(); // allocate a object from the free list
148 
149 void FreeObject( // place a object back on the free list
150  OBJECT *pFreeObj); // object to free
151 
152 bool isValidObject(OBJECT *obj);
153 
154 void CopyObject( // copy one object to another
155  OBJECT *pDest, // destination object
156  OBJECT *pSrc); // source object
157 
158 void InsertObject( // insert a object onto a sorted object list
159  OBJECT **pObjList, // list to insert object onto
160  OBJECT *pInsObj); // object to insert
161 
162 void DelObject( // delete a object from a object list and add to free list
163  OBJECT **pObjList, // list to delete object from
164  OBJECT *pDelObj); // object to delete
165 
166 void SortObjectList( // re-sort an object list
167  OBJECT **pObjList); // list to sort
168 
169 void GetAniOffset( // returns the anim offsets of a image, takes into account orientation
170  SCNHANDLE hImg, // image to get animation offset of
171  int flags, // images current flags
172  int *pAniX, // gets set to new X animation offset
173  int *pAniY); // gets set to new Y animation offset
174 
175 void GetAniPosition( // Returns a objects x,y animation point
176  OBJECT *pObj, // pointer to object
177  int *pPosX, // gets set to objects X animation position
178  int *pPosY); // gets set to objects Y animation position
179 
180 OBJECT *InitObject( // Init a object using a OBJ_INIT struct
181  const OBJ_INIT *pInitTbl); // pointer to object initialisation table
182 
183 void AnimateObjectFlags( // Give a object a new image and new orientation flags
184  OBJECT *pAniObj, // object to be updated
185  int newflags, // objects new flags
186  SCNHANDLE hNewImg); // objects new image
187 
188 void AnimateObject( // give a object a new image
189  OBJECT *pAniObj, // object to animate
190  SCNHANDLE hNewImg); // objects new image
191 
192 void HideObject( // Hides a object by giving it a "NullImage" image pointer
193  OBJECT *pObj); // object to be hidden
194 
195 OBJECT *RectangleObject( // create a rectangle object of the given dimensions
196  SCNHANDLE hPal, // palette for the rectangle object
197  int color, // which color offset from the above palette
198  int width, // width of rectangle
199  int height); // height of rectangle
200 
201 OBJECT *TranslucentObject( // create a translucent rectangle object of the given dimensions
202  int width, // width of rectangle
203  int height); // height of rectangle
204 
205 } // End of namespace Tinsel
206 
207 #endif // TINSEL_OBJECT_H
translucent rectangle object
Definition: object.h:47
SCNHANDLE hShape
objects current animation frame
Definition: object.h:93
3D objects for TinselV3
Definition: object.h:52
flip object horizontally
Definition: object.h:44
SCNHANDLE hImgBits
image bitmap handle
Definition: object.h:64
short anioffY
image y animation offset
Definition: object.h:63
short colorFlags
type of blending (Tinsel V3)
Definition: object.h:67
Definition: palette.h:69
uint32 SCNHANDLE
Definition: dw.h:31
short anioffX
image x animation offset
Definition: object.h:62
write non-zero data
Definition: object.h:39
frac_t yPos
y position of object
Definition: object.h:81
Definition: object.h:126
int16 right
Definition: rect.h:146
Common::Rect rcPrev
previous screen coordinates of object bounding rectangle
Definition: object.h:83
SCNHANDLE hImg
handle to object image definition
Definition: object.h:92
Definition: object.h:59
Definition: rect.h:144
OBJECT * pSlave
pointer to slave object (multi-part objects)
Definition: object.h:76
short isRLE
TinselVersion == 3, if image is using run-length encoding.
Definition: object.h:86
int oid
object identifier
Definition: object.h:95
OBJECT * pNext
pointer to next object in list
Definition: object.h:75
TenselV2+ run-length write all.
Definition: object.h:41
write all data
Definition: object.h:43
frac_t xPos
x position of object
Definition: object.h:80
int width
width of object
Definition: object.h:89
unsigned short imgHeight
image height
Definition: object.h:61
object has changed in some way since the last frame
Definition: object.h:49
Definition: object.h:36
Definition: object.h:74
clip object
Definition: object.h:46
uint32 FRAME
Definition: object.h:71
int zPos
z position of object
Definition: object.h:82
flip object vertically
Definition: object.h:45
Definition: object.h:55
Definition: actors.h:36
int16 left
Definition: rect.h:145
int height
height of object
Definition: object.h:90
user defined flags start here
Definition: object.h:50
int constant
TinselV3, type of color blending.
Definition: object.h:88
position of object is absolute
Definition: object.h:48
write constant on both zero & non-zero data
Definition: object.h:42
short imgWidth
image width
Definition: object.h:60
PALQ * pPal
objects palette Q position
Definition: object.h:85
SCNHANDLE hImgPal
image palette handle (Tinsel V1/V2)
Definition: object.h:65
SCNHANDLE hBits
image bitmap handle
Definition: object.h:91
int32 frac_t
Definition: frac.h:52
short isRLE
if image is using run-length encoding (Tinsel V3)
Definition: object.h:66
SCNHANDLE hMirror
objects previous animation frame
Definition: object.h:94
int flags
object flags - see above for list
Definition: object.h:84
TinselV1 write constant on non-zero data.
Definition: object.h:40