Routines |
Prev: 00798 | Up: Map | Next: 00949 |
This subroutine is entered with the 'main code' in the E register, the value of FLAGS in the D register, the value of MODE in the C register and the 'shift byte' in the B register.
By considering these four values and referring, as necessary, to the six key tables a 'final code' is produced. This is returned in the A register.
|
||||||||||||||||||
K_DECODE | 00819 | LD A,E | Copy the 'main code'. | |||||||||||||||
00820 | CP 58 | Jump forward if a digit key is being considered; also SPACE, ENTER and both shifts. | ||||||||||||||||
00822 | JR C,K_DIGIT | |||||||||||||||||
00824 | DEC C | Decrement the MODE value. | ||||||||||||||||
00825 | JP M,K_KLC_LET | Jump forward, as needed, for modes 'K', 'L', 'C' and 'E'. | ||||||||||||||||
00828 | JR Z,K_E_LET | |||||||||||||||||
Only 'graphics' mode remains and the 'final code' for letter keys in graphics mode is computed from the 'main code'.
|
||||||||||||||||||
00830 | ADD A,79 | Add the offset. | ||||||||||||||||
00832 | RET | Return with the 'final code'. | ||||||||||||||||
Letter keys in extended mode are considered next.
|
||||||||||||||||||
K_E_LET | 00833 | LD HL,491 | The base address for table 'b'. | |||||||||||||||
00836 | INC B | Jump forward to use this table if neither shift key is being pressed. | ||||||||||||||||
00837 | JR Z,K_LOOK_UP | |||||||||||||||||
00839 | LD HL,517 | Otherwise use the base address for table 'c'. | ||||||||||||||||
Key tables 'b-f' are all served by the following look-up routine. In all cases a 'final code' is found and returned.
|
||||||||||||||||||
K_LOOK_UP | 00842 | LD D,0 | Clear the D register. | |||||||||||||||
00844 | ADD HL,DE | Index the required table and fetch the 'final code'. | ||||||||||||||||
00845 | LD A,(HL) | |||||||||||||||||
00846 | RET | Then return. | ||||||||||||||||
Letter keys in 'K', 'L' or 'C' modes are now considered. But first the special SYMBOL SHIFT codes have to be dealt with.
|
||||||||||||||||||
K_KLC_LET | 00847 | LD HL,553 | The base address for table 'e'. | |||||||||||||||
00850 | BIT 0,B | Jump back if using the SYMBOL SHIFT key and a letter key. | ||||||||||||||||
00852 | JR Z,K_LOOK_UP | |||||||||||||||||
00854 | BIT 3,D | Jump forward if currently in 'K' mode. | ||||||||||||||||
00856 | JR Z,K_TOKENS | |||||||||||||||||
00858 | BIT 3,(IY+48) | If CAPS LOCK is set (bit 3 of FLAGS2 set) then return with the 'main code'. | ||||||||||||||||
00862 | RET NZ | |||||||||||||||||
00863 | INC B | Also return in the same manner if CAPS SHIFT is being pressed. | ||||||||||||||||
00864 | RET NZ | |||||||||||||||||
00865 | ADD A,32 | However if lower case codes are required then 32 has to be added to the 'main code' to give the correct 'final code'. | ||||||||||||||||
00867 | RET | |||||||||||||||||
The 'final code' values for tokens are found by adding 165 to the 'main code'.
|
||||||||||||||||||
K_TOKENS | 00868 | ADD A,165 | Add the required offset and return. | |||||||||||||||
00870 | RET | |||||||||||||||||
Next the digit keys, SPACE, ENTER and both shifts are considered.
|
||||||||||||||||||
K_DIGIT | 00871 | CP "0" | Proceed only with the digit keys, i.e. return with SPACE (32), ENTER (13) and both shifts (14). | |||||||||||||||
00873 | RET C | |||||||||||||||||
00874 | DEC C | Now separate the digit keys into three groups - according to the mode. | ||||||||||||||||
00875 | JP M,K_KLC_DGT | Jump with 'K', 'L' and 'C' modes, and also with 'G' mode. Continue with 'E' mode. | ||||||||||||||||
00878 | JR NZ,K_GRA_DGT | |||||||||||||||||
00880 | LD HL,596 | The base address for table 'f'. | ||||||||||||||||
00883 | BIT 5,B | Use this table for SYMBOL SHIFT and a digit key in extended mode. | ||||||||||||||||
00885 | JR Z,K_LOOK_UP | |||||||||||||||||
00887 | CP "8" | Jump forward with digit keys '8' and '9'. | ||||||||||||||||
00889 | JR NC,K_8_9 | |||||||||||||||||
The digit keys '0' to '7' in extended mode are to give either a 'paper colour code' or an 'ink colour code' depending on the use of CAPS SHIFT.
|
||||||||||||||||||
00891 | SUB 32 | Reduce the range 48 to 55 giving 16 to 23. | ||||||||||||||||
00893 | INC B | Return with this 'paper colour code' if CAPS SHIFT is not being used. | ||||||||||||||||
00894 | RET Z | |||||||||||||||||
00895 | ADD A,8 | But if it is then the range is to be 24 to 31 instead - indicating an 'ink colour code'. | ||||||||||||||||
00897 | RET | |||||||||||||||||
The digit keys '8' and '9' are to give 'BRIGHT' and 'FLASH' codes.
|
||||||||||||||||||
K_8_9 | 00898 | SUB 54 | 56 and 57 go to 2 and 3. | |||||||||||||||
00900 | INC B | Return with these codes if CAPS SHIFT is not being used. (These are 'BRIGHT' codes.) | ||||||||||||||||
00901 | RET Z | |||||||||||||||||
00902 | ADD A,254 | Subtract '2' if CAPS SHIFT is being used; giving 0 and 1 (as 'FLASH' codes). | ||||||||||||||||
00904 | RET | |||||||||||||||||
The digit keys in graphics mode are to give the block graphic characters (128 to 143), the GRAPHICS code (15) and the DELETE code (12).
|
||||||||||||||||||
K_GRA_DGT | 00905 | LD HL,560 | The base address of table 'd'. | |||||||||||||||
00908 | CP "9" | Use this table directly for both digit key '9' that is to give GRAPHICS, and digit key '0' that is to give DELETE. | ||||||||||||||||
00910 | JR Z,K_LOOK_UP | |||||||||||||||||
00912 | CP "0" | |||||||||||||||||
00914 | JR Z,K_LOOK_UP | |||||||||||||||||
00916 | AND 7 | For keys '1' to '8' make the range 128 to 135. | ||||||||||||||||
00918 | ADD A,128 | |||||||||||||||||
00920 | INC B | Return with a value from this range if neither shift key is being pressed. | ||||||||||||||||
00921 | RET Z | |||||||||||||||||
00922 | XOR 15 | But if 'shifted' make the range 136 to 143. | ||||||||||||||||
00924 | RET | |||||||||||||||||
Finally consider the digit keys in 'K', 'L' and 'C' modes.
|
||||||||||||||||||
K_KLC_DGT | 00925 | INC B | Return directly if neither shift key is being used. (Final codes 48 to 57.) | |||||||||||||||
00926 | RET Z | |||||||||||||||||
00927 | BIT 5,B | Use table 'd' if the CAPS SHIFT key is also being pressed. | ||||||||||||||||
00929 | LD HL,560 | |||||||||||||||||
00932 | JR NZ,K_LOOK_UP | |||||||||||||||||
The codes for the various digit keys and SYMBOL SHIFT can now be found.
|
||||||||||||||||||
00934 | SUB 16 | Reduce the range to give 32 to 41. | ||||||||||||||||
00936 | CP 34 | Separate the '@' character from the others. | ||||||||||||||||
00938 | JR Z,K_AT_CHAR | |||||||||||||||||
00940 | CP 32 | The '_' character has also to be separated. | ||||||||||||||||
00942 | RET NZ | Return now with the 'final codes' 33, 35 to 41. | ||||||||||||||||
00943 | LD A,"_" | Give the '_' character a code of 95. | ||||||||||||||||
00945 | RET | |||||||||||||||||
K_AT_CHAR | 00946 | LD A,"@" | Give the '@' character a code of 64. | |||||||||||||||
00948 | RET |
Prev: 00798 | Up: Map | Next: 00949 |