Prev: 1097 Up: Map Next: 111D
The address of this routine is found in the initial channel information table.
This important subroutine returns the code of the last key to have been pressed, but note that CAPS LOCK, the changing of the mode and the colour control parameters are handled within the subroutine.
A Code of the last key pressed
F Carry flag set if a key was pressed
KEY_INPUT 10A8 BIT 3,(IY+$02) Copy the edit-line or the INPUT-line to the screen if the mode has changed (bit 3 of TV-FLAG set).
10AF AND A Return with both carry and zero flags reset if no new key has been pressed (bit 5 of FLAGS reset).
10B0 BIT 5,(IY+$01)
10B4 RET Z
10B5 LD A,($5C08) Otherwise fetch the code (LAST-K) and signal that it has been taken (reset bit 5 of FLAGS).
10B8 RES 5,(IY+$01)
10BC PUSH AF Save the code temporarily.
10BD BIT 5,(IY+$02) Clear the lower part of the display if necessary (bit 5 of TV-FLAG set), e.g. after 'scroll?'.
10C4 POP AF Fetch the code.
10C5 CP " " Accept all characters and token codes.
10C9 CP $10 Jump forward with most of the control character codes.
10CD CP $06 Jump forward with the 'mode' codes and the CAPS LOCK code.
Now deal with the FLASH, BRIGHT and INVERSE codes.
10D1 LD B,A Save the code.
10D2 AND $01 Keep only bit 0.
10D4 LD C,A C holds +00 (=OFF) or +01 (=ON).
10D5 LD A,B Fetch the code.
10D6 RRA Rotate it once (losing bit 0).
10D7 ADD A,$12 Increase it by +12 giving +12 for FLASH, +13 for BRIGHT, and +14 for INVERSE.
The CAPS LOCK code and the mode codes are dealt with 'locally'.
KEY_M_CL 10DB JR NZ,KEY_MODE Jump forward with 'mode' codes.
10DD LD HL,$5C6A This is FLAGS2.
10E0 LD A,$08 Flip bit 3 of FLAGS2. This is the CAPS LOCK flag.
10E2 XOR (HL)
10E3 LD (HL),A
10E4 JR KEY_FLAG Jump forward.
KEY_MODE 10E6 CP $0E Check the lower limit.
10E8 RET C
10E9 SUB $0D Reduce the range.
10EB LD HL,$5C41 This is MODE.
10EE CP (HL) Has it been changed?
10EF LD (HL),A Enter the new 'mode' code.
10F0 JR NZ,KEY_FLAG Jump if it has changed; otherwise make it 'L mode'.
10F2 LD (HL),$00
KEY_FLAG 10F4 SET 3,(IY+$02) Signal 'the mode might have changed' (set bit 3 of TV-FLAG).
10F8 CP A Reset the carry flag and return.
10F9 RET
The control key codes (apart from FLASH, BRIGHT and INVERSE) are manipulated.
KEY_CONTR 10FA LD B,A Save the code.
10FB AND $07 Make the C register hold the parameter (+00 to +07).
10FE LD A,$10 A now holds the INK code.
1100 BIT 3,B But if the code was an 'unshifted' code then make A hold the PAPER code.
1104 INC A
The parameter is saved in K-DATA and the channel address changed from KEY_INPUT to KEY_NEXT.
KEY_DATA 1105 LD (IY-$2D),C Save the parameter at K-DATA.
1108 LD DE,$110D This is KEY_NEXT.
110B JR KEY_CHAN Jump forward.
Note: on the first pass entering at KEY_INPUT the A register is returned holding a 'control code' and then on the next pass, entering at KEY_NEXT, it is the parameter that is returned.
KEY_NEXT 110D LD A,($5C0D) Fetch the parameter (K-DATA).
1110 LD DE,$10A8 This is KEY_INPUT.
Now set the input address in the first channel area.
KEY_CHAN 1113 LD HL,($5C4F) Fetch the channel address (CHANS).
1116 INC HL
1117 INC HL
1118 LD (HL),E Now set the input address.
1119 INC HL
111A LD (HL),D
Finally exit with the required code in the A register.
KEY_DONE_2 111B SCF Show a code has been found and return.
111C RET
Prev: 1097 Up: Map Next: 111D