{TITLE.PA2} { Title } {Print the title screen: } {First, if the user has provided a } {file TITLE.TTL, display that, pausing} {if necessary. Then, print the GAGS } {copyright/credit information. } PROCEDURE Title; { Center } {Write the string of text centered} {on an 80-column display. } PROCEDURE center(st : s); VAR i : Integer; BEGIN IF morecount >= 23 THEN BEGIN Pause; morecount := 0; END; {delete leading blanks} WHILE st[1] = ' ' DO st := Copy(st, 2, Length(st)-1); FOR i := 1 TO ((80-Length(st)) DIV 2) DO Write(' '); WriteLn(st); morecount := morecount+1; END; {center} CONST {$IFDEF NormalVersion} cw1 = 'The Adventure Game Toolkit (AGT) 1.7'; {$ELSE} cw1 = 'The BIG Adventure Game Toolkit (AGT) 1.7'; {$ENDIF} cw2 = 'Copyright 1994 -- All Rights Reserved'; cw3 = 'by David R. Malmberg and Mark J. Welch'; cw4 = 'AGT is distributed as "Freeware" and you are free to use it as you wish.'; VAR titlefile : Text; Line1, Line2, GameName : s; LowStr, HighStr : words; fn : Text; Spot : Integer; datafile : FILE; BEGIN {title} GameName := data_file_name; Spot := POS('.', GameName); IF Spot <> 0 THEN GameName := Copy(GameName, 1, Spot-1); {$IFDEF NormalVersion} Line1 := 'Compiling Final Game Version -- should take a few minutes'; {$ELSE} Line1 := 'BIG Compiling Final Game Version -- should take a few minutes'; {$ENDIF} Line2 := Line1; CLRSCR; {clear the screen so nothing distracts user from title} WriteLn; morecount := 1; {$IFDEF NormalVersion} center('Compiling '+GameName+' using:'+cw1); {$ELSE} center('BIG Compiling '+GameName+' using:'+cw1); {$ENDIF} center(cw2); center(cw3); WriteLn; center(cw4); WriteLn; morecount := morecount+1; DELAY(5000); {give user at least 5 seconds to read title} IF CreatingFinalVersion THEN center(Line1) ELSE IF File_Exists(Command_File_Name) THEN center(Line2) {takes quite a bit longer if special commands to be read and initialized} ELSE IF File_Exists('CONFIG.SYS') THEN center(Line2); END; {title} FUNCTION Valid_Room(num : Integer) : Boolean; BEGIN IF ((num >= First_Room) AND (num <= TopRoom)) THEN Valid_Room := True ELSE Valid_Room := False; END; {Valid_Room} FUNCTION Valid_ZRoom(num : Integer) : Boolean; {Normal Rooms plus Room Zero} BEGIN IF ((num = 0) OR Valid_Room(num)) THEN Valid_ZRoom := True ELSE Valid_ZRoom := False; END; {Valid_ZRoom} FUNCTION Valid_Noun(num : Integer) : Boolean; BEGIN IF ((num >= First_noun) AND (num <= TopNoun)) THEN Valid_Noun := True ELSE Valid_Noun := False; END; {Valid_Noun} FUNCTION Valid_ZNoun(num : Integer) : Boolean; {Normal Nouns plus Noun Zero} BEGIN IF ((num = 0) OR Valid_Noun(num)) THEN Valid_ZNoun := True ELSE Valid_ZNoun := False; END; {Valid_ZNoun} FUNCTION Valid_Creature(num : Integer) : Boolean; BEGIN IF ((num >= First_creature) AND (num <= TopCreature)) THEN Valid_Creature := True ELSE Valid_Creature := False; END; {Valid_Creature} FUNCTION Valid_Thing(num : Integer) : Boolean; BEGIN IF (Valid_Creature(num) OR Valid_Noun(num)) THEN Valid_Thing := True ELSE Valid_Thing := False; END; {Valid_Thing} FUNCTION Valid_Token(num : Integer) : Boolean; BEGIN IF (num >= Ord(AtLocation)) AND (num <= Ord(DoneWithTurn)) THEN Valid_Token := True ELSE Valid_Token := False; END; {Valid_Token} FUNCTION Valid_Message(num : Integer) : Boolean; BEGIN IF ((num >= 1) AND (num <= TopMessage)) THEN Valid_Message := True ELSE Valid_Message := False; END; {Valid_Message} FUNCTION Valid_Counter(num : Integer) : Boolean; BEGIN IF ((num >= 1) AND (num <= MaxCounter)) THEN Valid_Counter := True ELSE Valid_Counter := False; END; {Valid_Counter} FUNCTION Valid_Flag(num : Integer) : Boolean; BEGIN IF ((num >= 1) AND (num <= MaxFlag)) THEN Valid_Flag := True ELSE Valid_Flag := False; END; {Valid_Flag} FUNCTION Valid_Variable(num : Integer) : Boolean; BEGIN IF ((num >= 1) AND (num <= MaxVariable)) THEN Valid_Variable := True ELSE Valid_Variable := False; END; {Valid_Variable} FUNCTION Valid_Question(num : Integer) : Boolean; BEGIN IF ((num >= 1) AND (num <= MaxQuestion)) THEN Valid_Question := True ELSE Valid_Question := False; END; {Valid_Variable} FUNCTION Valid_Location(num : Integer) : Boolean; BEGIN IF (Valid_Room(num) OR Valid_Noun(num) OR (num = Wearing) OR (num = Player) OR (num = 0)) THEN Valid_Location := True ELSE Valid_Location := False; END; {Valid_Location} PROCEDURE InitializeLimits; BEGIN NumberOfErrors := 0; TopRoom := Last_Room; TopNoun := Last_noun; TopCreature := Last_Creature; TopMessage := Last_Message; MaxMessage := 0; {to start with} END; {InitializeLimits} PROCEDURE ResetLimits; BEGIN TopRoom := MaxRoom; TopNoun := MaxNoun; TopCreature := MaxCreature; TopMessage := MaxMessage; END; {ResetLimits} PROCEDURE TestParameter(num : Integer; TopSen : s; InSen : s; TypeOfTest : TestType); VAR LastCount : Integer; BEGIN LastCount := NumberOfErrors; CASE TypeOfTest OF RoomTest : IF NOT Valid_Room(num) THEN NumberOfErrors := NumberOfErrors+1; ZRoomTest : IF NOT Valid_ZRoom(num) THEN NumberOfErrors := NumberOfErrors+1; NounTest : IF NOT Valid_Noun(num) THEN NumberOfErrors := NumberOfErrors+1; ZNounTest : IF NOT Valid_ZNoun(num) THEN NumberOfErrors := NumberOfErrors+1; CreatureTest : IF NOT Valid_Creature(num) THEN NumberOfErrors := NumberOfErrors+1; ThingTest : IF NOT Valid_Thing(num) THEN NumberOfErrors := NumberOfErrors+1; LocationTest : IF NOT Valid_Location(num) THEN NumberOfErrors := NumberOfErrors+1; TokenTest : IF NOT Valid_Token(num) THEN NumberOfErrors := NumberOfErrors+1; MessageTest : IF NOT Valid_Message(num) THEN NumberOfErrors := NumberOfErrors+1; CounterTest : IF NOT Valid_Counter(num) THEN NumberOfErrors := NumberOfErrors+1; VariableTest : IF NOT Valid_Variable(num) THEN NumberOfErrors := NumberOfErrors+1; FlagTest : IF NOT Valid_Flag(num) THEN NumberOfErrors := NumberOfErrors+1; QuestionTest : IF NOT Valid_Question(num) THEN NumberOfErrors := NumberOfErrors+1; END; {CASE} IF LastCount < NumberOfErrors THEN {some kind of error} BEGIN WriteLn; IF TopSen <> '' THEN WriteLn(TopSen); Write(' ', InSen, ' <-- '); CASE TypeOfTest OF RoomTest : WriteLn('ROOMS have only been defined for 2 to ', TopRoom); ZRoomTest : WriteLn('Valid locations have only been defined for 0 and 2 to ', TopRoom); NounTest : WriteLn('NOUNS have only been defined for 200 to ', TopNoun); CreatureTest : WriteLn('CREATURES have only been defined for 300 to ', TopCreature); ThingTest : WriteLn('Must be a NOUN (200 to ', TopNoun, ') or a CREATURE (300 to ', TopCreature, ')'); LocationTest : BEGIN WriteLn('Locations must be 0, 1, 1000 or in a ROOM (2 to ', TopRoom, ')'); WriteLn(' or inside a NOUN (200 to ', TopNoun, ')'); END; TokenTest : WriteLn('Tokens range from AtLocation to DoneWithTurn only'); MessageTest : WriteLn('MESSAGES have only been defined for 1 to ', TopMessage); CounterTest : WriteLn('COUNTERS have only been defined for 1 to ', MaxCounter); VariableTest : WriteLn('VARIABLES have only been defined for 1 to ', MaxVariable); FlagTest : WriteLn('FLAGS have only been defined for 1 to ', MaxFlag); QuestionTest : WriteLn('QUESTIONS have only been defined for 1 to ', MaxQuestion); END; {CASE} END; {some kind of error} END; {TestParameter} PROCEDURE CheckParameters; TYPE DName = ARRAY[Direction] OF words; VAR i, vv : Integer; sentence, TopSen, InSen : s; st : words; Dir : Direction; DirectionName : DName; BEGIN ResetLimits; {to actual upper limits -- as read in} DirectionName[NORTH] := 'NORTH'; DirectionName[SOUTH] := 'SOUTH'; DirectionName[WEST] := 'WEST'; DirectionName[EAST] := 'EAST'; DirectionName[northeast] := 'NORTHEAST'; DirectionName[southeast] := 'SOUTHEAST'; DirectionName[northwest] := 'NORTHWEST'; DirectionName[southwest] := 'SOUTHWEST'; DirectionName[up] := 'UP'; DirectionName[down] := 'DOWN'; DirectionName[enter] := 'ENTER'; DirectionName[Exit] := 'EXIT'; {first check out "special" room information} Str(Starting_room, st); sentence := 'STARTING_ROOM '+st; TestParameter(Starting_room, '', sentence, RoomTest); Str(Resurrection_Room, st); sentence := 'RESURRECTION_ROOM '+st; TestParameter(Resurrection_Room, '', sentence, ZRoomTest); {Zero allowed if no resurrection} IF Treasure_Room <> 3000 THEN {3000, i.e., no treasure room is default value} BEGIN Str(Treasure_Room, st); sentence := 'TREASURE_ROOM '+st; TestParameter(Treasure_Room, '', sentence, LocationTest); END; FOR i := First_Room TO MaxRoom DO BEGIN WITH Room[i]^ DO BEGIN Str(i, st); TopSen := 'ROOM '+st; FOR Dir := NORTH TO Exit DO BEGIN Str(Path[Dir], st); InSen := DirectionName[Dir]+' '+st; TestParameter(Path[Dir], TopSen, InSen, ZRoomTest); {Zero allowed} END; IF special <> 0 THEN {0, i.e., no special is default value} BEGIN Str(special, st); InSen := 'SPECIAL '+st; TestParameter(special, TopSen, InSen, RoomTest); END; IF key <> 0 THEN {0, i.e., no key is default value} BEGIN Str(key, st); InSen := 'KEY '+st; TestParameter(key, TopSen, InSen, NounTest); END; IF light > 1 THEN {0 or 1, i.e., no light or ANY light} BEGIN Str(light, st); InSen := 'LIGHT '+st; TestParameter(light, TopSen, InSen, NounTest); END; END; {WITH} END; {for i := first_room..MaxRoom} {now check out the noun information} FOR i := First_noun TO MaxNoun DO BEGIN WITH N[i]^ DO BEGIN Str(i, st); TopSen := 'NOUN '+st; Str(location, st); {test noun's location} sentence := 'LOCATION '+st; TestParameter(location, TopSen, sentence, LocationTest); IF key <> 0 THEN {0, i.e., no key is default value} BEGIN Str(key, st); InSen := 'KEY '+st; TestParameter(key, TopSen, InSen, NounTest); END; END; END; {now check out the creature information} IF MaxCreature > 0 THEN FOR i := First_creature TO MaxCreature DO BEGIN WITH M[i]^ DO BEGIN Str(i, st); TopSen := 'CREATURE '+st; Str(location, st); {test creature's location} sentence := 'LOCATION '+st; TestParameter(location, TopSen, sentence, ZRoomTest); END; END; END; {CheckParameters}