Prev: FE00 Up: Map Next: FE7E
FE47: Input routine: Protek
This is the input routine for Protek (cursor) joysticks. The Protek interface maps Up/Down/Left/Right/Fire to keys 7/6/5/8/0.
Output
A Input value (as per enum input).
inputroutine_protek FE47 LD BC,$F7FE Load BC with the port number of the keyboard half row for keys 1/2/3/4/5
FE4A IN A,(C) Read that port. We'll receive xxx54321
FE4C CPL The keyboard is active low, so complement the value
Check for left
FE4D AND $10 Is '5' pressed?
FE4F LD E,$03 left_right = input_LEFT
FE51 LD B,$EF Load BC with the port number of the keyboard half row for keys 0/9/8/7/6
FE53 JR NZ,inputroutine_protek_0 Jump forward if '5'/left was pressed
Check for right
FE55 IN A,(C) Read that port. We'll receive xxx67890
FE57 CPL The keyboard is active low, so complement the value
FE58 AND $04 Is '8' pressed?
FE5A LD E,$06 left_right = input_RIGHT
FE5C JR NZ,inputroutine_protek_0 Jump forward if '8'/right was pressed
FE5E LD E,$00 Otherwise left_right = 0
inputroutine_protek_0 FE60 IN A,(C) Read $EFFE again
FE62 CPL The keyboard is active low, so complement the value
FE63 LD D,A Save a copy of the port value
Check for up
FE64 AND $08 Is '7' pressed?
FE66 LD A,$01 up_down = input_UP
FE68 JR NZ,inputroutine_protek_1 Jump forward if '7'/up was pressed
Check for down
FE6A LD A,D Restore the port value
FE6B AND $10 Is '6' pressed?
FE6D LD A,$02 up_down = input_DOWN
FE6F JR NZ,inputroutine_protek_1 Jump forward if '6'/down was pressed
FE71 XOR A Otherwise up_down = 0
inputroutine_protek_1 FE72 ADD A,E Combine the up_down and left_right values
FE73 LD E,A
Check for fire
FE74 LD A,D Restore the port value
FE75 AND $01 Is '0' pressed?
FE77 LD A,$09 fire = input_FIRE
FE79 JR NZ,inputroutine_protek_2 Jump forward if fire was pressed
FE7B XOR A fire = 0
inputroutine_protek_2 FE7C ADD A,E Combine the (up_down + left_right) and fire values
FE7D RET Return
Prev: FE00 Up: Map Next: FE7E