Volex TTX2000 S Issue 1.2 | Routines |
Prev: 0F1F | Up: Map | Next: 0F7A |
Used by the routine at get_keypress.
|
||||
scan_keyboard | 0F34 | LD D,$08 | B to b11111110 and C to $FE. | |
0F36 | LD BC,$FEFE | |||
scan_keyboard_0 | 0F39 | IN A,(C) | Read one keyboard row. | |
0F3B | DEC D | Decrement counter. | ||
0F3C | OR $E0 | If any key bit is low jump to scan_keyboard_1. | ||
0F3E | CP $FF | |||
0F40 | JR NZ,scan_keyboard_1 | |||
0F42 | RLC B | Else rotate 0 bit left in B. | ||
0F44 | LD A,D | If loop counter is > 0 loop back to scan_keyboard_0. | ||
0F45 | AND A | |||
0F46 | JR NZ,scan_keyboard_0 | |||
0F48 | XOR A | Else return 0 (no key pressed). | ||
0F49 | RET | |||
scan_keyboard_1 | 0F4A | LD A,B | Copy row mask into A. | |
0F4B | LD BC,$0800 | Set B to 8 as a loop counter and C to 0 as a row count. | ||
scan_keyboard_2 | 0F4E | SRL A | Shift A right. | |
0F50 | JR NC,scan_keyboard_3 | If the 0 bit carried out jump to scan_keyboard_3. | ||
0F52 | INC C | Else increment the row count in C. | ||
0F53 | DJNZ scan_keyboard_2 | Decrement loop counter and loop back to scan_keyboard_2 if greater than zero. | ||
0F55 | XOR A | Else return 0 (no key pressed). | ||
0F56 | RET | |||
scan_keyboard_3 | 0F57 | LD A,C | Multiply row count by 5 and push onto stack. | |
0F58 | ADD A,A | |||
0F59 | ADD A,A | |||
0F5A | ADD A,C | |||
0F5B | PUSH AF | |||
0F5C | LD BC,$00FE | Read from all keyboard rows. | ||
0F5F | IN A,(C) | |||
0F61 | LD B,$05 | Set B to 5 as a loop counter, and C to 0 as a column count. | ||
0F63 | LD C,$00 | |||
scan_keyboard_4 | 0F65 | SRL A | Shift input byte left. | |
0F67 | JR NC,scan_keyboard_5 | If 0 carried out jump to scan_keyboard_5. | ||
0F69 | INC C | Else increment the column count in C. | ||
0F6A | DJNZ scan_keyboard_4 | Decrement loop counter and loop back to scan_keyboard_4 if > 0. | ||
0F6C | POP AF | Else balance stack and return 0 (no key pressed). | ||
0F6D | XOR A | |||
0F6E | RET | |||
scan_keyboard_5 | 0F6F | POP AF | Retrieve row count from stack and add column count. | |
0F70 | ADD A,C | |||
0F71 | LD HL,keyboard_lookup_table | Add result to keyboard_lookup_table as offset into keyboard look up table. | ||
0F74 | LD B,$00 | |||
0F76 | LD C,A | |||
0F77 | ADD HL,BC | |||
0F78 | LD A,(HL) | Return the key code. | ||
0F79 | RET |
Prev: 0F1F | Up: Map | Next: 0F7A |