8;
keyR = 19;
keyT = 20;
keyY = 21;
keyU = 22;
keyI = 23;
keyO = 24;
keyP = 25;
keyIndex = 26;
keyBackIndex = 27;
keyEnter = 28;
keyCapsLock = 58;
keyA = 30;
keyS = 31;
keyD = 32;
keyF = 33;
keyG = 34;
keyH = 35;
keyJ = 36;
keyK = 37;
keyL = 38;
keyDoublePeriod = 39;
keyApostroph = 40;
keyLShift = 42;
keyBackSlash = 43;
keyZ = 44;
keyX = 45;
keyC = 46;
keyV = 47;
keyB = 48;
keyN = 49;
keyM = 50;
keyComma = 51;
keyPeriod = 52;
keySlash = 53;
keyRShift = 54;
keyCtrl = 29;
keyAlt = 56;
keySpace = 57;
keyNumLock = 69;
keyMultiply = 55;
keyMinus = 74;
keyPlus = 78;
keyDelete = 83;
keyHome = 71;
keyUp = 72;
keyPgUp = 73;
keyLeft = 75;
keyFive = 76;
keyRight = 77;
keyEnd = 79;
keyDown = 80;
keyPgDn = 81;
keyInsert = 82;
KeyPressed: Boolean = FALSE;
Var
Key: Array [1 .. 128] of Boolean;
WasPressed: Array [1 .. 128] of Boolean;
Const
CheckWarmReboot: Boolean = TRUE;
WarmRebootFlag: Boolean = FALSE;
Procedure InitButtons;
Procedure DoneButtons;
Function ButtonsInited: Boolean;
Function IsKeypressed: Boolean;
Function Pressed (Index: Byte): Boolean;
Procedure ClearKeys;
IMPLEMENTATION
Const
Init: Boolean = FALSE;
Var
OldKbdHandler: Pointer;
Procedure Int9; INTERRUPT;
Var
ScanCode, Tmp: Byte;
begin
ScanCode: = Port [$ 60];
if ScanCode and 128 = 0 then
begin
Key [ScanCode]: = TRUE;
KeyPressed: = TRUE;
end else
begin
ScanCode: = ScanCode xor 128;
Key [ScanCode]: = FALSE;
WasPressed [ScanCode]: = TRUE;
KeyPressed: = FALSE;
end;
if CheckWarmReboot and (ScanCode = keyDelete) then
begin
Tmp: = Mem [Seg0040: $ 0017];
if Tmp and 12 = 12 then
begin
Tmp: = Tmp xor 21;
WarmRebootFlag: = TRUE;
end;
Mem [Seg0040: $ 0017]: = Tmp;
end;
asm
in al, 61h
or al, 82h
out 61h, al
and al, 7Fh
out 61h, al
mov al, 20h
out 20h, al
end;
В
end;
Procedure InitButtons;
begin
if not Init then
begin
GetIntVec ($ 9, OldKbdHandler);
SetIntVec ($ 9, @ Int9);
FillChar (Key, SizeOf (Key), FALSE);
FillChar (WasPressed, SizeOf (WasPressed), FALSE);
CheckWarmReboot: = TRUE;...