home *** CD-ROM | disk | FTP | other *** search
- /*
- #### # # # #
- # # # # # The FreeWare C library for
- # # ## ### # # # # ### RISC OS machines
- # # # # # # # # # # # ___________________________________
- # # #### ### ## # # # #
- # # # # # # # # # # Please refer to the accompanying
- #### ### #### # # ##### # ### documentation for conditions of use
- ________________________________________________________________________
-
- File: Sprite.h
- Author: Copyright © 1992, 1993 John Winters and Jason Williams
- Version: 0.25 (11 May 1993)
- Purpose: Sprite-SWI interfaces.
- This version of the Sprite library only includes the most common
- sprite operations, and only on "user" sprite areas, and "named"
- sprites. (i.e. not pointers-to-sprites)
- More Sprite operations may appear as the moderator gets time
- to include them into the library.
- */
-
-
- #ifndef __dl_sprite_h
- #define __dl_sprite_h
-
- #ifndef __dl_core_h
- #include "Core.h"
- #endif
-
- #ifndef __dl_wimp_h
- #include "Wimp.h"
- #endif
-
-
- #define sprite_MAXNAME 12
-
- #define spritepool_SYSTEM 0
- #define spritepool_WIMP 1
-
- typedef struct sprite_info *sprite;
- typedef struct sprite_areainfo *sprite_area;
-
- typedef struct {
- int callno ;
- sprite_area spritearea ;
- sprite sprite ;
- void *savearea ;
- } sprite_outputstate ;
-
- typedef struct {
- unsigned int areasize ;
- unsigned int numsprites ;
- unsigned int firstoffset ;
- unsigned int freeoffset ;
- } sprite_areainfo ;
-
- typedef struct {
- unsigned int width ;
- unsigned int height ;
- unsigned int maskstatus ;
- unsigned int mode ;
- } sprite_info ;
-
-
- typedef struct
- {
- int offset_next;
- char name[sprite_MAXNAME];
- int width;
- int height;
- int leftbit;
- int rightbit;
- int imageoffset;
- int maskoffset;
- int screenmode;
- } sprite_header;
-
-
- /* Save the screen as a sprite file - SpriteOp 2 */
- extern os_error *Sprite_ScreenSave(char *filename, BOOL savepalette);
-
-
- /* ScreenLoad a sprite file - SpriteOp 3 */
- extern os_error *Sprite_ScreenLoad(char *filename);
-
- /* Initialise a sprite area - SpriteOp 9 */
- extern os_error *Sprite_InitArea(sprite_area area);
-
- /* Load a file into a sprite area - SpriteOp 10 */
- extern os_error *Sprite_Load(sprite_area area, char *filename) ;
-
- /* Merge a file into a sprite area - SpriteOp 11 */
- extern os_error *Sprite_Merge(sprite_area area, char *filename);
-
- /* Save a sprite area into a file - SpriteOp 12 */
- extern os_error *Sprite_Save(sprite_area area, char *filename);
-
-
- /*
- * Sprite_Create() - SpriteOp 15
- * Creates a sprite according to the parameters.
- */
- extern os_error *Sprite_Create(sprite_area area, char *name, int haspalette,
- int width, int height, int screenmode);
-
- /*
- * Sprite_Delete() - SpriteOp 25
- * Deletes the given sprite
- */
- extern os_error *Sprite_Delete(sprite_area area, char *name);
-
-
- /*
- * Sprite_Rename() and Sprite_Copy() - SpriteOps 25, 26
- * Unsurprisingly, these rename and copy a sprite, respectively.
- */
- extern os_error *Sprite_Rename(sprite_area area, char *oldname, char *newname);
- extern os_error *Sprite_Copy(sprite_area area, char *oldname, char *newname);
-
-
- /*
- * Sprite_Get() - SpriteOp 16
- * Gets (creates and copies) a sprite from the given screen rectangle
- */
- extern os_error *Sprite_Get(sprite_area area, char *name, int with_palette,
- int left, int bottom, int right, int top,
- sprite *sprite_ptr);
-
- /*
- * Sprite_Plot() - SpriteOp 34
- * Plots a sprite with it's bottom-left corners at the given coordinate,
- * using the given GCOL plot action (see GFX.h for plot actions)
- */
- extern os_error *Sprite_Plot(sprite_area area, char *name, /* "PutUser" */
- int x, int y, int plot_action);
-
-
- /* Reads sprite information - SpriteOp 40 */
- extern os_error *Sprite_ReadInfo(sprite_area area, char *name,
- sprite_info *info);
-
- /* redirects VDU output into the named sprite - SpriteOp 60 */
- extern os_error *Sprite_Redirect(sprite_area area, char *name,
- void *savearea, sprite_outputstate *oldstate);
-
- /* Un-redirects VDU output back to the saved state - SpriteOp 60 */
- extern os_error *Sprite_UnRedirect(sprite_outputstate *oldstate);
-
-
- /* Sprite_ReadSaveAreaSize
- * Given a sprite area and a sprite name, returns the save area size needed
- * for the given sprite. (SpriteOp 62 veneer)
- */
- extern os_error *Sprite_ReadSaveAreaSize(sprite_area area, char *name,
- int *saveareasize);
-
-
- /* Sprite manipulation functions ------------------------------------------ */
-
- typedef enum
- {
- sprite_HASNOMASKPAL = 0x00, /* Sprite has no mask or palette */
- sprite_HASNOPALMASK = 0x00,
- sprite_HASMASK = 0x01, /* Sprite has a mask only */
- sprite_HASPAL = 0x02, /* Sprite has a palette only */
- sprite_HASMASKPAL = 0x03, /* Has both mask and palette */
- sprite_HASPALMASK = 0x03
- } spritemem_flags;
-
-
- /* Sprite_MemorySize
- * Returns the amount of memory to malloc to hold the sprite
- * defined by the parameters.
- *
- * -- Example, create sprite area large enough for 3 identical sprites
- * which are mode 12, 34x17, and have their own palettes.
- *
- * sprite_areainfo *pUserSprites;
- *
- * size = 3 * Sprite_MemorySize( 34, 17, 12, sprite_HASPAL );
- * size += sizeof( sprite_areainfo );
- * pUserSprites = (sprite_areainfo*) malloc( size );
- */
-
- extern int Sprite_MemorySize(int width, int height, int mode,
- spritemem_flags flags);
-
-
- /* Sprite_IconMemorySize
- * This takes the given WIMP icon, and calculates the size of the sprite
- * needed to exactly fill it, by calling Sprite_MemorySize for you.
- * If 'dimensions' is not NULL, then it will be filled in with the needed
- * size (width/height) of the sprite in pixels.
- *
- * The window is passed in as a window_block so that this can be applied
- * to templates as well as open windows.
- *
- * Example:
- * {
- * window_info winfo;
- * int s;
- *
- * Window_GetInfo(mainwindow, &winfo);
- * s = Sprite_IconMemorySize(&winfo.block, 5, |* Get info for icon 5 *|
- * screen_mode, |* in current screen mode *|
- * sprite_HASNOMASKPAL, |* with no mask/palette *|
- * NULL); |* Don't return dimensions*|
- */
-
- extern int Sprite_IconMemorySize(window_block *pWinBlock, icon_handle icon,
- int mode, spritemem_flags flags,
- wimp_point *dimensions);
-
- #endif
-