Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2121 lines
74 KiB

  1. PAGE ,132
  2. ;
  3. ; (C) Copyright Microsoft Corp. 1987-1990
  4. ; MS-DOS 5.00 - NLS Support - KEYB Command
  5. ;
  6. ;
  7. ; File Name: KEYBCMD.ASM
  8. ; ----------
  9. ;
  10. ;
  11. ; Description:
  12. ; ------------
  13. ; Contains transient command processing modules for KEYB command.
  14. ;
  15. ; Procedures contained in this file:
  16. ; ----------------------------------
  17. ; KEYB_COMMAND: Main routine for command processing.
  18. ; PARSE_PARAMETERS: Validate syntax of parameters included
  19. ; on command line.
  20. ; BUILD_PATH: Find KEYBOARD.SYS file and validate language and/or
  21. ; code page.
  22. ; INSTALL_INT_VECTORS: Install our INT 9, INT 2F Drivers
  23. ; NUMLK_ON: Turn on the NUM LOCK LED
  24. ; FIND_FIRST_CP: Determine first code page for given language in the
  25. ; Keyboard Definition file.
  26. ;
  27. ; Include Files Required:
  28. ; -----------------------
  29. ; KEYBMSG.INC
  30. ; KEYBEQU.INC
  31. ; KEYBSYS.INC
  32. ; KEYBI9C.INC
  33. ; KEYBI9.INC
  34. ; KEYBI2F.INC
  35. ; KEYBSHAR.INC
  36. ; KEYBDCL.INC
  37. ; KEYBTBBL.INC
  38. ; COMMSUBS.INC
  39. ; KEYBCPSD.INC
  40. ; POSTEQU.SRC
  41. ; DSEG.SRC
  42. ;
  43. ; External Procedure References:
  44. ; ------------------------------
  45. ; FROM FILE KEYBTBBL.ASM:
  46. ; TABLE_BUILD - Create the shared area containing all keyboard tables.
  47. ; STATE_BUILD - Build all states within the table area
  48. ; FROM FILE KEYBMSG.ASM:
  49. ; KEYB_MESSAGES - All messages
  50. ;
  51. ; Change History:
  52. ;
  53. ; Modified for DOS 3.40 - Nick Savage , IBM Corporation
  54. ; Wilf Russell, IBM Canada Laboratory
  55. ; DCR ???? -KEYBAORD SECURITY LOCK - CNS
  56. ;
  57. ;
  58. ; PTM 3906 - KEYB messages do not conform
  59. ; to spec. Error message does
  60. ; 3/24/88 not pass back the bogus command
  61. ; line argument. - CNS
  62. ;
  63. ; PTMP3955 ;KEYB component to free environment and close handles 0 - 4
  64. ;
  65. ; 3/24/88
  66. ;
  67. ; 9/26/89 jwg Moved code from resident module and reduce code size.
  68. ;
  69. ;;;;;;;;;;;;;
  70. PUBLIC KEYB_COMMAND
  71. ;*****************CNS********************
  72. PUBLIC ID_TAB_OFFSET
  73. ;*****************CNS********************
  74. PUBLIC CP_TAB_OFFSET
  75. PUBLIC STATE_LOGIC_OFFSET
  76. PUBLIC SYS_CODE_PAGE
  77. PUBLIC KEYBCMD_LANG_ENTRY_PTR
  78. PUBLIC DESIG_CP_BUFFER
  79. PUBLIC DESIG_CP_OFFSET
  80. PUBLIC KEYBSYS_FILE_HANDLE
  81. PUBLIC NUM_DESIG_CP
  82. PUBLIC TB_RETURN_CODE
  83. PUBLIC FILE_BUFFER
  84. PUBLIC FB
  85. ;*****************CNS********************
  86. PUBLIC ID_PTR_SIZE
  87. PUBLIC LANG_PTR_SIZE
  88. PUBLIC CP_PTR_SIZE
  89. PUBLIC NUM_ID
  90. PUBLIC NUM_LANG
  91. PUBLIC NUM_CP
  92. PUBLIC SHARED_AREA_PTR
  93. ;*****************CNS********************
  94. PUBLIC SD_SOURCE_PTR
  95. PUBLIC TEMP_SHARED_DATA
  96. PUBLIC FOURTH_PARM
  97. PUBLIC ONE_PARMID
  98. PUBLIC FTH_PARMID
  99. PUBLIC ID_FOUND
  100. PUBLIC BAD_ID
  101. PUBLIC ALPHA
  102. EXTRN PARSE_PARAMETERS:NEAR
  103. extrn pswitches:byte
  104. ;***CNS
  105. EXTRN SECURE_FL:BYTE
  106. EXTRN CUR_PTR:WORD
  107. EXTRN OLD_PTR:WORD
  108. EXTRN ERR_PART:WORD
  109. ;***CNS
  110. .xlist
  111. INCLUDE SYSMSG.INC ; message retriever
  112. .list
  113. MSG_UTILNAME <KEYB> ; identify to message retriever
  114. CODE SEGMENT PUBLIC 'CODE'
  115. .xlist
  116. INCLUDE KEYBEQU.INC
  117. INCLUDE KEYBSYS.INC
  118. INCLUDE KEYBI9.INC
  119. INCLUDE KEYBI9C.INC
  120. INCLUDE KEYBI2F.INC
  121. INCLUDE KEYBSHAR.INC
  122. INCLUDE KEYBDCL.INC
  123. INCLUDE KEYBTBBL.INC
  124. INCLUDE COMMSUBS.INC
  125. INCLUDE KEYBCPSD.INC
  126. .xlist
  127. INCLUDE POSTEQU.INC
  128. INCLUDE DSEG.INC
  129. .list
  130. ASSUME CS:CODE,DS:CODE
  131. ;;;;;;;;;;;;;
  132. ;
  133. ; Module: KEYB_COMMAND
  134. ;
  135. ; Description:
  136. ; Main routine for transient command processing.
  137. ;
  138. ; Input Registers:
  139. ; DS - points to our data segment
  140. ;
  141. ; Output Registers:
  142. ; Upon termination, if an error has occurred in which a keyboard table
  143. ; was not loaded, the AL register will contain the a error flag. This
  144. ; flag is defined as follows:
  145. ; AL:= 1 - Invalid language, code page, or syntax
  146. ; 2 - Bad or missing Keyboard Definition File
  147. ; 3 - KEYB could not create a table in resident memory
  148. ; 4 - An error condition was received when communicating
  149. ; with the CON device
  150. ; 5 - Code page requested has not been designated
  151. ; 6 - The keyboard table for the requested code page cannot
  152. ; be found in resident keyboard table.
  153. ;
  154. ; Logic:
  155. ; IF KEYB has NOT been previously loaded THEN
  156. ; Set SHARED_AREA_PTR to TEMP_SHARED_AREA
  157. ; INSTALLED_KEYB := 0
  158. ; Get HW_TYPE (set local variable)
  159. ; ELSE
  160. ; Set SHARED_AREA_PTR to ES:SHARED_AREA
  161. ; Get HW_TYPE (set local variable)
  162. ; Set TABLE_OK := 0
  163. ; INSTALLED_KEYB := 1
  164. ;
  165. ; IF CPS-CON has been loaded THEN
  166. ; INSTALLED_CON := 1
  167. ;
  168. ;*********************************** CNS *************************************
  169. ; Call PARSE_PARAMETERS := Edit ID or language, code page,
  170. ; and path parameters,ID on command line
  171. ;*********************************** CNS *************************************
  172. ; Check all return codes:
  173. ; IF any parameters are invalid THEN
  174. ; Display ERROR message
  175. ; ELSE
  176. ; IF no language parm specified
  177. ; AND code page is not invalid
  178. ; AND syntax is valid THEN
  179. ; Process QUERY:
  180. ; IF KEYB is installed THEN
  181. ; Get and display active language from SHARED_DATA_AREA
  182. ; Get invoked code page from SHARED_DATA_AREA
  183. ; Convert to ASCII
  184. ; Display ASCII representation of code page, CR/LF
  185. ;*********************************** CNS *************************************
  186. ; IF ALTERNATE FLAG SET
  187. ; Get and display active ID from SHARED_DATA_AREA
  188. ; Convert to ASCII
  189. ; Display ASCII representation of ID, CR/LF
  190. ;*********************************** CNS *************************************
  191. ; IF CPS-CON is installed THEN
  192. ; Get selected code page info from CON
  193. ; Convert to ASCII
  194. ; Display ASCII representation of code page, CR/LF
  195. ; EXIT without staying resident
  196. ;
  197. ; ELSE
  198. ; Call BUILD_PATH := Determine location of Keyboard definition file
  199. ; Open the file
  200. ; IF error in opening file THEN
  201. ; Display ERROR message and EXIT
  202. ; ELSE
  203. ; Save handle
  204. ; Set address of buffer
  205. ; READ header of Keyboard definition file
  206. ; IF error in reading file THEN
  207. ; Display ERROR message and EXIT
  208. ; ELSE
  209. ; Check signature for correct file
  210. ; IF file signature is correct THEN
  211. ; READ language table
  212. ; IF error in reading file THEN
  213. ; Display ERROR message and EXIT
  214. ; ELSE
  215. ; Use table to verify language parm
  216. ; Set pointer values
  217. ; IF code page was specified
  218. ; READ language entry
  219. ; IF error in reading file THEN
  220. ; Display ERROR message and EXIT
  221. ; ELSE
  222. ; READ Code page table
  223. ; IF error in reading file THEN
  224. ; Display ERROR message and EXIT
  225. ; ELSE
  226. ; Use table to verify code page parm
  227. ; Set pointer values
  228. ; IF CPS-CON is not installed THEN
  229. ; Set number of code pages = 1
  230. ; IF CODE_PAGE_PARM was specified THEN
  231. ; Copy CODE_PAGE_PARM into table of code pages to build
  232. ; ELSE
  233. ; Call FIND_FIRST_CP := Define the system code page (1st in Keyb Def file)
  234. ; Copy SYSTEM_CP into table of code pages to build
  235. ; ELSE
  236. ; Issue INT 2F ; 0AD03H to get table of Designated code pages
  237. ; Set number of designated code pages (HWCP + Desig CP)
  238. ; Issue INT 2F ; 0AD02H to get invoked code page
  239. ; IF CODE_PAGE_PARM was specified THEN
  240. ; Check that CODE_PAGE_PARM is in the list of designated code pages
  241. ; IF CODE_PAGE_PARM is in the list of designated code pages THEN
  242. ; Copy specified CP into table of code pages to build
  243. ; IF a CP has been selected AND is inconsistent with specified CP
  244. ; Issue WARNING message
  245. ; ELSE
  246. ; Display ERROR message
  247. ; ELSE
  248. ; IF a code page has been invoked THEN
  249. ; Copy invoked code page into table of code pages to build
  250. ; ELSE
  251. ; Call FIND_FIRST_CP := Define the system code page (1st in Keyb Def file)
  252. ; Copy SYSTEM_CP into table of code pages to build
  253. ;
  254. ; IF KEYB has not been previously installed THEN
  255. ; Call FIND_SYS_TYPE := Determine system type
  256. ; Call INSTALL_INT_9 := Install INT 9 handler
  257. ; Call FIND_KEYB_TYPE := Determine the keyboard type
  258. ;
  259. ; Call TABLE_BUILD := Build the TEMP_SHARED_DATA_AREA
  260. ;
  261. ; IF return codes from TABLE_BUILD are INVALID THEN
  262. ; IF KEYB_INSTALLED := 0 THEN
  263. ; Call REMOVE_INT_9
  264. ; Display corresponding ERROR message
  265. ; EXIT without staying resident
  266. ; ELSE
  267. ; IF any of the designated CPs were invalid in the build THEN
  268. ; Issue WARNING message
  269. ; Close the Keyboard definition file
  270. ; IF KEYB had NOT already been installed THEN
  271. ; IF keyboard is a Ferrari_G AND system is not an XT THEN
  272. ; Call NUMLK_ON := Turn the NUM LOCK LED on
  273. ; IF extended INT 16 support required THEN
  274. ; Install extended INT 16 support
  275. ; Call INSTALL_INT_9_NET := Let network know about INT 9
  276. ; Call INSTALL_INT_2F := Install the INT 2F driver
  277. ; Activate language
  278. ; Get resident end and copy TEMP_SHARED_DATA_AREA into SHARED_DATA_AREA
  279. ; EXIT but stay resident
  280. ; ELSE
  281. ; IF this was not a query call AND exit code was valid THEN
  282. ; Activate language
  283. ; Get resident end and copy TEMP_SHARED_DATA_AREA into SHARED_DATA_AREA
  284. ; EXIT without staying resident
  285. ; END
  286. ;
  287. ;;;;;;;;;;;;;
  288. INVALID_PARMS EQU 1 ; EXIT return codes
  289. BAD_KEYB_DEF_FILE EQU 2
  290. MEMORY_OVERFLOW EQU 3
  291. CONSOLE_ERROR EQU 4
  292. CP_NOT_DESIGNATED EQU 5
  293. KEYB_TABLE_NOT_LOAD EQU 6
  294. BAD_DOS_VER EQU 7
  295. EXIT_RET_CODE DB 0
  296. ;******************** CNS ***********
  297. ID_VALID EQU 0
  298. ID_INVALID EQU 1
  299. NO_ID EQU 2
  300. LANGUAGE_VALID EQU 0
  301. LANGUAGE_INVALID EQU 1 ; Return Codes
  302. NO_LANGUAGE EQU 2 ; from
  303. NO_IDLANG EQU 3
  304. ;******************** CNS ***********
  305. CODE_PAGE_VALID EQU 0 ; EDIT_LANGUAGE_CODE
  306. CODE_PAGE_INVALID EQU 1
  307. NO_CODE_PAGE EQU 2
  308. VALID_SYNTAX EQU 0
  309. INVALID_SYNTAX EQU 1
  310. ACT_KEYB EQU 2
  311. ACT_ID EQU 3
  312. ACT_KEYB_CP EQU 4
  313. ACT_CON_CP EQU 5
  314. INV_L EQU 6 ; message numbers...
  315. INV_I EQU 7
  316. INV_CP EQU 8
  317. INV_S EQU 18
  318. INV_FN EQU 9
  319. INV_KEYB_Q EQU 10
  320. INV_CON_Q EQU 11
  321. NOT_DESIG EQU 12
  322. NOT_SUPP EQU 13
  323. NOT_VALID EQU 14
  324. WARNING_1 EQU 15
  325. INV_COMBO EQU 16
  326. MEMORY_OVERF EQU 17
  327. help_1st equ 300
  328. help_last equ 306
  329. CR_LF DB 10,13,'$'
  330. FOURTH_PARM DB 0 ; switch was specified
  331. ONE_PARMID DB 0 ; id given as positional
  332. FTH_PARMID DB 0 ; id given as switch
  333. ID_FOUND DB 0 ; id was good (in k.d. file)
  334. BAD_ID DB 0 ; id was bad (from parse)
  335. ALPHA DB 0 ; first parm a language id
  336. ID_DISPLAYED DB 0 ; Indicating ID already displayed
  337. SUBLIST_NUMBER LABEL BYTE ; sublist for numbers
  338. DB 11 ; size
  339. DB 0
  340. PTR_TO_NUMBER DW ? ; offset ptr
  341. SEG_OF_NUMBER DW ? ; segment
  342. DB 1
  343. DB 10100001B ; flag
  344. DB 4 ; max width (YST)
  345. DB 1 ; min width
  346. DB " " ; filler
  347. SUBLIST_ASCIIZ LABEL BYTE ; sublist for asciiz
  348. DB 11 ; size
  349. DB 0
  350. PTR_TO_ASCIIZ DW ? ; offset ptr
  351. SEG_OF_ASCIIZ DW ? ; segment
  352. DB 1
  353. DB 00010000B ; flag
  354. DB 2 ; max width
  355. DB 2 ; min width
  356. DB " " ; filler
  357. NUMBER_HOLDER DW ? ; used for message retriever
  358. ;***CNS
  359. SUBLIST_COMLIN LABEL BYTE ; sublist for asciiz
  360. DB 11 ; size
  361. DB 0
  362. PTR_TO_COMLIN DW ? ; offset ptr
  363. SEG_OF_COMLIN DW ?
  364. DB 0
  365. DB LEFT_ALIGN+CHAR_FIELD_ASCIIZ ; flag
  366. DB 0 ; max width
  367. DB 1 ; min width
  368. DB " " ; filler
  369. STRING_HOLDER DB 64 DUP(0)
  370. ;***CNS
  371. FILE_BUFFER DB FILE_BUFFER_SIZE dup (0); Buffer for Keyboard Def file
  372. FB EQU FILE_BUFFER ;m for 32 language entries)
  373. DESIG_CP_BUFFER DW 28 DUP(?) ; (Room for 25 code pages)
  374. DESIG_CP_BUF_LEN DW $-DESIG_CP_BUFFER ; Length of code page buffer
  375. NUM_DESIG_CP DW 0
  376. CP_TAB_OFFSET DD ?
  377. ;****************** CNS ******************
  378. TOTAL_SIZE DW 0
  379. PASS_LANG DW 0
  380. ID_TAB_OFFSET DD ?
  381. ;****************** CNS ******************
  382. STATE_LOGIC_OFFSET DD -1
  383. KEYBSYS_FILE_HANDLE DW ?
  384. TB_RETURN_CODE DW 1
  385. DESIG_CP_OFFSET DW OFFSET DESIG_CP_BUFFER
  386. SYS_CODE_PAGE DW 0
  387. DESIG_LIST DW 0
  388. QUERY_CALL DB 0
  389. KB_MASK EQU 02h
  390. SIGNATURE DB 0FFh,'KEYB '
  391. SIGNATURE_LENGTH DW 8
  392. ;****************** CNS ***************************
  393. NUM_ID DW 0
  394. ERR4ID DB 0
  395. NUM_LANG DW 0
  396. NUM_CP DW 0
  397. ID_PTR_SIZE DW SIZE KEYBSYS_ID_PTRS
  398. ;****************** CNS ***************************
  399. LANG_PTR_SIZE DW SIZE KEYBSYS_LANG_PTRS
  400. CP_PTR_SIZE DW SIZE KEYBSYS_CP_PTRS
  401. KEYBCMD_LANG_ENTRY_PTR DD ?
  402. KEYB_INSTALLED DW 0
  403. CON_INSTALLED DW 0
  404. SHARED_AREA_PTR DD 0
  405. GOOD_MATCH DW 0
  406. ;****************** CNS ***************************;
  407. LANGUAGE_ASCII DB '??',0
  408. CMD_PARM_LIST PARM_LIST <>
  409. ;---------- TABLES FOR EXTENDED KEYBOARD SUPPORT CTRL CASE ---------
  410. RPL_K8 LABEL BYTE ;-------- CHARACTERS ---------
  411. DB 27,-1,00,-1,-1,-1 ; Esc, 1, 2, 3, 4, 5
  412. DB 30,-1,-1,-1,-1,31 ; 6, 7, 8, 9, 0, -
  413. DB -1,127,148,17,23,5 ; =, Bksp, Tab, Q, W, E
  414. DB 18,20,25,21,09,15 ; R, T, Y, U, I, O
  415. DB 16,27,29,10,-1,01 ; P, [, ], Enter, Ctrl, A
  416. DB 19,04,06,07,08,10 ; S, D, F, G, H, J
  417. DB 11,12,-1,-1,-1,-1 ; K, L, ;, ', `, LShift
  418. DB 28,26,24,03,22,02 ; \, Z, X, C, V, B
  419. DB 14,13,-1,-1,-1,-1 ; N, M, ,, ., /, RShift
  420. DB 150,-1,' ',-1 ; *, Alt, Space, CL
  421. ;--------- FUNCTIONS ---------
  422. DB 94,95,96,97,98,99 ; F1 - F6
  423. DB 100,101,102,103,-1,-1 ; F7 - F10, NL, SL
  424. DB 119,141,132,142,115,143 ; Home, Up, PgUp, -, Left, Pad5
  425. DB 116,144,117,145,118,146 ; Right, +, End, Down, PgDn, Ins
  426. DB 147,-1,-1,-1,137,138 ; Del, SysReq, Undef, WT, F11, F12
  427. L_CTRL_TAB EQU $-RPL_K8
  428. ;;;;;;;;;;;;;;;;
  429. ; Program Code
  430. ;;;;;;;;;;;;;;;;
  431. KEYB_COMMAND PROC NEAR
  432. CALL SYSLOADMSG ;load messages
  433. JNC VERSION_OK ;if no carry then version ok
  434. CALL SYSDISPMSG ;error..display version error
  435. MOV AL,BAD_DOS_VER ;bad DOS version
  436. MOV EXIT_RET_CODE,AL
  437. JMP KEYB_EXIT_NOT_RESIDENT ;exit..non resident
  438. VERSION_OK:
  439. MOV SEG_OF_NUMBER,CS ;initialize..
  440. MOV SEG_OF_ASCIIZ,CS ; ..sublists
  441. MOV BP,OFFSET CMD_PARM_LIST ;pointer for parm list
  442. MOV WORD PTR SHARED_AREA_PTR,ES ; ES segment
  443. KEYB_INSTALL_CHECK:
  444. MOV AX,0AD80H ; KEYB install check
  445. INT 2FH
  446. CMP AL,-1 ; If flag is not 0FFh THEN
  447. JE INSTALLED_KEYB
  448. MOV WORD PTR SHARED_AREA_PTR+2,OFFSET TSD
  449. JMP short CON_INSTALL_CHECK
  450. INSTALLED_KEYB:
  451. MOV KEYB_INSTALLED,1 ; Set KEYB_INSTALLED flag = YES
  452. MOV WORD PTR SHARED_AREA_PTR,ES ; Save segment of SHARED_DATA_AREA
  453. MOV WORD PTR SHARED_AREA_PTR+2,DI ;Save offset of SHARED_DATA_AREA
  454. MOV AX,ES:[DI].KEYB_TYPE
  455. MOV HW_TYPE,AX
  456. MOV ES:[DI].TABLE_OK,0 ; Do not allow processing
  457. PUSH CS ; while building table
  458. POP ES ; Reset ES until required
  459. CON_INSTALL_CHECK:
  460. MOV AX,0AD00H ; CONSOLE install check
  461. INT 2FH
  462. CMP AL,-1 ; If flag is not 0FFh THEN
  463. jnz call_first_stage
  464. MOV CON_INSTALLED,1 ; Set CON_INSTALLED flag = YES
  465. CALL_FIRST_STAGE:
  466. PUSH CS
  467. POP ES
  468. CALL PARSE_PARAMETERS ; Validate parameter list
  469. test pswitches,1 ; /? option?
  470. jz no_help ; brif not
  471. mov ax,help_1st ; first help msg
  472. help_loop:
  473. push ax
  474. MOV BX,STDOUT ; to standard out
  475. xor cx,cx ; no replacements
  476. MOV DH,UTILITY_MSG_CLASS ; utility message
  477. XOR DL,DL ; no input
  478. LEA SI,SUBLIST_ASCIIZ ; ptr to sublist
  479. CALL SYSDISPMSG
  480. pop ax
  481. inc ax
  482. cmp ax,help_last
  483. jbe help_loop
  484. mov exit_ret_code,invalid_parms ; return "invalid parms"
  485. jmp KEYB_EXIT_NOT_RESIDENT
  486. no_help:
  487. BEGIN_PARM_CHECK: ; CHECK ALL RETURN CODES
  488. MOV DL,[BP].RET_CODE_3
  489. CMP DL,1 ; Check for invalid syntax
  490. JNE VALID1
  491. JMP ERROR3
  492. VALID1:
  493. MOV DL,[BP].RET_CODE_1 ; Check for invalid language parm
  494. CMP DL,1
  495. JNE VALID2
  496. JMP ERROR1
  497. VALID2:
  498. MOV DL,[BP].RET_CODE_2 ; Check for invalid code page parm
  499. CMP DL,1
  500. JNE VALID3
  501. JMP ERROR2
  502. VALID3:
  503. MOV DL,[BP].RET_CODE_1 ; Check for query command
  504. CMP DL,2
  505. JE QUERY
  506. ;******************************* CNS **
  507. CMP DL,3 ; Get a status of the codepage
  508. JE QUERY ; language, and possible ID code
  509. ;******************************* CNS **
  510. JMP NOT_QUERY
  511. ; IF QUERY is requested THEN
  512. QUERY:
  513. MOV QUERY_CALL,DL
  514. MOV AX,KEYB_INSTALLED ; If KEYB is installed THEN
  515. or ax,ax
  516. JE QUERY_CONTINUE1
  517. MOV DI,WORD PTR SHARED_AREA_PTR+2 ; Get offset of
  518. MOV ES,WORD PTR SHARED_AREA_PTR ; shared area
  519. MOV BX,WORD PTR ES:[DI].ACTIVE_LANGUAGE ; Get active language
  520. or bx,bx ; if no language...
  521. JE I_MESSAGE ; then id was specified
  522. L_MESSAGE:
  523. MOV WORD PTR LANGUAGE_ASCII,BX ; Display Language
  524. LEA SI,LANGUAGE_ASCII ; sublist points to...
  525. MOV PTR_TO_ASCIIZ,SI ; language code asciiz string
  526. MOV AX,ACT_KEYB ; display 'Current keyboard code'
  527. MOV BX,STDOUT ; to standard out
  528. MOV CX,1 ; one replacement
  529. MOV DH,UTILITY_MSG_CLASS ; utility message
  530. XOR DL,DL ; no input
  531. LEA SI,SUBLIST_ASCIIZ ; ptr to sublist
  532. CALL SYSDISPMSG
  533. JMP short KEYB_L_FINISHED
  534. I_MESSAGE:
  535. MOV BX,WORD PTR ES:[DI].INVOKED_KBD_ID ; get id code.
  536. MOV NUMBER_HOLDER,BX ; transfer number to temp loc.
  537. LEA SI,NUMBER_HOLDER ; sublist points to...
  538. MOV PTR_TO_NUMBER,SI ; code page word
  539. MOV AX,ACT_ID ; display 'Current ID: '
  540. MOV BX,STDOUT ; to standard out
  541. MOV CX,1 ; one replacement
  542. MOV DH,UTILITY_MSG_CLASS ; utility message
  543. XOR DL,DL ; no input
  544. LEA SI,SUBLIST_NUMBER ; ptr to sublist
  545. CALL SYSDISPMSG
  546. MOV ID_DISPLAYED,1 ; ID was displayed.
  547. JMP short KEYB_L_FINISHED
  548. QUERY_CONTINUE1:
  549. MOV AX,INV_KEYB_Q
  550. MOV BX,STDOUT ; Else
  551. XOR CX,CX ; Display message that KEYB
  552. MOV DH,UTILITY_MSG_CLASS ; has not been installed
  553. XOR DL,DL
  554. CALL SYSDISPMSG
  555. JMP short KEYB_CP_FINISHED
  556. KEYB_L_FINISHED:
  557. MOV BX,ES:[DI].INVOKED_CP_TABLE ; Get invoked code page
  558. MOV NUMBER_HOLDER,BX ; transfer number to temp loc.
  559. LEA SI,NUMBER_HOLDER ; sublist points to...
  560. MOV PTR_TO_NUMBER,SI ; code page word
  561. MOV AX,ACT_KEYB_CP ; display ' code page: '
  562. MOV BX,STDOUT ; to standard out
  563. MOV CX,1 ; one replacement
  564. MOV DH,UTILITY_MSG_CLASS ; utility message
  565. XOR DL,DL ; no input
  566. LEA SI,SUBLIST_NUMBER ; ptr to sublist
  567. CALL SYSDISPMSG
  568. CMP ID_DISPLAYED,1 ; was id displayed?
  569. JE KEYB_CP_FINISHED ; yes..continue.
  570. MOV BX,WORD PTR ES:[DI].INVOKED_KBD_ID ; get id code.
  571. or bx,bx ; no id given
  572. JE KEYB_CP_FINISHED
  573. MOV NUMBER_HOLDER,BX ; transfer number to temp loc.
  574. LEA SI,NUMBER_HOLDER ; sublist points to...
  575. MOV PTR_TO_NUMBER,SI ; code page word
  576. MOV AX,ACT_ID ; display 'Current ID: '
  577. MOV BX,STDOUT ; to standard out
  578. MOV CX,1 ; one replacement
  579. MOV DH,UTILITY_MSG_CLASS ; utility message
  580. XOR DL,DL ; no input
  581. LEA SI,SUBLIST_NUMBER ; ptr to sublist
  582. CALL SYSDISPMSG
  583. MOV AH,09H ; need a CR_LF here.
  584. MOV DX,OFFSET CR_LF
  585. INT 21H
  586. KEYB_CP_FINISHED:
  587. MOV AX,CON_INSTALLED ; If CON has been installed THEN
  588. or ax,ax
  589. JNE GET_ACTIVE_CP
  590. JMP short CON_NOT_INSTALLED
  591. GET_ACTIVE_CP:
  592. MOV AX,0AD02H ; Get active code page
  593. INT 2FH ; information from the console
  594. JNC DISPLAY_ACTIVE_CP
  595. JMP ERROR5
  596. DISPLAY_ACTIVE_CP:
  597. MOV NUMBER_HOLDER,BX ; transfer number to temp loc.
  598. LEA SI,NUMBER_HOLDER ; sublist points to...
  599. MOV PTR_TO_NUMBER,SI ; code page word
  600. MOV AX,ACT_CON_CP ; display 'Current CON code page: '
  601. MOV BX,STDOUT ; to standard out
  602. MOV CX,1 ; one replacement
  603. MOV DH,UTILITY_MSG_CLASS ; utility message
  604. XOR DL,DL ; no input
  605. LEA SI,SUBLIST_NUMBER ; ptr to sublist
  606. CALL SYSDISPMSG
  607. JMP KEYB_EXIT_NOT_RESIDENT ; Exit from Proc
  608. CON_NOT_INSTALLED: ; ELSE
  609. MOV AX,INV_CON_Q
  610. MOV BX,STDOUT ; Else
  611. XOR CX,CX ; Display message that CON does
  612. MOV DH,UTILITY_MSG_CLASS ; not have active code page
  613. XOR DL,DL
  614. CALL SYSDISPMSG
  615. JMP KEYB_EXIT_NOT_RESIDENT ; Exit from Proc
  616. NOT_QUERY: ; IF not a query function requested
  617. CALL BUILD_PATH ; Determine location of KEYBOARD.SYS
  618. ; ...and open file.
  619. JNC VALID4 ; If no error in opening file then
  620. JMP ERROR4
  621. VALID4:
  622. MOV KEYBSYS_FILE_HANDLE,AX ; Save handle
  623. MOV BP,OFFSET CMD_PARM_LIST ; Set base pointer for structures
  624. MOV BX,KEYBSYS_FILE_HANDLE ; Retrieve the file handle
  625. MOV DX,OFFSET FILE_BUFFER ; Set address of buffer
  626. ;************************* CNS ********;
  627. cmp [BP].RET_CODE_4,ID_VALID ; CNS is there an ID available
  628. je ID_TYPED ; if so go find out if it is
  629. jmp short GET_LANG ; a 1st or 4th parm, if not must
  630. ; must be a language
  631. ID_TYPED:
  632. call SCAN_ID ; scan the table for the ID
  633. cmp ID_FOUND,1 ; if a legal ID check and see if
  634. jne LOST_ID ; it is a first or fourth parm
  635. cmp FTH_PARMID,1 ; if it is a fourth parm go
  636. je GET_ID ; check for language compatibility
  637. jmp short Language_found ; otherwise it must be a first
  638. ; parm id value
  639. LOST_ID: ; otherwise must be a bogus match
  640. ; between language and ID codes
  641. ; or the ID code does not exist
  642. jmp ERR1ID ; in the table
  643. ;************************* CNS ***********;
  644. GET_LANG: ; Must be a language/or a 1st parm ID
  645. XOR DI,DI ; Set number
  646. LEA CX,[DI].KH_NUM_LANG+2 ; bytes to read header
  647. MOV AH,3FH ; Read header of the Keyb Def file
  648. INT 21H
  649. JNC VALID5 ; If no error in opening file then
  650. JMP ERROR4
  651. VALID5:
  652. CLD ; all moves/scans forward
  653. MOV CX,SIGNATURE_LENGTH
  654. MOV DI,OFFSET SIGNATURE ; Verify matching
  655. MOV SI,OFFSET FB.KH_SIGNATURE ; signatures
  656. REPE CMPSB
  657. JE LANGUAGE_SPECIFIED
  658. JMP ERROR4
  659. ; READ the language table
  660. LANGUAGE_SPECIFIED:
  661. MOV AX,FB.KH_NUM_LANG
  662. MOV NUM_LANG,AX ; Save the number of languages
  663. MUL LANG_PTR_SIZE ; Determine # of bytes to read
  664. MOV DX,OFFSET FILE_BUFFER ; Establish beginning of buffer
  665. MOV CX,AX
  666. CMP CX,SIZE FILE_BUFFER ; Make sure buffer is not to small
  667. JBE READ_LANG_TAB
  668. JMP ERROR4
  669. READ_LANG_TAB:
  670. MOV AH,3FH ; Read language table from
  671. INT 21H ; Keyb Def file
  672. JNC READ_VALID ; If no error in opening file then
  673. JMP ERROR4 ; Else display ERROR message
  674. READ_VALID:
  675. MOV CX,NUM_LANG ; Number of valid codes
  676. MOV DI,OFFSET FILE_BUFFER ; Point to correct word in table
  677. SCAN_LANG_TABLE: ; FOR language parm
  678. MOV AX,[BP].LANGUAGE_PARM ; Get parameter
  679. CMP [DI].KP_LANG_CODE,AX ; Valid Code ??
  680. JE LANGUAGE_FOUND ; If not found AND more entries THEN
  681. ADD DI,LANG_PTR_SIZE ; Check next entry
  682. DEC CX ; Decrement count of entries
  683. JNE SCAN_LANG_TABLE ; Else
  684. JMP ERROR1 ; Display error message
  685. ;**************************** CNS ****
  686. GET_ID: ; CNS - Must be an ID value
  687. mov cx,1 ; initialize ctr value for # of ids
  688. SEARCH_ID: ; minimum per country
  689. ; ; There is atleast 1 ID for each country
  690. or cx,cx ; check for any more IDs left to check
  691. jne FINDID ; Country has more than one ID check
  692. jmp END_IDCHK ; Country & ID has been found or value
  693. ; is zero
  694. FINDID:
  695. push di ; save the current language entry ptr
  696. push cx ; save the minimum # of ids before
  697. ; reading the table data from the disk
  698. ;**************************** CNS ***********
  699. LANGUAGE_FOUND:
  700. MOV CX,WORD PTR [DI].KP_ENTRY_PTR+2 ; Get offset of lang entry
  701. MOV DX,WORD PTR [DI].KP_ENTRY_PTR ; in the Keyb Def file
  702. MOV WORD PTR KEYBCMD_LANG_ENTRY_PTR,DX ; Save
  703. MOV WORD PTR KEYBCMD_LANG_ENTRY_PTR+2,CX ; offset
  704. MOV AH,42H ; Move file pointer to
  705. MOV AL,0 ; location of language
  706. INT 21H ; entry
  707. JNC LSEEK_VALID
  708. JMP ERROR4
  709. LSEEK_VALID:
  710. MOV DI,AX
  711. MOV CX,SIZE KEYBSYS_LANG_ENTRY-1 ; Set number
  712. ; bytes to read header
  713. MOV DX,OFFSET FILE_BUFFER
  714. MOV AH,3FH ; Read language entry in
  715. INT 21H ; Keyb Def file
  716. JNC VALID6a ; If no error in file then
  717. JMP ERROR4
  718. ;**************************** CNS **********************************************
  719. valid6a:
  720. cmp FOURTH_PARM,1 ; Is the ID a 4th Parm
  721. jne VALID6 ; if not get out of routine, otherwise
  722. pop cx ; restore # of ids for the country
  723. ; Check to see if this is the first
  724. ; time checking the primary ID
  725. cmp cx,1 ; if there is just one ID check to make
  726. jne CHK4PARM ; sure both flags are not set
  727. ; this should not be necessary w/ new parser
  728. cmp FTH_PARMID,1 ; is the ID flag for switch set
  729. jne CHK1N4 ; is the flag set only for the 4th
  730. cmp FOURTH_PARM,1 ; if set only for the switch proceed
  731. jne CHK1N4 ; if not must be a positional
  732. mov cl,fb.kl_num_id ; get the number of IDs available from the table
  733. mov FTH_PARMID,0 ; turn switch flag off so the table
  734. ; counter will not be reset
  735. ;ids available for the
  736. CHK1N4: ;country
  737. cmp ONE_PARMID,1 ; this was to be done if
  738. jne CHK4PARM ; two the positional
  739. cmp FOURTH_PARM,0 ; and switch was specified
  740. jne CHK4PARM ; this should never happen
  741. pop di ; if the parser is intact
  742. jmp error3 ; report error & exit
  743. CHK4PARM: ; check on the first ID
  744. cmp FOURTH_PARM,1 ; ID was a switch
  745. jne ABORT_LOOP ; otherwise get out of routine
  746. call IDLANG_CHK ; check the ID
  747. jmp short ADVANCE_PTR ; advance to the next position
  748. ABORT_LOOP:
  749. xor cx,cx ; end loop
  750. ADVANCE_PTR:
  751. pop di ;restore entry value
  752. dec cx ; # of ids left to check
  753. je NO_ADVANCE ; if 0, don't advance table position
  754. cmp GOOD_MATCH,1 ; check to see if ID matched language
  755. je NO_ADVANCE ; if equal do not advance
  756. add di,LANG_PTR_SIZE ; step to the next entry
  757. ; in the table
  758. NO_ADVANCE:
  759. jmp SEARCH_ID ; for the country
  760. ; ; end of ID check for country
  761. END_IDCHK:
  762. cmp FOURTH_PARM,1 ; see if id was found
  763. jne VALID6
  764. cmp GOOD_MATCH,0 ; none found
  765. jne VALID6 ; report error
  766. mov [bp].ret_code_4,1 ; incompatible lang code
  767. mov al,[bp].ret_code_4 ; id combo
  768. jmp err2id
  769. ; otherwise found it
  770. ; continue to build tbl
  771. ;**************************** CNS **********************************************
  772. VALID6:
  773. MOV AX,WORD PTR FB.KL_LOGIC_PTR ; Save the offset of the state
  774. MOV WORD PTR STATE_LOGIC_OFFSET,AX ; logic section
  775. MOV AX,WORD PTR FB.KL_LOGIC_PTR+2 ; Save the offset of the state
  776. MOV WORD PTR STATE_LOGIC_OFFSET+2,AX ; logic section
  777. MOV DL,[BP].RET_CODE_2 ; IF code page was specified
  778. CMP DL,2
  779. JNE CODE_PAGE_SPECIFIED
  780. JMP short DONE
  781. CODE_PAGE_SPECIFIED: ; Then
  782. ;************************** CNS ***************************************
  783. xor ah,ah
  784. MOV Al,FB.KL_NUM_CP
  785. ;************************** CNS ***************************************
  786. MOV NUM_CP,AX ; Save the number of code pages
  787. MUL CP_PTR_SIZE ; Determine # of bytes to read
  788. MOV DX,OFFSET FILE_BUFFER ; Establish beginning of buffer
  789. MOV CX,AX
  790. CMP CX,SIZE FILE_BUFFER ; Make sure buffer is not to small
  791. JBE VALID7
  792. JMP ERROR4
  793. VALID7:
  794. MOV AH,3FH ; Read code page table from
  795. INT 21H ; Keyb Def file
  796. JNC VALID8 ; If no error in opening file then
  797. JMP ERROR4
  798. VALID8:
  799. MOV CX,NUM_CP ; Number of valid codes
  800. MOV DI,OFFSET FILE_BUFFER ; Point to correct word in table
  801. SCAN_CP_TABLE: ; FOR code page parm
  802. MOV AX,[BP].CODE_PAGE_PARM ; Get parameter
  803. CMP [DI].KC_CODE_PAGE,AX ; Valid Code ??
  804. JE CODE_PAGE_FOUND ; If not found AND more entries THEN
  805. ADD DI,CP_PTR_SIZE ; Check next entry
  806. DEC CX ; Decrement count of entries
  807. JNE SCAN_CP_TABLE ; Else
  808. ;;; if we can not find the CP, simply use the first one available for
  809. ;;; the language. This was done for NT because users can not really specified
  810. ;;; the code page id via KEYB.COM. By using the first CP, we maintain the
  811. ;;; compatibility with dos(keyb gr will succeed even the currnt code page is
  812. ;;; invalid for German layout
  813. ;;;
  814. ifdef NOT_NTVDM
  815. JMP ERROR2 ; Display error message
  816. else
  817. mov cx, 1
  818. mov NUM_DESIG_CP, cx
  819. mov [si].NUM_DESIGNATES, cx
  820. jmp short SET_TO_SYSTEM_CP
  821. endif
  822. CODE_PAGE_FOUND:
  823. MOV AX,WORD PTR [DI].KC_ENTRY_PTR
  824. MOV WORD PTR CP_TAB_OFFSET,AX
  825. MOV AX,WORD PTR [DI].KC_ENTRY_PTR+2
  826. MOV WORD PTR CP_TAB_OFFSET+2,AX
  827. DONE:
  828. MOV SI,OFFSET DESIG_CP_BUFFER
  829. MOV AX,CON_INSTALLED ; If CON is NOT installed THEN
  830. or ax,ax
  831. JE SYSTEM_CP
  832. JMP short GET_DESIG_CPS
  833. SYSTEM_CP:
  834. MOV CX,1
  835. MOV NUM_DESIG_CP,CX ; Set number of CPs = 1
  836. MOV [SI].NUM_DESIGNATES,CX
  837. MOV DL,[BP].RET_CODE_2 ; Check if code page parm
  838. or dl,dl ; was specified
  839. JNE SET_TO_SYSTEM_CP
  840. MOV DX,[BP].CODE_PAGE_PARM
  841. MOV [SI].DESIG_CP_ENTRY,DX ; Load specified code page into
  842. JMP READY_TO_BUILD_TABLE ; designated code page list
  843. SET_TO_SYSTEM_CP:
  844. CALL FIND_FIRST_CP ; Call routine that sets the first
  845. or ax,ax ; table found in the Keyb Def file
  846. JE SET_TO_SYSTEM_CP2 ; to the system code page
  847. JMP ERROR4
  848. SET_TO_SYSTEM_CP2:
  849. MOV SYS_CODE_PAGE,BX
  850. MOV [BP].CODE_PAGE_PARM,BX
  851. MOV [SI].DESIG_CP_ENTRY,BX ; Move sys CP into desig list
  852. JMP READY_TO_BUILD_TABLE
  853. GET_DESIG_CPS: ; ELSE
  854. MOV AX,0AD03H
  855. PUSH CS ; Make sure ES is set
  856. POP ES
  857. LEA DI,DESIG_CP_BUFFER
  858. MOV CX,DESIG_CP_BUF_LEN
  859. INT 2FH ; Get all designated code pages
  860. JNC SET_DESIG_VARIABLES ; from console
  861. JMP ERROR5
  862. SET_DESIG_VARIABLES:
  863. MOV CX,[SI].NUM_DESIGNATES
  864. ADD CX,[SI].NUM_HW_CPS
  865. MOV NUM_DESIG_CP,CX ; Set number of Designated CPs
  866. BUFFER_CREATED:
  867. MOV AX,0AD02H
  868. INT 2FH ; Get invoked code page
  869. SET_TO_CP_INVOKED:
  870. MOV DL,[BP].RET_CODE_2 ; IF code page parm was specified
  871. or dl,dl
  872. JNE SET_TO_INVOKED_CP
  873. MOV CX,NUM_DESIG_CP
  874. MOV DESIG_LIST,SI
  875. JMP short TEST_IF_DESIGNATED
  876. SET_TO_INVOKED_CP:
  877. CMP AX,1 ; IF a code page has been invoked
  878. JNE SET_TO_INVOKED_CP3
  879. CALL FIND_FIRST_CP ; Call the routine that sets the
  880. or ax,ax ; first code page in the Keyb Def
  881. JE SET_TO_INVOKED_CP2 ; file to the system code page
  882. JMP ERROR4
  883. SET_TO_INVOKED_CP2:
  884. MOV [BP].CODE_PAGE_PARM,BX
  885. MOV SYS_CODE_PAGE,BX
  886. JMP short TEST_IF_DESIGNATED
  887. SET_TO_INVOKED_CP3:
  888. MOV [BP].CODE_PAGE_PARM,BX
  889. TEST_IF_DESIGNATED:
  890. MOV DX,[BP].CODE_PAGE_PARM
  891. CMP [SI].DESIG_CP_ENTRY,DX ; Is Code page specified in the list
  892. JE CODE_PAGE_DESIGNATED ; of designated code pages ?
  893. NEXT_DESIG_CP:
  894. ADD SI,2 ; Check next code page
  895. DEC CX ; If all designated code pages have
  896. JNZ TEST_IF_DESIGNATED ; been checked Then ERROR
  897. JMP ERROR6
  898. CODE_PAGE_DESIGNATED:
  899. CMP SYS_CODE_PAGE,0
  900. JNE READY_TO_BUILD_TABLE
  901. CMP AX,1 ; IF a code page has been invoked
  902. JE READY_TO_BUILD_TABLE
  903. CMP [BP].CODE_PAGE_PARM,BX ; IF Invoked CP <> Specified CP
  904. JE READY_TO_BUILD_TABLE ; Issue warning
  905. ;***************************************************************************
  906. PUSH BX
  907. PUSH CX
  908. MOV AX,WARNING_1
  909. MOV BX,STDOUT
  910. XOR CX,CX
  911. MOV DH,UTILITY_MSG_CLASS
  912. XOR DL,DL
  913. CALL SYSDISPMSG
  914. POP CX
  915. POP BX
  916. ;***************************************************************************
  917. READY_TO_BUILD_TABLE:
  918. MOV AX,KEYB_INSTALLED
  919. or ax,ax ; Else if KEYB has not been installed
  920. JNE BUILD_THE_TABLE
  921. CALL FIND_SYS_TYPE ; Determine system type for INT 9 use
  922. ;------ LOAD IN SPECIAL INT 9 HANDLER AND SPECIAL TABLES
  923. CALL INSTALL_INT_9 ; Install INT 9
  924. CALL FIND_KEYB_TYPE ; Determine keyboard type table use
  925. BUILD_THE_TABLE:
  926. CALL TABLE_BUILD ; Build the TEMP_SHARED_DATA_AREA
  927. CHECK_ERRORS:
  928. ; Take appropriate action considering
  929. MOV CX,TB_RETURN_CODE ; return codes from TABLE_BUILD
  930. jcxz CHECK_FOR_INV_CP ; If return code is not 0
  931. MOV AX,KEYB_INSTALLED ; If KEYB has not been installed,
  932. or ax,ax
  933. JNE CHECK_ERROR_CONTINUE
  934. CALL REMOVE_INT_9 ; remove installed vector
  935. CHECK_ERROR_CONTINUE:
  936. CMP CX,1 ; If return code = 1
  937. JNE CHECK_ERROR2
  938. JMP ERROR1 ; display error message
  939. CHECK_ERROR2:
  940. CMP CX,2 ; If return code = 2
  941. JNE CHECK_ERROR3
  942. JMP ERROR2
  943. CHECK_ERROR3:
  944. CMP CX,3 ; If return code = 3
  945. JNE CHECK_ERROR4
  946. JMP ERROR3 ; display error message
  947. CHECK_ERROR4:
  948. CMP CX,4 ; If return code = 4
  949. JNE CHECK_ERROR5A
  950. JMP ERROR4 ; display error message
  951. CHECK_ERROR5A:
  952. CMP CX,5 ; If return code = 5
  953. JNE CHECK_ERROR6A
  954. JMP ERROR5A ; display error message
  955. CHECK_ERROR6A:
  956. JMP ERROR6A ; If return code not 0,1,2,3,4 then
  957. ; display error message
  958. CHECK_FOR_INV_CP:
  959. MOV CX,CPN_INVALID ; Check if any CPs were not loaded
  960. jcxz TERMINATE ; If some were invalid, issue
  961. ; warning message
  962. ;***************************************************************************
  963. PUSH BX
  964. PUSH CX
  965. MOV AX,NOT_SUPP
  966. MOV BX,STDOUT ; WARNING
  967. XOR CX,CX ; MESSAGE
  968. MOV DH,UTILITY_MSG_CLASS
  969. XOR DL,DL
  970. CALL SYSDISPMSG
  971. POP CX
  972. POP BX
  973. ;***************************************************************************
  974. TERMINATE:
  975. MOV AH,3EH ; Close the KEYBOARD.SYS file
  976. MOV BX,KEYBSYS_FILE_HANDLE ; if open
  977. or bx,bx
  978. JE KEYB_EXIT
  979. INT 21H
  980. MOV AX,KEYB_INSTALLED
  981. or ax,ax
  982. JE KEYB_EXIT
  983. JMP KEYB_EXIT_NOT_RESIDENT
  984. KEYB_EXIT:
  985. TEST SD.KEYB_TYPE,G_KB ; Q..FERRARI G??
  986. JZ NO_FERRARI_G ; N..LEAVE NUMLK ALONE
  987. TEST SD.SYSTEM_FLAG,PC_XT ; Q..PC/XT?
  988. JNZ NO_FERRARI_G ; Y..LEAVE NUMLK ALONE
  989. TEST SD.KEYB_TYPE,P_KB ; Q..FERRARI P??
  990. JNZ NO_FERRARI_G ; Y..LEAVE NUMLK ALONE
  991. ;***CNS
  992. CMP SECURE_FL,1 ; IF SECURITY FLAG SET
  993. JNE NO_FERRARI_G ; DON'T TURN ON NUM_LK
  994. ;***CNS
  995. CALL NUMLK_ON ; N..TURN NUMLK ON
  996. NO_FERRARI_G:
  997. TEST SD.SYSTEM_FLAG,EXT_16 ; extended INT 16 support?
  998. JZ SKIP_CTRL_COPY
  999. ; Yes, load extened CTRL case table
  1000. MOV CX,L_CTRL_TAB ; CX = LENGTH OF EXTENDED TABLE
  1001. MOV SI,OFFSET CS:RPL_K8 ; POINT TO EXT. CTRL TABLES
  1002. MOV DI,OFFSET CS:K8 ; POINT TO REGULAR CTRL TABLE
  1003. CLD
  1004. REP MOVSB ; OVERLAY WITH EXT. CTRL TABLE
  1005. SKIP_CTRL_COPY:
  1006. CALL INSTALL_INT_9_NET ; Let the network know about INT 9
  1007. ; (if the network is installed)
  1008. CALL INSTALL_INT_2F ; Install INT 2F
  1009. MOV AX,0AD82H ; Activate language
  1010. MOV BL,-1
  1011. INT 2FH
  1012. MOV AH,31H ; Function call to terminate but stay
  1013. XOR AL,AL ; resident
  1014. MOV DI,OFFSET SD_DEST_PTR ; Initialize destination ptr
  1015. MOV DX,ES:TSD.RESIDENT_END ; Get resident end
  1016. CALL COPY_SDA_SETUP ; Set up move common code
  1017. JMP COPY_SD_AREA ; Jump to proc that copies area in new
  1018. ; part of memory
  1019. ;***************************** CNS **************************************
  1020. ERR1ID:
  1021. ;************************************************************************
  1022. MOV AX,INV_I ; invalid ID message
  1023. MOV BX,STDOUT ; to standard out
  1024. XOR CX,CX ; no substitutions
  1025. MOV DH,UTILITY_MSG_CLASS ; utility message
  1026. XOR DL,DL ; no input
  1027. CALL SYSDISPMSG ; display message
  1028. MOV AL,INVALID_PARMS
  1029. MOV EXIT_RET_CODE,AL
  1030. ;***************************************************************************
  1031. JMP KEYB_EXIT_NOT_RESIDENT
  1032. ERR2ID:
  1033. ;***************************************************************************
  1034. MOV AX,INV_COMBO ; invalid combination message
  1035. MOV BX,STDOUT ; to standard out
  1036. XOR CX,CX ; no substitutions
  1037. MOV DH,UTILITY_MSG_CLASS ; utility message
  1038. XOR DL,DL ; no input
  1039. CALL SYSDISPMSG ; display message
  1040. MOV AL,INVALID_PARMS
  1041. MOV EXIT_RET_CODE,AL
  1042. ;**************************************************************************
  1043. JMP KEYB_EXIT_NOT_RESIDENT
  1044. ;***************************** CNS ****************************************
  1045. ERROR1:
  1046. ;***************************************************************************
  1047. MOV AX,INV_L ; invalid language code
  1048. MOV BX,STDOUT ; to standard out
  1049. XOR CX,CX ; no substitutions
  1050. MOV DH,UTILITY_MSG_CLASS ; utility message
  1051. XOR DL,DL ; no input
  1052. CALL SYSDISPMSG ; display message
  1053. MOV AL,INVALID_PARMS
  1054. MOV EXIT_RET_CODE,AL
  1055. ;***************************************************************************
  1056. JMP KEYB_EXIT_NOT_RESIDENT
  1057. ERROR2:
  1058. ;***************************************************************************
  1059. MOV AX,INV_CP ; invalid code page message
  1060. MOV BX,STDOUT ; to standard out
  1061. XOR CX,CX ; no substitutions
  1062. MOV DH,UTILITY_MSG_CLASS ; utility message
  1063. XOR DL,DL ; no input
  1064. CALL SYSDISPMSG ; display message
  1065. MOV AL,INVALID_PARMS
  1066. MOV EXIT_RET_CODE,AL
  1067. ;***************************************************************************
  1068. JMP KEYB_EXIT_NOT_RESIDENT
  1069. ERROR3:
  1070. ;***************************************************************************
  1071. MOV AX,INV_S ; invalid syntax message
  1072. MOV BX,STDOUT ; to standard out
  1073. ;***CNS
  1074. LEA DI,STRING_HOLDER ;Set PTR to look at the STRING
  1075. PUSH SI ;Save current SI index
  1076. PUSH AX
  1077. MOV AX,OLD_PTR ;Last locale of the end of a PARAM
  1078. SUB CUR_PTR,AX ;Get the length via the PSP
  1079. MOV SI,CUR_PTR
  1080. MOV CX,SI ;Save it in CX to move in the chars
  1081. POP AX ;Restore the PTR to the command line position
  1082. MOV SI,OLD_PTR ;Last locale of the end of a PARAM
  1083. REP MOVSB ;Move in the chars until no more
  1084. LEA DI,STRING_HOLDER ;Set PTR to look at the STRING
  1085. POP SI ;Restore the PTR to the command line position
  1086. MOV CX,1 ;One replacement
  1087. MOV PTR_TO_COMLIN,DI ; language code asciiz string
  1088. PUSH AX
  1089. MOV AX,DS ; language code asciiz string
  1090. MOV SEG_OF_COMLIN,AX
  1091. POP AX
  1092. MOV AX,ERR_PART
  1093. ifdef BILINGUAL
  1094. or ax,ax
  1095. jnz ERR03_GO
  1096. mov ax,8 ; Value Disallow
  1097. ERR03_GO:
  1098. endif
  1099. LEA SI,SUBLIST_COMLIN
  1100. MOV DH,PARSE_ERR_CLASS ; parse error message
  1101. XOR DL,DL ; no input
  1102. CALL SYSDISPMSG ; display message
  1103. MOV AL,INVALID_PARMS
  1104. MOV EXIT_RET_CODE,AL
  1105. ;***************************************************************************
  1106. JMP short KEYB_EXIT_NOT_RESIDENT
  1107. ERROR4:
  1108. ;***************************************************************************
  1109. MOV AX,INV_FN ; bad or missing file message
  1110. MOV BX,STDOUT ; to standard out
  1111. XOR CX,CX ; no substitutions
  1112. MOV DH,UTILITY_MSG_CLASS ; utility message
  1113. XOR DL,DL ; no input
  1114. CALL SYSDISPMSG ; display message
  1115. MOV AL,BAD_KEYB_DEF_FILE
  1116. MOV EXIT_RET_CODE,AL
  1117. ;***************************************************************************
  1118. JMP short KEYB_EXIT_NOT_RESIDENT
  1119. ERROR5:
  1120. ;***************************************************************************
  1121. MOV AX,INV_CON_Q ; CON code page not available.
  1122. MOV BX,STDOUT ; to standard out
  1123. XOR CX,CX ; no substitutions
  1124. MOV DH,UTILITY_MSG_CLASS ; utility message
  1125. XOR DL,DL ; no input
  1126. CALL SYSDISPMSG ; display message
  1127. MOV AL,CONSOLE_ERROR
  1128. MOV EXIT_RET_CODE,AL
  1129. ;***************************************************************************
  1130. JMP short KEYB_EXIT_NOT_RESIDENT
  1131. ERROR5A:
  1132. ;***************************************************************************
  1133. MOV AX,MEMORY_OVERF ; not enough resident memory.
  1134. MOV BX,STDOUT ; to standard out
  1135. XOR CX,CX ; no substitutions
  1136. MOV DH,UTILITY_MSG_CLASS ; utility message
  1137. XOR DL,DL ; no input
  1138. CALL SYSDISPMSG ; display message
  1139. MOV AL,MEMORY_OVERFLOW
  1140. MOV EXIT_RET_CODE,AL
  1141. ;***************************************************************************
  1142. JMP short KEYB_EXIT_NOT_RESIDENT
  1143. ERROR6:
  1144. ;***************************************************************************
  1145. MOV AX,NOT_DESIG ; code page not prepared.
  1146. MOV BX,STDOUT ; to standard out
  1147. XOR CX,CX ; no substitutions
  1148. MOV DH,UTILITY_MSG_CLASS ; utility message
  1149. XOR DL,DL ; no input
  1150. CALL SYSDISPMSG ; display message
  1151. MOV AL,CP_NOT_DESIGNATED
  1152. MOV EXIT_RET_CODE,AL
  1153. ;***************************************************************************
  1154. JMP short KEYB_EXIT_NOT_RESIDENT
  1155. ERROR6A:
  1156. ;***************************************************************************
  1157. MOV NUMBER_HOLDER,BX ; transfer number to temp loc.
  1158. LEA SI,NUMBER_HOLDER ; sublist points to...
  1159. MOV PTR_TO_NUMBER,SI ; code page word
  1160. MOV AX,NOT_VALID ; display 'Code page requested....'
  1161. MOV BX,STDOUT ; to standard out
  1162. MOV CX,1 ; one replacement
  1163. MOV DH,UTILITY_MSG_CLASS ; utility message
  1164. XOR DL,DL ; no input
  1165. LEA SI,SUBLIST_NUMBER ; ptr to sublist
  1166. CALL SYSDISPMSG
  1167. MOV AL,KEYB_TABLE_NOT_LOAD
  1168. MOV EXIT_RET_CODE,AL
  1169. ;***************************************************************************
  1170. KEYB_EXIT_NOT_RESIDENT:
  1171. MOV AH,04CH
  1172. MOV AL,QUERY_CALL ; Check if this was a query call
  1173. or al,al
  1174. JNE KEYB_EXIT3 ; IF yes then EXIT
  1175. MOV AL,EXIT_RET_CODE ; Check if return code was valid
  1176. or al,al
  1177. JNE KEYB_EXIT3 ; IF not then EXIT
  1178. COPY_INTO_SDA:
  1179. MOV AX,0AD82H ; Activate language
  1180. MOV BL,-1
  1181. INT 2FH
  1182. MOV AH,04CH
  1183. MOV AL,EXIT_RET_CODE
  1184. MOV DI,WORD PTR SHARED_AREA_PTR+2 ; Initialize destination ptr
  1185. MOV ES,WORD PTR SHARED_AREA_PTR
  1186. MOV DX,[BP].RESIDENT_END
  1187. CALL COPY_SDA_SETUP ; Set up move common code
  1188. JMP COPY_SD_AREA ; Jump to proc that copies area in new
  1189. KEYB_EXIT3:
  1190. MOV AL,EXIT_RET_CODE
  1191. MOV DI,WORD PTR SHARED_AREA_PTR+2 ; Initialize destination ptr
  1192. MOV ES,WORD PTR SHARED_AREA_PTR
  1193. MOV ES:[DI].TABLE_OK,1
  1194. INT 21H
  1195. KEYB_COMMAND ENDP
  1196. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1197. ;
  1198. ; Procedure: COPY_SDA_SETUP
  1199. ;
  1200. ; Description:
  1201. ; Common setup logic for exit
  1202. ;
  1203. ; Input Registers:
  1204. ; N/A
  1205. ;
  1206. ; Output Registers:
  1207. ; N/A
  1208. ;
  1209. ; Logic:
  1210. ;
  1211. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1212. COPY_SDA_SETUP PROC NEAR
  1213. push ax ;save existing values
  1214. push es
  1215. mov ax,cs:[2ch] ;check offset for address containin environ.
  1216. or ax,ax
  1217. je NO_FREEDOM
  1218. mov es,ax
  1219. mov ax,4900H ;make the free allocate mem func
  1220. int 21h
  1221. NO_FREEDOM:
  1222. pop es ;restore existing values
  1223. push bx
  1224. ;Terminate and stay resident
  1225. mov bx,4 ;1st close file handles
  1226. ;STDIN,STDOUT,STDERR
  1227. closeall:
  1228. mov ah,3eh
  1229. int 21h
  1230. dec bx
  1231. jnz closeall
  1232. pop bx
  1233. pop ax
  1234. MOV CL,4 ; Convert into paragrahs
  1235. SHR DX,CL
  1236. INC DX
  1237. MOV SI,OFFSET SD_SOURCE_PTR ; Initialize source ptr
  1238. XOR BP,BP
  1239. LEA BX,[BP].ACTIVE_LANGUAGE
  1240. ADD DI,BX ; Adjust for portion not copied
  1241. ADD SI,BX ; Adjust for portion not copied
  1242. MOV CX,SD_LENGTH ; Set length of SHARED_DATA_AREA
  1243. SUB CX,BX ; Adjust for portion not copied
  1244. RET
  1245. COPY_SDA_SETUP ENDP
  1246. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1247. ;
  1248. ; Procedure: NUMLK_ON
  1249. ;
  1250. ; Description:
  1251. ; Turn Num Lock On.
  1252. ;
  1253. ; Input Registers:
  1254. ; N/A
  1255. ;
  1256. ; Output Registers:
  1257. ; N/A
  1258. ;
  1259. ; Logic:
  1260. ; Set Num Lock bit in BIOS KB_FLAG
  1261. ; Issue Int 16 to update lights
  1262. ;
  1263. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1264. NUMLK_ON PROC
  1265. PUSH ES
  1266. PUSH AX
  1267. MOV AX,DATA
  1268. MOV ES,AX
  1269. OR ES:KB_FLAG,NUM_STATE ; Num Lock state active
  1270. MOV AH,1 ; Issue keyboard query call to
  1271. INT 16H ; have BIOS update the lights
  1272. POP AX
  1273. POP ES
  1274. RET
  1275. NUMLK_ON ENDP
  1276. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1277. ;
  1278. ; Module: INSTALL_INT_9
  1279. ;
  1280. ; Description:
  1281. ; Install our INT 9 driver.
  1282. ;
  1283. ; Input Registers:
  1284. ; DS - points to our data segment
  1285. ; BP - points to ES to find SHARED_DATA_AREA
  1286. ;
  1287. ; Output Registers:
  1288. ; DS - points to our data segment
  1289. ; AX, BX, DX, ES Trashed
  1290. ;
  1291. ; Logic:
  1292. ; Get existing vector
  1293. ; Install our vector
  1294. ; Return
  1295. ;
  1296. INSTALL_INT_9 PROC
  1297. PUSH ES
  1298. MOV AH,35H ; Get int 9 vector
  1299. MOV AL,9
  1300. INT 21H ; Vector in ES:BX
  1301. PUSH ES ; Save segment ES:
  1302. PUSH CS
  1303. POP ES
  1304. MOV WORD PTR ES:SD.OLD_INT_9,BX ; Offset
  1305. POP AX ; Recover ES: segment
  1306. MOV WORD PTR ES:SD.OLD_INT_9+2,AX ; Segment
  1307. MOV AH,25H
  1308. MOV AL,9
  1309. MOV DX,OFFSET KEYB_INT_9 ; Let DOS know about our handler
  1310. INT 21H
  1311. POP ES
  1312. RET
  1313. INSTALL_INT_9 ENDP
  1314. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1315. ;
  1316. ; Module: INSTALL_INT_9_NET
  1317. ;
  1318. ; Description:
  1319. ;
  1320. ;
  1321. ; Input Registers:
  1322. ; DS - points to our data segment
  1323. ; BP - points to ES to find SHARED_DATA_AREA
  1324. ;
  1325. ; Output Registers:
  1326. ; DS - points to our data segment
  1327. ; AX, BX, DX, ES Trashed
  1328. ;
  1329. ; Logic:
  1330. ; IF network is installed THEN
  1331. ; Let it know about our INT 9
  1332. ; Return
  1333. ;
  1334. INSTALL_INT_9_NET PROC
  1335. PUSH ES
  1336. TEST SD.SYSTEM_FLAG,PC_NET ; TEST FOR PC_NETWORK
  1337. ; IF NOT THE NETWORK INSTALLED
  1338. JZ INSTALL_9_DONE_NET ; SKIP THE PC NETWORK HANDSHAKE
  1339. ; ES:BX TO CONTAIN INT 9 ADDR
  1340. MOV BX,OFFSET KEYB_INT_9
  1341. MOV AX,0B808H ; FUNCTION FOR PC NETWORK TO INSTALL
  1342. ; THIS ADDRESS FOR THEIR JUMP TABLE
  1343. INT 2FH ; TELL PC_NET TO USE MY ADDR TO CHAIN TO
  1344. INSTALL_9_DONE_NET:
  1345. POP ES
  1346. RET
  1347. INSTALL_INT_9_NET ENDP
  1348. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1349. ;
  1350. ; Module: INSTALL_INT_2F
  1351. ;
  1352. ; Description:
  1353. ; Install our INT 2F drivers.
  1354. ;
  1355. ; Input Registers:
  1356. ; DS - points to our data segment
  1357. ; BP - points to ES to find SHARED_DATA_AREA
  1358. ;
  1359. ; Output Registers:
  1360. ; DS - points to our data segment
  1361. ; AX, BX, DX, ES Trashed
  1362. ;
  1363. ; Logic:
  1364. ; Get existing vectors
  1365. ; Install our vectors
  1366. ; Return
  1367. ;
  1368. ;
  1369. INSTALL_INT_2F PROC
  1370. MOV AH,35H ; Get int 2f vector
  1371. MOV AL,2FH
  1372. INT 21H ; Vector in ES:BX
  1373. PUSH ES ; Save segment ES:
  1374. PUSH CS
  1375. POP ES
  1376. MOV WORD PTR ES:SD.OLD_INT_2F,BX ; Offset
  1377. POP AX ; Recover ES: segment
  1378. MOV WORD PTR ES:SD.OLD_INT_2F+2,AX ; Segment
  1379. MOV AH,25H ; Set int 9 vector
  1380. MOV AL,2FH
  1381. MOV DX,OFFSET KEYB_INT_2F ; Vector in DS:DX
  1382. INT 21H
  1383. RET
  1384. INSTALL_INT_2F ENDP
  1385. ;
  1386. ;
  1387. ; Module: REMOVE_INT_9
  1388. ;
  1389. ; Description:
  1390. ; Remove our INT 9 driver.
  1391. ;
  1392. ; Input Registers:
  1393. ; DS - points to our data segment
  1394. ; BP - points to ES to find SHARED_DATA_AREA
  1395. ;
  1396. ; Output Registers:
  1397. ; DS - points to our data segment
  1398. ; AX, BX, DX, ES Trashed
  1399. ;
  1400. ; Logic:
  1401. ; Get old vector
  1402. ; Install old vector
  1403. ; Return
  1404. ;
  1405. REMOVE_INT_9 PROC
  1406. PUSH DS
  1407. PUSH ES
  1408. MOV ES,WORD PTR SHARED_AREA_PTR
  1409. MOV AX,WORD PTR ES:SD.OLD_INT_9+2 ; int 9 vector - segment
  1410. MOV DS,AX
  1411. MOV DX,WORD PTR ES:SD.OLD_INT_9 ; int 9 vector - offset
  1412. MOV AH,25H ; Set int 9 vector
  1413. MOV AL,9
  1414. INT 21H
  1415. REMOVE_9_DONE:
  1416. POP ES
  1417. POP DS
  1418. RET
  1419. REMOVE_INT_9 ENDP
  1420. IDLANG_CHK PROC NEAR
  1421. mov ax,fb.kl_id_code ;get the id code from the table
  1422. cmp ax,[bp].id_parm ;compare it to value taken
  1423. jne end_match ;from the switch-- if found
  1424. cmp ALPHA,0 ;a keyboard code was specified
  1425. je a_match ;no lang & a match
  1426. mov ax,fb.kl_lang_code ;compare lang codes
  1427. cmp ax,[BP].LANGUAGE_PARM ;they are equal
  1428. je a_match
  1429. jmp short end_match ;if not found go check next
  1430. ;id for the same country
  1431. a_match:
  1432. mov good_match,1 ;report the ids match
  1433. end_match:
  1434. ret
  1435. IDLANG_CHK ENDP
  1436. ;*********************** CNS *******************;
  1437. ;**********************************SCAN_ID***********************;
  1438. ; New variables defined - NUM_ID,ADRSS_LANG,ID_PTR_SIZE,ID_FOUND
  1439. ;****************************************************************;
  1440. SCAN_ID PROC NEAR
  1441. xor di,di ;clear di to set at the
  1442. ;beginning of KEYBSYS STRUCTURE
  1443. lea cx,[di].kh_num_ID+4 ; set number of bytes to read header
  1444. mov ah,3fh
  1445. int 21h
  1446. jnc VAL5ID
  1447. jmp short BAD_TAB ;bad table message
  1448. VAL5ID:
  1449. mov cx,SIGNATURE_LENGTH
  1450. mov di,offset SIGNATURE
  1451. mov si,offset FB.KH_SIGNATURE
  1452. repe CMPSB
  1453. je ID_SPECIFIED
  1454. jmp short BAD_TAB
  1455. ID_SPECIFIED:
  1456. mov ax,FB.KH_NUM_ID
  1457. mov NUM_ID,ax ; save # of IDs
  1458. mul ID_PTR_SIZE ; determine # of bytes to read
  1459. push ax ; save current # of bytes to read for
  1460. ; ID values only
  1461. mov ax,FB.KH_NUM_LANG ; add on lang data in table
  1462. mul LANG_PTR_SIZE ; data that comes before the ID data
  1463. mov cx,ax ; save that value for the size compare
  1464. mov PASS_LANG,cx
  1465. pop ax ; restore the info for # of ID bytes to read
  1466. add cx,ax ; add that value to get total in CX
  1467. mov TOTAL_SIZE,cx ; save the total size
  1468. cmp cx,size FILE_BUFFER
  1469. jbe READ_ID_TAB
  1470. jmp short BAD_TAB
  1471. READ_ID_TAB:
  1472. mov dx,offset FILE_BUFFER
  1473. mov ah,3fh ;read language table from
  1474. int 21h ;keyb defn file
  1475. jnc READ_IDVAL
  1476. jmp short BAD_TAB
  1477. READ_IDVAL:
  1478. mov cx,NUM_ID
  1479. mov di,offset FILE_BUFFER
  1480. add di,PASS_LANG
  1481. SCAN_ID_TAB:
  1482. mov ax,[bp].ID_PARM
  1483. cmp [di].KP_ID_CODE,ax
  1484. je ID_HERE
  1485. add di,ID_PTR_SIZE
  1486. dec cx
  1487. jne SCAN_ID_TAB
  1488. jmp short FINALE
  1489. BAD_TAB:
  1490. mov ERR4ID,1
  1491. jmp short FINALE
  1492. ID_HERE:
  1493. mov ID_FOUND,1 ;reset ptr for
  1494. ;current country
  1495. FINALE:
  1496. ret
  1497. SCAN_ID ENDP
  1498. ;*******************************SCAN_ID END******;
  1499. ;
  1500. ; Module: BUILD_PATH
  1501. ;
  1502. ; Description:
  1503. ; Build the complete filename of the Keyboard Definition File
  1504. ;*************************************WGR*********************
  1505. ; and open the file.
  1506. ;+++++++++++++++++++++++++++++++++++++WGR+++++++++++++++++++++
  1507. ;
  1508. ; Input Registers:
  1509. ; DS - points to our data segment
  1510. ; ES - points to our data segment
  1511. ; BP - offset of parmeter list
  1512. ;
  1513. ; Output Registers:
  1514. ;************************************WGR**********************
  1515. ; CARRY CLEAR
  1516. ; AX = HANDLE
  1517. ; CARRY SET (ERROR)
  1518. ; NONE
  1519. ;++++++++++++++++++++++++++++++++++++WGR++++++++++++++++++++++
  1520. ; The complete filename will be available in FILE_NAME
  1521. ;
  1522. ; Logic:
  1523. ;
  1524. ; Determine whether path parameter was specified
  1525. ; IF length is zero THEN
  1526. ;****************************************WGR******************
  1527. ; Try to open file in ACTIVE directory
  1528. ; IF failed THEN
  1529. ; Try to open file in ARGV(0) directory
  1530. ; IF failed THEN
  1531. ; Try to open file in ROOT directory (for DOS 3.3 compatibility)
  1532. ; ENDIF
  1533. ; ENDIF
  1534. ; ENDIF
  1535. ; ELSE
  1536. ; Copy path from PSP to FILE_NAME memory area
  1537. ; Try to open USER SPECIFIED file
  1538. ;++++++++++++++++++++++++++++++++++++++++WGR++++++++++++++++++
  1539. ;
  1540. ;
  1541. KEYBOARD_SYS DB '\KEYBOARD.SYS',00
  1542. KEYB_SYS_ACTIVE DB 'KEYBOARD.SYS',00
  1543. KEYB_SYS_LENG EQU 14
  1544. KEYB_SYS_A_LENG EQU 13
  1545. ifdef JAPAN
  1546. PUBLIC FILE_NAME
  1547. endif ; JAPAN
  1548. FILE_NAME DB 128 DUP(0)
  1549. ifdef JAPAN
  1550. PUBLIC keyb_table
  1551. keyb_table label byte ; keyboard definition file search table
  1552. ; len driver name sub type
  1553. db 9, 'KEYAX.SYS', 1
  1554. db 9, 'KEY01.SYS', 2
  1555. db 9, 'KEY02.SYS', 3
  1556. db 10,'KEYJ31.SYS',4
  1557. db 0
  1558. endif ; JAPAN
  1559. FILE_NOT_FOUND EQU 2
  1560. PATH_NOT_FOUND EQU 3
  1561. ;
  1562. ; Program Code
  1563. ;
  1564. BUILD_PATH PROC NEAR
  1565. CLD
  1566. MOV DI,OFFSET FILE_NAME ; Get the offset of the filename
  1567. MOV CX,[BP].PATH_LENGTH ; If path is specified then
  1568. jcxz APPEND_KEYB_SYS
  1569. MOV SI,[BP].PATH_OFFSET ; Get the offset of the path
  1570. REPE MOVSB ; Copy each char of the specified
  1571. MOV AX,3D00H ; Open the KEYBOARD.SYS file
  1572. MOV DX,OFFSET FILE_NAME
  1573. INT 21H
  1574. RET ; path into the filename location
  1575. APPEND_KEYB_SYS:
  1576. MOV SI,OFFSET KEYB_SYS_ACTIVE ; copy name for active directory
  1577. MOV CX,KEYB_SYS_A_LENG ; to file name variable.
  1578. REPE MOVSB
  1579. MOV AX,3D00H ; try to open it.
  1580. MOV DX,OFFSET FILE_NAME
  1581. INT 21H
  1582. jnc opened_ok ; brif no error opening
  1583. cmp ax,PATH_NOT_FOUND ; was it path?
  1584. jz open_err_1
  1585. cmp ax,FILE_NOT_FOUND ; or file not found?
  1586. jnz open_err_2
  1587. open_err_1:
  1588. CALL COPY_ARGV0 ; yes....try ARGV(0) directory.
  1589. MOV AX,3D00H
  1590. MOV DX,OFFSET FILE_NAME
  1591. INT 21H
  1592. jnc opened_ok ; done if open ok
  1593. cmp ax,PATH_NOT_FOUND ; if path or file not found, try root
  1594. jz open_err_3
  1595. cmp ax,FILE_NOT_FOUND
  1596. jnz open_err_2
  1597. open_err_3:
  1598. MOV SI,OFFSET KEYBOARD_SYS ; try ROOT directory.
  1599. MOV DI,OFFSET FILE_NAME
  1600. MOV CX,KEYB_SYS_LENG
  1601. REPE MOVSB
  1602. MOV AX,3D00H
  1603. MOV DX,OFFSET FILE_NAME
  1604. INT 21H
  1605. jmp short opened_ok
  1606. open_err_2:
  1607. stc ; some other error, set error flag
  1608. opened_ok:
  1609. RET
  1610. BUILD_PATH ENDP
  1611. COPY_ARGV0 PROC
  1612. PUSH ES
  1613. PUSH DI
  1614. PUSH SI
  1615. PUSH CX
  1616. MOV DI,2CH ; Locate environment string
  1617. MOV ES,[DI]
  1618. XOR SI,SI
  1619. carv0_loop:
  1620. cmp word ptr es:[si],0 ; find ARGV(0) string
  1621. jz carv0_loop_exit
  1622. inc si
  1623. jmp carv0_loop
  1624. carv0_loop_exit:
  1625. ADD SI,4
  1626. LEA DI,FILE_NAME ; move string to work area
  1627. carv0_loop1:
  1628. MOV AL,ES:[SI]
  1629. MOV [DI],AL
  1630. INC SI
  1631. INC DI
  1632. cmp byte ptr es:[si],0
  1633. jnz carv0_loop1
  1634. carv0_loop2:
  1635. dec di
  1636. cmp byte ptr [di],'\' ; scan back to first character after "\"
  1637. jz carv0_loop2_exit
  1638. cmp byte ptr [di],0
  1639. jnz carv0_loop2
  1640. carv0_loop2_exit:
  1641. INC DI
  1642. PUSH CS
  1643. POP ES
  1644. LEA SI,KEYB_SYS_ACTIVE ; copy in "KEYBOARD.SYS"
  1645. MOV CX,KEYB_SYS_A_LENG
  1646. REPE MOVSB
  1647. POP CX
  1648. POP SI
  1649. POP DI
  1650. POP ES
  1651. RET
  1652. COPY_ARGV0 ENDP
  1653. ;
  1654. ;
  1655. ; Module: FIND_FIRST_CP
  1656. ;
  1657. ; Description:
  1658. ; Check the keyboard definition file for the first code page
  1659. ;
  1660. ; Input Registers:
  1661. ; DS - points to our data segment
  1662. ; ES - points to our data segment
  1663. ; BP - offset of parmeter list
  1664. ;
  1665. ; Output Registers:
  1666. ; NONE
  1667. ;
  1668. ; Logic:
  1669. ; Open the file
  1670. ; IF error in opening file THEN
  1671. ; Display ERROR message and EXIT
  1672. ; ELSE
  1673. ; Save handle
  1674. ; Set address of buffer
  1675. ; READ header of Keyboard definition file
  1676. ; IF error in reading file THEN
  1677. ; Display ERROR message and EXIT
  1678. ; ELSE
  1679. ; Check signature for correct file
  1680. ; IF file signature is correct THEN
  1681. ; READ language table
  1682. ; IF error in reading file THEN
  1683. ; Display ERROR message and EXIT
  1684. ; ELSE
  1685. ; Use table to verify language parm
  1686. ; Set pointer values
  1687. ; IF code page was specified
  1688. ; READ language entry
  1689. ; IF error in reading file THEN
  1690. ; Display ERROR message and EXIT
  1691. ; ELSE
  1692. ; READ first code page
  1693. ; IF error in reading file THEN
  1694. ; Display ERROR message and EXIT
  1695. ; RET
  1696. ;
  1697. ;
  1698. FIND_FIRST_CP PROC NEAR
  1699. PUSH CX ; Save everything that
  1700. PUSH DX ; that will be changed
  1701. PUSH SI
  1702. PUSH DI
  1703. MOV BX,KEYBSYS_FILE_HANDLE ; Get handle
  1704. MOV DX,WORD PTR KEYBCMD_LANG_ENTRY_PTR ; LSEEK file pointer
  1705. MOV CX,WORD PTR KEYBCMD_LANG_ENTRY_PTR+2 ; to top of language entry
  1706. MOV AH,42H
  1707. MOV AL,0 ; If no problem with
  1708. INT 21H ; Keyb Def file Then
  1709. JNC FIND_FIRST_BEGIN
  1710. JMP short FIND_FIRST_CP_ERROR4
  1711. FIND_FIRST_BEGIN:
  1712. MOV DI,AX
  1713. MOV CX,SIZE KEYBSYS_LANG_ENTRY-1 ; Set number
  1714. ; bytes to read header
  1715. MOV DX,OFFSET FILE_BUFFER
  1716. MOV AH,3FH ; Read language entry in
  1717. INT 21H ; keyboard definition file
  1718. JNC FIND_FIRST_VALID4 ; If no error in opening file then
  1719. JMP short FIND_FIRST_CP_ERROR4
  1720. FIND_FIRST_VALID4:
  1721. ;************************** CNS *******;
  1722. xor ah,ah
  1723. MOV Al,FB.KL_NUM_CP
  1724. ;************************** CNS *******;
  1725. MUL CP_PTR_SIZE ; Determine # of bytes to read
  1726. MOV DX,OFFSET FILE_BUFFER ; Establish beginning of buffer
  1727. MOV CX,AX
  1728. CMP CX,SIZE FILE_BUFFER ; Make sure buffer is not to small
  1729. JBE FIND_FIRST_VALID5
  1730. JMP short FIND_FIRST_CP_ERROR4
  1731. FIND_FIRST_VALID5:
  1732. MOV AH,3FH ; Read code page table from
  1733. INT 21H ; keyboard definition file
  1734. JNC FIND_FIRST_VALID6 ; If no error in opening file then
  1735. JMP short FIND_FIRST_CP_ERROR4
  1736. FIND_FIRST_VALID6:
  1737. MOV CX,NUM_CP ; Number of valid codes
  1738. MOV DI,OFFSET FILE_BUFFER ; Point to correct word in table
  1739. MOV BX,[DI].KC_CODE_PAGE ; Get parameter
  1740. XOR AX,AX
  1741. JMP short FIND_FIRST_RETURN
  1742. FIND_FIRST_CP_ERROR4:
  1743. MOV AX,4
  1744. FIND_FIRST_RETURN:
  1745. POP DI
  1746. POP SI
  1747. POP DX
  1748. POP CX
  1749. RET
  1750. FIND_FIRST_CP ENDP
  1751. .xlist
  1752. MSG_SERVICES <MSGDATA>
  1753. MSG_SERVICES <LOADmsg,DISPLAYmsg,CHARmsg,NUMmsg>
  1754. MSG_SERVICES <KEYB.CL1>
  1755. MSG_SERVICES <KEYB.CL2>
  1756. MSG_SERVICES <KEYB.CLA>
  1757. .list
  1758. ;
  1759. ; Temp Shared Data Area
  1760. ; Contains data which is required by
  1761. ; both the resident and transient KEYB code.
  1762. ; All keyboard tables are stored in this area
  1763. ; Structures for this area are in file KEYBSHAR.INC
  1764. ;
  1765. db 'TEMP SHARED DATA'
  1766. SD_SOURCE_PTR LABEL BYTE
  1767. TEMP_SHARED_DATA SHARED_DATA_STR <>
  1768. CODE ENDS
  1769. END