Prev: 39982 Up: Map Next: 40046
40019: Read Key Input
Used by the routines at Game_Configs_Main, Game_Configs_Controls and Game_Over.
Annotated by Stephen Jones; Spectrum Discovery Club.
Keyboard_Test 40019 LD C,A Key to test in C.
40020 AND 7 Mask bits d0-d2 for row.
40022 INC A In range 1-8.
40023 LD B,A Place in B.
40024 SRL C Divide C by 8 to find position within row.
40026 SRL C
40028 SRL C
40030 LD A,5 Only 5 keys per row.
40032 SUB C Subtract position.
40033 LD C,A Put into C.
40034 LD A,254 High byte of port to read.
Keyboard_Find_Row 40036 RRCA Rotate into position.
40037 DJNZ Keyboard_Find_Row Repeat until we've found the relevant row.
40039 IN A,(254) Read port (A=high, 254=low).
Keyboard_Rotate_Loop 40041 RRA Rotate bit out of result.
40042 DEC C Loop counter.
40043 JR NZ,Keyboard_Rotate_Loop Repeat until bit for position in carry flag.
40045 RET Return.
Prev: 39982 Up: Map Next: 40046