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.

3754 lines
106 KiB

  1. TITLE KeyBoard Interrupt 09h 16h
  2. ;=======================================================================;
  3. ; (C)Copyright Qnix Computer Co. Ltd. 1992 ;
  4. ; This program contains proprietary and confidential information. ;
  5. ; All rights reserved. ;
  6. ;=======================================================================;
  7. ;=======================================================================;
  8. ; ;
  9. ; SPECIFICATION for keyboard ;
  10. ; ;
  11. ;=======================================================================;
  12. ;
  13. ; KBD service routine������ video routine�� ������ ���� video INT����
  14. ; sub-routine�� �����ϰų� ���� data/flag���� ���������ؼ��� �ʵȴ�.
  15. ;
  16. ; KBD Spec. : KS C 5853
  17. ; : KS C 5842 - 1991
  18. ;
  19. ; Keyboard type : english 84 KBD
  20. ; : hangeul 86 KBD(none standard)
  21. ; : hangeul 86 KBD(KS C 5853)
  22. ; : 101 KBD
  23. ; : 103 KBD(KS C 5853)
  24. ;
  25. ; Etc. Spec. : user definable HE/HJ key scan code
  26. ; : Hot key detection & service
  27. CODE SEGMENT PUBLIC WORD 'CODE'
  28. ASSUME CS:CODE,DS:CODE,ES:CODE
  29. INCLUDE EQU.INC
  30. ;=======================================================================;
  31. ; ;
  32. ; GLOBAL DATA & FLAG ;
  33. ; ;
  34. ;=======================================================================;
  35. ;
  36. ; �� �κп����� KBD main routine���� �����Ǵ� �͸��� ǥ���Ͽ� �̵���
  37. ; �����̴� ���� �Ѵ��� ���� �ֵ����Ѵ�.
  38. ; ----------- EQUATION -----------
  39. HanEngKey = 03800H
  40. HanjaKey = 01d00H
  41. BanJunKey = 08300H
  42. Upper2Low = 020H
  43. HjNumOf1Line = 10
  44. EXTRN HanCardReset:near, pHanCardReset:near, EnvrChange:near
  45. EXTRN KbStat:byte, HjStat:byte, HjMenuStat:byte,TotalMenuCnt:byte
  46. EXTRN OldKbInt:dword, OldKbioInt:dword, CodeStat:byte,KbdType:byte
  47. EXTRN DisplayStat:byte, HanStat:byte, HjMenuLine:byte
  48. EXTRN MenuBuffer:word, MenuLineBuf:word, KbMisc:byte, HotStat:byte
  49. EXTRN CompleteCharCnt:word, CompleteCharBuf:word, InterimCharCnt:word
  50. EXTRN InterimCharBuf:word, Auto:byte, TmpKbdType:byte
  51. EXTRN InterimCurPage:byte,InterimMaxCols:byte,InterimCurPos:word
  52. EXTRN SavedChar1:byte,SavedChar2:byte
  53. EXTRN MenuPtr:byte, CurrMenuCnt:byte, SaveCurrPage:byte, CrtMaxCols:byte
  54. EXTRN SaveCurPos:word, SaveCurType:word, prebufptr:word
  55. EXTRN DispIChar1:byte, DispIChar2:byte, InterimDispP:word
  56. EXTRN PreInCode:word, CurInCode:word, TmpBuf:word, PreTmpBuf:word
  57. EXTRN KsKbBuf:word, TmpBufCnt:byte
  58. if WINNT
  59. EXTRN ActiveCodePage:word
  60. endif
  61. ;=======================================================================;
  62. ; ;
  63. ; KEYBOARD INTERRUPT 9 ;
  64. ; ;
  65. ;=======================================================================;
  66. ;
  67. ; << Int9 >>
  68. ; FUNCTION = KBD hardware interrupt service routine
  69. ; Int9(-/-)
  70. ; {
  71. ; /* save AX, DS */
  72. ; DS = KbSeg;
  73. ; AL = in port 60H;
  74. ; if (AL == DelKey) && ([rKbFlag] == (AltFlag || CtrlFlag))
  75. ; {
  76. ; /* save DX */
  77. ; HanCardReset(-/-);
  78. ; pHanCardReset(-/-);
  79. ; /* reset 3bf port */
  80. ; /* Restore DX, DS, AX */
  81. ; /* goto cs:[OldKbInt] */
  82. ; }
  83. ; /* save BX, CX, DX */
  84. ; BX = [rBufferTail];
  85. ; AH = [rKbFlag3]
  86. ; DL = [rKbFlag]
  87. ; /* call cs:[OldKbInt] */
  88. ; if (CheckHeHjKey(AL/CX,flag) == NC)
  89. ; {
  90. ; if (AX == HanjaKey) && ([rKbFlag] == 00000100)
  91. ; {
  92. ; CS:[KbStat] = CS:[KbStat] || ReqEnvrChg;
  93. ; [rBufferTail] = BX
  94. ; }
  95. ; else
  96. ; if (CS:[KbStat] == HanKeyinMode), PushKeyBuf(BX,CX/-);
  97. ; }
  98. ; else
  99. ; {
  100. ; if ((CS:[KbStat] == HanKeyinMode) && ([rKbFlag] == CapsFlag)&&
  101. ; (BX != [rBufferTail]) && ((A<=AL<=Z)||(a<=AL<=z))
  102. ; XOR [rBufferTail],00100000b;
  103. ; }
  104. ; if ([rKbFlag3] == Ext10xKey)
  105. ; {
  106. ; cs:[KbStat] = cs:[KbStat] || Ext10xKey
  107. ; if (cs:[KbStat] != UserDefineKey) /* off right ALT+CTRL flag */
  108. ; }
  109. ; /* restore DX, CX, BX, DS, AX */
  110. ; iret;
  111. ; }
  112. ;
  113. EXTRN MachineType:byte, HeKey:byte, HjKey:byte
  114. PUBLIC Int9, PushKeyBuf
  115. E0Flag db 0
  116. Int9:
  117. ASSUME DS:KBSEG
  118. if Debug
  119. Extrn DebugData:word
  120. pushf
  121. cli
  122. push ax
  123. push bx
  124. mov ax,cs:[DebugData]
  125. mov bx,ax
  126. and bx,0f0h
  127. and ax,0ff0fh
  128. add bx,10h
  129. and bx,0f0h
  130. or ax,bx
  131. out 10h,ax
  132. mov cs:[DebugData],ax
  133. pop bx
  134. pop ax
  135. popf
  136. endif ; if Debug
  137. @push ax,ds
  138. mov ax,seg KbSeg
  139. mov ds,ax
  140. in al,60h
  141. cmp al,DelKey
  142. jnz @f
  143. mov ah,[rKbFlag]
  144. and ah,00001100b
  145. cmp ah,00001100b
  146. jnz @f
  147. push dx
  148. call HanCardReset
  149. call pHanCardReset
  150. mov dx,3bfh
  151. mov al,3
  152. out dx,al
  153. mov dl,0b8h
  154. mov al,28h
  155. out dx,al
  156. xor al,al
  157. mov dl,0bfh
  158. out dx,al
  159. @pop dx,ds,ax
  160. jmp cs:[OldKbInt]
  161. @@:
  162. @push bx,cx,dx
  163. mov bx,[rBufferTail]
  164. mov dl,[rKbFlag]
  165. mov ah,[rKbFlag3]
  166. test cs:[E0Flag],00000001b
  167. jz @f
  168. or ah,00000010b ;e0flag
  169. mov [rKbFlag3],ah
  170. @@:
  171. and cs:[E0Flag],11111110b
  172. cmp al,0e0h
  173. jnz @f
  174. or cs:[E0Flag],00000001b
  175. @@:
  176. ;; cmp al,0e0h
  177. ;; jnz @f
  178. ;; or ah,00000010b ;e0flag
  179. ;; mov [rKbFlag3],ah
  180. @@:
  181. pushf
  182. call cs:[OldKbInt]
  183. ; mov al,ah
  184. ; out 21h,al
  185. ; pop ax
  186. call CheckHeHjKey
  187. jc NoneHeHjKey
  188. if HotKey
  189. cmp ax,HanjaKey
  190. jnz @f
  191. test dl,00000100b ; Ctrl + HanJa
  192. jz @f
  193. cmp cs:[HeKey], 1
  194. je @f
  195. cmp cs:[HeKey], 2
  196. je @f
  197. or cs:[KbStat],ReqEnvrChg
  198. mov [rBufferTail],bx
  199. jmp short Int9hExit
  200. @@:
  201. endif ; if HotKey
  202. if AltHotKey
  203. cmp ax,HanEngKey
  204. jnz @f
  205. test dl,00001000b ; Alt + HanEng
  206. jz @f
  207. cmp cs:[HeKey], 2
  208. je @f
  209. or cs:[KbStat],ReqEnvrChg
  210. or cs:[HotStat],AltHotChg
  211. mov [rBufferTail],bx
  212. jmp short Int9hExit
  213. @@:
  214. endif ; if AltHotKey
  215. test cs:[KbStat],HanKeyinMode
  216. jz Int9hExit
  217. cmp ax,HanjaKey
  218. jnz @f
  219. test dl,00001000b ; Alt + HanJa
  220. jz @f
  221. mov [rBufferTail],bx
  222. jmp short Int9hExit
  223. @@:
  224. call PushKeyBuf
  225. jmp short Int9hExit
  226. NoneHeHjKey:
  227. test cs:[KbStat],HanKeyinMode
  228. jz Int9hExit
  229. test cs:[KbStat],HEStat
  230. jz Int9hExit
  231. test [rKbFlag],01000000B
  232. jz Int9hExit
  233. mov bx,cs:[PreBufPtr] ; get prev buffer pointer
  234. cmp bx,[rBufferTail]
  235. je Int9hExit
  236. mov al,byte ptr [bx]
  237. cmp al,'A'
  238. jb Int9hExit
  239. cmp al,'z'
  240. ja Int9hExit
  241. cmp al,'Z'
  242. jbe @f
  243. cmp al,'a'
  244. jb Int9hExit
  245. @@:
  246. xor byte ptr [bx],00100000b
  247. Int9hExit:
  248. mov ax,[rBufferTail] ; get ptr of ROM kb buffer tail
  249. mov cs:[PreBufPtr],ax
  250. test [rKbFlag3],Ext10xKey
  251. jz @f
  252. or cs:[KbStat],Ext10xKey
  253. if Kbd101On
  254. test cs:[KbStat],UserDefineKey
  255. jnz @f
  256. else
  257. test cs:[KbdType],SetKbd101
  258. jz @f
  259. endif
  260. and [rKbFlag3],11110011b
  261. and [rKbFlag],11110011b
  262. mov ah,[rKbFlag1]
  263. and ah,3
  264. shl ah,1
  265. shl ah,1
  266. or [rKbFlag],ah
  267. @@:
  268. @pop dx,cx,bx,ds,ax
  269. if Debug
  270. pushf
  271. cli
  272. push ax
  273. push bx
  274. mov ax,cs:[DebugData]
  275. mov bx,ax
  276. and bx,0f0h
  277. and ax,0ff0fh
  278. sub bx,10h
  279. and bx,0f0h
  280. or ax,bx
  281. out 10h,ax
  282. mov cs:[DebugData],ax
  283. pop bx
  284. pop ax
  285. popf
  286. endif ; if Debug
  287. iret
  288. ;------------------------------------------------------------------------
  289. ; << PushKeyBuf >>
  290. ; FUNCTION = push �ѿ�/���� key to buffer
  291. ; INPUT : AX = han/eng or hanja key, BX = buffer pointer
  292. ; OUTPUT : none
  293. ; PROTECT :
  294. ; PushKeyBuf(AX,BX/-)
  295. ; {
  296. ; CX = BX;
  297. ; if (CX == [rBufferTail])
  298. ; {
  299. ; CX = CX + 2;
  300. ; if (CX == [rBufferEnd])
  301. ; CX = [rBufferStart];
  302. ; }
  303. ; if (CX == [rBufferHead])
  304. ; Beep(-/-);
  305. ; else
  306. ; [BX] = AX;
  307. ; [rBufferTail] = CX;
  308. ; }
  309. ;
  310. PushKeyBuf:
  311. mov bx,[rBufferTail]
  312. mov cx,bx
  313. ; cmp [rBufferTail],cx
  314. ; jnz @f
  315. inc cx
  316. inc cx
  317. cmp cx,[rBufferEnd]
  318. jne @f
  319. mov cx,[rBufferStart]
  320. @@:
  321. cmp cx,[rBufferHead]
  322. je KbBufFull
  323. mov [bx],ax
  324. mov [rBufferTail],cx
  325. ret
  326. KbBufFull:
  327. call Beep
  328. ret
  329. PopKeyQueue PROC Near
  330. push di
  331. cli
  332. mov di, rBufferHead
  333. cmp di, rBufferTail
  334. je @f
  335. inc di
  336. inc di
  337. cmp di, rBufferEnd
  338. jne @f
  339. mov di, rBufferStart
  340. @@:
  341. xchg rBufferHead, di
  342. mov di, [di]
  343. @pkqTerm:
  344. sti
  345. pop di
  346. ret
  347. PopKeyQueue ENDP
  348. INCLUDE debug.inc
  349. ;------------------------------------------------------------------------
  350. ; << CheckHeHjKey >>
  351. ; FUNCTION = check Han/Eng and Hanja key
  352. ; INPUT : AL = raw code, AH = [rKbFlag3]
  353. ; OUTPUT : (NC)AX = Han/Eng or Hanja code
  354. ; (CY)AL = raw code
  355. ; PROTECT : BX
  356. ; CheckHeHjKey(AL/AX)
  357. ; {
  358. ; if ([KbStat] == UserDefineKey)
  359. ; {
  360. ; if (AL == [HeKey]), AX = HanEngKey, return(NC);
  361. ; if (AL == [HjKey]), AX = HanjaKey, return(NC);
  362. ; }
  363. ; else
  364. ; {
  365. ; if ([MachineType] == AtMachine)
  366. ; {
  367. ; if ((AL = 0f2h) || (AL == 0f1h))
  368. ; {
  369. ; [HeKey] = 0f2h;
  370. ; [HjKey] = 0f1h;
  371. ; [KbStat] = [KbStat] || UserDefineKey;
  372. ; }
  373. ; }
  374. ; else
  375. ; }
  376. ; if ((AL = 0f0h) || (AL == 0f1h))
  377. ; {
  378. ; [HeKey] = 0f0h;
  379. ; [HjKey] = 0f1h;
  380. ; [KbStat = [KbStat] || UserDefineKey;
  381. ; }
  382. ; }
  383. ; if ([KbStat] == UserDefineKey)
  384. ; {
  385. ; if (AL == [HeKey]), AX = HanEngKey, return(NC);
  386. ; if (AL == [HjKey]), AX = HanjaKey, return(NC);
  387. ; }
  388. ; else
  389. ; if ([rKbFlag3] == Ext10xKey)
  390. ; {
  391. ; if ([rKbFlag3] == /* E0 flag */)
  392. ; {
  393. ; if (AL == [HeKey]), AX = HanEngKey, return(NC);
  394. ; if (AL == [HjKey]), AX = HanjaKey, return(NC);
  395. ; }
  396. ; }
  397. ; else
  398. ; {
  399. ; if (AL == [HeKey]), AX = HanEngKey, return(NC);
  400. ; if (AL == [HjKey]), AX = HanjaKey, return(NC);
  401. ; }
  402. ; }
  403. ; return(CY);
  404. ; }
  405. ;
  406. EQUAL = 0Dh
  407. CTRL = 1Dh
  408. ALT = 38h
  409. SHIFT = 2Ah
  410. RSHIFT = 36h
  411. SPACE = 39h
  412. DEL = 53h
  413. ASSUME DS:KBSEG
  414. CheckHeHjKey:
  415. cmp cs:[HeKey], 1
  416. jne @checkNext
  417. cmp al, SPACE
  418. jne @noHotHe
  419. @@:
  420. test [rKbFlag], 00000010b ; Check Left-Shift Pressed (HE)
  421. ;jnz @HGHot
  422. jz @f
  423. call PopKeyQueue
  424. jmp @HGHot
  425. @@:
  426. test [rKbFlag1], 00000001b ; Check Left-Ctrl Pressed (HJ)
  427. ;jnz @HJHot
  428. jz @f
  429. call PopKeyQueue
  430. jmp @HJHot
  431. @@:
  432. jmp @noHotHj
  433. @checkNext:
  434. cmp cs:[HeKey], 2
  435. jne @checkAltOrCtrl
  436. cmp al, SHIFT
  437. je @f
  438. cmp al, RSHIFT
  439. jne @noHotHj
  440. @@:
  441. test [rKbFlag], 00001000b ; Check Alt Pressed (HE)
  442. jnz @HGHot
  443. test [rKbFlag], 00000100b ; Check Ctrl Pressed (HJ)
  444. jnz @HJHot
  445. jmp SHORT @noHotHj
  446. @checkAltOrCtrl:
  447. cmp al, ALT
  448. je @f
  449. cmp al, CTRL
  450. jne @noAltOrCtrl
  451. @@:
  452. test ah, 00000010b
  453. jz @noHotHj
  454. cmp al, cs:[HeKey]
  455. je @HGHot
  456. cmp al, cs:[HjKey]
  457. je @HjHot
  458. jmp @noHotHj
  459. @noAltOrCtrl:
  460. cmp al, cs:[HeKey]
  461. je @HGHot
  462. cmp cs:[HeKey], 0F0h
  463. jne @noHotHe
  464. cmp al, 0F2h
  465. jne @noHotHe
  466. @HGHot:
  467. mov cx, HanEngKey
  468. jmp @end
  469. @noHotHe:
  470. cmp al, 1
  471. je @noHotHj
  472. cmp al, cs:[HjKey]
  473. jne @noHotHj
  474. @HjHot:
  475. mov cx, HanjaKey
  476. jmp @end
  477. @noHotHj:
  478. stc
  479. ret
  480. @end:
  481. mov ax, cx
  482. clc
  483. ret
  484. if 0 ; 1993/7/21 skkhang
  485. if Kbd101On
  486. test cs:[KbStat],UserDefineKey
  487. jnz CompHeHjKey
  488. @@:
  489. test cs:[MachineType],AtMachine
  490. jnz AtHe103Cmp
  491. cmp al,0f0h
  492. je @f
  493. cmp al,0f1h
  494. jne AtCmpEo
  495. @@:
  496. mov cs:[HeKey],0f0h
  497. mov cs:[HjKey],0f1h
  498. or cs:[KbStat],UserDefineKey
  499. jmp AtCmpEo
  500. AtHe103Cmp:
  501. cmp al,0f2h
  502. je @f
  503. cmp al,0f1h
  504. jne AtCmpEo
  505. @@:
  506. mov cs:[HeKey],0f2h
  507. mov cs:[HjKey],0f1h
  508. or cs:[KbStat],UserDefineKey
  509. AtCmpEo:
  510. test cs:[KbStat],UserDefinekey
  511. jnz CompHeHjKey
  512. test [rKbFlag3],Ext10xKey
  513. jz CompHeHjKey
  514. test ah,00000010b
  515. jnz CompHeHjKey
  516. else
  517. test cs:[KbdType],SetKbd101
  518. jz CompHeHjKey
  519. test ah,00000010b
  520. jnz CompHeHjKey
  521. endif
  522. stc
  523. ret
  524. CompHeHjKey:
  525. mov cx,HanEngKey
  526. cmp al,cs:[HeKey]
  527. jz CompHeHjKeyS
  528. mov cx,HanjaKey
  529. cmp al,cs:[HjKey]
  530. jz CompHeHjKeyS
  531. if VirtualKey
  532. test [rKbFlag3],Ext10xKey
  533. jnz @f
  534. mov ah,[rKbFlag]
  535. test ah,00000011b ; LRShift
  536. jz @f
  537. test ah,00001100b ; Alt+Ctrl
  538. jz @f
  539. test ah,00000100b ;Ctrl
  540. jnz CompHeHjKeyS
  541. mov cx,HanEngKey
  542. jmp CompHeHjKeyS
  543. @@:
  544. endif ; VirtualKey
  545. stc
  546. ret
  547. CompHeHjKeyS:
  548. mov ax,cx
  549. clc
  550. ret
  551. endif ;0
  552. ;************************************************************************
  553. ;** **
  554. ;** KEYBOARD INTERRUPT 16H **
  555. ;** **
  556. ;************************************************************************
  557. ;------------------------------------------------------------------------
  558. ; << Kbd16hInt >>
  559. ; FUNCTION = keyboard interrupt service routine
  560. ; Int16(*/*)
  561. ; {
  562. ; Save BX,CX,DX,SI,DI,ES,DS,BP;
  563. ; DS = ES = CS
  564. ; BP = SP;
  565. ; if ([KbStat] == ReqEnvrChg)
  566. ; {
  567. ; [KbStat] = [KbStat] || (not ReqEnvrChg)
  568. ; if ([KbMisc] != RunningHot)
  569. ; {
  570. ; [KbMisc] = [KbMisc] || RunningHot
  571. ; EnvrChange(-/-);
  572. ; [KbMisc] = [KbMisc] && (not RunningHot)
  573. ; }
  574. ; if ([KbStat] != HanKeyinMode), /* call OldKbioInt() */;
  575. ; else
  576. ; {
  577. ; switch(AH)
  578. ; {
  579. ; case 0 : GetCompleteCode(-/AX);
  580. ; break;
  581. ; case 1 : CheckCompleteCode(-/ZF,AX);
  582. ; break;
  583. ; case 2 : GetKbStatus(-/AX);
  584. ; break;
  585. ; case 5 : PushCompleteCode(CX/AL);
  586. ; break;
  587. ; case 10h : GetCompleteCode(-/AX);
  588. ; break;
  589. ; case 11h : CheckCompleteCode(-/ZF,AX);
  590. ; break;
  591. ; case 12h : /* call OldKbioInt() */;
  592. ; break;
  593. ; case 0f0h : GetInterimCode(-/AX);
  594. ; break;
  595. ; case 0f1h : CheckInterimCode(-/ZF,AX);
  596. ; break;
  597. ; case 0f2h : ChangeKbStatus(AL/AL);
  598. ; break;
  599. ; case 0f3h : FlushKbBuffer(-/-);
  600. ; break;
  601. ; case 0f4h : CtrlInterimDisplay(DX/-);
  602. ; break;
  603. ; case 0f8h : xGetInterimCode(-/AX);
  604. ; break;
  605. ; case 0f9h : xCheckInterimCode(-/ZF,AX);
  606. ; break;
  607. ; case 0feh : CtrlHanJa(AL,BX,DL/AL,DL);
  608. ; break;
  609. ; default : /* call OldKbioInt() */;
  610. ; }
  611. ; Restore BP,DS,ES,DI,SI,DX,CX,BX;
  612. ; iret;
  613. ; }
  614. ; }
  615. ;
  616. Extrn EnvrChange:near, VideoActive:byte
  617. PUBLIC Int16
  618. Int16:
  619. ASSUME DS:CODE, ES:CODE
  620. if Debug
  621. pushf
  622. cli
  623. push ax
  624. push bx
  625. mov ax,cs:[DebugData]
  626. mov bx,ax
  627. and bx,0f000h
  628. and ax,0fffh
  629. add bx,1000h
  630. and bx,0f000h
  631. or ax,bx
  632. out 10h,ax
  633. mov cs:[DebugData],ax
  634. pop bx
  635. pop ax
  636. popf
  637. endif ; if Debug
  638. sti
  639. cld
  640. @push bx,cx,dx,si,di,es,ds,bp
  641. mov bp,cs
  642. mov ds,bp
  643. mov es,bp
  644. mov bp,sp
  645. if HotKey
  646. test [KbStat],ReqEnvrChg
  647. jz @f
  648. test [KbMisc],RunningHot
  649. jnz @f
  650. or [KbMisc],RunningHot
  651. inc [VideoActive]
  652. call EnvrChange
  653. dec [VideoActive]
  654. if AltHotKey
  655. and [HotStat],not AltHotChg
  656. endif ; AltHotKey
  657. and [KbStat],not ReqEnvrChg
  658. and [KbMisc],not RunningHot
  659. @@:
  660. endif ; if HotKey
  661. sub bx,bx
  662. mov bl,ah
  663. add bl,10h
  664. cmp bl,21h
  665. ja OldInt16Call
  666. test cs:[KbStat],HanKeyinMode
  667. jz OldInt16Call
  668. cmp bl,15h
  669. jbe @f
  670. sub bl,10
  671. @@:
  672. shl bx,1
  673. call [bx+Int16Tbl]
  674. @pop bp,ds,es,di,si,dx,cx,bx
  675. if Debug
  676. pushf
  677. cli
  678. push ax
  679. push bx
  680. mov ax,cs:[DebugData]
  681. mov bx,ax
  682. and bx,0f000h
  683. and ax,0fffh
  684. sub bx,1000h
  685. and bx,0f000h
  686. or ax,bx
  687. out 10h,ax
  688. mov cs:[DebugData],ax
  689. pop bx
  690. pop ax
  691. popf
  692. endif ; if Debug
  693. iret
  694. OldInt16jmp label word
  695. add sp,2
  696. OldInt16Call:
  697. @pop bp,ds,es,di,si,dx,cx,bx
  698. cmp ah,0f8h
  699. jnz @f
  700. mov ah,010h
  701. @@:
  702. cmp ah,0f9h
  703. jnz @f
  704. mov ah,011h
  705. @@:
  706. cmp ah,0f0h
  707. jnz @f
  708. mov ah,000h
  709. @@:
  710. cmp ah,0f1h
  711. jnz @f
  712. mov ah,001h
  713. @@:
  714. if Debug
  715. pushf
  716. call cs:[OldKbioInt]
  717. pushf
  718. cli
  719. push ax
  720. push bx
  721. mov ax,cs:[DebugData]
  722. mov bx,ax
  723. and bx,0f000h
  724. and ax,0fffh
  725. sub bx,1000h
  726. and bx,0f000h
  727. or ax,bx
  728. out 10h,ax
  729. mov cs:[DebugData],ax
  730. pop bx
  731. pop ax
  732. popf
  733. iret
  734. else
  735. jmp cs:[OldKbioInt]
  736. endif ; if Debug
  737. Int16Tbl label word
  738. dw offset GetInterimCode ;AH=F0H
  739. dw offset CheckInterimCode
  740. dw offset ChangeKbStatus
  741. dw offset FlushKbBuffer
  742. dw offset CtrlInterimDisplay
  743. dw offset OldInt16jmp
  744. dw offset OldInt16jmp
  745. dw offset OldInt16jmp
  746. dw offset GetInterimCode
  747. dw offset CheckInterimCode
  748. dw offset OldInt16jmp
  749. dw offset OldInt16jmp
  750. dw offset OldInt16jmp
  751. dw offset OldInt16jmp
  752. dw offset CtrlHanJa ;AH=FEH
  753. dw offset OldInt16jmp
  754. dw offset GetCompleteCode ;AH=00H
  755. dw offset CheckCompleteCode ;AH=01H
  756. dw offset GetKbStatus ;AH=02H
  757. dw offset OldInt16jmp ;AH=03H
  758. dw offset OldInt16jmp ;AH=04H
  759. dw offset PushCompleteCode ;AH=05H
  760. dw offset GetCompleteCode ;AH=10H
  761. dw offset CheckCompleteCode ;AH=11H
  762. ;========================================================================
  763. ; << GetCompleteCode >>
  764. ; FUNCTION = get complete code
  765. ; INPUT : none
  766. ; OUTPUT : AX = KBD scan code & system scan code
  767. ; PROTECT : AX
  768. ; GetCompleteCode(AH/AX)
  769. ; {
  770. ; [TmpKbdType] = AH;
  771. ; while (![CompleteCharCnt])
  772. ; {
  773. ; DispInterimChar(-/-);
  774. ; AH = [TmpKbdType];
  775. ; /* call [OldKbioInt] */
  776. ; Automata(AX/-);
  777. ; }
  778. ; ClearInterimChar(-/-);
  779. ; GetCompleteChar(-/AX,flag);
  780. ; }
  781. GetCompleteCode:
  782. mov [TmpKbdType],ah
  783. WaitCompleteKeyin:
  784. cmp [CompleteCharCnt],0
  785. jne @f
  786. call DispInterimChar
  787. call WaitKeyin
  788. call Automata
  789. jmp WaitCompleteKeyin
  790. @@:
  791. call ClearInterimChar
  792. call GetCompleteChar
  793. call Filter84
  794. ret
  795. ;------------------------------------------------------------------------
  796. Filter84:
  797. pushf
  798. test [TmpKbdType],Ext10xKey
  799. jnz @f
  800. cmp ah,0f0h
  801. jae @f
  802. mov bx,ax
  803. mov al,0
  804. cmp bl,0e0h
  805. jz @f
  806. mov ax,bx
  807. cmp bh,0e0h
  808. jnz @f
  809. mov ah,35h
  810. cmp bl,2fh
  811. jz @f
  812. mov ah,1ch
  813. cmp bl,0dh
  814. jz @f
  815. cmp bl,0ah
  816. jz @f
  817. mov ax,bx
  818. @@:
  819. popf
  820. ret
  821. ;========================================================================
  822. ; << GetInterimCode >>
  823. ; FUNCTION = get interim code
  824. ; INPUT : none
  825. ; OUTPUT : AX = KBD scan code & system scan code
  826. ; PROTECT : AX
  827. ; GetInterimCode(AH/AX)
  828. ; {
  829. ; AH = AH && 00001000b;
  830. ; AH = AH shl 1;
  831. ; [TmpKbdType] = AH;
  832. ; while (![CompleteCharCnt]) || (![InterimCharCnt])
  833. ; {
  834. ; AH = [TmpKbdType];
  835. ; /* call [OldKbioInt] */
  836. ; Automata(AX/-);
  837. ; }
  838. ; if ([CompleteCharCnt])
  839. ; GetCompleteChar(-/AX,flag);
  840. ; else
  841. ; GetInterimChar(-/AX,flag);
  842. ; }
  843. GetInterimCode:
  844. and ah,00001000b
  845. shl ah,1
  846. mov [TmpKbdType],ah
  847. WaitInterimKeyin:
  848. cmp [CompleteCharCnt],0
  849. jne GetCompleteCharCall
  850. cmp [InterimCharCnt],0
  851. jnz GetInterimCharCall
  852. call WaitKeyin
  853. call Automata
  854. jmp WaitInterimKeyin
  855. GetCompleteCharCall:
  856. call GetCompleteChar
  857. call Filter84
  858. jmp @f
  859. GetInterimCharCall:
  860. call GetInterimChar
  861. @@:
  862. ret
  863. ;------------------------------------------------------------------------
  864. WaitKeyin:
  865. if HotKey
  866. test [KbStat],ReqEnvrChg
  867. jz @f
  868. test [KbMisc],RunningHot
  869. jnz @f
  870. or [KbMisc],RunningHot
  871. inc [VideoActive]
  872. call EnvrChange
  873. dec [VideoActive]
  874. if AltHotKey
  875. and [HotStat],not AltHotChg
  876. endif ; AltHotKey
  877. and [KbStat],not ReqEnvrChg
  878. and [KbMisc],not RunningHot
  879. @@:
  880. endif ; if HotKey
  881. mov ah,[TmpKbdType]
  882. inc ah
  883. pushf
  884. call [OldKbioInt]
  885. jz WaitKeyin
  886. mov ah,[TmpKbdType]
  887. pushf
  888. call [OldKbioInt]
  889. ret
  890. ;========================================================================
  891. ; << CheckCompleteCode >>
  892. ; FUNCTION = check complete code
  893. ; INPUT : none
  894. ; OUTPUT : if ZF = 0, AX = KBD scan code & system scan code
  895. ; PROTECT : AX
  896. ; CheckCompleteCode(AH/AX,zero-flag)
  897. ; {
  898. ; [TmpKbdType] = AH;
  899. ; while ((![CompleteCharCnt]) ||
  900. ; (AH = [TmpKbdType], /* call [OldKbioInt] */ = NZ))
  901. ; {
  902. ; DispInterimChar(-/-);
  903. ; AH = [TmpKbdType];
  904. ; - AH;
  905. ; /* call [OldKbioInt] */
  906. ; Automata(AX/-);
  907. ; }
  908. ; AX = [CompleteCharBuf];
  909. ; if ([CompleteCharCnt])
  910. ; /* reset zero-flag */
  911. ; else
  912. ; /* set zero-flag */
  913. ; Restore BP,BP,DS,ES,DI,SI,DX,CX,BX; /* include return addr */
  914. ; far ret 2;
  915. ; }
  916. CheckCompleteCode:
  917. dec ah
  918. mov [TmpKbdType],ah
  919. CheckCompleteKeyin:
  920. mov ax,[CompleteCharBuf]
  921. cmp [CompleteCharCnt],0
  922. jne @f
  923. call DispInterimChar
  924. mov ah,[TmpKbdType]
  925. inc ah
  926. pushf
  927. call [OldKbioInt]
  928. jz @f
  929. mov ah,[TmpKbdType]
  930. pushf
  931. call [OldKbioInt]
  932. call Automata
  933. jmp CheckCompleteKeyin
  934. @@:
  935. call Filter84
  936. pop bp
  937. @pop bp,ds,es,di,si,dx,cx,bx
  938. if Debug
  939. pushf
  940. cli
  941. push ax
  942. push bx
  943. mov ax,cs:[DebugData]
  944. mov bx,ax
  945. and bx,0f000h
  946. and ax,0fffh
  947. sub bx,1000h
  948. and bx,0f000h
  949. or ax,bx
  950. out 10h,ax
  951. mov cs:[DebugData],ax
  952. pop bx
  953. pop ax
  954. popf
  955. endif ; if Debug
  956. FarRet2 proc far
  957. ret 2
  958. FarRet2 endp
  959. ;========================================================================
  960. ; << CheckInterimCode >>
  961. ; FUNCTION = check interim code
  962. ; INPUT : none
  963. ; OUTPUT : if ZF = 0, AX = KBD scan code & system scan code
  964. ; PROTECT : AX
  965. ; CheckInterimCode(AH/AX,zero-flag)
  966. ; {
  967. ; AH = AH && 00001000b;
  968. ; AH = AH shl 1;
  969. ; + AH;
  970. ; [TmpKbdType] = AH;
  971. ; if !((![CompleteCharCnt]) || ([InterimCharCnt] == 1))
  972. ; {
  973. ; while ((![CompleteCharCnt]) || (![InterimCharCnt]) ||
  974. ; (AH = [TmpKbdType], /* call [OldKbioInt] */ = NZ))
  975. ; {
  976. ; AH = [TmpKbdType];
  977. ; - AH;
  978. ; /* call [OldKbioInt] */
  979. ; Automata(AX/-);
  980. ; }
  981. ; }
  982. ; if ([CompleteCharCnt])
  983. ; {
  984. ; AX = [CompleteCharBuf];
  985. ; /* reset zero-flag */
  986. ; }
  987. ; else
  988. ; {
  989. ; if ([InterimCharCnt] == 0)
  990. ; /* set zero-flag */
  991. ; else
  992. ; {
  993. ; AX = [InterimCharBuf];
  994. ; /* reset zero-flag */
  995. ; }
  996. ; }
  997. ; Restore BP,BP,DS,ES,DI,SI,DX,CX,BX;
  998. ; far ret 2;
  999. ; }
  1000. CheckInterimCode:
  1001. and ah,00001000b
  1002. shl ah,1
  1003. mov [TmpKbdType],ah
  1004. CheckInterimKeyin:
  1005. mov ax,[CompleteCharBuf]
  1006. cmp [CompleteCharCnt],0
  1007. jne CheckInterimCodeRet
  1008. cmp [InterimCharCnt],1
  1009. jz CheckInterimCode2nd
  1010. mov ah,[TmpKbdType]
  1011. inc ah
  1012. pushf
  1013. call [OldKbioInt]
  1014. jz CheckInterimCode1st
  1015. mov ah,[TmpKbdType]
  1016. pushf
  1017. call [OldKbioInt]
  1018. call Automata
  1019. jmp CheckInterimKeyin
  1020. CheckInterimCode2nd:
  1021. mov ax,[InterimCharBuf+2]
  1022. jmp short @f
  1023. CheckInterimCode1st:
  1024. mov ax,[InterimCharBuf]
  1025. @@:
  1026. cmp [InterimCharCnt],0
  1027. CheckInterimCodeRet:
  1028. call Filter84
  1029. pop bp
  1030. @pop bp,ds,es,di,si,dx,cx,bx
  1031. if Debug
  1032. pushf
  1033. cli
  1034. push ax
  1035. push bx
  1036. mov ax,cs:[DebugData]
  1037. mov bx,ax
  1038. and bx,0f000h
  1039. and ax,0fffh
  1040. sub bx,1000h
  1041. and bx,0f000h
  1042. or ax,bx
  1043. out 10h,ax
  1044. mov cs:[DebugData],ax
  1045. pop bx
  1046. pop ax
  1047. popf
  1048. endif ; if Debug
  1049. FarRet proc far
  1050. ret 2
  1051. FarRet endp
  1052. ;========================================================================
  1053. ; << GetKbStatus >>
  1054. ; FUNCTION = get keyboard status(84/86 KBD)
  1055. ; INPUT : none
  1056. ; OUTPUT : AX = 84/86 KBD status
  1057. ; PROTECT : none
  1058. ; GetKbStatus(AH/AX)
  1059. ; {
  1060. ; AH = [KbStat]
  1061. ; AH = AH && Ext10xKey
  1062. ; [TmpKbdType] = AH
  1063. ; while (([CompleteCharCnt] < 16) &&
  1064. ; (AH = [TmpKbdType] || 1, /* call [OldKbioInt] */ = NZ))
  1065. ; {
  1066. ; ClearInterimChar(-/-);
  1067. ; AH = [TmpKbdType];
  1068. ; /* call [OldKbioInt] */
  1069. ; Automata(AX/-);
  1070. ; }
  1071. ; AH = 2;
  1072. ; /* call [OldKbioInt] */
  1073. ; AH = [KbStat];
  1074. ; AH = AH && (JJStat || HEStat);
  1075. ; }
  1076. GetKbStatus:
  1077. mov ah,[KbStat]
  1078. and ah,Ext10xKey
  1079. mov [TmpKbdType],ah
  1080. @@:
  1081. cmp [InterimCharCnt],1
  1082. jz @f
  1083. cmp [CompleteCharCnt],16
  1084. jae @f
  1085. mov ah,[TmpKbdType]
  1086. inc ah
  1087. pushf
  1088. call [OldKbioInt]
  1089. jz @f
  1090. ; call ClearInterimChar
  1091. mov ah,[TmpKbdType]
  1092. pushf
  1093. call [OldKbioInt]
  1094. call Automata
  1095. jmp short @b
  1096. @@:
  1097. mov ah,2
  1098. pushf
  1099. call [OldKbioInt]
  1100. mov ah,[KbStat]
  1101. and ah,(JJStat or HEStat)
  1102. ret
  1103. ;========================================================================
  1104. ; << PushCompleteCode >>
  1105. ; FUNCTION = push complete code
  1106. ; INPUT : CX = KBD scan code & system scan code
  1107. ; OUTPUT : if error, AL = -1
  1108. ; PROTECT : none
  1109. ; PushCompleteCode(-/-)
  1110. ; {
  1111. ; AutoReset(-/-);
  1112. ; pushf
  1113. ; /* call OldKbioInt() */
  1114. ; }
  1115. PushCompleteCode:
  1116. call AutoReset
  1117. pushf
  1118. call [OldKbioInt]
  1119. push ds
  1120. ASSUME DS:KBSEG
  1121. mov bx,seg KbSeg
  1122. mov ds,bx
  1123. mov bx,[rBufferTail] ; get ptr of ROM kb buffer tail
  1124. mov cs:[PreBufPtr],bx
  1125. ASSUME DS:CODE
  1126. pop ds
  1127. ret
  1128. ;========================================================================
  1129. ; << FlushKbBuffer >>
  1130. ; FUNCTION = flush kbd buffer & status flag without interim code
  1131. ; INPUT : none
  1132. ; OUTPUT : none
  1133. ; PROTECT : none
  1134. ; FlushKbBuffer(-/-)
  1135. ; {
  1136. ; /* Save DS */
  1137. ; DS = KbSeg;
  1138. ; BX = [rBufferStart];
  1139. ; [rBufferTail] = BX;
  1140. ; [rBufferHead] = BX;
  1141. ; /* Restore DS */
  1142. ; [CompleteCharCnt] = 0;
  1143. ; AutoReset(-/-);
  1144. ; }
  1145. FlushKbBuffer:
  1146. push ds
  1147. ASSUME DS:KBSEG
  1148. mov bx,Seg KbSeg
  1149. mov ds,bx
  1150. mov bx,[rBufferStart]
  1151. mov [rBufferTail],bx
  1152. mov [rBufferHead],bx
  1153. ASSUME DS:CODE
  1154. pop ds
  1155. mov [PreBufPtr],bx
  1156. mov [CompleteCharCnt],0
  1157. call AutoReset
  1158. ret
  1159. ;========================================================================
  1160. ; << CtrlInterimDisplay >>
  1161. ; FUNCTION = interim display control
  1162. ; INPUT : DX = -1(interim display) or 0fefeh(interim not display)
  1163. ; OUTPUT : none
  1164. ; PROTECT : none
  1165. ; CtrlInterimDisplay(-/-)
  1166. ; {
  1167. ; if (DX == 0ffffh), [KbMisc] = [KbMisc] || InterimCtrlDisp;
  1168. ; if (DX == 0fefeh), [KbMisc] = [KbMisc] && !(InterimCtrlDisp);
  1169. ; }
  1170. CtrlInterimDisplay:
  1171. cmp dx,0ffffh
  1172. jne @f
  1173. or [KbMisc],InterimCtrlDisp
  1174. @@:
  1175. cmp dx,0fefeh
  1176. jne @f
  1177. and [KbMisc],not InterimCtrlDisp
  1178. @@:
  1179. ret
  1180. ;========================================================================
  1181. ; << ChangeKbStatus >>
  1182. ; FUNCTION = change hangeul status
  1183. ; INPUT : AL = Hangeul/Hanja/Junja status
  1184. ; OUTPUT : if error, AL = -1
  1185. ; PROTECT : none
  1186. ; ChangeKbStatus(AL/AL)
  1187. ; {
  1188. ; BH = AL;
  1189. ; BL = AL && 00000011b /* junja flag */
  1190. ; switch(BL)
  1191. ; case 0: SetBanja(-/AL)
  1192. ; break;
  1193. ; case 1: SetJunja(-/AL)
  1194. ; break;
  1195. ; case 2: ToggleBanJun(-/AL)
  1196. ; break;
  1197. ; case 3: ChangeError(-/AL)
  1198. ; if (AL = 0)
  1199. ; {
  1200. ; BL = BL && 00001000b; /* han/eng flag */
  1201. ; switch(BL)
  1202. ; case 0:
  1203. ; if ([KbStat] == HEStat)
  1204. ; {
  1205. ; [KbSTat] = [KbStat] && !(HEStat);
  1206. ; AutoReset(-/-);
  1207. ; }
  1208. ; else
  1209. ; [KbSTat] = [KbStat] && !(HEStat);
  1210. ; break;
  1211. ; case 8:
  1212. ; [KbSTat] = [KbStat] || HEStat;
  1213. ; break;
  1214. ; }
  1215. ; }
  1216. ; SetBanja(-/AL)
  1217. ; {
  1218. ; [KbStat] = [KbStat] && !(JJStat);
  1219. ; AL = 0;
  1220. ; }
  1221. ; SetJunja(-/AL)
  1222. ; {
  1223. ; if ([HjStat] == HjLoaded)
  1224. ; {
  1225. ; [KbStat] = [KbStat] || JJStat;
  1226. ; }
  1227. ; else
  1228. ; AL = -1;
  1229. ; }
  1230. ; ToggleBanJun(-/AL)
  1231. ; {
  1232. ; if ([KbStat] == JJStat)
  1233. ; SetBanja(-/AL);
  1234. ; else
  1235. ; SetJunja(-/AL);
  1236. ; }
  1237. ; ChangeError(-/AL)
  1238. ; {
  1239. ; AL = -1, return;
  1240. ; }
  1241. ChangeKbStatus:
  1242. ifdef WINNT
  1243. cmp cs:[ActiveCodePage], 949 ;For NT 5.0. 949=WanSungCP
  1244. jz @f
  1245. mov al,-1
  1246. jmp ChangeKbStatusRet
  1247. @@:
  1248. endif
  1249. xor bx,bx
  1250. mov bl,al
  1251. and bl,00000011b
  1252. shl bl,1
  1253. mov si,bx
  1254. mov bh,al
  1255. call [si+BanJunTbl]
  1256. cmp al,0
  1257. jne ChangeError
  1258. and bh,00001000b
  1259. shr bh,1
  1260. mov bl,[KbStat]
  1261. and [KbStat],11111011b
  1262. or [KbStat],bh
  1263. xor bl,bh
  1264. test bl,00000100b
  1265. jz ChangeKbStatusRet
  1266. call AutoReset
  1267. ChangeKbStatusRet:
  1268. ret
  1269. SetHanInStat:
  1270. or [KbStat],HEStat
  1271. ret
  1272. BanJunTbl label word
  1273. dw offset SetBanja
  1274. dw offset SetJunja
  1275. dw offset ToggleBanJun
  1276. dw offset ChangeError
  1277. SetBanja:
  1278. and [KbStat],not JJStat
  1279. xor al,al
  1280. ret
  1281. SetJunja:
  1282. mov al,-1
  1283. test [HjStat],HjLoaded
  1284. jz @f
  1285. or [KbStat],JJStat
  1286. xor al,al
  1287. @@:
  1288. ret
  1289. ToggleBanJun:
  1290. test [KbStat],JJStat
  1291. jz @f
  1292. jmp SetBanja
  1293. @@:
  1294. jmp SetJunja
  1295. ChangeError:
  1296. mov al,-1
  1297. ret
  1298. ;========================================================================
  1299. ; << CtrlHanJa >>
  1300. ; FUNCTION : hanja function(see each sun-routines)
  1301. ; INPUT : AL=0, DL=0/1 - �������� ����/����
  1302. ; OUTPUT : AL=0/FFH - ���� �Ϸ�/�Ұ���
  1303. ; INPUT : AL=1
  1304. ; OUTPUT : DL=0/1 - ����ó�� ����/���� ����
  1305. ; INPUT : AL=2, BX - �ѱ۹����ڵ�(1st,2nd)
  1306. ; OUTPUT : AL=0/1/2 - ���ں�ȯ�Ϸ�/����/�ش����ھ���.
  1307. ; BX -���ڹ����ڵ�(1st,2nd)
  1308. ; INPUT : AL=3, BX - �ѱ۹����ڵ�(1st,2nd)
  1309. ; OUTPUT : AL=0/FFH - �б� �Ϸ�/�ش����ھ���
  1310. ; ES:BX - �ش����� ���ڿ��� ���¹���(����/1st/2nd/1st/...2nd/0)
  1311. ; INPUT : AL=4, DL=���ڸ޴�ǥ����
  1312. ; OUTPUT : AL=0/FFH - ���� �Ϸ�/�Ұ���
  1313. ; PROTECT : none
  1314. ; CtrlHanJa(*/*)
  1315. ; {
  1316. ; if ([HjStat] == HjLoaded)
  1317. ; BX = [BP+rBX]
  1318. ; {
  1319. ; switch(AL)
  1320. ; {
  1321. ; case 0 :
  1322. ; [HjStat] = [HjStat] && !(HjModeEnable);
  1323. ; [HjStat] = [HjStat] || DL;
  1324. ; break;
  1325. ; case 1 :
  1326. ; DL = [HjStat] && (HjModeEnable);
  1327. ; [BP+rDX] = DL;
  1328. ; break;
  1329. ; case 2 : ChangeHangeul2Hanja(BX/AL,BX);
  1330. ; break;
  1331. ; case 3 :
  1332. ; [BP + rKES] = CS;
  1333. ; [BP + rKBX] = offset MenuBuffer;
  1334. ; if (MakeHanjaList(BX/AL); AL == 0)
  1335. ; {
  1336. ; if ([TotalMenuCnt] > 1) ret(AL=FFh);
  1337. ; -[TotalMenuCnt]
  1338. ; DI = DI-4
  1339. ; ES:[DI] = 0
  1340. ; }
  1341. ; break;
  1342. ; case 4 :
  1343. ; AH = 0Fh
  1344. ; int 10h
  1345. ; if DL < [MaxRows]
  1346. ; [HjMenuLine] = DL;
  1347. ; AL = 0;
  1348. ; else
  1349. ; AL = -1;
  1350. ; break;
  1351. ; default: AL = -1;
  1352. ; }
  1353. ; }
  1354. ; else
  1355. ; AL = -1;
  1356. ; }
  1357. ;
  1358. ; ChangeHangeul2Hanja(BX/AL,BX)
  1359. ; {
  1360. ; MakeHanjaList(BX/AL)
  1361. ; if ((!AL) && ([TotalMenuCnt] > 1))
  1362. ; {
  1363. ; SaveMenuline(-/-);
  1364. ; TrapLoop:
  1365. ; AH = cs:[KbStat] && Ext10xKey
  1366. ; /* call OldKbioInt */
  1367. ; if (TrapHjMenu(AX/flag,AL,BX) == NC && NZ), goto TrapLoop; ; if (
  1368. ; else CY RestoreMenuLine(-/-); ret(AL=1);
  1369. ; [BP+rBX] = BX;
  1370. ; RestoreMenuline(-/-);
  1371. ; ret(AL=0);
  1372. ; }
  1373. ; else
  1374. ; ret(AL=2);
  1375. ; }
  1376. ;
  1377. ; MakeHanjaList(BX/AL,ES,BX)
  1378. ; {
  1379. ; [TotalMenuCnt] = 0; /* clear counter */
  1380. ; AX = BX;
  1381. ; if [CodeStat] == Chab)
  1382. ; if (ChgCh2Ks(AX/AX,BX,flag) == CY), return(AL = -1);
  1383. ; DI = MenuBuffer;
  1384. ; if (MakeHanjaListHg(AX,DI/AX,DI,flag) == NC)
  1385. ; {
  1386. ; MakeHanjaListUdc(AX,DI/AX,DI,flag);
  1387. ; if ([CodeStat] == Chab)
  1388. ; {
  1389. ; DI = MenuBuffer;
  1390. ; SI = DI;
  1391. ; CL = [TotalMenuCnt];
  1392. ; while (CL)
  1393. ; {
  1394. ; AL = [SI+1];
  1395. ; AH = [SI];
  1396. ; if ((ChgKs2Ch(AX/AX,BX,flag) == NC)
  1397. ; {
  1398. ; [DI+1] = AL;
  1399. ; [DI] = AH;
  1400. ; DI = DI + 2;
  1401. ; }
  1402. ; SI = SI + 2;
  1403. ; -CL;
  1404. ; }
  1405. ; AX = (DI - SI)/2;
  1406. ; [TotalMenuCnt] = AL;
  1407. ; }
  1408. ; CL = [MenuBuffer];
  1409. ; SI = MenuBuffer;
  1410. ; DI = SI;
  1411. ; while (CL)
  1412. ; {
  1413. ; AX = [SI];
  1414. ; xchg AL,AH;
  1415. ; [DI] = AX;
  1416. ; DI = DI + 2;
  1417. ; SI = SI + 2;
  1418. ; -CL;
  1419. ; }
  1420. ; ES:[DI] = 0
  1421. ; AL = 0;
  1422. ; }
  1423. ; else
  1424. ; AL = -1;
  1425. ; }
  1426. EXTRN ChgCh2Ks:near,ChgKs2Ch:near
  1427. CtrlHanJa:
  1428. mov byte ptr [bp+rDX],0 ; assume hanja disabled(DL)
  1429. test [HjStat],HjLoaded
  1430. jz CtrlHanJaErr
  1431. cmp al,4
  1432. ja CtrlHanJaErr
  1433. mov bx,[bp+rBX]
  1434. mov cl,al
  1435. xor ch,ch
  1436. mov si,cx
  1437. shl si,1
  1438. jmp [si+HanjaSupportTbl]
  1439. CtrlHanJaErr:
  1440. mov al,-1
  1441. ret
  1442. HanjaSupportTbl label word
  1443. dw SetHjMode
  1444. dw GetHjMode
  1445. dw ChangeHangeul2Hanja
  1446. dw Hg2HjList
  1447. dw SetMenuLine
  1448. SetHjMode:
  1449. and [HjStat],not HjModeEnable
  1450. and dl,HjModeEnable
  1451. or [HjStat],dl
  1452. ret
  1453. GetHjMode:
  1454. mov dl,[HjStat]
  1455. and dl,HjModeEnable
  1456. mov [bp+rDX],dl
  1457. ret
  1458. ChangeHangeul2Hanja:
  1459. call MakeHanjaList
  1460. or al,al
  1461. jnz NoHanjaCode
  1462. cmp [TotalMenuCnt],1
  1463. jbe NoHanjaCode
  1464. call SaveMenuline
  1465. @@:
  1466. mov ah,cs:[KbStat]
  1467. and ah,Ext10xKey
  1468. pushf
  1469. call [OldKbioInt]
  1470. call TrapHjMenu
  1471. jc @f
  1472. jz @b
  1473. mov [bp+rBX],ax
  1474. call RestoreMenuline
  1475. xor al,al
  1476. ret
  1477. @@:
  1478. call RestoreMenuline
  1479. mov al,1
  1480. ret
  1481. NoHanjaCode:
  1482. mov al,2
  1483. ret
  1484. Hg2HjList:
  1485. mov [bp + rES],cs
  1486. mov ax,offset MenuBuffer
  1487. dec ax
  1488. mov [bp + rBX],ax
  1489. call MakeHanjaList
  1490. or al,al
  1491. jnz @f
  1492. cmp [TotalMenuCnt],1
  1493. jbe ReturnFail
  1494. dec [TotalMenuCnt]
  1495. sub di,4
  1496. stosw
  1497. @@:
  1498. ret
  1499. SetMenuLine:
  1500. mov ah,0fh
  1501. int 10h
  1502. mov al,-1
  1503. cmp dl,ah
  1504. jae @f
  1505. mov [HjMenuLine],dl
  1506. mov al,0
  1507. @@:
  1508. ret
  1509. MakeHanjaList:
  1510. mov [TotalMenuCnt],0
  1511. mov ax,bx
  1512. test [CodeStat],chab
  1513. jz @f
  1514. call ChgCh2Ks
  1515. jc ReturnFail
  1516. @@:
  1517. mov di,offset MenuBuffer
  1518. call MakeHanjaListHg
  1519. jc ReturnFail
  1520. call MakeHanjaListUdc
  1521. test [CodeStat],Chab
  1522. jz MakeHjWan
  1523. mov di,offset MenuBuffer
  1524. mov si,di
  1525. mov cl,[TotalMenuCnt]
  1526. dec cl
  1527. cmp cl,0
  1528. jz MakeHjcho
  1529. MakeHJListLoop:
  1530. lodsw
  1531. call ChgKs2Ch
  1532. jc @f
  1533. stosw
  1534. @@:
  1535. dec cl
  1536. jnz MakeHjListLoop
  1537. MakeHjcho:
  1538. lodsw
  1539. call Ks2Ch
  1540. stosw
  1541. sub di,si
  1542. shr di,1
  1543. mov ax,di
  1544. sub [TotalMenuCnt],al
  1545. MakeHjWan:
  1546. mov cl,[TotalMenuCnt]
  1547. mov si,offset MenuBuffer
  1548. mov di,si
  1549. @@:
  1550. lodsw
  1551. xchg al,ah
  1552. stosw
  1553. dec cl
  1554. jnz @b
  1555. xor ax,ax
  1556. stosw
  1557. ret
  1558. ReturnFail:
  1559. mov al,-1
  1560. ret
  1561. ;------------------------------------------------------------------------
  1562. ; << DisplayHanja >>
  1563. ; FUNCTION = display Hj menu (end with null)
  1564. ; INPUT : none ([MenuPtr], [MenuBuffer], [CurrMenuCnt])
  1565. ; OUTPUT : none
  1566. ; PROTECT : ax, bx, cx, dx, si
  1567. ; DisplayHanja()
  1568. ; {
  1569. ; BH = [SaveCurrPage];
  1570. ; DX = CX = 0;
  1571. ; DH = [HjMenuLine];
  1572. ; AH = 2;
  1573. ; INT 10h;
  1574. ; CL = [CrtMaxCols]
  1575. ; BL = 70h;
  1576. ; AH = 09;
  1577. ; AL = ' ';
  1578. ; INT 10h;
  1579. ; DL = 15;
  1580. ; AH = 2;
  1581. ; INT 10h;
  1582. ; BH = 0
  1583. ; BX = [MenuPtr] * 2;
  1584. ; SI = BX+offset MenuBuffer;
  1585. ; CX=[CurrMenuCnt];
  1586. ; BH = '0';
  1587. ; BL = 70h;
  1588. ; if ([ModeId] == 6*2)
  1589. ; bl = 0fh;
  1590. ; while (CL != 0)
  1591. ; {
  1592. ; AL = BH;
  1593. ; AH = 0Eh;
  1594. ; INT 10h;
  1595. ; AL = '.';
  1596. ; INT 10h;
  1597. ; /* display [DS:SI];word */
  1598. ; /* display ' ' */
  1599. ; +BH;
  1600. ; -CX;
  1601. ; }
  1602. ; if ( [DS:SI] != 0 ) ;the end of hanja list
  1603. ; /* display NextMenuMsg */
  1604. ; return;
  1605. ; }
  1606. NextMenuMsg db '...',0
  1607. ModeVal db 0
  1608. DisplayHanja:
  1609. mov bh,[SaveCurrPage]
  1610. xor cx,cx
  1611. mov dx,cx
  1612. mov dh,[HjMenuLine]
  1613. mov ah,2
  1614. int 10h
  1615. mov cl,[CrtMaxCols]
  1616. mov bl,70H
  1617. mov ah,9
  1618. mov al,' '
  1619. int 10h
  1620. cmp [ModeVal],6*2
  1621. jnz @f
  1622. mov ax,00601h
  1623. mov bh,0ffh
  1624. mov cx,dx
  1625. mov dl,[CrtMaxCols]
  1626. dec dl
  1627. int 10h
  1628. mov bh,[SaveCurrPage]
  1629. xor ch,ch
  1630. @@:
  1631. mov dl,15
  1632. mov ah,2
  1633. int 10h
  1634. xor bh,bh
  1635. mov bl,[MenuPtr]
  1636. shl bx,1
  1637. mov si,offset MenuBuffer
  1638. add si,bx
  1639. mov cl,[CurrMenuCnt]
  1640. mov bh,'0'
  1641. mov bl,70h
  1642. cmp [ModeVal],6*2
  1643. jnz @f
  1644. mov bl,0ffh
  1645. @@:
  1646. mov al,bh
  1647. mov ah,0Eh
  1648. int 10h
  1649. mov ah,0Eh
  1650. mov al,'.'
  1651. int 10h
  1652. lodsw
  1653. mov dx,ax
  1654. mov ah,0Eh
  1655. int 10h
  1656. mov al,dh
  1657. mov ah,0Eh
  1658. int 10h
  1659. mov al,' '
  1660. mov ah,0Eh
  1661. int 10h
  1662. mov al,' '
  1663. mov ah,0Eh
  1664. int 10h
  1665. inc bh
  1666. loop @b
  1667. lodsw
  1668. or ax,ax
  1669. jz DisplayHanjaRet
  1670. mov si,offset NextMenuMsg
  1671. @@:
  1672. lodsb
  1673. or al,al
  1674. jz DisplayHanjaRet
  1675. mov ah,0Eh
  1676. int 10h
  1677. jmp @b
  1678. DisplayHanjaRet:
  1679. ret
  1680. ;------------------------------------------------------------------------
  1681. ; << DispInterimChar >>
  1682. ; FUNCTION = �̿ϼ� ���� DISPLAY
  1683. ; INPUT : none
  1684. ; OUTPUT : none
  1685. ; PROTECT : AX,BX,CX,DX
  1686. ; DispInterimChar(-/-)
  1687. ; {
  1688. ; if !(([HjMenuStat] == HjMenuMode) || ([KbMisc] != HaveInterim) ||
  1689. ; ([KbMisc] != InterimCtrlDisp) || ([InterimCharCnt] < 2) ||
  1690. ; [HanStat] == Han1st))
  1691. ; {
  1692. ; [DisplayStat] = [DisplayStat] && !(RunEsc);
  1693. ; [KbMisc] == [KbMisc] && !(HaveInterim);
  1694. ; AH = 0FH;
  1695. ; Int 10h;
  1696. ; [InterimCurPage] = BH;
  1697. ; [InterimMaxCols] = AH-1;
  1698. ; AH = 3;
  1699. ; Int 10h;
  1700. ; if (([KbMisc] == SavedInterim) &&
  1701. ; (([InterimCurPage] != bh) || ([InterimCurPos] != dx)))
  1702. ; {
  1703. ; [KbMisc] = [KbMISC] && !(SavedInterim);
  1704. ; xchg BH,[InterimCurPage];
  1705. ; xchg DX,[InterimCurPos];
  1706. ; AH = 2;
  1707. ; int 10h
  1708. ; AH = 8;
  1709. ; int 10h
  1710. ; if ([DispIChar1] == al)
  1711. ; {
  1712. ; DL+
  1713. ; AH = 2
  1714. ; int 10h
  1715. ; AH = 8
  1716. ; int 10h
  1717. ; if ([DispIChar2] == al)
  1718. ; {
  1719. ; CX = 1
  1720. ; DL-
  1721. ; AH = 2
  1722. ; int 10h
  1723. ; AH = 8
  1724. ; int 10h
  1725. ; BL = AH
  1726. ; AL = [SavedChar1]
  1727. ; AH = 9
  1728. ; int 10h
  1729. ; DL+
  1730. ; AH = 2
  1731. ; int 10h
  1732. ; AH = 8
  1733. ; int 10h
  1734. ; BL = AH
  1735. ; AL = [SavedChar2]
  1736. ; AH = 9
  1737. ; int 10h
  1738. ; }
  1739. ; }
  1740. ; xchg BH,[InterimCurPage];
  1741. ; xchg DX,[InterimCurPos];
  1742. ; AH = 2;
  1743. ; int 10h
  1744. ; }
  1745. ; if (DL >= [InterimMaxCols])
  1746. ; {
  1747. ; AH = 8;
  1748. ; Int 10h
  1749. ; BL = AH;
  1750. ; AX = 0e20h;
  1751. ; Int 10h
  1752. ; AH = 3
  1753. ; Int 10h
  1754. ; }
  1755. ; CX = 1;
  1756. ; AH = 8
  1757. ; Int 10h
  1758. ; if ([KbMisc] != SavedInterim)
  1759. ; {
  1760. ; [InterimCurPos] = DX;
  1761. ; [SavedChar1] = AL
  1762. ; }
  1763. ; BL = AH;
  1764. ; AL = [InterimCharBuf];
  1765. ; AH = 9;
  1766. ; Int 10h
  1767. ; +DL;
  1768. ; AH = 2;
  1769. ; Int 10h
  1770. ; AH = 8;
  1771. ; Int 10h
  1772. ; if ([KbMisc] != SavedInterim)
  1773. ; {
  1774. ; [KbMisc] = [KbMisc] || SavedInterim;
  1775. ; [SavedChar2] = AL
  1776. ; }
  1777. ; BL = AH;
  1778. ; AL = [InterimCharBuf+2];
  1779. ; AH = 9;
  1780. ; Int 10h
  1781. ; -DL;
  1782. ; AH = 2;
  1783. ; Int 10h
  1784. ; }
  1785. ; }
  1786. DispInterimCharRet:
  1787. ret
  1788. DispInterimChar:
  1789. test [HjMenuStat],HjMenuMode
  1790. jnz DispInterimCharRet
  1791. ; test [KbMisc],HaveInterim
  1792. ; jz DispInterimCharRet
  1793. test [KbMisc],InterimctrlDisp
  1794. jz DispInterimCharRet
  1795. cmp [InterimCharCnt],2
  1796. jb DispInterimCharRet
  1797. test [HanStat],Han1st
  1798. jnz DispInterimCharRet
  1799. and [DisplayStat],not RunEsc
  1800. ; and [KbMisc],not HaveInterim
  1801. mov ah,0fh
  1802. int 10h
  1803. mov ah,3
  1804. int 10h
  1805. cmp [InterimDispP],dx
  1806. jnz @f
  1807. mov al,byte ptr [InterimCharBuf+2]
  1808. cmp al,[DispIChar2]
  1809. jnz @f
  1810. mov al,byte ptr [InterimCharBuf]
  1811. cmp al,[DispIChar1]
  1812. jnz @f
  1813. jmp DispInterimCharRet
  1814. @@:
  1815. mov ah,0fh
  1816. int 10h
  1817. dec ah
  1818. mov [InterimMaxCols],ah
  1819. mov ah,3
  1820. int 10h
  1821. test [KbMisc],SavedInterim
  1822. jz NormalAct
  1823. cmp [InterimCurPage],bh
  1824. jnz @f
  1825. cmp [InterimCurPos],dx
  1826. jz NormalAct
  1827. @@:
  1828. and [KbMisc],not SavedInterim
  1829. NormalAct:
  1830. mov [InterimCurPage],bh
  1831. cmp dl,[InterimMaxCols]
  1832. jb @f
  1833. mov ah,8
  1834. int 10h
  1835. mov bl,ah
  1836. mov ax,0e20h
  1837. int 10h
  1838. mov ah,3
  1839. int 10h
  1840. @@:
  1841. mov cx,1
  1842. mov ah,8
  1843. int 10h
  1844. test [KbMisc],SavedInterim
  1845. jnz @f
  1846. mov [InterimCurPos],dx
  1847. mov [SavedChar1],al
  1848. @@:
  1849. mov bl,ah
  1850. mov al,byte ptr [InterimCharBuf]
  1851. mov [DispIChar1],al
  1852. mov [InterimDispP],dx
  1853. mov ah,9
  1854. int 10h
  1855. inc dl
  1856. mov ah,2
  1857. int 10h
  1858. mov ah,8
  1859. int 10h
  1860. test [KbMisc],SavedInterim
  1861. jnz @f
  1862. or [KbMisc],SavedInterim
  1863. mov [SavedChar2],al
  1864. @@:
  1865. mov bl,ah
  1866. mov al,byte ptr [InterimCharBuf+2]
  1867. mov [DispIChar2],al
  1868. mov ah,9
  1869. int 10h
  1870. dec dl
  1871. mov ah,2
  1872. int 10h
  1873. ret
  1874. ;------------------------------------------------------------------------
  1875. ; << ClearInterimChar >>
  1876. ; FUNCTION = �̿ϼ� ���� CLEAR
  1877. ; INPUT : none
  1878. ; OUTPUT : none
  1879. ; PROTECT : AX,BX,CX,DX
  1880. ; ClearInterimChar(-/-)
  1881. ; {
  1882. ; if ([KbMisc] == SavedInterim)
  1883. ; {
  1884. ; [KbMisc] = [KbMisc] && !(SavedInterim);
  1885. ; if ([HanStat] != Han1st)
  1886. ; {
  1887. ; [DisplayStat] = [DisplayStat] && !(RunEsc);
  1888. ; AH = 0Fh
  1889. ; Int 10h
  1890. ; AH = 3
  1891. ; Int 10h
  1892. ; CX = 1
  1893. ; if (([InterimCurPage] != bh) || ([InterimCurPos] != dx))
  1894. ; {
  1895. ; xchg BH,[InterimCurPage];
  1896. ; xchg DX,[InterimCurPos];
  1897. ; AH = 2;
  1898. ; int 10h
  1899. ; AH = 8;
  1900. ; int 10h
  1901. ; if ([DispIChar1] == al)
  1902. ; {
  1903. ; DL+
  1904. ; AH = 2
  1905. ; int 10h
  1906. ; AH = 8
  1907. ; int 10h
  1908. ; if ([DispIChar2] == al)
  1909. ; {
  1910. ; DL-
  1911. ; AH = 2
  1912. ; int 10h
  1913. ; AH = 8
  1914. ; }
  1915. ; else
  1916. ; {
  1917. ; xchg BH,[InterimCurPage];
  1918. ; xchg DX,[InterimCurPos];
  1919. ; AH = 2;
  1920. ; int 10h;
  1921. ; ret;
  1922. ; }
  1923. ; else
  1924. ; {
  1925. ; xchg BH,[InterimCurPage];
  1926. ; xchg DX,[InterimCurPos];
  1927. ; AH = 2;
  1928. ; int 10h;
  1929. ; ret;
  1930. ; }
  1931. ; }
  1932. ; int 10h
  1933. ; BL = AH
  1934. ; AL = [SavedChar1]
  1935. ; AH = 9
  1936. ; int 10h
  1937. ; DL+
  1938. ; AH = 2
  1939. ; int 10h
  1940. ; AH = 8
  1941. ; int 10h
  1942. ; BL = AH
  1943. ; AL = [SavedChar2]
  1944. ; AH = 9
  1945. ; int 10h
  1946. ; xchg BH,[InterimCurPage];
  1947. ; xchg DX,[InterimCurPos];
  1948. ; AH = 2;
  1949. ; int 10h;
  1950. ; }
  1951. ; }
  1952. ; }
  1953. ClearInterimCharretj:
  1954. ret
  1955. ClearInterimChar:
  1956. test [KbMisc],SavedInterim
  1957. jz ClearInterimCharRetj
  1958. and [KbMisc],not SavedInterim
  1959. test [HanStat],Han1st
  1960. jnz ClearInterimCharRet
  1961. and [DisplayStat],not RunEsc
  1962. mov ah,0fh
  1963. int 10h
  1964. mov ah,3
  1965. int 10h
  1966. mov cx,1
  1967. cmp [InterimCurPage],bh
  1968. jnz @f
  1969. cmp [InterimCurPos],dx
  1970. jz ClearAct
  1971. @@:
  1972. xchg bh,[InterimCurPage]
  1973. xchg dx,[InterimCurPos]
  1974. mov ah,2
  1975. int 10h
  1976. mov ah,8
  1977. int 10h
  1978. cmp [DispIChar1],al
  1979. jnz @f
  1980. inc dl
  1981. mov ah,2
  1982. int 10h
  1983. mov ah,8
  1984. int 10h
  1985. cmp [DispIChar2],al
  1986. jnz @f
  1987. dec dl
  1988. mov ah,2
  1989. int 10h
  1990. ClearAct:
  1991. mov ah,8
  1992. int 10h
  1993. mov bl,ah
  1994. mov al,[SavedChar1]
  1995. mov ah,9
  1996. int 10h
  1997. inc dl
  1998. mov ah,2
  1999. int 10h
  2000. mov ah,8
  2001. int 10h
  2002. mov bl,ah
  2003. mov al,[SavedChar2]
  2004. mov ah,9
  2005. int 10h
  2006. @@:
  2007. xchg bh,[InterimCurPage]
  2008. xchg dx,[InterimCurPos]
  2009. mov ah,2
  2010. int 10h
  2011. ClearInterimCharRet:
  2012. ret
  2013. ;------------------------------------------------------------------------
  2014. ; << GetCompleteChar >>
  2015. ; FUNCTION = get character from complete character buffer
  2016. ; INPUT : none
  2017. ; OUTPUT : NC = success ; get code(AX)
  2018. ; CY = fail
  2019. ; PROTECT : AX
  2020. ; GetCompleteChar(-/AX,flag)
  2021. ; {
  2022. ; if ( CompleteCharCnt = 0 ) ret(CY);
  2023. ; else
  2024. ; {
  2025. ; AX = [CompleteCharBuf];
  2026. ; CompleteCharCnt-- ;
  2027. ; for (j=CompleteCharCnt;j=0;j--)
  2028. ; [CompleteCharBuf]=[CompleteCharBuf+2];
  2029. ; ret(AX,NC);
  2030. ; }
  2031. ; }
  2032. GetCompleteChar:
  2033. cmp [CompleteCharCnt],0
  2034. je GetCompleteCharErr
  2035. mov bx,offset CompleteCharBuf
  2036. mov ax,[bx]
  2037. mov cx,[CompletecharCnt]
  2038. dec cx
  2039. mov [CompletecharCnt],cx
  2040. jcxz GetCompleteCharRet
  2041. @@:
  2042. mov dx,[bx+2]
  2043. mov [bx],dx
  2044. add bx,2
  2045. loop @b
  2046. GetCompleteCharRet:
  2047. clc
  2048. ret
  2049. GetCompleteCharErr:
  2050. stc
  2051. ret
  2052. ;------------------------------------------------------------------------
  2053. ; << GetInterimChar >>
  2054. ; FUNCTION = get character from interim character buffer
  2055. ; INPUT : none
  2056. ; OUTPUT : NC = success ; get code(AX)
  2057. ; CY = fail
  2058. ; PROTECT : AX
  2059. ; GetInterimChar(-/AX,flag)
  2060. ; {
  2061. ; if (InterimCharCnt = 0) ret(CY);
  2062. ; else
  2063. ; {
  2064. ; AX = [InterimCharBuf];
  2065. ; InterimCharCnt--;
  2066. ; [InterimCharBuf]=[InterimCharBuf+2];
  2067. ; ret(AX,NC);
  2068. ; }
  2069. ; }
  2070. GetInterimChar:
  2071. cmp [InterimCharCnt],0
  2072. je @f
  2073. mov ax,[InterimCharBuf]
  2074. dec [InterimCharCnt]
  2075. mov dx,[InterimCharBuf+2]
  2076. mov [InterimCharBuf],dx
  2077. clc
  2078. ret
  2079. @@:
  2080. stc
  2081. ret
  2082. ;------------------------------------------------------------------------
  2083. ; << PutCompleteHg >>
  2084. ; FUNCTION = put �ѱ� code into complete character buffer
  2085. ; INPUT : none
  2086. ; OUTPUT : none
  2087. ; PROTECT : AX
  2088. ; PutCompleteHg(-/-)
  2089. ; {
  2090. ; DH=CompleteHgAttr
  2091. ; DL=AH
  2092. ; AH=DH
  2093. ; PutCompleteBuf(DX,AX/-)
  2094. ; ret
  2095. ; }
  2096. ; PutCompleteBuf(DX,AX/-)
  2097. ; {
  2098. ; BX = offset CompleteCharBuf
  2099. ; SI = [CompleteCharCnt] * 2
  2100. ; [BX+SI] = DX
  2101. ; [BX+SI+2] = AX
  2102. ; [CompleteCharCnt]+2
  2103. ; ret;
  2104. ; }
  2105. CompleteHgAttr = 0f1H ; attr of complete Hangeul code
  2106. PutCompleteHg:
  2107. mov dh,CompleteHgAttr
  2108. mov dl,ah
  2109. mov ah,dh
  2110. PutCompleteBuf:
  2111. mov bx,offset CompleteCharBuf
  2112. mov si,[CompleteCharCnt]
  2113. shl si,1
  2114. mov [bx+si],dx
  2115. add si,2
  2116. mov [bx+si],ax
  2117. add [CompleteCharCnt],2
  2118. ret
  2119. ;------------------------------------------------------------------------
  2120. ; << PutInterimHg >>
  2121. ; FUNCTION = put �ѱ� code into interim character buffer
  2122. ; INPUT : none
  2123. ; OUTPUT : none
  2124. ; PROTECT : AX
  2125. ; PutInterimHg(-/-)
  2126. ; {
  2127. ; DH=InterimHgAttr
  2128. ; DL=AL
  2129. ; AH=DH
  2130. ; [InterimCharBuf]=code;
  2131. ; [InterimCharCnt]+2;
  2132. ; [KbMisc]=[KbMisc]&&HaveInterim
  2133. ; ret;
  2134. ; }
  2135. InterimHgAttr = 0f0H ; attr of interim Hangeul code
  2136. PutInterimHg:
  2137. mov dh,InterimHgAttr
  2138. mov dl,ah
  2139. mov ah,dh
  2140. mov [InterimCharBuf],dx
  2141. mov [InterimCharBuf+2],ax
  2142. mov [InterimCharCnt],2
  2143. or [KbMisc],HaveInterim
  2144. ret
  2145. ;------------------------------------------------------------------------
  2146. ; << PutHjJjChar >>
  2147. ; FUNCTION = put Hanja/Junja characters into CcKbBuf
  2148. ; INPUT : AX (Hj codes; ah-1st, al-2nd)
  2149. ; OUTPUT : [CompleteCharBuf],[CompleteCharCnt]
  2150. ; PROTECT :
  2151. ; PutHjJjChar()
  2152. ; {
  2153. ; DH=HanjaAttr
  2154. ; DL=AH
  2155. ; AH=DH
  2156. ; PutCompleteBuf(DX,AX/-)
  2157. ; ret
  2158. ; }
  2159. HanjaAttr = 0f2H ; Hanja attr converted at CCP
  2160. PutHjJjChar:
  2161. mov dh,HanjaAttr
  2162. mov dl,ah
  2163. mov ah,dh
  2164. call PutCompleteBuf
  2165. ret
  2166. ;------------------------------------------------------------------------
  2167. ; << MakeHanjaListHg >>
  2168. ; FUNCTION = make hanja list
  2169. ; INPUT : AX = code,ES:DI = menubuffer
  2170. ; OUTPUT : none
  2171. ; PROTECT : AX
  2172. ; MakeHanjaListHg(AX,DI/AX,DI,flag)
  2173. ; {
  2174. ; if (AX is in code range)
  2175. ; {
  2176. ; CX = 0
  2177. ; DX = HjTblMax
  2178. ; if (BinarySearch(AX,CX,DX/FLAG,SI) == NC)
  2179. ; {
  2180. ; SI = SI*2 + offset IndexTbl
  2181. ; CX = [SI+2]
  2182. ; SI = [SI] + offset SetTbl
  2183. ; [TotalMenuCnt]= [TotalMenuCnt]+CL
  2184. ; do loop CX
  2185. ; [ES:DI] = [DS:SI] ;word unit
  2186. ; ret(NC);
  2187. ; }
  2188. ; else
  2189. ; ret(CY);
  2190. ; }
  2191. ; else
  2192. ; ret(CY);
  2193. ; }
  2194. HjTblMax = 473 + 18 - 1
  2195. MakeHanjaListHg:
  2196. cmp ah,0a1h
  2197. jb MakeHanjaListHgRet
  2198. cmp ah,0feh
  2199. ja MakeHanjaListHgRet
  2200. cmp al,0a1h
  2201. jb MakeHanjaListHgRet
  2202. cmp al,0feh
  2203. ja MakeHanjaListHgRet
  2204. mov bx,offset MapTbl
  2205. sub cx,cx
  2206. mov dx,HjTblMax
  2207. push ax
  2208. call BinarySearch
  2209. jc @f
  2210. shl si,1
  2211. add si,offset IndexTbl
  2212. mov ch,0
  2213. mov cl,[si+2]
  2214. mov ah,[si+3]
  2215. add [TotalMenuCnt],cl
  2216. mov si,[si]
  2217. add si,offset SetTbl
  2218. cmp ah,0
  2219. jnz GetByteHj
  2220. rep movsw
  2221. jmp @f
  2222. GetByteHj:
  2223. lodsb
  2224. stosw
  2225. loop GetByteHj
  2226. mov cl,[TotalMenuCnt]
  2227. @@:
  2228. pop ax
  2229. clc
  2230. ret
  2231. MakeHanjaListHgRet:
  2232. stc
  2233. ret
  2234. ;------------------------------------------------------------------------
  2235. ; << MakeHanjaListUdc >>
  2236. ; FUNCTION = make hanja list + udc
  2237. ; INPUT : none
  2238. ; OUTPUT : none
  2239. ; PROTECT : AX
  2240. ; MakeHanjaListUdc(AX,DI/AX,DI,flag)
  2241. ; {
  2242. ; if ([HjStat] == UdcLoaded)
  2243. ; {
  2244. ; BX = [UdcTblPtr]
  2245. ; CX = 0
  2246. ; DX = [BX+UdcMapTblSize]
  2247. ; BX = BX + [BX+UdcMapTblPtr]
  2248. ; if (BinarySearch(AX,BX,CX,DX/CY,SI)=NC)
  2249. ; {
  2250. ; BX = [UdctblPtr]
  2251. ; SI = (SI*2 + [BX+UdcMapTblPtr] + BX)
  2252. ; CX = [SI+2]
  2253. ; SI = [SI]
  2254. ; SI = (SI + [BX+UdcSetTblPtr] + BX)
  2255. ; do loop CX
  2256. ; [ES:DI] = [DS:SI] ;word unit
  2257. ; ret(NC);
  2258. ; }
  2259. ; else
  2260. ; ret(CY);
  2261. ; }
  2262. ; else
  2263. ; ret(CY);
  2264. ; }
  2265. EXTRN UdcTblPtr:word
  2266. MakeHanjaListUdc:
  2267. test [HjStat],UdcLoaded
  2268. jz @f
  2269. mov bx,[UdcTblPtr]
  2270. sub cx,cx
  2271. mov dx,[bx+UdcMapTblSize]
  2272. add bx,[bx+UdcMapTblPtr]
  2273. call BinarySearch
  2274. jc @f
  2275. mov bx,[UdcTblPtr]
  2276. shl si,1
  2277. add si,[bx+UdcIndexTblPtr]
  2278. add si,bx
  2279. mov cx,[si+2]
  2280. mov si,[si]
  2281. add si,[bx+UdcSetTblPtr]
  2282. add si,bx
  2283. add [TotalMenuCnt],cl
  2284. rep movsw
  2285. @@:
  2286. inc [TotalMenuCnt]
  2287. stosw
  2288. ret
  2289. ;------------------------------------------------------------------------
  2290. ; << BinarySearch >>
  2291. ; FUNCTION = search designated characters(word) in the given table
  2292. ; in word unit (emulate recursive call)
  2293. ; INPUT : AX (codes; ah-1st, al-2nd)
  2294. ; BX (table start address)
  2295. ; CX (low byte-index)
  2296. ; DX (high byte-index = # of items - 1)
  2297. ; OUTPUT : SI (word-index of matching code), if CC=0(NC)
  2298. ; no found, if CC=1(CY)
  2299. ; PROTECT : cx, dx, si
  2300. ; BinarySearch()
  2301. ; {
  2302. ; while (CX <= DX) && (AX != [BX+SI])
  2303. ; {
  2304. ; SI = (CX+DX)
  2305. ; SI = SI && (not 1)
  2306. ; if (AX > [BX+SI])
  2307. ; {
  2308. ; SI = (SI/2)+1
  2309. ; CX = SI
  2310. ; }
  2311. ; if (AX < [BX+SI])
  2312. ; {
  2313. ; SI = (SI/2)-1
  2314. ; DX = SI
  2315. ; }
  2316. ; }
  2317. ; if (AX = [BX+SI])
  2318. ; ret(NC,SI);
  2319. ; else
  2320. ; ret(CY);
  2321. BinarySearch:
  2322. cmp cx,dx
  2323. jg NotFound
  2324. mov si,cx
  2325. add si,dx
  2326. and si,not 1
  2327. cmp ax,[bx+si]
  2328. ja HighPart
  2329. je Found
  2330. LowPart:
  2331. shr si,1
  2332. dec si
  2333. mov dx,si
  2334. jmp BinarySearch
  2335. HighPart:
  2336. shr si,1
  2337. inc si
  2338. mov cx,si
  2339. jmp BinarySearch
  2340. NotFound:
  2341. stc
  2342. Found:
  2343. ret
  2344. ;------------------------------------------------------------------------
  2345. ; << TrapHjMenu >>
  2346. ; FUNCTION = ���� menu display�� ���� control
  2347. ; INPUT : none
  2348. ; OUTPUT : ZR = next / back or other key
  2349. ; CY = escape key in flag
  2350. ; NZ,NC= success flag, AX = hanja code
  2351. ; PROTECT : AX
  2352. ; TrapHjMenu(AX/flag,AL,BX)
  2353. ; switch(AX)
  2354. ; {
  2355. ; case next menu key: /* right arrow */
  2356. ; {
  2357. ; get maximum menu counter;
  2358. ; if ( maximum menu counter > # of hanja menu 1 line )
  2359. ; {
  2360. ; get menu pointer;
  2361. ; add current menu counter to menu pointer;
  2362. ; if ( menu pointer >= maximum menu counter )
  2363. ; set menu pointer to 0;
  2364. ; set (MaximumMenuCounter-MenuPointer) to CurMenuCnt
  2365. ; if ( not last menu )
  2366. ; set CurMenuCnt to # of hanja menu 1 line;
  2367. ; DisplayHanja();
  2368. ; ret(ZR);
  2369. ; }
  2370. ; break;
  2371. ; }
  2372. ; case back menu key: /* left arrow */
  2373. ; {
  2374. ; if (maximum menu counter > # of hanja menu 1 line) &
  2375. ; menu pointer is not 0 )
  2376. ; {
  2377. ; sub # of hanja menu 1 line from menu pointer;
  2378. ; set current menu counter to # of hanja menu 1 line;
  2379. ; DisplayHanja();
  2380. ; ret(ZR);
  2381. ; }
  2382. ; break;
  2383. ; }
  2384. ; case "esc":
  2385. ; {
  2386. ; ret(CY);
  2387. ; }
  2388. ; case "0" =< AX =< "9"
  2389. ; {
  2390. ; if (the code =< current menu counter)
  2391. ; {
  2392. ; get selected code;
  2393. ; ret(NZ,NC,AX);
  2394. ; }
  2395. ; }
  2396. ; default:
  2397. ; {
  2398. ; beep();
  2399. ; ret(ZR);
  2400. ; }
  2401. TrapHjMenu:
  2402. cmp al,030h
  2403. jb @f
  2404. cmp al,039h
  2405. jbe TrapHjNum
  2406. @@:
  2407. cmp ah,04dh
  2408. je TrapHjNextMenu
  2409. cmp ah,04bh
  2410. je TrapHjBackMenu
  2411. cmp al,EscKey
  2412. je TrapHjMenuAbort
  2413. jmp TrapHjMenuErr
  2414. TrapHjNum:
  2415. sub al,030h
  2416. cbw
  2417. cmp al,[CurrMenuCnt]
  2418. jae TrapHjMenuErr
  2419. xor bh,bh
  2420. mov bl,[MenuPtr]
  2421. add bx,ax
  2422. shl bx,1
  2423. mov ax,[bx+MenuBuffer]
  2424. xchg ah,al
  2425. or ax,ax
  2426. ret
  2427. TrapHjNextMenu:
  2428. mov ah,[TotalMenuCnt]
  2429. cmp ah,HjNumOf1Line
  2430. jbe TrapHjMenuRet
  2431. mov al,[MenuPtr]
  2432. add al,[CurrMenuCnt]
  2433. cmp al,ah
  2434. jb @f
  2435. sub al,al
  2436. @@:
  2437. mov [MenuPtr],al
  2438. neg al
  2439. add al,ah
  2440. cmp al,HjNumOf1Line
  2441. jbe @f
  2442. mov al,HjNumOf1Line
  2443. @@:
  2444. mov [CurrMenuCnt],al
  2445. call DisplayHanja
  2446. jmp TrapHjMenuRet
  2447. TrapHjBackMenu:
  2448. cmp [TotalMenuCnt],HjNumOf1Line
  2449. jbe TrapHjMenuErr
  2450. cmp [MenuPtr],0
  2451. je TrapHjMenuErr
  2452. sub [MenuPtr],HjNumOf1Line
  2453. mov [CurrMenuCnt],HjNumOf1Line
  2454. call DisplayHanja
  2455. jmp TrapHjMenuRet
  2456. TrapHjMenuAbort:
  2457. stc
  2458. ret
  2459. TrapHjMenuErr:
  2460. call Beep
  2461. TrapHjMenuRet:
  2462. sub ax,ax
  2463. ret
  2464. ;------------------------------------------------------------------------
  2465. ; << SaveMenuLine >>
  2466. ; FUNCTION = save ����menuǥ����
  2467. ; INPUT : none
  2468. ; OUTPUT : none
  2469. ; PROTECT : AX
  2470. ; SaveMenuLine(-/-)
  2471. ; {
  2472. ; AH = 0Fh;
  2473. ; int 10h
  2474. ; [SaveCurrPage] = bh;
  2475. ; [CrtMaxCols] = ah;
  2476. ; AH = 3;
  2477. ; int 10h
  2478. ; [SaveCurPos] = dx;
  2479. ; [SaveCurType] = cx;
  2480. ; CX = 2020h;
  2481. ; AH = 1;
  2482. ; int 10h
  2483. ; DL = 0;
  2484. ; DH = [HjMenuLine];
  2485. ; AH = 2;
  2486. ; int 10h
  2487. ; CL = [CrtMaxCols];
  2488. ; DI = offset MenuLineBuf
  2489. ; loop(CL)
  2490. ; {
  2491. ; AH = 8
  2492. ; int 10h
  2493. ; [ES:DI] = AX
  2494. ; +DL
  2495. ; AH = 2
  2496. ; int 10h
  2497. ; }
  2498. ; if ([TotalMenuCnt] > HjNumOf1Line)
  2499. ; [CurrMenuCnt] = HjNumOf1Line;
  2500. ; else
  2501. ; [CurrMenuCnt] = [TotalMenuCnt];
  2502. ; DisplayHanja();
  2503. ; ret;
  2504. SaveMenuLine:
  2505. mov ah,0fh
  2506. int 10h
  2507. mov [SaveCurrPage],bh
  2508. mov [CrtMaxCols],ah
  2509. mov [ModeVal],6*2
  2510. cmp al,060h
  2511. jz @f
  2512. cmp al,011h
  2513. jz @f
  2514. cmp al,012h
  2515. jz @f
  2516. mov [ModeVal],0*2
  2517. @@:
  2518. mov ah,3
  2519. int 10h
  2520. mov [SaveCurPos],dx
  2521. mov [SaveCurType],cx
  2522. mov cx,2020h
  2523. mov ah,1
  2524. int 10h
  2525. xor dl,dl
  2526. mov dh,[HjMenuLine]
  2527. mov ah,2
  2528. int 10h
  2529. xor ch,ch
  2530. mov cl,[CrtMaxCols]
  2531. mov di, offset MenuLineBuf
  2532. @@:
  2533. mov ah,8
  2534. int 10h
  2535. stosw
  2536. inc dl
  2537. mov ah,2
  2538. int 10h
  2539. loop @b
  2540. mov al,[TotalMenuCnt]
  2541. cmp al,HjNumOf1Line
  2542. jbe @f
  2543. mov al,HjNumOf1Line
  2544. @@:
  2545. mov [CurrMenuCnt],al
  2546. call DisplayHanja
  2547. ret
  2548. ;------------------------------------------------------------------------
  2549. ; << RestoreMenuline >>
  2550. ; FUNCTION = restore ����menuǥ����
  2551. ; INPUT : none
  2552. ; OUTPUT : none
  2553. ; PROTECT : AX
  2554. ; RestoreMenuline(-/-)
  2555. ; {
  2556. ; BH = [SaveCurrPage]
  2557. ; DL =0
  2558. ; DH = [HjMenuLine]
  2559. ; AH = 2
  2560. ; int 10h
  2561. ; CL = [CrtMaxCols]
  2562. ; SI = offset MenuLineBuf
  2563. ; loop (CX)
  2564. ; {
  2565. ; DI = CX
  2566. ; AX = [DS:SI]
  2567. ; /* display the char */
  2568. ; /* set cursor position */
  2569. ; CX = DI
  2570. ; }
  2571. ; DX = [SaveCurPos]
  2572. ; AH = 2
  2573. ; int 10h
  2574. ; CX = [SaveCurType]
  2575. ; AH = 1
  2576. ; int 10h
  2577. ; }
  2578. RestoreMenuline:
  2579. xor dl,dl
  2580. mov [MenuPtr],dl
  2581. mov bh,[SaveCurrPage]
  2582. mov dh,[HjMenuLine]
  2583. mov ah,2
  2584. int 10h
  2585. xor ch,ch
  2586. mov cl,[CrtMaxCols]
  2587. mov si,offset MenuLineBuf
  2588. @@:
  2589. mov di,cx
  2590. lodsw
  2591. mov cx,1
  2592. mov bl,ah
  2593. mov ah,9
  2594. int 10h
  2595. inc dl
  2596. mov ah,2
  2597. int 10h
  2598. mov cx,di
  2599. loop @b
  2600. mov dx,[SaveCurPos]
  2601. mov ah,2
  2602. int 10h
  2603. mov cx,[SaveCurType]
  2604. mov ah,1
  2605. int 10h
  2606. ret
  2607. ;------------------------------------------------------------------------
  2608. EXTRN ChgKs2Ch7:near
  2609. Ch2KsAuto:
  2610. test [CodeStat],Chab
  2611. jnz ChabAuto
  2612. ; test [CodeStat],Wsung7
  2613. ; jnz @f
  2614. jmp Ch2Ks
  2615. @@:
  2616. call Ch2Ks
  2617. jc @f
  2618. call ChgKs2Ch7
  2619. @@:
  2620. ret
  2621. ChabAuto:
  2622. test [CodeStat],InstPatGen
  2623. jnz @f
  2624. push ax
  2625. call Ch2Ks
  2626. pop ax
  2627. ret
  2628. @@:
  2629. clc
  2630. ret
  2631. ;------------------------------------------------------------------------
  2632. ; << Ch2Ks >>
  2633. ; FUNCTION = convert chohab code to wansung code
  2634. ; INPUT : AX(XXYY)
  2635. ; OUTPUT : NC ;AX=�ϼ��ڵ�
  2636. ; CY ;fail
  2637. ; PROTECT : AX
  2638. ; Ch2Ks(AX/AX,flag)
  2639. ; {
  2640. ; AH = AH - 80h
  2641. ; SI = offset ChHgIndexTbl
  2642. ; /* get DX=# of (XX-1) list */
  2643. ; CL = # of XX list
  2644. ; SI = offset XX list
  2645. ; if (LinearByteSearch(SI,CX/CC,BX) == NC)
  2646. ; {
  2647. ; BL = 05Eh
  2648. ; AX = SI + DX
  2649. ; AH = AX/BL ...AL
  2650. ; AX = AX + B0A1h
  2651. ; ret(NC);
  2652. ; }
  2653. ; SI = offset ChHgCTbl
  2654. ; CX = ChHgWLng-1
  2655. ; if (LinearWordSearch((SI,CX/CC,BX) == NC)
  2656. ; {
  2657. ; SI = SI/2
  2658. ; AH = 0A4h
  2659. ; BX = offset ChHgWTbl
  2660. ; AL = [SI+BX]
  2661. ; ret(NC);
  2662. ; }
  2663. ; ret(CY);
  2664. ; }
  2665. PUBLIC ChHgWTbl, ChHgWLng, ChHgCTbl, ChHgIndexTbl, ah88h
  2666. PUBLIC Ch2Ks, LinearWordSearch, LinearByteSearch
  2667. Ch2Ks:
  2668. @push cx,dx,si,di,es,ds
  2669. push ax
  2670. mov bx,cs
  2671. mov ds,bx
  2672. mov es,bx
  2673. cmp ax,08442h
  2674. jb Ch2KsErr
  2675. cmp ax,0845dh
  2676. ja @f
  2677. cmp ax,08452h
  2678. je Ch2KsErr
  2679. call Ch2Kscompn
  2680. jmp Ch2KsSuccess
  2681. @@:
  2682. mov si,offset ChHgCTbl
  2683. mov cx,ChHgWLng+1
  2684. call LinearWordSearch
  2685. jc @f
  2686. shr bx,1
  2687. mov ah,0a4h
  2688. mov si,offset ChHgWTbl
  2689. mov al,byte ptr [si+bx]
  2690. jmp Ch2KsSuccess
  2691. @@:
  2692. cmp ah,088h
  2693. jb Ch2KsErr
  2694. sub ah,088h
  2695. mov si,offset ChHgIndexTbl
  2696. xor bx,bx
  2697. mov cx,bx
  2698. mov dx,bx
  2699. mov bl,ah
  2700. mov cl,bl
  2701. shl bx,1
  2702. add bx,cx
  2703. cmp ah,0
  2704. je @f
  2705. mov dx,[si+bx+1]
  2706. mov cx,[si+1]
  2707. sub dx,cx
  2708. @@:
  2709. xor ch,ch
  2710. mov cl,[si+bx]
  2711. mov si,[si+bx+1]
  2712. call LinearByteSearch
  2713. jc Ch2KsErr
  2714. mov ax,bx
  2715. add ax,dx
  2716. mov bl,05eh
  2717. div bl
  2718. xchg ah,al
  2719. add ax,0B0A1h
  2720. Ch2KsSuccess:
  2721. clc
  2722. pop bx
  2723. @pop ds,es,di,si,dx,cx
  2724. ret
  2725. Ch2KsErr:
  2726. stc
  2727. pop ax
  2728. @pop ds,es,di,si,dx,cx
  2729. ret
  2730. Ch2Kscompn:
  2731. mov ah,0a4h
  2732. add al,05fh
  2733. cmp al,0a8h
  2734. jb @f
  2735. add al,1
  2736. cmp al,0b2h
  2737. jb @f
  2738. sub al,1
  2739. cmp al,0b3h
  2740. jb @f
  2741. add al,1
  2742. cmp al,0b9h
  2743. jb @f
  2744. add al,1
  2745. @@:
  2746. ret
  2747. ;------------------------------------------------------------------------
  2748. ; << Ks2Ch >>
  2749. ; FUNCTION = convert chohab code to wansung code
  2750. ; INPUT : AX(XXYY)
  2751. PUBLIC Ks2Ch
  2752. Ks2Ch:
  2753. @push cx,dx,si,di,es,ds
  2754. push ax
  2755. mov bx,cs
  2756. mov ds,bx
  2757. mov es,bx
  2758. cmp ah,0a4h
  2759. jne Ks2ChHg
  2760. mov si,offset ChHgWTbl
  2761. mov cx,ChHgWLng+1
  2762. call LinearByteSearch
  2763. jc Ks2ChHg
  2764. shl bx,1
  2765. mov si,offset ChHgCTbl
  2766. mov ax,word ptr [si+bx]
  2767. jmp Ks2ChEnd
  2768. Ks2ChHg:
  2769. mov si,offset ah88h
  2770. sub ax,0B0A1h
  2771. mov bx,ax
  2772. mov al,ah
  2773. mov ah,0A2h
  2774. mul ah
  2775. sub bx,ax
  2776. mov al,[bx+si]
  2777. cmp al,0
  2778. je Ks2ChErr
  2779. mov si,offset ChHgIndexTbl
  2780. xor dx,dx
  2781. mov cx,dx
  2782. mov ah,dh
  2783. @@:
  2784. mov cl,[si]
  2785. add dx,cx
  2786. cmp bx,dx
  2787. jb short @f
  2788. add si,3
  2789. inc ah
  2790. jmp short @b
  2791. @@:
  2792. add ah,088h
  2793. Ks2ChEnd:
  2794. clc
  2795. pop bx
  2796. @pop ds,es,di,si,dx,cx
  2797. ret
  2798. Ks2ChErr:
  2799. pop ax
  2800. @pop ds,es,di,si,dx,cx
  2801. stc
  2802. ret
  2803. ;------------------------------------------------------------------------
  2804. ; << linearWordSearch >>
  2805. ; linearWordSearch()
  2806. ; FUNCTION = linear search word unit
  2807. ; INPUT : none
  2808. ; OUTPUT : BX (index) , if CC=0(NC)
  2809. ; not found , if CC=1(CY)
  2810. ; PROTECT : AX
  2811. ;
  2812. linearWordSearch:
  2813. xor bx,bx
  2814. @@:
  2815. cmp ax,[si+bx]
  2816. je @f
  2817. add bx,2
  2818. loop @b
  2819. stc
  2820. @@:
  2821. ret
  2822. ;------------------------------------------------------------------------
  2823. ; << LinearByteSearch >>
  2824. ; FUNCTION = linear search byte unit
  2825. ; INPUT : SI = pointer of list
  2826. ; CX = # of list
  2827. ; OUTPUT : BX (index), if CC=0(NC)
  2828. ; not found , if CC=1(CY)
  2829. ; PROTECT : AX
  2830. LinearByteSearch:
  2831. xor bx,bx
  2832. @@:
  2833. cmp [si+bx],al
  2834. je @f
  2835. inc bx
  2836. loop @b
  2837. stc
  2838. @@:
  2839. ret
  2840. ;------------------------------------------------------------------------
  2841. ; << Ban2Jun >>
  2842. ; FUNCTION = code conversion from Banja to Junja if needed
  2843. ; INPUT : AX (English raw code)
  2844. ; OUTPUT : none ([CcKbCnt], [CcKbBuf])
  2845. ; PROTECT : AX, BX, DX, SI
  2846. ; Ban2Jun(AX/AX,flag)
  2847. ; {
  2848. ; BX = AX;
  2849. ; if ((!BH) && (BL>=' ') && (BL <= '~'))
  2850. ; {
  2851. ; if (BL = ' ')
  2852. ; AX = 0a1a1h;
  2853. ; else
  2854. ; {
  2855. ; if (BL = '~')
  2856. ; AX = 0a1adh;
  2857. ; else
  2858. ; {
  2859. ; AH = 0a3h;
  2860. ; AL = AL || 80h;
  2861. ; }
  2862. ; }
  2863. ; if ([CodeStat] == Chab)
  2864. ; ChgKs2Ch(AX/AX,BX,flag);
  2865. ; /* reset carry */
  2866. ; }
  2867. ; else
  2868. ; AX = BX;
  2869. ; /* set carry */
  2870. ; }
  2871. BlankChar = ' '
  2872. TildeChar = '~'
  2873. JunjaBlankCode = 0a1a1H
  2874. JunjaTildeCode = 0a1adH
  2875. Junja1stCode = 0a3H
  2876. Ban2Jun:
  2877. test [KbStat],JJStat
  2878. jnz PutJunja
  2879. PutBanja:
  2880. mov bx,offset CompleteCharBuf
  2881. mov si,[CompleteCharCnt]
  2882. shl si,1
  2883. mov [bx+si],ax
  2884. inc [CompleteCharCnt]
  2885. ret
  2886. PutJunja:
  2887. or ah,ah
  2888. jz PutBanja
  2889. cmp al,BlankChar
  2890. je PutJunjaBlank
  2891. jb PutBanja
  2892. cmp al,TildeChar
  2893. je PutJunjaTilde
  2894. ja PutBanja
  2895. mov ah,Junja1stCode
  2896. or al,80H
  2897. call PutHjJjChar
  2898. ret
  2899. PutJunjaBlank:
  2900. mov ax,JunjaBlankCode
  2901. call PutHjJjChar
  2902. ret
  2903. PutJunjaTilde:
  2904. mov ax,JunjaTildeCode
  2905. call PutHjJjChar
  2906. ret
  2907. ;------------------------------------------------------------------------
  2908. ; << InitHjMenu >>
  2909. ; FUNCTION = prepare KS Hangeul code to Hanja code conversion
  2910. ; INPUT : none ([KbStatus])
  2911. ; OUTPUT : none (prepare KS Hangeul to Hanja conversion)
  2912. ; if there's no Hj for given Hg, beep & no action
  2913. ; PROTECT : ax, bx, cx, dx, si
  2914. ; InitHjMenu()
  2915. ; {
  2916. ; if ([HjStat] == HjModeEnable)
  2917. ; {
  2918. ; AH = 0Fh;
  2919. ; int 10h;
  2920. ; BL = AH; /* column */
  2921. ; AH = 3;
  2922. ; int 10h;
  2923. ; +DL
  2924. ; if (DL < BL)
  2925. ; AH = 8;
  2926. ; int 10h /* read char/attr at current cursor pos */
  2927. ; CH = AL;
  2928. ; +DL
  2929. ; AH = 2;
  2930. ; int 10h;
  2931. ; AH = 8;
  2932. ; int 10h;
  2933. ; CL = AL;
  2934. ; -DL
  2935. ; AH = 2;
  2936. ; int 10h;
  2937. ; AX = CX;
  2938. ; if (MakeHanjaList(AX/AL) == 0
  2939. ; {
  2940. ; SaveMenuLine();
  2941. ; [HjMenuStat] = [HjMenuStat] || HjMenuMode;
  2942. ; }
  2943. ; else
  2944. ; {
  2945. ; Beep();
  2946. ; AutoReset(-/-);
  2947. ; }
  2948. ; }
  2949. ; else
  2950. ; {
  2951. ; CX = AX;
  2952. ; AutoReset(-/-);
  2953. ; AX = CX;
  2954. ; PutBanja(AX/-);
  2955. ; }
  2956. InitHjMenu:
  2957. test [HjStat],HjModeEnable
  2958. jz InitHjMenuQuit
  2959. mov ah,0fh
  2960. int 10h
  2961. mov bl,ah
  2962. inc bl
  2963. mov ah,3
  2964. int 10h
  2965. cmp dl,bl
  2966. jae InitHjMenuErr
  2967. mov ah,8
  2968. int 10h
  2969. mov ch,al
  2970. inc dl
  2971. mov ah,2
  2972. int 10h
  2973. mov ah,8
  2974. int 10h
  2975. mov cl,al
  2976. dec dl
  2977. mov ah,2
  2978. int 10h
  2979. mov bx,cx
  2980. call MakeHanjaList
  2981. or al,al
  2982. jnz InitHjMenuErr
  2983. call SaveMenuLine
  2984. or [HjMenuStat],HjMenuMode
  2985. ret
  2986. InitHjMenuErr:
  2987. call Beep
  2988. call AutoReset
  2989. ret
  2990. InitHjMenuQuit:
  2991. call AutoReset
  2992. mov ax,0f100h
  2993. call PutBanja
  2994. ret
  2995. ;------------------------------------------------------------------------
  2996. ; << HjMenuSelect >>
  2997. ; FUNCTION = select one from Hanja menu by numeric key('0'-'9')
  2998. ; and put them into CcKbBuf & clear automata state,
  2999. ; process next(right)/back(left) menu key & abort(Esc)
  3000. ; INPUT : ax (English raw code), Hanja Menu List
  3001. ; OUTPUT : [CcKbCnt], [CcKbBuf]<-(Hanja code), if selected
  3002. ; and restore menu line & cursor position,
  3003. ; no action(escape from this mode), if Esc,
  3004. ; prepare next/prev menu, if NextMenuKey/BackMenuKey,
  3005. ; no action, if any other key is pressed(ignore key-in)
  3006. ; PROTECT : ax, bx, cx, dx, si
  3007. ; HjMenuSelect()
  3008. ; {
  3009. ; if (TrapHjMenu(AX/CC,ZF,AX) == CY)
  3010. ; {
  3011. ; RestoreMenuLine();
  3012. ; [HjMenuStat] = [HjMenuStat] && !(HjMenuMode)
  3013. ; }
  3014. ; if (TrapHjMenu(AX/CC,ZF,AX) == NC && NZ)
  3015. ; {
  3016. ; PutHjJjChar(AX/-);
  3017. ; InitHanState(-/-);
  3018. ; RestoreMenuLine();
  3019. ; [HjMenuStat] = [HjMenuStat] && !(HjMenuMode)
  3020. ; }
  3021. ; }
  3022. HjMenuSelect:
  3023. call TrapHjMenu
  3024. jc AbortHjMenuSelect
  3025. jz @f
  3026. call PutHjJjChar
  3027. call InitHanState
  3028. AbortHjMenuSelect:
  3029. call RestoreMenuLine
  3030. and [HjMenuStat],not HjMenuMode
  3031. @@:
  3032. ret
  3033. ;------------------------------------------------------------------------
  3034. ; << Automata >>
  3035. ; Automata(AX/-)
  3036. ; FUNCTION = �ѱ� Automata
  3037. ; INPUT : AX=code(english law code)
  3038. ; OUTPUT : none,CompleteKbBuf,InterimKbBuf
  3039. ; PROTECT : AX,BX
  3040. ;
  3041. ; {
  3042. ; if ( HanVdMode )
  3043. ; {
  3044. ; if ( SupportHj & HjMenuMode )
  3045. ; {
  3046. ; if ( the code is HanjaKey ), Beep(); ret;
  3047. ; HjMenuSelect();
  3048. ; ret;
  3049. ; }
  3050. ; if ( SupportHj )
  3051. ; if ( the code is HanjaKey ), InitHjMenu(); ret;
  3052. ; else
  3053. ; if ( the code is HanjaKey ), EngVdModeAuto(); ret;
  3054. ; endif
  3055. ; switch([CodeStat])
  3056. ; case BanJunKey: ToggleBanJun(); break;
  3057. ; case HanEngKey: ToggleHanEng(); break;
  3058. ; default:
  3059. ; {
  3060. ; if HanKinMode, HangeulAutomata(); Break;
  3061. ; else Ban2Jun();
  3062. ; }
  3063. ; }
  3064. ; else
  3065. ; {
  3066. ; ResetAotomata();
  3067. ; CompleteKbBuf=AX
  3068. ; }
  3069. ; ret;
  3070. ; }
  3071. fFillCode = 04h
  3072. vFillCode = 40h
  3073. lFillCode = 01h
  3074. MsbCode = 80h
  3075. Automata:
  3076. test [KbStat],HanKeyinMode
  3077. jz EngVdModeAuto
  3078. test [HjStat],HjLoaded
  3079. jz NonSupportHj
  3080. test [HjMenuStat],HjMenuMode
  3081. jz @f
  3082. cmp ax,HanjaKey
  3083. jne HjMenuSelect
  3084. call beep
  3085. ret
  3086. @@:
  3087. cmp ax,HanjaKey
  3088. jne NonSupportHj
  3089. mov ax,0f100h
  3090. jmp InitHjMenu
  3091. NonSupportHj:
  3092. cmp ax,HanjaKey
  3093. jne @f
  3094. mov ax,0f100h
  3095. jmp EngVdModeAuto
  3096. @@:
  3097. cmp ax,BanJunKey
  3098. je ToggleBanJunInMode
  3099. cmp ax,HanEngKey
  3100. je ToggleHanEngInMode
  3101. cmp [HeKey],ah
  3102. jne @f
  3103. or al,al
  3104. jnz @f
  3105. ret
  3106. @@:
  3107. cmp [HjKey],ah
  3108. jne @f
  3109. or al,al
  3110. jnz @f
  3111. ret
  3112. @@:
  3113. test [KbStat],HEStat
  3114. jnz HangeulAutomata
  3115. jmp Ban2Jun
  3116. EngVdModeAuto:
  3117. call AutoReset
  3118. call PutBanja
  3119. ret
  3120. ToggleBanJunInMode:
  3121. call ToggleBanJun
  3122. ret
  3123. ToggleHanEngInMode:
  3124. xor [KbStat],HEStat
  3125. ;------------------------------------------------------------------------
  3126. ; << AutoReset >>
  3127. ; AutoReset()
  3128. ; FUNCTION =
  3129. ; INPUT : none
  3130. ; OUTPUT : none
  3131. ; PROTECT : AX
  3132. ; {
  3133. ; [HjMenuStat] = [HjMenuStat] && !(HjMenuMode)
  3134. ; if ( Auto != 0 )
  3135. ; {
  3136. ; AX = [KsKbBuf];
  3137. ; PutCompleteHg(AX);
  3138. ; }
  3139. ; InitHanState();
  3140. ; ret;
  3141. ; }
  3142. ;
  3143. AutoReset:
  3144. cmp [Auto],0
  3145. jz InitHanState
  3146. push ax
  3147. mov ax,[KsKbBuf]
  3148. call PutCompleteHg
  3149. pop ax
  3150. ;------------------------------------------------------------------------
  3151. ; << InitHanState >>
  3152. ; InitHanState()
  3153. ; FUNCTION =
  3154. ; INPUT : none
  3155. ; OUTPUT : none
  3156. ; PROTECT : AX
  3157. ; {
  3158. ; Auto = 0;
  3159. ; InterimCharCnt = 0;
  3160. ; TmpBufCnt = 0;
  3161. ; ret;
  3162. ; }
  3163. InitHanState:
  3164. mov [Auto],0
  3165. mov [InterimCharCnt],0
  3166. mov [TmpBufCnt],0
  3167. ret
  3168. ;------------------------------------------------------------------------
  3169. ; << HangeulAutomata >>
  3170. ; HangeulAutomata()
  3171. ; FUNCTION =
  3172. ; INPUT : AX=english code
  3173. ; OUTPUT : CompleteKbBuf,InterimKbBuf
  3174. ; PROTECT : AX
  3175. ;
  3176. ; type0= DC (Double Consonant)-- ��,��,��,��
  3177. ; type1= SC (Single Consonant)-- ��,��,��,��,��,��
  3178. ; ��,��,��,��,��,��
  3179. ; type2= FC (First Consonant)--- ��,��,��
  3180. ; type3= SV (Single Vowel)------ ��,��,��,��,��,��
  3181. ; ��,��,��,��,��
  3182. ; type4= DV (Double Vowel)------ ��,��,��
  3183. ; ������������������������������������������������������������������������������
  3184. ; �� ��0 DC ��1 SC ��2 FC ��3 SV ��4 DV ��
  3185. ; �� �� �� �� �� �� �� �� �� �� �� ��
  3186. ; ������������������������������������������������������������������������������
  3187. ; ��a0 �� �� �� �� �� ��
  3188. ; �� �� 1�� 2�� 2�� 4�� 5��
  3189. ; ������������������������������������������������������������������������������
  3190. ; ��a1 DC �� �� �� �� �� ��
  3191. ; �� �� �� 3�� 3�� 2�� 7�� 8��
  3192. ; ������������������������������������������������������������������������������
  3193. ; ��a2 SC,FC�� �� �� �� �� ��
  3194. ; �� ��,���� 1�� 2�� 2�� 7�� 8��
  3195. ; ������������������������������������������������������������������������������
  3196. ; ��a3 DC+C �� �� �� �� �� ��
  3197. ; �� �� �� 1�� 2�� 2�� 7�� 8��
  3198. ; ������������������������������������������������������������������������������
  3199. ; ��a4 SV �� �� �� �� �� ��
  3200. ; �� �� �� 1�� 2�� 2�� 4�� 5��
  3201. ; ������������������������������������������������������������������������������
  3202. ; ��a5 DV �� �� �� �� �� ��
  3203. ; �� �� �� 1�� 2�� 2�� 6�� 5��
  3204. ; ������������������������������������������������������������������������������
  3205. ; ��a6 DV+SV �� �� �� �� �� ��
  3206. ; �� �� �� 1�� 2�� 2�� 4�� 5��
  3207. ; ������������������������������������������������������������������������������
  3208. ; ��a7 C+SV �� �� �� �� �� ��
  3209. ; �� �� �� A�� B�� 2�� 4�� 5��
  3210. ; ������������������������������������������������������������������������������
  3211. ; ��a8 C+DV �� �� �� �� �� ��
  3212. ; �� �� �� A�� B�� 2�� 9�� 5��
  3213. ; ������������������������������������������������������������������������������
  3214. ; ��a9 C+DV+SV �� �� �� �� �� ��
  3215. ; �� �� �� A�� B�� 2�� 4�� 5��
  3216. ; ������������������������������������������������������������������������������
  3217. ; ��aA C+V+DC �� �� �� �� �� ��
  3218. ; �� �� �� C�� C�� 2�� 7�� 8��
  3219. ; ������������������������������������������������������������������������������
  3220. ; ��aB C+V+SC �� �� �� �� �� ��
  3221. ; �� �� �� 1�� 2�� 2�� 7�� 8��
  3222. ; ������������������������������������������������������������������������������
  3223. ; ��aC C+V+DC+C �� �� �� �� �� ��
  3224. ; �� �� �� 1�� 2�� 2�� 7�� 8��
  3225. ; ������������������������������������������������������������������������������
  3226. HangeulAutomata:
  3227. or ah,ah
  3228. jz @f
  3229. cmp al,041h
  3230. jb @f
  3231. cmp al,05ah
  3232. jbe Eng2HanAuto
  3233. cmp al,061h
  3234. jb @f
  3235. cmp al,07ah
  3236. jbe Eng2HanAuto
  3237. @@:
  3238. cmp [Auto],0
  3239. je @f
  3240. mov cx,ax
  3241. mov ax,[KsKbBuf]
  3242. call PutCompleteHg
  3243. call InitHanState
  3244. mov ax,cx
  3245. @@:
  3246. call Ban2Jun
  3247. ret
  3248. Eng2HanAuto:
  3249. mov bx,[CurInCode]
  3250. mov [PreInCode],bx
  3251. mov [CurInCode],ax
  3252. mov bx,offset TypeTbl
  3253. sub cx,cx
  3254. mov cl,al
  3255. sub cl,041h
  3256. add bx,cx
  3257. mov cl,[bx]
  3258. sub bx,bx
  3259. mov bl,[Auto]
  3260. mov bh,bl
  3261. shl bl,1
  3262. shl bl,1
  3263. add bl,bh
  3264. xor bh,bh
  3265. add bx,cx
  3266. add bx,offset StateTbl
  3267. mov bl,[bx]
  3268. mov [Auto],bl
  3269. sub bh,bh
  3270. shl bx,1
  3271. jmp word ptr [bx+ActTbl]
  3272. TypeTbl:
  3273. db 001h,003h,001h,001h,002h,000h,001h,004h,003h,003h,003h,003h,004h
  3274. db 004h,003h,003h,002h,001h,000h,001h,003h,001h,002h,001h,003h,001h
  3275. db 00,00,00,00,00,00
  3276. db 001h,003h,001h,001h,001h,000h,001h,004h,003h,003h,003h,003h,004h
  3277. db 004h,003h,003h,000h,000h,000h,001h,003h,001h,001h,001h,003h,001h
  3278. StateTbl:
  3279. ; 0 state
  3280. db 01h,02h,02h,04h,05h
  3281. ; 1 state
  3282. db 03h,03h,02h,07h,08h
  3283. ; 2 state
  3284. db 01h,02h,02h,07h,08h
  3285. ; 3 state
  3286. db 01h,02h,02h,07h,08h
  3287. ; 4 state
  3288. db 01h,02h,02h,04h,05h
  3289. ; 5 state
  3290. db 01h,02h,02h,06h,05h
  3291. ; 6 state
  3292. db 01h,02h,02h,04h,05h
  3293. ; 7 state
  3294. db 0Ah,0Bh,02h,04h,05h
  3295. ; 8 state
  3296. db 0Ah,0Bh,02h,09h,05h
  3297. ; 9 state
  3298. db 0Ah,0Bh,02h,04h,05h
  3299. ; A state
  3300. db 0Ch,0Ch,02h,07h,08h
  3301. ; B state
  3302. db 01h,02h,02h,07h,08h
  3303. ; C state
  3304. db 01h,02h,02h,07h,08h
  3305. ;action table
  3306. ActTbl label word
  3307. dw offset Act0
  3308. dw offset Act1
  3309. dw offset Act2
  3310. dw offset Act3
  3311. dw offset Act4
  3312. dw offset Act5
  3313. dw offset Act6
  3314. dw offset Act7
  3315. dw offset Act8
  3316. dw offset Act9
  3317. dw offset ActA
  3318. dw offset ActB
  3319. dw offset ActC
  3320. ConversionTbl:
  3321. DCTbl: ; DC=������
  3322. db 051h,074h,014h ;��
  3323. ;
  3324. db 052h,074h,004h ;��
  3325. ;
  3326. db 053h,047h,007h ;��
  3327. db 053h,067h,007h ;��
  3328. db 053h,077h,006h ;��
  3329. ;
  3330. db 046h,041h,00Bh ;��
  3331. db 046h,047h,010h ;��
  3332. db 046h,056h,00Fh ;��
  3333. db 046h,058h,00Eh ;��
  3334. db 046h,061h,00Bh ;��
  3335. db 046h,067h,010h ;��
  3336. db 046h,071h,00Ch ;��
  3337. db 046h,072h,00Ah ;��
  3338. db 046h,074h,00Dh ;��
  3339. db 046h,076h,00Fh ;��
  3340. db 046h,078h,00Eh ;��
  3341. DCTblLen = ( $ - offset DCTbl ) / 3
  3342. DVTbl: ; DV=������
  3343. db 048h,04Bh,01Ch ;��
  3344. db 048h,04Ch,024h ;��
  3345. db 048h,06Bh,01Ch ;��
  3346. db 048h,06Ch,024h ;��
  3347. db 048h,06Fh,01Eh ;��
  3348. ;
  3349. db 04Eh,04Ah,02Ah ;��
  3350. db 04Eh,04Ch,02Eh ;��
  3351. db 04Eh,06Ah,02Ah ;��
  3352. db 04Eh,06Ch,02Eh ;��
  3353. db 04Eh,070h,02Ch ;��
  3354. ;
  3355. db 04Dh,04Ch,038h ;��
  3356. db 04Dh,06Ch,038h ;��
  3357. DVTblLen = ( $ - offset DVTbl ) / 3
  3358. ConvTbl1:
  3359. ;�ʼ�+����( �ʼ�+0+0, 0+����+0 )
  3360. ;+shift
  3361. db 020h,034h,040h,034h,018h,01Ch,050h,01Ah,00Ah,00Eh,006h,03Ah,036h
  3362. db 028h,00Ch,018h,028h,00Ch,010h,030h,016h,04Ch,03Ch,048h,026h,044h
  3363. db 00,00,00,00,00,00 ;null
  3364. db 020h,034h,040h,034h,014h,01Ch,050h,01Ah,00Ah,00Eh,006h,03Ah,036h
  3365. db 028h,008h,014h,024h,008h,010h,02Ch,016h,04Ch,038h,048h,026h,044h
  3366. ConvTbl2:
  3367. ;����+��ħ( 0+����+0, 0+0+���� )
  3368. db 011h,034h,019h,017h,018h,009h,01Dh,01Ah,00Ah,00Eh,006h,03Ah,036h
  3369. db 028h,00Ch,018h,028h,003h,005h,016h,016h,01Ch,03Ch,01Bh,026h,01Ah
  3370. db 00,00,00,00,00,00 ;null
  3371. db 011h,034h,019h,017h,008h,009h,01Dh,01Ah,00Ah,00Eh,006h,03Ah,036h
  3372. db 028h,008h,014h,013h,002h,005h,015h,016h,01Ch,018h,01Bh,026h,01Ah
  3373. ;------------------------------------------------------------------------
  3374. ; << CompleteStart >>
  3375. ; CompleteStart()
  3376. ; FUNCTION =
  3377. ; INPUT : AX = english code
  3378. ; OUTPUT : AX = conversion code
  3379. ; PROTECT : AX
  3380. CompleteStart:
  3381. mov cx,ax
  3382. mov [TmpBufCnt],0
  3383. mov [InterimCharCnt],0
  3384. mov ax,[KsKbBuf]
  3385. call PutCompleteHg
  3386. mov ax,cx
  3387. ret
  3388. Act0:
  3389. call CompleteStart
  3390. mov [Auto],0
  3391. mov ax,[CurInCode]
  3392. jmp Eng2HanAuto
  3393. Act1:
  3394. Act2:
  3395. call act11
  3396. call PutInterimHg
  3397. ret
  3398. Act11:
  3399. mov bl,[TmpBufCnt]
  3400. cmp bl,0
  3401. je @f
  3402. call CompleteStart
  3403. @@:
  3404. call GetCharCodeXX00
  3405. or al,vFillCode
  3406. or al,lFillCode
  3407. call GetKCode
  3408. ret
  3409. Act1Sub1:
  3410. call GetKCode
  3411. call PutInterimHg
  3412. ret
  3413. Act3:
  3414. mov bx,offset DCTbl
  3415. mov cx,DCTblLen
  3416. call SearchCompound
  3417. jc GoAct0
  3418. xor ah,ah
  3419. or al,vFillCode
  3420. or ah,fFillCode
  3421. AutoProcess:
  3422. or ah,MsbCode
  3423. AutoProcess1:
  3424. call PutTmpBuf
  3425. call Ch2KsAuto
  3426. jc GoAct0
  3427. mov [KsKbBuf],ax
  3428. call PutInterimHg
  3429. ret
  3430. Act4:
  3431. call GetVowelCode
  3432. call GetKCode
  3433. mov [Auto],0
  3434. jmp CompleteStart
  3435. GoAct0:
  3436. jmp Act0
  3437. Act5:
  3438. call GetVowelCode
  3439. jmp Act1Sub1
  3440. Act6:
  3441. mov bx,offset DVTbl
  3442. mov cx,DVTblLen
  3443. call SearchCompound
  3444. jc GoAct0
  3445. xor ah,ah
  3446. shl ax,1
  3447. shl ax,1
  3448. shl ax,1
  3449. shl ax,1
  3450. or ah,fFillCode
  3451. or al,lFillCode
  3452. or ah,MsbCode
  3453. call PutTmpBuf
  3454. call Ch2KsAuto
  3455. jc GoAct0
  3456. mov [KsKbBuf],ax
  3457. mov [Auto],0
  3458. jmp CompleteStart
  3459. Act7:
  3460. Act8:
  3461. mov bl,[TmpBufCnt]
  3462. cmp bl,3
  3463. jb @f
  3464. mov ax,[PreTmpBuf]
  3465. call Ch2KsAuto
  3466. mov [KsKbBuf],ax
  3467. mov [InterimCharCnt],0
  3468. call PutCompleteHg
  3469. mov [TmpBufCnt],0
  3470. mov ax,[PreInCode]
  3471. call Act11
  3472. mov ax,[CurInCode]
  3473. @@:
  3474. call GetCharCode0XX0
  3475. mov cl,not vFillCode
  3476. call Or2Code
  3477. jmp AutoProcess1
  3478. Act9:
  3479. mov bx,offset DVTbl
  3480. mov cx,DVTblLen
  3481. call SearchCompound
  3482. jc GoAct0
  3483. xor ah,ah
  3484. shl ax,1
  3485. shl ax,1
  3486. shl ax,1
  3487. shl ax,1
  3488. mov bx,[TmpBuf]
  3489. and bx,not 03E0h
  3490. or ax,bx
  3491. jmp AutoProcess1
  3492. ActA:
  3493. ActB:
  3494. call GetCharCode00XX
  3495. mov cl,not lFillCode
  3496. call Or2Code
  3497. jmp AutoProcess1
  3498. ActC:
  3499. mov bx,offset DCTbl
  3500. mov cx,DCTblLen
  3501. call SearchCompound
  3502. jnc @f
  3503. jmp Act0
  3504. @@:
  3505. xor ah,ah
  3506. mov cl,not 01Fh
  3507. call Or2Code
  3508. jmp AutoProcess1
  3509. ;------------------------------------------------------------------------
  3510. GetVowelCode:
  3511. mov bl,[TmpBufCnt]
  3512. cmp bl,0
  3513. je @f
  3514. call CompleteStart
  3515. @@:
  3516. call GetCharCode0XX0
  3517. or ah,fFillCode
  3518. or al,lFillCode
  3519. ret
  3520. ;------------------------------------------------------------------------
  3521. GetKCode:
  3522. or ah,MsbCode
  3523. call PutTmpBuf
  3524. call Ch2KsAuto
  3525. mov [KsKbBuf],ax
  3526. ret
  3527. ;------------------------------------------------------------------------
  3528. GetCharCodeXX00:
  3529. mov bx, offset ConvTbl1
  3530. sub al,041h
  3531. xlat
  3532. mov ah,al
  3533. xor al,al
  3534. ret
  3535. ;------------------------------------------------------------------------
  3536. GetCharCode0XX0:
  3537. mov bx, offset ConvTbl1
  3538. sub al,041h
  3539. xlat
  3540. xor ah,ah
  3541. shl ax,1
  3542. shl ax,1
  3543. shl ax,1
  3544. shl ax,1
  3545. ret
  3546. ;------------------------------------------------------------------------
  3547. GetCharCode00XX:
  3548. mov bx, offset ConvTbl2
  3549. sub al,041h
  3550. xlat
  3551. xor ah,ah
  3552. ret
  3553. ;------------------------------------------------------------------------
  3554. PutTmpBuf:
  3555. mov bx,[TmpBuf]
  3556. mov [PreTmpBuf],bx
  3557. mov [TmpBuf],ax
  3558. mov bl,[TmpBufCnt]
  3559. inc bl
  3560. mov [TmpBufCnt],bl
  3561. ret
  3562. ;------------------------------------------------------------------------
  3563. ; << Or2Code >>
  3564. Or2Code:
  3565. mov bx,[TmpBuf]
  3566. and bl,cl
  3567. or ax,bx
  3568. ret
  3569. ;------------------------------------------------------------------------
  3570. ; << SearchCompound >>
  3571. ; SearchCompound()
  3572. ; FUNCTION = �ش��ϴ� ������/�������� ã�´�.
  3573. ; INPUT : BX=pointer of conversion table
  3574. ; OUTPUT : CY=success --> AX=conversioned code
  3575. ; NC=fail
  3576. ; PROTECT : AX
  3577. SearchCompound:
  3578. mov ax,[PreInCode]
  3579. and al,not Upper2Low
  3580. mov dx,[CurInCode]
  3581. SearchCompoundLoop:
  3582. cmp al,[bx]
  3583. jne @f
  3584. cmp dl,[bx+1]
  3585. jne @f
  3586. mov al,[bx+2]
  3587. clc
  3588. ret
  3589. @@:
  3590. add bx,3
  3591. loop SearchCompoundLoop
  3592. stc
  3593. ret
  3594. ;------------------------------------------------------------------------
  3595. ; << Beep >>
  3596. ; Beep()
  3597. ; FUNCTION = beeping for a time
  3598. ; INPUT : none
  3599. ; OUTPUT : none
  3600. ; PROTECT : ALL
  3601. Beep:
  3602. mov ax,0e07h
  3603. int 10h
  3604. ret
  3605. public MapTbl, KbEnd, ChHgWTbl ; for .MAP file
  3606. include CH2KS.TBL
  3607. include HANJA.TBL
  3608. KbEnd label byte
  3609. CODE ENDS
  3610. END
  3611.