home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************************
- * sprP.h
- *
- * Private definitions for the sprite support system.
- **********************************************************************
- 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.
-
- **********************************************************************
- **********************************************************************/
-
- #if !defined(__SPRP_H_)
- #define __SPRP_H_
-
- #include "grtypes.h"
-
- #define FLAG_NONE (0)
-
- /** the internal type for pointers into pre-shifted bitmaps **/
- typedef BYTE far *FARMAP;
-
- /** the sprite datatype **/
- typedef struct _sprite *SPRITE;
- #define __SPRITE_
-
- /** display lists for each display page **/
- extern SPRITE spr_sprites[2];
-
- /** the current drawing page **/
- extern WORD spr_drawingpage;
-
- /** determine the correct shifted shape/mask bitmap offset of sprite spr **/
- #define SHAPE_OFS(spr) \
- ((spr)->res==8 ? (spr)->size * ((spr)->x & 7) : \
- ((spr)->res==4 ? (spr)->size * (((spr)->x & 7) >> 1) : \
- ((spr)->res==2 ? (spr)->size * (((spr)->x & 7) >> 2) : 0)))
-
-
- /**********************************************************************
- * The actual definition of the sprite datatype
- **********************************************************************/
- struct _sprite {
- WORD flags; /* Special info about the sprite */
- WORD id; /* The user supplied ID info */
- BYTE w; /* Width of the sprite in bytes */
- WORD wp; /* Width of the sprite in pixels */
- BYTE hp; /* Height of the sprite in pixels */
- WORD x; /* The last X position (for spr_hit)*/
- WORD y; /* The last Y position (for spr_hit)*/
- WORD size; /* w*h/8 * 2 */
- BYTE res; /* The number of steps per 8 pixels */
- FARMAP data; /* The sprite shape/mask data */
- FARMAP saved[2]; /* The data saved under the sprite */
- FARMAP share; /* The share indicators */
- WORD max_share; /* The max index into share table */
- WORD share_index; /* The index into share table */
- BYTE far *addr[2]; /* The screen address of the sprite */
- struct _sprite *next[2];/* Next sprite in each display list */
- struct _sprite *cur_hit;/* Current sprite for hit detection */
- };
-
- /**********************************************************************
- * The sprite picture data is stored in the following expanded format:
- * ShapeByte1, MaskByte1, ShapeByte2, MaskByte2, ... ShapeByteN, MaskByteN
- * where N = w*h/8
- *
- * If the horizontal resolution (res) is different from 1 then there
- * is a picture/mask data block for each shifted shape.
- *
- * The save buffer is allocated in the same memory block as the
- * shape/mask data. This is necessary to keep them all in the same
- * segment (required for efficient implementation of spr_low_put)
- *
- * When the sprites are "displayed" with the spr_put function they
- * are only added into the display list for the current page.
- *
- * When the spr_next_pass is called all the sprites in the list
- * are output to the hidden page at once, then the pages are flipped
- * and the old sprites are deleted from the now hidden page.
- *
- * This all means that it is quite fast to put all sprites with spr_put,
- * then check the collisions with spr_hit routines, hide or delete
- * the collided sprites or correct their positions and after all that,
- * call spr_next_pass to get them visible.
- *
- * The spr_share function reallocates save space for all shared
- * copies and keeps usage information through share pointer.
- * The spr_copy function can be used to make copies of SPRITE objects.
- **********************************************************************/
-
- #endif
-