(* File - RB_KBD.INC
By - Greg Teater
Date - December 29, 1987
Purpose - This procedure, RB_Kbd, waits for a key to be pressed on
the Rainbow keyboard. It returns the value of a character
or of a function key and the status of the Control, Shift,
and Lock keys.
Details - All Rainbow keys return a unique code which can be captured
with a firmware level 1 call. This call is achieved by
loading the DI register with a $06 and making a software
interrupt $18. If a key was pressed, then the CL register
returns a $FF, the AH register contains the status of the
Control, Shift, and Lock keys and the AL register contains
the code of the function or character key. If the AH
register is odd, then a function key was pressed. If even,
then a character key was pressed.
If the CL register contains a $01, then the level 2 buffer
has characters in it. These are then cleared out and CL
set to $00 to force it to check again for a level 1
character. This is needed to keep the level 2 buffer from
filling, which can cause a hang problem.
Usage - Five variables are returned when RB_Kbd terminates.
(var Ch : char; { Character Pressed }
var F_Key : F_Key_Type; { Function Key Value }
var Ctrl_Key, {\ }
Shift_Key, { > True If On }
Lock_Key : boolean); {/ }
The F_Key should be used to test if a character was pressed
or a function key. If a character was pressed then F_Key
will equal _Char. If a function key was pressed, then the
F_Key will equal the corresponding value according to the
Function Key Return Value Table. You should always test
F_Key first for _Char then procede accordingly.
The calling command should be structured as follows:
procedure RB_Kbd (var Ch : char; { Character Pressed }
var F_Key : F_Key_Type; { Function Key Value }
var Ctrl_Key, {\ }
Shift_Key, { > True If On }
Lock_Key : boolean); {/ }
var register : record case integer of
1 : (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : integer);
2 : (AL,AH,BL,BH,CL,CH,DL,DH : byte);
end;
begin { RB_Kbd }
repeat
register.di := $06; { set up to read keyboard }
Intr ($18,register); { lets read it }
if register.cl = $01 { does the level 2 buffer contain characters ? }
then
begin { yes }
register.dl := $FF; { \ }
register.ah := $0C; { \ }
register.al := $06; { - Clears Level 2 input buffer }
MsDos (register); { / }
register.cl := $00; { force back into loop }
end;
until register.cl = $FF; { repeat until key is pressed }
if odd (register.ah) { true if function key was pressed }
then F_Key := F_Keys [register.al] { assign function key type name }
else
begin
F_key := _Char; { assign something to test for when }
{ RB_Kbd returns }
Ch := chr (register.al); { assign char value of key }
end;
Ctrl_Key := register.ah in [$4,$5,$6,$7,$C,$D,$E,$F]; { true if on }
Shift_Key := register.ah in [$2,$3,$6,$7,$A,$B,$E,$F]; { or pressed }
Lock_Key := register.ah in [$8..$F]; { }
end; { RB_Kbd }