3 TITLE DOS KEYB Command
- Transient Command Processing
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6 ;; DOS - NLS Support - KEYB Command
7 ;; (C) Copyright 1988 Microsoft
9 ;; File Name: KEYBTBBL.ASM
14 ;; Build SHARED_DATA_AREA with parameters specified
17 ;; Documentation Reference:
18 ;; ------------------------
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
28 ;; Include Files Required:
29 ;; -----------------------
35 ;; External Procedure References:
36 ;; ------------------------------
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46 PUBLIC FIND_CP_TABLE
;;
50 CODE SEGMENT PUBLIC 'CODE' ;;
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 ;;
60 ASSUME
CS:CODE,DS:CODE ;;
62 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
64 ;; Module: TABLE_BUILD
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
74 ;; DS - points to our data segment
75 ;; ES - points to our data segment
76 ;; BP - points at beginning of CMD_PARM_LIST
78 ;; SHARED_DATA_STR must be allocated in memory
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
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)
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
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
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
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
144 ;; Update RESIDENT_END ptr
148 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
150 FB EQU FILE_BUFFER
;;
153 FIRST_XLAT_TAB
DW 0 ;;
154 NEXT_SECT_PTR
DW -1 ;;
157 MAX_SPEC_SIZE
DW ?
;;
158 MAX_LOGIC_SIZE
DW ?
;;
160 RESIDENT_END_ACC
DW 0 ;;
161 SA_HEADER_SIZE
DW SIZE SHARED_DATA_STR
;;
162 PARM_LIST_OFFSET
DW ?
;;
163 ;********************CNS*************************
165 ;********************CNS*************************
166 TB_LANGUAGE_PARM
DW 0 ;;
167 TB_CODE_PAGE_PARM
DW 0 ;;
171 KEYB_INSTALLED
DW 0 ;;
172 SD_AREA_DIFFERENCE
DW 0 ;;
175 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
177 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
179 TABLE_BUILD PROC
NEAR ;;
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
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
197 TB_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 ;;
206 MOV BX,KEYBSYS_FILE_HANDLE
;;;;;;;;;;;;;;; Get handle
207 XOR DX,DX ;; LSEEK file pointer
208 XOR CX,CX ;; back to top of file
210 MOV AL,0 ;; If no problem with
211 INT 21H
;; Keyboard Def file THEN
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
228 JE TB_ERROR_CHECK1
;;
230 JMP TB_CPN_INVALID
;;
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 ;;
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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
251 CMP DX,-1 ;;;;;;;;;; If no language table then
252 JNE TB_STATE_CONTINUE1
;; jump to code page begin
255 TB_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
;;
262 TB_STATE_CONTINUE2: ;;
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
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
271 MOV CX,4 ;; Set number bytes to read length and
273 MOV DX,OFFSET FILE_BUFFER
;; Set the buffer address
274 MOV AH,3FH
;; Read from the Keyb Def file
276 JNC TB_STATE_CONTINUE3
;;
279 TB_STATE_CONTINUE3: ;;
281 JE TB_ERROR_CHECK2
;;
283 JMP TB_CPN_INVALID
;;
286 MOV AX,FB
.KT_SPECIAL_FEATURES
;; Save the special features in the
287 MOV ES:[BP].SPECIAL_FEATURES
,AX ;; SHARED_DATA_AREA
289 CMP HW_TYPE
,JR_KB
;;;;;;;;
291 TEST AX,JR_HOT_KEY_1_2
;;
293 MOV ES:[BP].HOT_KEY_ON_SCAN
,ONE_SCAN
;;
294 MOV ES:[BP].HOT_KEY_OFF_SCAN
,TWO_SCAN
;;
298 MOV ES:[BP].HOT_KEY_ON_SCAN
,F1_SCAN
;;
299 MOV ES:[BP].HOT_KEY_OFF_SCAN
,F2_SCAN
;;
301 HOT_KEY_SET: ;;;;;;;;
302 MOV CX,FB
.KT_LOGIC_LEN
;; Set length of section to read
304 JNE TB_STATE_CONTINUE4
;;
306 MOV ES:[BP].LOGIC_PTR
,CX ;;
309 TB_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
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
320 MOV AH,3FH
;; Read logic section from the
321 INT 21H
;; Keyb Def file
324 JNC TB_STATE_CONTINUE5
;;
327 TB_STATE_CONTINUE5: ;;
329 JE TB_ERROR_CHECK3
;;
331 JMP TB_CPN_INVALID
;;
334 ADD DI,CX ;; Set DI at new beginning of area
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
342 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
343 ;; ** FOR COMMON TRANSLATE SECTION FOR LANG **
344 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
347 MOV CX,SIZE KEYBSYS_XLAT_SECT
-1 ;; Set number bytes to read header
348 MOV DX,DI ;; Set the SHARED_DATA_AREA address
351 MOV AH,3FH
;; Read from the Keyb Def file
355 JNC TB_STATE_CONTINUE6
;;
358 TB_STATE_CONTINUE6: ;;
359 MOV CX,ES:[DI].KX_SECTION_LEN
;; Set length of section to read
361 JNE TB_STATE_CONTINUE7
;;
364 TB_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
373 ;; DI set at new beginning of area
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
381 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
382 ;; FOR ALL DESIGNATED OR INVOKED CODE PAGES
383 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
385 TB_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
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
394 JMP TB_DONE
;; Then done
397 MOV SI,[DESIG_CP_OFFSET
] ;;
398 MOV BX,[SI] ;; Get the CP
400 JNE TB_CPN_CONTINUE1
;;
403 TB_CPN_CONTINUE1: ;; ELSE
405 CALL FIND_CP_TABLE
;; Find offset of code page table
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
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
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
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
;;
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
434 MOV CX,TB_CODE_PAGE_PARM
;;;;; If this code page is the
435 MOV SI,[DESIG_CP_OFFSET
] ;; invoked code page
437 JNE TB_CPN_CONTINUE4
;; Then
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
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
449 CALL STATE_BUILD
;; Build state
451 CMP CX,0 ;; COMMON_XLAT_SECTION
452 JE TB_CPN_REPEAT
;; SPECIFIC_XLAT_SECTION(S)
453 JMP TB_ERROR4
;; DI --->
456 MOV CX,RESIDENT_END_ACC
;;
457 ADD CX,MAX_SPEC_SIZE
;; Refresh resident end size
458 MOV RESIDENT_END_ACC
,CX ;;
460 MOV CX,DESIG_CP_OFFSET
;;
461 ADD CX,2 ;; Adjust offset to find next code page
462 MOV DESIG_CP_OFFSET
,CX ;;
464 MOV CX,NUM_DESIG_CP
;; Adjust the number of code pages left
466 MOV NUM_DESIG_CP
,CX ;;
469 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
471 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
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
;;;;;;;;;;;
483 TB_DONE_CONTINUE1: ;;
484 CMP ES:[BP].RESIDENT_END
,-1 ;;
488 MOV BP,OFFSET SD_SOURCE_PTR
;;
489 MOV ES:[BP].RESIDENT_END
,CX ;; Save resident end
490 JMP CONTINUE_2_END
;;
495 MOV BP,OFFSET SD_SOURCE_PTR
;;
498 SUB CX,OFFSET SD_DEST_PTR
;; Calculate # of bytes to copy
501 XOR CX,CX ;; Set valid completion return code
502 MOV TB_RETURN_CODE
,CX ;;
506 CMP CX,1 ;; Set error 1 return code
508 MOV TB_RETURN_CODE
,CX ;;
512 CMP CX,2 ;; Set error 2 return code
514 MOV TB_RETURN_CODE
,CX ;;
518 CMP CX,3 ;; Set error 3 return code
520 MOV TB_RETURN_CODE
,CX ;;
524 CMP CX,4 ;; Set error 4 return code
526 MOV TB_RETURN_CODE
,CX ;;
530 MOV CX,5 ;; Set error 5 return code
531 MOV TB_RETURN_CODE
,CX ;;
535 MOV BX,TB_CODE_PAGE_PARM
;;
537 MOV TB_RETURN_CODE
,CX ;; Set error 6 return code
542 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
544 ;; Module: STATE_BUILD
547 ;; Create the state/xlat section within the specific translate section.
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
555 ;; KEYBSYS_FILE_HANDLE - handle of the KEYBOARD.SYS file
558 ;; DI - offset of the end of the area used by STATE_BUILD
560 ;; CX - Return Code := 0 - State build successful
561 ;; 4 - State build unsuccessful
562 ;; (Bad or missing Keyboard Def file)
565 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
567 END_OF_AREA_PTR
DW 0 ;;
568 SB_FIRST_STATE
DW 0 ;;
569 SB_STATE_LENGTH
DW 0 ;;
570 SB_STATE_OFFSET
DD 0 ;;
574 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
576 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
578 STATE_BUILD PROC
NEAR ;;
580 MOV SI,DI ;; Get the tally pointer
581 MOV END_OF_AREA_PTR
,DI ;; Save pointer
583 MOV RESTORE_BP
,BP ;; Save the base pointer
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
589 MOV AL,0 ;;;;;;;;; If no problem with
590 INT 21H
;; Keyboard Def file THEN
591 JNC SB_FIRST_HEADER
;;
596 LEA CX,[BP].KX_FIRST_STATE
;; Set number of bytes to read header
600 MOV AH,3FH
;; read in the header
604 JNC SB_HEAD_CONTINUE1
;;
607 SB_HEAD_CONTINUE1: ;;
608 MOV DX,NEXT_SECT_PTR
;;
610 JE SB_HEAD_CONTINUE2
;;
611 SUB DX,SD_AREA_DIFFERENCE
;; Adjust for relocation
613 SB_HEAD_CONTINUE2: ;;
614 MOV ES:[DI].XS_NEXT_SECT_PTR
,DX ;;
616 JE SB_HEAD_CONTINUE3
;;;;;
617 ADD DX,SD_AREA_DIFFERENCE
;; Adjust for relocation
619 SB_HEAD_CONTINUE3: ;;
620 ADD DI,CX ;; Update the DI pointer
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
633 PUSH CS ;; Reset the data segment
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
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
650 PUSH CS ;; Reset the data segment
653 MOV AX,ES:[DI].XS_KBD_TYPE
;; Get the keyboard type def
654 TEST AX,HW_TYPE
;; Does it match our hardware?
656 MOV DX,ES:[DI].XS_STATE_LEN
;; No, then
657 LEA CX,[BP].KX_FIRST_XLAT
;;
660 MOV AH,42H
;; LSEEK past this state
665 SB_CONTINUE2: ;; Yes, then
666 MOV AX,SIZE STATE_STR
-1 ;;
667 ADD DI,AX ;; Set PTR and end of header
669 SB_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
;;
677 MOV AH,3FH
;; Read in the xlat tables
686 JE SB_ERROR_CHECK1
;;
690 ADD DI,CX ;; Update the end of area ptr
697 MOV SI,END_OF_AREA_PTR
;;
698 MOV NEXT_SECT_PTR
,SI ;;
722 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
724 ;; Module: FIND_CP_TABLE
727 ;; Determine the offset of the specified code page table in KEYBOARD.SYS
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
735 ;; KEYBSYS_FILE_HANDLE - handle of the KEYBOARD.SYS file
738 ;; CP_TAB_OFFSET - offset of the CP table in KEYBOARD.SYS
740 ;; CX - Return Code := 0 - State build successful
741 ;; 2 - Invalid Code page for language
742 ;; 4 - Bad or missing Keyboard Def file
745 ;; READ language table
746 ;; IF error in reading file THEN
747 ;; Display ERROR message and EXIT
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
756 ;; READ Code page table
757 ;; IF error in reading file THEN
758 ;; Display ERROR message and EXIT
760 ;; Use table to get the offset of the code page parm
762 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
766 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
768 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
770 FIND_CP_TABLE PROC
NEAR ;;
773 MOV FIND_CP_PARM
,BX ;; Save Code page
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
779 MOV AL,0 ;;;;;;;;;;;;;; If no problem with
780 INT 21H
;; Keyb Def file Then
782 JMP FIND_CP_ERROR4
;;
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
;;
795 ;****************************** CNS *******************************************
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
803 CMP CX,FILE_BUFFER_SIZE
;; Make sure buffer is not to small
805 JMP FIND_CP_ERROR4
;;
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
;;
814 MOV CX,NUM_CP
;; Number of valid codes
815 MOV DI,OFFSET FILE_BUFFER
;; Point to correct word in table
817 F_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
826 F_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 ;;
851 FIND_CP_TABLE ENDP
;;
852 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;