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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * Object Manager data structures 22 */ 23 24 #ifndef TINSEL_OBJECT_H // prevent multiple includes 25 #define TINSEL_OBJECT_H 26 27 #include "tinsel/dw.h" 28 #include "common/frac.h" 29 #include "common/rect.h" 30 31 namespace Tinsel { 32 33 struct PALQ; 34 35 enum { 36 /** the maximum number of objects */ 37 NUM_OBJECTS = 512, 38 39 // object flags 40 DMA_WNZ = 0x0001, ///< write non-zero data 41 DMA_CNZ = 0x0002, ///< write constant on non-zero data 42 DMA_CONST = 0x0004, ///< write constant on both zero & non-zero data 43 DMA_WA = 0x0008, ///< write all data 44 DMA_FLIPH = 0x0010, ///< flip object horizontally 45 DMA_FLIPV = 0x0020, ///< flip object vertically 46 DMA_CLIP = 0x0040, ///< clip object 47 DMA_TRANS = 0x0084, ///< translucent rectangle object 48 DMA_ABS = 0x0100, ///< position of object is absolute 49 DMA_CHANGED = 0x0200, ///< object has changed in some way since the last frame 50 DMA_USERDEF = 0x0400, ///< user defined flags start here 51 DMA_GHOST = 0x0080, 52 53 54 /** flags that effect an objects appearance */ 55 DMA_HARDFLAGS = (DMA_WNZ | DMA_CNZ | DMA_CONST | DMA_WA | DMA_FLIPH | DMA_FLIPV | DMA_TRANS) 56 }; 57 58 /** structure for image */ 59 #include "common/pack-start.h" // START STRUCT PACKING 60 struct IMAGE { 61 short imgWidth; ///< image width 62 unsigned short imgHeight; ///< image height 63 short anioffX; ///< image x animation offset 64 short anioffY; ///< image y animation offset 65 SCNHANDLE hImgBits; ///< image bitmap handle 66 SCNHANDLE hImgPal; ///< image palette handle 67 } PACKED_STRUCT; 68 #include "common/pack-end.h" // END STRUCT PACKING 69 70 /** a multi-object animation frame is a list of multi-image handles */ 71 typedef uint32 FRAME; 72 73 74 // object structure 75 struct OBJECT { 76 OBJECT *pNext; ///< pointer to next object in list 77 OBJECT *pSlave; ///< pointer to slave object (multi-part objects) 78 // char *pOnDispList; ///< pointer to display list byte for background objects 79 // frac_t xVel; ///< x velocity of object 80 // frac_t yVel; ///< y velocity of object 81 frac_t xPos; ///< x position of object 82 frac_t yPos; ///< y position of object 83 int zPos; ///< z position of object 84 Common::Rect rcPrev; ///< previous screen coordinates of object bounding rectangle 85 int flags; ///< object flags - see above for list 86 PALQ *pPal; ///< objects palette Q position 87 int constant; ///< which color in palette for monochrome objects 88 int width; ///< width of object 89 int height; ///< height of object 90 SCNHANDLE hBits; ///< image bitmap handle 91 SCNHANDLE hImg; ///< handle to object image definition 92 SCNHANDLE hShape; ///< objects current animation frame 93 SCNHANDLE hMirror; ///< objects previous animation frame 94 int oid; ///< object identifier 95 resetOBJECT96 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 OBJECTOBJECT121 OBJECT() { reset(); } 122 }; 123 typedef OBJECT *POBJECT; 124 125 #include "common/pack-start.h" // START STRUCT PACKING 126 127 // object initialisation structure 128 struct OBJ_INIT { 129 SCNHANDLE hObjImg; // objects shape - handle to IMAGE structure 130 int32 objFlags; // objects flags 131 int32 objID; // objects id 132 int32 objX; // objects initial x position 133 int32 objY; // objects initial y position 134 int32 objZ; // objects initial z position 135 } PACKED_STRUCT; 136 137 #include "common/pack-end.h" // END STRUCT PACKING 138 139 140 /*----------------------------------------------------------------------*\ 141 |* Object Function Prototypes *| 142 \*----------------------------------------------------------------------*/ 143 144 void KillAllObjects(); // kill all objects and place them on free list 145 146 void FreeObjectList(); // free the object list 147 148 #ifdef DEBUG 149 void ObjectStats(); // Shows the maximum number of objects used at once 150 #endif 151 152 OBJECT *AllocObject(); // allocate a object from the free list 153 154 void FreeObject( // place a object back on the free list 155 OBJECT *pFreeObj); // object to free 156 157 bool isValidObject(OBJECT *obj); 158 159 void CopyObject( // copy one object to another 160 OBJECT *pDest, // destination object 161 OBJECT *pSrc); // source object 162 163 void InsertObject( // insert a object onto a sorted object list 164 OBJECT **pObjList, // list to insert object onto 165 OBJECT *pInsObj); // object to insert 166 167 void DelObject( // delete a object from a object list and add to free list 168 OBJECT **pObjList, // list to delete object from 169 OBJECT *pDelObj); // object to delete 170 171 void SortObjectList( // re-sort an object list 172 OBJECT **pObjList); // list to sort 173 174 void GetAniOffset( // returns the anim offsets of a image, takes into account orientation 175 SCNHANDLE hImg, // image to get animation offset of 176 int flags, // images current flags 177 int *pAniX, // gets set to new X animation offset 178 int *pAniY); // gets set to new Y animation offset 179 180 void GetAniPosition( // Returns a objects x,y animation point 181 OBJECT *pObj, // pointer to object 182 int *pPosX, // gets set to objects X animation position 183 int *pPosY); // gets set to objects Y animation position 184 185 OBJECT *InitObject( // Init a object using a OBJ_INIT struct 186 const OBJ_INIT *pInitTbl); // pointer to object initialisation table 187 188 void AnimateObjectFlags( // Give a object a new image and new orientation flags 189 OBJECT *pAniObj, // object to be updated 190 int newflags, // objects new flags 191 SCNHANDLE hNewImg); // objects new image 192 193 void AnimateObject( // give a object a new image 194 OBJECT *pAniObj, // object to animate 195 SCNHANDLE hNewImg); // objects new image 196 197 void HideObject( // Hides a object by giving it a "NullImage" image pointer 198 OBJECT *pObj); // object to be hidden 199 200 OBJECT *RectangleObject( // create a rectangle object of the given dimensions 201 SCNHANDLE hPal, // palette for the rectangle object 202 int color, // which color offset from the above palette 203 int width, // width of rectangle 204 int height); // height of rectangle 205 206 OBJECT *TranslucentObject( // create a translucent rectangle object of the given dimensions 207 int width, // width of rectangle 208 int height); // height of rectangle 209 210 void ResizeRectangle( // resizes a rectangle object 211 OBJECT *pRect, // rectangle object pointer 212 int width, // new width of rectangle 213 int height); // new height of rectangle 214 215 216 // FIXME: This does not belong here 217 struct FILM; 218 struct FREEL; 219 struct MULTI_INIT; 220 IMAGE *GetImageFromReel(const FREEL *pfreel, const MULTI_INIT **ppmi = 0); 221 IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr = 0, 222 const MULTI_INIT **ppmi = 0, const FILM **ppfilm = 0); 223 224 225 } // End of namespace Tinsel 226 227 #endif // TINSEL_OBJECT_H 228