PageRenderTime 63ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/engines/tinsel/object.h

https://github.com/anguslees/scummvm
C Header | 212 lines | 130 code | 43 blank | 39 comment | 0 complexity | cf58035a6a044382ae04cfca0e034d7b MD5 | raw file
  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. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. *
  20. * $URL$
  21. * $Id$
  22. *
  23. * Object Manager data structures
  24. */
  25. #ifndef TINSEL_OBJECT_H // prevent multiple includes
  26. #define TINSEL_OBJECT_H
  27. #include "tinsel/dw.h"
  28. #include "common/frac.h"
  29. #include "common/rect.h"
  30. namespace Tinsel {
  31. struct PALQ;
  32. enum {
  33. /** the maximum number of objects */
  34. NUM_OBJECTS = 256,
  35. // object flags
  36. DMA_WNZ = 0x0001, ///< write non-zero data
  37. DMA_CNZ = 0x0002, ///< write constant on non-zero data
  38. DMA_CONST = 0x0004, ///< write constant on both zero & non-zero data
  39. DMA_WA = 0x0008, ///< write all data
  40. DMA_FLIPH = 0x0010, ///< flip object horizontally
  41. DMA_FLIPV = 0x0020, ///< flip object vertically
  42. DMA_CLIP = 0x0040, ///< clip object
  43. DMA_TRANS = 0x0084, ///< translucent rectangle object
  44. DMA_ABS = 0x0100, ///< position of object is absolute
  45. DMA_CHANGED = 0x0200, ///< object has changed in some way since the last frame
  46. DMA_USERDEF = 0x0400, ///< user defined flags start here
  47. DMA_GHOST = 0x0080,
  48. /** flags that effect an objects appearance */
  49. DMA_HARDFLAGS = (DMA_WNZ | DMA_CNZ | DMA_CONST | DMA_WA | DMA_FLIPH | DMA_FLIPV | DMA_TRANS)
  50. };
  51. /** structure for image */
  52. #include "common/pack-start.h" // START STRUCT PACKING
  53. struct IMAGE {
  54. short imgWidth; ///< image width
  55. unsigned short imgHeight; ///< image height
  56. short anioffX; ///< image x animation offset
  57. short anioffY; ///< image y animation offset
  58. SCNHANDLE hImgBits; ///< image bitmap handle
  59. SCNHANDLE hImgPal; ///< image palette handle
  60. } PACKED_STRUCT;
  61. #include "common/pack-end.h" // END STRUCT PACKING
  62. /** a multi-object animation frame is a list of multi-image handles */
  63. typedef uint32 FRAME;
  64. // object structure
  65. struct OBJECT {
  66. OBJECT *pNext; ///< pointer to next object in list
  67. OBJECT *pSlave; ///< pointer to slave object (multi-part objects)
  68. // char *pOnDispList; ///< pointer to display list byte for background objects
  69. // frac_t xVel; ///< x velocity of object
  70. // frac_t yVel; ///< y velocity of object
  71. frac_t xPos; ///< x position of object
  72. frac_t yPos; ///< y position of object
  73. int zPos; ///< z position of object
  74. Common::Rect rcPrev; ///< previous screen coordinates of object bounding rectangle
  75. int flags; ///< object flags - see above for list
  76. PALQ *pPal; ///< objects palette Q position
  77. int constant; ///< which colour in palette for monochrome objects
  78. int width; ///< width of object
  79. int height; ///< height of object
  80. SCNHANDLE hBits; ///< image bitmap handle
  81. SCNHANDLE hImg; ///< handle to object image definition
  82. SCNHANDLE hShape; ///< objects current animation frame
  83. SCNHANDLE hMirror; ///< objects previous animation frame
  84. int oid; ///< object identifier
  85. };
  86. typedef OBJECT *POBJECT;
  87. #include "common/pack-start.h" // START STRUCT PACKING
  88. // object initialisation structure
  89. struct OBJ_INIT {
  90. SCNHANDLE hObjImg; // objects shape - handle to IMAGE structure
  91. int32 objFlags; // objects flags
  92. int32 objID; // objects id
  93. int32 objX; // objects initial x position
  94. int32 objY; // objects initial y position
  95. int32 objZ; // objects initial z position
  96. } PACKED_STRUCT;
  97. #include "common/pack-end.h" // END STRUCT PACKING
  98. /*----------------------------------------------------------------------*\
  99. |* Object Function Prototypes *|
  100. \*----------------------------------------------------------------------*/
  101. void KillAllObjects(); // kill all objects and place them on free list
  102. void FreeObjectList(); // free the object list
  103. #ifdef DEBUG
  104. void ObjectStats(); // Shows the maximum number of objects used at once
  105. #endif
  106. OBJECT *AllocObject(); // allocate a object from the free list
  107. void FreeObject( // place a object back on the free list
  108. OBJECT *pFreeObj); // object to free
  109. bool isValidObject(OBJECT *obj);
  110. void CopyObject( // copy one object to another
  111. OBJECT *pDest, // destination object
  112. OBJECT *pSrc); // source object
  113. void InsertObject( // insert a object onto a sorted object list
  114. OBJECT *pObjList, // list to insert object onto
  115. OBJECT *pInsObj); // object to insert
  116. void DelObject( // delete a object from a object list and add to free list
  117. OBJECT *pObjList, // list to delete object from
  118. OBJECT *pDelObj); // object to delete
  119. void SortObjectList( // re-sort an object list
  120. OBJECT *pObjList); // list to sort
  121. OBJECT *GetNextObject( // object list iterator - returns next obj in list
  122. OBJECT *pObjList, // which object list
  123. OBJECT *pStrtObj); // object to start from - when NULL will start from beginning of list
  124. OBJECT *FindObject( // Searches the specified obj list for a object matching the specified OID
  125. OBJECT *pObjList, // object list to search
  126. int oidDesired, // object identifer of object to find
  127. int oidMask); // mask to apply to object identifiers before comparison
  128. void GetAniOffset( // returns the anim offsets of a image, takes into account orientation
  129. SCNHANDLE hImg, // image to get animation offset of
  130. int flags, // images current flags
  131. int *pAniX, // gets set to new X animation offset
  132. int *pAniY); // gets set to new Y animation offset
  133. void GetAniPosition( // Returns a objects x,y animation point
  134. OBJECT *pObj, // pointer to object
  135. int *pPosX, // gets set to objects X animation position
  136. int *pPosY); // gets set to objects Y animation position
  137. OBJECT *InitObject( // Init a object using a OBJ_INIT struct
  138. const OBJ_INIT *pInitTbl); // pointer to object initialisation table
  139. void AnimateObjectFlags( // Give a object a new image and new orientation flags
  140. OBJECT *pAniObj, // object to be updated
  141. int newflags, // objects new flags
  142. SCNHANDLE hNewImg); // objects new image
  143. void AnimateObject( // give a object a new image
  144. OBJECT *pAniObj, // object to animate
  145. SCNHANDLE hNewImg); // objects new image
  146. void HideObject( // Hides a object by giving it a "NullImage" image pointer
  147. OBJECT *pObj); // object to be hidden
  148. OBJECT *RectangleObject( // create a rectangle object of the given dimensions
  149. SCNHANDLE hPal, // palette for the rectangle object
  150. int colour, // which colour offset from the above palette
  151. int width, // width of rectangle
  152. int height); // height of rectangle
  153. OBJECT *TranslucentObject( // create a translucent rectangle object of the given dimensions
  154. int width, // width of rectangle
  155. int height); // height of rectangle
  156. void ResizeRectangle( // resizes a rectangle object
  157. OBJECT *pRect, // rectangle object pointer
  158. int width, // new width of rectangle
  159. int height); // new height of rectangle
  160. // FIXME: This does not belong here
  161. struct FILM;
  162. struct FREEL;
  163. struct MULTI_INIT;
  164. IMAGE *GetImageFromReel(const FREEL *pfreel, const MULTI_INIT **ppmi = 0);
  165. IMAGE *GetImageFromFilm(SCNHANDLE hFilm, int reel, const FREEL **ppfr = 0,
  166. const MULTI_INIT **ppmi = 0, const FILM **ppfilm = 0);
  167. } // End of namespace Tinsel
  168. #endif // TINSEL_OBJECT_H