/*
 *
 * Copyright 1988 by Perihelion Software Ltd.
 * 
 * Permission to use, copy, modify, and distribute this
 * software and its documentation for any purpose and without
 * fee is hereby granted, provided that the above copyright
 * notice appear in all copies and that both that copyright
 * notice and this permission notice appear in supporting
 * documentation, and that the name of Perihelion Software Ltd.
 * not be used in advertising or publicity pertaining to
 * distribution of the software without specific, written
 * prior permission.  Perihelios Software Ltd. makes no
 * representations about the suitability of this software
 * for any purpose.  It is provided "as is" without
 * express or implied warranty.
 *
 * Perihelion  Software  Ltd  disclaims all  warranties with
 * regard to this software, including all implied warranties
 * of merchantability  and fitness for a particular purpose.
 * In no event shall Perihelion Software Ltd be  liable  for 
 * any  special,  indirect or  consequential damages  or any
 * damages  whatsoever resulting from loss of use,  data  or
 * profits,  whether in an action of contract, negligence or
 * other  tortious action,  arising out of  or in connection 
 * with the use or performance of this software.
 */

/*****************************************************************

	Blossom registers

	RGM 17 October 1988

	C structure version

	THG 24 October 1988

*****************************************************************/

#ifndef BLOSSOM_H
#define BLOSSOM_H

#define NUM_VREGS 	9				/* Number of video registers */
#define VREG_BASE 	0x40000040			/* Base of video registers */
#define BLOSSOM_BASE	((BlossomPtr)0x40000000)	/* Base of everything */
#define BLITTER_BASE	((BlitterPtr)0x40000080)	/* Base of blitter registers */

typedef struct _Blossom
{
	int	MC;		/* Master control 	*/
	int	EA;		/* Event line address 	*/
	int	TS;		/* Test (leave alone!) 	*/
	int	OB;		/* I/O bits 		*/

	int	T0;
	int	T1;		/* writes as EV 	*/

	int	pad1[ 0xA ];

	int	HT;		/* horizontal total (words)	*/
	int	HD;		/* horizontal displayed		*/
	int	HS;		/* horizontal sync		*/
	int	HW;		/* horizontal sync width	*/

	int	VT;		/* vertical total		*/
	int	VD;		/* vertical displayed		*/
	int	VS;		/* vertical sync		*/
	int	VW;		/* vertical sync width		*/
	
	int	VC;		/* video control		*/
} Blossom, *BlossomPtr;

typedef struct _Blitter
{
	int	DS;		/* destination start (nibbles)		*/
	int	DF;		/* destination start (fraction)		*/
	int	DT;		/* destination stride (nibbles)		*/
	int	DI;		/* destination stride (fraction)	*/
	int	DW;		/* destination width / end mask		*/
	int	DL;		/* destination length (lines)		*/

	int	MS;		/* mask start (lines)			*/
	int	MB;		/* mask bit control			*/

	int	SS;		/* source start (nibbles)		*/
	int	SF;		/* source start (fraction)		*/
	int	ST;		/* source stride (nibbles)		*/
	int	SI;		/* source stride (fraction)		*/

	int	BF;		/* bit function control			*/
	int	TC;		/* test control				*/
	int	PM;		/* planar mask				*/
	int	TV;		/* test valuies / colour data		*/

	int	SD;		/* source data (also SP)		*/
	int	DD;		/* destination data			*/
	int	MD;		/* mask data				*/
	
	int	BC;		/* blitter control			*/

	int 	pad3[ 0x2C ];

	int	LS;		/* ??? start (nibbles)			*/
	int	LF;		/* ??? start (fraction)			*/
	int	LT;		/* ??? stride (nibbles)			*/
	int	LI;		/* ??? stride (fraction)		*/
} Blitter, *BlitterPtr;

/*****************************************************************/

#define	BCgo	0x80000000	/* start blossom */
#define	BCresb	0x40000000	/* restart blossom */
#define	BCssp	0x20000000	/* select source pipe */
#define	BCssh	0x10000000	/* select source shifts */

#define	BCstp	0x08000000	/* stipple mode */
#define	BCsrc	0x04000000	/* read source data */
#define	BCdst	0x02000000	/* read destination area */
#define	BCmsk	0x01000000	/* read mask area */

#define	BCfcen	0x00800000	/* fraction carry enable */
#define	BCeols	0x00400000	/* end of line control */

#define	BCmps	0x00100000	/* mask pixel size (2 bits) */
#define	BCmpr	0x00010000	/* mask pixel rotate (4 bits) */

#define	BCdq	0x00004000	/* destination quadrant (2 bits) */
#define	BCdps	0x00001000	/* destination pixel size (2 bits) */
#define	BCdxc	0x00000400	/* destination x-direction count control (2 bits) */
#define	BCdyc	0x00000100	/* destination y-direction count control (2 bits) */
#define	BCsq	0x00000040	/* soucre quadrant (2 bits) */
#define	BCsps	0x00000010	/* source pixel size (2 bits) */
#define	BCsxc	0x00000004	/* source x-direction count control (2 bits) */
#define	BCsyc	0x00000001	/* source y-direction count control (2 bits) */

/* BLOSSOM equivalents of X's GX values */

#define BFclear		0
#define BFand		8
#define BFandReverse	4
#define BFcopy		12
#define BFandInverted	2
#define BFnoop		10
#define BFxor		6
#define BFor		14
#define BFnor		1
#define BFequiv		9
#define BFinvert	5
#define BForReverse	13
#define BFcopyInverted	3
#define BForInverted	11
#define BFnand		7
#define BFset		15

#define RESET_BLITTER(bPtr) \
		(bPtr)->MD = 0xFFFFFFFF; \
		(bPtr)->TC = 1; \
		(bPtr)->MB = 0xFF00; \
		(bPtr)->BC = 0;

#define MAP0	0x00000000
#define MAP1	0x00200000
#define MAP2	0x00400000
#define MAP3	0x00600000

#endif /* BLOSSOM_H */

