| Routines

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

Used by the routine at 7996. 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 0x01 to 0x27) points at an entry in the table of keypress handling routines at ED00.
EAB2 | CALL $EAD9 | Collect the ASCII code of the last key pressed in A
EAB5 | JR NZ,$EAF2 | Jump if a key was pressed
EAB7 | LD A,($7FFA) | Collect the input device indicator from 7FFA
EABA | AND A | Are we using the Kempston joystick?
EABB | RET Z | Return with the zero flag set if not
We are using the Kempston joystick.
EABC | IN A,($1F) | Take a reading from the joystick port
EABE | AND $1F | Any input from the joystick?
EAC0 | RET Z | Return if not
EAC1 | LD L,$50 | 0x50='P' (RIGHT)
EAC3 | RRCA | Was the joystick moved right?
EAC4 | JR C,$EAF3 | Jump if so
EAC6 | DEC L | L=0x4F='O' (LEFT)
EAC7 | RRCA | Was the joystick moved left?
EAC8 | JR C,$EAF3 | Jump if so
EACA | LD L,$41 | 0x41='A' (DOWN)
EACC | RRCA | Was the joystick moved down?
EACD | JR C,$EAF3 | Jump if so
EACF | LD L,$51 | 0x51='Q' (UP)
EAD1 | RRCA | Was the joystick moved up?
EAD2 | JR C,$EAF3 | Jump if so
EAD4 | LD L,$6B | 0x6B='k' (knock on or open a door)
EAD6 | JR $EAF3 | Collect and return the keypress offset that corresponds to the joystick movement