Prev: 55096 Up: Map Next: 55202
55141: Game Loop
Used by the routines at Change_Room and Dispatch_Handlers.
Watches demo input and *PauseTimer. Jumps to Dispatch_Handlers while the game is active or the demo timer is running, else picks a room and jumps to Change_Room.
Game_Loop 55141 LD A,(25711) Jump to Dispatch_Handlers if *GameActiveFlag is zero.
55144 OR A
55145 JR Z,Dispatch_Handlers
55147 CALL Read_Kempston Call Read_Kempston.
55150 JR NZ,Demo_Timeout Jump to Demo_Timeout if the port is unstable.
55152 CP 16 Jump to Reset_Introduction if fire was pressed.
55154 JP Z,Reset_Introduction
Demo_Timeout 55157 CALL 654 Call KEY_SCAN.
55160 LD A,E Jump to Reset_Introduction if any key is pressed.
55161 INC A
55162 JP NZ,Reset_Introduction
55165 LD BC,(25712) Decrease *PauseTimer by one.
55169 DEC BC
55170 LD (25712),BC
55174 LD A,B Jump to Dispatch_Handlers until the timer is zero.
55175 OR C
55176 JR NZ,Dispatch_Handlers
55178 LD A,(55432) Jump to Reset_Introduction if *Demo_RoomCount is 1.
55181 DEC A
55182 JP Z,Reset_Introduction
55185 LD (55432),A Write the decreased count back to *Demo_RoomCount.
55188 CALL JumpTable_GetRandomNumber Call JumpTable_GetRandomNumber.
55191 AND %00001111 Keep only bits 0-3.
55193 LD E,A Copy that room nibble into E.
55194 CALL JumpTable_GetRandomNumber Call JumpTable_GetRandomNumber.
55197 AND %00000111 Keep only bits 0-2.
55199 ADD A,E Add the two nibbles together.
55200 JR Change_Room Jump to Change_Room.
Prev: 55096 Up: Map Next: 55202