Prev: 51841 Up: Map Next: 52175
51943: Main game loop
Used by the routine at Cashboxes_Completed_0.
51943 LD A,127 Read from the keyboard;
Port Number Bit
0 1 2 3 4
127 SPACE FULL-STOP M N B
51945 IN A,(254)
51947 RRA Was "SPACE" pressed?
51948 JR C,51963 Jump forward if not.
51950 LD A,254 Read from the keyboard;
Port Number Bit
0 1 2 3 4
254 SHIFT Z X C V
51952 IN A,(254)
51954 RRA Was "CAPS SHIFT" pressed?
51955 JR C,51963 Jump forward if not.
51957 LD HL,52148 CAPS + SPACE pressed = BREAK. Abort the game.
51960 CALL 64896
The game has not been aborted. Check if it is paused and loop round if so until it is unpaused.
51963 LD A,254 Read from the keyboard;
Port Number Bit
0 1 2 3 4
254 SHIFT Z X C V
51965 IN A,(254)
51967 BIT 1,A Was 'Z' pressed? (PAUSE)
51969 JR NZ,51979 Jump forward if not.
51971 LD A,254 Read from the keyboard;
Port Number Bit
0 1 2 3 4
254 SHIFT Z X C V
51973 IN A,(254)
51975 BIT 2,A was 'X' pressed? (UNPAUSE)
51977 JR NZ,51971 Loop back round if not.
The game is running.
51979 CALL Controls Get the keyboard or joystick input from the player.
51982 LD BC,(52764) Get the game speed from 52764 and delay for that amount of time.
51986 DEC BC
51987 LD A,B
51988 OR C
51989 JR NZ,51986
51991 CALL 54289 Check for closed doors and movement. This routine exits here if all doors are closed and all money is collected.
At this point, the player is not moving and the phase is still in play, so look at the doors.
51994 CALL 52134 Clear the temporary storage from BufferGeneral to 23551.
Look at door 1.
51997 LD IX,53605 Point to the first door at Door_Flags_01.
52001 LD (IX+8),0 Clear "deposit made" flag on this door.
52005 LD HL,52756 Check the contents of the first door at Door_Routine_01.
52008 LD A,(HL) If there no character at this door, the door will point to 0 and the zero flag will be set.
52009 INC HL
52010 OR (HL)
52011 PUSH AF Remember the flags.
52012 CALL Z,Character_Chooser If the door is empty, look at putting a character in.
52015 POP AF Restore the flags.
52016 JR Z,52031 If the door was empty, skip the next bit.
There's somebody at the door.
52018 LD HL,(52756) Get the contents of the first door.
52021 LD DE,52031 Remember a return to 52031 on the stack.
52024 PUSH DE
52025 LD A,1 Looking at the first door.
52027 LD (52762),A
52030 JP (HL) Do the action.
Look at door 2.
52031 LD IX,53619 Point to the second door at Door_Flags_02.
52035 LD (IX+8),0 Clear "deposit made" flag on this door.
52039 LD HL,52758 Check the contents of the second door at Door_Routine_02.
52042 LD A,(HL) If there no character at this door, the door will point to 0 and the zero flag will be set.
52043 INC HL
52044 OR (HL)
52045 PUSH AF Remember the flags.
52046 CALL Z,Character_Chooser If the door is empty, look at putting a character in.
52049 POP AF Restore the flags.
52050 JR Z,52065 If the door was empty, skip the next bit.
There's somebody at the door.
52052 LD HL,(52758) Get the contents of the second door.
52055 LD DE,52065 Remember a return to 52065 on the stack.
52058 PUSH DE
52059 LD A,2 Looking at the second door.
52061 LD (52762),A
52064 JP (HL) Do the action.
Look at door 3.
52065 LD IX,53633 Point to the thrd door at Door_Flags_03.
52069 LD (IX+8),0 Clear "deposit made" flag on this door.
52073 LD HL,52760 Check the contents of the thrd door at Door_Routine_03.
52076 LD A,(HL) If there no character at this door, the door will point to 0 and the zero flag will be set.
52077 INC HL
52078 OR (HL)
52079 PUSH AF Remember the flags.
52080 CALL Z,Character_Chooser If the door is empty, look at putting a character in.
52083 POP AF Restore the flags.
52084 JR Z,52099 If the door was empty, skip the next bit.
There's somebody at the door.
52086 LD HL,(52760) Get the contents of the door.
52089 LD DE,52099 Remember a return to 52099 on the stack.
52092 PUSH DE
52093 LD A,3 Looking at the third door.
52095 LD (52762),A
52098 JP (HL) Do the action.
After taking action on all three doors, see if the player made a mistake.
52099 LD A,(54014) If bit 0 of Mistakes is not zero then jump to 52551 and lose a life.
52102 BIT 0,A
52104 JP NZ,52551
52107 BIT 1,A Else if bit 1 is not zero, jump to Flash_Lives and flash a life counter.
52109 JP NZ,Flash_Lives
52112 CALL Scoring Apply scoring.
52115 LD HL,53648 If we got money (set by 01 in 53648), collect it.
52118 LD A,(HL)
52119 AND A
52120 LD (HL),0
52122 CALL NZ,52128
52125 JP 51943 Go round the main loop again.
This routine plays the "collect" effect and redraws the money boxes.
52128 CALL Dollar_Scroll_0 Play the "collect money" effect.
52131 JP 52379 Redraw the cash boxes.
This routine is called each time round the loop, and clears out any temporary storage used when acting on a character.
52134 LD HL,23296 Blanks 255 bytes from BufferGeneral onwards, then returns.
52137 LD DE,23297
52140 LD BC,255
52143 LD (HL),0
52145 LDIR
52147 RET
This code and data is copied to Print_TwoToneText_Alias.
Copied_5B80 52148 JP Print_TwoToneText
52151 JP Life_Images
52154 DEFW Lives
52156 LD HL,(52754)
52159 JP (HL)
52160 JP Scoring_Prep
52163 JP Character_Address
52166 JP Copy_Routine
52169 JP Merge_Shot
52172 JP Draw_Score
Prev: 51841 Up: Map Next: 52175