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
30namespace Tinsel {
31
32struct PALQ;
33
34enum {
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
59struct IMAGE {
60 short imgWidth;
61 unsigned short imgHeight;
62 short anioffX;
63 short anioffY;
66 short isRLE;
67 short colorFlags;
68};
69
71typedef uint32 FRAME;
72
73// object structure
74struct 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;
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
126struct 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
139void KillAllObjects(); // kill all objects and place them on free list
140
141void FreeObjectList(); // free the object list
142
143#ifdef DEBUG
144void ObjectStats(); // Shows the maximum number of objects used at once
145#endif
146
147OBJECT *AllocObject(); // allocate a object from the free list
148
149void FreeObject( // place a object back on the free list
150 OBJECT *pFreeObj); // object to free
151
152bool isValidObject(OBJECT *obj);
153
154void CopyObject( // copy one object to another
155 OBJECT *pDest, // destination object
156 OBJECT *pSrc); // source object
157
158void InsertObject( // insert a object onto a sorted object list
159 OBJECT **pObjList, // list to insert object onto
160 OBJECT *pInsObj); // object to insert
161
162void 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
166void SortObjectList( // re-sort an object list
167 OBJECT **pObjList); // list to sort
168
169void 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
175void 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
180OBJECT *InitObject( // Init a object using a OBJ_INIT struct
181 const OBJ_INIT *pInitTbl); // pointer to object initialisation table
182
183void 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
188void AnimateObject( // give a object a new image
189 OBJECT *pAniObj, // object to animate
190 SCNHANDLE hNewImg); // objects new image
191
192void HideObject( // Hides a object by giving it a "NullImage" image pointer
193 OBJECT *pObj); // object to be hidden
194
195OBJECT *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
201OBJECT *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
int32 frac_t
Definition: frac.h:52
Definition: actors.h:36
@ DMA_ABS
position of object is absolute
Definition: object.h:48
@ DMA_WNZ
write non-zero data
Definition: object.h:39
@ DMA_FLIPH
flip object horizontally
Definition: object.h:44
@ DMA_3D
3D objects for TinselV3
Definition: object.h:52
@ DMA_FLIPV
flip object vertically
Definition: object.h:45
@ DMA_CLIP
clip object
Definition: object.h:46
@ DMA_CHANGED
object has changed in some way since the last frame
Definition: object.h:49
@ DMA_HARDFLAGS
Definition: object.h:55
@ DMA_CONST
write constant on both zero & non-zero data
Definition: object.h:42
@ DMA_TRANS
translucent rectangle object
Definition: object.h:47
@ NUM_OBJECTS
Definition: object.h:36
@ DMA_RLWA
TenselV2+ run-length write all.
Definition: object.h:41
@ DMA_WA
write all data
Definition: object.h:43
@ DMA_CNZ
TinselV1 write constant on non-zero data.
Definition: object.h:40
@ DMA_USERDEF
user defined flags start here
Definition: object.h:50
uint32 SCNHANDLE
Definition: dw.h:31
uint32 FRAME
Definition: object.h:71
T right
Definition: rect.h:171
T left
Definition: rect.h:170
Definition: rect.h:536
Definition: object.h:59
short anioffY
image y animation offset
Definition: object.h:63
unsigned short imgHeight
image height
Definition: object.h:61
short anioffX
image x animation offset
Definition: object.h:62
short isRLE
if image is using run-length encoding (Tinsel V3)
Definition: object.h:66
SCNHANDLE hImgBits
image bitmap handle
Definition: object.h:64
SCNHANDLE hImgPal
image palette handle (Tinsel V1/V2)
Definition: object.h:65
short colorFlags
type of blending (Tinsel V3)
Definition: object.h:67
short imgWidth
image width
Definition: object.h:60
Definition: object.h:126
Definition: object.h:74
int constant
TinselV3, type of color blending.
Definition: object.h:88
int flags
object flags - see above for list
Definition: object.h:84
frac_t yPos
y position of object
Definition: object.h:81
Common::Rect rcPrev
previous screen coordinates of object bounding rectangle
Definition: object.h:83
PALQ * pPal
objects palette Q position
Definition: object.h:85
SCNHANDLE hImg
handle to object image definition
Definition: object.h:92
frac_t xPos
x position of object
Definition: object.h:80
SCNHANDLE hBits
image bitmap handle
Definition: object.h:91
int width
width of object
Definition: object.h:89
int oid
object identifier
Definition: object.h:95
int zPos
z position of object
Definition: object.h:82
SCNHANDLE hMirror
objects previous animation frame
Definition: object.h:94
OBJECT * pNext
pointer to next object in list
Definition: object.h:75
OBJECT * pSlave
pointer to slave object (multi-part objects)
Definition: object.h:76
int height
height of object
Definition: object.h:90
SCNHANDLE hShape
objects current animation frame
Definition: object.h:93
short isRLE
TinselVersion == 3, if image is using run-length encoding.
Definition: object.h:86
Definition: palette.h:69