Prev: 24266 Up: Map Next: 24341
24267: Game Loop
Used by the routines at OfferAnotherGame, Restored and StartGame.
Runs the adventure. It prepares a new game, describes the room, runs the location scripts, draws the picture, then reads a command and obeys it. A ROM error returns with the stack at ErrorStack.
Install the word at ErrorStack as the ROM error handler and give the game its own stack.
GameLoop 24267 LD HL,27457 Store ErrorStack in ERR_SP.
24270 LD (23613),HL
24273 LD SP,23940 The stack grows down from StackTop.
Start in the first room with an empty inventory.
24276 CALL PrepareGame Call PrepareGame to prepare a new game.
24279 XOR A The picture has not been drawn yet.
24280 LD (24965),A
24283 CALL DescribeLocation
This entry point is used by the routines at ObeyCommand and RefuseCommand.
Run the high-priority scripts, and describe the room again if they moved the player.
GameLoop_Act 24286 XOR A Write 0 to *RepeatCounter.
24287 LD (23950),A
24290 CALL RunPriorityScripts Call RunPriorityScripts to run the high-priority scripts.
24293 LD A,(23445) Jump to GameLoop_Draw when the room stayed the same.
24296 OR A
24297 JR Z,GameLoop_Draw
24299 CALL DescribeLocation Call DescribeLocation to describe the new room.
Draw the illustration once for this room, then either repeat or ask for a command.
GameLoop_Draw 24302 CALL DrawRoomOnce Call DrawRoomOnce to draw the picture if this room is not already on screen.
24305 XOR A Write 0 to *RoomChanged.
24306 LD (23445),A
24309 LD A,(23950) Jump to ObeyCommand_Repeat while a script asked for another look.
24312 OR A
24313 JR NZ,ObeyCommand_Repeat
Read a command. An empty line is a complaint, not an action.
24315 CALL ReadCommand Call ReadCommand to read the next command from bank 3.
24318 LD A,(23423) Jump to ObeyCommand when a verb was recognised.
24321 OR A
24322 JR NZ,ObeyCommand
24324 LD A,(23424) Jump to ObeyCommand when a noun was recognised.
24327 OR A
24328 JR NZ,ObeyCommand
24330 LD A,11 Message 11: that input contained no recognised words.
24332 CALL PrintSystemMessage
24335 XOR A A failed line does not keep a comma continuation.
24336 LD (23429),A
24339 JR GameLoop_Act Jump to GameLoop_Act for another turn.
Prev: 24266 Up: Map Next: 24341