![]() |
Routines |
| Prev: 62979 | Up: Map | Next: 63102 |
|
Used by the routines at MainMenu_ChooseLearnerOrSuper, MainMenu_SelectOptions and Read_PlayerControls.
Scan the keyboard half-rows via Table_KeyboardPortMap and return the matching ASCII key code in A, or 0 if nothing is pressed.
|
||||
|
Probe port 65278 first (caps/shift row with bit 0 forced).
|
||||
| Read_KeyboardControls | 63040 | LD BC,65278 | Load BC with keyboard port 65278. | |
| 63043 | LD HL,63102 | Point HL at Table_KeyboardPortMap. | ||
| 63046 | IN A,(C) | Read the half-row. | ||
| 63048 | SET 0,A | Force bit 0 set (ignore caps-shift alone). | ||
| 63050 | AND %00011111 | Keep the five key bits. | ||
| 63052 | XOR %00011111 | Invert so pressed keys are set. | ||
| 63054 | JR NZ,Read_KeyboardControls_Decode | If any are pressed, decode at Read_KeyboardControls_Decode. | ||
| 63056 | LD DE,5 | Load DE with 0005, then advance HL onto the next half-row's key codes. | ||
| 63059 | ADD HL,DE | |||
| 63060 | LD E,6 | Load E with 6 remaining half-rows. | ||
|
Scan the remaining keyboard half-rows for a pressed key.
|
||||
| Read_KeyboardControls_HalfRowLoop | 63062 | RLC B | Rotate the port select in B left (next half-row). | |
| 63064 | IN A,(C) | Read that half-row. | ||
| 63066 | AND %00011111 | Keep the five key bits. | ||
| 63068 | XOR %00011111 | Invert so pressed keys are set. | ||
| 63070 | JR NZ,Read_KeyboardControls_Decode | If any are pressed, decode at Read_KeyboardControls_Decode. | ||
| 63072 | INC HL | Advance HL onto the next half-row's key codes. | ||
| 63073 | INC HL | |||
| 63074 | INC HL | |||
| 63075 | INC HL | |||
| 63076 | INC HL | |||
| 63077 | DEC E | Decrease the half-row counter. | ||
| 63078 | JR NZ,Read_KeyboardControls_HalfRowLoop | Loop at Read_KeyboardControls_HalfRowLoop if more half-rows remain. | ||
|
Final half-row: force bit 1 set before testing.
|
||||
| 63080 | RLC B | Rotate onto the last half-row port. | ||
| 63082 | IN A,(C) | Read it. | ||
| 63084 | SET 1,A | Force bit 1 set. | ||
| 63086 | AND %00011111 | Keep / invert the key bits. | ||
| 63088 | XOR %00011111 | Invert so pressed keys are set. | ||
| 63090 | JR NZ,Read_KeyboardControls_Decode | If any are pressed, decode at Read_KeyboardControls_Decode. | ||
| 63092 | RET | Return with A = 0 (no key). | ||
|
Shift through the pressed-bit positions to pick the ASCII code at HL.
|
||||
| Read_KeyboardControls_Decode | 63093 | SRL A | Shift the pressed-bit mask right, then if that key is pressed, take its code at Read_KeyboardControls_Found. | |
| 63095 | JR C,Read_KeyboardControls_Found | |||
| 63097 | INC HL | Advance HL onto the next key's code. | ||
| 63098 | JR Read_KeyboardControls_Decode | Jump to Read_KeyboardControls_Decode to keep decoding. | ||
|
Return the ASCII code for the pressed bit position from the port map.
|
||||
| Read_KeyboardControls_Found | 63100 | LD A,(HL) | Fetch the ASCII key code at HL. | |
| 63101 | RET | Return. | ||
| Prev: 62979 | Up: Map | Next: 63102 |