|Prev: 031E||Up: Map||Next: 03B5|
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||0333||LD A,E||Copy the 'main code'.|
|0334||CP $3A||Jump forward if a digit key is being considered; also SPACE, ENTER and both shifts.|
|0338||DEC C||Decrement the MODE value.|
|0339||JP M,K_KLC_LET||Jump forward, as needed, for modes 'K', 'L', 'C' and 'E'.|
Only 'graphics' mode remains and the 'final code' for letter keys in graphics mode is computed from the 'main code'.
|033E||ADD A,$4F||Add the offset.|
|0340||RET||Return with the 'final code'.|
Letter keys in extended mode are considered next.
|K_E_LET||0341||LD HL,$01EB||The base address for table 'b'.|
|0344||INC B||Jump forward to use this table if neither shift key is being pressed.|
|0347||LD HL,$0205||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||034A||LD D,$00||Clear the D register.|
|034C||ADD HL,DE||Index the required table and fetch the 'final code'.|
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||034F||LD HL,$0229||The base address for table 'e'.|
|0352||BIT 0,B||Jump back if using the SYMBOL SHIFT key and a letter key.|
|0356||BIT 3,D||Jump forward if currently in 'K' mode.|
|035A||BIT 3,(IY+$30)||If CAPS LOCK is set (bit 3 of FLAGS2 set) then return with the 'main code'.|
|035F||INC B||Also return in the same manner if CAPS SHIFT is being pressed.|
|0361||ADD A,$20||However if lower case codes are required then +20 has to be added to the 'main code' to give the correct 'final code'.|
The 'final code' values for tokens are found by adding +A5 to the 'main code'.
|K_TOKENS||0364||ADD A,$A5||Add the required offset and return.|
Next the digit keys, SPACE, ENTER and both shifts are considered.
|K_DIGIT||0367||CP "0"||Proceed only with the digit keys, i.e. return with SPACE (+20), ENTER (+0D) and both shifts (+0E).|
|036A||DEC C||Now separate the digit keys into three groups - according to the mode.|
|036B||JP M,K_KLC_DGT||Jump with 'K', 'L' and 'C' modes, and also with 'G' mode. Continue with 'E' mode.|
|0370||LD HL,$0254||The base address for table 'f'.|
|0373||BIT 5,B||Use this table for SYMBOL SHIFT and a digit key in extended mode.|
|0377||CP "8"||Jump forward with digit keys '8' and '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.
|037B||SUB $20||Reduce the range +30 to +37 giving +10 to +17.|
|037D||INC B||Return with this 'paper colour code' if CAPS SHIFT is not being used.|
|037F||ADD A,$08||But if it is then the range is to be +18 to +1F instead - indicating an 'ink colour code'.|
The digit keys '8' and '9' are to give 'BRIGHT' and 'FLASH' codes.
|K_8_9||0382||SUB $36||+38 and +39 go to +02 and +03.|
|0384||INC B||Return with these codes if CAPS SHIFT is not being used. (These are 'BRIGHT' codes.)|
|0386||ADD A,$FE||Subtract '2' if CAPS SHIFT is being used; giving +00 and +01 (as 'FLASH' codes).|
The digit keys in graphics mode are to give the block graphic characters (+80 to +8F), the GRAPHICS code (+0F) and the DELETE code (+0C).
|K_GRA_DGT||0389||LD HL,$0230||The base address of table 'd'.|
|038C||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.|
|0394||AND $07||For keys '1' to '8' make the range +80 to +87.|
|0398||INC B||Return with a value from this range if neither shift key is being pressed.|
|039A||XOR $0F||But if 'shifted' make the range +88 to +8F.|
Finally consider the digit keys in 'K', 'L' and 'C' modes.
|K_KLC_DGT||039D||INC B||Return directly if neither shift key is being used. (Final codes +30 to +39.)|
|039F||BIT 5,B||Use table 'd' if the CAPS SHIFT key is also being pressed.|
The codes for the various digit keys and SYMBOL SHIFT can now be found.
|03A6||SUB $10||Reduce the range to give +20 to +29.|
|03A8||CP $22||Separate the '@' character from the others.|
|03AC||CP $20||The '_' character has also to be separated.|
|03AE||RET NZ||Return now with the 'final codes' +21, +23 to +29.|
|03AF||LD A,"_"||Give the '_' character a code of +5F.|
|K_AT_CHAR||03B2||LD A,"@"||Give the '@' character a code of +40.|
|Prev: 031E||Up: Map||Next: 03B5|