/* GnarlPlot screen header V0.29 10/11/05
   Copyright 2008 Jeffrey Lee
   This file is part of GnarlPlot.
   GnarlPlot 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.
   GnarlPlot 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 GnarlPlot.  If not, see <http://www.gnu.org/licenses/>. */

#ifndef _GP_SCREEN_H
#define _GP_SCREEN_H

typedef struct {
	int width; /* Width, in pixels */
	int height; /* Height, in pixels */
	int ps; /* Pixel size: 1 << ps = bytes per pixel */
	int mt; /* Mask type */
	int gap; /* End-of-line gap, in bytes */
	void *bank0; /* Bank to draw to */
	void *bank1; /* Bank to read from */
} gp_screen;

/* Mask formats */
#define GP_MT_NONE 0
#define GP_MT_ONOFF 1
#define GP_MT_GREY 2
#define GP_MT_RGB 3

extern const int gp_mask_conv(int imt,int ips,int im,int omt,int ops); /* Convert a mask value 'im' in format imt pixel size ips to format omt pixel size ops. If omt is GP_MT_ONOFF it returns 0 or 1. *ps is only used when *mt is GP_MT_RGB. */

extern gp_screen *gp_screen_new_fromvdu(); /* Create new screen obj, from the current VDU variables */
extern gp_screen *gp_screen_new_frompaintsprite(const int *spr); /* Create new screen obj, from the given !Paint sprite (Currently ignores the mask) */
extern void gp_screen_delete(gp_screen *s); /* Delete a screen obj */
extern void gp_screen_crop(gp_screen *s,int x,int y,int w,int h); /* Crop 's' to a region inside itself */
extern int gp_screen_readpix(const gp_screen *s,int x,int y,int ps); /* Read a pixel (from bank1) */
extern int gp_screen_readpix0(const gp_screen *s,int x,int y,int ps); /* Read a pixel (from bank0, e.g. to allow transparent sprite plotters to mask against the correct screen bank) */
extern int gp_screen_readmask(const gp_screen *s,int x,int y,int mt,int ps); /* Read pixel mask (from bank1) */
extern int gp_screen_readmask0(const gp_screen *s,int x,int y,int mt,int ps); /* Read pixel mask (from bank0) */
extern void gp_screen_writepix(gp_screen *s,int x,int y,int ps,int c); /* Write a pixel (to bank0) */
extern void gp_screen_writemask(gp_screen *s,int x,int y,int mt,int ps,int c); /* Write pixel mask (to bank0) */
extern void gp_screen_hline(gp_screen *s,int x,int y,int l,int ps,int c); /* Draw a horizontal line of length l to bank0 */
extern void gp_screen_line(gp_screen *s,int x1,int y1,int x2,int y2,int ps,int c); /* Draw a line from (x1,y1) to (x2,y2) to bank0 */
extern void gp_screen_rect(gp_screen *s,int lx,int rx,int ty,int by,int ps,int c); /* Draw a rectangle from (lx,ty) to (rx,by) all inclusive to bank0 */
extern void gp_screen_circ(gp_screen *s,int x,int y,int r,int ps,int c); /* Draw a circle to bank0 at (x,y) with radius r */

extern void gp_screen_hline0(int col,void *scr,int len);
/* Draws 'len' pixels of colour 'col' to 'scr' (pixel size 0)
   col must be a full word of colour
   Dithering is fully supported; colours are word-aligned
*/

extern void gp_screen_hline1(int col,void *scr,int len);
/* Draws 'len' pixels of colour 'col' to 'scr' (pixel size 1)
   col must be a full word of colour
   Dithering is fully supported; colours are word-aligned
*/

extern void gp_screen_hline2(int col,void *scr,int len);
/* Draws 'len' pixels of colour 'col' to 'scr' (pixel size 2)
*/

extern void gp_screen_hline3(int col,void *scr,int len,int col2);
/* Draws 'len' pixels of colour 'col','col2' to 'scr' (pixel size 3)
*/

#endif

