3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ;; DOS - - NLS Support - KEYB Command
5 ;; (C) Copyright 1988 Microsoft
7 ;; File Name: KEYBSHAR.INC
12 ;; Include file containing structure definitions Shared Data Area
13 ;; for the Shared Data Area.
14 ;; The Shared Data Area contains data which is required by
15 ;; both the resident and transient KEYB code. The Shared
16 ;; Data Area is allocated in the KEYBI2F file and will be
17 ;; resident following initial installation.
23 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
25 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 ;; SHARED_DATA_STR defines the initial fixed length portion of the
28 ;; Tables are loaded beginning at TABLE_AREA in the following order:
30 ;; Common Translate Section
31 ;; Specific Translate Sections for
33 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
34 ;; SPECIAL_FEATURES equates:
35 TYPEWRITER_CAPS_LK EQU 8000H ;; typewriter style caps lock
36 JR_HOT_KEY_1_2 EQU 4000H ;; on PCjr use 1/2 as the hot keys
39 ;; Some useful scan codes:
45 ;; SYSTEM_FLAG equates:
46 EXT_16 EQU 8000H ;; extended int16 support is there
47 PC_AT EQU 4000H ;; code for pcat
48 PC_LAP EQU 2000H ;; code for pc lap computer (p-12)
49 PC_XT EQU 1000H ;; code for PC, PC/XT, PORTABLE
50 PC_JR EQU 0800H ;; code for PCjr
51 PC_PAL EQU 0400H ;; code for ???
52 PC_386 EQU 0200H ;; code for ???
53 PC_NET EQU 0100H ;; PC Net is installed
55 ;; HOT_KEY_FLAG EQUATES:
56 US_MODE EQU 0 ;; hot key is active => US
57 LANG_MODE EQU 0FFH ;; hot key is inactive
59 ;; -----------------------------------
60 SHARED_DATA_STR STRUC ;; SHARED DATA AREA
62 OLD_INT_9 DD 0 ;; saved int 9 vector
63 OLD_INT_2F DD 0 ;; saved int 2F vector
64 OLD_INT_48 DD 0 ;; saved int 48 vector (if PCjr)
65 KEYB_TYPE DW 0 ;; type of keyboard
66 SYSTEM_FLAG DW 0 ;; system configuration flags
67 TABLE_OK DB 0 ;; flag to INT 9 that table is built
68 JR_KB_FLAG DB 0 ;; flag for special PCjr processing
69 DB 4 DUP(0) ;; reserved
71 ;; Table copy begins here:
72 ACTIVE_LANGUAGE DB 'US' ;; language code
73 INVOKED_CP_TABLE DW 437 ;; ptr to table for invoked code page
74 ACTIVE_XLAT_PTR DW -1 ;; ptr to active Specific Translate Sect
75 FIRST_XLAT_PTR DW -1 ;; ptr to first Specific Translate Sect
76 RESIDENT_END DW 0ffffh ;; offset of last byte in resident mem
77 LOGIC_PTR DW -1 ;; ptr to State Logic
78 COMMON_XLAT_PTR DW -1 ;; ptr to Common Translate Section
79 SPECIAL_FEATURES DW ? ;; special Features
80 TABLE_OVERFLOW DB 0 ;; overflow flag for table rebuild
81 HOT_KEY_ON_SCAN DB ? ;; scan codes to use with ALT+CTRL
82 HOT_KEY_OFF_SCAN DB ? ;; to turn hot key on and off
83 DB 4 DUP(0) ;; reserved
84 TABLE_AREA DB ? ;; tables loaded here:
86 ;; Common Translate Section
87 ;; Specific Translate Sections for
89 SHARED_DATA_STR ENDS ;;
93 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
94 ;; State Logic equates.
95 ;; Contains equates for our NLS Flags and for the State Logic
97 ;; State Logic command macros are defined in KEYBMAC.INC
98 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
100 STATE_LOGIC_STR STRUC ;;
102 SL_LOGIC_LEN DW ? ;; length of state logic
103 SL_SPECIAL_FEATURES DW ? ;;
104 SL_LOGIC_CMDS DB 0 ;; state logic commands begin here
106 STATE_LOGIC_STR ENDS ;;
109 NUM_BIOS_FLAGS EQU 4 ;;
110 NUM_NLS_FLAGS EQU 2 ;; '+1' below is the EXT_KB_FLAG
111 NUM_FLAGS EQU NUM_BIOS_FLAGS+NUM_NLS_FLAGS+1
114 EITHER_SHIFT EQU 80H ;; EXT_KB_FLAG : our own shift state
115 EITHER_CTL EQU 40H ;; flags
116 EITHER_ALT EQU 20H ;;
117 SCAN_MATCH EQU 08H ;; set if scan code found in XLATT
118 ;; or SET_FLAG searches
121 KB_FLAG_ID EQU 0 ;; Flag ID's as coded in IFF and ANDF
122 KB_FLAG_1_ID EQU 1 ;; commands
123 KB_FLAG_2_ID EQU 2 ;;
124 KB_FLAG_3_ID EQU 3 ;;
125 EXT_KB_FLAG_ID EQU 4 ;;
126 NLS_FLAG_1_ID EQU 5 ;;
127 NLS_FLAG_2_ID EQU 6 ;;
129 COMMAND_BITS EQU 0F0H ;; Mask to isolate command code
130 SUB_CMD_BITS EQU 0FH ;; mask to isolate sub command code
131 NOT_TEST EQU 08H ;; NOT bit in IFF, ANDF
132 COMMAND_SHIFT EQU 4 ;; shift amount for command code
133 FLAG_ID_BITS EQU 07H ;; mask to isolate flag id in IFF, ANDF
134 NUM_COMMANDS EQU 0CH ;; number of commands
136 IFF_COMMAND EQU 00H ;;
137 ANDF_COMMAND EQU 10H ;;
138 ELSEF_COMMAND EQU 20H ;;
139 ENDIFF_COMMAND EQU 30H ;;
140 XLATT_COMMAND EQU 40H ;;
141 OPTION_COMMAND EQU 50H ;;
142 SET_FLAG_COMMAND EQU 60H ;;
143 PUT_ERROR_COMMAND EQU 70H ;;
144 IFKBD_COMMAND EQU 80H ;;
145 GOTO_COMMAND EQU 90H ;;
146 BEEP_COMMAND EQU 0A0H ;;
147 RESET_NLS_COMMAND EQU 0B0H ;;
148 CHECK_CORE_COMMAND EQU 0C0H ;;
151 EXIT_INT_9_FLAG EQU 01H ;; Special forms of GOTO. These
152 EXIT_STATE_LOGIC_FLAG EQU 02H ;; values are in the right nibble
153 ;; of the GOTO command.
155 ;; PROCESSING OPTIONS:
156 EXIT_IF_FOUND EQU 80H ;; exit INT 9 if a translation
160 JR_KB EQU 8000H ;; Keyboard types
167 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
168 ;; Translate Table Sections. Both the Specific and Common
169 ;; Translate Sections are formatted as follows.
171 ;; The Specific Translate Sections are chained together using the
172 ;; XS_NEXT_SECT_PTR field (-1 if last section).
173 ;; Translate Sections contains multiple States.
174 ;; A State contains the translate tables for a single
175 ;; shift state (IE lower case, upper case ....)
176 ;; Each State may contain multiple translate tables.
178 ;; The Translate Section layout is defined using several STRUCs.
179 ;; These STRUCs are allocated in the Shared Data Area as follows:
181 ;; XLAT_SECT_STR ; header info for the section
182 ;; STATE_STR ; header for state #1
183 ;; XLAT_STR ; first translate tab for state #1
184 ;; XLAT_TYPE_1_STR or XLAT_TYPE_2_STR
185 ;; XLAT_STR ; second translate tab
186 ;; XLAT_TYPE_1_STR or XLAT_TYPE_2_STR
188 ;; STATE_STR ; header for state #2
190 ;; XLAT_TYPE_1_STR or XLAT_TYPE_2_STR
194 ;; A State may contain a "Set_Flag" table instead of translate tables.
195 ;; These tables are used to set the NLS flags instead of generating
196 ;; ASCII codes (for example: to remember dead key states).
197 ;; There can be only on Set_Flag table per state.
198 ;; The Set_Flag table layout is defined in the SET_FLAG_STR STRUC.
200 ;; So some states will contain translate tables (to generate ASCII codes)
201 ;; and some states will contain a Set_Flag table (to record dead key
204 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
206 XLAT_SECT_STR STRUC ;;
208 XS_NEXT_SECT_PTR DW ? ;; Pointer to next Specific Translate
210 XS_CP_ID DW ? ;; code page id
211 XS_FIRST_STATE DB ? ;;
213 XLAT_SECT_STR ENDS ;;
215 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
217 ;; The last State is a null State containing only the
218 ;; XS_STATE_LEN field with a value of 0.
219 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
223 XS_STATE_LEN DW ? ;; length of state section
224 XS_STATE_ID DB ? ;; State ID
225 XS_KBD_TYPE DW ? ;; Keyboard Type
226 XS_ERROR_CHAR DW ? ;; Buffer entry for error character
231 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
232 ;; Translate Table structures.
233 ;; There may be many translate tables in a State. The last
234 ;; table is a null table containing only the XLAT_TAB_SIZE field with
236 ;; The xlate table can be in one of two forms:
237 ;; Type 1 = Table contains buffer entries only.
238 ;; Scan code is used as an index into xlat table
239 ;; Type 2 = Table contains pairs of SCAN/BUFFER_ENTRY.
240 ;; Table must be searched for matching scan.
241 ;; Type 1 is the default. Type 2 tables should be identified by setting
242 ;; the TYPE_2_TAB bit in XLAT_OPTIONS.
243 ;; Buffer entries default to 2-bytes per entry.
244 ;; Optionally the table may contain ASCII codes only
245 ;; (1-byte entries). This is specified by setting the ASCII_ONLY bit
246 ;; in XLAT_OPTIONS. 2-byte buffer entries are coded ASCII,SCAN.
247 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
249 ;; Translate options:
250 ASCII_ONLY EQU 80H ;; Only ASCII codes listed - use
251 ;; incoming scan for buffer entry
252 TYPE_2_TAB EQU 40H ;; search xlat table for matching scan
253 ZERO_SCAN EQU 20H ;; set the scan half of the buffer
256 NULL_ASCII_CODE EQU -1 ;;
258 DEFAULT_TAB_2_ENT_SZ EQU 3 ;;
259 ASC_ONLY_TAB_2_ENT_SZ EQU 2 ;;
264 XLAT_TAB_SIZE DW ? ;; Size in bytes of this table -
265 ;; includes this field, options etc.
266 XLAT_OPTIONS DB ? ;; xlat options
267 ;; XLAT TABLE IS HERE
270 XLAT_TYPE_1_STR STRUC ;; use scan code as index into table
271 DB TYPE XLAT_STR DUP(?) ;; filler
272 XLAT_SCAN_LO DB ? ;; Scan code
273 XLAT_SCAN_HI DB ? ;; range
274 XLAT_1_BUF_ENTRY DB ? ;; The table itself
275 XLAT_TYPE_1_STR ENDS ;;
277 XLAT_TYPE_2_STR STRUC ;; search table for scan
278 DB TYPE XLAT_STR DUP(?) ;; filler
279 XLAT_NUM DB ? ;; number of scans
280 XLAT_SCAN DB ? ;; Scan code
281 XLAT_2_BUF_ENTRY DB ? ;; The table itself
282 XLAT_TYPE_2_STR ENDS ;;
284 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
286 ;; State Sections immediately following the LAST_ENTRYs.
287 ;; Dead key definitions. If the scan matches then
288 ;; set the bit in NLS_FLAGs indicated in DK_MASK
289 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
291 SF_ENT_SZ EQU 3 ;; size of entry
293 SET_FLAG_STR STRUC ;;
295 SF_NUM DB 0 ;; Number of entries
296 SF_SCAN_CODE DB 0 ;; scan code
297 SF_FLAG_ID DB 0 ;; flag id
298 SF_FLAG_MASK DB 0 ;; flag mask
303 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;