/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "Licence").
 * You may not use this file except in compliance with the Licence.
 *
 * You can obtain a copy of the licence at RISC OS path @.^.LICENCE
 * or  http://www.riscosdev.com/lanman98/LICENCE.CDDL
 * See the Licence for the specific language governing permissions
 * and limitations under the Licence.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the Licence file. If applicable, add the
 * following below this CDDL HEADER, with the fields enclosed by
 * brackets "[]" replaced with your own identifying information:
 * Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
 
/*
 *   Portions Copyright 1996 Warm Silence Software Ltd.
 */

/********************************************************************/
/*                                                                  */
/* Name: PGspr.h                                                    */
/* Author: Paul Gardiner.                                           */
/* Function:                                                        */
/*   Provides a library of functions for manipulating sprites, for  */
/* use with one of the two modules, PGscn or PGwin. They CAN be     */
/* used in isolation.                                               */
/*                                                                  */
/********************************************************************/

#ifndef _PGspr_
#define _PGspr_

#ifndef NULL
#define NULL (0)
#endif

#define SprScreen12      SprType(12, 1280, 1024)
#define SprRect12(x, y)  SprType(12, x, y)
#define SprBitMap(x, y)  SprType(18, x, y)

typedef struct
{
    int mode;
    int xsize, ysize;
    int memory;
} spr_type;

typedef struct spr_sprite_s *spr_sprite;

typedef enum {spr_WRT     = 0,
              spr_AND     = 2,
              spr_OR      = 1,
              spr_EXOR    = 3,
              spr_AND_NOT = 6,
              spr_OR_NOT  = 7} spr_action;

typedef struct spr_scale_s {int mult;
                            int  div;} spr_scale;

typedef struct
{
  char *base, *limit;
  int yinc;
} sprmem_t;



spr_type SprType(int, int, int);
/*
    Returns a sprite type for the specified (mode, x_size,
    y_size).
*/

spr_type SprNewType(int, int, int);
/*
    Returns a sprite type for the specified (bpp, x_size,
    y_size). RiscOS 3.5
*/

spr_sprite SprCreate(spr_type);
    /* Create a sprite of the specified type.               */

spr_sprite *SprCreateN(int, spr_type);
    /* Create a NULL-terminated array of the specified      */
    /* length, containing sprites of the specified type.    */

spr_sprite SprLoad(char *);
    /* Load the first sprite from the specified sprite      */
    /* file. This call is a little wasteful of memory: it   */
    /* loads the whole file.                                */

spr_sprite *SprLoadN(char *);
    /* Load a sprite file, and return it as a NULL-         */
    /* terminated array of sprites.                         */

spr_sprite SprScreen(int, int, int, int);
/*
 * Grabs a rectangle of the screen and returns it as
 * a sprite.
 */

void SprFree(spr_sprite);
    /* Free the memory allocated to the specified sprite.   */
    /* This should not be applied to an element of an       */
    /* array returned from SprLoadN, because it will free   */
    /* some of the memory allocated to other members of the */
    /* array.                                               */

void SprFreeN(spr_sprite *);
    /* Free the memory allocated to an array of sprites.    */
    /* Should be applied only to arrays returned by         */
    /* SprLoadN or SprCreateN.                              */

void SprSave(spr_sprite, char *);
    /* Save the specified sprite to a file.                 */

void SprRemode(spr_sprite, int);
/*
 * Sets the mode of a sprite.
 */

void SprVDU(spr_sprite);
    /* Direct plotting commands to the specified sprite.    */
    /* If NULL is specified then plotting is directed back  */
    /* to the terminal. This call should not be used while  */
    /* output is directed to a bitmapped window (see        */
    /* ScnVDU).                                             */

void SprPlot(spr_sprite, int, int);
    /* Plot the specified sprite. If output is directed to  */
    /* the terminal, this call does the necessary colour    */
    /* translation and scaling to cope with mode changes.   */
    /* When output is directed to another sprite, this call */
    /* just hopes for the best!                             */

void SprPlotQ(spr_sprite);
    /* Do a quick plot of the specified sprite, without     */
    /* any colour translation or scaling. This call uses    */
    /* the current graphics cursor position.                */

void SprBlt(spr_action, spr_sprite);
    /* Plot with the specified plotting action.             */

void SprPlotS(spr_scale, spr_sprite, int, int);
    /* Plot sprite using scaling factor. If output is       */
    /* directed to the terminal, the scaling and colours    */
    /* are adjusted for the current mode.                   */

void SprPlotBM(spr_scale, spr_sprite, int, int);
    /* Plot a bitmap using the prevailing foreground and    */
    /* background colours, and with scaling. If output is   */
    /* directed to the terminal, the scaling and colours    */
    /* are adjusted for the current mode.                   */

void SprGetSize(spr_sprite, int *, int *);
/*
    Returns the size of a sprite in OS units.
*/

int SprBPP(spr_sprite);
/*
    Returns log of No. bits per pixel for a sprite
*/

sprmem_t SprDirect(spr_sprite);
/*
    Returns information for direct access to sprites (or screen if
    argument is NULL)
*/

#endif /* _PGspr_ */
