home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * spr.h
- *
- * The sprite support system interface prototypes and structures
- **********************************************************************
- This file is part of
-
- STK -- The sprite toolkit -- version 1.0
-
- Copyright (C) Jari Karjala 1990
-
- The sprite toolkit (STK) is a FreeWare toolkit for creating high
- resolution sprite graphics with PCompatible hardware. This toolkit
- is provided as is without any warranty or such thing. See the file
- COPYING for further information.
-
- **********************************************************************
- **********************************************************************/
-
- #ifndef __SPR_H_
- #define __SPR_H_
-
- #include "grtypes.h"
-
- /**********************************************************************
- * The delay after setvisualpage() before removing old objects in
- * the funtion spr_next_pass().
- * Many EGA/VGA cards need some milliseconds to switch pages,
- * and therefore the sprites flash if this delay is too short.
- *
- * If someone has better solutions in dealing with this problem,
- * I sure would like to know about them.
- *
- * Time is given in milliseconds and the default is 10 ms for EGA
- * and 0 ms for Hercules (use spr_regulate_speed to balance the frame
- * rate with different display adapters).
- **********************************************************************/
- extern int spr_pass_delay;
-
- /**********************************************************************
- * The maximum coordinate values for current graphics adapter.
- * (Variables defined in module grmisc.c, and initialized in gr_start)
- * (It is faster to use variables instead of getmaxx() and getmaxy());
- **********************************************************************/
- #define spr_max_x gr_max_x
- #define spr_max_y gr_max_y
-
- /**********************************************************************
- * The sprite type is private. Ifdef is needed due to the internal
- * implementation and TC
- **********************************************************************/
- #ifndef __SPRITE_
- typedef void *SPRITE;
- #endif
-
-
- /**********************************************************************
- * Initialize the sprite system to the given display hardware.
- * Supported graphicsdrivers: EGAMONO and HERCMONO
- * NOTE: This function must be called before any other sprite funtions
- * and the graphics mode must have been set before this call.
- *
- * graphicsdriver The BGI identifier for the graphics driver used.
- **********************************************************************/
- void spr_initialize(int graphicsdriver);
-
- /**********************************************************************
- * Create a sprite from the given bitmaps.
- *
- * w,h Width (must be < 512) and height (<256) of sprite in pixels
- * pic The picture bitmap for the sprite
- * mask The mask bitmap for the sprite
- * res The number of steps wanted per 8 bit interval in horizontal
- * direction (1,2,4,8). For example, the value 8 gives one
- * pixel resolution in X-direction.
- * ID The user supplied ID for the sprite (not obligatory)
- *
- * Return: the newly created sprite or NULL if parameter error,
- * sprite too big or out-of-memory
- **********************************************************************/
- SPRITE spr_create(WORD w, WORD h,
- BITMAP pic, BITMAP mask,
- BYTE res, WORD ID);
-
- /**********************************************************************
- * Create a shared version of the given sprite. This allows
- * n spr_copies which all share the shape data thus saving
- * quite much memory.
- *
- * spr The sprite to share
- * n The maximum number of shared copies
- *
- * Return: New SPRITE or NULL if error (out of memory, spr==NULL, etc)
- **********************************************************************/
- SPRITE spr_share(SPRITE spr, BYTE n);
-
- /**********************************************************************
- * Create a copy of the given sprite. If the sprite was shared
- * then a shared copy is created (if possible).
- *
- * spr The sprite to share
- * id The ID for the new sprite
- *
- * Return: New SPRITE of NULL if error (out of memory, spr was NULL,
- * no more shared copies)
- **********************************************************************/
- SPRITE spr_copy(SPRITE spr, WORD id);
-
- /**********************************************************************
- * Put the sprite into the given position into the display.
- * NOTE: the call has no effect on screen until a call to
- * spr_next_pass() is made.
- * NOTE: Cannot be called twice for the same sprite before spr_hide or
- * spr_next_pass().
- *
- * spr The sprite to put
- * x The X coordinate
- * y The Y coordinate
- **********************************************************************/
- void spr_put(SPRITE spr, WORD x, WORD y);
-
- /**********************************************************************
- * Remove the sprite from the display.
- * NOTE: the call has no effect on screen until a call to
- * spr_next_pass() is made.
- *
- * spr The sprite to hide
- **********************************************************************/
- void spr_hide(SPRITE spr);
-
- /**********************************************************************
- * Delete the given sprite and release associated memory buffers.
- *
- * spr The sprite to delete
- **********************************************************************/
- void spr_delete(SPRITE spr);
-
- /**********************************************************************
- * Draw all sprites into hidden screen page,
- * activate hidden screen page,
- * delete old sprites from the new hidden page.
- *
- * Return: The current visual page
- **********************************************************************/
- WORD spr_next_pass(void);
-
- /**********************************************************************
- * This function tries to regulate the frame speed by delaying if
- * we are doing more frames per second than we should. The target
- * speed is 1 frame per one clock tick (about 18 frames per second).
- * This is reasonable target speed at least for 286 machines.
- * This function should be called after each spr_next_pass() call.
- **********************************************************************/
- void spr_regulate_speed(void);
-
-
- /***** Information retrieving functions *****/
-
- /**********************************************************************
- * Return the user supplied identifier of the sprite
- **********************************************************************/
- WORD spr_get_id(SPRITE spr);
-
- /**********************************************************************
- * Return the X coordinate of the sprite in pixels from top-left
- **********************************************************************/
- WORD spr_get_x(SPRITE spr);
-
- /**********************************************************************
- * Return the Y coordinate of the sprite in pixels from top-left
- **********************************************************************/
- WORD spr_get_y(SPRITE spr);
-
- /**********************************************************************
- * Return the width of the sprite in pixels
- **********************************************************************/
- WORD spr_get_width(SPRITE spr);
-
- /**********************************************************************
- * Return the height of the sprite in pixels
- **********************************************************************/
- WORD spr_get_height(SPRITE spr);
-
- #endif
-