📄 llkeys.asm
字号:
TITLE LLKEYS - Keyboard support and mapping routines
;***
; LLKEYS.ASM - keyboard support and mapping routines
;
; Copyright <C> 1986, Microsoft Corporation
;
;Purpose:
;
;******************************************************************************
INCLUDE switch.inc ;switch file [new]
INCLUDE rmacros.inc ;useseg macro
USESEG RT_TEXT ;core runtime segment
USESEG _DATA
USESEG CONST
USESEG _BSS
INCLUDE seg.inc ;segment definitions
INCLUDE idmac.inc ;internal debug macros
INCLUDE oscalls.inc ;Dos 5 structures
INCLUDE ibmunv.inc
INCLUDE intmac.inc
INCLUDE const.inc
SUBTTL local constant definitions
page
HidScn1 = 0E0H ; hidden scan code for 101-key keyboard
HidScn2 = 0F0H ; hidden scan code for 101-key keyboard
CharSlash = 2FH ; character code for keypad /
CharEnter = 0DH ; character code for keypad Enter
CharCTRLEnter = 0AH ; character code for CTRL keypad Enter
ScanSlash = 35H ; scan code for keypad /
ScanEnter = 1CH ; scan code for keypad Enter
SUBTTL data definitions
page
sBegin CONST
PAGE
;List of Microsoft Key codes and their significance (all key codes
;are in Hex)
;
;KeyCode(Hex) Remarks
;________________________________________________________________________
;
;00 Null (but printable if a font exists)
;
;01-0C Printable 1-byte characters
;
;0D Carriage Return
;
;0E-0F Printable 1-byte characters
;
;20-7E ASCII characters
;
;7F DELETE character
;
;80 First byte of 2-byte character set
; Softkey implementation
; 8000-801F **Unimplemented**
; 8020-803F Function Keys (mapped by INPUT routines)
; 8040 **Unimplemented**
; 8041-805A Super-shift Keys
; 805B-807E **Unimplemented**
; 8080 printable character 80 (if a font exists)
; Font is 1 byte only
; 8081-80FC **Unimplemented**
;
;81-9F First byte of 2-byte character set
; 40-FC Second byte of 2-byte character set (7F is illegal)
;
;A0-DF Printable 1-byte character set
;
;E0-FC First byte of 2-byte character set
; 40-FC Second byte of 2-byte character set (7F is illegal)
;
;FE First byte of 3-byte character set
; 0000-FFFF Second and third bytes of a 3-byte character
; mapped to 1- or 2- byte character by INPUT routines
;
;FF First byte of 2-byte character set
; 00-0F Editor control characters (as input keys)
; 10 Editor control key ( as input key)
; Printable character FE, if font exists (as print code)
; Font is 1 byte only
; FF11-FFFE Editor control characters (as input keys)
; FFFF Editor control key ( as input key)
; Printable character FF, (font is space) as print code
; Font is 1 byte only
;
;Note:
; **Unimplemented** key codes are also valid but currently they have no
; assigned function.
;
PAGE
FKPARM LABEL WORD
FKCCNT DB 6 ;# of chars/function key to display
FKDCNT DB 10D ;# of function keys to display
FKNUM DB 1 ;# of first function key to display
sEnd CONST
sBegin _BSS
externB b$RcoFlg ; flag for 101-key keyboard
externB b$ScrWidth
externB b$BiosMode
sEnd _BSS
PAGE
sBegin RT_TEXT
assumes CS,RT_TEXT
; Moved FAR with revision [18].
; Let function-key mapping table have entries for 0-13 & 28,29,30, & 31
FKYMAP_TABLE LABEL BYTE ; Mapped to
DB 0 ; Null (no mapping)
DB 1 ; No special mapping
DB 2 ; No special mapping
DB 3 ; No special mapping
DB 4 ; No special mapping
DB 5 ; No special mapping
DB 6 ; No special mapping
DB 14 ; music bar character
DB 254 ; Small square block char
DB 26 ; Right arrow (->)
DB 27 ; Left arrow (<-)
DB 127 ; House char
DB 22 ; Lower-half block char
DB 27 ; Left arrow (<-)
DB 16 ; Right wedge char
DB 17 ; Lefht wedge char
DB 24 ; Up arrow char
DB 25 ; Down arrow char
; B$PRTMAP uses this table to determine 1- or 2-byte code
; The table entry's MSB is set (=1) if it is a 2-byte code
; else it is cleared (value < 128)
; This table contains translation bytes for ascii 0-31
PRTMAP_TABLE LABEL BYTE ; Mapping done is as follows:
DB 0D ; No special mapping
DB 1D ; No special mapping
DB 2D ; No special mapping
DB 3D ; No special mapping
DB 4D ; No special mapping
DB 5D ; No special mapping
DB 6D ; No special mapping
DB 080H+07H ; Backspace
DB 8D ; No special mapping
DB 080H+09H ; TAB
DB 080H+0AH ; LineFeed
DB 080H+0BH ; Home cursor
DB 080H+0CH ; Clear scroll window
DB 080H+0DH ; Carriage Return
DB 14D ; No special mapping
DB 15D ; No special mapping
DB 16D ; No special mapping
DB 17D ; No special mapping
DB 18D ; No special mapping
DB 19D ; No special mapping
DB 20D ; No special mapping
DB 21D ; No special mapping
DB 22D ; No special mapping
DB 23D ; No special mapping
DB 24D ; No special mapping
DB 25D ; No special mapping
DB 26D ; No special mapping
DB 27D ; No special mapping
DB 080H+1CH ; Cursor Right
DB 080H+1DH ; Cursor Left
DB 080H+1EH ; Cursor Up
DB 080H+1FH ; Cursor Down
PAGE
; B$EDTMAP uses a table to determine 1- or 2-byte code
; The table entry's MSB is set (=1) if it is a 2-byte code
; else it is cleared (value < 128)
; This table contains translation bytes for ascii 0-31
EDTMAP_TABLE LABEL BYTE
DB 080H+10H
DB 0001H
DB 080H+02H
DB 080H+03H
DB 0004H
DB 080H+05H
DB 080H+06H
DB 080H+07H
DB 080H+08H
DB 080H+09H
DB 080H+0AH
DB 080H+0BH
DB 080H+0CH
DB 080H+0DH
DB 080H+0EH
DB 000FH
DB 0010H
DB 0011H
DB 080H+12H
DB 0013H
DB 080H+14H
DB 080H+15H
DB 0016H
DB 0017H
DB 0018H
DB 0019H
DB 001AH
DB 080H+15H
DB 080H+1CH
DB 080H+1DH
DB 080H+1EH
DB 080H+1FH
PAGE
;KEYCODE TABLE FORMAT : <raw-code>,<new-AL> ;<new-AH>
;
; Remarks on the KEYINP_TABLE table arrangement
;
; Currently, the arrangement is as follows:
; <raw-code> = All sorts of values found (i.e. cannot make any assumptions)
; <new-AL > 0 - 1F 20 - 7E 7F 80 FE FF
; <new-AH > FF 80 FF 80 Scan FF
; Byte-category 2 1 2 2 3 2
;
;It can be seen, that by arranging the table in such a fashion that <new-AL>
; is ordered so that the returned <new-AH> would be 80,FF,Scan
; we eliminate the need to store <new-AH> in the table. Of course, this would
; need some comparisons once a match has been found in this table but the
; overall search is improved with the expected (or by design) reduction in
; code size.
;
; In the following table the third entry is commented out
; The original table is ordered as suggested above
; The intervening labels identify various <new-AH> types
; Within each type, the table is ordered by <new-AL> (ascending)
; To assist the search better (less code), the table has been organized
; in this order
; <new-AL>, <scan> ;<new-AH>
KEYINP_TABLE LABEL WORD ; Word access
; <new-AL>, <scan> ;<new-AH>
DB 032D,059D ;128D ;function keys 1
DB 033D,060D ;128D ; 2
DB 034D,061D ;128D ; 3
DB 035D,062D ;128D ; 4
DB 036D,063D ;128D ; 5
DB 037D,064D ;128D ; 6
DB 038D,065D ;128D ; 7
DB 039D,066D ;128D ; 8
DB 040D,067D ;128D ; 9
DB 041D,068D ;128D ; 10
DB 042D,133D ;128D ; F11
DB 043D,134D ;128D ; F12
DB 044D,135D ;128D ; Shift-F11
DB 045D,136D ;128D ; Shift-F12
DB 046D,137D ;128D ; Ctrl-F11
DB 047D,138D ;128D ; Ctrl-F12
DB 048D,139D ;128D ; Alt-F11
DB 049D,140D ;128D ; Alt-F12
DB 065D,030D ;128D ;super shift A
DB 066D,048D ;128D ; B
DB 067D,046D ;128D ; C
DB 068D,032D ;128D ; D
DB 069D,018D ;128D ; E
DB 070D,033D ;128D ; F
DB 071D,034D ;128D ; G
DB 072D,035D ;128D ; H
DB 073D,023D ;128D ; I
DB 074D,036D ;128D ; J
DB 075D,037D ;128D ; K
DB 076D,038D ;128D ; L
DB 077D,050D ;128D ; M
DB 078D,049D ;128D ; N
DB 079D,024D ;128D ; O
DB 080D,025D ;128D ; P
DB 081D,016D ;128D ; Q
DB 082D,019D ;128D ; R
DB 083D,031D ;128D ; S
DB 084D,020D ;128D ; T
DB 085D,022D ;128D ; U
DB 086D,047D ;128D ; V
DB 087D,017D ;128D ; W
DB 088D,045D ;128D ; X
DB 089D,021D ;128D ; Y
DB 090D,044D ;128D ; Z
DB 128D,253D ;128D ;special M.S. code uses 128D
KEY_128 EQU THIS WORD + 2 ; 2-Byte and <new-AH> = 80H
; Note that '+2' is used because
; LODSW increments SI by 2 and
; 'jump below' condition is used
KEY_128_LEN EQU (KEY_128 - KEYINP_TABLE)/2 ; No. of entries for 128
KEY_255_START LABEL WORD ; From here it is '255' code
DB 002D,115D ;255D ;previous word
DB 005D,117D ;255D ;erase --> EOLN
DB 006D,116D ;255D ;next word
DB 011D,071D ;255D ;home cursor
DB 012D,119D ;255D ;clear screen and home cursor
DB 014D,079D ;255D ;--> EOLN
DB 016D,254D ;255D ;special since M.S. code uses 254D
DB 018D,082D ;255D ;toggle insert mode
DB 026D,118D ;255D ;clear to end of window
DB 028D,077D ;255D ;right cursor
DB 029D,075D ;255D ;left cursor
DB 030D,072D ;255D ;up cursor
DB 031D,080D ;255D ;down cursor
DB 127D,083D ;255D ;delete char under cursor
DB 255D,255D ;255D ;special since M.S. code uses 255D
KEY_255 EQU THIS WORD + 2 ; end of '255' codes
; Note that '+2' is used because
; LODSW increments SI by 2 and
; 'jump below' condition is used
KEY_255_LEN EQU (KEY_255-KEY_255_START)/2 ; No. of entries for 255
DB 254D,003D ;003D ;unimplemented
DB 254D,015D ;015D ; "
DB 254D,073D ;073D ; "
DB 254D,081D ;081D ; "
DB 254D,114D ;114D ; "
DB 254D,120D ;120D ; "
DB 254D,121D ;121D ; "
DB 254D,122D ;122D ; "
DB 254D,123D ;123D ; "
DB 254D,124D ;124D ; "
DB 254D,125D ;125D ; "
DB 254D,126D ;126D ; "
DB 254D,127D ;127D ; "
DB 254D,128D ;128D ; "
DB 254D,129D ;129D ; "
DB 254D,130D ;130D ; "
DB 254D,131D ;131D ; "
DB 254D,132D ;132D ; "
DB 000D,000D ;000D ;end of table specifier
KEYINP_TABLE_END LABEL WORD
PAGE
;***
;B$FKYFMT - return format of Function Key display line
;OEM-interface routine
;
;Purpose:
; This routine supports the function key display line feature by
; providing the function key display format. The format is made
; up of three parts as follows:
;
; FKCCNT - 1 byte count of the number of bytes
; to be displayed for each function key
; description.
; FKDCNT - 1 byte count of the number of function
; keys to be displayed.
; FKNUM - 1 byte number of the first key to be
; displayed.
;
; The format must be in the preceding order since the address
; of the format descriptor is what will be returned. The
; current screen width must be sufficient to display this format.
;
; The function key line is displayed as FKDCNT iterations of
; a single digit key number, FKCCNT characters from the function
; key expansion table, and a space. Thus, there will be FKDCNT
; fields of size (1+FKCCNT+1). If two digits are necessary to
; display the function key number, then FKCCNT-1 function key
; characters are displayed. If there are fewer than FKDCNT+
; FKNUM-1 keys to display, then the display will wrap around to
; the first function key, like thus:
;
; 8 xxx 9 xxx 10 xx 1 xxx 2 xxx
;
; for FKCCNT = 3, FKDCNT = 5, FKNUM = 8
;
; If you are supporting double byte characters, take note that this
; routine takes the number of bytes of the function key name, not
; the number of characters. When it is printed, if the last
; character would be the first of a two byte sequence, a space
; will be used instead.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -