/*============================================================*/
/*============================================================*/
/*==														==*/
/*==			Universal Utilities Routines Header			==*/
/*==														==*/
/*============================================================*/
/*============================================================*/

#pragma once

/* switch depth resources reserve	130-139 ID's */
/* file error resources reserve		140-149 ID's */
/* about dialog resources reserve	150-159 ID's */
/* preference resources reserve		160-169 ID's */
/* death error resources reserve	170-179 ID's */
/* minor error resources reserve	180-189 ID's */
/* network resources reserve		190-199 ID's */
/* message window resources reserve	200-209 ID's */
/* sound dialog resources reserve	210-219 ID's */
/* keys configure resources reserve	220-229 ID's */


/*========================================================  Compiler Directives  */

#define kDemoVersion	0


/*========================================================  Prototypes  */

void CenterDialog (short);
void CenterAlert (short);
void FlashDialogButton (DialogPtr, short);
void DrawDefaultButton (DialogPtr, short);
void SetDialogString (DialogPtr, short, StringPtr);
void SetDialogNumToStr (DialogPtr, short, long);
void EnableControl(DialogPtr, short);
void DisableControl(DialogPtr, short);
void SelectFromRadioGroup (DialogPtr, short, short, short);
void LocalToGlobalRect (Rect *);
void GlobalToLocalRect (Rect *);
void ZoomOutDialogRect (short);
void PasStringCopy (StringPtr, StringPtr);
void PasStringCopyNum (StringPtr, StringPtr, short);
void PasStringConcat (StringPtr, StringPtr);
short RandomInt (short);
Boolean RandomCoin (void);
void DeathError (short);
void MinorError (short);
void SimpleMessage (void);
Boolean KeyIsDown (short);
Boolean CommandKeyIsDown (void);
Boolean OptionKeyIsDown (void);
Boolean CommandPeriodDown (void);
void RectFromWindow (Rect *, WindowPtr);
OSErr GetRect (Rect *, short);
void ShowMenuBar (WindowPtr);
void HideMenuBar (WindowPtr);
void USSecsToDateString (long, StringPtr);
void IntlSecsToDateString (long, StringPtr);
void HoldIt (short);
void GetOrigin (Point *);
void SetMouse (Point);
Boolean ForcePointInRect(Point *, Rect *);
void GetChooserName (StringPtr);


/*========================================================  Defines  */

#define	kNilPointer					0L		/* a long zero (nil or NULL) */
#define	kPutInFront			(WindowPtr)-1L	/* for opening windows in front */
#define kRemoveAllEvents			0
#define kMaxShort					32767
#define kMinShort					-32738

#define kAsynch						TRUE
#define kSynch						FALSE
#define kActive						0
#define kInactive					255

#define	kSleepTime					0L
#define	kNormalUpdates				TRUE
#define	kLeaveItWhereItIs			FALSE
#define	kSuspendResumeMssg			1		/* high byte suspend/resume message */
#define	kResumeMask					1		/* bit for resume vs. suspend */

#define	kDITop						0x0050	/*  80 decimal  */
#define	kDILeft						0x0070	/* 112 decimal  */
#define	kPutDialogWide				344		/* Height in pixels of SFPut dialog */
#define	kPutDialogTall				188		/* Width in pixels of SFPut dialog */
#define	kGetDialogWide				344		/* Height in pixels of SFGet dialog */
#define	kGetDialogTall				166		/* Width in pixels of SFGet dialog */

#define kWNETrap					0x60
#define	kSetDepthTrap				0xA2
#define kUnimpTrap					0x9F
#define kGestaltTrap				0xAD

#define	kIsNilWindow				0
#define	kIsUnknownWindow			1
#define	kIsDAWindow					2

#define	kWhiteColor4Bit				0
#define	kYellowColor4Bit			1
#define	kFuschiaColor4Bit			4
#define	kVioletColor4Bit			5
#define	kBlueColor4Bit				6
#define	kBlackColor4Bit				15
#define	kWhiteColor8Bit				0
#define	kBlackColor8Bit				255

#define	kNullString					"\p"

#define	kDisplay1Bit				1
#define	kDisplay2Bit				2
#define	kDisplay4Bit				4
#define	kDisplay8Bit				8

#define kEnterKeyASCII				0x03	/* ASCII code for the Enter key */
#define kHelpKeyASCII				0x05	/* ASCII code for the Help key */
#define kTabKeyASCII				0x09	/* ASCII code for the TAB key */
#define	kReturnKeyASCII				0x0D	/* ASCII code for Return key */
#define	kLeftArrowKeyASCII			0x1C	// ASCII code for the Left Arrow key
#define kRightArrowKeyASCII			0x1D	// ASCII code for the Right Arrow key
#define	kUpArrowKeyASCII			0x1E	// ASCII code for the Up Arrow key
#define kDownArrowKeyASCII			0x1F	// ASCII code for the Down Arrow key
#define k0KeyASCII					0x30
#define k1KeyASCII					0x31
#define k2KeyASCII					0x32
#define k3KeyASCII					0x33
#define k4KeyASCII					0x34
#define k5KeyASCII					0x35
#define k6KeyASCII					0x36
#define k7KeyASCII					0x37
#define kZKeyMap					1		/* key map offset for Z key */
#define kSKeyMap					6		/* key map offset for S key */
#define	kRKeyMap					8		/* key map offset for R key */
#define	kEKeyMap					9		/* key map offset for E key */
#define	kQKeyMap					11		/* key map offset for Q key */
#define	kBKeyMap					12		/* key map offset for B key */
#define kPeriodKeyMap				40		/* key map offset for Period key */
#define	kMKeyMap					41		/* key map offset for M key */
#define	kNKeyMap					42		/* key map offset for N key */
#define	kCommandKeyMap				48		/* key map offset for Command key */
#define kSpaceBarMap				54		/* key map offset for Space Bar */
#define	kTabKeyMap					55		/* key map offset for Tab key */
#define	kOptionKeyMap				61		/* key map offset for Option key */

#define	rDeathAlertID				170		/* alert res. ID for death error */
#define	rErrTitleID					170		/* string ID for death error title*/
#define	rErrMssgID					171		/* string ID for death error message*/
#define	rMinorAlertID				180		/* alert res. ID for minor error */
#define	rMinorErrMssgID				180		/* string ID for minor error message*/
#define rSimpleWindID				200		/* window ID for simple message */
#define rSimpleMssgID				200		/* string ID for simple message */

#define	kErrUnnaccounted			1
#define	kErrNeedMacPlus				2
#define	kErrNeedSystem602			3
#define	kErrNoDevice				4
#define	kErrFailedSwitch			5
#define	kErr2or16Colors				6
#define	kErrNoPictRsrc				7
#define	kErrNoMemory				8
#define kErrNoResource				9
#define kErrPastBeta				10
#define kErrFailedValidation		11
#define kMinorCantNetAndNetOnly		12

#define kMinorNoNetConfirm			1
#define kMinorMasterWrong			2
#define kMinorArenaTooBig			3
#define kMinorArenaTooSmall			4
#define kMinorNetPlayFailed			5
#define kMinor2HumanPlayers			6
#define kMinor2NetPlayers			7

#define kMinorOpponentAborted		9
#define kMinorRegisterFailed		10
#define kMinorSynchFailed			11
#define kMinorNoMasterPossible		12
#define kMinorNetCantPractice		13

#define kMinorNetCantTournament		15
#define kMinorWrongNetVersion		16
#define kMinorCantNetDefault		17
#define kMinorNeedOneValidCopy		18
#define kMinorNetworkOnlyRestrict	19


/*========================================================  Macros Defined  */

#define	SetRect(rect,l,t,r,b)	{(rect)->top = (t); (rect)->left = (l); (rect)->bottom = (b); (rect)->right = (r);}
#define	OffHRect(rect,h)		{(rect)->left += (h); (rect)->right += (h);}
#define	OffVRect(rect,v)		{(rect)->top += (v); (rect)->bottom += (v);}
#define topLeft(r)				(((Point *) &(r))[0])
#define botRight(r)				(((Point *) &(r))[1])
#define LeftShoveRect(rect,l,t)	{(rect)->right += ((l)-(rect)->left); (rect)->bottom += ((t)-(rect)->top); (rect)->left += ((l)-(rect)->left); (rect)->top += ((t)-(rect)->top);}
#define	abs(a)					((a) <0? -(a) : (a))
#define HiWrd(aLong)			(((aLong) >> 16) & 0xFFFF)
#define LoWrd(aLong)			((aLong) & 0xFFFF)

