home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
demos
/
proart24
/
PCA
/
TBoxLibs
/
h
/
sprite
Wrap
Text File
|
1996-04-26
|
18KB
|
529 lines
/****************************************************************************
* This source file was written by Acorn Computers Limited. It is part of *
* the RISCOS library for writing applications in C for RISC OS. It may be *
* used freely in the creation of programs for Archimedes. It should be *
* used with Acorn's C Compiler Release 3 or later. *
* *
***************************************************************************/
/*
* Title : sprite.h
* Purpose: provide access to RISC OS sprite facilities
*
*/
# ifndef __sprite_h
# define __sprite_h
#ifndef __kernel_h
#include "kernel.h"
#endif
#ifndef BOOL
#define BOOL int
#endif
/*
* This file contains functions for performing operations on sprites.
* For brevity only a brief description is given for each call. More details
* can be found in the Programmer's Reference manual under the section on
* Sprite SWIs.
*
*/
/******** Simple operations, use no sprite area, no name/sprite pointer ***/
typedef enum
{
sprite_nopalette = 0,
sprite_haspalette = 1
} sprite_palflag;
typedef struct
{
int xmag,ymag,xdiv,ydiv;
} sprite_factors;
typedef char sprite_pixtrans;
/* ----------------------------- sprite_screensave -------------------------
* Save the current graphics window as a sprite file, with optional palette.
* Equivalent to *ScreenSave.
*
*/
extern _kernel_oserror * sprite_screensave(const char *filename, sprite_palflag);
/* ---------------------------- sprite_screenload --------------------------
* Load a sprite file onto the screen. Equivalent to *ScreenLoad.
*
*/
extern _kernel_oserror * sprite_screenload(const char *filename);
/****** Operations on either system/user area, no name/sprite pointer *****/
typedef struct /* Format of a sprite area control block */
{
int size;
int number;
int sproff;
int freeoff;
} sprite_area;
typedef struct /* Format of a sprite header */
{
int next; /* Offset to next sprite */
char name[12]; /* Sprite name */
int width; /* Width in words-1 (0..639) */
int height; /* Height in scanlines-1 (0..255/511) */
int lbit; /* First bit used (left end of row) */
int rbit; /* Last bit used (right end of row) */
int image; /* Offset to sprite image */
int mask; /* Offset to transparency mask */
int mode; /* Mode sprite was defined in */
/* Palette data optionally follows here */
/* in memory */
} sprite_header;
#define sprite_mainarea ((sprite_area *) 0)
typedef void * sprite_ptr;
/* ------------------------ sprite_area_initialise -------------------------
* Initialise an area of memory as a sprite area
*
*/
void sprite_area_initialise(sprite_area *, int size);
/* ----------------------- sprite_area_readinfo ----------------------------
* Read information from a sprite area control block
*
*/
extern _kernel_oserror * sprite_area_readinfo(sprite_area *, sprite_area *resultarea);
/* --------------------------- sprite_area_reinit --------------------------
* Reinitialise a sprite area.
* If system area, then equivalent to *SNew
*
*/
extern _kernel_oserror * sprite_area_reinit(sprite_area *);
/* --------------------------- sprite_area_load ----------------------------
* Load a sprite file into a sprite area.
* If system area, then equivalent to *SLoad
*
*/
extern _kernel_oserror * sprite_area_load(sprite_area *, const char *filename);
/* ---------------------------- sprite_area_merge --------------------------
* Merge a sprite file with a sprite area.
* If system area, then equivalent to *SMerge
*
*/
extern _kernel_oserror * sprite_area_merge(sprite_area *, const char *filename);
/* ---------------------------- sprite_area_save ---------------------------
* Saves a sprite area as a sprite file.
* If system area, then equivalent to *SSave
*
*/
extern _kernel_oserror * sprite_area_save(sprite_area *, const char *filename);
/* ---------------------------- sprite_getname -----------------------------
* Return the name and length of name of the n'th sprite in a sprite area into
* a buffer.
*
*/
extern _kernel_oserror * sprite_getname(sprite_area *, void *buffer, int *length, int index);
/* ---------------------------- sprite_get ---------------------------------
* Copy a rectangle of screen delimited by the last pair of graphics cursor
* positions as a named sprite in a sprite area, optionally storing the
* palette with the sprite.
*
*/
extern _kernel_oserror * sprite_get(sprite_area *, char *name, sprite_palflag);
/* ---------------------------- sprite_get_rp ------------------------------
* Copy a rectangle of screen delimited by the last pair of graphics cursor
* positions as a named sprite in a sprite area, optionally storing the
* palette with the sprite. Address of sprite returned in resultaddress.
*
*/
extern _kernel_oserror * sprite_get_rp(sprite_area *, char *name, sprite_palflag,
sprite_ptr *resultaddress);
/* ---------------------------- sprite_get_given ---------------------------
* Copy a rectangle of screen delimited by the given pair of graphics
* coordinates as a named sprite in a sprite area, optionally storing the
* palette with the sprite.
*
*/
extern _kernel_oserror * sprite_get_given(sprite_area *, char *name, sprite_palflag,
int x0, int y0, int x1, int y1);
/* --------------------------- sprite_get_given_rp -------------------------
* Copy a rectangle of screen delimited by the given pair of graphics
* coordinates as a named sprite in a sprite area, optionally storing the
* palette with the sprite. Address of sprite returned in resultaddress.
*
*/
extern _kernel_oserror * sprite_get_given_rp(sprite_area *, char *name, sprite_palflag,
int x0, int y0, int x1, int y1,
sprite_ptr *resultaddress);
/* ------------------------------ sprite_create ----------------------------
* Create a named sprite in a sprite area of specified size and screen mode,
* optionally reserving space for palette data with the sprite.
*
*/
extern _kernel_oserror * sprite_create(sprite_area *, char *name, sprite_palflag,
int width, int height, int mode);
/* ------------------------------ sprite_create_rp -------------------------
* Create a named sprite in a sprite area of specified size and screen mode,
* optionally reserving space for palette data with the sprite.Address of
* sprite returned in resultaddress.
*
*/
extern _kernel_oserror * sprite_create_rp(sprite_area *, char *name, sprite_palflag,
int width, int height, int mode,
sprite_ptr *resultaddress);
/*********** Operations on system/user area, name/sprite pointer **********/
typedef enum
{
sprite_id_name = 0,
sprite_id_addr = 0x74527053 /* 'Magic' number ("SpRt") to test against */
} sprite_type;
typedef struct
{
union
{
char * name; /* Can use either name of sprite or address (faster) */
sprite_ptr addr;
} s;
sprite_type tag; /* User must tag the use of this structure manually */
} sprite_id;
/* ----------------------------- sprite_select -----------------------------
* Select the specified sprite for plotting using plot(0xed,x,y).
*
*/
extern _kernel_oserror * sprite_select(sprite_area *, sprite_id *);
/* ----------------------------- sprite_select_rp --------------------------
* Select the specified sprite for plotting using plot(0xed,x,y). Address of
* sprite returned in resultaddress.
*
*/
extern _kernel_oserror * sprite_select_rp(sprite_area *, sprite_id *,
sprite_ptr *resultaddress);
/* ----------------------------- sprite_delete -----------------------------
* Delete the specified sprite.
*
*/
extern _kernel_oserror * sprite_delete(sprite_area *, sprite_id *);
/*