Prev: D738 Up: Map Next: D7A2
D765: 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 D765 LD A,($646F) Jump to Dispatch_Handlers if *GameActiveFlag is zero.
D768 OR A
D769 JR Z,Dispatch_Handlers
D76B CALL Read_Kempston Call Read_Kempston.
D76E JR NZ,Demo_Timeout Jump to Demo_Timeout if the port is unstable.
D770 CP $10 Jump to Reset_Introduction if fire was pressed.
D772 JP Z,Reset_Introduction
Demo_Timeout D775 CALL $028E Call KEY_SCAN.
D778 LD A,E Jump to Reset_Introduction if any key is pressed.
D779 INC A
D77A JP NZ,Reset_Introduction
D77D LD BC,($6470) Decrease *PauseTimer by one.
D781 DEC BC
D782 LD ($6470),BC
D786 LD A,B Jump to Dispatch_Handlers until the timer is zero.
D787 OR C
D788 JR NZ,Dispatch_Handlers
D78A LD A,($D888) Jump to Reset_Introduction if *Demo_RoomCount is 01.
D78D DEC A
D78E JP Z,Reset_Introduction
D791 LD ($D888),A Write the decreased count back to *Demo_RoomCount.
D794 CALL JumpTable_GetRandomNumber Call JumpTable_GetRandomNumber.
D797 AND %00001111 Keep only bits 0-3.
D799 LD E,A Copy that room nibble into E.
D79A CALL JumpTable_GetRandomNumber Call JumpTable_GetRandomNumber.
D79D AND %00000111 Keep only bits 0-2.
D79F ADD A,E Add the two nibbles together.
D7A0 JR Change_Room Jump to Change_Room.
Prev: D738 Up: Map Next: D7A2