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

  1. /**********************************************************************
  2. * spr.h
  3. *
  4. * The sprite support system interface prototypes and structures
  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. #ifndef __SPR_H_
  21. #define __SPR_H_
  22.  
  23. #include "grtypes.h"
  24.  
  25. /**********************************************************************
  26. * The delay after setvisualpage() before removing old objects in
  27. * the funtion spr_next_pass(). 
  28. * Many EGA/VGA cards need some milliseconds to switch pages, 
  29. * and therefore the sprites flash if this delay is too short.
  30. *
  31. * If someone has better solutions in dealing with this problem,
  32. * I sure would like to know about them.
  33. *
  34. * Time is given in milliseconds and the default is 10 ms for EGA
  35. * and 0 ms for Hercules (use spr_regulate_speed to balance the frame
  36. * rate with different display adapters).
  37. **********************************************************************/
  38. extern int spr_pass_delay;
  39.  
  40. /**********************************************************************
  41. * The maximum coordinate values for current graphics adapter.
  42. * (Variables defined in module grmisc.c, and initialized in gr_start)
  43. * (It is faster to use variables instead of getmaxx() and getmaxy());
  44. **********************************************************************/
  45. #define spr_max_x gr_max_x
  46. #define spr_max_y gr_max_y
  47.  
  48. /**********************************************************************
  49. * The sprite type is private. Ifdef is needed due to the internal 
  50. * implementation and TC
  51. **********************************************************************/
  52. #ifndef __SPRITE_
  53. typedef void *SPRITE;
  54. #endif
  55.  
  56.  
  57. /**********************************************************************
  58. * Initialize the sprite system to the given display hardware.
  59. * Supported graphicsdrivers: EGAMONO and HERCMONO
  60. * NOTE: This function must be called before any other sprite funtions
  61. *       and the graphics mode must have been set before this call.
  62. * graphicsdriver  The BGI identifier for the graphics driver used.
  63. **********************************************************************/
  64. void spr_initialize(int graphicsdriver);
  65.  
  66. /**********************************************************************
  67. * Create a sprite from the given bitmaps.
  68. *
  69. * w,h   Width (must be < 512) and height (<256) of sprite in pixels
  70. * pic   The picture bitmap for the sprite
  71. * mask  The mask bitmap for the sprite
  72. * res   The number of steps wanted per 8 bit interval in horizontal
  73. *       direction (1,2,4,8). For example, the value 8 gives one
  74. *       pixel resolution in X-direction.
  75. * ID    The user supplied ID for the sprite (not obligatory)
  76. *
  77. * Return: the newly created sprite or NULL if parameter error,
  78. *           sprite too big or out-of-memory
  79. **********************************************************************/
  80. SPRITE spr_create(WORD w, WORD h, 
  81.                   BITMAP pic, BITMAP mask, 
  82.                   BYTE res, WORD ID);
  83.  
  84. /**********************************************************************
  85. * Create a shared version of the given sprite. This allows
  86. * n spr_copies which all share the shape data thus saving
  87. * quite much memory.
  88. *
  89. * spr   The sprite to share
  90. * n     The maximum number of shared copies
  91. *
  92. * Return: New SPRITE or NULL if error (out of memory, spr==NULL, etc)
  93. **********************************************************************/
  94. SPRITE spr_share(SPRITE spr, BYTE n);
  95.  
  96. /**********************************************************************
  97. * Create a copy of the given sprite. If the sprite was shared
  98. * then a shared copy is created (if possible).
  99. *
  100. * spr   The sprite to share
  101. * id    The ID for the new sprite
  102. *
  103. * Return: New SPRITE of NULL if error (out of memory, spr was NULL, 
  104. * no more shared copies)
  105. **********************************************************************/
  106. SPRITE spr_copy(SPRITE spr, WORD id);
  107.  
  108. /**********************************************************************
  109. * Put the sprite into the given position into the display.
  110. * NOTE: the call has no effect on screen until a call to 
  111. *       spr_next_pass() is made.
  112. * NOTE: Cannot be called twice for the same sprite before spr_hide or
  113. *       spr_next_pass().
  114. *
  115. * spr   The sprite to put
  116. * x     The X coordinate
  117. * y     The Y coordinate
  118. **********************************************************************/
  119. void spr_put(SPRITE spr, WORD x, WORD y);
  120.  
  121. /**********************************************************************
  122. * Remove the sprite from the display.
  123. * NOTE: the call has no effect on screen until a call to 
  124. *       spr_next_pass() is made.
  125. *
  126. * spr   The sprite to hide
  127. **********************************************************************/
  128. void spr_hide(SPRITE spr);
  129.  
  130. /**********************************************************************
  131. * Delete the given sprite and release associated memory buffers.
  132. *
  133. * spr   The sprite to delete
  134. **********************************************************************/
  135. void spr_delete(SPRITE spr);
  136.  
  137. /**********************************************************************
  138. * Draw all sprites into hidden screen page,
  139. * activate hidden screen page,
  140. * delete old sprites from the new hidden page.
  141. *
  142. * Return: The current visual page
  143. **********************************************************************/
  144. WORD spr_next_pass(void);
  145.  
  146. /**********************************************************************
  147. * This function tries to regulate the frame speed by delaying if
  148. * we are doing more frames per second than we should. The target 
  149. * speed is 1 frame per one clock tick (about 18 frames per second).
  150. * This is reasonable target speed at least for 286 machines.
  151. * This function should be called after each spr_next_pass() call.
  152. **********************************************************************/
  153. void spr_regulate_speed(void);
  154.  
  155.  
  156. /***** Information retrieving functions *****/
  157.  
  158. /**********************************************************************
  159. * Return the user supplied identifier of the sprite
  160. **********************************************************************/
  161. WORD spr_get_id(SPRITE spr);
  162.  
  163. /**********************************************************************
  164. * Return the X coordinate of the sprite in pixels from top-left
  165. **********************************************************************/
  166. WORD spr_get_x(SPRITE spr);
  167.  
  168. /**********************************************************************
  169. * Return the Y coordinate of the sprite in pixels from top-left
  170. **********************************************************************/
  171. WORD spr_get_y(SPRITE spr);
  172.  
  173. /**********************************************************************
  174. * Return the width of the sprite in pixels
  175. **********************************************************************/
  176. WORD spr_get_width(SPRITE spr);
  177.  
  178. /**********************************************************************
  179. * Return the height of the sprite in pixels
  180. **********************************************************************/
  181. WORD spr_get_height(SPRITE spr);
  182.  
  183. #endif
  184.