#include "stdio.h"
#include "intuition/intuitionbase.h"
#include "exec/types.h"
#include "intuition/intuition.h"
#include "graphics/gfxbase.h"

/* Include A Font header here */
#include ":Carmela/42.h"

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;
struct Screen *CustScr;
struct Window *Wdw;
struct ViewPort *WVP;
struct IntuiMessage *message;

struct NewScreen ns = {
	0,0,	
	640,200,
	4,	
	0,1,	
	HIRES,	
	CUSTOMSCREEN,	
	NULL,	
	"Font Test Screen",	
	NULL,	
	NULL	
};


USHORT Palette[] = {
	0x0AAA,	
	0x0900,	
	0x0FFF,	
	0x0000,	
	0x000F,	
	0x0F0F,	
	0x00FF,	
	0x0FFF,	
	0x0620,	
	0x0E50,	
	0x09F1,	
	0x0EB0,	
	0x055F,	
	0x092F,	
	0x00F8,	
	0x0CCC	
};

#define PALETTE Palette

struct NewWindow nw = {
	0,0,
	640,200,	
	0,1,	
	CLOSEWINDOW,	
	WINDOWSIZING+WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH,	
	NULL,	
	NULL,	
	"Test Font Window  by Terry Bullard",	
	NULL,	
	NULL,	
	5,5,	
	-1,-1,	
	CUSTOMSCREEN	
};


#define rp Wdw->RPort

#define RN 0L
void imgone();
void dothings();

main()
   {
int x,y;
if((IntuitionBase=(struct IntuitionBase *)
    OpenLibrary("intuition.library",RN)) == NULL) 
       exit(0);

if((GfxBase=(struct GfxBase *)
    OpenLibrary("graphics.library",RN)) == NULL) {
		CloseLibrary(IntuitionBase);
		exit(0);
		}	

if((nw.Screen = CustScr =
(struct Screen *)OpenScreen(&ns)) == NULL) {
	CloseLibrary(GfxBase);
	CloseLibrary(IntuitionBase);
	exit(0);
	}

if ((Wdw = (struct Window *)OpenWindow(&nw)) == NULL) {
	CloseScreen(CustScr);
	CloseLibrary(GfxBase);
	CloseLibrary(IntuitionBase);
	exit(0);
	}

WVP = (struct ViewPort *)ViewPortAddress(Wdw);
LoadRGB4(WVP,Palette,16);

SetAPen(rp,6);
SetFont(rp,&WTextFont);

y = WTextFont.tf_YSize;
x = y+11;
Move(rp,10,x);
Text(rp,"AaBbCcDdEeFfGgHhIiJj",20);
x=x+y+2;
Move(rp,10,x);
Text(rp,"KkLlMmNnOoPpQqRrSsTt",20);
x=x+y+2;
Move(rp,10,x);
Text(rp,"UuVvWwXxYyZz12345678",20);
x=x+y+2;
Move(rp,10,x);
Text(rp,"90!@#$%^&*()_+|-=ZZZ",20);
dothings();
}

void imgone()
{
RemFont(WTextFont);
CloseWindow(Wdw);
CloseScreen(CustScr);
CloseLibrary(GfxBase);
CloseLibrary(IntuitionBase);
exit(0);
   }

void dothings()
   {
ULONG MessageClass;
USHORT code;
for(;;) {
	WaitPort(Wdw->UserPort);
   if(message = (struct IntuiMessage *)GetMsg(Wdw->UserPort)) {
      MessageClass = message->Class;
      code = message->Code;
      ReplyMsg((struct Message *)message);
      switch(MessageClass) {
         case CLOSEWINDOW :
         imgone();
         break;
         }
      }
   }
}

