/****************************************************************************
*		The Amiga dragon program				    *
*		Header file -- Defines screen,window, etc.		    *
*		Created 7/10/85						    *
****************************************************************************/
#include "exec/types.h"
#include "exec/nodes.h"
#include "exec/lists.h"
#include "intuition/intuition.h"
#include "graphics/text.h"
long GfxBase = 0;	/* Base of graphics library */
long IntuitionBase = 0;		/* Base of Intuition library */
struct Window *OpenWindow();
struct InputEvent *Intuition();
struct RastPort *CDRastPort();
struct Screen *OpenScreen();
struct TextAttr TestFont = {
	"Topaz80",8,0,0		/* Define text font for our screen */
	};
USHORT wakeup;	/* Wake me up for event */
USHORT class;	/* Intu event class */
USHORT code;	/* Intu event code */
USHORT qual;	/* Intu event qualifier */
USHORT mode;	/* Intu event mode */
APTR address;	/* address of gadget that user hit */
struct Window *w;		/* Lots of pointers for lots of things */
struct RastPort *rp,*cdrp;
struct ViewPort *vp;
struct IntuiMessage *message;
struct Screen *screen;
/************************ Screen Defines ***********************************/

struct NewScreen ns = {
	0,0,			/* start pos.*/
	640,400,2,		/* width height depth (2 bit planes) */
	0,1,			/* detail pen, block pen */
	HIRES | LACE,	 	/* viewing mode (640x400 interlaced) */
	CUSTOMSCREEN,		/* screen type */
	&TestFont,		/* font */
	"Fractles",		/* screen title */
	NULL			/* gadget pointer */
	};
/************************ Window Defines ***********************************/

struct NewWindow nw = {
		0,0,			/* Starting corner */
		640,400,		/* Width, height */
		0,1,			/* detail, block pens */
	CLOSEWINDOW,			/* IDCMP flags */
	WINDOWCLOSE | WINDOWSIZING | GIMMEZEROZERO,
					/* Window flags */
		NULL,			/* Pointer to first gadget */
		NULL,			/* Pointer to checkmark */
		"Dragon",		/* title */
		NULL,			/* screen pointer */
		NULL,			/* bitmap pointer */
		30,30,640,400,		/* sizing limits */
		CUSTOMSCREEN		/* type of screen */
		};

/************************ Set-Up routine ***********************************
*	This function opens the Intuition and Graphics libraries, then     *
*       opens up our custom screen and window, defining screen colors,     *
*	size, etc...							   *
***************************************************************************/
initwind()
{
	GfxBase = OpenLibrary("graphics.library",0); /* Get graphics driver */
	if(GfxBase == NULL)
	{
		printf("Can't open graphics library...\n");
		exit();
	}
	IntuitionBase = OpenLibrary("intuition.library",0); /*Get Intuition*/  
	if(IntuitionBase == NULL)
	{
		printf("Can't open intuition library...\n");
		exit();
	}
	screen = OpenScreen(&ns); /* Open our new screen */
	if(screen == NULL)
	{
		exit(0);
	}
	nw.Screen = screen;
	w = OpenWindow(&nw);		/* Open our new window */
	rp = w->RPort;			/* Get the raster port pointer */
	vp = &w->WScreen->ViewPort;	/* Get the view port pointer */
	SetRGB4(vp,0,0,0,15);		/* Color 0 is blue */
	SetRGB4(vp,1,15,0,0);		/* Color 1 is red */
	SetRGB4(vp,2,0,15,0);		/* Color 2 is green */
	SetRGB4(vp,3,15,15,15);		/* Color 3 is white */
	SetDrMd(rp,JAM1);		/* Draw with foreground pen only */
}

