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.

1106 lines
30 KiB

  1. ;========================================================================
  2. ;
  3. ; PRINTER DRIVER program
  4. ;
  5. ;========================================================================
  6. ASSUME CS:CODE,DS:CODE,ES:CODE
  7. ; *** SUPPORTED PRINTER ***
  8. ;
  9. ; (WS)
  10. ; 1. KS printer
  11. ; 2. Qnix LBP
  12. ; 3. KSSM
  13. ; (CH)
  14. ; 4. Qnix printer
  15. ; 5. Qnix LBP
  16. ; 6. TG
  17. ; 7. KSSM
  18. ;
  19. ; concept
  20. ;
  21. ; 1. WanSung code system 80h - feh
  22. ; check MSB(1st/2nd byte)
  23. ; check ESC code
  24. ;
  25. ; 2. ChoHab code system 40h - ffh
  26. ; check MSB(1st byte), check range(>3FH, 2nd byte)
  27. ; check ESC code
  28. ;
  29. ; 3. ChoHab 7 bit code system 21h - 7eh
  30. ; check code range(1st/2nd byte)
  31. ; check ESC code
  32. TblEnd = -1
  33. FsKey = 1ch
  34. ; PrtAuto
  35. AutoNor = 00h ; 00h, 01h ; have no
  36. AutoEsc = 01h ; 00h, 02h, 03h, 04h ; have ESC/FS
  37. ; 06h, 08h, 0ah, 0bh, 0ch, 0dh, 0eh, 0fh
  38. Auto3 = 02h ; 00h ; spend 1 byte
  39. Auto4 = 03h ; 05h ; spend 2 byte
  40. AutoV1 = 04h ; 00h, 06h, 08h ; spend n+1 byte
  41. AutoVCnt = 05h ; 00h ; spend n byte
  42. AutoV1stx1 = 06h ; 07h ; have 1st counter
  43. AutoV2ndx1 = 07h ; 05h ; have 2nd counter
  44. AutoV1stx3 = 08h ; 09h ; have 1st counter
  45. AutoV2ndx3 = 09h ; 05h ; have 2nd counter
  46. AutoNull = 0ah ; 00h, 0ah ; spend until null.
  47. AutoEng = 0bh ; 00h, 0bh ; spend until eng-char
  48. AutoEngLow = 0ch ; 00h, 0ch ; spend until eng-low-char
  49. Auto74 = 0dh ; 05h ; spend 74 byte
  50. Auto5 = 0eh ; 05h ; spend 5 byte
  51. Auto8 = 0fh ; 05h ; spend 8 byte
  52. Auto3Cnt = 10h ; 05h ; spend 3 byte
  53. Auto78 = 11h ; 05h ; spend 78 byte
  54. AutoEnd = 12h
  55. PrtAuto db 0 ; automata variable
  56. CharCnt dw 0 ; ESC control char counter
  57. HanCnt db 0 ; 2 byte char counter
  58. Han1stCode db 0 ; 1 st char code
  59. EscCode2Addr dw 0
  60. EscCode3Addr dw 0
  61. EscCodeNAddr dw 0
  62. EscCode4Addr dw 0
  63. public Int17
  64. Int17:
  65. or ah,ah
  66. jnz SkipNew17
  67. test cs:[CodeStat],HangeulMode
  68. jz SkipNew17 ; jump if english print
  69. @push bx,cx,dx,si,di,es,ds,bp
  70. mov bx,cs
  71. mov ds,bx
  72. mov es,bx
  73. mov bl,[PrtAuto]
  74. cmp bl,AutoEnd
  75. jb @f
  76. xor bl,bl
  77. mov [PrtAuto],bl
  78. @@:
  79. xor bh,bh
  80. shl bx,1
  81. add bx,offset PioJumpTbl
  82. call [bx]
  83. mov ah,0 ; assume write char.
  84. jnc @f
  85. mov ah,2 ; get status.
  86. @@:
  87. @pop bp,ds,es,di,si,dx,cx,bx
  88. SkipNew17:
  89. jmp cs:[OldInt17]
  90. PioJumpTbl label word
  91. dw offset sAutoNor ; 0
  92. dw offset sAutoEsc ; 1
  93. dw offset sAuto3 ; 2
  94. dw offset sAuto4 ; 3
  95. dw offset sAutoV1 ; 4
  96. dw offset sAutoVCnt ; 5
  97. dw offset sAutoV1stx1 ; 6
  98. dw offset sAutoV2ndx1 ; 7
  99. dw offset sAutoV1stx3 ; 8
  100. dw offset sAutoV2ndx3 ; 9
  101. dw offset sAutoNull ; a
  102. dw offset sAutoEng ; b
  103. dw offset sAutoEngLow ; c
  104. dw offset sAuto74 ; d
  105. dw offset sAuto5 ; e
  106. dw offset sAuto8 ; f
  107. dw offset sAuto3Cnt ; 10
  108. dw offset sAuto78 ; 11
  109. ;========================================================================
  110. sAutoNor: ; 0
  111. ; FUNCTION = check ESC code, code range, convert code if need.
  112. ; check 1st/2nd byte code.
  113. ; AUTO = 0, 1
  114. cmp al,EscKey
  115. jz @f
  116. cmp al,FsKey
  117. jz @f
  118. cmp al,' '
  119. jbe NorEnd
  120. call ChkRange
  121. jc NorEnd
  122. call ChgCodeTy
  123. ret
  124. @@:
  125. mov bl,[Printer]
  126. and bl,not ChPrinter
  127. cmp bl,wKmPrt
  128. jnz NorEnd
  129. mov [PrtAuto],AutoEsc
  130. cmp al,EscKey
  131. jnz @f ; jump if "FS" code
  132. mov [EscCode2Addr],offset KmEscCode2
  133. mov [EscCode3Addr],offset KmEscCode3
  134. mov [EscCodeNAddr],offset KmEscCodeN
  135. mov [EscCode4Addr],offset KmEscCode4
  136. jmp short NorEnd
  137. @@:
  138. mov [EscCode2Addr],offset KmFsCode2
  139. mov [EscCode3Addr],offset KmFsCode3
  140. mov [EscCodeNAddr],offset KmFsCodeN
  141. mov [EscCode4Addr],offset KmFsCode4
  142. NorEnd:
  143. cmp [HanCnt],0
  144. jz @f
  145. mov [HanCnt],0
  146. mov bl,al
  147. mov al,[Han1stCode]
  148. xor ah,ah
  149. pushf
  150. call [OldInt17] ; print a char.
  151. mov al,bl
  152. @@:
  153. clc
  154. ret
  155. ;========================================================================
  156. ; << sAutoEsc >>
  157. ; FUNCTION = search 2nd ESC code, send 1st byte if saved.
  158. ; AUTO = 0, 2, 3, 4, 6, 8, a, b, c, d, e, f
  159. sAutoEsc: ; 1
  160. mov si,[EscCode2Addr]
  161. call SearchEscCode1
  162. mov ah,0
  163. jc @f ; jump if found.
  164. mov si,[EscCode3Addr]
  165. call SearchEscCode1
  166. mov ah,Auto3
  167. jc @f ; jump if found.
  168. mov si,[EscCodeNAddr]
  169. call SearchEscCode2
  170. jc @f ; jump if found.
  171. mov [PrtAuto],AutoNor
  172. jmp sAutoNor
  173. @@:
  174. mov [PrtAuto],ah
  175. clc
  176. ret
  177. ;========================================================================
  178. ; << sAuto3 >>
  179. ; FUNCTION = return to normal.
  180. ; AUTO = 0
  181. sAuto3: ; 2
  182. mov [PrtAuto],AutoNor
  183. clc
  184. ret
  185. ;========================================================================
  186. ; << sAuto4 >>
  187. ; FUNCTION = go to sAutoVCnt for spend 1 byte.
  188. ; AUTO = 8
  189. sAuto4: ; 3
  190. mov [CharCnt],1
  191. mov [PrtAuto],AutoV1stx3
  192. clc
  193. ret
  194. ;========================================================================
  195. ; << sAutoV1 >>
  196. ; FUNCTION = check 3rd ESC code
  197. ; AUTO = 0, 6, 8
  198. sAutoV1: ; 4
  199. mov si,[EscCode4Addr]
  200. call SearchEscCode2
  201. jnc @f ; jump if not found.
  202. mov [PrtAuto],ah
  203. clc
  204. ret
  205. @@:
  206. mov [PrtAuto],AutoNor
  207. ret
  208. ;========================================================================
  209. ; << sAutoVCnt >>
  210. ; FUNCTION = spend n char.
  211. ; AUTO = 0
  212. sAutoVCnt: ; 5
  213. dec [CharCnt]
  214. jnz @f
  215. mov [PrtAuto],AutoNor
  216. @@:
  217. clc
  218. ret
  219. ;========================================================================
  220. ; << sAutoV1stx1 >>
  221. ; FUNCTION = save 1st counter.
  222. ; AUTO = 7
  223. sAutoV1stx1: ; 6
  224. xor ah,ah
  225. mov [CharCnt],ax
  226. mov [PrtAuto],AutoV2ndx1
  227. clc
  228. ret
  229. ;========================================================================
  230. ; << sAutoV2ndx1 >>
  231. ; FUNCTION = save 2nd counter, calc size(*1).
  232. ; AUTO = 5
  233. sAutoV2ndx1: ; 7
  234. mov cl,al
  235. mov bx,[CharCnt]
  236. mul bx
  237. mov [CharCnt],ax
  238. mov al,cl
  239. mov [PrtAuto],AutoVCnt
  240. clc
  241. ret
  242. ;========================================================================
  243. ; << sAutoV1stx3 >>
  244. ; FUNCTION = save 1st counter.
  245. ; AUTO = 9
  246. sAutoV1stx3: ; 8
  247. xor ah,ah
  248. mov [CharCnt],ax
  249. mov [PrtAuto],AutoV2ndx3
  250. clc
  251. ret
  252. ;========================================================================
  253. ; << sAutoV2ndx3 >>
  254. ; FUNCTION = save 2nd counter, calc size(*3).
  255. ; AUTO = 5
  256. sAutoV2ndx3: ; 9
  257. mov cl,al
  258. mov bx,[CharCnt]
  259. mul bx
  260. mov bl,3
  261. mul bx
  262. mov [CharCnt],ax
  263. mov al,cl
  264. mov [PrtAuto],AutoVCnt
  265. clc
  266. ret
  267. ;========================================================================
  268. ; << sAutoNull >>
  269. ; FUNCTION = spend until null.
  270. ; AUTO = 0
  271. sAutoNull: ; a
  272. or al,al
  273. jnz @f
  274. mov [PrtAuto],AutoNor
  275. @@:
  276. clc
  277. ret
  278. ;========================================================================
  279. ; << sAutoEng >>
  280. ; FUNCTION = spend until english char.
  281. ; AUTO = 0
  282. sAutoEng: ; b
  283. mov ah,al
  284. or ah,20h ; make low char.
  285. cmp ah,'a'
  286. jb @f
  287. cmp ah,'z'
  288. ja @f
  289. mov [PrtAuto],AutoNor
  290. @@:
  291. clc
  292. ret
  293. ;========================================================================
  294. ; << sAutoEngLow >>
  295. ; FUNCTION = spend until english low char.
  296. ; AUTO = 0
  297. sAutoEngLow: ; c
  298. cmp al,'a'
  299. jb @f
  300. cmp al,'z'
  301. ja @f
  302. mov [PrtAuto],AutoNor
  303. @@:
  304. clc
  305. ret
  306. ;========================================================================
  307. ; << sAuto74 >>
  308. ; FUNCTION = set counter to 73.
  309. ; AUTO = 5
  310. sAuto74: ; d
  311. mov [HanCnt],73
  312. mov [PrtAuto],AutoVCnt
  313. clc
  314. ret
  315. ;========================================================================
  316. ; << sAuto5 >>
  317. ; FUNCTION = set counter to 4.
  318. ; AUTO = 5
  319. sAuto5: ; e
  320. mov [HanCnt],4
  321. mov [PrtAuto],AutoVCnt
  322. clc
  323. ret
  324. ;========================================================================
  325. ; << sAuto8 >>
  326. ; FUNCTION = set counter to 7.
  327. ; AUTO = 5
  328. sAuto8: ; f
  329. mov [HanCnt],7
  330. mov [PrtAuto],AutoVCnt
  331. clc
  332. ret
  333. ;========================================================================
  334. ; << sAuto3Cnt >>
  335. ; FUNCTION = set counter to 2.
  336. ; AUTO = 5
  337. sAuto3Cnt: ; 10
  338. mov [HanCnt],2
  339. mov [PrtAuto],AutoVCnt
  340. clc
  341. ret
  342. ;========================================================================
  343. ; << sAuto78 >>
  344. ; FUNCTION = set counter to 73.
  345. ; AUTO = 5
  346. sAuto78: ; 11
  347. mov [HanCnt],78
  348. mov [PrtAuto],AutoVCnt
  349. clc
  350. ret
  351. ;------------------------------------------------------------------------
  352. ChkRange:
  353. test [CodeStat],Chab
  354. jz @f
  355. call ChkRangeCh
  356. jmp short ChkEnd
  357. ;@@:
  358. ; test [CodeStat],Wsung7
  359. ; jz @f
  360. ; call ChkRangeCh7
  361. ; jmp short ChkEnd
  362. @@:
  363. call ChkRangeWs
  364. ChkEnd:
  365. ret
  366. ChkRangeWs:
  367. test [Printer],ChPrinter
  368. jz @f ; jump if code == printer type
  369. call CheckCodeRange1st
  370. ret
  371. @@:
  372. stc ; out range
  373. ret
  374. ChkRangeCh:
  375. test [Printer],ChPrinter
  376. jnz @b ; jump if code == printer type
  377. cmp [HanCnt],0
  378. jnz @f
  379. call CheckCodeRange1st
  380. ret
  381. @@:
  382. mov ah,[Han1stCode]
  383. call CheckCodeRangeword
  384. ret
  385. ChkRangeCh7:
  386. cmp [HanCnt],0
  387. jnz @f
  388. call CheckCodeRange1st
  389. ret
  390. @@:
  391. mov ah,[Han1stCode]
  392. call CheckCodeRangeword
  393. ret
  394. ;------------------------------------------------------------------------
  395. ChgCodeTy:
  396. cmp [HanCnt],0
  397. jnz @f
  398. mov [Han1stCode],al
  399. inc [HanCnt]
  400. stc ; does not print char.
  401. ret
  402. @@:
  403. mov [HanCnt],0
  404. mov ah,[Han1stCode]
  405. mov cx,ax ; save code
  406. push cx
  407. push dx
  408. test [Printer],ChPrinter
  409. jnz ChoHabPrt
  410. test [CodeStat],Chab
  411. jz @f
  412. call ChgCh2Ks
  413. jmp short ChgEnd
  414. @@:
  415. ; test [CodeStat],Wsung7
  416. ; jz ChgEnd
  417. ; call ChgCh72Ks
  418. ; jmp short ChgEnd
  419. ChoHabPrt:
  420. ; test [CodeStat],Wsung7
  421. ; jnz @f
  422. test [CodeStat],Chab
  423. jnz ChgEnd
  424. call ChgKs2Ch
  425. jmp short ChgEnd
  426. ;@@:
  427. ; call ChgCh72Ks
  428. ; jc ChgEnd
  429. ; call ChgKs2Ch
  430. ChgEnd:
  431. pop dx
  432. pop cx
  433. jc @f
  434. mov bx,ax
  435. mov al,bh ; print 1st byte
  436. xor ah,ah
  437. pushf
  438. call [OldInt17] ; print a char.
  439. mov al,bl ; set 2nd byte
  440. clc
  441. ret
  442. @@:
  443. mov al,ch
  444. xor ah,ah
  445. pushf
  446. call [OldInt17] ; print a char.
  447. mov al,cl
  448. ; test [CodeStat],Wsung7
  449. ; jz @f
  450. ; call ChkRange ; It's ChoHab 7 bit code system only.
  451. ; jnc @f
  452. ; mov [Han1stCode],al
  453. ; inc [HanCnt]
  454. ; stc ; does not print char.
  455. clc
  456. @@:
  457. ret
  458. ;------------------------------------------------------------------------
  459. SearchEscCode1:
  460. mov bl,al
  461. @@:
  462. lodsb
  463. cmp al,TblEnd
  464. jz @f
  465. cmp al,bl
  466. jnz @b
  467. stc ; found
  468. @@:
  469. mov al,bl
  470. ret
  471. ;------------------------------------------------------------------------
  472. SearchEscCode2:
  473. mov bl,al
  474. @@:
  475. lodsw
  476. cmp al,TblEnd
  477. jz @f
  478. cmp al,bl
  479. jnz @b
  480. stc ; found
  481. @@:
  482. mov al,bl
  483. ret
  484. EscCode2Tbl label word
  485. dw offset KsEscCode2
  486. dw offset LbpEscCode2
  487. dw offset KmEscCode2
  488. dw 0
  489. dw 0
  490. dw 0
  491. dw offset KmEscCode2
  492. dw offset TgEscCode2
  493. EscCode3Tbl label word
  494. dw offset KsEscCode3
  495. dw offset LbpEscCode3
  496. dw offset KmEscCode3
  497. dw 0
  498. dw 0
  499. dw 0
  500. dw offset KmEscCode3
  501. dw offset TgEscCode3
  502. EscCodeNTbl label word
  503. dw offset KsEscCodeN
  504. dw offset LbpEscCodeN
  505. dw offset KmEscCodeN
  506. dw 0
  507. dw 0
  508. dw 0
  509. dw offset KmEscCodeN
  510. dw offset TgEscCodeN
  511. EscCode4Tbl label word
  512. dw offset KsEscCode4
  513. dw offset LbpEscCode4
  514. dw offset KmEscCode4
  515. dw 0
  516. dw 0
  517. dw 0
  518. dw offset KmEscCode4
  519. dw offset TgEscCode4
  520. KsEscCode2 label byte
  521. db '01267<EFGH',TblEnd
  522. KsEscCode3 label byte
  523. db '-3ACJUWcdhimqruwxyz',TblEnd
  524. KsEscCodeN label byte
  525. db 't', Auto4
  526. db 'K', AutoV1stx1
  527. db 'L', AutoV1stx1
  528. db 'n', AutoV1stx3
  529. db 'D', AutoNull
  530. KsEscCode4 label byte
  531. db TblEnd
  532. ChEscCode2 label byte
  533. db '01267<EFGHMPTqy',TblEnd
  534. ChEscCode3 label byte
  535. db '-3ACJQSUWbcfghimprsvl',TblEnd
  536. ChEscCodeN label byte
  537. db 'R', Auto4
  538. db '*', AutoV1
  539. db 't', Auto3Cnt
  540. db 'K', AutoV1stx1
  541. db 'L', AutoV1stx1
  542. db 'Y', AutoV1stx1
  543. db 'k', AutoV1stx3
  544. db 'D', AutoNull
  545. db TblEnd
  546. ChEscCode4 label byte
  547. db 'p', AutoV1stx1
  548. db '!', AutoV1stx3
  549. db TblEnd
  550. TgEscCode2 label byte
  551. db 'heWwIiDLdNjk6c7GgUuFfBbSsVv'
  552. TgEscCode3 label byte
  553. db TblEnd
  554. TgEscCodeN label byte
  555. db 'T',Auto3Cnt
  556. db '[',AutoV1
  557. db TblEnd
  558. TgEscCode4 label byte
  559. db 'M',Auto4
  560. db 'm',AutoNor
  561. db 'R',AutoNor
  562. db 'r',AutoNor
  563. db TblEnd
  564. KmEscCode2 label byte
  565. db 'O01267MPTg45EFGH@<',0fh,0eh,TblEnd
  566. KmEscCode3 label byte
  567. db 'CNQl3A/JRSkptx% a-w!WqUdr',19h,TblEnd
  568. KmEscCodeN label byte
  569. db '$', Auto4
  570. db 'C', Auto4
  571. db '\', Auto4
  572. db ' ', Auto4
  573. db '?', Auto4
  574. db ':', Auto5
  575. db '(', Auto8
  576. db '*', AutoV1
  577. db 'K', AutoV1stx1
  578. db 'L', AutoV1stx1
  579. db 'Y', AutoV1stx1
  580. db 'Z', AutoV1stx1
  581. db 'B', AutoNull
  582. db 'D', AutoNull
  583. db 'b', AutoNull
  584. db TblEnd
  585. KmEscCode4 label byte
  586. db 0, AutoV1stx1
  587. db 1, AutoV1stx1
  588. db 2, AutoV1stx1
  589. db 3, AutoV1stx1
  590. db 4, AutoV1stx1
  591. db 6, AutoV1stx1
  592. db 32, AutoV1stx3
  593. db 33, AutoV1stx3
  594. db 38, AutoV1stx3
  595. db 39, AutoV1stx3
  596. db 40, AutoV1stx3
  597. db TblEnd
  598. KmFsCode2 label byte
  599. db 'JK&.UV ',0fh,12h,0eh,14h,TblEnd
  600. KmFsCode3 label byte
  601. db '$a!-WXvkrtx ',TblEnd
  602. KmFsCodeN label byte
  603. db 'D', Auto4
  604. db 'M', Auto4
  605. db 'S', Auto4
  606. db 'T', Auto4
  607. db '&', Auto78
  608. db '2', Auto74
  609. KmFsCode4 label byte
  610. db TblEnd
  611. LbpEscCode2 label byte
  612. db '@SJKBbRrUuWwMmDdIi'
  613. LbpEscCode3 label byte
  614. db TblEnd
  615. LbpEscCodeN label byte
  616. db '[', AutoEng ; ESC "[" ____ ENGLISH-char
  617. db '(', AutoEngLow ; ESC "(" ____ ENGLISH-low-char
  618. db ')', AutoEngLow ; ESC ")" ____ ENGLISH-low-char
  619. LbpEscCode4 label byte
  620. db TblEnd
  621. ;========================================================================
  622. ;
  623. ; CODE CONVERSION program
  624. ;
  625. ;========================================================================
  626. ASSUME CS:CODE,DS:CODE,ES:CODE
  627. EXTRN ChHgWTbl:byte, ChHgWLng:word, ChHgCTbl:byte, ChHgIndexTbl:word
  628. EXTRN ah88h:byte
  629. ;========================================================================
  630. ; << ChgCh2Ks >>
  631. ; FUNCTION = Code convertion ChoHab to WanSung in HanJa/Grp/Hangeul
  632. ;
  633. ; RANGE :
  634. ; 84-d3, 41h-7eh 81h-feh (ѱ)
  635. ; d9-de, 31h-7eh 91h-feh (Ÿ)
  636. ; e0-f9, 31h-7eh 91h-feh ()
  637. ; d8, 31h-7eh 91h-feh (udc)
  638. ;
  639. ; Code array : 88 ...... 61 00 = B0A1
  640. ; | | B0A2
  641. ; FD BF :
  642. ; 89 ...... 41 C0 :
  643. ; | |
  644. ; B7 17F
  645. ; 90 ...... 61 180
  646. ; | | |
  647. ; | | |
  648. ; D3 B7
  649. ;
  650. ; INPUT : AX=Էcode
  651. ; OUTPUT : if CY=fail
  652. ; if NC=success, AX=ȯ code, BX=Էcode
  653. EXTRN Ch2Ks:near
  654. PUBLIC ChgCh2Ks
  655. ChgCh2Ks:
  656. @push cx,dx,si,di,es,ds,bp
  657. push ax
  658. mov bx,cs
  659. mov ds,bx
  660. mov es,bx
  661. mov di,ax
  662. ChHgKs:
  663. cmp ah,084h
  664. jb ChgCh2KsErr
  665. cmp ah,0d3h
  666. ja ChHjKs
  667. cmp al,41h ; 41h - 7eh, 81h - feh
  668. jb ChgCh2KsErr
  669. cmp al,0feh
  670. ja ChgCh2KsErr
  671. cmp al,07eh
  672. jbe @f
  673. cmp al,81h
  674. jb ChgCh2KsErr
  675. @@:
  676. jmp Ch2KsHg
  677. ChHjKs:
  678. cmp al,31h ; 31h - 7eh, 91h - feh
  679. jb ChgCh2KsErr
  680. cmp al,0feh
  681. ja ChgCh2KsErr
  682. cmp al,07eh
  683. jbe @f
  684. cmp al,91h
  685. jb ChgCh2KsErr
  686. @@:
  687. cmp ah,0d8h
  688. jz ChUdcKs
  689. cmp ah,0d9h ; d9h - deh
  690. jb ChgCh2KsErr
  691. cmp ah,0deh
  692. ja @f
  693. jmp Ch2KsHj
  694. @@:
  695. cmp ah,0e0h ; e0h - f9h
  696. jb ChgCh2KsErr
  697. cmp ah,0f9h
  698. ja ChgCh2KsErr
  699. jmp Ch2KsHj2
  700. ChgCh2KsErr:
  701. jmp PostSetRegErr
  702. Ch2KsHg:
  703. call Ch2Ks
  704. jmp PostSetReg
  705. ChUdcKs:
  706. cmp al,07eh
  707. ja @f
  708. sub ax,00e90h
  709. jmp PostSetRegSuc
  710. @@:
  711. cmp al,0a1h
  712. jae @f
  713. sub ax,00ea2h
  714. jmp PostSetRegSuc
  715. @@:
  716. mov ah,0feh
  717. jmp PostSetRegSuc
  718. Ch2KsHj:
  719. mov bx,ax
  720. sub bh,0d9h-0a1h
  721. sub bh,0a1h
  722. shl bh,1
  723. add bh,0a1h
  724. jmp @f
  725. Ch2KsHj2:
  726. mov bx,ax
  727. sub bh,0e0h-0cah
  728. sub bh,0cah
  729. shl bh,1
  730. add bh,0cah
  731. @@:
  732. inc bh
  733. cmp al,0a1h
  734. jae @f
  735. dec bh
  736. add bl,0a1h-31h
  737. cmp al,7eh
  738. jbe @f
  739. mov bl,al
  740. add bl,0efh-91h
  741. @@:
  742. mov ax,bx
  743. jmp PostSetRegSuc
  744. ;========================================================================
  745. ; << ChgKs2Ch >>
  746. ; FUNCTION = Code conversion Wansung to Chohab in HanJa/Grp/hanguel
  747. ;
  748. ; RANGE : A4A1 - A4D3(Hangeul Component)
  749. ; A1A1 - ABF6(Graphics)
  750. ; B0A1 - C8FE(Hangeul)
  751. ; CAA1 - FDFE(Hanja)
  752. ;
  753. ; Code array : 88 ...... 61 00 = B0A1
  754. ; | | B0A2
  755. ; FD BF :
  756. ; 89 ...... 41 C0 :
  757. ; | |
  758. ; B7 17F
  759. ; 90 ...... 61 180
  760. ; | | |
  761. ; | | |
  762. ; D3 B7
  763. ;
  764. ; INPUT : AX=Էcode
  765. ; OUTPUT : if CY=fail
  766. ; if NC=success, AX=ȯ code, BX=Էcode
  767. EXTRN Ks2Ch:near
  768. PUBLIC ChgKs2Ch
  769. ChgKs2Ch:
  770. @push cx,dx,si,di,es,ds,bp
  771. push ax
  772. mov bx,cs
  773. mov ds,bx
  774. mov es,bx
  775. mov di,ax
  776. @@:
  777. cmp al,0a1h
  778. jb isnotJH
  779. cmp al,0feh
  780. ja isnotJH
  781. cmp ah,0a1h
  782. jb isnotJH
  783. cmp ah,0feh
  784. ja isnotJH
  785. cmp ah,0ach
  786. ja @f
  787. jmp Ks2ChGrp
  788. @@:
  789. cmp ah,0b0h
  790. jb isnotJH
  791. cmp ah,0c8h
  792. ja @f
  793. jmp Ks2ChHg
  794. @@:
  795. cmp ah,0feh
  796. jne @f
  797. mov ah,0d8h
  798. jmp PostSetRegSuc
  799. @@:
  800. cmp ah,0c9h
  801. ja Ks2ChHj
  802. cmp al,0eeh
  803. jbe @f
  804. add ax,00012h
  805. @@:
  806. add ax,00e90h
  807. jmp PostSetRegSuc
  808. isnotJH:
  809. jmp PostSetRegErr
  810. Ks2ChHgComp:
  811. Ks2ChHg:
  812. call Ks2Ch
  813. jmp PostSetReg
  814. Ks2ChGrp:
  815. mov bx,ax
  816. sub bh,0a1h
  817. shr bh,1
  818. add bh,0a1h
  819. add bh,0d9h-0a1h
  820. xor ah,1
  821. jmp short @f
  822. Ks2ChHj:
  823. mov bx,ax
  824. sub bh,0cah
  825. shr bh,1
  826. add bh,0cah
  827. add bh,0e0h-0cah
  828. @@:
  829. test ah,1
  830. jnz @f
  831. sub bl,0a1h-31h
  832. cmp al,0eeh
  833. jb @f
  834. mov bl,al
  835. sub bl,0efh-91h
  836. @@:
  837. mov ax,bx
  838. jmp PostSetRegSuc
  839. ;========================================================================
  840. ; << ChgCh72Ks >>
  841. ; FUNCTION = Code conversion Chohab7 to Wansung in Hangule
  842. ;
  843. ; RANGE : B0A1 - C8FE(Hanguel)
  844. ;
  845. ; Code array : 00 B0A1
  846. ; | |
  847. ; 5D B0FE
  848. ; 5E B1A1
  849. ; | |
  850. ; BB B1FE
  851. ; BC B2A1
  852. ; | |
  853. ;
  854. ; C8FE
  855. ;
  856. ; INPUT : AX=Էcode
  857. ; OUTPUT : if CY=fail
  858. ; if NC=success, AX=ȯ code, BX=Էcode
  859. EXTRN LinearWordSearch:near, LinearByteSearch:near
  860. PUBLIC ChgCh72Ks
  861. ChgCh72Ks:
  862. @push cx,dx,si,di,es,ds,bp
  863. push ax
  864. mov bx,cs
  865. mov ds,bx
  866. mov es,bx
  867. cmp ax,5f21h
  868. jb isnotJ7Wan
  869. cmp ax,5f54h
  870. ja @f
  871. mov si,offset Ch7HgETbl
  872. mov cx,ChHgWLng+1
  873. mov di,offset ChHgWTbl
  874. mov dh,0a4h
  875. jmp GetCodeInUnSort2
  876. @@:
  877. mov di,ax
  878. cmp ax,7e7eh
  879. ja isnotJ7Wan
  880. sub ah,05Fh
  881. mov si,offset Ch7HgTbl
  882. xor dx,dx
  883. xor bx,bx
  884. xor cx,cx
  885. mov bl,ah
  886. mov cl,bl
  887. shl bx,1
  888. add bx,cx
  889. cmp ah,0
  890. jz short @f
  891. mov dx,[si+bx+1]
  892. mov cx,[si+1]
  893. sub dx,cx
  894. @@:
  895. xor ch,ch
  896. mov cl,[si+bx]
  897. mov si,[si+bx+1]
  898. call LinearByteSearch
  899. jc short @f
  900. mov ax,bx
  901. add ax,dx
  902. mov bl,05eh
  903. div bl
  904. xchg ah,al
  905. add ax,0B0A1h
  906. jmp PostSetRegSuc
  907. @@:
  908. mov ax,di
  909. cmp ah,07eh
  910. jnz isnotJ7Wan
  911. mov si,offset Ch7HgCTbl
  912. mov cx,Ch7HgCLng
  913. mov di,offset Ch7HgWTbl
  914. jmp GetCodeInUnSort1
  915. isnotJ7Wan:
  916. jmp PostSetRegErr
  917. ;========================================================================
  918. ; << ChgKs2Ch7 >>
  919. ; FUNCTION = Code convertion Wansung to Chohab7 in Hanguel
  920. ;
  921. ; RANGE : B0A1 - C8FE(Hanguel)
  922. ;
  923. ; Code array : B0A1 00
  924. ; | |
  925. ; B0FE 5D
  926. ; B1A1 5E
  927. ; | |
  928. ; B1FE BB
  929. ; B2A1 BC
  930. ; |
  931. ;
  932. ; C8FE
  933. ;
  934. ; INPUT : AX=Էcode
  935. ; OUTPUT : if CY=fail
  936. ; if NC=success, AX=ȯ code, BX=Էcode
  937. PUBLIC ChgKs2Ch7
  938. ChgKs2Ch7:
  939. @push cx,dx,si,di,es,ds,bp
  940. push ax
  941. mov bx,cs
  942. mov ds,bx
  943. mov es,bx
  944. cmp ax,0a4a1h
  945. jb ChWanJ7Err
  946. cmp ax,0a4d3h
  947. ja @f
  948. mov si,offset ChHgWTbl
  949. mov cx,ChHgWLng+1
  950. mov dh,05fh
  951. mov di,offset Ch7HgETbl
  952. jmp GetCodeInUnSort2
  953. @@:
  954. cmp ax,0B0A1h
  955. jb ChWanJ7Err
  956. cmp ax,0C8FEh
  957. ja ChWanJ7Err
  958. mov di,ax
  959. mov si,offset AH5F
  960. sub ax,0B0A1h
  961. mov bx,ax
  962. mov al,ah
  963. mov ah,0A2h
  964. mul ah
  965. sub bx,ax
  966. mov al,[bx+si]
  967. cmp al,0
  968. je ChWan7C
  969. mov si,offset Ch7HgTbl
  970. xor dx,dx
  971. mov cx,dx
  972. mov ah,dh
  973. @@:
  974. mov cl,[si]
  975. add dx,cx
  976. cmp bx,dx
  977. jb short @f
  978. add si,3
  979. inc ah
  980. jmp short @b
  981. @@:
  982. add ah,05fh
  983. jmp ChWanJ7End
  984. ChWan7C:
  985. mov ax,di
  986. mov si,offset Ch7HgWTbl
  987. mov cx,Ch7HgCLng
  988. mov di,offset Ch7HgCTbl
  989. mov dh,07eh
  990. jmp GetCodeInUnSort3
  991. ChWanJ7End:
  992. jmp PostSetRegSuc
  993. ChWanJ7Err:
  994. jmp PostSetRegErr
  995. ;------------------------------------------------------------------------
  996. GetCodeInUnSort1:
  997. call LinearByteSearch
  998. jc SetFail
  999. shl bx,1
  1000. mov si,di
  1001. mov ax,word ptr [si+bx]
  1002. SetSuccess:
  1003. jmp PostSetRegSuc
  1004. SetFail:
  1005. jmp PostSetRegErr
  1006. GetCodeInUnSort2:
  1007. call LinearByteSearch
  1008. jc SetFail
  1009. jmp short @f
  1010. GetCodeInUnSort3:
  1011. call LinearWordSearch
  1012. jc SetFail
  1013. shr bx,1
  1014. @@:
  1015. mov ah,dh
  1016. mov si,di
  1017. mov al,byte ptr [si+bx]
  1018. jmp SetSuccess
  1019. PostSetReg:
  1020. pop bx
  1021. jnc @f
  1022. mov ax,bx
  1023. @@:
  1024. @pop bp,ds,es,di,si,dx,cx
  1025. ret
  1026. PostSetRegErr:
  1027. stc
  1028. pop ax
  1029. @pop bp,ds,es,di,si,dx,cx
  1030. ret
  1031. PostSetRegSuc:
  1032. clc
  1033. pop bx
  1034. @pop bp,ds,es,di,si,dx,cx
  1035. ret
  1036. include CHOHAB7.TBL
  1037.