home *** CD-ROM | disk | FTP | other *** search
-
- title Keyboard Driver
- name Keyboard
-
- include machine.ah
- include dos.mac
- pseg
-
- if DEC_Rainbow
- ;+
- ; Function:
- ;
- ; The Read_Keyboard function returns a unique 16-bit code for esentially
- ; all keys on the keyboard.
- ;
- ; 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- ; +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
- ; | | C | S | F | code |
- ; +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
- ; F = 1, this is a function key
- ; S = 1, shift key in effect
- ; C = 1, control key in effect
- ;
- ; Returns:
- ;
- ;-
-
- ROM equ 18H ; new ROM access
- Function_Key equ 01H ; this is a function key
- Shift_Flag equ 02H ; shift key in effect
- Control_Flag equ 04H ; control key in effect
- Caps_Lock_Flag equ 08H ; caps lock key in effect
-
- public Read_Keyboard
-
- $proc Read_Keyboard
- push ES ; Save ES
- mov DI,6 ; Level 1 console input
- int ROM
- cmp CL,0 ; Anything?
- je Read_80 ; No, return -1
- cmp CL,1 ; Any Level 2 characters?
- jne Read_10 ; No, go process Level 1 character
-
- ; Here to fetch the Level 2 character left in the buffer.
-
- mov DI,2 ; Level 2 console input
- int ROM
- cmp CL,0 ; Anything?
- je Read_80 ; No
- jmp Read_90
-
- ; Here to process a Level 1 character
-
- Read_10:
- and AH,0F7H ; clear caps lock flag
- jmp Read_90
-
- Read_80:
- mov AX,-1 ; Return -1 to denote no character
-
- Read_90:
- pop ES ; Restore ES
- ret ; Return to caller
-
- $endp Read_Keyboard
-
- endif
-
- if IBM_PC or Tandy_2000
-
- public Read_Keyboard
-
- $proc Read_Keyboard
- mov AH,1
- int 16H ; Scan the keyboard
- jz Read_Keyboard_1 ; No character available
- mov AH,0 ; Yes
- int 16H ; Read keyboard
- cmp AL,0 ; Extended character
- je Read_Keyboard_2 ; Yes
- mov AH,0 ; No, normal character
- ret
-
- Read_Keyboard_1:
- mov AX,-1 ; Denote "no character available"
- ret
-
- Read_Keyboard_2: ; Extended character
- mov AL,AH
- mov AH,01H ; Set the "function key" flags
- ret
-
- $endp Read_Keyboard
-
- endif
-
- endps
- end
-
- OK
-