Prev: 47772 Up: Map Next: 47853
47788: Read keyboard and load pressed key character into A
Used by the routines at 47893 and 47942.
Output
A Index of the key that was pressed
47788 EXX Swap registers
47789 LD BC,65278 Load B and C with 254
47792 LD HL,47853 Point HL at list of return values
47795 IN A,(C) Read from port 254 into A (i.e. read keyboard) [IN 65278 reads the half row CAPS SHIFT to V]
47797 SET 0,A Set bit 0 of A (i.e. clear pressing of CAPS SHIFT)
47799 AND 31 Strip out all but the five bits representing key presses
47801 XOR 31 Invert all of the lowest five bits
47803 JR NZ,47843 If this value is non-zero, then a key has been pressed, so skip ahead to 47843
47805 LD DE,5 Advance HL by five characters in list of return values string...
47808 ADD HL,DE ...
47809 LD E,6 Load E with 6 as there are 6 keyboard half-rows to test (loop counter)
47811 RLC B With each loop, change BC from 65278 -> 65022 -> 64510 -> 63486 -> 61438 -> 57342 -> 49150
47813 IN A,(C) Read from port 254 into A (i.e. read keyboard)
47815 AND 31 Strip out all but the five bits representing key presses
47817 XOR 31 Invert all of the lowest five bits
47819 JR NZ,47843 If this value is non-zero, then a key has been pressed, so skip ahead to 47843
47821 INC HL Advance HL by five characters in list of return values string...
47822 INC HL ...
47823 INC HL ...
47824 INC HL ...
47825 INC HL ...
47826 DEC E Decrease number of remaining keyboard half-rows to check
47827 JR NZ,47811 If there are any more half rows to check then loop back to 47811
47829 RLC B Set BC to 32766 for final keyboard half-row
47831 IN A,(C) Read from port 254 into A (i.e. read keyboard)
47833 SET 1,A Set bit 1 of A (i.e. clear pressing of SYMBOL SHIFT)
47835 AND 31 Strip out all but the five bits representing key presses
47837 XOR 31 Invert all of the lowest five bits
47839 JR NZ,47843 If this value is non-zero, then a key has been pressed, so skip ahead to 47843
47841 EXX Swap registers
47842 RET Return [no key pressed]
47843 SRL A Shift bits right
47845 JR C,47850 If carry flag is set, then this is the key that was pressed, so skip ahead to 47850
47847 INC HL Advance HL to check next character
47848 JR 47843 Loop back to 47843
47850 LD A,(HL) Load current character in list of return values string into A as this is the key that was pressed
47851 EXX Swap registers
47852 RET Return [key pressed]
Prev: 47772 Up: Map Next: 47853