Routines

29118: Collect code of last key pressed


Used by routines at 24175, 29178, 62178, 62483 and 63166. Return with the zero flag set if no key was pressed. Otherwise return with A holding the code of the last key pressed.

29118 3AEC7F LD A,(32748) A=0 if using keyboard, 1 if using Kempston
29121 A7 AND A Are we using the keyboard?
29122 281E JR Z,29154 Jump if so
29124 DB1F IN A,(31)
29126 E61F AND 31 Any input from the joystick?
29128 2818 JR Z,29154 Jump if not
29130 2E4F LD L,79 79='O' (LEFT)
29132 0F RRCA
29133 3810 JR C,29151 Jump if joystick was moved left
29135 2C INC L L=80='P' (RIGHT)
29136 0F RRCA
29137 380C JR C,29151 Jump if joystick was moved right
29139 2E41 LD L,65 65='A' (DOWN)
29141 0F RRCA
29142 3807 JR C,29151 Jump if joystick was moved down
29144 2E51 LD L,81 81='Q' (UP)
29146 0F RRCA
29147 3802 JR C,29151 Jump if joystick was moved up
29149 2E66 LD L,102 102='f' (fire)
29151 7D LD A,L Pass the appropriate character code to A
29152 A7 AND A Reset the zero flag
29153 C9 RET

This entry point is used by the startup routines at 20896, 21152 and 21664:
29154 213B5C LD HL,23611 Point HL at the system variable FLAGS
29157 CB6E BIT 5,(HL)
29159 CBAE RES 5,(HL)
29161 C8 RET Z Return if no key was pressed
29162 3A085C LD A,(23560) Collect code of key last pressed
29165 FE0D CP 13 Was it ENTER?
29167 2804 JR Z,29173 Jump if so
29169 FE20 CP 32 Was it a control character?
29171 3803 JR C,29176 Jump if so
29173 FE80 CP 128 Was it an extended character?
29175 D8 RET C Return if not

This entry point is used by the routine at 29118:
29176 AF XOR A Set the zero flag to indicate no (relevant) key pressed
29177 C9 RET