| Routines

60082: Get the keypress offset of the last key pressed (1)

Used by the routine at 31126. Returns with the zero flag set if no game keys were pressed. Otherwise returns with A holding the value from the keypress offset table corresponding to the last key pressed or joystick movement made. This offset (an odd number from 1 to 39) points at an entry in the table of keypress handling routines at 60672.
60082 | CALL 60121 | Collect the ASCII code of the last key pressed in A
60085 | JR NZ,60146 | Jump if a key was pressed
60087 | LD A,(32762) | Collect the input device indicator from 32762
60090 | AND A | Are we using the Kempston joystick?
60091 | RET Z | Return with the zero flag set if not
We are using the Kempston joystick.
60092 | IN A,(31) | Take a reading from the joystick port
60094 | AND 31 | Any input from the joystick?
60096 | RET Z | Return if not
60097 | LD L,80 | 80='P' (RIGHT)
60099 | RRCA | Was the joystick moved right?
60100 | JR C,60147 | Jump if so
60102 | DEC L | L=79='O' (LEFT)
60103 | RRCA | Was the joystick moved left?
60104 | JR C,60147 | Jump if so
60106 | LD L,65 | 65='A' (DOWN)
60108 | RRCA | Was the joystick moved down?
60109 | JR C,60147 | Jump if so
60111 | LD L,81 | 81='Q' (UP)
60113 | RRCA | Was the joystick moved up?
60114 | JR C,60147 | Jump if so
60116 | LD L,107 | 107='k' (knock on or open a door)
60118 | JR 60147 | Collect and return the keypress offset that corresponds to the joystick movement