#include "Pandora Booter Kernel.h"
#include "Pandora Booter Errors.h"

void		InitToolbox(void);
char		CheckSystem(void);

void main(void)
{
	InitToolbox();
	
	DialogPtr theDlog = GetNewDialog(128,nil,(DialogPtr)-1L);
	
	SelectWindow(theDlog);
	SetPort((GrafPtr)theDlog);
	SetDialogDefaultItem(theDlog,1);
	
	TextFont(geneva);
	TextSize(9);
	
	MoveTo(15,135);
	DrawString("\pPandora Booter ");
	
	PVersion version(kBooterVersion);
	drawstring(version);
	
	DrawDialog(theDlog);
	
	if(CheckSystem())
		Boot();
}

void InitToolbox(void)
{
	InitGraf(&qd.thePort);
	InitFonts();
	FlushEvents(everyEvent,false);
	InitWindows();
	TEInit();
	InitDialogs(nil);
	InitCursor();
}

char CheckSystem(void)
{
	long sysaVal;
	OSErr err;
	
	err = Gestalt('sysa',&sysaVal);
	if(err || sysaVal != gestaltPowerPC)
	{
		WaitMessage("\pThe Pandora OS cannot run on this kind of machine.  You need a PowerPC computer.");
		return false;
	}
	
	return true;
}
