home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / MISC / STK100.ZIP / STKSRC.COM / SPRP.H < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-20  |  4.2 KB  |  100 lines

  1. /**********************************************************************
  2. * sprP.h
  3. *
  4. * Private definitions for the sprite support system.
  5. **********************************************************************
  6.                     This file is part of
  7.  
  8.           STK -- The sprite toolkit -- version 1.0
  9.  
  10.               Copyright (C) Jari Karjala 1990
  11.  
  12. The sprite toolkit (STK) is a FreeWare toolkit for creating high
  13. resolution sprite graphics with PCompatible hardware. This toolkit 
  14. is provided as is without any warranty or such thing. See the file
  15. COPYING for further information.
  16.  
  17. **********************************************************************
  18. **********************************************************************/
  19.  
  20. #if     !defined(__SPRP_H_)
  21. #define __SPRP_H_
  22.  
  23. #include "grtypes.h"
  24.  
  25. #define FLAG_NONE       (0)
  26.  
  27. /** the internal type for pointers into pre-shifted bitmaps **/
  28. typedef BYTE far *FARMAP;
  29.  
  30. /** the sprite datatype **/
  31. typedef struct _sprite *SPRITE;
  32. #define __SPRITE_
  33.  
  34. /** display lists for each display page **/
  35. extern SPRITE spr_sprites[2];
  36.  
  37. /** the current drawing page **/
  38. extern WORD spr_drawingpage;
  39.  
  40. /** determine the correct shifted shape/mask bitmap offset of sprite spr **/
  41. #define SHAPE_OFS(spr) \
  42.         ((spr)->res==8 ? (spr)->size * ((spr)->x & 7) :            \
  43.             ((spr)->res==4 ? (spr)->size * (((spr)->x & 7) >> 1) : \
  44.                 ((spr)->res==2 ? (spr)->size * (((spr)->x & 7) >> 2) : 0)))
  45.  
  46.  
  47. /**********************************************************************
  48. * The actual definition of the sprite datatype
  49. **********************************************************************/
  50. struct _sprite {
  51.     WORD flags;             /* Special info about the sprite    */
  52.     WORD id;                /* The user supplied ID info        */
  53.     BYTE w;                 /* Width of the sprite in bytes     */
  54.     WORD wp;                /* Width of the sprite in pixels    */
  55.     BYTE hp;                /* Height of the sprite in pixels   */
  56.     WORD x;                 /* The last X position (for spr_hit)*/
  57.     WORD y;                 /* The last Y position (for spr_hit)*/
  58.     WORD size;              /* w*h/8 * 2                        */
  59.     BYTE res;               /* The number of steps per 8 pixels */
  60.     FARMAP data;            /* The sprite shape/mask data       */
  61.     FARMAP saved[2];        /* The data saved under the sprite  */
  62.     FARMAP share;           /* The share indicators             */
  63.     WORD max_share;         /* The max index into share table   */
  64.     WORD share_index;       /* The index into share table       */
  65.     BYTE far *addr[2];      /* The screen address of the sprite */
  66.     struct _sprite *next[2];/* Next sprite in each display list */
  67.     struct _sprite *cur_hit;/* Current sprite for hit detection */
  68. };
  69.  
  70. /**********************************************************************
  71. * The sprite picture data is stored in the following expanded format:
  72. * ShapeByte1, MaskByte1, ShapeByte2, MaskByte2, ... ShapeByteN, MaskByteN
  73. * where N = w*h/8
  74. * If the horizontal resolution (res) is different from 1 then there
  75. * is a picture/mask data block for each shifted shape.
  76. *
  77. * The save buffer is allocated in the same memory block as the
  78. * shape/mask data. This is necessary to keep them all in the same
  79. * segment (required for efficient implementation of spr_low_put)
  80. *
  81. * When the sprites are "displayed" with the spr_put function they
  82. * are only added into the display list for the current page. 
  83. *
  84. * When the spr_next_pass is called all the sprites in the list
  85. * are output to the hidden page at once, then the pages are flipped 
  86. * and the old sprites are deleted from the now hidden page.
  87. *
  88. * This all means that it is quite fast to put all sprites with spr_put,
  89. * then check the collisions with spr_hit routines, hide or delete
  90. * the collided sprites or correct their positions and after all that,
  91. * call spr_next_pass to get them visible.
  92. *
  93. * The spr_share function reallocates save space for all shared
  94. * copies and keeps usage information through share pointer.
  95. * The spr_copy function can be used to make copies of SPRITE objects.
  96. **********************************************************************/
  97.  
  98. #endif
  99.