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 PALACE
52 PC_386 EQU 0200H ;; code for WRANGLER
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 TIMING_FACTOR DW 1 ;; Scale factor for INT 9 timing loops
71 DB 2 DUP(0) ;; reserved
73 ;; Table copy begins here:
74 ACTIVE_LANGUAGE DB 'US' ;; language code
75 INVOKED_CP_TABLE DW 437 ;; ptr to table for invoked code page
76 INVOKED_KBD_ID DW 0 ;; WGR invoked keyboard id. ;AN000
77 ACTIVE_XLAT_PTR DW -1 ;; ptr to active Specific Translate Sect
78 FIRST_XLAT_PTR DW -1 ;; ptr to first Specific Translate Sect
79 RESIDENT_END DW 0ffffh ;; offset of last byte in resident mem
80 LOGIC_PTR DW -1 ;; ptr to State Logic
81 COMMON_XLAT_PTR DW -1 ;; ptr to Common Translate Section
82 SPECIAL_FEATURES DW ? ;; special Features
83 TABLE_OVERFLOW DB 0 ;; overflow flag for table rebuild
84 HOT_KEY_ON_SCAN DB ? ;; scan codes to use with ALT+CTRL
85 HOT_KEY_OFF_SCAN DB ? ;; to turn hot key on and off
86 DB 4 DUP(0) ;; reserved
87 TABLE_AREA DB ? ;; tables loaded here:
89 ;; Common Translate Section
90 ;; Specific Translate Sections for
92 SHARED_DATA_STR ENDS ;;
96 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
97 ;; State Logic equates.
98 ;; Contains equates for our NLS Flags and for the State Logic
100 ;; State Logic command macros are defined in KEYBMAC.INC
101 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103 STATE_LOGIC_STR STRUC ;;
105 SL_LOGIC_LEN DW ? ;; length of state logic
106 SL_SPECIAL_FEATURES DW ? ;;
107 SL_LOGIC_CMDS DB 0 ;; state logic commands begin here
109 STATE_LOGIC_STR ENDS ;;
112 NUM_BIOS_FLAGS EQU 4 ;;
113 NUM_NLS_FLAGS EQU 2 ;; '+1' below is the EXT_KB_FLAG
114 NUM_FLAGS EQU NUM_BIOS_FLAGS+NUM_NLS_FLAGS+1
117 EITHER_SHIFT EQU 80H ;; EXT_KB_FLAG : our own shift state
118 EITHER_CTL EQU 40H ;; flags
119 EITHER_ALT EQU 20H ;;
120 SCAN_MATCH EQU 08H ;; set if scan code found in XLATT
121 ;; or SET_FLAG searches
124 KB_FLAG_ID EQU 0 ;; Flag ID's as coded in IFF and ANDF
125 KB_FLAG_1_ID EQU 1 ;; commands
126 KB_FLAG_2_ID EQU 2 ;;
127 KB_FLAG_3_ID EQU 3 ;;
128 EXT_KB_FLAG_ID EQU 4 ;;
129 NLS_FLAG_1_ID EQU 5 ;;
130 NLS_FLAG_2_ID EQU 6 ;;
132 COMMAND_BITS EQU 0F0H ;; Mask to isolate command code
133 SUB_CMD_BITS EQU 0FH ;; mask to isolate sub command code
134 NOT_TEST EQU 08H ;; NOT bit in IFF, ANDF
135 COMMAND_SHIFT EQU 4 ;; shift amount for command code
136 FLAG_ID_BITS EQU 07H ;; mask to isolate flag id in IFF, ANDF
137 NUM_COMMANDS EQU 0CH ;; number of commands
139 IFF_COMMAND EQU 00H ;;
140 ANDF_COMMAND EQU 10H ;;
141 ELSEF_COMMAND EQU 20H ;;
142 ENDIFF_COMMAND EQU 30H ;;
143 XLATT_COMMAND EQU 40H ;;
144 OPTION_COMMAND EQU 50H ;;
145 SET_FLAG_COMMAND EQU 60H ;;
146 PUT_ERROR_COMMAND EQU 70H ;;
147 IFKBD_COMMAND EQU 80H ;;
148 GOTO_COMMAND EQU 90H ;;
149 BEEP_COMMAND EQU 0A0H ;;
150 RESET_NLS_COMMAND EQU 0B0H ;;
151 CHECK_CORE_COMMAND EQU 0C0H ;;
154 EXIT_INT_9_FLAG EQU 01H ;; Special forms of GOTO. These
155 EXIT_STATE_LOGIC_FLAG EQU 02H ;; values are in the right nibble
156 ;; of the GOTO command.
158 ;; PROCESSING OPTIONS:
159 EXIT_IF_FOUND EQU 80H ;; exit INT 9 if a translation
163 JR_KB EQU 8000H ;; Keyboard types
170 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
171 ;; Translate Table Sections. Both the Specific and Common
172 ;; Translate Sections are formatted as follows.
174 ;; The Specific Translate Sections are chained together using the
175 ;; XS_NEXT_SECT_PTR field (-1 if last section).
176 ;; Translate Sections contains multiple States.
177 ;; A State contains the translate tables for a single
178 ;; shift state (IE lower case, upper case ....)
179 ;; Each State may contain multiple translate tables.
181 ;; The Translate Section layout is defined using several STRUCs.
182 ;; These STRUCs are allocated in the Shared Data Area as follows:
184 ;; XLAT_SECT_STR ; header info for the section
185 ;; STATE_STR ; header for state #1
186 ;; XLAT_STR ; first translate tab for state #1
187 ;; XLAT_TYPE_1_STR or XLAT_TYPE_2_STR
188 ;; XLAT_STR ; second translate tab
189 ;; XLAT_TYPE_1_STR or XLAT_TYPE_2_STR
191 ;; STATE_STR ; header for state #2
193 ;; XLAT_TYPE_1_STR or XLAT_TYPE_2_STR
197 ;; A State may contain a "Set_Flag" table instead of translate tables.
198 ;; These tables are used to set the NLS flags instead of generating
199 ;; ASCII codes (for example: to remember dead key states).
200 ;; There can be only on Set_Flag table per state.
201 ;; The Set_Flag table layout is defined in the SET_FLAG_STR STRUC.
203 ;; So some states will contain translate tables (to generate ASCII codes)
204 ;; and some states will contain a Set_Flag table (to record dead key
207 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
209 XLAT_SECT_STR STRUC ;;
211 XS_NEXT_SECT_PTR DW ? ;; Pointer to next Specific Translate
213 XS_CP_ID DW ? ;; code page id
214 XS_FIRST_STATE DB ? ;;
216 XLAT_SECT_STR ENDS ;;
218 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
220 ;; The last State is a null State containing only the
221 ;; XS_STATE_LEN field with a value of 0.
222 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
226 XS_STATE_LEN DW ? ;; length of state section
227 XS_STATE_ID DB ? ;; State ID
228 XS_KBD_TYPE DW ? ;; Keyboard Type
229 XS_ERROR_CHAR DW ? ;; Buffer entry for error character
234 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
235 ;; Translate Table structures.
236 ;; There may be many translate tables in a State. The last
237 ;; table is a null table containing only the XLAT_TAB_SIZE field with
239 ;; The xlate table can be in one of two forms:
240 ;; Type 1 = Table contains buffer entries only.
241 ;; Scan code is used as an index into xlat table
242 ;; Type 2 = Table contains pairs of SCAN/BUFFER_ENTRY.
243 ;; Table must be searched for matching scan.
244 ;; Type 1 is the default. Type 2 tables should be identified by setting
245 ;; the TYPE_2_TAB bit in XLAT_OPTIONS.
246 ;; Buffer entries default to 2-bytes per entry.
247 ;; Optionally the table may contain ASCII codes only
248 ;; (1-byte entries). This is specified by setting the ASCII_ONLY bit
249 ;; in XLAT_OPTIONS. 2-byte buffer entries are coded ASCII,SCAN.
250 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
252 ;; Translate options:
253 ASCII_ONLY EQU 80H ;; Only ASCII codes listed - use
254 ;; incoming scan for buffer entry
255 TYPE_2_TAB EQU 40H ;; search xlat table for matching scan
256 ZERO_SCAN EQU 20H ;; set the scan half of the buffer
259 NULL_ASCII_CODE EQU -1 ;;
261 DEFAULT_TAB_2_ENT_SZ EQU 3 ;;
262 ASC_ONLY_TAB_2_ENT_SZ EQU 2 ;;
267 XLAT_TAB_SIZE DW ? ;; Size in bytes of this table -
268 ;; includes this field, options etc.
269 XLAT_OPTIONS DB ? ;; xlat options
270 ;; XLAT TABLE IS HERE
273 XLAT_TYPE_1_STR STRUC ;; use scan code as index into table
274 DB TYPE XLAT_STR DUP(?) ;; filler
275 XLAT_SCAN_LO DB ? ;; Scan code
276 XLAT_SCAN_HI DB ? ;; range
277 XLAT_1_BUF_ENTRY DB ? ;; The table itself
278 XLAT_TYPE_1_STR ENDS ;;
280 XLAT_TYPE_2_STR STRUC ;; search table for scan
281 DB TYPE XLAT_STR DUP(?) ;; filler
282 XLAT_NUM DB ? ;; number of scans
283 XLAT_SCAN DB ? ;; Scan code
284 XLAT_2_BUF_ENTRY DB ? ;; The table itself
285 XLAT_TYPE_2_STR ENDS ;;
287 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
289 ;; State Sections immediately following the LAST_ENTRYs.
290 ;; Dead key definitions. If the scan matches then
291 ;; set the bit in NLS_FLAGs indicated in DK_MASK
292 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
294 SF_ENT_SZ EQU 3 ;; size of entry
296 SET_FLAG_STR STRUC ;;
298 SF_NUM DB 0 ;; Number of entries
299 SF_SCAN_CODE DB 0 ;; scan code
300 SF_FLAG_ID DB 0 ;; flag id
301 SF_FLAG_MASK DB 0 ;; flag mask
306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;