'=========================================================================== ' Subject: KEYBOARD HANDLER FOR PB Date: 03-30-99 (13:12) ' Author: Tim Nordell Code: PB ' Origin: tim@techmaster.roseville.k12.mn Packet: KEYBOARD.ABC '=========================================================================== DECLARE FUNCTION SetOnExit%(BYVAL ProcedurePointer???) shared sf??,foff?? dim ckeys(128,1) as shared byte sub enablekey() public dim h as byte ptr h=codeptr32(skppp)+1 @h=1 end sub sub disablekey() public dim h as byte ptr h=codeptr32(skppp)+1 @h=0 end sub sub enable() public dim h as integer ptr dim g as dword ptr h=codeptr32(locat)+1 @h=varseg(ckeys(0,0)) h=h+3 @h=varptr(ckeys(0,0)) g=codeptr32(hjkl)+1 getinterruptvector 9,sf??,foff?? @g=sf??*&h10000+foff?? setinterruptvector 9,codeseg(keyhand),codeptr(keyhand) a???=codeptr32(disable) call setonexit(a???) end sub sub disable() public setinterruptvector 9,sf??,foff?? end sub sub kyhand() print "Not to be called directly..." exit sub keyhand: ! push ax ! push bx ! push ds ! push si ! push cx ! push dx locat: ! mov ax,&hffef ! Mov bx,&hfeff ! push ax ! pop ds ! push bx ! pop si ! xor ax,ax ! mov al,ds:[si] ! cmp al,1 ! jne notex ! add bx,129 ! mov ax,0 ! mov ds:[si],al ! push bx ! pop si notex: ! mov ah,0 ! in al,&h60 ! cmp al,&he0 ! je exttt ! cmp ax,127 ! jle of ! mov ds:[Si],al ! sub al,128 ! add bx,ax ! push bx ! pop si ! xor al,al ! mov ds:[Si],al ! jmp skppp of: ! mov ds:[Si],al ! add bx,ax ! push bx ! pop si ! mov al,1 ! mov ds:[Si],al skppp: ! mov al,&h01 ! cmp al,0 ! je hjkll ! pop dx ! pop cx ! pop si ! pop ds ! pop bx ! pop ax hjkl: $inline &HeA,&Hff,&hff,&hff,&hff ! iret exttt: ! mov al,1 ! mov ds:[si],al ! jmp skppp hjkll: ! mov al,&h20 ! out &h20,al ! pop dx ! pop cx ! pop si ! pop ds ! pop bx ! pop ax ! iret end sub SUB SetInterruptVector(Intr%,Segment??,Offset??) ! cli REG 1,&H2500 + Intr% REG 4,Offset?? REG 8,Segment?? CALL INTERRUPT &H21 ! sti END SUB SUB GetInterruptVector(Intr%,S??,O??) ! cli REG 1,&H3500 + Intr% CALL INTERRUPT &H21 S??=REG(9) O??=REG(2) ! sti END SUB enable disablekey do if ckeys(1,0) then disable:stop for i%=1 to 128 if ckeys(i%,0) then print " ";hex$(i%); if ckeys(i%,1) then print " E";hex$(i%); next i% print loop