PageRenderTime 50ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/engines/tinsel/object.h

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