Prev: 36118 Up: Map Next: 36229
36138: Game Loop
Used by the routines at Handler_DispatchVerb and GameStart.
One turn: turn-based threats, scenic checks, a command, then the matching verb.
Run any turn-based threats.
GameLoop 36138 CALL HandlerTurnBasedEvents Call HandlerTurnBasedEvents.
Walk the scenic-event rooms for the plasma-shell warning.
36141 LD HL,25124 HL=Table_ScenicEventLocations.
36144 LD BC,8 BC=0008.
Test whether the player is standing in this scenic room.
GameLoop_Loop1 36147 LD A,(25123) Fetch the current room.
36150 CPIR Search the scenic-event rooms for it.
36152 JR NZ,GameLoop_Step1 Jump to GameLoop_Step1 if the player is not in a scenic room.
36154 PUSH HL Keep the scenic search while the warning is printed.
36155 PUSH BC
Print " An alien soldier has appeared. He fires a plasma gun at you.".
36156 LD HL,30801 HL=Messaging_AnAlienSoldierHasAppearedHeFiresAPlasma.
36159 CALL PrintStringAndANewline Call PrintStringAndANewline.
Give the plasma shell one chance in 20 of hitting.
36162 LD A,20 A=20.
36164 CALL GenerateRandomNumber Call GenerateRandomNumber.
36167 JR Z,HandlerPlasmaShell Jump to HandlerPlasmaShell if the shell hits.
Print "But he missed.".
36169 LD HL,30863 HL=Messaging_ButHeMissed.
36172 CALL PrintStringAndANewline Call PrintStringAndANewline.
36175 POP BC Restore the scenic-room search.
36176 POP HL
36177 XOR A See whether another scenic room is still to be checked.
36178 OR C
36179 JR NZ,GameLoop_Loop1 Jump to GameLoop_Loop1 to check the next scenic room.
Read a command and turn it into vocabulary tokens.
GameLoop_Step1 36181 CALL Handler_UserInput Call Handler_UserInput.
Continue with Action: Type when the first word is "Y".
36184 LD A,(25233) Fetch the first word of the command.
36187 CP 89 Jump to GameLoop_Step3 when Y (89) was not pressed.
36189 JR NZ,GameLoop_Step3
GameLoop_Step2 36191 LD HL,39295 Continue at VerbMatched_Run to run Action: Type.
36194 JP VerbMatched_Run
Ensure every named object is present here.
GameLoop_Step3 36197 XOR A Start the synonym scan with a clear result.
36198 LD HL,25233 Point at the command's word tokens.
36201 LD B,10 A command has at most 10 word tokens.
GameLoop_Loop2 36203 LD A,(HL) Read the next word token.
36204 CP 255 Jump to Handler_DispatchVerb when the command has no more words (255).
36206 JR Z,Handler_DispatchVerb
36208 EXX Look that token up in the noun list without losing the token pointer.
36209 LD HL,34920
36212 LD BC,(25288)
36216 CPIR
36218 JR NZ,GameLoop_Step4 Jump to GameLoop_Step4 if this token is not a noun.
36220 CALL Parser_ResolvePhrase Call Parser_ResolvePhrase.
36223 JR C,GameLoop Jump back to GameLoop when the carry flag is set.
GameLoop_Step4 36225 EXX Bring the token pointer back.
36226 INC HL Move on to the next word token.
36227 DJNZ GameLoop_Loop2 Jump to GameLoop_Loop2 for the remaining words of the command.
Prev: 36118 Up: Map Next: 36229