#include <stdio.h>
#include <stdlib.h>
#include <exec/types.h>
#include <intuition/intuition.h>

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Window *OurWindow;


#define REVISION 33

struct NewWindow NewWindowStructure1 = {
	0,0,	/* window XY origin relative to TopLeft of screen */
	640,512,	/* window width and height */
	0,1,	/* detail and block pens */
	NULL,	/* IDCMP flags */
	ACTIVATE|WINDOWCLOSE|WINDOWDRAG|WINDOWSIZING|SMART_REFRESH|WINDOWDEPTH|GIMMEZEROZERO,	/* other window flags */
	NULL,	/* first gadget in gadget list */
	NULL,	/* custom CHECKMARK imagery */
	"Quicksort window",	/* window title */
	NULL,	/* custom screen pointer */
	NULL,	/* custom bitmap */
	5,5,	/* minimum width and height */
	640,512,	/* maximum width and height */
	CUSTOMSCREEN	/* destination screen type */
};


struct NewScreen NewScreenStructure = {
	0,0,	/* screen XY origin relative to View */
	640,512,	/* screen width and height */
	2,	/* screen depth (number of bitplanes) */
	0,1,	/* detail and block pens */
	LACE+HIRES,	/* display modes for this screen */
	CUSTOMSCREEN,	/* screen type */
	NULL,	/* pointer to default screen font */
	"Hires Screen",	/* screen title */
	NULL,	/* first in list of custom screen gadgets */
	NULL	/* pointer to custom BitMap structure */
};

void OpenAll()
{
  IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library", REVISION);
  if (IntuitionBase==NULL) exit(0);
  GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",REVISION);
  if (GfxBase==NULL) exit(0);
}

struct Window *makewindow(struct screen *screen)
{
  struct Window *tmp;
  extern struct NewWindow NewWindowStructure1;
  NewWindowStructure1.Screen=screen;
  tmp=(struct Window *)OpenWindow(&NewWindowStructure1);
  if (tmp==NULL) 
  {
    CloseScreen(screen);
    exit(0);  /* exit closes all libraries */
  }
  else return(tmp);
}

struct Screen *makescreen()
{
  struct Screen *tmp;
  extern struct NewScreen NewScreenStructure;
  tmp=(struct Screen *)OpenScreen(&NewScreenStructure);
  if (tmp==NULL) exit(0);
  else return(tmp);
}
