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