![]() |
Routines |
| Prev: 35713 | Up: Map | Next: 35835 |
|
Used by the routine at Input_WaitForAKey.
Reads a newly pressed key. Returns 0 if there isn't one.
|
||||||||||||||||||||
| GetKey | 35731 | PUSH HL | Save HL, IX and BC and call Pause to pause. | |||||||||||||||||
| 35732 | PUSH IX | |||||||||||||||||||
| 35734 | PUSH BC | |||||||||||||||||||
| 35735 | CALL Pause | |||||||||||||||||||
| 35738 | LD (35721),BC | Write 0000 to 35721. | ||||||||||||||||||
| 35742 | LD HL,35723 | Point HL at 35723. | ||||||||||||||||||
| 35745 | LD IX,35713 | Point IX at KeyboardRowMasks. | ||||||||||||||||||
| 35749 | LD BC,65278 | Read the keyboard from port 65278. | ||||||||||||||||||
| GetKey_Loop | 35752 | IN A,(C) | Read from the keyboard port. | |||||||||||||||||
| 35754 | AND %00011111 | Keep the selected bits. | ||||||||||||||||||
| 35756 | OR (IX+0) | OR against what IX is pointing to. | ||||||||||||||||||
| 35759 | PUSH AF | Save the row and complement it. | ||||||||||||||||||
| 35760 | CPL | |||||||||||||||||||
| 35761 | AND (HL) | Keep the keys that are pressed now but were up in the previous scan at HL. The second CPL leaves the flags alone. | ||||||||||||||||||
| 35762 | CPL | |||||||||||||||||||
| 35763 | JR Z,GetKey_StoreTheRow | Jump to GetKey_StoreTheRow if no key in this half-row has been newly pressed. | ||||||||||||||||||
| 35765 | LD (35721),BC | Store BC at 35721. | ||||||||||||||||||
| 35769 | LD (35721),A | Store the result at 35721. | ||||||||||||||||||
| GetKey_StoreTheRow | 35772 | POP AF | Store the result, then step HL on. | |||||||||||||||||
| 35773 | LD (HL),A | |||||||||||||||||||
| 35774 | INC HL | |||||||||||||||||||
| 35775 | INC IX | Step IX to the next byte of KeyboardRowMasks. | ||||||||||||||||||
| 35777 | RLC B | Rotate the next bit of B into carry. | ||||||||||||||||||
| 35779 | JR C,GetKey_Loop | Jump back to GetKey_Loop until all eight half-rows have been read. | ||||||||||||||||||
| 35781 | LD BC,(35721) | Bring BC back from 35721. | ||||||||||||||||||
|
No newly pressed key was stored.
|
||||||||||||||||||||
| 35785 | LD A,B | If BC is 0000, return 0 through GetKey_Return. | ||||||||||||||||||
| 35786 | OR C | |||||||||||||||||||
| 35787 | JR Z,GetKey_Return | |||||||||||||||||||
| 35789 | LD A,251 | Start the key index at 251 (that is -5). | ||||||||||||||||||
| GetKey_CountTheRows | 35791 | ADD A,5 | Add 5 for each keyboard row passed. | |||||||||||||||||
| 35793 | RRC B | Shift the next row bit of B into the carry flag. | ||||||||||||||||||
| 35795 | JR C,GetKey_CountTheRows | If there is any carry, jump to GetKey_CountTheRows. | ||||||||||||||||||
| 35797 | DEC A | Step back one so the next loop starts in the same place. | ||||||||||||||||||
| GetKey_CountTheKeys | 35798 | INC A | Count one more key along the row. | |||||||||||||||||
| 35799 | RRC C | Shift the next key bit of C into the carry flag. | ||||||||||||||||||
| 35801 | JR C,GetKey_CountTheKeys | If there is any carry, jump to GetKey_CountTheKeys. | ||||||||||||||||||
| 35803 | LD C,A | Copy the key code into C. | ||||||||||||||||||
| 35804 | LD B,0 | Start the character count at zero. | ||||||||||||||||||
| 35806 | LD HL,35835 | Point HL at the unshifted keyboard map at KeyboardMapUnshifted. | ||||||||||||||||||
| 35809 | LD A,254 | Read from the keyboard port.
|
||||||||||||||||||
| 35811 | IN A,(254) | |||||||||||||||||||
| 35813 | AND %00000001 | Keep only bit 0 (SHIFT). | ||||||||||||||||||
| 35815 | JR Z,GetKey_UseTheShiftedMap | If it is zero, jump to GetKey_UseTheShiftedMap. | ||||||||||||||||||
| 35817 | LD A,127 | Read from the keyboard port.
|
||||||||||||||||||
| 35819 | IN A,(254) | |||||||||||||||||||
| 35821 | AND %00000010 | Keep only bit 1 (SYMBOL SHIFT). | ||||||||||||||||||
| 35823 | JR NZ,GetKey_GetByte | If it is not zero, jump to GetKey_GetByte. | ||||||||||||||||||
| GetKey_UseTheShiftedMap | 35825 | LD HL,35875 | Point HL at the shifted keyboard map at KeyboardMapShifted. | |||||||||||||||||
| GetKey_GetByte | 35828 | ADD HL,BC | Add the key code in BC to the keyboard map pointer. | |||||||||||||||||
| 35829 | LD A,(HL) | Read the character for this key from the keyboard map. | ||||||||||||||||||
| GetKey_Return | 35830 | POP BC | Restore BC, IX and HL from the stack. | |||||||||||||||||
| 35831 | POP IX | |||||||||||||||||||
| 35833 | POP HL | |||||||||||||||||||
| 35834 | RET | Return. | ||||||||||||||||||
| Prev: 35713 | Up: Map | Next: 35835 |