summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/KEYB/KEYBTBBL.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/KEYB/KEYBTBBL.ASM')
-rw-r--r--v4.0/src/CMD/KEYB/KEYBTBBL.ASM855
1 files changed, 855 insertions, 0 deletions
diff --git a/v4.0/src/CMD/KEYB/KEYBTBBL.ASM b/v4.0/src/CMD/KEYB/KEYBTBBL.ASM
new file mode 100644
index 0000000..b28f08c
--- /dev/null
+++ b/v4.0/src/CMD/KEYB/KEYBTBBL.ASM
@@ -0,0 +1,855 @@
1
2 PAGE ,132
3 TITLE DOS KEYB Command - Transient Command Processing
4
5;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6;; DOS - NLS Support - KEYB Command
7;; (C) Copyright 1988 Microsoft
8;;
9;; File Name: KEYBTBBL.ASM
10;; ----------
11;;
12;; Description:
13;; ------------
14;; Build SHARED_DATA_AREA with parameters specified
15;; in KEYBCMD.ASM
16;;
17;; Documentation Reference:
18;; ------------------------
19;; None
20;;
21;; Procedures Contained in This File:
22;; ----------------------------------
23;; TABLE_BUILD: Build the header sections of the SHARED_DATA_AREA
24;; STATE_BUILD: Build the state sections in the table area
25;; FIND_CP_TABLE: Given the language and code page parm, determine the
26;; offset of the code page table in KEYBOARD.SYS
27;;
28;; Include Files Required:
29;; -----------------------
30;; KEYBSHAR.INC
31;; KEYBSYS.INC
32;; KEYBDCL.INC
33;; KEYBI2F.INC
34;;
35;; External Procedure References:
36;; ------------------------------
37;; None
38;;
39;; Change History:
40;; ---------------
41;;
42;;
43;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
44 ;;
45 PUBLIC TABLE_BUILD ;;
46 PUBLIC FIND_CP_TABLE ;;
47 PUBLIC CPN_INVALID ;;
48 PUBLIC SD_LENGTH ;;
49 ;;
50CODE SEGMENT PUBLIC 'CODE' ;;
51 ;;
52 INCLUDE KEYBEQU.INC ;;
53 INCLUDE KEYBSHAR.INC ;;
54 INCLUDE KEYBSYS.INC ;;
55 INCLUDE KEYBCMD.INC ;;
56 INCLUDE KEYBDCL.INC ;;
57 INCLUDE COMMSUBS.INC ;;
58 INCLUDE KEYBCPSD.INC ;;
59 ;;
60 ASSUME CS:CODE,DS:CODE ;;
61 ;;
62;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
63;;
64;; Module: TABLE_BUILD
65;;
66;; Description:
67;; Create the table area within the shared data structure. Each
68;; table is made up of a descriptor plus the state sections.
69;; Translate tables are found in the Keyboard definition file and are
70;; copied into the shared data area by means of the STATE_BUILD
71;; routine.
72;;
73;; Input Registers:
74;; DS - points to our data segment
75;; ES - points to our data segment
76;; BP - points at beginning of CMD_PARM_LIST
77;;
78;; SHARED_DATA_STR must be allocated in memory
79;;
80;; The following variables must also be passed from KEYB_COMMAND
81;; KEYBSYS_FILE_HANDLE is set to file handle after opening file
82;; CP_TAB_OFFSET is the offset of the CP table in the SHARED_DATA_AREA
83;; STATE_LOGIC_OFFSET is the offset of the state section in the SHARED_DATA_AREA
84;; SYS_CODE_PAGE is the binary representation of the system CP
85;; KEYBCMD_LANG_ENTRY_PTR is a pointer to the lang entry in KEY DEF file
86;; DESIG_CP_BUFFER is the buffer which holds a list of designated CPs
87;; DESIG_CP_OFFSET:WORD is the offset of that list
88;; NUM_DESIG_CP is the number of CPs designated
89;; FILE_BUFFER is the buffer to read in the KEY DEF file
90;**********CNS ***************************************
91;; ID_PTR_SIZE is the size of the ID ptr structure
92;**********CNS ***************************************
93;; LANG_PTR_SIZE is the size of the lang ptr structure
94;; CP_PTR_SIZE is the size of the CP ptr structure
95;; NUM_CP is the number of CPs in the KEYB DEF file for that lang
96;; SHARED_AREA_PTR segment and offset of the SHARED_DATA_AREA
97;;
98;;
99;; Output Registers:
100;; CX - RETURN_CODE := 0 - Table build successful
101;; 1 - Table build unsuccessful - ERROR 1
102;; (Invalid language parm)
103;; 2 - Table build unsuccessful - ERROR 2
104;; (Invalid Code Page parm)
105;; 3 - Table build unsuccessful - ERROR 3
106;; (Machine type unavaliable)
107;; 4 - Table build unsuccessful - ERROR 4
108;; (Bad or missing keyboard def file)
109;; 5 - Table build unsuccessful - ERROR 5
110;; (Memory overflow occurred)
111;; Logic:
112;; Calculate Offset difference between TEMP and SHARED_DATA_AREAs
113;; Get LANGUAGE_PARM and CODE_PAGE_PARM from parm list
114;; Call FIND_CP_TABLE := Determine whether CP is valid for given language
115;; IF CP is valid THEN
116;; Store them in the SHARED_DATA_AREA
117;; Prepare to read Keyboard definition file by LSEEKing to the top
118;; READ the header
119;; Store maximum table values for calculation of RES_END
120;; Set DI to point at TABLE_AREA within SHARED_DATA_AREA
121;; FOR the state logic section of the specified language:
122;; IF STATE_LOGIC_PTR is not -1 THEN
123;; LSEEK to state logic section in keyboard definition file
124;; READ the state logic section into the TABLE_AREA
125;; Set the hot keyb scan codes
126;; Set the LOGIC_PTR in the header
127;; FOR the common translate section:
128;; IF Length parameter is not 0 THEN
129;; Build state
130;; Set the COMMON_XLAT_PTR in the header
131;; FOR the specific translate sections:
132;; Establish addressibility to list of designated code pages
133;; FOR each code page
134;; IF CP_ENTRY_PTR is not -1 THEN
135;; Determine offset of CP table in Keyb Def file
136;; IF CP table not avaliable THEN
137;; Set CPN_INVALID flag
138;; ELSE
139;; LSEEK to CPn state section in keyboard definition file
140;; IF this is the invoked code page THEN
141;; Set ACTIVE_XLAT_PTR in SHARED_DATA_AREA
142;; Update RESIDENT_END ptr
143;; Build state
144;; Update RESIDENT_END ptr
145;; End
146;;
147;;
148;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
149 ;;
150FB EQU FILE_BUFFER ;;
151KB_MASK EQU 02H ;;
152 ;;
153FIRST_XLAT_TAB DW 0 ;;
154NEXT_SECT_PTR DW -1 ;;
155 ;;
156MAX_COM_SIZE DW ? ;;
157MAX_SPEC_SIZE DW ? ;;
158MAX_LOGIC_SIZE DW ? ;;
159 ;;
160RESIDENT_END_ACC DW 0 ;;
161SA_HEADER_SIZE DW SIZE SHARED_DATA_STR;;
162PARM_LIST_OFFSET DW ? ;;
163;********************CNS*************************
164TB_ID_PARM DW 0
165;********************CNS*************************
166TB_LANGUAGE_PARM DW 0 ;;
167TB_CODE_PAGE_PARM DW 0 ;;
168 ;;
169CPN_INVALID DW 0 ;;
170 ;;
171KEYB_INSTALLED DW 0 ;;
172SD_AREA_DIFFERENCE DW 0 ;;
173SD_LENGTH DW 2000 ;;
174 ;;
175;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
176;; Program Code
177;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
178 ;;
179TABLE_BUILD PROC NEAR ;;
180 ;;
181 MOV AX,OFFSET SD_SOURCE_PTR ;; Setup the difference
182 SUB AX,OFFSET SD_DEST_PTR ;; value used to calculate
183 MOV SD_AREA_DIFFERENCE,AX ;; new ptr values for
184 ;; SHARED_DATA_AREA
185 MOV AX,[BP].ID_PARM ;; WGR Get id parameter ;AN000
186 MOV TB_ID_PARM,AX ;; WGR ;AN000
187 MOV AX,[BP].LANGUAGE_PARM ;; Get language parameter
188 MOV TB_LANGUAGE_PARM,AX ;;
189 MOV BX,[BP].CODE_PAGE_PARM ;; Get code page parameter
190 MOV TB_CODE_PAGE_PARM,BX ;;
191 ;; Make sure code page is
192 CALL FIND_CP_TABLE ;; valid for the language
193 CMP CX,0 ;; Test return codes
194 JE TB_CHECK_CONTINUE1 ;; IF code page is found
195 JMP TB_ERROR6 ;; for language THEN
196 ;;
197TB_CHECK_CONTINUE1: ;;;;;;;;
198 MOV BP,OFFSET SD_SOURCE_PTR ;; Put language parm and ;AN000
199 MOV AX,TB_ID_PARM ;; WGR id parm and.. ;AN000
200 MOV ES:[BP].INVOKED_KBD_ID,AX ;; WGR
201 MOV BX,TB_CODE_PAGE_PARM ;;
202 MOV ES:[BP].INVOKED_CP_TABLE,BX ;;;;;; code page parm into the
203 MOV AX,TB_LANGUAGE_PARM ;; SHARED_DATA_AREA
204 MOV WORD PTR ES:[BP].ACTIVE_LANGUAGE,AX ;;
205 ;;
206 MOV BX,KEYBSYS_FILE_HANDLE ;;;;;;;;;;;;;;; Get handle
207 XOR DX,DX ;; LSEEK file pointer
208 XOR CX,CX ;; back to top of file
209 MOV AH,42H ;;
210 MOV AL,0 ;; If no problem with
211 INT 21H ;; Keyboard Def file THEN
212 JNC TB_START ;;
213 JMP TB_ERROR4 ;;
214 ;;
215TB_START: ;; Else
216 XOR DI,DI ;; Set number
217 LEA CX,[DI].KH_MAX_LOGIC_SZ+2;; bytes to read header
218 MOV DX,OFFSET FILE_BUFFER ;; Move contents into file buffer
219 MOV AH,3FH ;; READ
220 PUSH CS ;;
221 POP DS ;;
222 INT 21H ;; File
223 JNC TB_CONTINUE1 ;;
224 JMP TB_ERROR4 ;;
225 ;;
226TB_CONTINUE1: ;;
227 CMP CX,AX ;;
228 JE TB_ERROR_CHECK1 ;;
229 MOV CX,4 ;;
230 JMP TB_CPN_INVALID ;;
231 ;;
232TB_ERROR_CHECK1: ;;
233 MOV CX,FB.KH_MAX_COM_SZ ;; Save values for RESIDENT_END
234 MOV MAX_COM_SIZE,CX ;; calculation
235 MOV CX,FB.KH_MAX_SPEC_SZ ;;
236 MOV MAX_SPEC_SIZE,CX ;;
237 MOV CX,FB.KH_MAX_LOGIC_SZ ;;
238 MOV MAX_LOGIC_SIZE,CX ;;
239 ;;
240 LEA DI,[BP].TABLE_AREA ;; Point at beginning of table area
241 ;; DI ---> TABLE_AREA
242;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
243;; ** FOR STATE LOGIC SECTION FOR LANG **
244;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
245 ;;
246TB_STATE_BEGIN: ;;
247 MOV BX,KEYBSYS_FILE_HANDLE ;; Get handle
248 MOV CX,WORD PTR STATE_LOGIC_OFFSET+2 ;;
249 MOV DX,WORD PTR STATE_LOGIC_OFFSET ;; Get LSEEK file pointer
250 ;;
251 CMP DX,-1 ;;;;;;;;;; If no language table then
252 JNE TB_STATE_CONTINUE1 ;; jump to code page begin
253 JMP TB_CP_BEGIN ;;
254 ;;
255TB_STATE_CONTINUE1: ;; Else
256 MOV AH,42H ;; LSEEK to beginning of state logic sect
257 MOV AL,0 ;; If no problem with
258 INT 21H ;; Keyboard Def file THEN
259 JNC TB_STATE_CONTINUE2 ;;
260 JMP TB_ERROR4 ;;
261 ;;;;;;;;;;
262TB_STATE_CONTINUE2: ;;
263 MOV DX,AX ;;
264 MOV WORD PTR SB_STATE_OFFSET+2,CX ;; Save the offset of the
265 MOV WORD PTR SB_STATE_OFFSET,DX ;; states in Keyb Def file
266 ;;
267 SUB DI,SD_AREA_DIFFERENCE ;; Adjust for relocation
268 MOV ES:[BP].LOGIC_PTR,DI ;;;;;;;;;; Set because this is state
269 ADD DI,SD_AREA_DIFFERENCE ;; Adjust for relocation
270 ;;
271 MOV CX,4 ;; Set number bytes to read length and
272 ;; special features
273 MOV DX,OFFSET FILE_BUFFER ;; Set the buffer address
274 MOV AH,3FH ;; Read from the Keyb Def file
275 INT 21H ;;
276 JNC TB_STATE_CONTINUE3 ;;
277 JMP TB_ERROR4 ;;
278 ;;
279TB_STATE_CONTINUE3: ;;
280 CMP CX,AX ;;
281 JE TB_ERROR_CHECK2 ;;
282 MOV CX,4 ;;
283 JMP TB_CPN_INVALID ;;
284 ;;;;;
285TB_ERROR_CHECK2: ;;
286 MOV AX,FB.KT_SPECIAL_FEATURES ;; Save the special features in the
287 MOV ES:[BP].SPECIAL_FEATURES,AX ;; SHARED_DATA_AREA
288 ;;
289 CMP HW_TYPE,JR_KB ;;;;;;;;
290 JNE USE_F1_F2 ;;
291 TEST AX,JR_HOT_KEY_1_2 ;;
292 JZ USE_F1_F2 ;;
293 MOV ES:[BP].HOT_KEY_ON_SCAN,ONE_SCAN ;;
294 MOV ES:[BP].HOT_KEY_OFF_SCAN,TWO_SCAN ;;
295 JMP HOT_KEY_SET ;;
296 ;;
297USE_F1_F2: ;;
298 MOV ES:[BP].HOT_KEY_ON_SCAN,F1_SCAN ;;
299 MOV ES:[BP].HOT_KEY_OFF_SCAN,F2_SCAN ;;
300 ;;
301HOT_KEY_SET: ;;;;;;;;
302 MOV CX,FB.KT_LOGIC_LEN ;; Set length of section to read
303 CMP CX,0 ;;
304 JNE TB_STATE_CONTINUE4 ;;
305 MOV CX,-1 ;;;;;
306 MOV ES:[BP].LOGIC_PTR,CX ;;
307 JMP SB_COMM_BEGIN ;;
308 ;;
309TB_STATE_CONTINUE4: ;;
310 MOV ES:[DI],CX ;; Store length parameter in
311 ADD DI,2 ;; SHARED_DATA_AREA
312 MOV CX,FB.KT_SPECIAL_FEATURES;; Save the special features
313 MOV ES:[DI],CX ;;
314 ADD DI,2 ;;
315 MOV CX,FB.KT_LOGIC_LEN ;; Set length of section to read
316 SUB CX,4 ;; Adjust for what we have already read
317 MOV DX,DI ;; Set the address of SHARED_DATA_AREA
318 PUSH ES ;;
319 POP DS ;;
320 MOV AH,3FH ;; Read logic section from the
321 INT 21H ;; Keyb Def file
322 PUSH CS ;;
323 POP DS ;;
324 JNC TB_STATE_CONTINUE5 ;;
325 JMP TB_ERROR4 ;;
326 ;;
327TB_STATE_CONTINUE5: ;;
328 CMP CX,AX ;;
329 JE TB_ERROR_CHECK3 ;;
330 MOV CX,4 ;;
331 JMP TB_CPN_INVALID ;;
332 ;;
333TB_ERROR_CHECK3: ;;
334 ADD DI,CX ;; Set DI at new beginning of area
335 ;; TABLE_AREA
336 ;; STATE_LOGIC
337 MOV CX,RESIDENT_END_ACC ;; DI --->
338 ADD CX,SA_HEADER_SIZE ;;
339 ADD CX,MAX_LOGIC_SIZE ;;
340 MOV RESIDENT_END_ACC,CX ;; Refresh resident end size
341 ;;
342;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
343;; ** FOR COMMON TRANSLATE SECTION FOR LANG **
344;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
345 ;;
346SB_COMM_BEGIN: ;;
347 MOV CX,SIZE KEYBSYS_XLAT_SECT-1 ;; Set number bytes to read header
348 MOV DX,DI ;; Set the SHARED_DATA_AREA address
349 PUSH ES ;;
350 POP DS ;;
351 MOV AH,3FH ;; Read from the Keyb Def file
352 INT 21H ;;
353 PUSH CS ;;
354 POP DS ;;
355 JNC TB_STATE_CONTINUE6 ;;
356 JMP TB_ERROR4 ;;
357 ;;
358TB_STATE_CONTINUE6: ;;
359 MOV CX,ES:[DI].KX_SECTION_LEN;; Set length of section to read
360 CMP CX,0 ;;
361 JNE TB_STATE_CONTINUE7 ;;
362 JMP TB_CP_BEGIN ;;
363 ;;;;;;;
364TB_STATE_CONTINUE7: ;;
365 MOV CX,WORD PTR SB_STATE_OFFSET ;; Save the offset of the
366 ADD CX,FB.KT_LOGIC_LEN ;;
367 MOV WORD PTR SB_STATE_OFFSET,CX ;; Save the offset of the
368 SUB DI,SD_AREA_DIFFERENCE ;; Adjust for relocation
369 MOV ES:[BP].COMMON_XLAT_PTR,DI ;;
370 ADD DI,SD_AREA_DIFFERENCE ;; Adjust for relocation
371 ;;;;;;;
372 CALL STATE_BUILD ;;
373 ;; DI set at new beginning of area
374 ;; TABLE_AREA
375 ;; STATE_LOGIC
376 ;; COMMON_XLAT_SECTION
377 MOV CX,RESIDENT_END_ACC ;;
378 ADD CX,MAX_COM_SIZE ;;
379 MOV RESIDENT_END_ACC,CX ;; Refresh resident end size
380 ;;
381;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
382;; FOR ALL DESIGNATED OR INVOKED CODE PAGES
383;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
384 ;;
385TB_CP_BEGIN: ;; Get the offset to
386 MOV CX,OFFSET DESIG_CP_BUFFER.DESIG_CP_ENTRY ;; the beginning of the
387 MOV DESIG_CP_OFFSET,CX ;; table of designated
388 ;;;;;; code pages
389TB_CPN_BEGIN: ;;
390 MOV AX,WORD PTR ES:[BP].ACTIVE_LANGUAGE ;; Get the active language
391 MOV CX,NUM_DESIG_CP ;;;;;;;;;;;;;; Get the number of CPs
392 CMP CX,0 ;; IF we have done all requested CPs
393 JNE TB_CPN_VALID1 ;;
394 JMP TB_DONE ;; Then done
395 ;;
396TB_CPN_VALID1: ;;
397 MOV SI,[DESIG_CP_OFFSET] ;;
398 MOV BX,[SI] ;; Get the CP
399 CMP BX,-1 ;;
400 JNE TB_CPN_CONTINUE1 ;;
401 JMP TB_CPN_REPEAT ;;
402 ;;
403TB_CPN_CONTINUE1: ;; ELSE
404 PUSH DI ;;
405 CALL FIND_CP_TABLE ;; Find offset of code page table
406 POP DI ;;
407 ;;
408 CMP CX,0 ;; Test return codes
409 JE TB_CPN_VALID ;; IF code page is not found for language
410 MOV CPN_INVALID,CX ;; Set flag and go to next CP
411 JMP TB_CPN_REPEAT ;; Else
412 ;;
413TB_CPN_VALID: ;;;;;;
414 MOV BX,KEYBSYS_FILE_HANDLE ;; Get handle
415 MOV CX,WORD PTR CP_TAB_OFFSET+2 ;; Get offset of the code page
416 MOV DX,WORD PTR CP_TAB_OFFSET ;; in the Keyb Def file
417 ;;
418 CMP DX,-1 ;;;;;; Test if code page is blank
419 JNE TB_CPN_CONTINUE2 ;;
420 JMP TB_CPN_REPEAT ;; If it is then go get next CP
421 ;;
422TB_CPN_CONTINUE2: ;;
423 MOV AH,42H ;; LSEEK to table in Keyb Def file
424 MOV AL,0 ;; If no problem with
425 INT 21H ;; Keyb Def file Then
426 JNC TB_CPN_CONTINUE3 ;;
427 JMP TB_ERROR4 ;;
428 ;;;;;;;;;;
429TB_CPN_CONTINUE3: ;;
430 MOV DX,AX ;;
431 MOV WORD PTR SB_STATE_OFFSET+2,CX ;; Save the offset of the
432 MOV WORD PTR SB_STATE_OFFSET,DX ;; states in Keyb Def file
433 ;;
434 MOV CX,TB_CODE_PAGE_PARM ;;;;; If this code page is the
435 MOV SI,[DESIG_CP_OFFSET] ;; invoked code page
436 CMP CX,[SI] ;;
437 JNE TB_CPN_CONTINUE4 ;; Then
438 ;;
439 SUB DI,SD_AREA_DIFFERENCE ;; Adjust for relocation
440 MOV ES:[BP].ACTIVE_XLAT_PTR,DI ;; Set active xlat section
441 ADD DI,SD_AREA_DIFFERENCE ;; Adjust for relocation
442 ;;;;;;;
443TB_CPN_CONTINUE4: ;;
444 SUB DI,SD_AREA_DIFFERENCE ;; Adjust for relocation
445 MOV ES:[BP].FIRST_XLAT_PTR,DI;; Set flag
446 ADD DI,SD_AREA_DIFFERENCE ;; Adjust for relocation
447 ;;
448TB_CPN_CONTINUE5: ;;
449 CALL STATE_BUILD ;; Build state
450 ;; TABLE_AREA
451 CMP CX,0 ;; COMMON_XLAT_SECTION
452 JE TB_CPN_REPEAT ;; SPECIFIC_XLAT_SECTION(S)
453 JMP TB_ERROR4 ;; DI --->
454 ;;
455TB_CPN_REPEAT: ;;
456 MOV CX,RESIDENT_END_ACC ;;
457 ADD CX,MAX_SPEC_SIZE ;; Refresh resident end size
458 MOV RESIDENT_END_ACC,CX ;;
459 ;;
460 MOV CX,DESIG_CP_OFFSET ;;
461 ADD CX,2 ;; Adjust offset to find next code page
462 MOV DESIG_CP_OFFSET,CX ;;
463 ;;
464 MOV CX,NUM_DESIG_CP ;; Adjust the number of code pages left
465 DEC CX ;;
466 MOV NUM_DESIG_CP,CX ;;
467 ;;
468 JMP TB_CPN_BEGIN ;;
469;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
470;;
471;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
472 ;;
473TB_DONE: ;;
474 MOV CX,RESIDENT_END_ACC ;; Set final calculated value
475 ADD CX,BP ;;;;;;;;;;;
476 SUB CX,SD_AREA_DIFFERENCE ;; Adjust for relocation
477 MOV ES,WORD PTR SHARED_AREA_PTR ;; Set segment
478 MOV BP,WORD PTR SHARED_AREA_PTR+2 ;;
479 CMP CX,ES:[BP].RESIDENT_END ;;
480 JNA TB_DONE_CONTINUE1 ;;;;;;;;;;;
481 JMP TB_ERROR5 ;;
482 ;;
483TB_DONE_CONTINUE1: ;;
484 CMP ES:[BP].RESIDENT_END,-1 ;;
485 JNE DONT_REPLACE ;;
486 PUSH CS ;;
487 POP ES ;;
488 MOV BP,OFFSET SD_SOURCE_PTR ;;
489 MOV ES:[BP].RESIDENT_END,CX ;; Save resident end
490 JMP CONTINUE_2_END ;;
491 ;;
492DONT_REPLACE: ;;
493 PUSH CS ;;
494 POP ES ;;
495 MOV BP,OFFSET SD_SOURCE_PTR ;;
496 ;;
497CONTINUE_2_END: ;;
498 SUB CX,OFFSET SD_DEST_PTR ;; Calculate # of bytes to copy
499 MOV SD_LENGTH,CX ;;
500 ;;
501 XOR CX,CX ;; Set valid completion return code
502 MOV TB_RETURN_CODE,CX ;;
503 RET ;;
504 ;;
505TB_CPN_INVALID: ;;
506 CMP CX,1 ;; Set error 1 return code
507 JNE TB_ERROR2 ;;
508 MOV TB_RETURN_CODE,CX ;;
509 RET ;;
510 ;;
511TB_ERROR2: ;;
512 CMP CX,2 ;; Set error 2 return code
513 JNE TB_ERROR3 ;;
514 MOV TB_RETURN_CODE,CX ;;
515 RET ;;
516 ;;
517TB_ERROR3: ;;
518 CMP CX,3 ;; Set error 3 return code
519 JNE TB_ERROR4 ;;
520 MOV TB_RETURN_CODE,CX ;;
521 RET ;;
522 ;;
523TB_ERROR4: ;;
524 CMP CX,4 ;; Set error 4 return code
525 JNE TB_ERROR5 ;;
526 MOV TB_RETURN_CODE,CX ;;
527 RET ;;
528 ;;
529TB_ERROR5: ;;
530 MOV CX,5 ;; Set error 5 return code
531 MOV TB_RETURN_CODE,CX ;;
532 RET ;;
533 ;;
534TB_ERROR6: ;;
535 MOV BX,TB_CODE_PAGE_PARM ;;
536 MOV CX,6 ;;
537 MOV TB_RETURN_CODE,CX ;; Set error 6 return code
538 RET ;;
539 ;;
540TABLE_BUILD ENDP ;;
541 ;;
542;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
543;;
544;; Module: STATE_BUILD
545;;
546;; Description:
547;; Create the state/xlat section within the specific translate section.
548;;
549;; Input Registers:
550;; DS - points to our data segment
551;; ES - points to our data segment
552;; SB_STATE_OFFSET - offset to the beginning of the info in Keyb Def SYS
553;; DI - offset of the beginning of the area used to build states
554;;
555;; KEYBSYS_FILE_HANDLE - handle of the KEYBOARD.SYS file
556;;
557;; Output Registers:
558;; DI - offset of the end of the area used by STATE_BUILD
559;;
560;; CX - Return Code := 0 - State build successful
561;; 4 - State build unsuccessful
562;; (Bad or missing Keyboard Def file)
563;;
564;; Logic:
565;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
566 ;;
567END_OF_AREA_PTR DW 0 ;;
568SB_FIRST_STATE DW 0 ;;
569SB_STATE_LENGTH DW 0 ;;
570SB_STATE_OFFSET DD 0 ;;
571STATE_LENGTH DW 0 ;;
572RESTORE_BP DW ? ;;
573 ;;
574;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
575;; Program Code
576;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
577 ;;
578STATE_BUILD PROC NEAR ;;
579 ;;
580 MOV SI,DI ;; Get the tally pointer
581 MOV END_OF_AREA_PTR,DI ;; Save pointer
582 ;;
583 MOV RESTORE_BP,BP ;; Save the base pointer
584 ;;;;;;;;;
585 MOV BX,KEYBSYS_FILE_HANDLE ;; Get handle
586 MOV DX,WORD PTR SB_STATE_OFFSET ;; LSEEK file pointer
587 MOV CX,WORD PTR SB_STATE_OFFSET+2 ;; back to top of XLAT table
588 MOV AH,42H ;;
589 MOV AL,0 ;;;;;;;;; If no problem with
590 INT 21H ;; Keyboard Def file THEN
591 JNC SB_FIRST_HEADER ;;
592 JMP SB_ERROR4 ;;
593 ;;
594SB_FIRST_HEADER: ;;
595 XOR BP,BP ;;
596 LEA CX,[BP].KX_FIRST_STATE ;; Set number of bytes to read header
597 MOV DX,DI ;;
598 PUSH ES ;;
599 POP DS ;;
600 MOV AH,3FH ;; read in the header
601 INT 21H ;;
602 PUSH CS ;;
603 POP DS ;;
604 JNC SB_HEAD_CONTINUE1 ;;
605 JMP SB_ERROR4 ;;
606 ;;
607SB_HEAD_CONTINUE1: ;;
608 MOV DX,NEXT_SECT_PTR ;;
609 CMP DX,-1 ;;
610 JE SB_HEAD_CONTINUE2 ;;
611 SUB DX,SD_AREA_DIFFERENCE ;; Adjust for relocation
612 ;;;;;
613SB_HEAD_CONTINUE2: ;;
614 MOV ES:[DI].XS_NEXT_SECT_PTR,DX ;;
615 CMP DX,-1 ;;
616 JE SB_HEAD_CONTINUE3 ;;;;;
617 ADD DX,SD_AREA_DIFFERENCE ;; Adjust for relocation
618 ;;
619SB_HEAD_CONTINUE3: ;;
620 ADD DI,CX ;; Update the DI pointer
621 ;;
622SB_NEXT_STATE: ;;
623 XOR BP,BP ;; Set number
624 LEA CX,[BP].KX_STATE_ID ;; bytes to read state length
625 MOV DX,DI ;; Read the header into the
626 MOV BX,KEYBSYS_FILE_HANDLE ;; SHARED_DATA_AREA
627 PUSH ES ;;
628 POP DS ;;
629 MOV AH,3FH ;;
630 INT 21H ;;
631 ;;
632SB_CONTINUE1: ;;
633 PUSH CS ;; Reset the data segment
634 POP DS ;;
635 MOV CX,ES:[DI].KX_STATE_LEN ;; If the length of the state section
636 MOV STATE_LENGTH,CX ;;
637 ADD DI,2 ;; is zero then done
638 CMP CX,0 ;;
639 JE SB_DONE ;;
640 XOR BP,BP ;; Set number
641 LEA CX,[BP].KX_FIRST_XLAT-2 ;; bytes to read state length
642 MOV DX,DI ;; Read the header into the
643 MOV BX,KEYBSYS_FILE_HANDLE ;; SHARED_DATA_AREA
644 PUSH ES ;;
645 POP DS ;;
646 MOV AH,3FH ;;
647 INT 21H ;;
648 ;;
649SB_CONTINUE1A: ;;
650 PUSH CS ;; Reset the data segment
651 POP DS ;;
652 SUB DI,2 ;;
653 MOV AX,ES:[DI].XS_KBD_TYPE ;; Get the keyboard type def
654 TEST AX,HW_TYPE ;; Does it match our hardware?
655 JNZ SB_CONTINUE2 ;;
656 MOV DX,ES:[DI].XS_STATE_LEN ;; No, then
657 LEA CX,[BP].KX_FIRST_XLAT ;;
658 SUB DX,CX ;;
659 XOR CX,CX ;;
660 MOV AH,42H ;; LSEEK past this state
661 MOV AL,01H ;;
662 INT 21H ;;
663 JMP SB_NEXT_STATE ;;
664 ;;
665SB_CONTINUE2: ;; Yes, then
666 MOV AX,SIZE STATE_STR-1 ;;
667 ADD DI,AX ;; Set PTR and end of header
668 ;;
669SB_XLAT_TAB_BEGIN: ;; Begin getting xlat tables
670 MOV BX,KEYBSYS_FILE_HANDLE ;;
671 LEA DX,[BP].KX_FIRST_XLAT ;; Adjust for what we have already read
672 MOV CX,STATE_LENGTH ;;
673 SUB CX,DX ;;
674 MOV DX,DI ;;
675 PUSH ES ;;
676 POP DS ;;
677 MOV AH,3FH ;; Read in the xlat tables
678 INT 21H ;;
679 PUSH CS ;;
680 POP DS ;;
681 JNC SB_CONTINUE4 ;;
682 JMP SB_ERROR4 ;;
683 ;;
684SB_CONTINUE4: ;;
685 CMP CX,AX ;;
686 JE SB_ERROR_CHECK1 ;;
687 JMP SB_ERROR4 ;;
688 ;;
689SB_ERROR_CHECK1: ;;
690 ADD DI,CX ;; Update the end of area ptr
691 ;;
692 MOV SI,DI ;;
693 JMP SB_NEXT_STATE ;;
694 ;;
695SB_DONE: ;;
696 MOV AX,-1 ;;
697 MOV SI,END_OF_AREA_PTR ;;
698 MOV NEXT_SECT_PTR,SI ;;
699 ;;
700 MOV BP,RESTORE_BP ;;
701 RET ;;
702 ;;
703SB_ERROR1: ;;
704 MOV CX,1 ;;
705 RET ;;
706 ;;
707SB_ERROR2: ;;
708 MOV CX,2 ;;
709 RET ;;
710 ;;
711SB_ERROR3: ;;
712 MOV CX,3 ;;
713 RET ;;
714 ;;
715SB_ERROR4: ;;
716 MOV CX,4 ;;
717 RET ;;
718 ;;
719 ;;
720STATE_BUILD ENDP ;;
721 ;;
722;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
723;;
724;; Module: FIND_CP_TABLE
725;;
726;; Description:
727;; Determine the offset of the specified code page table in KEYBOARD.SYS
728;;
729;; Input Registers:
730;; DS - points to our data segment
731;; ES - points to our data segment
732;; AX - ASCII representation of the language parm
733;; BX - binary representation of the code page
734;;
735;; KEYBSYS_FILE_HANDLE - handle of the KEYBOARD.SYS file
736;;
737;; Output Registers:
738;; CP_TAB_OFFSET - offset of the CP table in KEYBOARD.SYS
739;;
740;; CX - Return Code := 0 - State build successful
741;; 2 - Invalid Code page for language
742;; 4 - Bad or missing Keyboard Def file
743;; Logic:
744;;
745;; READ language table
746;; IF error in reading file THEN
747;; Display ERROR message and EXIT
748;; ELSE
749;; Use table to verify language parm
750;; Set pointer values
751;; IF code page was specified
752;; READ language entry
753;; IF error in reading file THEN
754;; Display ERROR message and EXIT
755;; ELSE
756;; READ Code page table
757;; IF error in reading file THEN
758;; Display ERROR message and EXIT
759;; ELSE
760;; Use table to get the offset of the code page parm
761;; RET
762;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
763 ;;
764FIND_CP_PARM DW ? ;;
765 ;;
766;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
767;; Program Code
768;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
769 ;;
770FIND_CP_TABLE PROC NEAR ;;
771 ;;
772 ;;
773 MOV FIND_CP_PARM,BX ;; Save Code page
774 ;;;;;;;;;;;;;;
775 MOV BX,KEYBSYS_FILE_HANDLE ;; Get handle
776 MOV DX,WORD PTR KEYBCMD_LANG_ENTRY_PTR ;; LSEEK file pointer
777 MOV CX,WORD PTR KEYBCMD_LANG_ENTRY_PTR+2 ;; to top of language entry
778 MOV AH,42H ;;
779 MOV AL,0 ;;;;;;;;;;;;;; If no problem with
780 INT 21H ;; Keyb Def file Then
781 JNC FIND_BEGIN ;;
782 JMP FIND_CP_ERROR4 ;;
783 ;;;;;;;;;
784FIND_BEGIN: ;;
785 MOV DI,AX ;;
786 MOV CX,SIZE KEYBSYS_LANG_ENTRY-1 ;; Set number
787 ;; bytes to read header
788 MOV DX,OFFSET FILE_BUFFER ;;;;;;;;;
789 MOV AH,3FH ;; Read language entry in
790 INT 21H ;; KEYBOARD.SYS file
791 JNC FIND_VALID4 ;; If no error in opening file then
792 JMP FIND_CP_ERROR4 ;;
793 ;;
794FIND_VALID4: ;;
795;****************************** CNS *******************************************
796 xor ah,ah
797 mov al,FB.KL_NUM_CP
798;****************************** CNS *******************************************
799 MOV NUM_CP,AX ;; Save the number of code pages
800 MUL CP_PTR_SIZE ;; Determine # of bytes to read
801 MOV DX,OFFSET FILE_BUFFER ;; Establish beginning of buffer
802 MOV CX,AX ;;
803 CMP CX,FILE_BUFFER_SIZE ;; Make sure buffer is not to small
804 JBE FIND_VALID5 ;;
805 JMP FIND_CP_ERROR4 ;;
806 ;;
807FIND_VALID5: ;;
808 MOV AH,3FH ;; Read code page table from
809 INT 21H ;; KEYBOARD.SYS file
810 JNC FIND_VALID6 ;; If no error in opening file then
811 JMP FIND_CP_ERROR4 ;;
812 ;;
813FIND_VALID6: ;;
814 MOV CX,NUM_CP ;; Number of valid codes
815 MOV DI,OFFSET FILE_BUFFER ;; Point to correct word in table
816 ;;
817F_SCAN_CP_TABLE: ;; FOR code page parm
818 MOV AX,FIND_CP_PARM ;; Get parameter
819 CMP [DI].KC_CODE_PAGE,AX ;; Valid Code ??
820 JE F_CODE_PAGE_FOUND ;; If not found AND more entries THEN
821 ADD DI,LANG_PTR_SIZE ;; Check next entry
822 DEC CX ;; Decrement count of entries
823 JNE F_SCAN_CP_TABLE ;; Else
824 JMP FIND_CP_ERROR2 ;; Display error message
825 ;;;;;;;;;;
826F_CODE_PAGE_FOUND: ;;
827 MOV AX,WORD PTR [DI].KC_ENTRY_PTR ;;
828 MOV WORD PTR CP_TAB_OFFSET,AX ;;
829 MOV AX,WORD PTR [DI].KC_ENTRY_PTR+2 ;;
830 MOV WORD PTR CP_TAB_OFFSET+2,AX ;;
831 ;;
832 XOR CX,CX ;;;;;;;;;;
833 RET ;;
834 ;;
835FIND_CP_ERROR1: ;;
836 MOV CX,1 ;;
837 RET ;;
838 ;;
839FIND_CP_ERROR2: ;;
840 MOV CX,2 ;;
841 RET ;;
842 ;;
843FIND_CP_ERROR3: ;;
844 MOV CX,3 ;;
845 RET ;;
846 ;;
847FIND_CP_ERROR4: ;;
848 MOV CX,4 ;;
849 RET ;;
850 ;;
851FIND_CP_TABLE ENDP ;;
852;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
853CODE ENDS
854 END TABLE_BUILD
855 \ No newline at end of file