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.

694 lines
26 KiB

  1. PAGE ,132
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;
  4. ; (C) Copyright Microsoft Corp. 1987-1990
  5. ; MS-DOS 5.00 - NLS Support - KEYB Command
  6. ;
  7. ; File Name: KEYBI9.ASM
  8. ; ----------
  9. ;
  10. ; Description:
  11. ; ------------
  12. ; Converts scan codes to ASCII for non-US keyboards.
  13. ; This orutine uses the tables loaded into the SHARED_DATA_AREA
  14. ; from KEYBOARD.SYS by the KEYB_COMMAND module.
  15. ;
  16. ;
  17. ; Procedures Contained in This File:
  18. ; ----------------------------------
  19. ; KEYB_STATE_PROCESSOR - Scan to ASCII translator.
  20. ;
  21. ; External Procedure References:
  22. ; ------------------------------
  23. ; None.
  24. ;
  25. ; Linkage Information: Refer to file KEYB.ASM
  26. ; --------------------
  27. ;
  28. ; Change History:
  29. ; ---------------
  30. ;
  31. ;
  32. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  33. INCLUDE KEYBEQU.INC
  34. INCLUDE DSEG.INC ; System data segments
  35. INCLUDE POSTEQU.INC ; System equates
  36. INCLUDE KEYBSHAR.INC
  37. INCLUDE KEYBI2F.INC
  38. INCLUDE KEYBI9C.INC
  39. INCLUDE KEYBCPSD.INC
  40. INCLUDE KEYBCMD.INC
  41. PUBLIC KEYB_STATE_PROCESSOR
  42. PUBLIC FLAGS_TO_TEST ;; (YST)
  43. PUBLIC NLS_FLAG_1 ;; (YST)
  44. CODE SEGMENT PUBLIC 'CODE'
  45. ASSUME CS:CODE,DS:CODE
  46. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  47. ;
  48. ; Procedure: KEYB_STATE_PROCESSOR
  49. ;
  50. ; Description:
  51. ; Convert scan to ASCII using the tables loaded into the
  52. ; SHARED_DATA_AREA. Conversion is directed by the STATE LOGIC
  53. ; commands contained in the SHARED_DATA_AREA. This routine
  54. ; interprets those commands.
  55. ;
  56. ; Input Registers:
  57. ; N/A
  58. ;
  59. ; Output Registers:
  60. ; N/A
  61. ;
  62. ; Logic:
  63. ; Enable interrupts
  64. ; Save registers
  65. ;
  66. ;
  67. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  68. BREAK_CODE EQU 80H
  69. HOT_KEY_ACTIVE DB 0 ; 1 if hot key is active
  70. ; These are copies of the BIOS FLAGS
  71. FLAGS_TO_TEST LABEL BYTE ; KB_FLAG, KB_FLAG_1,2,3
  72. KB_SHADOW_FLAGS DB NUM_BIOS_FLAGS DUP(0)
  73. EXT_KB_FLAG DB 0 ; Extended KB Flag for shift states
  74. NLS_FLAG_1 DB 0 ; NLS Flags for dead key etc
  75. NLS_FLAG_2 DB 0 ; .
  76. SAVED_NLS_FLAGS DB 0,0 ; Saved copy of the NLS flags
  77. OPTION_BYTE DB 0 ; Set by OPTION command
  78. KB_FLAG_PTRS DW OFFSET KB_FLAG ; These are pointers to the BIOS flags
  79. DW OFFSET KB_FLAG_1 ; we must test
  80. DW OFFSET KB_FLAG_2
  81. DW OFFSET KB_FLAG_3
  82. XLAT_TAB_PTR DW 0 ; pointer to xlat tables for cur state
  83. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  84. NEST_LEVEL DB 0
  85. PROCESS_LEVEL DB 0
  86. TAKE_ELSE DB 0
  87. BUSY_FLAG DB 0 ; Flag to prevent re-entry
  88. CMD_JUMP_TABLE LABEL WORD
  89. DW OFFSET IFF_PROC ; CODE 0
  90. DW OFFSET ANDF_PROC ; 1
  91. DW OFFSET ELSEF_PROC ; 2
  92. DW OFFSET ENDIFF_PROC ; 3
  93. DW OFFSET XLATT_PROC ; 4
  94. DW OFFSET OPTION_PROC ; 5
  95. DW OFFSET SET_FLAG_PROC ; 6
  96. DW OFFSET PUT_ERROR_PROC ; 7
  97. DW OFFSET IFKBD_PROC ; 8
  98. DW OFFSET GOTO_PROC ; 9
  99. DW OFFSET BEEP_PROC ; A
  100. DW OFFSET RESET_NLS_PROC ; B
  101. DW OFFSET RESET_NLS1_PROC ; C
  102. DW OFFSET UNKNOWN_COMMAND ; D
  103. DW OFFSET UNKNOWN_COMMAND ; E
  104. DW OFFSET UNKNOWN_COMMAND ; F
  105. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  106. KEYB_STATE_PROCESSOR PROC NEAR
  107. TEST byte ptr CS:SD.TABLE_OK,1
  108. JNZ WE_HAVE_A_TABLE
  109. CLC ; BACK TO US INT 9
  110. RET
  111. WE_HAVE_A_TABLE:
  112. PUSH DS ; save DS
  113. PUSH ES ; save ES
  114. PUSH AX ; save scan code for caller
  115. PUSH BX ; save shift states for caller
  116. PUSH CS
  117. POP DS ; DS = our seg
  118. MOV BX,DATA
  119. MOV ES,BX ; addressability to BIOS data
  120. CMP COUNTRY_FLAG,0FFH ; Q..country mode?
  121. JE INIT_STATE_PROCESSING ; Y..continue
  122. JMP GOTO_BIOS ; N..exit
  123. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  124. ; -------STATE SECTION PROCESSING-------
  125. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  126. INIT_STATE_PROCESSING:
  127. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  128. ; Set NLS shift flags EITHER_SHIFT, EITHER_ALT, EITHER_CTRL
  129. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  130. ; Q..in shift state?
  131. TEST ES:KB_FLAG,RIGHT_SHIFT+LEFT_SHIFT
  132. JNZ IN_SHIFT_STATE ; Y..go set bit
  133. AND EXT_KB_FLAG,NOT EITHER_SHIFT ; N..clear bit
  134. JMP SHORT TEST_CTL
  135. IN_SHIFT_STATE:
  136. OR EXT_KB_FLAG,EITHER_SHIFT
  137. TEST_CTL:
  138. TEST ES:KB_FLAG,CTL_SHIFT ; Q..in control state?
  139. JNZ IN_CTL_STATE ; Y..go set bit
  140. TEST ES:KB_FLAG_3,R_CTL_SHIFT ; Q..how bout the right ctl?
  141. JNZ IN_CTL_STATE ; Y..go set the bit
  142. AND EXT_KB_FLAG,NOT EITHER_CTL ; N..clear the bit
  143. JMP SHORT TEST_ALT
  144. IN_CTL_STATE:
  145. OR EXT_KB_FLAG,EITHER_CTL
  146. TEST_ALT:
  147. TEST ES:KB_FLAG,ALT_SHIFT ; Q..in alt state?
  148. JNZ IN_ALT_STATE ; Y..go set bit
  149. TEST ES:KB_FLAG_3,R_ALT_SHIFT ; Q..how bout the right alt?
  150. JNZ IN_ALT_STATE ; Y..go set the bit
  151. AND EXT_KB_FLAG,NOT EITHER_ALT ; N..clear the bit
  152. JMP SHORT COPY_FLAGS
  153. IN_ALT_STATE:
  154. OR EXT_KB_FLAG,EITHER_ALT
  155. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  156. ; Copy BIOS KB flags from BIOS data seg into the
  157. ; FLAGS_TO_TEST structure.
  158. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  159. COPY_FLAGS:
  160. MOV CX,NUM_BIOS_FLAGS
  161. xor si,si ; pointers to the BIOS flags
  162. xor di,di ; create shadow copies
  163. MOVE_NEXT_FLAG:
  164. MOV BX,KB_FLAG_PTRS[SI] ; pointer to next flag
  165. MOV AL,ES:[BX] ; flag in AL
  166. MOV KB_SHADOW_FLAGS[DI],AL ; save it in the shadow table
  167. INC DI
  168. INC SI
  169. INC SI
  170. LOOP MOVE_NEXT_FLAG
  171. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  172. ; Interpret State Logic Commands
  173. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  174. PROCESS_STATES:
  175. MOV OPTION_BYTE,0 ; clear options
  176. MOV SI,SD.LOGIC_PTR
  177. LEA SI,[SI].SL_LOGIC_CMDS
  178. NEXT_COMMAND:
  179. XOR BH,BH ; ????
  180. MOV BL,[SI] ; command byte in BL
  181. SHR BL,1
  182. SHR BL,1
  183. SHR BL,1
  184. SHR BL,1 ; ISOLATE COMMAND CODE
  185. SHL BL,1 ; command code * 2
  186. JMP CMD_JUMP_TABLE[BX] ; go process command
  187. UNKNOWN_COMMAND:
  188. JMP FATAL_ERROR ; bad news
  189. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  190. IFKBD_PROC:
  191. MOV AL,NEST_LEVEL
  192. CMP AL,PROCESS_LEVEL ; Q..nest level = process level?
  193. JNE IFKBD_DONE ; N..don't process
  194. MOV AX,[SI+1] ; Keyboard Type Flag
  195. TEST SD.KEYB_TYPE,AX ; Q..are we the right system?
  196. JNZ IFKBD_TEST_OK ; Y..
  197. IFKBD_TEST_FAILED:
  198. MOV TAKE_ELSE,YES ; test failed - take ELSE
  199. JMP SHORT IFKBD_DONE
  200. IFKBD_TEST_OK:
  201. INC PROCESS_LEVEL ; process commands within IF
  202. MOV TAKE_ELSE,NO
  203. IFKBD_DONE:
  204. INC NEST_LEVEL ; IFKBD increments nest level
  205. INC SI ; bump past IFKBD
  206. INC SI
  207. INC SI
  208. JMP NEXT_COMMAND
  209. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  210. PUT_ERROR_PROC:
  211. MOV AL,NEST_LEVEL
  212. CMP AL,PROCESS_LEVEL ; Q..nest level = process level?
  213. JNE PUT_ERROR_DONE ; N..don't process
  214. MOV DI,SD.ACTIVE_XLAT_PTR ; pointer to active Xlat Section
  215. MOV AL,[SI+1] ; state id in AL
  216. CALL PUT_ERROR ; check active section
  217. JC PUT_ERROR_DONE ; carry set if translation found
  218. MOV DI,SD.COMMON_XLAT_PTR ; check common Xlat Section
  219. MOV AL,[SI+1] ; state id for XLATT in AL
  220. CALL PUT_ERROR
  221. PUT_ERROR_DONE:
  222. INC SI
  223. INC SI
  224. JMP NEXT_COMMAND
  225. PUT_ERROR PROC
  226. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  227. ; Search for a state whose ID matches the ID
  228. ; on the PUT_ERROR command
  229. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  230. CLC
  231. LEA DI,[DI].XS_FIRST_STATE ; point to first state in section
  232. PE_NEXT_STATE:
  233. CMP [DI].XS_STATE_LEN,0 ; Q..out of states?
  234. JE PE_EXIT ; Y..exit
  235. CMP AL,[DI].XS_STATE_ID ; Q..is this the requested state?
  236. JE PE_STATE_MATCH
  237. ADD DI,[DI].XS_STATE_LEN ; N..check next state
  238. JMP SHORT PE_NEXT_STATE
  239. PE_STATE_MATCH:
  240. MOV AX,[DI].XS_ERROR_CHAR ; get error char in AX
  241. CALL BUFFER_FILL
  242. STC ; indicate that we found the state
  243. PE_EXIT:
  244. RET
  245. PUT_ERROR ENDP
  246. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  247. GOTO_BIOS:
  248. CLC ; clear carry flag indicating
  249. POP BX ; we should continue INT 9
  250. POP AX ; processing
  251. POP ES
  252. POP DS
  253. RET
  254. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  255. IFF_PROC:
  256. MOV AL,NEST_LEVEL
  257. CMP AL,PROCESS_LEVEL ; Q..nest level = process level?
  258. JNE IFF_DONE ; N..don't process IFF
  259. MOV BL,[SI] ; command byte
  260. AND BL,FLAG_ID_BITS ; isolate flag id
  261. XOR BH,BH
  262. MOV AL,FLAGS_TO_TEST[BX] ; flag in AL
  263. TEST BYTE PTR[SI],NOT_TEST ; Q..is this a NOT test?
  264. JNZ ITS_A_NOT
  265. TEST AL,[SI]+1 ; Y..check for bit set
  266. JNZ IFF_MATCH
  267. JZ IFF_NO_MATCH
  268. ITS_A_NOT:
  269. TEST AL,[SI]+1 ; Y..check for bit clear
  270. JZ IFF_MATCH
  271. IFF_NO_MATCH:
  272. MOV TAKE_ELSE,YES ; flag test failed - take ELSE
  273. JMP SHORT IFF_DONE
  274. IFF_MATCH:
  275. INC PROCESS_LEVEL ; process commands within IF
  276. MOV TAKE_ELSE,NO
  277. IFF_DONE:
  278. INC NEST_LEVEL ; IFF increments nest level
  279. INC SI ; bump past IFF
  280. INC SI
  281. JMP NEXT_COMMAND
  282. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  283. ELSEF_PROC:
  284. MOV AL,PROCESS_LEVEL
  285. CMP AL,NEST_LEVEL ; Q..nest level = process level?
  286. JNE CHECK_TAKE_ELSEF ; N..check for take_else
  287. DEC PROCESS_LEVEL ; Y..we just finished the "IF" block
  288. JMP short ELSEF_DONE ; so we are finished with IFF/ELSEF
  289. CHECK_TAKE_ELSEF:
  290. CMP TAKE_ELSE,YES ; Q..are we scanning for ELSE?
  291. JNE ELSEF_DONE ; N..done
  292. DEC NEST_LEVEL ; ELSEF itself is back a level
  293. CMP AL,NEST_LEVEL ; Q..nest level = process level?
  294. JNE NOT_THIS_ELSEF ; N..this else is not the one
  295. INC PROCESS_LEVEL ; Y..process ELSEF block
  296. MOV TAKE_ELSE,NO ; reset
  297. NOT_THIS_ELSEF:
  298. INC NEST_LEVEL ; stuff within the ELSEF is up a level
  299. ELSEF_DONE:
  300. INC SI ; bump past ELSEF
  301. JMP NEXT_COMMAND
  302. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  303. ENDIFF_PROC:
  304. MOV AL,PROCESS_LEVEL
  305. CMP AL,NEST_LEVEL ; Q..nest level = process level?
  306. JNE ENDIFF_DONE ; N..don't adjust process level
  307. DEC PROCESS_LEVEL ; Y..we just finished the IF/ELSE
  308. ENDIFF_DONE:
  309. DEC NEST_LEVEL ; ENDIF decrements nest level
  310. INC SI ; bump past ENDIF
  311. JMP NEXT_COMMAND
  312. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  313. ; Translations may be in the Common or Specific
  314. ; Sections. Search the Specific section first
  315. ; then the common section.
  316. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  317. XLATT_PROC:
  318. MOV AL,PROCESS_LEVEL
  319. CMP AL,NEST_LEVEL ; Q..nest level = process level?
  320. JNE XLATT_DONE ; N..next command
  321. MOV DI,SD.ACTIVE_XLAT_PTR ; pointer to active Xlat Section
  322. MOV AL,[SI+1] ; state id for XLATT in AL
  323. CALL TRANSLATE ; check active section
  324. JC XLATT_FOUND ; carry set if translation found
  325. MOV DI,SD.COMMON_XLAT_PTR ; check common Xlat Section
  326. MOV AL,[SI+1] ; state id for XLATT in AL
  327. CALL TRANSLATE
  328. JNC XLATT_DONE
  329. XLATT_FOUND:
  330. OR EXT_KB_FLAG,SCAN_MATCH ; set flag indicating scan matched
  331. TEST OPTION_BYTE,EXIT_IF_FOUND ; Q..exit
  332. JZ XLATT_DONE
  333. JMP EXIT ; Y..BYE
  334. XLATT_DONE:
  335. INC SI
  336. INC SI
  337. JMP NEXT_COMMAND
  338. TRANSLATE PROC
  339. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  340. ; Search for a state whose ID matches the ID
  341. ; on the XLATT command
  342. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  343. CLC
  344. LEA DI,[DI].XS_FIRST_STATE ; point to first state in section
  345. TP_NEXT_STATE:
  346. CMP [DI].XS_STATE_LEN,0 ; Q..out of states?
  347. JE TP_EXIT ; Y..exit
  348. CMP AL,[DI].XS_STATE_ID ; Q..is this the requested state?
  349. JE TP_STATE_MATCH
  350. ADD DI,[DI].XS_STATE_LEN ; N..check next state
  351. JMP SHORT TP_NEXT_STATE
  352. TP_STATE_MATCH:
  353. AND EXT_KB_FLAG,NOT SCAN_MATCH ; reset flag before search
  354. PUSH SI ; save pointer to next command
  355. LEA SI,[DI].XS_FIRST_TAB ; point to first xlat table
  356. MOV XLAT_TAB_PTR,SI ; start of XLAT tables
  357. MOV AL,SCAN_CODE ; restore incoming scan code
  358. JMP SHORT NEXT_XLAT_TAB
  359. TP_DONE: ; return here from XLAT
  360. POP SI
  361. TP_EXIT:
  362. RET
  363. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  364. ; Check xlate tables for matching scan code
  365. ; The xlate table can be in one of two forms:
  366. ; Type 1 = Table contains buffer entries only.
  367. ; Scan code is used as an index into xlat table
  368. ; Type 2 = Table contains pairs of SCAN/BUFFER_ENTRY.
  369. ; Table must be searched for matching scan.
  370. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  371. NEXT_XLAT_TAB:
  372. MOV SI,XLAT_TAB_PTR ; pointer to xlat tables
  373. CMP [SI].XLAT_TAB_SIZE,0 ; Q..any more xlat tables?
  374. JNE PROCESS_XLAT_TAB ; Y..check um
  375. JMP TP_DONE ; N..done
  376. PROCESS_XLAT_TAB:
  377. MOV DL,[SI].XLAT_OPTIONS ; save translate options IN DL
  378. MOV BX,[SI].XLAT_TAB_SIZE ; Y..calc pointer to next xlat tab
  379. ADD BX,SI
  380. MOV XLAT_TAB_PTR,BX ; pointer to next xlat tab
  381. TEST DL,TYPE_2_TAB ; Q..is this a type 2 table?
  382. JZ TYPE_1_LOOKUP ; N..go do table lookup
  383. TYPE_2_SEARCH: ; Y..search table
  384. XOR CH,CH
  385. MOV CL,[SI].XLAT_NUM ; number of xlat entries
  386. MOV BX,DEFAULT_TAB_2_ENT_SZ ; default entry size
  387. TEST DL,ASCII_ONLY+ZERO_SCAN ; Q..are buffer entries ASCII only?
  388. JZ NEXT_TAB_2_ENTRY ; N..continue
  389. MOV BX,ASC_ONLY_TAB_2_ENT_SZ ; Y..set size in BX
  390. NEXT_TAB_2_ENTRY: ; entry size is in BX
  391. jcxz next_xlat_tab ; brif last entry
  392. CMP AL,[SI].XLAT_SCAN ; Q..scan match?
  393. JE FOUND_TAB_2_ENTRY ; Y..go create buffer entry
  394. ADD SI,BX ; point to next entry
  395. LOOP NEXT_TAB_2_ENTRY
  396. JMP SHORT NEXT_XLAT_TAB
  397. FOUND_TAB_2_ENTRY: ; Q..set scan code to 0?
  398. MOV AH,AL ; default scan code in AH
  399. MOV AL,[SI].XLAT_2_BUF_ENTRY ; ASCII code from table in AL
  400. TEST DL,ASCII_ONLY+ZERO_SCAN ; Q..are buffer entries ASCII only?
  401. JNZ BUFFER_ENTRY_READY ; Y..buffer entry is ready
  402. MOV AH,[SI].XLAT_2_BUF_ENTRY+1 ; N..scan code from table as well
  403. JMP SHORT BUFFER_ENTRY_READY ; go put entry in buffer
  404. TYPE_1_LOOKUP:
  405. CMP AL,[SI].XLAT_SCAN_LO ; Q..is scan in range of this table?
  406. JB NEXT_XLAT_TAB ; N..next table
  407. CMP AL,[SI].XLAT_SCAN_HI ; Q..is scan in range of this table?
  408. JA NEXT_XLAT_TAB ; N..next table
  409. SUB AL,[SI].XLAT_SCAN_LO ; convert scan code to xlat index
  410. TEST DL,ASCII_ONLY+ZERO_SCAN ; Q..ASCII only in xlat ?
  411. JZ TWO_BYTE_LOOKUP ; N..go do 2-byte lookup
  412. LEA BX,[SI].XLAT_1_BUF_ENTRY ; Y..do 1-byte lookup
  413. XLAT [SI].XLAT_1_BUF_ENTRY ; ASCII code in AL
  414. MOV AH,SCAN_CODE ; SCAN in AH
  415. JMP SHORT BUFFER_ENTRY_READY ; go put entry in buffer
  416. TWO_BYTE_LOOKUP:
  417. MOV BL,2 ; multiply scan index
  418. MUL BL ; by two
  419. MOV BX,AX ; real index in BX
  420. MOV AX,WORD PTR [SI].XLAT_1_BUF_ENTRY[BX] ; get 2-byte buffer entry
  421. ; AL=ASCII AH=SCAN
  422. BUFFER_ENTRY_READY:
  423. TEST DL,ZERO_SCAN ; Q..set scan part to zero?
  424. JZ NO_ZERO_SCAN ; N..
  425. XOR AH,AH ; scan = 0
  426. NO_ZERO_SCAN:
  427. CALL BUFFER_FILL ; go put entry in buffer
  428. STC ; indicate translation found
  429. JMP TP_DONE
  430. TRANSLATE ENDP
  431. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  432. OPTION_PROC:
  433. MOV AL,PROCESS_LEVEL
  434. CMP AL,NEST_LEVEL ; Q..nest level = process level?
  435. JNE DONE_OPTION ; N..done
  436. MOV AL,[SI]+1 ; mask in AL
  437. TEST BYTE PTR[SI],NOT_TEST ; Q..is this a NOT?
  438. JNZ AND_MASK
  439. OR OPTION_BYTE,AL ; N..OR in the mask bits
  440. JMP short DONE_OPTION
  441. AND_MASK:
  442. NOT AL
  443. AND OPTION_BYTE,AL ; Y..AND out the mask bits
  444. DONE_OPTION:
  445. INC SI
  446. INC SI
  447. JMP NEXT_COMMAND
  448. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  449. RESET_NLS_PROC:
  450. MOV AL,NEST_LEVEL
  451. CMP AL,PROCESS_LEVEL ; Q..nest level = process level?
  452. JNE RN_DONE ; N..don't process
  453. MOV NLS_FLAG_1,0
  454. MOV NLS_FLAG_2,0
  455. MOV COPY_NLS1_FLAG,0 ;; (YST)
  456. RN_DONE:
  457. INC SI
  458. JMP NEXT_COMMAND
  459. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  460. ;; This PROC only for Yugoslavian (Cyrillic)
  461. ;; keyboard from CRAZY IBM (YST)
  462. ;;
  463. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  464. RESET_NLS1_PROC: ;;
  465. MOV AL,NEST_LEVEL ;;
  466. CMP AL,PROCESS_LEVEL ;; Q..nest level = process level?
  467. JNE RN1_DONE ;; N..don't process
  468. MOV NLS_FLAG_1, 1 ;;
  469. MOV NLS_FLAG_2,0 ;;
  470. MOV COPY_NLS1_FLAG, 1 ;; (YST)
  471. RN1_DONE: ;;
  472. INC SI ;;
  473. JMP NEXT_COMMAND ;;
  474. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  475. BEEP_PROC:
  476. MOV AL,NEST_LEVEL
  477. CMP AL,PROCESS_LEVEL ; Q..nest level = process level?
  478. JNE BP_DONE ; N..don't process
  479. MOV BEEP_PENDING,YES ; set beep pending flag. the beep
  480. ; will be done just before iret
  481. BP_DONE:
  482. INC SI
  483. JMP NEXT_COMMAND
  484. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  485. GOTO_PROC:
  486. MOV AL,NEST_LEVEL
  487. CMP AL,PROCESS_LEVEL ; Q..nest level = process level?
  488. JNE GOTO_DONE ; N..don't process
  489. MOV BL,[SI] ; command byte in BL
  490. AND BL,NOT COMMAND_BITS ; remove command code
  491. OR BL,BL ; Q..goto label?
  492. JZ GOTO_LABEL ; Y..go jump
  493. CMP BL,EXIT_INT_9_FLAG ; Q..SPECIAL - Exit Int 9?
  494. JNE NOT_EXIT_INT_9 ; N..
  495. JMP EXIT ; Y..bye bye
  496. NOT_EXIT_INT_9:
  497. CMP BL,EXIT_STATE_LOGIC_FLAG ; Q..SPECIAL - Exit State Logic?
  498. JNE NOT_EXIT_S_L ; N..
  499. JMP GOTO_BIOS ; Y..goto bios
  500. NOT_EXIT_S_L:
  501. JMP FATAL_ERROR ; garbage in that command
  502. GOTO_LABEL:
  503. ADD SI,[SI]+1 ; bump by relative offset
  504. MOV PROCESS_LEVEL,0 ; reset process and nest level
  505. MOV NEST_LEVEL,0
  506. GOTO_DONE:
  507. ADD SI,3 ; bump to next command
  508. JMP NEXT_COMMAND
  509. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  510. ANDF_PROC:
  511. MOV AL,NEST_LEVEL
  512. CMP AL,PROCESS_LEVEL ; Q..nest level = process level?
  513. JNE ANDF_DONE ; N..don't process ANDF
  514. MOV BL,[SI] ; command byte
  515. AND BL,FLAG_ID_BITS ; isolate flag id
  516. XOR BH,BH
  517. MOV AL,FLAGS_TO_TEST[BX] ; flag in AL
  518. TEST BYTE PTR[SI],NOT_TEST ; Q..is this a NOT test?
  519. JNZ ANDF_NOT
  520. TEST AL,[SI]+1 ; Y..check for bit set
  521. JNZ ANDF_DONE ; if set then remain in IFF
  522. JZ ANDF_NO_MATCH
  523. ANDF_NOT:
  524. TEST AL,[SI]+1 ; Y..check for bit clear
  525. JZ ANDF_DONE ; if clear then remain in IFF
  526. ANDF_NO_MATCH:
  527. MOV TAKE_ELSE,YES ; flag test failed - take ELSE
  528. DEC PROCESS_LEVEL ; IFF would have inc'd - so dec
  529. ANDF_DONE:
  530. INC SI ; bump past ANDF
  531. INC SI
  532. JMP NEXT_COMMAND
  533. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  534. ; SET_FLAG Command.
  535. ; Flag Table must be in the Common Section
  536. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  537. SET_FLAG_PROC:
  538. MOV AL,NEST_LEVEL
  539. CMP AL,PROCESS_LEVEL ; Q..nest level = process level?
  540. JNE SF_DONE ; N..don't process
  541. MOV DI,SD.COMMON_XLAT_PTR ; check common Xlat Section
  542. MOV AL,[SI+1] ; state id in AL
  543. LEA DI,[DI].XS_FIRST_STATE ; point to first state in section
  544. SF_NEXT_STATE:
  545. CMP [DI].XS_STATE_LEN,0 ; Q..out of states?
  546. JE SF_DONE ; Y..exit
  547. CMP AL,[DI].XS_STATE_ID ; Q..is this the requested state?
  548. JE SF_STATE_MATCH
  549. ADD DI,[DI].XS_STATE_LEN ; N..check next state
  550. JMP SHORT SF_NEXT_STATE
  551. SF_STATE_MATCH:
  552. AND EXT_KB_FLAG,NOT SCAN_MATCH ; reset flag before search
  553. PUSH SI ; save pointer to next command
  554. LEA SI,[DI].XS_FIRST_TAB ; point to table
  555. MOV AL,SCAN_CODE ; restore incoming scan code
  556. MOV CX,[SI] ; number of entries
  557. jcxz sf_restore ; done if no entries
  558. INC SI ; Y..Bump to first entry
  559. INC SI
  560. NEXT_SF_ENTRY:
  561. CMP AL,[SI] ; Q..scan match?
  562. JE FOUND_SF_ENTRY ; Y..go set flag
  563. ADD SI,3 ; point to next entry
  564. LOOP NEXT_SF_ENTRY
  565. JMP SHORT SF_RESTORE ; no match found
  566. FOUND_SF_ENTRY:
  567. MOV NLS_FLAG_1,0 ; clear all NLS bits
  568. MOV NLS_FLAG_2,0
  569. MOV BL,[SI]+1 ; flag id in BX
  570. XOR BH,BH
  571. MOV AL,[SI]+2 ; mask in AL
  572. OR FLAGS_TO_TEST[BX],AL ; set the bit
  573. OR EXT_KB_FLAG,SCAN_MATCH ; set flag indicating scan matched
  574. MOV AL,NLS_FLAG_1 ;; copy NLS_FLAG_1 to the (YST)
  575. MOV COPY_NLS1_FLAG,AL ;; public place (YST)
  576. TEST OPTION_BYTE,EXIT_IF_FOUND ; Q..exit
  577. JZ SF_RESTORE
  578. POP SI
  579. JMP short EXIT
  580. SF_RESTORE:
  581. POP SI
  582. SF_DONE:
  583. INC SI ; bump past command
  584. INC SI
  585. JMP NEXT_COMMAND
  586. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  587. ; Fatal Error routine. Come here when
  588. ; we have a critical error such as an
  589. ; invalid State Logic Command.
  590. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  591. FATAL_ERROR:
  592. JMP SHORT EXIT ; end the int 9 processing
  593. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  594. ; Exit point.
  595. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  596. EXIT:
  597. MOV BUSY_FLAG,NO
  598. STC ; indicate we should end INT 9
  599. POP BX ; processing
  600. POP AX
  601. POP ES
  602. POP DS
  603. RET
  604. KEYB_STATE_PROCESSOR ENDP
  605. CODE ENDS
  606. END