unit Globals;

interface
	uses
		Palettes;

	const
		kGlideVersion = $0100;		{version of house format}

		kStackSize = 24576;			{must be even - stack size}
		kSleep = 1;				{sleep time in Ticks}
		kSuspendResumeBit = $0001;	{for WNE}
		kResuming = 1;				{for WNE}
		kSecondaryAddr = $3F2700;		{address of alternate page buffer}
		kSlowScoreIncrement = 17;		{fast machine extend score-odometer}
		kFastScoreIncrement = 37;		{slow machine race score-odometer}
		kMouseSlop = 1;				{who knows}
		kMinBassLoop = 14;			{quickest pace of duh-dum}
		kBassFract = 8;				{smaller = slower bass @ 1st / larger = quicker}
		kBonusTimeToBeat = 256;		{number of passes for time bonus}
		kCeilingVert = 24;			{absolute ceiling in pixels}
		kFloorVert = 325;			{absolute floor in pixels}
		kFloorLimit = kFloorVert + 5;
		kMaxThrust = 5;				{maximum speed (in pixels) of glider}
		kLastHelpScreen = 7;			{number of help screens}
		kCursCount = 12;			{number of frames for animated cursor}

		rAcurID = 128;				{resource ID numbers}
		rMainWndoID = 128;
		rAlertID = 128;
		rFileAlertID = 129;
		rSoundDlgID = 131;
		rQuitNoSaveAlertID = 132;
		rDepthAlertID = 136;
		rCustomKeysID = 137;
		rCustGetID = 256;
		rAlertStrIDs = 128;
		rFileStrIDs = 129;
		rMiscStrID = 130;
		rDemoStrIDs = 131;
		rObjectPictID = 128;
		rMaskPictID = 129;
		rFarmPict = 130;
		rSidePict1 = 140;
		rSidePict2 = 141;
		rIdleID = 200;
		rColorIdleID = 210;
		rHelpBasePictID = 1000;

		kDefaultLeftKey = $2B;			{default control keys}
		kDefaultRightKey = $2F;
		kDefaultEnergyKey = $24;
		kDefaultBandKey = $31;
		kDefaultLeftName = ', key';		{default names for control keys}
		kDefaultRightName = '. key';
		kDefaultEnergyName = 'return';
		kDefaultBandName = 'space';
		kTabKey = $09;					{misc. ascii codes}
		kReturnKey = $0D;
		kSpaceBar = $20;
		kSKeyMap = $01;					{misc. keymap codes}
		kQKeyMap = $0C;
		kEKeyMap = $0E;
		kReturnKeyMap = $24;
		kTabKeyMap = $30;
		kControlKeyMap = $3B;
		kCommandKeyMap = $37;
		kShiftKey = $38;

		kErrUnaccounted = 1;				{error codes}
		kErrMacPlusNeeded = 2;			{these correspond with STR#}
		kErr2Or16Colors = 4;				{resources for the TEXT part}
		kErrNotEnoughMem = 5;			{of the message}
		kErrUnknownAtInit = 6;
		kErrMemLow = 7;
		kErrGraphicsNotFound = 8;
		kErrGraphicLoad = 9;
		kErrSavingPrefs = 10;
		kErrAirChange = 11;
		kErrLoadingRes = 12;
		kErrFileExists = 13;
		kErrNothingToPrint = 14;
		kErrWrongHouseVers = 15;
		kErrLoadingDfltHouse = 16;
		kErrLoadingPrefs = 17;
		kErrNotDemoHouse = 18;
		kErrExitSansGraphics = 19;
		kErrGraphicsAre2Bit = 20;
		kErrGraphicsAre16Bit = 21;
		kErrGameOldVers = 22;
		kErrExitSansHouse = 23;
		kErrHouseModified = 24;
		kErrBackgroundMusic = 25;
		kErrDepthSwitched = 26;
		kErrStartUpWrongType = 27;
		kErrNoSounds = 28;
		kErrVolLocked = 29;
		kErrMissionINIT = 30;
		kErrNotFirstHouse = 31;
		kErrDemoRefuseHouse = 32;
		kErrNewKeyboard = 33;

		kHouseType = 0;
		kArtType = 1;
		kGameType = 2;

		nulObj = 0;					{room object codes}
{furniture}
		table = 1;
		shelf = 2;
		books = 3;
		cabnet = 4;
		extRct = 5;
		obsRct = 6;
{blowers}
		flrVnt = 8;
		celVnt = 9;
		celDct = 10;
		candle = 11;
		lftFan = 12;
		ritFan = 13;
{table objects}
		clock = 16;
		paper = 17;
		grease = 18;
		bnsRct = 19;
		battry = 20;
		rbrBnd = 21;
{wall objects}
		litSwt = 24;
		outlet = 25;
		thermo = 26;
		shredr = 27;
		pwrSwt = 28;
		guitar = 29;
{animate objects}
		drip = 32;
		toastr = 33;
		ball = 34;
		fshBwl = 35;
		teaKtl = 36;
		window = 37;
{jewelry}
		paintg = 40;
		mirror = 41;
		basket = 42;
		macTsh = 43;
		upStar = 44;
		dnStar = 45;

		normal = 0;		{glider situational modes}
		fadingIn = 1;
		fadingOut = 2;
		turnRt2Lf = 3;
		turnLf2Rt = 4;
		burning = 5;
		ascending = 6;
		descending = 7;
		shredding = 8;
					{objects effects codes}
		ignoreIt = 0;		{null or unknown objects}
		crashIt = 1;		{tables, shelves, cabinets, etc...}
		liftIt = 2;		{floor vents}
		dropIt = 3;		{ceiling blower, some ducts}
		moveIt = 4;		{exit rects/suction ceiling ducts}
		burnIt = 5;		{candle if too close}
		turnItLeft = 6;		{left fan}
		turnItRight = 7;	{right fan}
		awardIt = 8;		{clocks}
		extraIt = 9;		{folded pieces of paper}
		slideIt = 10;		{grease fallen}
		trickIt = 11;		{bonus rect}
		energizeIt = 12;	{battery}
		bandIt = 13;		{rubber bands}
		playIt = 14;		{guitar}
		lightIt = 15;		{light switch}
		zapIt = 16;		{wall outlet}
		airOnIt = 17;		{thermostats}
		shredIt = 18;		{shredder}
		toggleIt = 19;		{power switch}
		weightIt = 20;		{?}
		spillIt = 21;		{grease standing up}
		ascendIt = 22;		{up stair case}
		descendIt = 23;		{down stair case}
		steamIt = 24;

		highScoreMode = 0;	{demo mode numbers}
		balloonMode = 1;
		copterMode = 2;
		dartMode = 3;
		controlMode = 4;
		tabMode = 5;
		adMode = 6;
		editorMode = 7;
		colorMusicMode = 8;
		ventCandleMode = 9;
		bandBatteryMode = 10;
		paperClockMode = 11;
		lastDemo = 11;
		helpScreensMode = 99;

		iNothing = 0;
		mApple = 128;		{Menu resource ID}
		iAbout = 1;		{Menu items}

		mGame = 129;		{Menu resource ID}
		iBegin = 1;		{Menu itemsÉ}
		iLoadHouse = 2;
		iEndGame = 3;
		iLoadGame = 5;
		iSaveGame = 6;
		iSaveGameAs = 7;
		iQuit = 9;

		mOption = 130;		{Menu resource ID}
		iControls = 1;		{Menu itemsÉ}
		iSound = 2;
		iShowAir = 3;
		iRestoreDeep = 4;
		iHiScores = 6;
		iHelp = 8;

		mControls = 131;	{Menu resource ID}
		iHoldKeyboard = 1;	{Menu itemsÉ}
		iDropKeyboard = 2;
		iAbsMouse = 3;
		iRelMouse = 4;
		iConfigure = 6;

		whoCares = 0;		{place where entered room}
		topOfRoom = 1;
		bottomOfRoom = 2;
		leftOfRoom = 3;
		rightOfRoom = 4;

		kWhistleSound = 13;
		kTapSound = 27;
		kCRSound = 28;
		kMusicSound = 29;	{ID of music sound}
		kDuhDumSound = 30;	{ID of bass beat}


	type
		objectData = record
				objectIs: Integer;
				boundRect: Rect;
				amount: Integer;
				extra: Integer;
				isOn: Boolean;
			end;

		roomData = record
				roomName: string[24];
				numberOObjects: Integer;
				backPictID: Integer;
				tileOrder: array[0..7] of Integer;
				leftOpen, rightOpen: Boolean;
				animateKind: Integer;
				animateNumber: Integer;
				animateDelay: LongInt;
				conditionCode: Integer;
				theObjects: array[1..16] of objectData;
			end;

		houseRec = record
				version: Integer;
				numberORooms: Integer;
				timeStamp: LongInt;
				hiScores: array[0..19] of LongInt;
				hiLevel: array[0..19] of Integer;
				hiName: array[0..19] of string[24];
				hiRoom: array[0..19] of string[24];
				pictFile: string[32];
				nextFile: string[32];
				firstFile: string[32];
				theRooms: array[1..40] of roomData;
			end;

		gliderRec = record
				destRect, oldRect, wholeRect: Rect;
				shadoDest, oldShado, wholeShado: Rect;
				touchRect: Rect;
				timeStamp: LongInt;
				mode, phase: Integer;
				srcNum: Integer;
				forVel: Integer;
				mass: Integer;
				bands, energy: Integer;
				isRight, isForward: Boolean;
			end;

		animateRec = record
				destRect, wholeRect, oldRect: Rect;
				horiOff, vertOff: Integer;
				kind, phase: Integer;
				tickStamp, delay: LongInt;
				unSeen: Boolean;
			end;

		cycleRec = record
				holdRect, wholeRect, oldRect: Rect;
				tiedTo, kindIs, phase: Integer;
				reset, position: LongInt;
				accel, velocity: Integer;
			end;

		bandRec = record
				dest, whole, old: Rect;
				phase, velocity: Integer;
			end;

		scoreRec = record
				rank: Integer;
				changed: Boolean;
			end;

		pointRec = record
				whereR: Rect;
				tickStamp: LongInt;
				saysWhat: string[16];
				out: Boolean;
			end;

		lightningRec = record
				theBolts: array[1..3, 0..7, 0..1] of Integer;
				whichBolt, whatPhase: Integer;
				whatTime: LongInt;
			end;

		BitMapPtr = ^BitMap;
		IntPtr = ^Integer;
		LongintPtr = ^Longint;

		acur = record
				whichBall: LongInt;
				ball: array[1..kCursCount] of CursHandle;
			end;
		acurPtr = ^acur;
		acurHand = ^acurPtr;

	var
		theEvent: EventRecord;

		mainWndo: WindowPtr;
		mainPalette: PaletteHandle;
		wholeArea, fullArea, nullRect, smScoreRect, lgScoreRect: Rect;
		wholeRgn: RgnHandle;
		offMaskMap, offVirginMap, offLoadMap, offPlayerMap, offReserveMap: BitMap;
		offMaskPort, offVirginPort, offLoadPort, offPlayerPort, offReservePort: GrafPtr;
		offMaskBits, offVirginBits, offLoadBits, offPlayerBits, offReserveBits: Ptr;
		virginCPort, loadCPort, objectCPort, reserveCPort: CGrafPort;
		virginCPtr, loadCPtr, objectCPtr, reserveCPtr: CGrafPtr;
		virginCBits, loadCBits, objectCBits, reserveCBits: Ptr;
		rgbBlack, rgbWhite, rgbLtBlue, rgbRed, rgbBlue, rgbLtGreen: RGBColor;
		rgbYellow, rgbViolet, rgbBrown, rgbLtBrown, rgbDkGray: RGBColor;
		noCursor: CursHandle;

		thisHouse: houseRec;
		theKeys: KeyMap;
		theErr: OSErr;

		currentBall: Integer;
		ballList: acurHand;
		ballC: array[1..kCursCount] of CCrsrHandle;

		theAnimates: array[1..16] of animateRec;
		animateRct: array[0..2, -1..16] of Rect;
		cycleObjects: array[1..16] of cycleRec;

		floatPoints: pointRec;

		theGlider: GliderRec;
		roomVisits: array[1..40] of Boolean;
		glideRct: array[0..27] of Rect;
		shadoRct: array[0..1] of Rect;
		nextPhase: array[1..4, 0..16] of Integer;

		theBand: BandRec;
		bandRct: array[0..2] of Rect;

		roomScore, suppScore, rollScore, loopsThruRoom, workingGameNumber: LongInt;
		scoreList: scoreRec;

		rightOffset, downOffset, gliderResNum, wasSndVolume: Integer;
		controlMethod, demoMode, demoCount, wasDepth: Integer;
		liftAmount, mortals, shiftAmount, sideYouCantExit: Integer;
		leftKey, rightKey, energyKey, bandKey, scoreIncrement: Integer;
		roomAt, roomsPassed, nObjects, binaryFlip: Integer;
		gameNumber, houseNumber, wasMBarHeight: Integer;
		houseVolNum, gameVolNum, resVolNum, bassLoop, playBassTime: Integer;
		nAnimates, nCycleObs, herKeyBoard, iGlidersHelp: Integer;

		leftName, rightName, energyName, bandName: string[12];
		playerName: string[24];
		musicName, gameName, resourceName: string[32];
		firstFileName, defaultHouse, housesName: string[32];
		mirrorRgn, windowRgn, toastRgn: RgnHandle;
		theLightning: LightningRec;

		tileRects: array[0..7] of Rect;
		srcRect: array[0..69] of Rect;
		eventRect, reserveRects: array[0..16] of Rect;
		eventKind: array[0..16, 0..2] of LongInt;

		windowOpen, hasWindow, leftIsOpen, rightIsOpen, enteredLeft: Boolean;
		cantSwitch, airVisible, hasMirror, hasToast, lightsOut, airOut: Boolean;
		bandBorne, cantColor, soundOn, musicOn, inhibitSound, hasSys7: Boolean;
		buttonFires, cantMusic, smsIsActive, doneFlag, inColor: Boolean;
		inBackground, playing, pausing, hasWNE, restoreColor, refuseHigh: Boolean;
		scoreIsRolling, lifeNormal, didntExitEntrance, areFlipping: Boolean;
		mainScreenHidden, fileWasLost, is4Channel, useColorCursor: Boolean;

implementation
end.