/* OS_SpriteOp utilities V1.02 18/12/07
   Copyright 2008 Jeffrey Lee
   This file is part of WOUM.
   WOUM is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.
   WOUM is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
   You should have received a copy of the GNU General Public License
   along with WOUM.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _OSSPR_H
#define _OSSPR_H

/* Data block returned by OSSpr_GetInfo */
typedef struct {
	int width; /* Width of sprite in pixels */
	int height; /* Height of sprite in pixels */
	int mask; /* 0 or 1 depending on whether a mask is present */
	int mode; /* Mode number or sprite type field */
} osspr_info;

/* All coordinates use 0,0 as the bottom-left of the sprite
   Positive x heads to the right
   Positive y heads up
*/

extern void *OSSpr_LoadFile(char *f);
/* Load the sprite file who's name is given by 'f' and return a pointer to the sprite area.
   Returns NULL on failure
*/

extern void *OSSpr_CreateFile(int length);
/* Create an empty sprite area of length 'length' bytes.
   Returns NULL on failure
*/

extern void OSSpr_CreateSprite(void *b,char *name,int pal,int width,int height,int mode);
/* Creates a new sprite in sprite area 'b', of the characteristics given.
   'pal' must be 0 or 1, to flag whether the sprite should have a palette
   'mode' should be the sprite mode (either a mode number or sprite type field)
*/

extern int OSSpr_SaveFile(void *b,char *f);
/* Attempts to save the sprite block 'b' to the file 'f'
   Returns 0 on success, nonzero on failure
*/

extern osspr_info OSSpr_GetInfo(void *b,char *n);
/* Returns an osspr_info object containing the details of a named sprite from sprite area 'b'
*/

extern osspr_info OSSpr_GetInfo2(void *b,void *s);
/* Returns an osspr_info object containing the details of an indicated sprite from sprite area 'b'
*/

extern int OSSpr_ReadPixel(void *b,char *n,int x,int y);
/* Returns the colour value of the pixel at x,y in sprite 'n' of area 'b'
   For tinted sprite modes, the colour returned is the pixel colour + pixel tint
*/

extern int OSSpr_ReadPixel2(void *b,void *s,int x,int y);
/* Returns the colour value of the pixel at x,y in sprite 's' of area 'b'
   For tinted sprite modes, the colour returned is the pixel colour + pixel tint
*/

extern void OSSpr_WritePixel(void *b,char *n,int x,int y,int col,int tint);
/* Sets the colour and tint of the pixel at x,y in sprite 'n' of area 'b'
*/

extern void OSSpr_WritePixel2(void *b,void *s,int x,int y,int col,int tint);
/* Sets the colour and tint of the pixel at x,y in sprite 's' of area 'b'
*/

extern int OSSpr_ReadMask(void *b,char *n,int x,int y);
/* Reads the mask value of the pixel at x,y in sprite 'n' of area 'b'
   Returns 0 if the pixel is transparent, 1 if it is solid
*/

extern int OSSpr_ReadMask2(void *b,void *s,int x,int y);
/* Reads the mask value of the pixel at x,y in sprite 's' of area 'b'
   Returns 0 if the pixel is transparent, 1 if it is solid
*/

extern void OSSpr_WriteMask(void *b,char *n,int x,int y,int mask);
/* Sets the mask value of the pixel at x,y in sprite 'n' of area 'b'
   'mask' should be 0 for transparent or 1 for solid
*/

extern void OSSpr_WriteMask2(void *b,void *s,int x,int y,int mask);
/* Sets the mask value of the pixel at x,y in sprite 's' of area 'b'
   'mask' should be 0 for transparent or 1 for solid
*/

extern void OSSpr_CloseFile(void *b);
/* 'Closes' the given sprite area, i.e. calls free() on it
*/

extern void OSSpr_GetName(void *b,char *n,int i);
/* Writes to 'n' the name of sprite number 'i'
   Sprites are numbered from 1 to OSSpr_CountSprites() inclusive
*/

extern void *OSSpr_GetAddress(void *b,char *n);
/* Returns the address of the sprite with name 'n'
   Addresses can be used with OSSpr_ReadPixel2, OSSpr_WritePixel2, etc.
*/

extern int OSSpr_CountSprites(void *b);
/* Returns the number of sprites contained in the sprite area
*/

extern int OSSpr_GetPalette(void *b,char *n);
/* Returns a pointer to the palette of the specified sprite
*/

extern int OSSpr_GetPalette2(void *b,void *s);
/* Returns a pointer to the palette of the specified sprite
*/

extern int OSSpr_GetPaletteSize(void *b,char *n);
/* Returns the size of the palette of the specified sprite
*/

extern int OSSpr_GetPaletteSize2(void *b,void *s);
/* Returns the size of the palette of the specified sprite
*/

#endif
