UNIT Initialization;
INTERFACE
USES
	Globals, SubInitialization;

PROCEDURE InitBasicStuff;
PROCEDURE InitGame;
IMPLEMENTATION
{*****************************************************************}
PROCEDURE InitStandardCard (CardNum, StandardType: Integer; CName: Str20);
{frozen}
	VAR
		i: Integer;
	BEGIN
		CardName[CardNum] := CName;
		ThisCard := CardNum;
		LoadCard;
		SavedMapPtr[StandardType] := NewPtr(PackedSize);
		BlockMove(PackedMapPtr, SavedMapPtr[StandardType], Size(PackedSize));
		SavedNumTriangles[StandardType] := NumTriangles;
		i := 1;
		WHILE i <= NumTriangles DO
			BEGIN
				SavedCTriangle[StandardType, i] := CTriangle[i];
				i := i + 1;
			END;
	END;
{*****************************************************************}
PROCEDURE InitBasicStuff;
{liquid}
	VAR
		i, j, k, x, y: Integer;
		MacError: OSErr;
		theWorld: SysEnvRec;
		TempStr: Str255;
	BEGIN

		QuitFlag := FALSE;
		LoadGameFlag := FALSE;
		PScrollFlag := FALSE;
{ECO 6: two new initialization declarations}
		WarningFlag := FALSE;
		NoWarningYet := TRUE;
		Year := 1989; {ECO 6: changed Year to 1989}
		Turn := 0; {ECO 6: changed Turn to 0}
		WatchCursr := GetCursor(WatchCursor);
		MaltaKreuz := GetCursor(258);
		MacError := SysEnvirons(1, theWorld);
		YesColor := theWorld.hasColorQD;
		PackedMapPtr := NewPtr(MaxScreenSize);
		SetRect(BitMapRect, 0, 0, BitMapWidth, BitMapHeight);
{ECO 1: Extended ValueRect 5 pixels right}
{ECO 2: and 16 pixels up}
		SetRect(ValueRect, BaseX, BaseY - 128, 512, BaseY - 100);

		x := screenbits.bounds.right DIV 2;
		y := screenbits.bounds.bottom DIV 2;
		SetRect(StdRect, x - 256, y - 151, x + 256, y + 171);
		FOR i := 1 TO MaxNoCards DO
			BEGIN
				CauseCount[i] := 0;
				EffectCount[i] := 0;
				FOR j := 1 TO MaxCauses DO
					BEGIN
						Cause[i, j] := 0;
						Effect[i, j] := 0;
					END;
			END;

		Cause[LakeAcidity, 1] := AcidRain;
		Cause[AcidRain, 1] := SulfurDioxide;
		Cause[AcidRain, 2] := NitrousDioxide;
		Cause[AveEnergyPrice, 1] := CoalPrice;
		Cause[AveEnergyPrice, 2] := DamPrice;
		Cause[AveEnergyPrice, 3] := NaturalGasPrice;
		Cause[AveEnergyPrice, 4] := NuclearPrice;
		Cause[AveEnergyPrice, 5] := OilPrice;
		Cause[AveEnergyPrice, 6] := SolarEnergyPrice;
		Cause[BeefProduction, 1] := BeefTax;
		Cause[BeefProduction, 2] := Grasslands;
		Cause[BiodiversityPoints, 1] := GlobalGenePool;
		Cause[Biotechnology, 1] := BasicResearch%S;
		Cause[Biotechnology, 2] := BioResearch%S;
		Cause[BirthRate, 1] := QualityOfLife;
		Cause[BirthRate, 2] := FamilyPlanning%S;
		Cause[CarbonDioxide, 1] := CoalUse;
		Cause[CarbonDioxide, 2] := ForestClearing;
		Cause[CarbonDioxide, 3] := OilUse;
		Cause[CarbonDioxide, 4] := NaturalGasUse;
		Cause[CFCProduction, 1] := CFCTax;
		Cause[CFCProduction, 2] := MaterialsDemand;
		Cause[CoalPrice, 1] := CoalSupply;
		Cause[CoalPrice, 2] := CoalUse;
		Cause[CoalSupply, 1] := CoalPrice;
		Cause[CoalSupply, 1] := TotalCoalUse;
		Cause[CoalTechnology, 1] := CoalResearch%S;
		Cause[CoalTechnology, 2] := BasicResearch%S;
		Cause[CoalUse, 1] := CoalPrice;
		Cause[CoalUse, 2] := CoalTax;
		Cause[CoalUse, 3] := EnergyDemand;
		Cause[ComputerGamesPts, 1] := ConsumerGoods;
		Cause[ConsumerGoods, 1] := IndustrialOutput;
		Cause[CropStrains, 1] := BioTechnology;
		Cause[CropStrains, 2] := GlobalGenePool;
		Cause[CropTechnology, 1] := CropStrains;
		Cause[CropTechnology, 2] := PesticideUse;
		Cause[CropTechnology, 3] := FertilizerUse;
		Cause[CropYields, 1] := CropTechnology;
		Cause[CropYields, 2] := UV;
		Cause[CropYields, 3] := WaterSupply;
		Cause[Crops, 1] := BeefProduction;
		Cause[Crops, 2] := CropYields;
		Cause[Crops, 3] := FarmLand;
		Cause[DamPrice, 1] := DamUse;
		Cause[DamUse, 1] := DamPrice;
		Cause[DamUse, 2] := Dam%S;
		Cause[DamUse, 3] := EnergyDemand;
		Cause[Desertification, 1] := FuelwoodUse;
		Cause[Desertification, 2] := Overgrazing;
		Cause[DrinkingWater, 1] := WaterSupply;
		Cause[EnergyConservation, 1] := AveEnergyPrice;
		Cause[EnergyConservation, 2] := RecycledAluminum;
{ECO 6: next line commented out}
{Cause[EnergyDemand, 1] := GrossGlobalProduct;}
		Cause[FallPoints, 1] := FallsFromRoofs;
		Cause[FallsFromRoofs, 1] := SolarEnergyUse;
		Cause[FarmLand, 1] := ForestClearing;
		Cause[FertilizerUse, 1] := FertilizerTax;
		Cause[FertilizerUse, 2] := IndustrialOutput;
		Cause[FloodDeathPoints, 1] := FloodDeaths;
		Cause[FloodDeaths, 1] := SoilErosion;
		Cause[FloodDeaths, 2] := DamUse;
		Cause[FoodSupply, 1] := BeefProduction;
		Cause[FoodSupply, 2] := Crops;
		Cause[FoodSupply, 3] := SeaFood;
		Cause[ForestClearing, 1] := DebtForNature%S;
		Cause[ForestClearing, 2] := Starvation;
		Cause[ForestHabitats, 1] := ForestLand;
		Cause[ForestLand, 1] := AcidRain;
		Cause[ForestLand, 2] := ForestClearing;
		Cause[ForestLand, 3] := FuelwoodUse;
		Cause[ForestLand, 4] := Logging;
		Cause[ForestLifePoints, 1] := ForestHabitats;
		Cause[FuelwoodUse, 1] := Population;
		Cause[FuelwoodUse, 2] := WoodStove%S;
		Cause[Garbage, 1] := GrossGlobalProduct;
		Cause[Garbage, 2] := RecycledPaper;
		Cause[GlobalGenePool, 1] := ForestHabitats;
		Cause[GlobalGenePool, 2] := LakeHabitats;
		Cause[GlobalGenePool, 3] := MarineLife;
		Cause[GlobalGenePool, 4] := RiparianHabitats;
		Cause[GlobalTemperature, 1] := CarbonDioxide;
		Cause[GlobalTemperature, 2] := Methane;
		Cause[GlobalTemperature, 3] := TroposphericCFCs;
		Cause[Grasslands, 1] := Desertification;
		Cause[GrossGlobalProduct, 1] := IndustrialOutput;
		Cause[GroundwaterSupply, 1] := GroundwaterUse;
		Cause[GroundwaterUse, 1] := GroundwaterSupply;
		Cause[GroundwaterUse, 2] := LandAbuse;
{ECO 6: changed to "AveEnergyPrice" from "MaterialsDemand"}
		Cause[GroundwaterUse, 3] := AveEnergyPrice;
		Cause[HeavyMetalDeaths, 1] := HeavyMetalUse;
		Cause[HeavyMetalPoints, 1] := HeavyMetalDeaths;
		Cause[HeavyMetalPrice, 1] := HeavyMetalSupply;
		Cause[HeavyMetalPrice, 2] := HeavyMetalUse;
		Cause[HeavyMetalSupply, 1] := HeavyMetalPrice;
		Cause[HeavyMetalSupply, 2] := TotHeavyMetUse;
		Cause[HeavyMetalUse, 1] := HeavyMetalPrice;
		Cause[HeavyMetalUse, 2] := HeavyMetalTax;
		Cause[HeavyMetalUse, 3] := MaterialsDemand;
		Cause[Housing, 1] := IndustrialOutput;
		Cause[Housing, 2] := Logging;
		Cause[IndustrialInput, 1] := CFCProduction;
		Cause[IndustrialInput, 2] := GlobalGenePool;
		Cause[IndustrialInput, 3] := HeavyMetalUse;
		Cause[IndustrialInput, 4] := NetEnergy;
		Cause[IndustrialOutput, 1] := IndustrialInput;
		Cause[InundationPoints, 1] := SeaLevel;
		Cause[LakeHabitats, 1] := LakeAcidity;
		Cause[LakeLifePoints, 1] := LakeHabitats;
		Cause[LandAbusePoints, 1] := LandAbuse;
		Cause[LandAbuse, 1] := Garbage;
		Cause[LandAbuse, 2] := StripMining;
		Cause[Logging, 1] := LoggingTax;
		Cause[Logging, 2] := MaterialsDemand;
		Cause[Logging, 3] := RecycledPaper;
		Cause[LungDiseaseDeaths, 1] := SulfurDioxide;
		Cause[LungDiseaseDeaths, 2] := NitrousDioxide;
		Cause[LungDiseasePts, 1] := LungDiseaseDeaths;
		Cause[MarineLifePoints, 1] := MarineLife;
		Cause[MarineLife, 1] := OilSpills;
		Cause[MarineLife, 2] := PesticideUse;
		Cause[MarineLife, 3] := Phytoplankton;
		Cause[MarineLife, 4] := Seafood;
{ECO 6: next line deleted}
{Cause[MaterialsDemand, 1] := GrossGlobalProduct;}
		Cause[Medicines, 1] := BioTechnology;
		Cause[Medicines, 2] := GlobalGenePool;
		Cause[Methane, 1] := BeefProduction;
		Cause[Methane, 2] := AcidRain;
		Cause[NaturalGasPrice, 1] := NaturalGasSupply;
		Cause[NaturalGasPrice, 2] := NaturalGasUse;
		Cause[NaturalGasSupply, 1] := NaturalGasPrice;
		Cause[NaturalGasSupply, 2] := TotalNatGasUse;
		Cause[NaturalGasUse, 1] := EnergyDemand;
		Cause[NaturalGasUse, 2] := NaturalGasPrice;
		Cause[NaturalGasUse, 3] := NaturalGasTax;
		Cause[NetEnergy, 1] := EnergyConservation;
		Cause[NetEnergy, 2] := NonRenewEnergy;
		Cause[NetEnergy, 3] := RenewableEnergy;
		Cause[NitrousDioxide, 1] := CoalTechnology;
		Cause[NitrousDioxide, 2] := CoalUse;
		Cause[NitrousDioxide, 3] := OilTechnology;
		Cause[NitrousDioxide, 4] := OilUse;
		Cause[NonRenewEnergy, 1] := CoalUse;
		Cause[NonRenewEnergy, 2] := NaturalGasUse;
		Cause[NonRenewEnergy, 3] := NuclearUse;
		Cause[NonRenewEnergy, 4] := OilUse;
		Cause[NorthernLifestyle, 1] := BeefProduction;
		Cause[NorthernLifestyle, 2] := ConsumerGoods;
		Cause[NorthernLifestyle, 3] := Medicines;
		Cause[NorthernLifestyle, 4] := NetEnergy;
		Cause[NuclearAccidents, 1] := NuclearTechnology;
		Cause[NuclearAccidents, 2] := NuclearUse;
		Cause[NuclearPrice, 1] := NuclearSupply;
		Cause[NuclearPrice, 2] := NuclearUse;
		Cause[NuclearSupply, 1] := NuclearPrice;
		Cause[NuclearSupply, 2] := TotalNuclearUse;
		Cause[NuclearTechnology, 1] := BasicResearch%S;
		Cause[NuclearTechnology, 2] := NuclearResearch%S;
		Cause[NuclearUse, 1] := EnergyDemand;
		Cause[NuclearUse, 2] := NuclearPrice;
		Cause[NuclearUse, 3] := NuclearTax;
		Cause[OilSpills, 1] := OilUse;
		Cause[OilPrice, 1] := OilSupply;
		Cause[OilPrice, 2] := OilUse;
		Cause[OilSupply, 1] := OilPrice;
		Cause[OilSupply, 2] := TotalOilUse;
		Cause[OilTechnology, 1] := BasicResearch%S;
		Cause[OilTechnology, 2] := OilResearch%S;
		Cause[OilUse, 1] := EnergyDemand;
		Cause[OilUse, 2] := OilPrice;
		Cause[OilUse, 3] := OilTax;
		Cause[Overgrazing, 1] := Starvation;
		Cause[Ozone, 1] := StratosphericCFC;
		Cause[PesticideDeathPts, 1] := PesticideDeaths;
		Cause[PesticideDeaths, 1] := PesticideUse;
		Cause[PesticideUse, 1] := IndustrialOutput;
		Cause[PesticideUse, 2] := PesticideTax;
		Cause[Phytoplankton, 1] := UV;
		Cause[Population, 1] := BirthRate;
		Cause[Population, 2] := Starvation;
		Cause[PropertyDamage%S, 1] := NitrousDioxide;
		Cause[PropertyDamage%S, 2] := SulfurDioxide;
		Cause[QualityOfLife, 1] := NorthernLifestyle;
		Cause[QualityOfLife, 2] := Population;
		Cause[QualityOfLife, 3] := SouthernLifestyle;
		Cause[QualityPoints, 1] := QualityOfLife;
		Cause[RadWastePoints, 1] := RadWaste;
		Cause[RadWaste, 1] := NuclearTechnology;
		Cause[RadWaste, 2] := NuclearUse;
		Cause[RadiationCancer, 1] := Radiation;
		Cause[RadiationCancer, 2] := NuclearAccidents;
		Cause[RadiationPoints, 1] := RadiationCancer;
		Cause[Radiation, 1] := NuclearTechnology;
		Cause[Radiation, 2] := NuclearUse;
		Cause[RecycledAluminum, 1] := RecyclingCenter%S;
		Cause[RecycledPaper, 1] := RecyclingCenter%S;
		Cause[RenewableEnergy, 1] := DamUse;
		Cause[RenewableEnergy, 2] := SolarEnergyUse;
		Cause[ReservoirCapacity, 1] := DamUse;
		Cause[RiparianHabitats, 1] := DamUse;
		Cause[SeaLevel, 1] := GlobalTemperature;
		Cause[Seafood, 1] := MarineLife;
		Cause[SkinCancerDeaths, 1] := UV;
		Cause[SkinCancerPoints, 1] := SkinCancerDeaths;
		Cause[SoilErosion, 1] := Desertification;
		Cause[SoilErosion, 2] := ForestClearing;
		Cause[SolarEnergyPrice, 1] := SolarEnergyUse;
		Cause[SolarEnergyPrice, 2] := SolarTechnology;
		Cause[SolarEnergyUse, 1] := EnergyDemand;
		Cause[SolarEnergyUse, 2] := SolarEnergy%S;
		Cause[SolarEnergyUse, 3] := SolarEnergyPrice;
		Cause[SolarTechnology, 1] := BasicResearch%S;
		Cause[SolarTechnology, 2] := SolarResearch%S;
		Cause[SouthernLifestyle, 1] := DrinkingWater;
		Cause[SouthernLifestyle, 2] := FoodSupply;
		Cause[SouthernLifestyle, 3] := Housing;
		Cause[StarvationPoints, 1] := Starvation;
		Cause[Starvation, 1] := FoodSupply;
		Cause[Starvation, 2] := Population;
		Cause[StratosphericCFC, 1] := TroposphericCFCs;
		Cause[StripMining, 1] := CoalUse;
		Cause[SulfurDioxide, 1] := CoalTechnology;
		Cause[SulfurDioxide, 2] := CoalUse;
		Cause[SustainabilityPts, 1] := Sustainability;
		Cause[Sustainability, 1] := BirthRate;
{ECO 6: removed Groundwater Use as a cause of Sustainability}
		Cause[Sustainability, 2] := NonrenewEnergy;
		Cause[Sustainability, 3] := RenewableEnergy;
		Cause[TotHeavyMetUse, 1] := HeavyMetalUse;
		Cause[TotalCoalUse, 1] := CoalUse;
		Cause[TotalNatGasUse, 1] := NaturalGasUse;
		Cause[TotalNuclearUse, 1] := NuclearUse;
		Cause[TotalOilUse, 1] := OilUse;
		Cause[TroposphericCFCs, 1] := CFCProduction;
		Cause[UV, 1] := Ozone;
		Cause[WaterPollution, 1] := FertilizerUse;
		Cause[WaterPollution, 2] := HeavyMetalUse;
		Cause[WaterPollution, 3] := PesticideUse;
		Cause[WaterSupply, 1] := GroundwaterUse;
		Cause[WaterSupply, 2] := ReservoirCapacity;
		Cause[WaterSupply, 3] := WaterPollution;

		FOR i := 1 TO MaxNoCards DO
			BEGIN
				FOR j := 1 TO MaxCauses DO
					BEGIN
						k := Cause[i, j];
						IF k > 0 THEN
							BEGIN
								CauseCount[i] := CauseCount[i] + 1;
								x := EffectCount[k] + 1;
								EffectCount[k] := x;
								Effect[k, x] := i;
							END;
					END;
			END;

		MyBlack.red := 0;
		MyBlack.green := 0;
		MyBlack.blue := 0;
		OpenPort(@SwapPort);
		SwapPort.portbits.bounds := BitMapRect;
		SwapPort.portbits.rowBytes := 50;
		SwapPort.portbits.baseAddr := NewPtr(16100);
		SwapPort.portrect := BitMapRect;
		ClipRect(BitMapRect);

		InitAllCards;

{ECO 6: I moved the remaining InitCard calls over to file SubInit.p to simplify the ResetGame procedure.}
{The only reason they were here in the first place was they initially made SubInit too big.}

		InitStandardCard(DeathPoints, DeathPtsCard, 'Death Points');
		InitStandardCard(LifePoints, LifePtsCard, 'Life Points');
		InitStandardCard(Tax, TaxCard, 'Tax');
		InitStandardCard(Subsidy, SubsidyCard, 'Subsidy');
		InitStandardCard(Price, PriceCard, 'Price');
		InitStandardCard(Total, TotalCard, 'Total');

		TaxIndex[BeefTaxIndex] := BeefTax;
		TaxIndex[CFCTaxIndex] := CFCTax;
		TaxIndex[CoalTaxIndex] := CoalTax;
		TaxIndex[FertilizerTaxIndex] := FertilizerTax;
		TaxIndex[HeavyMetalTaxIndex] := HeavyMetalTax;
		TaxIndex[LoggingTaxIndex] := LoggingTax;
		TaxIndex[NaturalGasTaxIndex] := NaturalGasTax;
		TaxIndex[NuclearTaxIndex] := NuclearTax;
		TaxIndex[OilTaxIndex] := OilTax;
		TaxIndex[PesticideTaxIndex] := PesticideTax;
		TaxValue[BeefTaxIndex] := CardValue[BeefTax];
		InitialTaxValue[BeefTaxIndex] := CardValue[BeefTax];
		CardValue[BeefTax] := TaxValue[BeefTaxIndex] * CardValue[BeefProduction];
		CardHistory[BeefTax, 1] := CardValue[BeefTax];
		TaxValue[CFCTaxIndex] := CardValue[CFCTax];
		InitialTaxValue[CFCTaxIndex] := CardValue[CFCTax];
		CardValue[CFCTax] := TaxValue[CFCTaxIndex] * CardValue[CFCProduction];
		CardHistory[CFCTax, 1] := CardValue[CFCTax];
		TaxValue[CoalTaxIndex] := CardValue[CoalTax];
		InitialTaxValue[CoalTaxIndex] := CardValue[CoalTax];
		CardValue[CoalTax] := TaxValue[CoalTaxIndex] * CardValue[CoalUse];
		CardHistory[CoalTax, 1] := CardValue[CoalTax];
		TaxValue[FertilizerTaxIndex] := CardValue[FertilizerTax];
		InitialTaxValue[FertilizerTaxIndex] := CardValue[FertilizerTax];
		CardValue[FertilizerTax] := TaxValue[FertilizerTaxIndex] * CardValue[FertilizerUse];
		CardHistory[FertilizerTax, 1] := CardValue[FertilizerTax];
		TaxValue[HeavyMetalTaxIndex] := CardValue[HeavyMetalTax];
		InitialTaxValue[HeavyMetalTaxIndex] := CardValue[HeavyMetalTax];
		CardValue[HeavyMetalTax] := TaxValue[HeavyMetalTaxIndex] * CardValue[HeavyMetalUse];
		CardHistory[HeavyMetalTax, 1] := CardValue[HeavyMetalTax];
		TaxValue[LoggingTaxIndex] := CardValue[LoggingTax];
		InitialTaxValue[LoggingTaxIndex] := CardValue[LoggingTax];
		CardValue[LoggingTax] := TaxValue[LoggingTaxIndex] * CardValue[Logging];
		CardHistory[LoggingTax, 1] := CardValue[LoggingTax];
		TaxValue[NaturalGasTaxIndex] := CardValue[NaturalGasTax];
		InitialTaxValue[NaturalGasTaxIndex] := CardValue[NaturalGasTax];
		CardValue[NaturalGasTax] := TaxValue[NaturalGasTaxIndex] * CardValue[NaturalGasUse];
		CardHistory[NaturalGasTax, 1] := CardValue[NaturalGasTax];
		TaxValue[NuclearTaxIndex] := CardValue[NuclearTax];
		InitialTaxValue[NuclearTaxIndex] := CardValue[NuclearTax];
		CardValue[NuclearTax] := TaxValue[NuclearTaxIndex] * CardValue[NuclearUse];
		CardHistory[NuclearTax, 1] := CardValue[NuclearTax];
		TaxValue[OilTaxIndex] := CardValue[OilTax];
		InitialTaxValue[OilTaxIndex] := CardValue[OilTax];
		CardValue[OilTax] := TaxValue[OilTaxIndex] * CardValue[OilUse];
		CardHistory[OilTax, 1] := CardValue[OilTax];
		TaxValue[PesticideTaxIndex] := CardValue[PesticideTax];
		InitialTaxValue[PesticideTaxIndex] := CardValue[PesticideTax];
		CardValue[PesticideTax] := TaxValue[PesticideTaxIndex] * CardValue[PesticideUse];
		CardHistory[PesticideTax, 1] := CardValue[PesticideTax];

		SubsidyIndex[PropertyDamage%SIndex] := PropertyDamage%S;
		SubsidyIndex[BasicResearch%SIndex] := BasicResearch%S;
		SubsidyIndex[BioResearch%SIndex] := BioResearch%S;
		SubsidyIndex[CoalResearch%SIndex] := CoalResearch%S;
		SubsidyIndex[Dam%SIndex] := Dam%S;
		SubsidyIndex[DebtForNature%SIndex] := DebtForNature%S;
		SubsidyIndex[FamilyPlanning%SIndex] := FamilyPlanning%S;
		SubsidyIndex[NuclearResearch%SIndex] := NuclearResearch%S;
		SubsidyIndex[OilResearch%SIndex] := OilResearch%S;
		SubsidyIndex[RecyclingCenter%SIndex] := RecyclingCenter%S;
		SubsidyIndex[SolarEnergy%SIndex] := SolarEnergy%S;
		SubsidyIndex[SolarResearch%SIndex] := SolarResearch%S;
		SubsidyIndex[WoodStove%SIndex] := WoodStove%S;
		SubsidyValue[1] := 0;
		FOR i := 2 TO NoSubsidyCards DO
			BEGIN
				SubsidyValue[i] := 8;
				InitialSubsidyValue[i] := 8;
			END;

		CalcTreasury;
{ECO 6: This is a new chunk of code}
		Points := 0;
		FOR i := 1 TO MaxNoCards DO
			BEGIN
				IF CardType[i] = LifePtsCard THEN
					Points := Points + CardValue[i];
				IF CardType[i] = DeathPtsCard THEN
					Points := Points - CardValue[i];
			END; {i-loop}
		LastPoints := Points;

		j := 0;
		k := 1;
		FOR i := 1 TO MaxNoCards DO
			BEGIN
				InversionIndex[i] := 0;
				IF CardType[i] = TaxCard THEN
					BEGIN
						j := j + 1;
						InversionIndex[i] := j;
					END;
				IF (CardType[i] = SubsidyCard) & (i <> PropertyDamage%S) THEN
					BEGIN
						k := k + 1;
						InversionIndex[i] := k;
					END;
			END;
		InversionIndex[PropertyDamage%S] := PropertyDamage%SIndex;

{These are traps to verify that my constant declarations match my text list.}
		IF WoodStove%S <> 155 THEN
			i := 1; {this is just a placeholder for the debugger trap}
		IF CardName[WoodStove%S] <> 'Wood Stove $' THEN
			i := 1; {this is just a placeholder for the debugger trap}

	END;
{*****************************************************************}
PROCEDURE InitGame;
{frozen}
	VAR
		oldDevice: GDHandle;
		theMaxDevice: GDHandle;
		theFile: AppFile;
		x, y: Integer;
	BEGIN
		MenuArr[1] := GetMenu(8);
		InsertMenu(MenuArr[1], 0);
		AppendMenu(MenuArr[1], '(-');
		AddResMenu(MenuArr[1], 'DRVR');
		MenuArr[2] := GetMenu(9);
		InsertMenu(MenuArr[2], 0);
{ECO 6: changed 3 to 4}
		DisableItem(MenuArr[2], 4);
{ECO 6: changed 8 to 3}
		DisableItem(MenuArr[2], 3);
		DrawMenuBar;
		IF YesColor THEN
			BEGIN
				MainWind := NewCWindow(NIL, StdRect, 'Balance of the Planet', TRUE, DocumentProc, WindowPtr(-1), FALSE, 1);
				theMaxDevice := GetMaxDevice(MainWind^.portrect);
				oldDevice := GetGDevice;
				SetGDevice(theMaxDevice);
			END
		ELSE
			MainWind := NewWindow(NIL, StdRect, 'Balance of the Planet', TRUE, DocumentProc, WindowPtr(-1), FALSE, 1);
		SetPort(MainWind);
		FillRect(MainWind^.portrect, white);
		LoadScreen('Earth');
		JumpLocation := EarthProc;
{ECO 4: The remainder of the code in this proc allows game startup by clicking on saved game icon.}
		CountAppFiles(x, y);
		IF y > 0 THEN
			BEGIN
				GetAppFiles(1, theFile);
				ClrAppFiles(y);
				IF theFile.fType = 'SvGm' THEN
					BEGIN
						Error := FSOpen(theFile.fName, theFile.vRefNum, RefNum);
						IF Error = NoErr THEN
							BEGIN
								SetCursor(WatchCursr^^);
{ECO 4: Changed a '4' to an '11' here.}
								Count := ((MaxNoCards * (MaxConstants + 11)) + (2 * (NoSubsidyCards + NoTaxCards))) * SizeOf(Real);
{ECO 6: There was a bad bug in this line; there is also a change for a new variable}
								Count := Count + 4 + 5 * SizeOf(Real) + 11 * SizeOf(Rect);
								Error := FSRead(RefNum, Count, @InitialTaxValue);
{ECO 4: I am now saving the bias file as part of the saved game; this adds these next two lines}
								Count := MaxNoCards * MaxConstants * SizeOf(Real);
								Error := FSRead(RefNum, Count, @CardConstant);
								Error := FSClose(RefNum);
								InitCursor;
								LoadGameFlag := TRUE;
							END;
					END
				ELSE
					BEGIN {this is not a saved game file!}
{ECO 6: added capability of starting up from a bias file}
						IF theFile.fType = 'Bias' THEN
							BEGIN
								Error := FSOpen(theFile.fName, theFile.vRefNum, RefNum);
								IF Error = NoErr THEN
									BEGIN
										SetCursor(WatchCursr^^);
										Count := MaxNoCards * MaxConstants * SizeOf(Real);
										Error := FSRead(RefNum, Count, @CardConstant);
										Error := FSClose(RefNum);
										InitCursor;
									END;
							END
						ELSE
							BEGIN
								ParamText(theFile.fName, '', '', '');
								y := StopAlert(161, NIL);
							END;
					END;
			END;
	END;
{*****************************************************************}
END.