/***********************************************************/
/*      _  __ __                                           */
/*  /_//_)/_ (                                             */
/* / //( (_/__)|/STEM   written by H.Raaf © 1992-93        */
/*             /                                           */
/*                           ProDev / X-Pert               */
/*                                                         */
/***********************************************************/
/*                                                         */
/*   Definition der ModeInfo Strukture                     */
/*                                                         */
/***********************************************************/

#ifndef HRG_MODEINFO_H
#define HRG_MODEINFO_H

/* Definitions for the BitMapTypes */

#ifndef HRG_BITMAP_H
#include <hrg/bitmap.h>
#endif

#ifndef EXEC_TYPES_H
#include <exec/types.h>
#endif

/* Structure for Mode Info */
/* The HRModeInfo structure are ordered by ColorDeep */
/* then by X and Y resolution */

struct HRModeInfo
{
	struct HRModeInfo *next, *prev;

	UWORD ResWidth;			/* Resolution width */
	UWORD ResHeight;			/* Resolution height */
	UWORD MaxWidth;			/* Maximal moegliche Breite fuer den Modus */
	UWORD MaxHeight;			/* Maximal moegliche Hoehe fuer den Modus */
	UWORD MinWidth;			/* Minimal moegliche Breite fuer den Modus */
	UWORD MinHeight;			/* Minimal moegliche Hoehe fuer den Modus */
	WORD	CurOffX;				/* Cursor Offset X */
	WORD	CurOffY;				/* Cursor Offset Y */

	ULONG ClockFreq;			/* Base Clock of the PLL in kHz */

	ULONG	HFreq;				/* Horizontal-Freq in Hz */
	UWORD	VFreq;				/* Vertical-Freq in Hz */
	UBYTE AspectX;
	UBYTE AspectY;
	ULONG ModeFlags;			/* Flags for the Display type */
	UWORD	BitMapType;			/* (BitMap.Mode<<8 | BitMap.BitsPerPixel) */
	ULONG SpecialFlags;		/* Flags for Mode Aspect and other things */
	UWORD Usage;				/* Number of usage for this mode */

	/* PRIVATE	*/
	
	ULONG	ColorMode;				/* private */
	ULONG	ResFlags;				/* private */

	UBYTE	Clock;						/* Domino 0-7 / Merlin 0-15 */
	UBYTE	ClockDivide;				/* 1,2,4 */
	UWORD	H_Total;						/*  9	Bit (0,3F)		*/
	UWORD	H_BlankStart;				/*  9 Bit (2,3F)		*/
	UWORD	H_BlankEnd;					/*  6 Bit (3,5)		*/
	UWORD H_SyncStart;				/*	 9 Bit (4,3F)		*/
	UWORD H_SyncEnd;					/*  5 Bit (5)			*/
	UBYTE	H_SyncSkew;					/*  2 Bit (5)			*/
	UBYTE H_DisplayEnableSkew;		/*  2 Bit (3)			*/
	UWORD	V_Total;						/* 11	Bit (6,7,35)	*/
	UWORD V_BlankStart;				/*	11 Bit (15,7,9,35)*/
	UWORD V_BlankEnd;					/*  8 Bit (16)			*/
	UWORD	V_SyncStart;				/* 11 Bit (10,7,35)	*/
	UWORD	V_SyncEnd;					/*  4 Bit (11)			*/

	UBYTE	ScanlinesPerChar;			/*  5 Bit (9) 			*/
	UBYTE	BytePanning;				/*  2 Bit (8) 			*/
	UBYTE	InitialRowAdress;			/*  5 Bit (8)			*/
	UBYTE Pad1;
	APTR	CardModeAdds;				/* Reserved for Future extensions */
};

/* Definitions for the ModeFlags of the HRModeInfo structure */

#define HRMB_Interlace		0
#define HRMB_DoubleScan		1
#define HRMB_Scrollable		2
#define HRMB_SplitView		3
#define HRMB_SecondView		4	/* Nicht bei Domino */
#define HRMB_Cursor			5	/* Nicht bei Domino */

#define HRMF_ALL				0xffffffffL
#define HRMF_Interlace		(1L<<HRMB_Interlace)
#define HRMF_DoubleScan		(1L<<HRMB_DoubleScan)
#define HRMF_Scrollable		(1L<<HRMB_Scrollable)
#define HRMF_SplitView		(1L<<HRMB_SplitView)
#define HRMF_SecondView		(1L<<HRMB_SecondView)
#define HRMF_Cursor			(1L<<HRMB_Cursor)

/* Definitions for the Special-Flags */

#define HRMSB_FLUSH			0		/* ModeInfo is not longer useable */
#define HRMSB_VIDEO			1		/* ModeInfo supports FBAS/YC - VIDEO */
#define HRMSB_31KHZ			2		/* ModeInfo avoid monitor resync */

/* The following is for Aspect considerations */
/* It will be possible to search for a ScreenMode by this Flags.. */
/* e.x. A HAM Lace Picture will normally match "HRMSF_LORES|HRMSF_LACE|HRMSF_PAL" */

#define HRMSB_HIRES			3		/* Aspects like Amiga 640x PAL/NTSC */
#define HRMSB_LORES			4		/* Aspects like Amiga 320x PAL/NTSC */
#define HRMSB_LACE			5		/* Aspects like Amiga Lace Modes */
#define HRMSB_1BY2			6		/* Double as WIDTH as HEIGHT */
#define HRMSB_2BY1			7		/* Double as HEIGHT as WIDTH */
#define HRMSB_VGA				8		/* Aspects like IBM (GIF) [4/3] */
#define HRMSB_PAL				9		/* Aspects like PAL [5/4] */
#define HRMSB_NTSC			10		/* Aspects like NTSC [5/3] */

#define HRMSF_FLUSH			(1<<HRMSB_FLUSH)
#define HRMSF_VIDEO			(1<<HRMSB_VIDEO)
#define HRMSF_31KHZ			(1<<HRMSB_31KHZ)

#define HRMSF_HIRES			(1<<HRMSB_HIRES)
#define HRMSF_LORES			(1<<HRMSB_LORES)
#define HRMSF_LACE			(1<<HRMSB_LACE)
#define HRMSF_1BY2			(1<<HRMSB_1BY2)
#define HRMSF_2BY1			(1<<HRMSB_2BY1)
#define HRMSF_VGA				(1<<HRMSB_VGA)
#define HRMSF_PAL				(1<<HRMSB_PAL)
#define HRMSF_NTSC			(1<<HRMSB_NTSC)

/* Definitions for the  Res(mode)-Flags */

#define HRMRESB_16BPC		0		/* Use 16 Bit Per Pixel Clock */
#define HRMRESB_DomBPC		1		/* Use the "Domino Spezial" Mode */
#define HRMRESB_SYNCPH     2		/* Horizontal Sync Polarity Change */
#define HRMRESB_SYNCPV		3		/* Vertical Sync Polarity Change */
#define HRMRESB_PELCLKby2	4		/* Halve Horizontal Pixel-Rate */
#define HRMRESB_9DPCC		5		/* 9 instead of 8 DotPer Character Clock */

#define HRMRESF_16BPC		(1<<HRMRESB_16BPC)
#define HRMRESF_DomBPC		(1<<HRMRESB_DomBPC)
#define HRMRESF_SYNCPH		(1<<HRMRESB_SYNCPH)
#define HRMRESF_SYNCPV		(1<<HRMRESB_SYNCPV)
#define HRMRESF_PELCLKby2	(1<<HRMRESB_PELCLKby2)
#define HRMRESF_9DPCC		(1<<HRMRESB_9DPCC)

#endif

