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.

6657 lines
186 KiB

  1. TITLE Video interrupt 10h
  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 video ;
  10. ; ;
  11. ;=======================================================================;
  12. ;
  13. ; Video card : MGA
  14. ; CGA
  15. ; EGA-mono
  16. ; EGA-color
  17. ; VGA
  18. ; Font card
  19. ; Dual monitor
  20. ; �ѱ�/���� video card
  21. ;
  22. ; Code/spec. : KS C 5842 - 1991
  23. ; ���� �ѱ� ������, KSSM ����
  24. ; û��õ �ѱ�
  25. ;
  26. ; Video mode : 2/3 640*400 16 H/TE/TG
  27. ; (8*16font) 7 640*400 B/W H/TE/TG
  28. ; 40h 640*400 B/W G
  29. ; 60h 640*400 16 G
  30. ; 70h 640*400 B/W G
  31. ; 11h 640*480 B/W G
  32. ; 12h 640*480 16 G
  33. ;
  34. ; Video mode : 2/3 960*600 16 H
  35. ; (12*24font) 7 960*600 B/W H
  36. ; * H = �ѱ� text mode
  37. ; TE = Text emulation mode
  38. ; TG = Text emulation mode(not refresh)
  39. ; G = Graphics mode
  40. ;
  41. ; Font box : 8*16
  42. ;
  43. ; ���������� ����
  44. ; : 16 * 16 ���� font - 'HJ16.PAT'
  45. ;========================================================================;
  46. ; ;
  47. ; VIDEO INTERRUPT 10H ;
  48. ; ;
  49. ;========================================================================;
  50. ;
  51. ; Video service routine���� �������� �ϸ��俬�ϰ� ǥ���ϸ� ��������
  52. ; ª�� �����ϰ� ǥ���Ѵ�.
  53. ;
  54. ; Reserved register : BP = stack pointer
  55. ; DS = CS
  56. ; ES = DataSeg
  57. ;
  58. ;
  59. ; Int10(AX, BX, CX, DX, SI, DI, ES)
  60. ; {
  61. ; if ([CodeStat] != HangeulMode), goto [OldInt10], Iret;
  62. ; sti
  63. ; cld
  64. ; if (AH=0,0fch,0fdh) || HangeulVideoMode
  65. ; {
  66. ; +[VideoActive]; /* INT10�� nesting���� */
  67. ; Save BX,CX,DX,SI,DI,ES,DS,BP; /* AX = destory */
  68. ; BP = SP; /* save stack pointer */
  69. ; ES = DataSeg; /* default */
  70. ; DS = CodeSeg; /* default */
  71. ; switch(AH)
  72. ; case 0 : ModeSet(AL/-);
  73. ; break;
  74. ; case 1 : SetCurType(CX/-);
  75. ; break;
  76. ; case 2 : SetCurPos(BH,DX/-);
  77. ; break;
  78. ; case 3 : GetCurPos(BH/CX,DX);
  79. ; break;
  80. ; case 5 : SetPage(AL/-);
  81. ; break;
  82. ; case 6 : ScrollUp(AL,BH,CX,DX/-);
  83. ; break;
  84. ; case 7 : ScrollDown(AL,BH,CX,DX/-);
  85. ; break;
  86. ; case 8 : ReadCharAttr(BH/AX);
  87. ; break;
  88. ; case 9 : WriteCharAttr(AL,BX,CX/-);
  89. ; break;
  90. ; case 0ah : WriteChar(AL,BX,CX/-);
  91. ; break;
  92. ; case 0ch : WritePixel(AL,BH,CX,DX/-);
  93. ; break;
  94. ; case 0dh : ReadPixel(BH,CX,DX/AL);
  95. ; break;
  96. ; case 0eh : WriteTty(AL,BL/-);
  97. ; break;
  98. ; case 0fh : GetMode(-/AX,BH);
  99. ; break;
  100. ; case 0f6h : BlockMove(AL,BX,CX,DX/-);
  101. ; break;
  102. ; case 0f7h : BlockCopy(BX,CX,DX/-);
  103. ; break;
  104. ; case 0f8h : GetCharType(-/AL);
  105. ; break;
  106. ; case 0fch : FontCtrl(AL,*/*);
  107. ; break;
  108. ; case 0fdh : GetInfor(-/AL,BX,ES);
  109. ; break;
  110. ; case 0feh : WriteTtyInterim(AL,BL/-);
  111. ; break;
  112. ; default : Restore BX,CX,DX,SI,DI,ES,DS,BP;
  113. ; goto [OldInt10];
  114. ; UserEOP(-/-);
  115. ; Restore BX,CX,DX,SI,DI,ES,DS,BP;
  116. ; -[VideoActive];
  117. ; }
  118. ; else goto [OldInt10];
  119. ; iret;
  120. ; }
  121. CODE SEGMENT PUBLIC WORD 'CODE'
  122. ASSUME CS:CODE,DS:CODE,ES:DATA
  123. INCLUDE EQU.INC
  124. INCLUDE DATA.INC
  125. ; CursorStat
  126. CursorOn = 00000001b
  127. PUBLIC Int10
  128. Int10:
  129. if Debug
  130. pushf
  131. cli
  132. push ax
  133. push bx
  134. mov ax,cs:[DebugData]
  135. mov bx,ax
  136. and bx,0f00h
  137. and ax,0f0ffh
  138. add bx,100h
  139. and bx,0f00h
  140. or ax,bx
  141. out 10h,ax
  142. mov cs:[DebugData],ax
  143. pop bx
  144. pop ax
  145. popf
  146. endif ; if Debug
  147. cmp ah,01ch
  148. jnz @f
  149. jmp Return1ch
  150. @@:
  151. cmp ah,00h
  152. jz @f
  153. cmp ah,0fch
  154. jz @f
  155. cmp ah,0fdh
  156. jz @f
  157. test cs:[CodeStat],HangeulMode or HangeulVideoMode
  158. jz EngInt10Do
  159. jpo EngInt10Do
  160. @@:
  161. sti
  162. cld
  163. inc cs:[VideoActive]
  164. @push bx,cx,dx,si,di,es,ds,bp
  165. xor bp,bp
  166. mov es,bp
  167. mov bp,cs
  168. mov ds,bp
  169. mov bp,sp
  170. mov si,ax
  171. mov al,ah
  172. xor ah,ah
  173. add al,(10h-4)
  174. xchg si,ax
  175. cmp si,(23h-4)
  176. ja EngInt10
  177. shl si,1
  178. call [si+JumpTbl]
  179. @pop bp,ds,es,di,si,dx,cx,bx
  180. dec cs:[VideoActive]
  181. if Debug
  182. pushf
  183. cli
  184. push ax
  185. push bx
  186. mov ax,cs:[DebugData]
  187. mov bx,ax
  188. and bx,0f00h
  189. and ax,0f0ffh
  190. sub bx,100h
  191. and bx,0f00h
  192. or ax,bx
  193. out 10h,ax
  194. mov cs:[DebugData],ax
  195. pop bx
  196. pop ax
  197. popf
  198. endif ; if Debug
  199. iret
  200. VdDummyRet:
  201. add sp,2
  202. EngInt10:
  203. @pop bp,ds,es,di,si,dx,cx,bx
  204. dec cs:[VideoActive]
  205. EngInt10Do:
  206. ; KSE VGA mode 6 & AX = 1003h
  207. cmp ax,1003h
  208. jnz @f
  209. push ax
  210. push es
  211. xor ax,ax
  212. mov es,ax
  213. cmp [rCrtMode],6
  214. pop es
  215. pop ax
  216. jnz @f
  217. iret
  218. @@:
  219. if Debug
  220. pushf
  221. call cs:[OldVideo]
  222. pushf
  223. cli
  224. push ax
  225. push bx
  226. mov ax,cs:[DebugData]
  227. mov bx,ax
  228. and bx,0f00h
  229. and ax,0f0ffh
  230. sub bx,100h
  231. and bx,0f00h
  232. or ax,bx
  233. out 10h,ax
  234. mov cs:[DebugData],ax
  235. pop bx
  236. pop ax
  237. popf
  238. iret
  239. else
  240. jmp cs:[OldVideo]
  241. endif ; if Debug
  242. Return1ch:
  243. pushf
  244. call cs:[OldVideo]
  245. mov al,01ch
  246. iret
  247. JumpTbl label word ; to be set at init by invoking SetMode
  248. dw offset ControlCode ; ah=f4
  249. dw offset CodeChange ; ah=f5
  250. dw offset BlockMove ; ah=f6
  251. dw offset BlockCopy ; ah=f7
  252. dw offset GetCharType ; ah=f8
  253. dw offset VdDummyRet ; ah=f9
  254. dw offset VdDummyRet ; ah=fa
  255. dw offset VdDummyRet ; ah=fb
  256. dw offset FontCtrl ; ah=fc
  257. dw offset GetInfor ; ah=fd
  258. dw offset WriteTtyInterim ; ah=fe
  259. dw offset VdDummyRet ; ah=ff (x)
  260. dw offset ModeSet ; ah=0
  261. dw offset SetCurType ; ah=1
  262. dw offset SetCurPosAll ; ah=2
  263. dw offset GetCurPos ; ah=3
  264. dw offset VdDummyRet ; ah=4
  265. dw offset SetPage ; ah=5
  266. dw offset ScrollUp ; ah=6
  267. dw offset ScrollDown ; ah=7
  268. dw offset ReadCharAttr ; ah=8
  269. dw offset WriteCharAttr ; ah=9
  270. dw offset WriteChar ; ah=0a
  271. dw offset VdDummyRet ; ah=0b
  272. dw offset WritePixel ; ah=0c
  273. dw offset ReadPixel ; ah=0d
  274. dw offset WriteTty ; ah=0e
  275. dw offset GetMode ; ah=0f
  276. dw offset Attribute ; ah=10
  277. dw offset VdDummyRet ; ah=11
  278. dw offset VdDummyRet ; ah=12
  279. dw offset WriteString ; ah=13
  280. ;=======================================================================
  281. ; << ModeSet >>
  282. ; FUNCTION = set video mode
  283. ; INPUT : AH = 00h
  284. ; AL = mode value & MSB
  285. ; OUTPUT : none
  286. ; PROTECT : none
  287. ;
  288. ; video card�� ���� mode�� �з�(mode-ID)
  289. ; 0 - �ѱ� video card, mode 2/3/7, MGA/CGA/EGA/VGA
  290. ; 1 - text emulation mode 7, MGA
  291. ; 2 - text emulation mode 2/3, CGA
  292. ; 3 - text emulation mode 7, EGA/VGA
  293. ; 4 - text emulation mode 2/3, EGA/VGA
  294. ; 5 - mode 40/70
  295. ; 6 - mode 60/11/12, EGA/VGA
  296. ;
  297. ; video card�� �з�
  298. ; 0 - MGA
  299. ; 1 - CGA
  300. ; 2 - EGA mono
  301. ; 3 - EGA color
  302. ; 4 - MCGA
  303. ; 5 - VGA
  304. ;
  305. ; video card�� mode�� ���� modeset���� �з�
  306. ; 0 - �ѱ� video card, mode 2/3/7, MGA/CGA
  307. ; 1 - �ѱ� video card, mode 2/3/7, EGA/VGA
  308. ; 2 - grp mode or TE mode, MGA
  309. ; 3 - grp mode or TE mode, CGA
  310. ; 4 - grp mode or TE mode, EGA/VGA
  311. ;
  312. ; video buffer�� ���� ���� �з�
  313. ; 0 - 80*25, 8*16 font
  314. ; 1 - 80*30, 8*16 font
  315. ;
  316. ; ��Ȳ�� ���� video mode set�� ����(TEXT mode)
  317. ; 0 - �ѱ� card, single monitor - TEXT, 8 page
  318. ; 1 - �ѱ� card, dual monitor - TEXT, 8 page
  319. ; 2 - ���� card, single monitor - TE , 8 page (not CGA)
  320. ; 3 - ���� card, dual monitor - grp , 1 page
  321. ;
  322. ;========================================================================
  323. ; << ModeSet >>
  324. ; FUNCTION = initialize the video mode
  325. ; INPUT : AL
  326. ; OUTPUT : none
  327. ; PROTECT : SS, SP
  328. ;
  329. ; ModeSet(AL/-)
  330. ; {
  331. ; save AX;
  332. ; ClearCursor(-/-);
  333. ; [ModeStat] = 0;
  334. ; [KbStat] = [KbStat] && not HanKeyinMode;
  335. ; [CodeStat] = [CodeStat] && not HangeulVideoMode;
  336. ; [CurMode] = AL;
  337. ; AL = AL && 01111111b;
  338. ; PreModeset(AL/AL); /* monitor type�� ���� equip/crtc addr set */
  339. ; HanCardReset(-/-);
  340. ; if (SearchMode(AL/AL,SI,carry) == CY)
  341. ; {
  342. ; Resrore AX;
  343. ; Restore BX,CX,DX,SI,DI,ES,DS,BP;
  344. ; goto [OldInt10];
  345. ; }
  346. ; Restore BX; /* = AX */
  347. ; [KbStat] = HanKeyinMode;
  348. ; [CodeStat] = [CodeStat] || HangeulVideoMode;
  349. ; NorModeset(AL,SI/SI);
  350. ; SettingVariables(SI/SI);
  351. ; InitVideoBuffer(SI/-);
  352. ; [CurMode] = [CurMode] && 01111111b;
  353. ; HanCardSet(-/-); /* �ѱ� card enable */
  354. ; }
  355. ;
  356. ModeSet:
  357. if Hwin31sw
  358. jmp WinModeSet
  359. endif ; Hwin31sw
  360. ModeSet2:
  361. push ax
  362. call ClearCursor
  363. mov [ModeStat],0
  364. and [KbStat],not HanKeyinMode
  365. and [CodeStat],not HangeulVideoMode
  366. mov [CurMode],al
  367. and al,01111111b
  368. call PreModeset
  369. call HanCardReset
  370. call SearchMode
  371. jnc ModeSetH
  372. if KseVga
  373. test cs:[KseCard],00000001b
  374. jz @f
  375. pop ax
  376. push ax
  377. cmp al,038h
  378. jnz @f
  379. call HanCardReSetGr
  380. call kseveop
  381. @@:
  382. endif ; if KseVga
  383. pop ax
  384. pushf
  385. call cs:[OldVideo]
  386. ret
  387. ModeSetH:
  388. pop bx ; AX
  389. or [KbStat],HanKeyinMode
  390. or [CodeStat],HangeulVideoMode
  391. test cs:[Card1st],VgaCard
  392. jz @f
  393. call ChgParmE2H
  394. @@:
  395. call NorModeset
  396. test cs:[Card1st],VgaCard
  397. jz @f
  398. call ChgParmH2E
  399. @@:
  400. call SettingVariables
  401. call InitVideoBuffer
  402. and [CurMode],01111111b
  403. call HanCardSet
  404. ret
  405. if KseVga
  406. HanCardReSetGr:
  407. call KseVgaKey
  408. mov al,37h
  409. out dx,al
  410. inc dl
  411. in al,dx
  412. and al,11111110b
  413. or al,00000011b
  414. out dx,al
  415. ret
  416. endif ; KseVga
  417. ChgParmH2E:
  418. @push es,ds,di
  419. ASSUME DS:DATA
  420. xor di,di
  421. mov ds,di
  422. les di,cs:[OldVdParms]
  423. mov word ptr [rVdParm],di
  424. mov word ptr [rVdParm+2],es
  425. test cs:[Card1st],VgaCard
  426. jz @f
  427. les di,cs:[OldSavePtr]
  428. les di,es:[di]
  429. mov word ptr cs:[HanSavePtr],di
  430. mov word ptr cs:[HanSavePtr+2],es
  431. @@:
  432. ASSUME DS:CODE
  433. @pop di,ds,es
  434. ret
  435. ChgParmE2H:
  436. @push ds,di
  437. ASSUME DS:DATA
  438. xor di,di
  439. mov ds,di
  440. mov word ptr [rVdParm],offset VideoParms
  441. mov word ptr [rVdParm+2],cs
  442. test cs:[Card1st],VgaCard
  443. jz @f
  444. mov word ptr cs:[HanSavePtr],offset VideoParmsTbl
  445. mov word ptr cs:[HanSavePtr+2],cs
  446. @@:
  447. ASSUME DS:CODE
  448. @pop di,ds
  449. ret
  450. ;------------------------------------------------------------------------
  451. ; << PreModeSet >>
  452. ; FUNCTION = initialize video card state
  453. ; INPUT : AL
  454. ; OUTPUT : AL
  455. ; PROTECT : DS, ES, AL
  456. ;
  457. ; PreModeSet(AL/AL)
  458. ; {
  459. ; if (([Card1st] == DualMnt) && ([Card1st] != ES:[rEquip]))
  460. ; {
  461. ; XCHG [GetHan1st],[GetHan2nd];
  462. ; XCHG [GetUdc1st],[GetUdc2nd];
  463. ; XCHG [PutUdc1st],[PutUdc2nd];
  464. ; XCHG [HanOn1st],[HanOn2nd];
  465. ; XCHG [HanOff1st],[HanOff2nd];
  466. ; XCHG [Card1st],[Card2nd];
  467. ; }
  468. ; else
  469. ; {
  470. ; if ([Card1st] == EgaCardM)
  471. ; {
  472. ; ES:[rEquip] = mono equip;
  473. ; ES:[rAddr6845] = 3b4h;
  474. ; OUT 3c2h,62h;
  475. ; }
  476. ; if ([Card1st] == EgaCardC)
  477. ; {
  478. ; ES:[rEquip] = color equip;
  479. ; ES:[rAddr6845] = 3d4h;
  480. ; OUT 3c2h,63h;
  481. ; }
  482. ; }
  483. ; }
  484. ;
  485. PreModeSet:
  486. test [Card1st],DualMnt
  487. jz PreModeSetSingle
  488. xor ah,ah
  489. test [Card1st],ColorMnt
  490. jz @f
  491. xor ah,1
  492. @@:
  493. test [rEquip],00110000b
  494. jpe @f
  495. xor ah,1
  496. @@:
  497. or ah,ah
  498. jz @f
  499. call XchgCardParms
  500. @@:
  501. ret
  502. XchgCardParms:
  503. mov bx,[GetHan1st]
  504. xchg bx,[GetHan2nd]
  505. mov [GetHan1st],bx
  506. mov bx,[GetUdc1st]
  507. xchg bx,[GetUdc2nd]
  508. mov [GetUdc1st],bx
  509. mov bx,[PutUdc1st]
  510. xchg bx,[PutUdc2nd]
  511. mov [PutUdc1st],bx
  512. mov bx,[HanOn1st]
  513. xchg bx,[HanOn2nd]
  514. mov [HanOn1st],bx
  515. mov bx,[HanOff1st]
  516. xchg bx,[HanOff2nd]
  517. mov [HanOff1st],bx
  518. mov bl,[Card1st]
  519. xchg bl,[Card2nd]
  520. mov [Card1st],bl
  521. ret
  522. PreModeSetSingle:
  523. push ax
  524. mov ah,[Card1st]
  525. and ah,CardType
  526. cmp ah,EgaCardM
  527. jnz @f
  528. or [rEquip],00110000b
  529. mov [rAddr6845],3b4h
  530. mov dx,GrpIndex
  531. mov al,62h
  532. out dx,al
  533. @@:
  534. cmp ah,EgaCardC
  535. jnz @f
  536. and [rEquip],11101111b
  537. or [rEquip],00100000b
  538. mov [rAddr6845],3d4h
  539. mov dx,3c2h
  540. mov al,63h
  541. out dx,al
  542. @@:
  543. pop ax
  544. ret
  545. ;------------------------------------------------------------------------
  546. ; << SearchMode >>
  547. ; FUNCTION = search video mode & get parms pointer
  548. ; INPUT : AL = mode value(W/O MSB)
  549. ; OUTPUT : AL, SI, carry(set = english mode)
  550. ; PROTECT : DS, ES, AL
  551. ;
  552. ; SearchMode(AL/AL,SI,carry)
  553. ; {
  554. ; switch([Card1st])
  555. ; {
  556. ; case MgaCard:
  557. ; if (AL != 7/40h/70h), AL = 7;
  558. ; break;
  559. ; case CgaCard:
  560. ; if (AL != 0-6/40h), AL = 3;
  561. ; break;
  562. ; case EgaCardM:
  563. ; if (AL != 7/0fh/40h/70h), AL = 7;
  564. ; break;
  565. ; case EgaCardC:
  566. ; if (AL != 0-6/0dh/0eh/10h/40h/70h/60h), AL = 3;
  567. ; break;
  568. ; case VgaCard:
  569. ; case McgaCard:
  570. ; if (AL != 0-6/0dh-13h/40h/70h/60h), AL = 3;
  571. ; }
  572. ; if (AL == 2), AL = 3;
  573. ; if ([Card1st] == DualMnt)
  574. ; {
  575. ; if (([rEquip] == mono) && (AL == 40h))
  576. ; AL = 7;
  577. ; if (([rEquip] == color) && (AL == 70h))
  578. ; AL = 3;
  579. ; }
  580. ; if (([Card1st] != HanCard) && (AL == 3/7))
  581. ; {
  582. ; AL = AL || 10h;
  583. ; if ([Card1st] == DualMnt), AL = AL || 80h;
  584. ; }
  585. ; switch([card1st])
  586. ; {
  587. ; case MgaCard:
  588. ; SI = MgaModeTbl;
  589. ; break;
  590. ; case CgaCard:
  591. ; SI = CgaModeTbl;
  592. ; break;
  593. ; case EgaCardM:
  594. ; case EgaCardC:
  595. ; SI = EgaModeTbl;
  596. ; break;
  597. ; case VgaCard:
  598. ; case McgaCard:
  599. ; SI = VgaModeTbl;
  600. ; }
  601. ; /* search AL */
  602. ; /* if match, NC */
  603. ; /* if not, CY */
  604. ; }
  605. ;
  606. SearchMode:
  607. test [CodeStat],HangeulMode
  608. jz SearchModeErr
  609. test [Card1st],DualMnt
  610. jz SearchModeDual
  611. cmp al,7
  612. jz @f
  613. cmp al,0fh
  614. jz @f
  615. cmp al,70h
  616. jz @f
  617. test [rEquip],00110000b
  618. jpo SearchModeDual ; jump if color mode & color equip
  619. mov al,7
  620. mov [CurMode],al
  621. jmp short SearchModeDual
  622. @@:
  623. test [rEquip],00110000b
  624. jpe SearchModeDual ; jump if mono mode & mono equip
  625. mov al,3
  626. mov [CurMode],al
  627. SearchModeDual:
  628. mov bl,[Card1st]
  629. and bx,CardType
  630. mov si,[bx+ModeTable]
  631. @@:
  632. cmp [si],al
  633. jz SearchModeAdj
  634. cmp byte ptr [si],-1
  635. jz SearchModeDefault
  636. cmp byte ptr [si],-2
  637. jz SearchModeErr
  638. inc si
  639. jmp short @b
  640. SearchModeErr:
  641. stc
  642. ret
  643. SearchModeDefault:
  644. mov al,7
  645. test [Card1st],ColorMnt
  646. jz @f
  647. mov al,3
  648. @@:
  649. mov [CurMode],al
  650. SearchModeAdj:
  651. cmp al,2
  652. jnz @f
  653. mov al,3
  654. @@:
  655. test [Card1st],DualMnt
  656. jz SearchModeAdj2
  657. cmp al,40h
  658. jnz @f
  659. test [rEquip],00110000b
  660. jpo @f
  661. mov al,70h
  662. mov [CurMode],al
  663. @@:
  664. cmp al,70h
  665. jnz SearchModeAdj2
  666. test [rEquip],00110000b
  667. jpe SearchModeAdj2
  668. mov al,40h
  669. mov [CurMode],al
  670. SearchModeAdj2:
  671. mov ah,al
  672. cmp ah,3
  673. jz @f
  674. cmp ah,7
  675. jnz SearchModeDo
  676. @@:
  677. test [CodeStat],Chab or WSung7
  678. jnz @f
  679. test [Card1st],HanCard
  680. jnz SearchModeDo
  681. @@:
  682. or ah,80h
  683. test [Card1st],DualMnt
  684. jz SearchModeDo
  685. or ah,10h
  686. SearchModeDo:
  687. mov bl,[Card1st]
  688. and bx,CardType
  689. shl bx,1
  690. mov si,[bx+ModeParmsTbl]
  691. add bx,2
  692. mov cx,[bx+ModeParmsTbl]
  693. mov bx,ModeTblLng
  694. @@:
  695. cmp [si],ah
  696. jz @f
  697. add si,bx
  698. loop @b
  699. jmp SearchModeErr
  700. @@:
  701. clc
  702. ret
  703. ModeTable label word
  704. dw offset MgaAllModeTbl
  705. dw offset CgaAllModeTbl
  706. dw offset EgaMAllModeTbl
  707. dw offset EgaCAllModeTbl
  708. dw offset McgaAllModeTbl
  709. dw offset VgaAllModeTbl
  710. MgaAllModeTbl db 7, 40h, 70h, -1
  711. CgaAllModeTbl db 0, 1, 2, 3, 4, 5, 6, 40h, -1
  712. ModeParmsTbl label word
  713. dw offset MgaModeTbl
  714. dw 5
  715. dw offset CgaModeTbl
  716. dw 4
  717. dw offset EgaModeTbl
  718. dw 9
  719. dw offset EgaModeTbl
  720. dw 9
  721. dw offset VgaModeTbl
  722. dw 11
  723. dw offset VgaModeTbl
  724. dw 11
  725. MgaModeTbl label byte
  726. db 07h,0*2,07h,0b0h,0b0h,10h,000h,00000000b,25 ; han
  727. dw 0, 0,0b0ch
  728. ModeTblLng = $-MgaModeTbl
  729. db 87h,1*2,07h,0b0h,0b8h,10h,080h,10000100b,25 ; single
  730. dw 38h,38ah,0b0ch
  731. db 97h,1*2,07h,000h,0b0h,00h,080h,00000100b,25 ; dual
  732. dw 38h,10ah,0b0ch
  733. db 40h,5*2,07h,000h,0b8h,00h,080h,01100100b,25 ;
  734. dw 38h,38ah,2e0fh
  735. db 70h,5*2,07h,000h,0b0h,00h,080h,00100100b,25 ;
  736. dw 38h,10ah,2e0fh
  737. CgaModeTbl label byte
  738. db 03h,0*2,03h,0b8h,0b8h,10h,000h,01001000b,25 ; han
  739. dw 0,0,0607h
  740. db 83h,2*2,06h,000h,0b8h,00h,080h,01000100b,25 ; single
  741. dw 38h,0,0607h
  742. db 93h,2*2,06h,000h,0b8h,00h,080h,01000100b,25 ; dual
  743. dw 38h,0,0607h
  744. db 40h,5*2,06h,000h,0b8h,00h,080h,01100100b,25 ;
  745. dw 38h,0,2e0fh
  746. ;------------------------------------------------------------------------
  747. ; << NorModeset >>
  748. ; FUNCTION = video mode setting
  749. ; INPUT : AL, SI
  750. ; OUTPUT : SI
  751. ; PROTECT : DS, ES, SI
  752. ;
  753. ; NorModeset(AL,SI/SI)
  754. ; {
  755. ; if (([Card1st] == CgaCard) || ([Card1st] == MgaCard))
  756. ; {
  757. ; if ([SI+sRealMode] == 3/7)
  758. ; {
  759. ; ModeSetMonoText(SI/-);
  760. ; }
  761. ; else
  762. ; {
  763. ; ModeSetMonoGrp(SI/-);
  764. ; }
  765. ; }
  766. ; else
  767. ; {
  768. ; if ([SI+sRealMode] == 3/7)
  769. ; {
  770. ; ModeSetVgaText(SI/-);
  771. ; }
  772. ; else
  773. ; {
  774. ; ModeSetVgaGrp(SI/-);
  775. ; }
  776. ; }
  777. ; }
  778. ;
  779. NorModeset:
  780. mov al,[si+sRealMode]
  781. mov ah,[CurMode]
  782. and ah,10000000B
  783. or al,ah
  784. xor ah,ah
  785. mov bh,[si+sMode]
  786. mov bl,[Card1st]
  787. and bl,CardType
  788. cmp bl,CgaCard
  789. ja NorModesetVga
  790. cmp bh,3
  791. jz @f
  792. cmp bh,7
  793. jz @f
  794. jmp ModeSetMonoGrp
  795. @@:
  796. jmp ModeSetMonoText
  797. NorModesetVga:
  798. cmp bh,3
  799. jz @f
  800. cmp bh,7
  801. jz @f
  802. jmp ModeSetVgaGrp
  803. @@:
  804. jmp ModeSetVgaText
  805. ModeSetMonoText:
  806. pushf
  807. call [OldVideo]
  808. mov [Port3bf],0
  809. ret
  810. ModeSetMonoGrp:
  811. mov di,word ptr [rVdParm]
  812. add di,[si+sAdjParms]
  813. xchg di,word ptr [rVdParm]
  814. pushf
  815. call [OldVideo]
  816. xchg di,word ptr [rVdParm]
  817. mov bx,[si].sParms
  818. or bx,bx
  819. jz @f
  820. mov dx,3bfh
  821. mov al,00000011b
  822. out dx,al
  823. mov dl,0b8h
  824. mov al,bl
  825. out dx,al
  826. mov [rCrtModeSet],al
  827. mov dl,0bfh
  828. mov al,bh
  829. mov [Port3bf],al
  830. out dx,al
  831. @@:
  832. ret
  833. ;------------------------------------------------------------------------
  834. ; << SettingVariables >>
  835. ; FUNCTION = initialize variables
  836. ; INPUT : SI
  837. ; OUTPUT : SI
  838. ; PROTECT : DS, ES, SI
  839. ;
  840. ; SettingVariables(SI/SI)
  841. ; {
  842. ; set flages
  843. ; [HjStat] = [HjStat] || [OrgHjStat];
  844. ; if ([CodeStat] == Chab), [HjStat] = [HjStat] && not (UdcLoaded or UdcArea);
  845. ; if ([CodeStat] == WSung7), [HjStat] = [HjStat] && not (UdcLoaded or UdcArea or HjLoaded);
  846. ; [ModeStat] = [SI+sStatus];
  847. ; [DisplayStat] = [DisplayStat] && not RunEsc;
  848. ; [ModeId] = [SI+sModeId];
  849. ; [KbStat] = [KbStat] && not (HEStat or JJStat);
  850. ; [HanStat] = 0;
  851. ; [HjMenuStat] = 0;
  852. ;
  853. ; set internal constant
  854. ; [MaxPage] = 1;
  855. ; if ([ModeStat] == MultiPage), [MaxPage] = 8;
  856. ; [MaxRows] = [SI+sRows];
  857. ; [HjMenuLine] = [SI+sRows] - 1;
  858. ; [CurPos] = 0;
  859. ; [CurPage] = 0;
  860. ; [TextPos1Addr] = 0;
  861. ; [TextPos2Addr] = 0;
  862. ; [GrpPosAddr] = 0;
  863. ;
  864. ; set ROM BIOS data area
  865. ; AL = [CurMode];
  866. ; if(AL != 1000000B)
  867. ; {
  868. ; [rInfo] == [rInfo] || 10000000B;
  869. ; }
  870. ; AL = AL && 01111111b;
  871. ; ES:[rCrtMode] = AL;
  872. ; ES:[rPoints] = 16;
  873. ; ES:[rCrtCols] = 80;
  874. ; ES:[rRows] = [MaxRows] - 1;
  875. ; ES:[rCrtLen] = [SI+CodeSize];
  876. ; if (ES:[rCrtLen] == 0), ES:[rCrtLen] = [SI+GrpSize];
  877. ; ES:[rCurType] = [SI+sCurType];
  878. ;
  879. ; set code buffer address
  880. ; BH = [SI+sCodeVram];
  881. ; BL = 0;
  882. ; AX = 0
  883. ; if (BX == 0)
  884. ; {
  885. ; AX = [CodeBuf2Addr];
  886. ; BX = [CodeBuf2Addr+2];
  887. ; }
  888. ; [CodeBuf1Addr] = AX;
  889. ; [CodeBuf1Addr+2] = BX;
  890. ;
  891. ; Set EQUIP flag
  892. ; if ([Card1st] != DualMnt)
  893. ; {
  894. ; if ([ModeStat] == ColorMode)
  895. ; /* set color equip */
  896. ; else
  897. ; /* set mono equip */
  898. ; }
  899. ; }
  900. ;
  901. SettingVariables:
  902. ; set flages
  903. mov ah,[OrgHjStat]
  904. or [HjStat],ah
  905. test [CodeStat],WSung7
  906. jz @f
  907. and [HjStat],not (UdcLoaded or UdcArea or HjLoaded )
  908. @@:
  909. mov ah,[si+sStatus]
  910. test [KseCard],Page1Fix
  911. jz @f
  912. and ah,not MultiPage
  913. @@:
  914. mov [ModeStat],ah
  915. and [DisplayStat],not RunEsc
  916. mov ah,[si+sModeId]
  917. mov [ModeId],ah
  918. if WINNT
  919. else
  920. and [KbStat],not (HEStat or JJStat)
  921. endif
  922. mov [HanStat],0
  923. mov [HjMenuStat],0
  924. ; set internal constant
  925. mov [MaxPage],1
  926. test [ModeStat],MultiPage
  927. jz @f
  928. mov [MaxPage],8
  929. @@:
  930. mov ah,[si+sRows]
  931. mov [MaxRows],ah
  932. dec ah
  933. mov [HjMenuLine],ah
  934. mov [CurPos],0
  935. mov [CurPage],0
  936. mov [TextPos1Addr],0
  937. mov [TextPos2Addr],0
  938. mov [GrpPosAddr],0
  939. ; set ROM BIOS data area
  940. mov ah,[CurMode]
  941. and [rInfo],01111111B
  942. mov al,ah
  943. and al,10000000B
  944. or [rInfo],al
  945. and ah,01111111b
  946. mov [rCrtMode],ah
  947. mov [rPoints],16
  948. mov [rCrtCols],80
  949. mov bl,[MaxRows]
  950. dec bl
  951. mov [rRows],bl
  952. mov bh,[si+sCodeSize]
  953. or bh,bh
  954. jnz @f
  955. mov bh,[si+sGrpSize]
  956. @@:
  957. xor bl,bl
  958. mov [rCrtLen],bx
  959. mov bx,[si+sCurType]
  960. mov [rCurType],bx
  961. ; set code buffer address
  962. mov bh,[si+sCodeVram]
  963. xor bl,bl
  964. xor ax,ax
  965. or bx,bx
  966. jnz @f
  967. mov ax,word ptr [CodeBuf2Addr]
  968. mov bx,word ptr [CodeBuf2Addr+2]
  969. @@:
  970. mov word ptr [CodeBuf1Addr],ax
  971. mov word ptr [CodeBuf1Addr+2],bx
  972. ; set grp buffer address
  973. mov bh,[si+sGrpVram]
  974. xor bl,bl
  975. or bx,bx
  976. jz @f
  977. mov word ptr [GrpBufAddr],0
  978. mov word ptr [GrpBufAddr+2],bx
  979. @@:
  980. ; Set EQUIP flag
  981. test [Card1st],DualMnt
  982. jnz @f
  983. or [rEquip],00110000b
  984. test [ModeStat],ColorMode
  985. jz @f
  986. and [rEquip],11101111b
  987. @@:
  988. ret
  989. ;------------------------------------------------------------------------
  990. ; << InitVideoBuffer >>
  991. ; FUNCTION = initialize video buffer(1st code, 2nd code and grp buffer)
  992. ; INPUT : SI
  993. ; OUTPUT : none
  994. ; PROTECT : DS, ES
  995. ;
  996. ; InitVideoBuffer(SI/-)
  997. ; {
  998. ; if ([CurMode] == 10000000b)
  999. ; {
  1000. ; AX = 720h;
  1001. ; LES DI,[CodeBuf1Addr];
  1002. ; CX = 8000h;
  1003. ; if ([SI+sCodeSize] == 0), CX = [CodeBufSize];
  1004. ; CX = CX/2;
  1005. ; REP STOSW;
  1006. ; LES DI,[CodeBuf2Addr];
  1007. ; CX = [CodeBufSize]/2;
  1008. ; REP STOSW;
  1009. ; if ([SI+sGrpSize] != 0)
  1010. ; {
  1011. ; LES DI,[GrpBufAddr];
  1012. ; CH = [SI+sGrpSize];
  1013. ; CL = 0;
  1014. ; CX = CX/2;
  1015. ; AX = 0;
  1016. ; REP STOSW;
  1017. ; }
  1018. ; }
  1019. ; }
  1020. ;
  1021. InitVideoBuffer:
  1022. test [CurMode],10000000b
  1023. jnz InitVideoBufferEnd
  1024. push es
  1025. mov ax,720h
  1026. les di,[CodeBuf1Addr]
  1027. mov cx,8000h
  1028. cmp [si+sCodeSize],0
  1029. jnz @f
  1030. mov cx,[CodeBufSize]
  1031. @@:
  1032. shr cx,1
  1033. if HotKey
  1034. test [KbStat],ReqEnvrChg
  1035. jz @f
  1036. test [KbMisc],RunningHot
  1037. jz @f
  1038. or di,di
  1039. jnz InitGrpBuffer
  1040. rep stosw
  1041. jmp short InitGrpBuffer
  1042. @@:
  1043. endif ; if HotKey
  1044. rep stosw
  1045. les di,[CodeBuf2Addr]
  1046. mov cx,[CodeBufSize]
  1047. shr cx,1
  1048. rep stosw
  1049. InitGrpBuffer:
  1050. mov ch,[si+sGrpSize]
  1051. or ch,ch
  1052. jz @f
  1053. les di,[GrpBufAddr]
  1054. xor cl,cl
  1055. shr cx,1
  1056. xor ax,ax
  1057. rep stosw
  1058. @@:
  1059. pop es
  1060. InitVideoBufferEnd:
  1061. ret
  1062. ;========================================================================
  1063. ; << SetCurType >>
  1064. ; FUNCTION = set cursor type
  1065. ; INPUT : AH = 01h
  1066. ; CH = cursor start, CL = cursor end
  1067. ; (CH) 7 6 5 4 3 2 1 0
  1068. ; | | | | | | | |
  1069. ; | | | +-+-+-+-+--- cursor start
  1070. ; | | +------------- 0 : cursor on, 1 : off
  1071. ; +-+--------------- not used
  1072. ; (CL) 7 6 5 4 3 2 1 0
  1073. ; | | | | |
  1074. ; +-+-+-+-+--- cursor end
  1075. ; OUTPUT : none
  1076. ; PROTECT : none
  1077. ; SetCurType(CX/-)
  1078. ; {
  1079. ; ClearCursor(-/-);
  1080. ; switch([ModeId])
  1081. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  1082. ; call [OldInt10];
  1083. ; break;
  1084. ; case 2 : ; TE mode 7, MGA
  1085. ; case 4 : ; TE mode 2/3, CGA
  1086. ; case 6 : ; TE mode 7, EGA/VGA
  1087. ; case 8 : ; TE mode 2/3, EGA/VGA
  1088. ; case 10 : ; mode 40/70
  1089. ; case 12 : ; mode 60/11/12, EGA/VGA
  1090. ; ES:[rCurType] = CX;
  1091. ; }
  1092. SetCurType:
  1093. call ClearCursor
  1094. pushf
  1095. call [OldVideo]
  1096. mov [rCurType],cx
  1097. cmp [Modeid],2*0
  1098. jnz SetCurTypeEnd
  1099. test [rInfo],00000001b
  1100. jz SetCurTypeEnd
  1101. test [Card1st],00001100b
  1102. jz SetCurTypeEnd ; jump if not EGA or VGA card
  1103. cmp ch,cl
  1104. ja @f
  1105. mov ax,cx
  1106. and cx,0f0fh
  1107. cmp cl,5
  1108. jb SetCurTypeMonoCL
  1109. inc cl
  1110. cmp cl,10
  1111. jb SetCurTypeMonoCL
  1112. inc cl
  1113. SetCurTypeMonoCL:
  1114. cmp ch,5
  1115. jb SetCurTypeMonoCH
  1116. inc ch
  1117. cmp ch,10
  1118. jb SetCurTypeMonoCH
  1119. inc ch
  1120. SetCurTypeMonoCH:
  1121. mov dh,ah
  1122. and dh,20h
  1123. or ch,dh
  1124. test [ModeStat],ColorMode
  1125. jz @f
  1126. mov cx,ax
  1127. and cx,0707h
  1128. shl cx,1
  1129. mov dh,ah
  1130. and dh,20h
  1131. or ch,dh
  1132. @@:
  1133. mov dx,[rAddr6845]
  1134. mov al,0ah
  1135. mov ah,ch
  1136. out dx,ax
  1137. inc al
  1138. mov ah,cl
  1139. out dx,ax
  1140. SetCurTypeEnd:
  1141. ret
  1142. ;========================================================================
  1143. ; << SetCurPos >>
  1144. ; FUNCTION = set cursor position
  1145. ; INPUT : AH = 02h
  1146. ; BH = page #, DX = cursor position
  1147. ; OUTPUT : none
  1148. ; PROTECT : AX, BX, CX, DX, ES, DS
  1149. ; SetCurPos(BH,DX/-)
  1150. ; {
  1151. ; if ([MaxPage] == 1), BH = 0;
  1152. ; if (BH >= [MaxPage]), BH = [CurPage];
  1153. ; if (DL >= 80), return;
  1154. ; if (DH >= [MaxRows]), return;
  1155. ; save AX, BX;
  1156. ; ClearCursor(-/-);
  1157. ; if ([ModeId = 0*2)
  1158. ; AH = 2;
  1159. ; call [OldInt10];
  1160. ; ES:[BH*2+rCurPos] = DX;
  1161. ; restore AX,BX;
  1162. ; }
  1163. SetCurPosAll:
  1164. cmp [ModeId],0*2
  1165. jne SetCurPos
  1166. jmp VdDummyRet
  1167. SetCurPos:
  1168. cmp [MaxPage],1
  1169. ja @f
  1170. xor bh,bh
  1171. @@:
  1172. cmp bh,[MaxPage]
  1173. jb @f
  1174. mov bh,[CurPage]
  1175. @@:
  1176. @push ax,bx
  1177. call ClearCursor
  1178. cmp [ModeId],0*2
  1179. jne @f
  1180. mov ah,2
  1181. pushf
  1182. call [OldVideo]
  1183. @@:
  1184. xchg bh,bl
  1185. xor bh,bh
  1186. shl bx,1
  1187. mov [bx+rCurPos],dx
  1188. @pop bx,ax
  1189. ret
  1190. ;========================================================================
  1191. ; << GetCurPos >>
  1192. ; FUNCTION = get cursor position
  1193. ; INPUT : AH = 03h
  1194. ; BH = page #
  1195. ; OUTPUT : CX = cursor type, DX = cursor position
  1196. ; PROTECT : none
  1197. ; GetCurPos(BH/CX,DX)
  1198. ; {
  1199. ; if ([MaxPage] == 1), BH = 0;
  1200. ; if (BH >= [MaxPage]), BH = [CurPage];
  1201. ; SS:[BP+rCX] = ES:[rCurType];
  1202. ; SS:[BP+rDX] = ES:[BH*2 + rCurPos];
  1203. ; }
  1204. GetCurPos:
  1205. cmp [MaxPage],1
  1206. ja @f
  1207. xor bh,bh
  1208. @@:
  1209. cmp bh,[MaxPage]
  1210. jb @f
  1211. mov bh,[CurPage]
  1212. @@:
  1213. mov ax,[rCurType]
  1214. mov [bp+rCX],ax
  1215. xchg bh,bl
  1216. xor bh,bh
  1217. shl bx,1
  1218. mov ax,[bx+rCurPos]
  1219. mov [bp+rDX],ax
  1220. ret
  1221. ;========================================================================
  1222. ; << SetPage >>
  1223. ; FUNCTION = set display page
  1224. ; INPUT : AH = 05h
  1225. ; AL = page #
  1226. ; OUTPUT : none
  1227. ; PROTECT : none
  1228. ; SetPage(AL/-)
  1229. ; {
  1230. ; if (AL >= [MaxPage]), return;
  1231. ; if (AL = [CurPage] || [MaxPage] = 1), return;
  1232. ; [HanStat] = [HanStat] && not Han1st;
  1233. ; ClearCursor(-/-);
  1234. ; if ([ModeId] = 0*2)
  1235. ; {
  1236. ; call [OldInt10];
  1237. ; AL = ES:[rCurPage];
  1238. ; }
  1239. ; ES:[rCurPage] = AL;
  1240. ; [CurPage] = AL;
  1241. ; ES:[rCrtStart] = AL * ES:[rCrtLen];
  1242. ; }
  1243. SetPage:
  1244. cmp al,[MaxPage]
  1245. jae SetPageExit
  1246. cmp al,[CurPage]
  1247. jz SetPageExit
  1248. cmp [MaxPage],1
  1249. jz SetPageExit
  1250. and [HanStat],not Han1st
  1251. call ClearCursor
  1252. cmp [ModeId],0*2
  1253. jnz @f
  1254. pushf
  1255. call [OldVideo]
  1256. mov al,[rCurPage]
  1257. @@:
  1258. mov [rCurPage],al
  1259. mov [CurPage],al
  1260. xor ah,ah
  1261. mul [rCrtLen]
  1262. mov [rCrtStart],ax
  1263. SetPageExit:
  1264. ret
  1265. ;========================================================================
  1266. ; << ReadCharAttr >>
  1267. ; FUNCTION = read character & attribute at current cursor position
  1268. ; INPUT : AH = 08h
  1269. ; BH = page #
  1270. ; OUTPUT : AL = char, AH = attribute(grp mode = don't care)
  1271. ; PROTECT : none
  1272. ; ReadCharAttr(BH/AL,AH)
  1273. ; {
  1274. ; if ([MaxPage] == 1), BH = 0;
  1275. ; if (BH >= [MaxPage]), BH = [CurPage];
  1276. ; DX = [BH*2+rCurPos];
  1277. ; SI = DH*80*2+DL*2;
  1278. ; AX = [CodeBuf1Addr:[SI + [rCrtLen] * BH]];
  1279. ; }
  1280. ReadCharAttr:
  1281. cmp [MaxPage],1
  1282. ja @f
  1283. xor bh,bh
  1284. @@:
  1285. cmp bh,[MaxPage]
  1286. jb @f
  1287. mov bh,[CurPage]
  1288. @@:
  1289. mov bl,bh
  1290. xor bh,bh
  1291. shl bx,1
  1292. mov dx,[bx+rCurPos]
  1293. mov ax,80
  1294. mul dh
  1295. xor dh,dh
  1296. add ax,dx
  1297. shl ax,1
  1298. mov si,ax
  1299. mov ax,[rCrtLen]
  1300. shr bx,1
  1301. mul bx
  1302. add ax,si
  1303. lds si,[CodeBuf1Addr]
  1304. add si,ax
  1305. lodsw ; AX = Cahracter : Attribute
  1306. @@:
  1307. ret
  1308. ;========================================================================
  1309. ; << GetMode >>
  1310. ; FUNCTION = get mode, page and columns
  1311. ; INPUT : AH = 0Fh
  1312. ; OUTPUT : AL = video mode, AH = columns, BH = current page
  1313. ; PROTECT : none
  1314. ; GetMode(-/AL,AH,BH)
  1315. ; {
  1316. ; call [OldInt10];
  1317. ; AL = [CurMode] + buffer clear information(0:487 bit7);
  1318. ; SS:[BP+rBX] = BX
  1319. ; }
  1320. GetMode:
  1321. pushf
  1322. call [OldVideo]
  1323. mov al,[rCrtMode]
  1324. mov bl,[rInfo]
  1325. and bl,10000000b ; buffer clear information
  1326. or al,bl
  1327. mov cx,ss:[bp+rBX]
  1328. mov bl,cl
  1329. mov ss:[bp+rBX],bx
  1330. ret
  1331. ;========================================================================
  1332. ; << Attribute >>
  1333. ; Function = Skip if english ext. video card and video mode 2, 3, 7, 40, 70
  1334. ; in EGA/VGA/MCGA card.
  1335. ; INPUT : AH = 010h
  1336. ; AL = 03h
  1337. ; BL = blink/intensity toggle ( 0 : enable intensity, 1 : enable blinking)
  1338. ; OUTPUT : none
  1339. ; PROTECT : none
  1340. Attribute:
  1341. test [ModeStat],EmuCursor
  1342. jz GoToVdRom
  1343. test [ModeStat],GrpMode
  1344. jnz GoToVdRom
  1345. cmp ax,1002h
  1346. jz @f
  1347. cmp ax,1003h ; intensity function ?
  1348. jnz GoToVdRom
  1349. @@:
  1350. ret
  1351. JmpVdDummyjj:
  1352. jmp JmpVdDummy
  1353. GoToVdRom:
  1354. if KseVga
  1355. test cs:[KseCard],00000001b
  1356. jz JmpVdDummyjj
  1357. cmp [ModeId],0
  1358. jnz JmpVdDummyjj
  1359. cmp al,1
  1360. jz @f
  1361. cmp al,2
  1362. jnz JmpVdDummyjj
  1363. @@:
  1364. push ax
  1365. push bx
  1366. push dx
  1367. mov ah,4 ; border chip on
  1368. mov dx,03CCh
  1369. in al,dx
  1370. test al,80h ; VS Negative ?
  1371. jnz @f ; No Positive
  1372. or ah,1 ; border_0
  1373. @@: ; border_1
  1374. test al,40h ; HS Negative ?
  1375. jnz @f ; No Positive
  1376. or ah,2
  1377. @@: ; border_2
  1378. mov dx,257h
  1379. in al,dx
  1380. mov al,2 ; index 2 control reg
  1381. out dx,al
  1382. mov al,ah
  1383. out dx,al
  1384. in al,dx
  1385. mov al,0 ; index 0 border position
  1386. out dx,al
  1387. mov al,94h
  1388. out dx,al
  1389. in al,dx
  1390. mov al,1 ; index 0 border width
  1391. out dx,al
  1392. mov al,8
  1393. out dx,al
  1394. in al,dx
  1395. mov al,3 ; index 0 border color sampling position
  1396. out dx,al
  1397. mov al,8
  1398. out dx,al
  1399. pop dx
  1400. pop bx
  1401. pop ax
  1402. endif ;KseVga
  1403. cmp ax,1001h
  1404. jz @f
  1405. cmp ax,1002h
  1406. jz @f
  1407. jmp JmpVdDummy
  1408. @@:
  1409. mov bl,010h
  1410. cmp [CurMode],060h
  1411. jz @f
  1412. cmp [CurMode],040h
  1413. jz @f
  1414. mov bl,00fh
  1415. cmp [CurMode],070h
  1416. jz @f
  1417. jmp JmpVdDummy
  1418. @@:
  1419. mov ES:[rCrtMode],bl
  1420. add sp,2
  1421. @pop bp,ds,es,di,si,dx,cx,bx
  1422. pushf
  1423. call cs:[OldVideo]
  1424. dec cs:[VideoActive]
  1425. @push ax,es
  1426. xor ax,ax
  1427. mov es,ax
  1428. mov al,CS:[CurMode]
  1429. mov ES:[rCrtMode],al
  1430. @pop es,ax
  1431. iret
  1432. JmpVdDummy:
  1433. jmp VdDummyRet ; go to ROM bios
  1434. ;========================================================================
  1435. ; << WriteCharAttr >>
  1436. ; FUNCTION = write character & attribute at given page
  1437. ; INPUT : AH = 09h
  1438. ; AL = char, BL = attr, BH = page, CX = counter
  1439. ; OUTPUT : none
  1440. ; PROTECT : none
  1441. ;========================================================================
  1442. ; << WriteChar >>
  1443. ; FUNCTION = write character at given page with current attribute
  1444. ; INPUT : AH = 0Ah
  1445. ; AL = char, (BL = attr), BH = page, CX = counter
  1446. ; OUTPUT : none
  1447. ; PROTECT : none
  1448. ; WriteCharAttr(AL,BX,CX/-)
  1449. ; WriteChar(AL,BX,CX/-)
  1450. ; {
  1451. ; CalcCurPosPage(BH/DX,[TextPos1Addr],[TextPos2Addr],[GrpPosAddr]);
  1452. ; if ([DisplayStat] == RunEsc), jump EscSequence(AX,BX,CX,DX/-);
  1453. ; if (AL = EscKey) && (CX = 1), jump EscSequence(AX,BX,CX,DX/-);
  1454. ; if ([MaxPage] == 1), BH = 0;
  1455. ; if (BH >= [MaxPage]), BH = [CurPage];
  1456. ; WriteCharAll(AL,AH,BL,BH,CX,DX/-);
  1457. ; }
  1458. WriteCharAttr:
  1459. WriteChar:
  1460. cmp [MaxPage],1
  1461. ja @f
  1462. xor bh,bh
  1463. @@:
  1464. cmp bh,[MaxPage]
  1465. jb @f
  1466. mov bh,[CurPage]
  1467. @@:
  1468. call CalcCurPosPage
  1469. test [DisplayStat],RunEsc
  1470. jz @f
  1471. jmp EscSequence
  1472. @@:
  1473. cmp al,EscKey
  1474. jne WriteCharEsc
  1475. cmp cx,1
  1476. jne WriteCharEsc
  1477. jmp EscSequence
  1478. WriteCharEsc:
  1479. call WriteCharAll
  1480. ret
  1481. ;========================================================================
  1482. ; << WriteTty >>
  1483. ; FUNCTION = write character with cursor moving
  1484. ; INPUT : AH = 0Eh
  1485. ; AL = charr, (BL = attr)
  1486. ; OUTPUT : none
  1487. ; PROTECT : none
  1488. ;========================================================================
  1489. ; << WriteTtyInterim >>
  1490. ; FUNCTION = write char and cursor move with interim char
  1491. ; INPUT : AH = 0FEh
  1492. ; AL = char, (BL = attr)
  1493. ; OUTPUT : none
  1494. ; PROTECT : none
  1495. ;
  1496. ; WriteTty(AL,BL/-)
  1497. ; WriteTtyInterim(AL,BL/-)
  1498. ; {
  1499. ; BH = [CurPage];
  1500. ; CalcCurPosPage(BH/DX,[TextPos1Addr],[TextPos2Addr],[GrpPosAddr]);
  1501. ; switch(AL)
  1502. ; case CR :
  1503. ; if ([HanStat] == Han1st), DispEnglishOld(-/-);
  1504. ; [HanStat] = [HanStat] && not Han1st;
  1505. ; DL = 0;
  1506. ; SetCurPos(BH,DX/-);
  1507. ; break;
  1508. ; case LF :
  1509. ; if ([HanStat] == Han1st), DispEnglishOld(-/-);
  1510. ; [HanStat] = [HanStat] && not Han1st;
  1511. ; if (DH = [MaxRows]-1), FullScroll(BH/-);
  1512. ; if (DH < [MaxRows]-1), DH = DH+1;
  1513. ; SetCurPos(BH,DX/-);
  1514. ; break;
  1515. ; case BELL :
  1516. ; AX = 0e07h;
  1517. ; call [OldInt10];
  1518. ; break;
  1519. ; case BS :
  1520. ; if (DL = 0), return;
  1521. ; if ([HanStat] == Han1st), DispEnglishOld(-/-);
  1522. ; [HanStat] = [HanStat] && not Han1st;
  1523. ; DL = DL-1
  1524. ; SetCurPos(BH,DX/-);
  1525. ; break;
  1526. ; default :
  1527. ; CX = 1;
  1528. ; if (AH == 0eh)
  1529. ; {
  1530. ; WriteCharAll(AL,AH,BL,BH,CX,DX/-);
  1531. ; +DL;
  1532. ; if (DL >= 80)
  1533. ; {
  1534. ; DL = 0;
  1535. ; +DH;
  1536. ; if (DH >= [MaxRows])
  1537. ; FullScroll(BH/-);
  1538. ; -DH;
  1539. ; }
  1540. ; SetCurPos(BH,DX/-);
  1541. ; }
  1542. ; else
  1543. ; {
  1544. ; AH = 0eh;
  1545. ; [OldHanStat] = [HanStat];
  1546. ; WriteCharAll(AL,AH,BL,BH,CX,DX/-);
  1547. ; DL = DL+1;
  1548. ; if ([HanStat] != Han1st) &&
  1549. ; ([OldHanStat] == Han1st)), DL = DL-2;
  1550. ; SetCurPos(BH,DX/-);
  1551. ; }
  1552. WriteTty:
  1553. WriteTtyInterim:
  1554. mov bh,[CurPage]
  1555. call CalcCurPosPage
  1556. cmp al,CR
  1557. jne WriteTtyLF
  1558. test [HanStat],Han1st
  1559. jz @f
  1560. call DispEnglishOld
  1561. and [HanStat], not Han1st
  1562. @@:
  1563. xor dl,dl
  1564. call SetCurPos
  1565. ret
  1566. WriteTtyLF:
  1567. cmp al,LF
  1568. jne WriteTtyBELL
  1569. test [HanStat],Han1st
  1570. jz @f
  1571. call DispEnglishOld
  1572. and [HanStat],not Han1st
  1573. @@:
  1574. inc dh
  1575. cmp dh,[MaxRows]
  1576. jne @f
  1577. dec dh
  1578. jmp FullScroll
  1579. @@:
  1580. call SetCurPos
  1581. ret
  1582. WriteTtyBELL:
  1583. cmp al,BELL
  1584. jne @f
  1585. mov ax,0e07h
  1586. pushf
  1587. call [OldVideo]
  1588. ret
  1589. @@:
  1590. cmp al,BS
  1591. jne WriteTtyDefault
  1592. or dl,dl
  1593. jz WriteTtyTmpExit
  1594. test [HanStat],Han1st
  1595. jz @f
  1596. call DispEnglishOld
  1597. and [HanStat], not Han1st
  1598. @@:
  1599. dec dl
  1600. call SetCurPos
  1601. WriteTtyTmpExit:
  1602. ret
  1603. WriteTtyDefault:
  1604. mov cx,1
  1605. cmp ah,0Eh
  1606. jnz WriteTtyFE
  1607. call WriteCharAll
  1608. inc dl
  1609. cmp dl,80
  1610. jb @f
  1611. xor dl,dl
  1612. inc dh
  1613. cmp dh,[MaxRows]
  1614. jnz @f
  1615. dec dh
  1616. call FullScroll
  1617. @@:
  1618. call SetCurPos
  1619. ret
  1620. WriteTtyFE:
  1621. ;
  1622. ; old Han1st new Han1st
  1623. ; 0 0 none
  1624. ; 0 1 inc
  1625. ; 1 0 dec
  1626. ; 1 1 dec
  1627. ;
  1628. mov ah,[HanStat]
  1629. mov [OldHanStat],ah
  1630. mov ah,0eh
  1631. call WriteCharAll
  1632. test [OldHanStat],Han1st ; 00, 01, 10, 11
  1633. jz @f
  1634. dec dl ; 10, 11
  1635. jmp short TtySeyCurPos
  1636. @@:
  1637. test [HanStat],Han1st ; 00, 01
  1638. jz TtySeyCurPos
  1639. inc dl ; 01
  1640. TtySeyCurPos:
  1641. call SetCurPos
  1642. WriteStringEnd:
  1643. ret
  1644. ;========================================================================
  1645. ; << WriteString >>
  1646. ; FUNCTION = write string
  1647. ; INPUT : AH = 13h, AL = function
  1648. ; BH = page, BL = attr(AL=0,1), CX = counter, DX = curpos
  1649. ; ES:BP = string pointer
  1650. ; OUTPUT : none
  1651. ; PROTECT : none
  1652. WriteString:
  1653. cmp al,3
  1654. ja WriteStringEnd
  1655. jcxz WriteStringEnd
  1656. mov si,[bp+rBP]
  1657. mov ds,[bp+rES]
  1658. mov di,bx
  1659. mov bl,bh
  1660. xchg di,bx
  1661. and di,0fh
  1662. shl di,1
  1663. push [di+rCurPos] ; save curpos
  1664. mov di,ax
  1665. mov ah,2
  1666. int 10h
  1667. WriteStrLoop:
  1668. ; BL = attr(AL=0,1), BH = page, DX = curpos, DS:SI = string position
  1669. ; ES = data segment, DI = function
  1670. lodsb
  1671. test di,00000010b
  1672. jz @f
  1673. xchg al,bl
  1674. lodsb
  1675. xchg al,bl
  1676. @@:
  1677. push cx
  1678. push si
  1679. push ds
  1680. mov cx,cs
  1681. mov ds,cx
  1682. cmp al,cr
  1683. jz WriteStr0E
  1684. cmp al,lf
  1685. jz WriteStr0E
  1686. cmp al,bell
  1687. jz WriteStr0E
  1688. cmp al,bs
  1689. jz WriteStr0E
  1690. test [HanStat],Han1st
  1691. jnz WriteStrEng
  1692. call CheckCodeRange1st
  1693. jc WriteStrEng
  1694. cmp dl,80-1
  1695. jb WriteStrEng
  1696. test [CodeStat],WSung7
  1697. jnz WriteStrEng
  1698. xor dl,dl
  1699. inc dh
  1700. cmp dh,[MaxRows]
  1701. jnz @f
  1702. dec dh
  1703. call FullScroll
  1704. @@:
  1705. call SetCurPos
  1706. WriteStrEng:
  1707. mov cx,1
  1708. mov ah,9
  1709. int 10h
  1710. inc dl
  1711. cmp dl,80
  1712. jb @f
  1713. xor dl,dl
  1714. inc dh
  1715. cmp dh,[MaxRows]
  1716. jnz @f
  1717. dec dh
  1718. call FullScroll
  1719. @@:
  1720. call SetCurPos
  1721. jmp short @f
  1722. WriteStr0E:
  1723. mov ah,0eh
  1724. int 10h
  1725. mov ah,3
  1726. int 10h
  1727. @@:
  1728. pop ds
  1729. pop si
  1730. pop cx
  1731. loop WriteStrLoop
  1732. pop dx ; restore curpos
  1733. test di,00000001b
  1734. jnz @f
  1735. mov ah,2
  1736. int 10h
  1737. @@:
  1738. ret
  1739. ;------------------------------------------------------------------------
  1740. ; << WriteCharAll >>
  1741. ; FUNCTION = write hangeul/english char
  1742. ; INPUT : AH = 9/0ah/0eh function
  1743. ; AL = char, (BL = attr), BH = page, CX = counter, DX = cursor pos
  1744. ; OUTPUT : none
  1745. ; PROTECT : BH, DX, DS, ES
  1746. ;
  1747. ; WriteCharAll(AL,AH,BL,BH,CX,DX/-)
  1748. ; {
  1749. ; GetAttr(AH,BL,BH/BL);
  1750. ; if (CheckCodeRangeWord(AX/carry)=DBCS(NC) && ([HanStat] == Han1st)
  1751. ; && ([OldCurPos] = DX) && ([OldPage] = BH))
  1752. ; DispHangeul(AL,BL,BH/-);
  1753. ; else
  1754. ; {
  1755. ; if ([HanStat] == Han1st)
  1756. ; DispEnglishOld(-/-);
  1757. ; if (CheckCodeRange1st(AL/carry) = DBCS(NC))
  1758. ; {
  1759. ; if ((DL >= 80-1)
  1760. ; {
  1761. ; if ([CodeStat] == WSung7)
  1762. ; goto DispEnglishNew(AL,BX,CX/-);
  1763. ; else
  1764. ; {
  1765. ; DL = 0;
  1766. ; +DH;
  1767. ; if (DH >= [MaxRows])
  1768. ; {
  1769. ; FullScroll(BH/-);
  1770. ; -DH;
  1771. ; }
  1772. ; SetCurPos(BH,DX/-);
  1773. ; CalcCurPosPage(BH/DX,[TextPos1Addr],[TextPos2Addr],[GrpPosAddr]);
  1774. ; }
  1775. ; }
  1776. ; /* save AL,BL,BH,CX,DH,DL+1,[TextPos1Addr],[TextPos2Addr],
  1777. ; [GrpPosAddr] to old */
  1778. ; if ([CodeStat] == WSung7), DispEnglishNew(AL,BX,CX/-);
  1779. ; [HanStat] = [HanStat] || Han1st;
  1780. ; }
  1781. ; else
  1782. ; DispEnglishNew(AL,BX,CX/-);
  1783. ; }
  1784. ; }
  1785. WriteCharAll:
  1786. call GetAttr
  1787. test [HanStat],Han1st
  1788. jz DispHanEnglish
  1789. cmp [OldCurPos],dx
  1790. jnz @f
  1791. cmp [OldPage],bh
  1792. jnz @f
  1793. push ax
  1794. mov ah,[OldChar]
  1795. call CheckCodeRangeWord
  1796. pop ax
  1797. jc @f
  1798. jmp DispHangeul
  1799. @@:
  1800. call DIspEnglishOld
  1801. and [HanStat],not Han1st
  1802. DispHanEnglish:
  1803. call CheckCodeRange1st
  1804. jc DispEnglish
  1805. call CheckCurPos1st
  1806. jc @f
  1807. jmp DispHangeul
  1808. @@:
  1809. cmp dl,80-1
  1810. jb DispSaveAddr
  1811. cmp ah,0ah
  1812. jbe DispEnglish
  1813. test [CodeStat],WSung7
  1814. jnz DispEnglish
  1815. xor dl,dl
  1816. inc dh
  1817. cmp dh,[MaxRows]
  1818. jnz @f
  1819. dec dh
  1820. call FullScroll
  1821. @@:
  1822. call SetCurPos
  1823. call CalcCurPosPage
  1824. DispSaveAddr:
  1825. mov [OldChar],al
  1826. mov [OldAttr],bl
  1827. mov [OldPage],bh
  1828. mov [OldCounter],cx
  1829. mov [OldCurPos],dx
  1830. inc [OldCurPos]
  1831. mov di,[TextPos1Addr]
  1832. mov [OldTextPos1Addr],di
  1833. mov di,[TextPos2Addr]
  1834. mov [OldTextPos2Addr],di
  1835. mov di,[GrpPosAddr]
  1836. mov [OldGrpPosAddr],di
  1837. test [CodeStat],WSung7
  1838. jz @f
  1839. call DispEnglishNew
  1840. @@:
  1841. or [HanStat],Han1st
  1842. ret
  1843. DispEnglish:
  1844. call DispEnglishNew
  1845. ret
  1846. CheckCurPos1st:
  1847. test [CodeStat],Chab or WSung7
  1848. jnz CheckCurPos1stR
  1849. test [Card1st],HanCard
  1850. jnz CheckCurPos1stR
  1851. cmp dl,0
  1852. jz CheckCurPos1stR
  1853. @push ds,si,ax,bx,cx,dx
  1854. mov cl,dl
  1855. sub cl,1
  1856. std
  1857. lds si,[CodeBuf1Addr]
  1858. add si,cs:[TextPos1Addr]
  1859. lodsw
  1860. xor ch,ch
  1861. xor bl,bl
  1862. lodsw
  1863. mov dx,ax
  1864. call CheckHanType
  1865. and al,00000011b
  1866. cld
  1867. cmp al,00000001b
  1868. jnz @f
  1869. mov [OldChar],dl
  1870. mov [OldAttr],dh
  1871. mov cx,01
  1872. mov [OldCounter],cx
  1873. @pop dx,cx,bx,ax
  1874. mov [OldPage],bh
  1875. mov [OldCurPos],dx
  1876. mov si,[TextPos1Addr]
  1877. sub si,2
  1878. mov [OldTextPos1Addr],di
  1879. mov si,[TextPos2Addr]
  1880. sub si,2
  1881. mov [OldTextPos2Addr],di
  1882. mov si,[GrpPosAddr]
  1883. sub si,2
  1884. mov [OldGrpPosAddr],di
  1885. @pop si,ds
  1886. clc
  1887. ret
  1888. @@:
  1889. @pop dx,cx,bx,ax,si,ds
  1890. CheckCurPos1stR:
  1891. stc
  1892. ret
  1893. ;------------------------------------------------------------------------
  1894. ; << EscSequence >>
  1895. ; FUNCTION = write english char
  1896. ; INPUT : AL = char, BL = attr, BH = page, CX = counter, DX = cursor pos
  1897. ; OUTPUT : none
  1898. ; PROTECT : AX, BX, CX, DX, DS, ES
  1899. ;
  1900. ; EscSequence(AX,BX,CX,DX/-)
  1901. ; {
  1902. ; if ([DisplayStat] == RunEsc)
  1903. ; {
  1904. ; switch([EscIndex])
  1905. ; case 0:
  1906. ; if (AL == '$'), EscIndex=1*2, break;
  1907. ; if (AL == '('), EscIndex=3*2, break;
  1908. ; DispEnglishOld(-/-);
  1909. ; [EscIndex] = 0;
  1910. ; [DisplayStat] = [DisplayStat] && not RunEsc;
  1911. ; jmp WriteCharEsc;
  1912. ; case 2:
  1913. ; if (AL == ')'), [EscIndex] = 2*2, break;
  1914. ; [EscIndex] = 0;
  1915. ; [DisplayStat] = [DisplayStat] && not RunEsc;
  1916. ; jmp WriteCharEsc;
  1917. ; case 4:
  1918. ; if (AL == '1'), /* set hangeul key in mode */
  1919. ; [EscIndex] = 0;
  1920. ; [DisplayStat] = [DisplayStat] && not RunEsc;
  1921. ; jmp WriteCharEsc;
  1922. ; case 6:
  1923. ; if (AL == '2'), /* reset hangeul key in mode */
  1924. ; [EscIndex] = 0;
  1925. ; [DisplayStat] = [DisplayStat] && not RunEsc;
  1926. ; jmp WriteCharEsc;
  1927. ; }
  1928. ; else
  1929. ; /* save AL,BL,BH,CX,DX
  1930. ; [TextPos1Addr],[TextPos2Addr],[GrpPosAddr] to old */
  1931. ; [DisplayStat] = [DisplayStat] || RunEsc;
  1932. ; [EscIndex] = 0;
  1933. ; }
  1934. EscSequence:
  1935. test [DisplayStat],RunEsc
  1936. jz RunEscStart
  1937. mov si,[EscIndex]
  1938. jmp [si+EscSeqJmpTbl]
  1939. EscSeqJmpTbl Label Word
  1940. dw offset EscIndexDollar
  1941. dw offset EscIndexLeftBr
  1942. dw offset EscIndex1
  1943. dw offset EscIndex2
  1944. RunEscStart:
  1945. mov [OldChar],al
  1946. mov [OldAttr],bl
  1947. mov [OldPage],bh
  1948. mov [OldCounter],cx
  1949. mov [OldCurPos],dx
  1950. mov di,[TextPos1Addr]
  1951. mov [OldTextPos1Addr],di
  1952. mov di,[TextPos2Addr]
  1953. mov [OldTextPos2Addr],di
  1954. mov di,[GrpPosAddr]
  1955. mov [OldGrpPosAddr],di
  1956. or [DisplayStat],RunEsc
  1957. mov [EscIndex],0
  1958. ret
  1959. EscIndexDollar:
  1960. cmp al,'$'
  1961. jne @f
  1962. mov [EscIndex],1*2
  1963. ret
  1964. @@:
  1965. cmp al,'('
  1966. jne @f
  1967. mov [EscIndex],3*2
  1968. ret
  1969. @@:
  1970. call DispEnglishOld
  1971. EscBreak:
  1972. mov [EscIndex],0
  1973. and [DisplayStat],not RunEsc
  1974. jmp WriteCharEsc
  1975. EscIndexLeftBr:
  1976. cmp al,')'
  1977. jne EscBreak
  1978. mov [EscIndex],2*2
  1979. ret
  1980. EscIndex1:
  1981. cmp al,'1'
  1982. jne EscBreak
  1983. or [KbStat],HEStat ; Hangeul On
  1984. mov [EscIndex],0
  1985. and [DisplayStat],not RunEsc
  1986. ret
  1987. EscIndex2:
  1988. cmp al,'2'
  1989. jne EscBreak
  1990. and [KbStat],not HEStat ; Hangeul Off
  1991. mov [EscIndex],0
  1992. and [DisplayStat],not RunEsc
  1993. ret
  1994. ;------------------------------------------------------------------------
  1995. ; << CalcCurPosPage >>
  1996. ; FUNCTION = calculation cursor position
  1997. ; INPUT : BH
  1998. ; OUTPUT : DX
  1999. ; : [TextPos1Addr],[TextPos2Addr],[GrpPosAddr]
  2000. ; PROTECT : AX,BX,CX
  2001. ;
  2002. ; CalcCurPosPage(BH/DX,[TextPos1Addr],[TextPos2Addr],[GrpPosAddr])
  2003. ; {
  2004. ; save AX,BX,CX;
  2005. ; CX = ES:[BH*2+rCurPos];
  2006. ; [TextPos1Addr] = CH*80*2+CL*2+ES:[rCrtLen]*BH;
  2007. ; [TextPos2Addr] = CH*80*2+CL*2;
  2008. ; if ([ModeId] == HgcGrpMode(ModeId=2/4/10)
  2009. ; {
  2010. ; [GrpPosAddr] = CH*80*4+CL;
  2011. ; }
  2012. ; [GrpPosAddr] = CH*80*16+CL;
  2013. ; [CurPos] = CX;
  2014. ; DX = CX;
  2015. ; restore AX,BX,CX;
  2016. ; }
  2017. CalcCurPosPage:
  2018. @push ax,bx,cx
  2019. mov bl,bh
  2020. xor bh,bh
  2021. shl bx,1
  2022. mov cx,[bx+rCurPos]
  2023. mov [CurPos],cx
  2024. mov al,80
  2025. mul ch
  2026. mov dx,cx ; GrpPosAddr�� �����ϱ����� ����
  2027. xor dh,dh
  2028. add ax,dx
  2029. shl ax,1
  2030. mov [TextPos1Addr],ax
  2031. mov [TextPos2Addr],ax
  2032. mov ax,[rCrtLen]
  2033. shr bx,1
  2034. mul bx
  2035. add [TextPos1Addr],ax
  2036. mov ax,80*4
  2037. cmp [ModeId],4
  2038. jbe @f
  2039. cmp [ModeId],5*2
  2040. jz @f
  2041. mov ax,80*16
  2042. @@:
  2043. mov dl,ch
  2044. xor dh,dh
  2045. mul dx
  2046. xor ch,ch
  2047. add ax,cx
  2048. mov [GrpPosAddr],ax
  2049. mov dx,[CurPos]
  2050. @pop cx,bx,ax
  2051. ret
  2052. ;------------------------------------------------------------------------
  2053. ; << GetAttr >>
  2054. ; FUNCTION = get attribute
  2055. ; INPUT : AH = 9/0ah/0eh function
  2056. ; BH = page#
  2057. ; BL = attribute
  2058. ; OUTPUT : BL = attribute
  2059. ; PROTECT : AX,BH,CX,DX,DS,ES,SI
  2060. ; {
  2061. ; if (([ModeStat] != GrpMode) || (AH != 9))
  2062. ; {
  2063. ; save DS,SI;
  2064. ; BL = CodeBuf1Addr:[[CodeBuf1Addr]+[TextPos1Addr]+1];
  2065. ; restore DS,SI;
  2066. ; }
  2067. ; }
  2068. ; GetAttr(AH,BL,BH/BL)
  2069. GetAttr:
  2070. test [ModeStat],GrpMode
  2071. jnz @f
  2072. cmp ah,09h
  2073. jz @f
  2074. @push di,es
  2075. les di,[CodeBuf1Addr]
  2076. add di,[TextPos1Addr]
  2077. mov bl,es:[di+1]
  2078. @pop es,di
  2079. @@:
  2080. ret
  2081. ;========================================================================
  2082. ; << WritePixel >>
  2083. ; FUNCTION = write graphics pixel
  2084. ; INPUT : AH = 0Ch
  2085. ; AL = color, BH = page, CX = graphics columns, DX = graphics rows
  2086. ; OUTPUT : none
  2087. ; PROTECT : none
  2088. ; WritePixel(AL,BH,CX,DX/-)
  2089. ; {
  2090. ; switch([ModeId])
  2091. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  2092. ; case 2 : ; TE mode 7, MGA
  2093. ; case 4 : ; TE mode 2/3, CGA
  2094. ; case 6 : ; TE mode 7, EGA/VGA
  2095. ; case 8 : ; TE mode 2/3, EGA/VGA
  2096. ; break;
  2097. ; case 10 : ; mode 40/70
  2098. ; MgaWritePixel(AL,CX,DX/-);
  2099. ; break;
  2100. ; case 12 : ; mode 60/11/12, EGA/VGA
  2101. ; VgaWritePixel(AL,CX,DX/-);
  2102. ; break;
  2103. ; }
  2104. WritePixel:
  2105. les di,[GrpBufAddr]
  2106. xchg si,bx
  2107. mov bl,[ModeId]
  2108. xor bh,bh
  2109. xchg si,bx
  2110. jmp [si+WritePixelJmpTbl]
  2111. WritePixelJmpTbl Label Word
  2112. dw offset WrtPxlHanCardText
  2113. dw offset WrtPxlMgaTE
  2114. dw offset WrtPxlCgaTE
  2115. dw offset WrtPxlEgaVgaTE7
  2116. dw offset WrtPxlEgaVgaTE2_3
  2117. dw offset MgaWritePixel
  2118. dw offset VgaWritePixel
  2119. WrtPxlHanCardText:
  2120. WrtPxlMgaTE:
  2121. WrtPxlCgaTE:
  2122. WrtPxlEgaVgaTE7:
  2123. WrtPxlEgaVgaTE2_3:
  2124. ret
  2125. ;========================================================================
  2126. ; << ReadPixel >>
  2127. ; FUNCTION = write graphics pixel
  2128. ; INPUT : BH = page, CX = graphics columns, DX = graphics rows
  2129. ; OUTPUT : AL = color
  2130. ; PROTECT : none
  2131. ; ReadPixel(BH,CX,DX/)
  2132. ; {
  2133. ; switch([ModeId])
  2134. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  2135. ; case 2 : ; TE mode 7, MGA
  2136. ; case 4 : ; TE mode 2/3, CGA
  2137. ; case 6 : ; TE mode 7, EGA/VGA
  2138. ; case 8 : ; TE mode 2/3, EGA/VGA
  2139. ; break;
  2140. ; case 10 : ; mode 40/70
  2141. ; MgaReadPixel(BH,CX,DX/AL);
  2142. ; break;
  2143. ; case 12 : ; mode 60/11/12, EGA/VGA
  2144. ; VgaReadPixel(BH,CX,DX/AL);
  2145. ; break;
  2146. ; }
  2147. ReadPixel:
  2148. les di,[GrpBufAddr]
  2149. xchg si,bx
  2150. mov bl,[ModeId]
  2151. xor bh,bh
  2152. xchg si,bx
  2153. jmp [si+ReadPixelJmpTbl]
  2154. ReadPixelJmpTbl Label Word
  2155. dw offset RdPxlHanCardText
  2156. dw offset RdPxlMgaTE
  2157. dw offset RdPxlCgaTE
  2158. dw offset RdPxlEgaVgaTE7
  2159. dw offset RdPxlEgaVgaTE2_3
  2160. dw offset MgaReadPixel
  2161. dw offset VgaReadPixel
  2162. RdPxlHanCardText:
  2163. RdPxlMgaTE:
  2164. RdPxlCgaTE:
  2165. RdPxlEgaVgaTE7:
  2166. RdPxlEgaVgaTE2_3:
  2167. ret
  2168. ;========================================================================
  2169. ; << ScrollUp >>
  2170. ; FUNCTION = window scroll up
  2171. ; INPUT : AH = 06h
  2172. ; AL = scroll line #, CX = window start, DX = window end
  2173. ; BH = attribute to be used on blank lines
  2174. ; OUTPUT : none
  2175. ; PROTECT : none
  2176. ;========================================================================
  2177. ; << ScrollDown >>
  2178. ; FUNCTION = window scroll down
  2179. ; INPUT : AH = 07h
  2180. ; AL = scroll line #, CX = window start, DX = window end
  2181. ; BH = attribute to be used on blank lines
  2182. ; OUTPUT : none
  2183. ; PROTECT : none
  2184. ; ScrollUp(AL,BH,CX,DX/-)
  2185. ; ScrollDown(AL,BH,CX,DX/-)
  2186. ; {
  2187. ; if (CL > DL), xchg CL,DL;
  2188. ; if (CH > DH), xchg CH,DH;
  2189. ; if (DL >= 80), return;
  2190. ; if (DH >= [MaxRows]), return;
  2191. ; if (AL > (DL-CL)), AL=(DL-CL); /* scroll line counter */
  2192. ; if ([ModeStat] == GrpMode)
  2193. ; {
  2194. ; if (BH = 0), BH = 7;
  2195. ; if (BH = -1), BH = 70h;
  2196. ; }
  2197. ; [HanStat] = [HanStat] && not Han1st;
  2198. ; TextEmu(-/-);
  2199. ; ClearCursor(-/-);
  2200. ; save CX;
  2201. ; CalcScrollParms(AL,CX,DX/...);
  2202. ; TextBufferScroll(1st code buffer's segment:offset/-);
  2203. ; if ([ModeStat] == TextEmulation), TextBufferScroll(2nd code buffer's segment:offset/-);
  2204. ; restore CX;
  2205. ; switch([ModeId])
  2206. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  2207. ; break;
  2208. ; case 2 : ; TE mode 7, MGA
  2209. ; case 4 : ; TE mode 2/3, CGA
  2210. ; case 10 : ; mode 40/70
  2211. ; MgaGrpScroll(.../-);
  2212. ; break;
  2213. ; case 6 : ; TE mode 7, EGA/VGA
  2214. ; case 8 : ; TE mode 2/3, EGA/VGA
  2215. ; case 12 : ; mode 60/11/12, EGA/VGA
  2216. ; VgaGrpScroll(.../-);
  2217. ; break;
  2218. ; }
  2219. ScrollUp:
  2220. ScrollDown:
  2221. and [DisplayStat],not Han1st
  2222. and [DisplayStat],not RunEsc ; reset ESC sequence
  2223. call ClearCursor
  2224. mov cs:[ScrUpDnFlag],1
  2225. cmp ah,6
  2226. jz @f
  2227. mov cs:[ScrUpDnFlag],2
  2228. @@:
  2229. cmp cl,dl
  2230. jb @f
  2231. xchg cl,dl
  2232. @@:
  2233. cmp ch,dh
  2234. jb @f
  2235. xchg ch,dh
  2236. @@:
  2237. cmp dl,80
  2238. jb @f
  2239. mov dl,80-1
  2240. @@:
  2241. cmp dh,[MaxRows]
  2242. jb @f
  2243. mov dh,[MaxRows]
  2244. dec dh
  2245. @@:
  2246. mov bl,dh
  2247. sub bl,ch
  2248. inc bl
  2249. cmp bl,al
  2250. jae @f
  2251. mov al,bl
  2252. @@:
  2253. or al,al
  2254. jnz @f
  2255. mov al,bl
  2256. @@:
  2257. cmp [ModeId],5*2 ; 5 - mode 40/70
  2258. jnz NotBlank
  2259. or bh,bh
  2260. jne @f
  2261. mov bh,7 ; 0 -> 7
  2262. jmp NotBlank
  2263. @@:
  2264. cmp bh,-1
  2265. jne NotBlank
  2266. mov bh,70h ; FF -> 70h
  2267. NotBlank:
  2268. call TextEmu
  2269. call CalcScrollParms
  2270. push bx
  2271. mov bx,[rCrtStart]
  2272. les ax,[CodeBuf1Addr]
  2273. add ax,bx
  2274. pop bx
  2275. call TextBufferScroll ; 1st code buffer
  2276. test [ModeStat],TextEmulation
  2277. jz @f
  2278. les ax,[CodeBuf2Addr]
  2279. call TextBufferScroll ; 2nd code buffer
  2280. @@:
  2281. mov al,[ModeId]
  2282. xor ah,ah
  2283. mov si,ax
  2284. call [si+ScrollUpDownJmpTbl]
  2285. ScrollUpDownExit:
  2286. ScrUpDownHanCardText:
  2287. ret
  2288. ScrollUpDownJmpTbl Label Word
  2289. dw offset ScrUpDownHanCardText
  2290. dw offset MgaGrpScroll
  2291. dw offset MgaGrpScroll
  2292. dw offset VgaGrpScroll
  2293. dw offset VgaGrpScroll
  2294. dw offset MgaGrpScroll
  2295. dw offset VgaGrpScroll
  2296. ;========================================================================
  2297. ; << CodeChange >>
  2298. ; FUNCTION = �ڵ庯ȯ����
  2299. ; INPUT : AH = 0F5h
  2300. ; input : AL = 00h ; �Էµ� �ϼ����ڵ带 �������ڵ��� ��ȯ
  2301. ; BX = �ϼ����ڵ�
  2302. ; output: AL = 00H=success ,BX = ��ȯ�� �������ڵ�
  2303. ; AL = FFH=fail
  2304. ; input : AL = 01h ; �Էµ� �������ڵ带 �ϼ����ڵ��� ��ȯ
  2305. ; BX = �������ڵ�
  2306. ; output: AL = 00H=success ,BX = ��ȯ�� �ϼ����ڵ�
  2307. ; AL = FEH �ϼ����� ���Ե��� ���� �ѱ� ������
  2308. ; BX = �Էµ� ������ �ʼ��� �ش��ϴ� �ѱ۳����ڵ�
  2309. ; CX = �Էµ� ������ �߼��� �ش��ϴ� �ѱ۳����ڵ�
  2310. ; DX = �Էµ� ������ ������ �ش��ϴ� �ѱ۳����ڵ�
  2311. ; AL = FFH=fail(�Է°��� �������� ����.)
  2312. ; input : AL = 02h ; �ϼ��� �����ڷḦ �������ڵ��� ��ȯ
  2313. ; BX = �ʼ��� �ش��ϴ� �ѱ۳����ڵ�
  2314. ; CX = �߼��� �ش��ϴ� �ѱ۳����ڵ�
  2315. ; DX = ������ �ش��ϴ� �ѱ۳����ڵ�
  2316. ; output: AL = 00H success ,BX = ��ȯ�� �������ڵ�
  2317. ; AL = FFH fail
  2318. ; PROTECT : none
  2319. fFillCode = 84h
  2320. vFillCode = 40h
  2321. lFillCode = 01h
  2322. CodeChange:
  2323. cmp al,02h
  2324. ja CodeChgErr
  2325. xor ah,ah
  2326. mov si,ax
  2327. shl si,1
  2328. mov ax,bx
  2329. jmp [si+CodeChangeTbl]
  2330. CodeChangeTbl Label word
  2331. dw offset Ks2ChCall
  2332. dw offset Ch2KsCall
  2333. dw offset KsComp2ChCall
  2334. Ks2ChCall:
  2335. call ChgKs2Ch
  2336. jc CodeChgErr
  2337. jmp CodeChgSuc
  2338. Ch2KsCall:
  2339. call CheckCodeRangeCh
  2340. jc CodeChgErr
  2341. call ChgCh2Ks
  2342. jnc CodeChgSuc
  2343. jmp SplitCompKS
  2344. KsComp2ChCall:
  2345. call CheckCodeRangeWs
  2346. jc CodeChgErr
  2347. call Ks2Ch
  2348. jc CodeChgErr
  2349. xchg ax,cx
  2350. call Ks2Ch
  2351. jc CodeChgErr
  2352. xchg ax,dx
  2353. mov bl,lFillCode
  2354. cmp ax,0a4d4h
  2355. jz @f
  2356. cmp ax,0a4a1h
  2357. jb CodeChgErr
  2358. cmp ax,0a4beh
  2359. ja CodeChgErr
  2360. call Ks2Chcompn
  2361. jc CodeChgErr
  2362. @@:
  2363. and ch,11111100b
  2364. and dh,10000011b
  2365. and dl,11100000b
  2366. and bl,00011111b
  2367. xor bh,bh
  2368. or bx,dx
  2369. or bh,ch
  2370. mov ax,bx
  2371. CodeChgSuc:
  2372. mov [bp+rBX],ax
  2373. xor al,al
  2374. ret
  2375. CodeChgErr:
  2376. mov al,0ffh
  2377. ret
  2378. ;------------------
  2379. SplitCompKS:
  2380. mov ax,bx
  2381. mov dx,ax
  2382. and ah,10000011b ;�߼�
  2383. and al,11100000b
  2384. or ah,fFillCode
  2385. or al,lFillCode
  2386. call Ch2Ks
  2387. jc CodeChgErr
  2388. mov cx,ax
  2389. mov ax,dx ;�ʼ�
  2390. and ah,11111100b
  2391. mov al,0
  2392. or al,(vFillCode or lFillCode)
  2393. call Ch2Ks
  2394. jc CodeChgErr
  2395. xchg dx,ax
  2396. mov bx,0a4d4h
  2397. mov ah,0
  2398. and al,00011111b
  2399. cmp al,lFillCode
  2400. jz @f
  2401. or ah,fFillCode
  2402. or al,vFillCode
  2403. call Ch2Ks
  2404. mov bx,ax
  2405. @@:
  2406. mov [bp+rBX],dx
  2407. mov [bp+rCX],cx
  2408. mov [bp+rDX],bx
  2409. mov al,0feh
  2410. ret
  2411. Ks2Chcompn:
  2412. mov bl,al
  2413. sub bl,05fh
  2414. cmp al,0a8h
  2415. je ChcompErr
  2416. jb @f
  2417. sub bl,1
  2418. cmp al,0b2h
  2419. jb @f
  2420. add bl,1
  2421. cmp al,0b3h
  2422. je ChcompErr
  2423. jb @f
  2424. sub bl,1
  2425. cmp al,0b9h
  2426. je ChcompErr
  2427. jb @f
  2428. sub bl,1
  2429. @@:
  2430. clc
  2431. ret
  2432. ChcompErr:
  2433. stc
  2434. ret
  2435. ;========================================================================
  2436. ; << ControlCode >>
  2437. ; FUNCTION = ������ȣ�� �������ñ���
  2438. ; INPUT : AH = 0F4h
  2439. ; input : AL = 00h
  2440. ; output: AL = 00H = �ý����� �����ڵ� ü�谡 �ϼ���
  2441. ; AL = 01H = �ý����� �����ڵ� ü�谡 �ϼ����� ������
  2442. ; BL = 00H : �ϼ�����ȣ��
  2443. ; BL = 01H : ��������ȣ��
  2444. ; AL = 02H = �ý����� �����ڵ� ü�谡 ������
  2445. ; PROTECT : none
  2446. ControlCode:
  2447. cmp al,00h
  2448. jne ControlCodeRet
  2449. test [CodeStat],ChabLoad
  2450. jz ControlCodeRet
  2451. mov bx,[bp+rBX]
  2452. mov al,1
  2453. xor bl,bl
  2454. test [CodeStat],WSung7 or Chab
  2455. jz @f
  2456. mov bl,01h
  2457. test [CodeStat],Chab
  2458. jnz @f
  2459. mov bl,02h
  2460. @@:
  2461. mov [bp+rBX],bx
  2462. ControlCodeRet:
  2463. ret
  2464. ;========================================================================
  2465. ; << BlockMove >>
  2466. ; FUNCTION = block move
  2467. ; INPUT : AH = 0F6h
  2468. ; AL = attr, BX = target position, CX:DX = windows
  2469. ; OUTPUT : none
  2470. ; PROTECT : none
  2471. ;========================================================================
  2472. ; << BlockCopy >>
  2473. ; FUNCTION = block copy
  2474. ; INPUT : AH = 0F7h
  2475. ; AL = attr, BX = target position, CX:DX = windows
  2476. ; OUTPUT : none
  2477. ; PROTECT : none
  2478. ; BlockMove(AL,BX,CX,DX/-)
  2479. ; BlockCopy(BX,CX,DX/-)
  2480. ; {
  2481. ; [DispStat] = [DispStat] && not Han1st
  2482. ; [DispStat] = [DispStat] && not RunEsc
  2483. ; if ( [ModeStat] = GrpMode ), return;
  2484. ; ClearCursor(-/-);
  2485. ; if (DH >= [MaxRows]), return; /* range over */
  2486. ; if (DL >= 80), return; /* range over */
  2487. ; if ((DL-CL+BL) >= 80), return; /* range over */
  2488. ; if ((DH-CH+BH) >= [MaxRows]), return; /* range over */
  2489. ; if (CL > DL), return;
  2490. ; if (CH > DH), return;
  2491. ; if (BX = CX), return;
  2492. ; ParseBlock(-/-);
  2493. ; Save CX,BX;
  2494. ; CalcTextBlock(-/-);
  2495. ; DS:SI = [CodeBuf1Addr + rCrtStart]
  2496. ; BlockText(1st code buffer's segment:offset/-);
  2497. ; if ([ModeStat] == TextEmulation), BlockText(2nd code buffer's segment:offset/-);
  2498. ; switch([ModeId])
  2499. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  2500. ; break;
  2501. ; case 2 : ; TE mode 7, MGA
  2502. ; case 4 : ; TE mode 2/3, CGA
  2503. ; MgaGrpBlock(BX/-);
  2504. ; break;
  2505. ; case 6 : ; TE mode 7, EGA/VGA
  2506. ; case 8 : ; TE mode 2/3, EGA/VGA
  2507. ; VgaGrpBlock(BX/-);
  2508. ; case 10 : ; mode 40/70
  2509. ; case 12 : ; mode 60/11/12, EGA/VGA
  2510. ; }
  2511. BlockMove:
  2512. BlockCopy:
  2513. and [DisplayStat],not Han1st
  2514. and [DisplayStat],not RunEsc ; reset ESC sequence
  2515. test [ModeStat],GrpMode
  2516. jnz BlockEnd
  2517. call ClearCursor
  2518. cmp dh,25
  2519. jae BlockEnd
  2520. cmp dl,80
  2521. jae BlockEnd
  2522. mov bp,ax
  2523. mov si,dx
  2524. sub dx,cx
  2525. mov ax,dx
  2526. add dx,bx
  2527. cmp dh,25
  2528. jae BlockEnd
  2529. cmp dl,80
  2530. jae BlockEnd
  2531. mov dx,si
  2532. cmp dl,cl
  2533. jc BlockEnd
  2534. cmp dh,ch
  2535. jc BlockEnd
  2536. cmp bx,cx
  2537. jz BlockEnd
  2538. call ParseBlock
  2539. push cx
  2540. push bx
  2541. call CalcTextBlock
  2542. lds ax,[CodeBuf1Addr]
  2543. add ax,es:[rCrtStart]
  2544. call BlockText
  2545. test [ModeStat],TextEmulation
  2546. jz @f
  2547. lds ax,[CodeBuf2Addr]
  2548. call BlockText
  2549. @@:
  2550. push bx
  2551. mov bl,cs:[ModeId]
  2552. xor bh,bh
  2553. jmp [bx+BlockMoveCopyJmpTbl]
  2554. BlkMvCpHanCardText:
  2555. BlkMvCpMode40_70:
  2556. BlkMvCpMode60_11_12:
  2557. @pop bx,bx,cx
  2558. BlockEnd:
  2559. ret
  2560. BlockMoveCopyJmpTbl Label Word
  2561. dw offset BlkMvCpHanCardText
  2562. dw offset MgaGrpBlock
  2563. dw offset MgaGrpBlock
  2564. dw offset VgaGrpBlock
  2565. dw offset VgaGrpBlock
  2566. dw offset BlkMvCpMode40_70
  2567. dw offset BlkMvCpMode60_11_12
  2568. ;================================================
  2569. ParseBlock:
  2570. mov [BlockAdj],0
  2571. cmp bh,ch
  2572. jb Block12
  2573. Block34:
  2574. and bp,0bfffh
  2575. cmp bl,cl
  2576. jb Block3
  2577. Block4:
  2578. add bx,ax
  2579. xchg cx,dx
  2580. and bp,7fffh ; set STD
  2581. std
  2582. jmp short @f
  2583. Block3:
  2584. mov [BlockAdj],-(80*4)
  2585. xchg ch,dh
  2586. add bh,ah
  2587. jmp short @f
  2588. Block12:
  2589. cmp bl,cl
  2590. jb @f
  2591. Block2:
  2592. mov [BlockAdj],80*4
  2593. add bl,al
  2594. xchg cl,dl
  2595. and bp,7fffh ; set STD
  2596. std
  2597. @@:
  2598. ret
  2599. ;========================================================================
  2600. ; << GetCharType >>
  2601. ; FUNCTION = get char type at current cursor position
  2602. ; INPUT : AH = 0F8h
  2603. ; OUTPUT : AL = char type
  2604. ; PROTECT : none
  2605. ; (AL) bit 76543210
  2606. ; ||
  2607. ; |+---> # of bytes of char
  2608. ; | 0: 1 byte character
  2609. ; | 1: 2 byte character
  2610. ; +----> ordinal # of 2 byte char
  2611. ; 0: 1st byte of 2 byte character
  2612. ; 1: 2nd byte of 2 byte character
  2613. ; GetCharType(-/AL)
  2614. ; {
  2615. ; if ([CodeStat] != (Chab || WSung7))
  2616. ; {
  2617. ; BH = ES:[rCurPage];
  2618. ; CalcCurPosPage(BH/DX,[TextPos1Addr],[TextPos2Addr],[GrpPosAddr]);
  2619. ; CL = DL;
  2620. ; CH = 0;
  2621. ; BL = 0;
  2622. ; STD;
  2623. ; DS : SI = [CodeBuf1Addr];
  2624. ; while ( CX == 0, CX-)
  2625. ; {
  2626. ; LODSW;
  2627. ; if (CheckCodeRange1st(AL/carry) == DBCS(NC))
  2628. ; {
  2629. ; BL = BL || 1;
  2630. ; XOR BL,2;
  2631. ; }
  2632. ; }
  2633. ; AL = BL;
  2634. ; }
  2635. ; }
  2636. GetCharType:
  2637. mov bl,al
  2638. test [CodeStat],Chab or WSung7
  2639. jnz GetCharTypeEnd
  2640. mov bh,[rCurPage]
  2641. call CalcCurPosPage
  2642. std
  2643. lds si,[CodeBuf1Addr]
  2644. add si,cs:[TextPos1Addr]
  2645. mov cl,dl
  2646. xor ch,ch
  2647. xor bl,bl
  2648. lodsw
  2649. CheckHanType:
  2650. call CheckCodeRange1st
  2651. mov al,0
  2652. jc GetCharTypeEnd
  2653. or bl,00000001b
  2654. @@:
  2655. lodsw
  2656. call CheckCodeRange1st
  2657. jc @f
  2658. xor bl,00000010b
  2659. loop @b
  2660. @@:
  2661. mov al,bl
  2662. GetCharTypeEnd:
  2663. ret
  2664. ;========================================================================
  2665. ; << FontCtrl >>
  2666. ; FUNCTION = see sub function
  2667. ; INPUT : AH = 0FCh
  2668. ; AL = sub function
  2669. ; OUTPUT : see sub function
  2670. ; PROTECT : none
  2671. ; input (ah)=FCH read/write font from/to char pattern
  2672. ; (�������� �Ǵ� ���ڻ����� ũ�� �б�)
  2673. ; (cx) char to read/write font(ch=0 if 1 byte char on read)
  2674. ; input (al)=0 read font for given code
  2675. ; (es:bx) pointer of character pattern buffer
  2676. ; output (al)=0 successfully operation
  2677. ; (es:bx) pointer of character pattern buffer
  2678. ; (al)=ff error, corresponding pattern can't be read
  2679. ; input (al)=1 read size of char box
  2680. ; output (ah,al) (horizontal size, vertical size)
  2681. ; input (al)=2 write font for given 2 byte code (UDC only)
  2682. ; (es:bx) pointer of character pattern buffer
  2683. ; output (al)=0 successfully operation
  2684. ; (al)=ff error, corresponding pattern can't be written
  2685. ; FontCtrl(AL/AL)
  2686. ; {
  2687. ; switch(AL)
  2688. ; case 0 :
  2689. ; ES = SS:[BP+rES];
  2690. ; DI = SS:[BP+rBX];
  2691. ; if CH = 0
  2692. ; {
  2693. ; if (GetPatternEng(CL,ES,DI/carry)=error(CY)), AL = -1;
  2694. ; else AL = 0;
  2695. ; }
  2696. ; else
  2697. ; {
  2698. ; if (GetPattern(CX,ES,DI/carry)=error(CY)), AL = -1;
  2699. ; else AL = 0;
  2700. ; }
  2701. ; break;
  2702. ; case 1 :
  2703. ; AL = 16;
  2704. ; AH = 16;
  2705. ; break;
  2706. ; case 2 :
  2707. ; DS = SS:[BP+rES];
  2708. ; SI = SS:[BP+rBX];
  2709. ; if (PutPattern(CX,DS,SI/carry)=error(CY)), AL = -1;
  2710. ; else AL = 0;
  2711. ; break;
  2712. ; default : AL = -1;
  2713. ; }
  2714. FontCtrl:
  2715. cmp al,1
  2716. jae FontCtrlSub1
  2717. mov es,[bp+rES]
  2718. mov di,[bp+rBX]
  2719. or ch,ch
  2720. jnz NotEng16
  2721. call GetPatternEng
  2722. jc @f
  2723. xor al,al
  2724. ret
  2725. @@:
  2726. mov al,-1
  2727. ret
  2728. NotEng16:
  2729. call GetPattern
  2730. jc @b
  2731. xor al,al
  2732. ret
  2733. FontCtrlSub1:
  2734. jne FontCtrlSub2
  2735. mov al,10h
  2736. mov ah,al
  2737. ret
  2738. FontCtrlSub2:
  2739. cmp al,2
  2740. ja @b
  2741. mov ds,[bp+rES]
  2742. mov si,[bp+rBX]
  2743. call PutPattern
  2744. jc @b
  2745. xor al,al
  2746. ret
  2747. ;========================================================================
  2748. ; << GetInfor >>
  2749. ; FUNCTION = get hangeul BIOS information
  2750. ; INPUT : AH = 0FDh
  2751. ; AL = 00
  2752. ; OUTPUT : AL = 0fdh, ES:BX = BIOS data address
  2753. ; PROTECT : none
  2754. ; GetInfor(-/AL,ES,BX)
  2755. ; {
  2756. ; if AL = 0, break;
  2757. ; SS:[BP+rES] = CS;
  2758. ; SS:[BP+rBX] = offset public data;
  2759. ; AL = AH;
  2760. ; }
  2761. GetInfor:
  2762. or al,al
  2763. jnz @f
  2764. mov [bp+rES],cs
  2765. mov word ptr [bp+rBX],offset PublicData
  2766. mov al,ah
  2767. @@:
  2768. ret
  2769. ;========================================================================
  2770. ;
  2771. ; VIDEO SUB-ROUTINES
  2772. ;
  2773. ;------------------------------------------------------------------------
  2774. ; << CheckCodeRangeWord >>
  2775. ; FUNCTION = check code range for word
  2776. ; INPUT : AX = Code
  2777. ; OUTPUT : AX = Code
  2778. ; : carry - NC ( success )
  2779. ; : - CY ( code range over )
  2780. ; PROTECT : AL,BX,DX,DS,ES
  2781. ;
  2782. ; CheckCodeRangeWord(AX/AX,carry)
  2783. ; {
  2784. ; switch([CodeStat])
  2785. ; case WSung :
  2786. ; if ((0a1h=<AH=<0feh) && (0a1h=<AL=<0feh)), NC, break;
  2787. ; CY;
  2788. ; break;
  2789. ; case CHab :
  2790. ; if ((84h=<AH<=0d3h) && (041h=<AL=<07eh)), NC, break;
  2791. ; if ((84h=<AH<=0d3h) && (081h=<AL=<0feh)), NC, break;
  2792. ; if ((d9h=<AH<=0deh) && (031h=<AL=<07eh)), NC, break;
  2793. ; if ((d9h=<AH<=0deh) && (091h=<AL=<0feh)), NC, break;
  2794. ; if ((e0h=<AH<=0f9h) && (031h=<AL=<07eh)), NC, break;
  2795. ; if ((e0h=<AH<=0f9h) && (091h=<AL=<0feh)), NC, break;
  2796. ; if ((feh=AH) && (031h=<AL=<07eh)), NC, break;
  2797. ; if ((feh=AH) && (091h=<AL=<0feh)), NC, break;
  2798. ; CY;
  2799. ; break;
  2800. ; case WSung7 :
  2801. ; if (5fh=<AH=<60h) && (21h=<AL=<7eh), NC, return;
  2802. ; if (7bh=<AH=<7eh) && (21h=<AL=<7eh), NC, break;
  2803. ; if (61h=<AH=<7ah) && (40h=<AL=<5fh), NC, return;
  2804. ; CY;
  2805. ; }
  2806. CheckCodeRangeWdfe:
  2807. test cs:[CodeStat],Chab or WSung7
  2808. jnz NoWSung
  2809. cmp ah,0feh
  2810. ja @f
  2811. cmp ah,0a1h
  2812. jb @f
  2813. cmp al,0feh
  2814. ja @f
  2815. cmp al,0a1h
  2816. jb @f
  2817. ret
  2818. CheckCodeRangeWord:
  2819. test cs:[CodeStat],Chab or WSung7
  2820. jnz NoWSung
  2821. CheckCodeRangeWs:
  2822. cmp ah,0feh
  2823. ja @f
  2824. cmp ah,0a1h
  2825. jb @f
  2826. cmp al,0ffh
  2827. ja @f
  2828. cmp al,0a1h
  2829. jb @f
  2830. ret
  2831. @@:
  2832. stc
  2833. ret
  2834. NoWSung:
  2835. test cs:[CodeStat],CHab
  2836. jz NoCHab
  2837. CheckCodeRangeCh:
  2838. cmp ah,084h
  2839. jb @b
  2840. cmp ah,0d3h
  2841. ja @f
  2842. cmp al,041h
  2843. jb CheckFail
  2844. cmp al,07eh
  2845. jbe CheckSuc
  2846. cmp al,81h
  2847. jb CheckFail
  2848. cmp al,0feh
  2849. ja CheckFail
  2850. jmp CheckSuc
  2851. @@:
  2852. cmp al,031h
  2853. jb CheckFail
  2854. cmp al,0feh
  2855. ja CheckFail
  2856. cmp al,07eh
  2857. jbe @f
  2858. cmp al,091h
  2859. jb CheckFail
  2860. @@:
  2861. cmp ah,0d8h
  2862. jb CheckFail
  2863. cmp ah,0deh
  2864. jbe CheckSuc
  2865. cmp ah,0e0h
  2866. jb CheckFail
  2867. cmp ah,0f9h
  2868. jbe CheckSuc
  2869. CheckFail:
  2870. stc
  2871. ret
  2872. CheckSuc:
  2873. clc
  2874. ret
  2875. NoCHab: ; WanSung 7Bit Code
  2876. cmp ah,5fh
  2877. jb CheckFail
  2878. cmp ah,7eh
  2879. ja CheckFail
  2880. cmp ah,61h
  2881. jb @f
  2882. cmp ah,7ah
  2883. jbe WSung72
  2884. @@:
  2885. cmp al,7Eh
  2886. ja @f
  2887. cmp al,21h
  2888. jb @f
  2889. ret
  2890. WSung72:
  2891. cmp al,5Fh
  2892. ja @f
  2893. cmp al,40h
  2894. jb @f
  2895. ret
  2896. @@:
  2897. stc
  2898. ret
  2899. ;------------------------------------------------------------------------
  2900. ; << CheckCodeRange1st >>
  2901. ; FUNCTION = check code range for byte
  2902. ; INPUT : AL = Code
  2903. ; OUTPUT : AL = Code
  2904. ; : carry - NC ( success )
  2905. ; : - CY ( code range over )
  2906. ; PROTECT : AL,BX,DX,DS,ES
  2907. ;
  2908. ; CheckCodeRange1st(AL/AL,carry)
  2909. ; {
  2910. ; switch([CodeStat])
  2911. ; case WSung :
  2912. ; if (0a1h=<AL=<0feh), NC, break;
  2913. ; CY;
  2914. ; break;
  2915. ; case CHob :
  2916. ; if (84h=<AL=<0d3h), NC, break;
  2917. ; if (d9h=<AL=<0deh), NC, break;
  2918. ; if (e0h=<AL=<0f9h), NC, break;
  2919. ; CY;
  2920. ; break;
  2921. ; case WSung7 :
  2922. ; if (5fh=<AL=<7eh), NC, break;
  2923. ; CY;
  2924. ; }
  2925. CheckCodeRange1st:
  2926. test cs:[CodeStat],Chab or WSung7
  2927. jnz NotWSung1st
  2928. cmp al,0feh
  2929. ja CCFail
  2930. cmp al,0a1h
  2931. jb CCFail
  2932. ret
  2933. CCFail:
  2934. stc
  2935. ret
  2936. NotWSung1st:
  2937. test cs:[CodeStat],CHab
  2938. jz NotCHab
  2939. cmp al,0f9h
  2940. ja CCFail
  2941. cmp al,0e0h
  2942. jae CCSuc
  2943. cmp al,0deh
  2944. ja CCFail
  2945. cmp al,0d8h
  2946. jae CCSuc
  2947. cmp al,0d3h
  2948. ja CCFail
  2949. cmp al,084h
  2950. jb CCFail
  2951. CCSuc:
  2952. clc
  2953. ret
  2954. NotCHab: ; WanSung 7Bit Code
  2955. cmp al,7eh
  2956. ja CCFail
  2957. cmp al,5fh
  2958. jb CCFail
  2959. ret
  2960. ;------------------------------------------------------------------------
  2961. ; << ClearCursor >>, << ToggleCursor >>
  2962. ; FUNCTION = cursor clear/toggle
  2963. ; INPUT : none
  2964. ; OUTPUT : none
  2965. ; PROTECT : ALL
  2966. ; CursorCursor(-/-)
  2967. ; {
  2968. ; if (CursorStat] == CursorOn)
  2969. ; ToggleCursor(-/-)
  2970. ; save AX,BX,CX,DX,DI,ES;
  2971. ; switch([ModeId])
  2972. ; case 2 : ; TE mode 7, MGA
  2973. ; case 4 : ; TE mode 2/3, CGA
  2974. ; case 10 : ; mode 40/70
  2975. ; ToggleMonoCursor(-/-);
  2976. ; break;
  2977. ; case 6 : ; TE mode 7, EGA/VGA
  2978. ; case 8 : ; TE mode 2/3, EGA/VGA
  2979. ; ToggleColorCursor(-/-);
  2980. ; case 0 : ; �ѱ� card, TEXT mode 2/3
  2981. ; case 12 : ; mode 60/11/12, EGA/VGA
  2982. ; restore AX,BX,CX,DX,DI,ES;
  2983. ; }
  2984. ClearCursor:
  2985. test [CursorStat],CursorOn
  2986. jz ToggleCursorEnd
  2987. ToggleCursor:
  2988. test [ModeStat],EmuCursor
  2989. jz ToggleCursorEnd
  2990. @push ax,bx,cx,dx,di,es
  2991. pushf
  2992. cld
  2993. mov bl,[ModeId]
  2994. xor bh,bh
  2995. call [bx+ToggleCursorJmpTbl]
  2996. popf
  2997. @pop es,di,dx,cx,bx,ax
  2998. ToggleCursorEnd:
  2999. ToggleCursorHanCard:
  3000. ret
  3001. ToggleCursorJmpTbl Label Word
  3002. dw offset ToggleCursorHanCard
  3003. dw offset ToggleMonoCursor
  3004. dw offset ToggleMonoCursor
  3005. dw offset ToggleColorCursor
  3006. dw offset ToggleColorCursor
  3007. dw offset ToggleMonoCursor
  3008. dw offset ToggleCursorHanCard
  3009. ;------------------------------------------------------------------------
  3010. ; << ToggleMonoCursor >>
  3011. ; FUNCTION = mono cursor toggle
  3012. ; INPUT : none
  3013. ; OUTPUT : none
  3014. ; PROTECT : DS,SI
  3015. ; ToggleMonoCursor(-/-)
  3016. ToggleMonoCursor:
  3017. cli
  3018. mov cx,[rCurType] ; BIOS Cursor Type Information Read
  3019. cmp ch,20h ; Check Not Display Cursor Type
  3020. jae ToggleMonoCursorExit
  3021. and cx,0f0fh ; Get Low 4 Bits
  3022. sub cl,ch
  3023. jc ToggleMonoCursorExit
  3024. inc cl
  3025. mov dx,[OrgCurPos]
  3026. test [CursorStat],CursorOn
  3027. jnz @f
  3028. mov bl,[CurPage]
  3029. xor bh,bh
  3030. shl bx,1
  3031. mov dx,[bx+rCurPos]
  3032. mov [OrgCurPos],dx
  3033. @@:
  3034. cmp dl,80
  3035. jae ToggleMonoCursorExit
  3036. cmp dh,[MaxRows]
  3037. jae ToggleMonoCursorExit
  3038. les di,[GrpBufAddr]
  3039. mov ax,80
  3040. mul dh
  3041. shl ax,1
  3042. shl ax,1
  3043. xor dh,dh
  3044. add ax,dx
  3045. add di,ax ; 80 * 4 * Rows +Cols
  3046. shr ch,1
  3047. jnc @f
  3048. add di,2000h ; Next Scan Line=Scan Line Length Add
  3049. @@:
  3050. shr ch,1
  3051. jnc @f
  3052. add di,2000h*2 ; Next Scan Line
  3053. @@:
  3054. shr ch,1
  3055. jnc @f
  3056. add di,50h
  3057. @@:
  3058. shr ch,1
  3059. jnc @f
  3060. add di,50h*2
  3061. @@:
  3062. mov al,0ffh ; Mask Data
  3063. @@:
  3064. xor es:[di],al
  3065. add di,2000h
  3066. js ToggleMonoCursorAdjust
  3067. loop @b
  3068. MonoCursorExit:
  3069. xor [CursorStat],CursorOn
  3070. ToggleMonoCursorExit:
  3071. sti
  3072. ret
  3073. ToggleMonoCursorAdjust:
  3074. sub di,8000h-50h
  3075. loop @b
  3076. jmp MonoCursorExit
  3077. ;------------------------------------------------------------------------
  3078. ; << FullScroll >>
  3079. ; FUNCTION = full scroll
  3080. ; INPUT : BH = page #
  3081. ; OUTPUT : none
  3082. ; PROTECT : AX, BX, CX, DX, DS, ES
  3083. ; FullScroll(BH/-)
  3084. ; {
  3085. ; save AX,BX,CX,DX,ES,DS;
  3086. ; ES:DI = [CodeBuf1Addr];
  3087. ; DI = DI + ES:[rCrtStart];
  3088. ; FullScrollText(ES,DI/BL);
  3089. ; if (BH == [CurPage])
  3090. ; {
  3091. ; if ([ModeStat] == TextEmulation)
  3092. ; {
  3093. ; ES:DI = [CodeBuf2Addr];
  3094. ; FullScrollText(ES,DI/BL);
  3095. ; }
  3096. ; ES:DI = [GrpBufAddr];
  3097. ; switch([ModeId])
  3098. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  3099. ; break;
  3100. ; case 2 : ; TE mode 7, MGA
  3101. ; case 4 : ; TE mode 2/3, CGA
  3102. ; case 10 : ; mode 40/70
  3103. ; FullScrollMono([GrpBufAddr]/-);
  3104. ; break;
  3105. ; case 6 : ; TE mode 7, EGA/VGA
  3106. ; FullScrollColor([GrpBufAddr]/-);
  3107. ; break;
  3108. ; case 8 : ; TE mode 2/3, EGA/VGA
  3109. ; case 12 : ; mode 60/11/12, EGA/VGA
  3110. ; FullScrollColor([GrpBufAddr]/-);
  3111. ; }
  3112. ; restore AX,BX,CX,DX,DS,ES
  3113. ; }
  3114. FullScroll:
  3115. @push ax,bx,cx,dx,es,ds
  3116. mov ax,[rCrtStart]
  3117. les di,[CodeBuf1Addr]
  3118. add di,ax
  3119. call FullScrollText
  3120. cmp [CurPage],bh
  3121. jnz FullScrollEnd
  3122. test [ModeStat],TextEmulation
  3123. jz @f
  3124. les di,[CodeBuf2Addr]
  3125. call FullScrollText
  3126. @@:
  3127. call ClearCursor
  3128. mov al,[ModeId]
  3129. xor ah,ah
  3130. mov si,ax
  3131. les di,[GrpBufAddr]
  3132. call [si+FullScrollJmpTbl]
  3133. FullScrollEnd:
  3134. @pop ds,es,dx,cx,bx,ax
  3135. FullScrHanCardText:
  3136. ret
  3137. FullScrollJmpTbl Label Word
  3138. dw offset FullScrHanCardText
  3139. dw offset FullScrollMono
  3140. dw offset FullScrollMono
  3141. dw offset FullScrollColor
  3142. dw offset FullScrollColor
  3143. dw offset FullScrollMono
  3144. dw offset FullScrollColor
  3145. ;------------------------------------------------------------------------
  3146. ; << MakeHanAttr >>
  3147. ; FUNCTION = make hangeul character attribute
  3148. ; INPUT : BL = Attr
  3149. ; : DS:SI = source pattern
  3150. ; OUTPUT : BL = Attr
  3151. ; AL = Background Attr
  3152. ; PROTECT : ALL
  3153. ;
  3154. ; MakeHanAttr(BL,DS,SI/AL,BL)
  3155. ; BL register�� �������� background attr�� AL register�� setting
  3156. ; MGA/CGA/40/70 �� ������ pattern���� modify��
  3157. ; {
  3158. ; switch([ModeId])
  3159. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  3160. ; AL = BH shr 4;
  3161. ; break;
  3162. ; case 2 : ; TE mode 7, MGA
  3163. ; case 10 : ; mode 40/70
  3164. ; /* pattern modify = reverse,underline,none-display */
  3165. ; break;
  3166. ; case 4 : ; TE mode 2/3, CGA
  3167. ; /* pattern modify = reverse,none-display */
  3168. ; break;
  3169. ; case 6 : ; TE mode 7, EGA/VGA
  3170. ; AL = BH shr 4;
  3171. ; /* AL/BH attr�� modify */
  3172. ; /* pattern modify */
  3173. ; break;
  3174. ; case 8 : ; TE mode 2/3, EGA/VGA
  3175. ; AL = BH shr 4;
  3176. ; break;
  3177. ; case 12 : ; mode 60/11/12, EGA/VGA
  3178. ; }
  3179. MakeHanAttr:
  3180. push bx
  3181. mov bl,[ModeId]
  3182. xor bh,bh
  3183. jmp [bx+MakeHanAttrJmpTbl]
  3184. MakeHanAttrJmpTbl Label Word
  3185. dw offset MkHanAttrHanCardText
  3186. dw offset MkHanAttrMgaTE
  3187. dw offset MkHanAttrCgaTE
  3188. dw offset MkHanAttrEgaVgaTE7
  3189. dw offset MkHanAttrEgaVgaTE23
  3190. dw offset MkHanAttrMode40_70
  3191. dw offset MkHanAttrMode60_11_12
  3192. MkHanAttrHanCardText:
  3193. MkHanAttrEgaVgaTE23:
  3194. pop bx
  3195. mov bh,bl
  3196. shr bh,1
  3197. shr bh,1
  3198. shr bh,1
  3199. shr bh,1
  3200. mov al,bh
  3201. ret
  3202. MkHanAttrMgaTE:
  3203. MkHanAttrMode40_70:
  3204. pop bx
  3205. mov bh,bl
  3206. test bh,00001000b
  3207. jz @f
  3208. call MakeHanAttrHigh
  3209. @@:
  3210. test bh,01110111b
  3211. jz MakeHanAttrNonDisp
  3212. and bh,01110111b
  3213. cmp bh,70h
  3214. jz MakeHanAttrReverse
  3215. and bh,00000111b
  3216. cmp bh,1
  3217. jnz @f
  3218. or word ptr [si+30],-1
  3219. @@:
  3220. ret
  3221. MakeHanAttrReverse:
  3222. @push bx,cx,si
  3223. mov bx,2
  3224. mov cx,10h
  3225. @@:
  3226. not Word Ptr [si] ; 1
  3227. add si,bx
  3228. loop @b
  3229. @pop si,cx,bx
  3230. ret
  3231. MakeHanAttrNonDisp:
  3232. @push ax,cx,di,es
  3233. mov cx,10h
  3234. mov ax,ds
  3235. mov es,ax
  3236. mov di,si
  3237. xor ax,ax
  3238. rep stosw
  3239. @pop es,di,cx,ax
  3240. ret
  3241. MakeHanAttrHigh:
  3242. @push ax,bx,cx,si
  3243. mov cx,10h
  3244. mov bx,2
  3245. @@:
  3246. mov ax,[si]
  3247. shr al,1 ; High Byte
  3248. rcr ah,1 ; Low Byte
  3249. or [si],ax
  3250. add si,bx
  3251. loop @b
  3252. @pop si,cx,bx,ax
  3253. ret
  3254. MkHanAttrCgaTE:
  3255. pop bx
  3256. mov bh,bl
  3257. test bh,00001000b
  3258. jz @f
  3259. call MakeHanAttrHigh
  3260. @@:
  3261. test bh,01110111b
  3262. jz MakeHanAttrNonDisp
  3263. and bh,01110111b
  3264. cmp bh,70h
  3265. jz MakeHanAttrReverse
  3266. ret
  3267. MkHanAttrEgaVgaTE7:
  3268. pop bx
  3269. mov bh,0
  3270. test bl,01110111B
  3271. jz @f
  3272. mov bh,1
  3273. test bl,01111000B
  3274. jz @f
  3275. mov bh,bl
  3276. and bh,01111000B
  3277. cmp bh,00001000B
  3278. mov bh,4
  3279. jz @f
  3280. mov bh,10h
  3281. test bl,00000111B
  3282. jz @f
  3283. mov bh,11h
  3284. test bl,00001000B
  3285. jz @f
  3286. mov bh,40h
  3287. @@:
  3288. push bx
  3289. mov bh,bl
  3290. and bh,01110111B
  3291. cmp bh,00000001B
  3292. jnz @f
  3293. or Word Ptr [si+30],0FFFFh
  3294. @@:
  3295. pop bx
  3296. mov bl,bh
  3297. mov al,bh
  3298. shr al,1
  3299. shr al,1
  3300. shr al,1
  3301. shr al,1
  3302. ret
  3303. MkHanAttrMode60_11_12:
  3304. pop bx
  3305. xor al,al
  3306. ;MkNonDsiplay:
  3307. ; test bl,00001111b
  3308. ; jnz @f
  3309. ; @push bx,ax
  3310. ; mov ah,0fh
  3311. ; int 10h
  3312. ; and al,01111111b
  3313. ; cmp al,011h
  3314. ; @pop ax,bx
  3315. ; jnz @f
  3316. ; @push ax,cx,es,di
  3317. ; mov ax,ds
  3318. ; mov es,ax
  3319. ; mov di,si
  3320. ; mov cx,16
  3321. ; xor ax,ax
  3322. ; rep stosw
  3323. ; @pop di,es,cx,ax
  3324. ;@@:
  3325. ret
  3326. ;------------------------------------------------------------------------
  3327. ; << MakeEngAttr >>
  3328. ; FUNCTION = make english character attribute
  3329. ; INPUT : BL = Attr
  3330. ; : DS:SI = source pattern
  3331. ; OUTPUT : BL = Attr
  3332. ; AL = Background Attr
  3333. ; PROTECT : ALL
  3334. ;
  3335. ; MakeEngAttr(BL,DS,SI/AL,BL)
  3336. ; BL register�� �������� background attr�� AL register�� setting
  3337. ; MGA/CGA/40/70 �� ������ pattern���� modify��
  3338. ; {
  3339. ; switch([ModeId])
  3340. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  3341. ; AL = BH shr 4;
  3342. ; break;
  3343. ; case 2 : ; TE mode 7, MGA
  3344. ; case 10 : ; mode 40/70
  3345. ; /* pattern modify = reverse,underline,none-display */
  3346. ; break;
  3347. ; case 4 : ; TE mode 2/3, CGA
  3348. ; /* pattern modify = reverse,none-display */
  3349. ; break;
  3350. ; case 6 : ; TE mode 7, EGA/VGA
  3351. ; AL = BH shr 4;
  3352. ; /* AL/BH attr�� modify */
  3353. ; /* pattern modify */
  3354. ; break;
  3355. ; case 8 : ; TE mode 2/3, EGA/VGA
  3356. ; AL = BH shr 4;
  3357. ; break;
  3358. ; case 12 : ; mode 60/11/12, EGA/VGA
  3359. ; }
  3360. MakeEngAttr:
  3361. push bx
  3362. mov bl,[ModeId]
  3363. xor bh,bh
  3364. jmp [bx+MakeEngAttrJmpTbl]
  3365. MakeEngAttrJmpTbl Label Word
  3366. dw offset MkEngAttrHanCardText
  3367. dw offset MkEngAttrMgaTE
  3368. dw offset MkEngAttrCgaTE
  3369. dw offset MkEngAttrEgaVgaTE7
  3370. dw offset MkEngAttrEgaVgaTE23
  3371. dw offset MkEngAttrMode40_70
  3372. dw offset MkEngAttrMode60_11_12
  3373. MkEngAttrHanCardText:
  3374. MkEngAttrEgaVgaTE23:
  3375. pop bx
  3376. mov bh,bl
  3377. shr bh,1
  3378. shr bh,1
  3379. shr bh,1
  3380. shr bh,1
  3381. mov al,bh
  3382. ret
  3383. MkEngAttrMgaTE:
  3384. MkEngAttrMode40_70:
  3385. pop bx
  3386. mov bh,bl
  3387. test bh,00001000b
  3388. jz @f
  3389. call MakeEngAttrHigh
  3390. @@:
  3391. test bh,01110111b
  3392. jz MakeEngAttrNonDisp
  3393. and bh,01110111b
  3394. cmp bh,70h
  3395. jz MakeEngAttrReverse
  3396. and bh,00000111b
  3397. cmp bh,1
  3398. jnz @f
  3399. or byte ptr [si+15],-1
  3400. @@:
  3401. ret
  3402. MakeEngAttrReverse:
  3403. @push si,cx
  3404. mov cx,10h
  3405. @@:
  3406. not Byte Ptr [si]
  3407. inc si
  3408. loop @b
  3409. @pop cx,si
  3410. ret
  3411. MakeEngAttrNonDisp:
  3412. @push ax,cx,di,es
  3413. mov cx,08h
  3414. mov ax,ds
  3415. mov es,ax
  3416. mov di,si
  3417. xor ax,ax
  3418. rep stosw
  3419. @pop es,di,cx,ax
  3420. ret
  3421. MakeEngAttrHigh:
  3422. @push ax,bx,cx,si
  3423. mov cx,08h
  3424. mov bx,2
  3425. @@:
  3426. mov ax,[si]
  3427. shr al,1
  3428. shr ah,1
  3429. or [si],ax ; First & Second Byte
  3430. add si,bx
  3431. loop @b
  3432. @pop si,cx,bx,ax
  3433. ret
  3434. MkEngAttrCgaTE:
  3435. pop bx
  3436. mov bh,bl
  3437. test bh,00001000b
  3438. jz @f
  3439. call MakeEngAttrHigh
  3440. @@:
  3441. test bh,01110111b
  3442. jz MakeEngAttrNonDisp
  3443. and bh,01110111b
  3444. cmp bh,70h
  3445. jz MakeEngAttrReverse
  3446. ret
  3447. MkEngAttrEgaVgaTE7:
  3448. pop bx
  3449. mov bh,0
  3450. test bl,01110111B
  3451. jz @f
  3452. mov bh,1
  3453. test bl,01111000B
  3454. jz @f
  3455. mov bh,bl
  3456. and bh,01111000B
  3457. cmp bh,00001000B
  3458. mov bh,4
  3459. jz @f
  3460. mov bh,10h
  3461. test bl,00000111B
  3462. jz @f
  3463. mov bh,11h
  3464. test bl,00001000B
  3465. jz @f
  3466. mov bh,40h
  3467. @@:
  3468. push bx
  3469. mov bh,bl
  3470. and bh,01110111B
  3471. cmp bh,00000001B
  3472. jnz @f
  3473. or Word Ptr [si+15],0FFh
  3474. @@:
  3475. pop bx
  3476. mov bl,bh
  3477. mov al,bh
  3478. shr al,1
  3479. shr al,1
  3480. shr al,1
  3481. shr al,1
  3482. ret
  3483. MkEngAttrMode60_11_12:
  3484. pop bx
  3485. xor al,al
  3486. ; call MkNonDsiplay
  3487. ret
  3488. ;------------------------------------------------------------------------
  3489. ; << DispHangeul >>
  3490. ; FUNCTION = write hangeul char
  3491. ; INPUT : AL = char, BL = attr, BH = page, DX = cursor position
  3492. ; OUTPUT : none
  3493. ; PROTECT : BH, DX, DS, ES
  3494. ;
  3495. ; DispHangeul(AL,BL,BH/-)
  3496. ; {
  3497. ; Save BX,DX,ES,DS;
  3498. ; [HanStat] = [HanStat] && not Han1st;
  3499. ; ES:DI = [CodeBuf1Addr];
  3500. ; DI = DI + [OldTextPos1Addr];
  3501. ; AH = BL;
  3502. ; CL = [OldChar];
  3503. ; CH = [OldAttr];
  3504. ; XCHG AX,CX;
  3505. ; STOSW;
  3506. ; XCHG AX,CX;
  3507. ; STOSW;
  3508. ; if ([CurPage] == BH)
  3509. ; {
  3510. ; [CursorStat] = [CursorStat] && not CursorOn;
  3511. ; if ([ModeStat] == TextEmulation)
  3512. ; {
  3513. ; ES:DI = [CodeBuf2Addr];
  3514. ; DI = DI + [OldTextPos2Addr];
  3515. ; XCHG AX,CX;
  3516. ; STOSW;
  3517. ; XCHG AX,CX;
  3518. ; STOSW;
  3519. ; }
  3520. ; XCHG CH,CL;
  3521. ; CL = AL;
  3522. ; ES = CS;
  3523. ; DI = offset PatternBuffer;
  3524. ; GetPattern(CX,ES,DI/carry);
  3525. ; SI = DI;
  3526. ; AL = [ModeId];
  3527. ; AH = 0;
  3528. ; DI = AX;
  3529. ; ES:AX = [GrpBufAddr];
  3530. ; AX = AX + [OldGrpPosAddr];
  3531. ; switch([ModeId])
  3532. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  3533. ; break;
  3534. ; case 2 : ; TE mode 7, MGA
  3535. ; case 4 : ; TE mode 2/3, CGA
  3536. ; DispHanMono(BL,DS,SI,ES,AX/-);
  3537. ; break;
  3538. ; case 6 : ; TE mode 7, EGA/VGA
  3539. ; case 8 : ; TE mode 2/3, EGA/VGA
  3540. ; DispHanColor(BL,DS,SI,ES,AX/-);
  3541. ; break;
  3542. ; case 10 : ; mode 40/70
  3543. ; DispHanMonoXor(BL,DS,SI,ES,AX/-);
  3544. ; break;
  3545. ; case 12 : ; mode 60/11/12, EGA/VGA
  3546. ; DispHanColorXor(BL,DS,SI,ES,AX/-);
  3547. ; break;
  3548. ; }
  3549. ; restore BX,DX,ES,DS;
  3550. ; }
  3551. DispHangeul:
  3552. @push bx,dx,es,ds
  3553. and [HanStat],not Han1st
  3554. cmp dl,80
  3555. jae DispHangeulExit
  3556. cmp dh,[MaxRows]
  3557. jae DispHangeulExit
  3558. les di,[CodeBuf1Addr]
  3559. add di,[OldTextPos1Addr]
  3560. mov ah,bl
  3561. mov cl,[OldChar]
  3562. mov ch,[OldAttr]
  3563. xchg ax,cx
  3564. stosw
  3565. xchg ax,cx
  3566. stosw
  3567. cmp [CurPage],bh
  3568. jnz DispHangeulExit
  3569. cmp [ModeId],0
  3570. jz DispHangeulExit
  3571. and [CursorStat],not CursorOn
  3572. test [ModeStat],TextEmulation
  3573. jz @f
  3574. les di,[CodeBuf2Addr]
  3575. add di,[OldTextPos2Addr]
  3576. xchg ax,cx
  3577. stosw
  3578. xchg ax,cx
  3579. stosw
  3580. @@:
  3581. xchg ch,cl
  3582. mov cl,al
  3583. mov ax,cs
  3584. mov es,ax
  3585. mov di,offset PatternBuf
  3586. call GetPattern
  3587. mov si,di
  3588. mov al,[ModeId]
  3589. xor ah,ah
  3590. mov di,ax
  3591. les ax,[GrpBufAddr]
  3592. add ax,[OldGrpPosAddr]
  3593. call [di+DispHangeulJmpTbl]
  3594. DispHangeulExit:
  3595. @pop ds,es,dx,bx
  3596. DispHanHanCardText:
  3597. ret
  3598. DispHangeulJmpTbl Label Word
  3599. dw offset DispHanHanCardText
  3600. dw offset DispHanMono
  3601. dw offset DispHanMono
  3602. dw offset DispHanColor
  3603. dw offset DispHanColor
  3604. dw offset DispHanMonoXor
  3605. dw offset DispHanColorXor
  3606. ;------------------------------------------------------------------------
  3607. ; << DispEnglishNew >>
  3608. ; FUNCTION = write english char
  3609. ; INPUT : AL = char, BL = attr, BH = page, CX = counter, DX = cursor position
  3610. ; OUTPUT : none
  3611. ; PROTECT : BH, DX, DS, ES
  3612. ;
  3613. ; DispEnglishNew(AL,BL,BH,CX/-)
  3614. ; {
  3615. ; Save BX,DX,ES,DS;
  3616. ; SI = 80*25;
  3617. ; if ([MaxRows] == 30), SI = 80*30;
  3618. ; SI = SI - [TextPos1Addr]/2;
  3619. ; if (CX > SI), CX = SI;
  3620. ; [HanStat] = [HanStat] && not Han1st;
  3621. ; ES:DI = [CodeBuf1Addr];
  3622. ; DI = DI + [TextPos1Addr];
  3623. ; SI = CX;
  3624. ; AH = BL;
  3625. ; REP STOSW;
  3626. ; if ([CurPage] == BH)
  3627. ; {
  3628. ; [CursorStat] = [CursorStat] && not CursorOn;
  3629. ; if ([ModeStat] == TextEmulation)
  3630. ; {
  3631. ; ES:DI = [CodeBuf2Addr];
  3632. ; DI = DI + [TextPos2Addr];
  3633. ; CX = SI;
  3634. ; REP STOSW;
  3635. ; }
  3636. ; ES = CS;
  3637. ; DI = offset PatternBuffer;
  3638. ; CL = AL;
  3639. ; GetPatternEng(CL,ES,DI/carry);
  3640. ; CX = SI;
  3641. ; SI = DI;
  3642. ; AL = [ModeId];
  3643. ; AH = 0;
  3644. ; DI = AX;
  3645. ; ES:AX = [GrpBufAddr];
  3646. ; AX = AX + [GrpPosAddr];
  3647. ; switch([ModeId])
  3648. ; case 0 : ; �ѱ� card, TEXT mode 2/3/7
  3649. ; break;
  3650. ; case 2 : ; TE mode 7, MGA
  3651. ; case 4 : ; TE mode 2/3, CGA
  3652. ; DispEngMonoMulti(BL,DS,SI,ES,AX/-);
  3653. ; break;
  3654. ; case 6 : ; TE mode 7, EGA/VGA
  3655. ; case 8 : ; TE mode 2/3, EGA/VGA
  3656. ; DispEngColorMulti(BL,DS,SI,ES,AX/-);
  3657. ; break;
  3658. ; case 10 : ; mode 40/70
  3659. ; DispEngMonoXorMulti(BL,DS,SI,ES,AX/-);
  3660. ; break;
  3661. ; case 12 : ; mode 60/11/12, EGA/VGA
  3662. ; DispEngColorXorMulti(BL,DS,SI,ES,AX/-);
  3663. ; break;
  3664. ; }
  3665. ; restore BX,DX,ES,DS;
  3666. ; }
  3667. DispEnglishExitj:
  3668. jmp DispEnglishExit
  3669. DispEnglishNew:
  3670. @push bx,dx,es,ds
  3671. cmp dl,80
  3672. jae DispEnglishExitj
  3673. cmp dh,[MaxRows]
  3674. jae DispEnglishExit
  3675. mov si,80*25
  3676. cmp [MaxRows],25
  3677. jbe @f
  3678. mov si,80*30
  3679. @@:
  3680. mov di,[TextPos1Addr]
  3681. shr di,1
  3682. sub si,di
  3683. cmp cx,si
  3684. jbe @f
  3685. mov cx,si
  3686. @@:
  3687. and [HanStat],not Han1st
  3688. les di,[CodeBuf1Addr]
  3689. add di,[TextPos1Addr]
  3690. mov si,cx
  3691. mov ah,bl
  3692. rep stosw
  3693. cmp [CurPage],bh
  3694. jnz DispEnglishExit
  3695. cmp [ModeId],0
  3696. jz DispEnglishExit
  3697. and [CursorStat],not CursorOn
  3698. test [ModeStat],TextEmulation
  3699. jz @f
  3700. les di,[CodeBuf2Addr]
  3701. add di,[TextPos2Addr]
  3702. mov cx,si
  3703. rep stosw
  3704. @@:
  3705. mov di,cs
  3706. mov es,di
  3707. mov di,offset PatternBuf
  3708. mov cl,al
  3709. call GetPatternEng
  3710. mov cx,si
  3711. mov si,di
  3712. mov al,[ModeId]
  3713. xor ah,ah
  3714. mov di,ax
  3715. les ax,[GrpBufAddr]
  3716. add ax,[GrpPosAddr]
  3717. call [di+DispEnglishNewJmpTbl]
  3718. DispEnglishExit:
  3719. @pop ds,es,dx,bx
  3720. DispEngHanCardText:
  3721. ret
  3722. DispEnglishNewJmpTbl Label Word
  3723. dw offset DispEngHanCardText
  3724. dw offset DispEngMonoMulti
  3725. dw offset DispEngMonoMulti
  3726. dw offset DispEngColorMulti
  3727. dw offset DispEngColorMulti
  3728. dw offset DispEngMonoXorMulti
  3729. dw offset DispEngColorXorMulti
  3730. ;------------------------------------------------------------------------
  3731. ; << DispEnglishOld >>
  3732. ; FUNCTION = write english char
  3733. ; INPUT : none
  3734. ; OUTPUT : none
  3735. ; PROTECT : AX, BX, CX, DX, DS, ES
  3736. ;
  3737. ; DispEnglishOld(-/-)
  3738. ; {
  3739. ; /* save AL,BL,BH,CX,DX */
  3740. ; /* xchg [TextPos1Addr],[TextPos2Addr],[GrpPosAddr] to old */
  3741. ; /* get [OldChar],[OldPage],[OldAttr],[OldCounter] */
  3742. ; DispEnglishNew(AL,BL,BH,CX/-);
  3743. ; /* restore AL,BL,BH,CX,DX */
  3744. ; /* xchg [TextPos1Addr],[TextPos2Addr],[GrpPosAddr] to old */
  3745. ; }
  3746. DispEnglishOld:
  3747. @push ax,bx,cx,dx
  3748. push word ptr [CursorStat]
  3749. mov ax,[OldTextPos1Addr]
  3750. xchg [TextPos1Addr],ax
  3751. mov [OldTextPos1Addr],ax
  3752. mov ax,[OldTextPos2Addr]
  3753. xchg [TextPos2Addr],ax
  3754. mov [OldTextPos2Addr],ax
  3755. mov ax,[OldGrpPosAddr]
  3756. xchg [GrpPosAddr],ax
  3757. mov [OldGrpPosAddr],ax
  3758. mov al,[OldChar]
  3759. mov bl,[OldAttr]
  3760. mov bh,[OldPage]
  3761. mov cx,[OldCounter]
  3762. mov dx,[OldCurPos]
  3763. call DispEnglishNew
  3764. mov ax,[OldTextPos1Addr]
  3765. xchg [TextPos1Addr],ax
  3766. mov [OldTextPos1Addr],ax
  3767. mov ax,[OldTextPos2Addr]
  3768. xchg [TextPos2Addr],ax
  3769. mov [OldTextPos2Addr],ax
  3770. mov ax,[OldGrpPosAddr]
  3771. xchg [GrpPosAddr],ax
  3772. mov [OldGrpPosAddr],ax
  3773. pop ax
  3774. mov [CursorStat],al
  3775. @pop dx,cx,bx,ax
  3776. ret
  3777. ;=======================================================================
  3778. ; << GetPattern >>
  3779. ; FUNCTION = get hangeul pattern
  3780. ; INPUT : CX = code, ES:DI = pattern buffer
  3781. ; OUTPUT : carry(if error)
  3782. ; PROTECT : ALL
  3783. ;
  3784. ; GetPattern(CX,ES,DI/carry)
  3785. ; {
  3786. ; GetPattern(CX,ES,DI/carry);
  3787. ; }
  3788. GetPattern:
  3789. @push ax,bx,cx,dx,si,di,ds,es
  3790. mov ax,cs
  3791. mov ds,ax
  3792. mov ax,cx
  3793. ; UDC
  3794. test [CodeStat],WSung7
  3795. jnz GetHanPat
  3796. test [CodeStat],Chab
  3797. jz @f
  3798. cmp ah,0d8h
  3799. jnz GetHanPat
  3800. call ChgCh2Ks
  3801. mov cx,ax
  3802. @@:
  3803. call UdcRange
  3804. jc GetHanPat
  3805. test [HjStat],UdcArea
  3806. jz GetPatternErr
  3807. call [GetUdc1st]
  3808. jmp short GetPatternEnd
  3809. GetHanPat:
  3810. call CheckCodeRangeWdfe
  3811. jc GetPatternErr
  3812. test [CodeStat],WSung7
  3813. jz @f
  3814. call ChgCh72Ks
  3815. jc GetPatternErr
  3816. @@:
  3817. test [CodeStat],Chab
  3818. jz @f
  3819. test [CodeStat],InstPatGen
  3820. jz GetHanPatCode
  3821. cmp ah,0d3h
  3822. ja GetHanPatCode
  3823. call [PatGenAddr]
  3824. jc GetPatternErr
  3825. jmp short GetPatternEnd
  3826. GetHanPatCode:
  3827. call ChgCh2Ks
  3828. jc GetPatternErr
  3829. @@:
  3830. mov cx,ax
  3831. test [CodeStat],InstPatGen
  3832. jz GetPatHanCard
  3833. cmp ah,0a4h
  3834. jne CheckHangeul
  3835. cmp al,0a1h
  3836. jb CheckHangeul
  3837. cmp al,0d3h
  3838. jbe @f
  3839. CheckHangeul:
  3840. cmp ah,0b0h
  3841. jb GetPatHanCard
  3842. cmp ah,0c8h
  3843. ja GetPatHanCard
  3844. @@:
  3845. call [PatGenAddr]
  3846. jc GetPatternErr
  3847. jmp short GetPatternEnd
  3848. GetPatHanCard:
  3849. call [GetHan1st]
  3850. jc GetPatternErr
  3851. GetPatternEnd:
  3852. clc
  3853. jmp short @f
  3854. GetPatternErr:
  3855. mov si,offset ErrHanFont
  3856. mov cx,16*2
  3857. rep movsb
  3858. stc
  3859. @@:
  3860. @pop es,ds,di,si,dx,cx,bx,ax
  3861. ret
  3862. UdcRange:
  3863. cmp ah,0c9h
  3864. jz @f
  3865. cmp ah,0feh
  3866. jnz UdcRangeErr
  3867. @@:
  3868. cmp al,0a1h
  3869. jb UdcRangeErr
  3870. cmp al,0feh
  3871. ja UdcRangeErr
  3872. clc
  3873. ret
  3874. UdcRangeErr:
  3875. stc
  3876. ret
  3877. ErrHanFont dw 0fe7fh, 240h, 240h, 240h, 240h, 240h, 240h, 240h
  3878. dw 240h, 240h, 240h, 240h, 240h, 240h, 240h, 0fe7fh
  3879. ;------------------------------------------------------------------------
  3880. ; << PutPattern >>
  3881. ; FUNCTION = put hangeul pattern
  3882. ; INPUT : CX = code, DS:SI = pattern buffer
  3883. ; OUTPUT : carry(if error)
  3884. ; PROTECT : ALL
  3885. ;
  3886. ; PutPattern(CX,DS,SI/carry)
  3887. ;
  3888. PutPattern:
  3889. @push ax,bx,cx,dx,si,di,ds,es
  3890. mov ax,cx
  3891. test cs:[HjStat],UdcArea
  3892. jz PutPatternErr
  3893. test cs:[CodeStat],Chab
  3894. jz @f
  3895. call ChgCh2Ks
  3896. mov cx,ax
  3897. @@:
  3898. call UdcRange
  3899. jc PutPatternErr
  3900. push ax
  3901. mov dx,3c4h ; sequence index register
  3902. mov al,1
  3903. out dx,al
  3904. inc dl
  3905. in al,dx
  3906. or al,20h ; disable screen
  3907. out dx,al
  3908. pop ax
  3909. mov cx,ax
  3910. push cx
  3911. push si
  3912. push ds
  3913. call cs:[PutUdc1st]
  3914. pop ds
  3915. pop si
  3916. pop cx
  3917. test cs:[Card1st],DualMnt
  3918. jz @f
  3919. call cs:[PutUdc2nd]
  3920. @@:
  3921. mov dx,3c4h ; sequence index register
  3922. mov al,1
  3923. out dx,al
  3924. inc dl
  3925. in al,dx
  3926. and al,not 20h ; enable screen
  3927. out dx,al
  3928. clc
  3929. jmp short @f
  3930. PutPatternErr:
  3931. stc
  3932. @@:
  3933. @pop es,ds,di,si,dx,cx,bx,ax
  3934. ret
  3935. ;------------------------------------------------------------------------
  3936. ; << GetPatternEng >>
  3937. ; FUNCTION = get english pattern
  3938. ; INPUT : CL = code, ES:DI = pattern buffer
  3939. ; OUTPUT : carry(if error)
  3940. ; PROTECT : ALL
  3941. ;
  3942. ; GetPatternEng(CL,ES,DI/carry)
  3943. ;
  3944. GetPatternEng:
  3945. @push ax,cx,di,si,ds
  3946. mov ax,cs
  3947. mov ds,ax
  3948. xor ch,ch
  3949. shl cx,1
  3950. shl cx,1
  3951. shl cx,1
  3952. shl cx,1
  3953. mov si,cx
  3954. add si,offset EngFont
  3955. mov cx,16
  3956. rep movsb
  3957. GetPatEngEnd:
  3958. @pop ds,si,di,cx,ax
  3959. ret
  3960. public HanCardSet, HanCardReset, pHanCardReset
  3961. ;------------------------------------------------------------------------
  3962. ; << HanCardSet >>
  3963. ; FUNCTION = set active hangeul card
  3964. ; INPUT : none
  3965. ; OUTPUT : none
  3966. ; PROTECT : ALL
  3967. ;
  3968. ; HanCardSet(-/-)
  3969. ; {
  3970. ; if (CS:[Card1st] == HanCard)
  3971. ; {
  3972. ; save AX,DX;
  3973. ; /* call CS:[HanOn1st];
  3974. ; restore AX,DX;
  3975. ; }
  3976. ; }
  3977. ;
  3978. HanCardSet:
  3979. test cs:[Card1st],HanCard
  3980. jz HanCardSetEnd
  3981. test cs:[CodeStat],HangeulMode
  3982. jz HanCardSetEnd
  3983. if KseVga
  3984. test cs:[KseCard],00000001b
  3985. jz @f
  3986. test cs:[CodeStat],Chab or WSung7
  3987. jnz HanCardSetEnd
  3988. test cs:[ModeStat],GrpMode
  3989. jnz HanCardSetEnd
  3990. @@:
  3991. endif ; if KseVga
  3992. @push ax,dx
  3993. call cs:[HanOn1st]
  3994. @pop dx,ax
  3995. HanCardSetEnd:
  3996. ret
  3997. ;------------------------------------------------------------------------
  3998. ; << HanCardReset >>
  3999. ; FUNCTION = reset active hangeul card
  4000. ; INPUT : none
  4001. ; OUTPUT : none
  4002. ; PROTECT : ALL
  4003. ;
  4004. ; HanCardReset(-/-)
  4005. ; {
  4006. ; if (CS:[Card1st] == HanCard)
  4007. ; {
  4008. ; save AX,DX;
  4009. ; /* call CS:[HanOff1st];
  4010. ; restore AX,DX;
  4011. ; }
  4012. ; }
  4013. ;
  4014. HanCardReset:
  4015. test cs:[Card1st],HanCard
  4016. jz @f
  4017. @push ax,dx
  4018. call cs:[HanOff1st]
  4019. @pop dx,ax
  4020. @@:
  4021. ret
  4022. ;------------------------------------------------------------------------
  4023. ; << pHanCardReset >>
  4024. ; FUNCTION = reset inactive hangeul card
  4025. ; INPUT : none
  4026. ; OUTPUT : none
  4027. ; PROTECT : ALL
  4028. ;
  4029. ; pHanCardReset(-/-)
  4030. ; {
  4031. ; if (CS:[Card2nd] == HanCard)
  4032. ; {
  4033. ; save AX,DX;
  4034. ; /* call CS:[HanOff2nd];
  4035. ; restore AX,DX;
  4036. ; }
  4037. ; }
  4038. ;
  4039. pHanCardReset:
  4040. test cs:[Card2nd],DualMnt
  4041. jz @f
  4042. test cs:[Card2nd],HanCard
  4043. jz @f
  4044. @push ax,dx
  4045. call cs:[HanOff2nd]
  4046. @pop dx,ax
  4047. @@:
  4048. ret
  4049. ;=======================================================================
  4050. public GetFontHanExt, GetFontUdcExt, PutFontUdcExt
  4051. GetFontUdcExt:
  4052. xor ax,ax
  4053. cmp ch,0c9h
  4054. jz @f
  4055. mov al,94
  4056. @@:
  4057. xor ch,ch
  4058. sub cl,0a1h
  4059. add cx,ax
  4060. mov al,32
  4061. mul cx
  4062. add ax,[UdcAddr]
  4063. adc dl,[UdcAddrH]
  4064. mov bx,32/2
  4065. jmp short GetFontExtDo
  4066. GetFontHanExtErr:
  4067. stc
  4068. ret
  4069. GetFontHanExt:
  4070. cmp ch,0adh
  4071. jb @f
  4072. cmp ch,0b0h
  4073. jb GetFontHanExtErr
  4074. sub ch,29
  4075. @@:
  4076. sub cx,0a1a1h
  4077. mov al,94
  4078. mul ch
  4079. xor ch,ch
  4080. add cx,ax
  4081. mov ax,32
  4082. mul cx
  4083. add ax,[HanAddr]
  4084. adc dl,[HanAddrH]
  4085. mov bx,32/2
  4086. GetFontExtDo:
  4087. mov si,offset GdtDataTbl
  4088. mov [si+GdtSL],ax
  4089. mov [si+GdtSH],dl
  4090. mov dx,es
  4091. mov cl,4
  4092. shr dh,cl
  4093. mov ax,es
  4094. shl ax,cl
  4095. add ax,di
  4096. adc dh,0
  4097. mov [si+GdtDL],ax
  4098. mov [si+GdtDH],dh
  4099. GetFontExtCall:
  4100. mov ax,cs
  4101. mov es,ax
  4102. mov cx,bx
  4103. mov ah,87h
  4104. int 15h
  4105. ret
  4106. PutFontUdcExt:
  4107. xor ax,ax
  4108. cmp ch,0c9h
  4109. jz @f
  4110. mov al,94
  4111. @@:
  4112. xor ch,ch
  4113. sub cl,0a1h
  4114. add cx,ax
  4115. mov al,32
  4116. mul cx
  4117. add ax,cs:[UdcAddr]
  4118. adc dl,cs:[UdcAddrH]
  4119. mov bx,32/2
  4120. mov di,offset GdtDataTbl
  4121. mov cs:[di+GdtDL],ax
  4122. mov cs:[di+GdtDH],dl
  4123. mov dx,ds
  4124. mov cl,4
  4125. shr dh,cl
  4126. mov ax,ds
  4127. shl ax,cl
  4128. add ax,si
  4129. adc dh,0
  4130. mov cs:[di+GdtSL],ax
  4131. mov cs:[di+GdtSH],dh
  4132. mov si,di
  4133. jmp GetFontExtCall
  4134. public Int15Srv, GdtDataTbl
  4135. Int15Srv:
  4136. pushf
  4137. cmp ah,88H ; extended memory size determine?
  4138. je @f
  4139. popf
  4140. jmp cs:[OldInt15]
  4141. @@:
  4142. popf
  4143. mov ax,cs:[MaxMemSize]
  4144. iret
  4145. GdtDataTbl label word
  4146. db 16 dup(?) ; 00 - 0f
  4147. dw -1 ; 10 - 11
  4148. db 3 dup(?) ; 12 - 14
  4149. db 93h ; 15
  4150. db 2 dup(?) ; 16 - 17
  4151. dw -1 ; 18 - 19
  4152. db 3 dup(?) ; 1a - 1c
  4153. db 93h ; 1d
  4154. db 2 dup(?) ; 1e - 1f
  4155. db 16 dup(?) ; 20 - 2f
  4156. ;----------------------------------------
  4157. public GetFontHanEms, GetFontUdcEms, PutFontUdcEms
  4158. GetFontUdcEms:
  4159. xor ax,ax
  4160. cmp ch,0c9h
  4161. jz @f
  4162. mov al,94
  4163. @@:
  4164. xor ch,ch
  4165. sub cl,0a1h
  4166. add cx,ax
  4167. mov al,32
  4168. mul cx
  4169. add ax,[UdcAddr]
  4170. adc dl,0
  4171. shl dl,1
  4172. shl dl,1
  4173. add dl,[UdcAddrH]
  4174. mov cx,32
  4175. jmp short GetFontEmsDo
  4176. GetFontHanEms:
  4177. cmp ch,0adh
  4178. jb @f
  4179. cmp ch,0b0h
  4180. jb GetFontHanEmsErr
  4181. sub ch,29
  4182. @@:
  4183. sub cx,0a1a1h
  4184. mov al,94
  4185. mul ch
  4186. xor ch,ch
  4187. add cx,ax
  4188. mov ax,32
  4189. mul cx
  4190. add ax,[HanAddr]
  4191. adc dl,0
  4192. shl dl,1
  4193. shl dl,1
  4194. add dl,[HanAddrH]
  4195. mov cx,32
  4196. GetFontEmsDo:
  4197. cmp ax,16384
  4198. jb @f
  4199. sub ax,16384
  4200. inc dl
  4201. jmp short GetFontEmsDo
  4202. @@:
  4203. mov si,ax
  4204. mov bl,dl
  4205. xor bh,bh
  4206. mov [CurEmsPage],bx
  4207. mov ds,[EmsSeg]
  4208. mov dx,cs:[EmsHandle]
  4209. mov ah,47h
  4210. int 67h
  4211. jmp short SetEmsPage
  4212. @@:
  4213. cmp si,16384
  4214. jae NextEmsPage
  4215. movsb
  4216. dec cx
  4217. jz GetFontEmsDoEnd
  4218. jmp short @b
  4219. NextEmsPage:
  4220. xor si,si
  4221. mov bx,cs:[CurEmsPage]
  4222. inc bx
  4223. SetEmsPage:
  4224. mov ax,4400h ; set page
  4225. int 67h
  4226. or ah,ah
  4227. jz @b
  4228. mov ah,48h
  4229. int 67h
  4230. GetFontHanEmsErr:
  4231. stc
  4232. ret
  4233. GetFontEmsDoEnd:
  4234. mov ah,48h
  4235. int 67h
  4236. clc
  4237. ret
  4238. PutFontUdcEms:
  4239. xor ax,ax
  4240. cmp ch,0c9h
  4241. jz @f
  4242. mov al,94
  4243. @@:
  4244. xor ch,ch
  4245. sub cl,0a1h
  4246. add cx,ax
  4247. mov al,32
  4248. mul cx
  4249. add ax,cs:[UdcAddr]
  4250. adc dl,0
  4251. shl dl,1
  4252. shl dl,1
  4253. add dl,cs:[UdcAddrH]
  4254. mov cx,32
  4255. @@:
  4256. cmp ax,16384
  4257. jb @f
  4258. sub ax,16384
  4259. inc dl
  4260. jmp short @b
  4261. @@:
  4262. mov di,ax
  4263. mov bl,dl
  4264. xor bh,bh
  4265. mov cs:[CurEmsPage],bx
  4266. mov es,cs:[EmsSeg]
  4267. mov dx,cs:[EmsHandle]
  4268. mov ah,47h
  4269. int 67h
  4270. jmp short SetPutEmsPage
  4271. @@:
  4272. cmp di,16384
  4273. jae NextPutEmsPage
  4274. movsb
  4275. dec cx
  4276. jz PutFontEmsDoEnd
  4277. jmp short @b
  4278. NextPutEmsPage:
  4279. xor di,di
  4280. mov bx,cs:[CurEmsPage]
  4281. inc bx
  4282. SetPutEmsPage:
  4283. mov ax,4400h ; set page
  4284. int 67h
  4285. or ah,ah
  4286. jz @b
  4287. mov ah,48h
  4288. int 67h
  4289. stc
  4290. ret
  4291. PutFontEmsDoEnd:
  4292. mov ah,48h
  4293. int 67h
  4294. clc
  4295. ret
  4296. ;----------------------------------------
  4297. public GetFontHanReal, GetFontUdcReal, PutFontUdcReal
  4298. GetFontUdcReal:
  4299. xor ax,ax
  4300. cmp ch,0c9h
  4301. jz @f
  4302. mov al,94
  4303. @@:
  4304. xor ch,ch
  4305. sub cl,0a1h
  4306. add al,cl
  4307. mov cl,5
  4308. shl ax,cl
  4309. add ax,[UdcAddr]
  4310. mov si,ax
  4311. and si,0fh
  4312. mov cl,4
  4313. shr ax,cl
  4314. mov cx,cs
  4315. add ax,cx
  4316. mov ds,ax
  4317. mov cx,32/2
  4318. rep movsw
  4319. clc
  4320. @@:
  4321. ret
  4322. GetFontHanReal:
  4323. cmp ch,0adh
  4324. jb @f
  4325. cmp ch,0b0h
  4326. jb @b ; set carry
  4327. sub ch,29
  4328. @@:
  4329. sub cx,0a1a1h
  4330. mov al,94
  4331. mul ch
  4332. xor ch,ch
  4333. add ax,cx
  4334. mov cx,32
  4335. mul cx
  4336. add ax,[HanAddr]
  4337. adc dl,0
  4338. mov si,ax
  4339. and si,0fh
  4340. mov cl,4
  4341. shr ax,cl
  4342. shl dl,cl
  4343. or ah,dl
  4344. mov cx,cs
  4345. add ax,cx
  4346. mov ds,ax
  4347. mov cx,32/2
  4348. rep movsw
  4349. clc
  4350. ret
  4351. PutFontUdcReal:
  4352. xor ax,ax
  4353. cmp ch,0c9h
  4354. jz @f
  4355. mov al,94
  4356. @@:
  4357. xor ch,ch
  4358. sub cl,0a1h
  4359. add al,cl
  4360. mov cl,5
  4361. shl ax,cl
  4362. add ax,cs:[UdcAddr]
  4363. mov di,ax
  4364. and di,0fh
  4365. mov cl,4
  4366. shr ax,cl
  4367. mov cx,cs
  4368. add ax,cx
  4369. mov es,ax
  4370. mov cx,32/2
  4371. rep movsw
  4372. clc
  4373. ret
  4374. ;=======================================================================
  4375. ; MGA/CGA video card porting area
  4376. ;
  4377. ; MGA card
  4378. public HanOnMga, HanOffMga, GetFontMga, PutFontMga
  4379. GetFontMga:
  4380. mov si,0b800h-2
  4381. mov ds,si
  4382. sub si,si
  4383. cli ; for proper operation
  4384. mov ax,cx
  4385. mov dx,3b6H ; point to 3b6 port
  4386. out dx,ax ; out high byte
  4387. mov cx,16 ; repeat word counter
  4388. rep movsw ; move pattern into es:di
  4389. inc dl
  4390. out dx,al
  4391. sti
  4392. clc
  4393. ret
  4394. PutFontMga:
  4395. mov ax,cx ; save codes
  4396. mov dx,3b6H ; point to 3b6 port
  4397. cli
  4398. out dx,ax
  4399. mov di,0b800h-2
  4400. mov es,di
  4401. xor di,di
  4402. mov cx,16
  4403. rep movsw ; move pattern to put_through RAM
  4404. inc dl
  4405. out dx,al
  4406. sti
  4407. clc
  4408. ret
  4409. HanOnMga:
  4410. mov dx,3bdH ; point to 3bd port
  4411. mov al,00000001B ; data to output
  4412. out dx,al
  4413. ret
  4414. HanOffMga:
  4415. mov dx,3bdH ; point to 3bd port
  4416. xor al,al ; data to output
  4417. out dx,al
  4418. ret
  4419. ;
  4420. ; CGA card
  4421. public HanOnCga, HanOffCga, GetFontCga, PutFontCga
  4422. GetFontCga:
  4423. mov si,0b800h
  4424. mov ds,si
  4425. UDC_Check:
  4426. cmp ch,0c9h ; First UDC Area ?
  4427. je @f
  4428. cmp ch,0feh ; Second UDC Area ?
  4429. je @f
  4430. jmp Short GetText
  4431. @@:
  4432. sub ax,ax ; Calc. Ref Address
  4433. mov al,cl ; get code
  4434. sub al,80H
  4435. and ch,00010000B
  4436. mov cl,5
  4437. shl ax,cl ; * 32
  4438. or ah,ch
  4439. Mov Si,Ax ; Set Ref. Address
  4440. Mov AH,81h ; Select Bank 1
  4441. Jmp Short GetGraph
  4442. GetText:
  4443. sub cl,80H
  4444. mov ax,cx ; get code
  4445. and ah,01111111b
  4446. shr ah,1 ; get bank #
  4447. shr ah,1
  4448. shr ah,1
  4449. or ah,10000000B
  4450. and ch,7
  4451. sub cl,cl
  4452. shr cx,1
  4453. add cl,al
  4454. mov si,cx
  4455. mov cl,5 ; AH = Bank Select Value
  4456. shl si,cl ; Si = get relative addr within a bank
  4457. GetGraph:
  4458. xor cx,cx
  4459. mov dx,3daH ; point to 3da port
  4460. @@:
  4461. dec cx
  4462. jz @f
  4463. in al,dx
  4464. test al,00001000B ; dots on?
  4465. jz @b
  4466. @@:
  4467. cli
  4468. sub dl,4 ; point to 3d6 port
  4469. mov al,ah ; select bank #
  4470. out dx,al
  4471. mov cx,16
  4472. rep movsw
  4473. mov al,11000000B ; select bank 0 & enable Hangeul mode
  4474. out dx,al
  4475. sti ; enable interrupts
  4476. clc
  4477. ret
  4478. PutFontCga:
  4479. sub ax,ax
  4480. mov al,cl ; get code
  4481. sub al,80H
  4482. and ch,00010000B
  4483. mov cl,5
  4484. shl ax,cl ; * 32
  4485. or ah,ch
  4486. mov di,0b800h
  4487. mov es,di
  4488. mov di,ax ; FontWinSeg:(0 or 1000H)+(cl-80H)*32
  4489. mov dx,3daH ; point to 3da port
  4490. @@:
  4491. in al,dx
  4492. test al,00001000B ; dots off?
  4493. jnz @b
  4494. cli ; disable interrupts
  4495. @@:
  4496. in al,dx
  4497. test al,00001000B ; dots on?
  4498. jz @b
  4499. sub dl,2 ; point to 3d8 port
  4500. mov al,21H ; bit 3 <- 0
  4501. out dx,al ; disable video signal
  4502. sub dl,2 ; point to 3d6 port
  4503. mov al,81H ; select bank 1
  4504. out dx,al
  4505. mov cx,16
  4506. rep movsw
  4507. mov al,10000000B ; select bank 0 & enable Hangeul mode
  4508. out dx,al
  4509. add dl,2 ; point to 3d8 port
  4510. mov cx,ds
  4511. xor ax,ax
  4512. mov ds,ax
  4513. mov al,[rCrtModeSet] ; get modeset value
  4514. out dx,al ; enable video signal
  4515. mov ds,cx
  4516. sti ; enable interrupts
  4517. clc
  4518. ret
  4519. HanOnCga:
  4520. mov dx,3d6H ; point to 3d6 port
  4521. mov al,10000000B ; data to output
  4522. out dx,al
  4523. cmp [ModeId],0*2
  4524. jz @f
  4525. mov al,11000000b
  4526. out dx,al
  4527. @@:
  4528. ret
  4529. HanOffCga:
  4530. mov dx,3d6H ; point to 3d6 port
  4531. xor al,al ; data to output
  4532. out dx,al
  4533. ret
  4534. ;
  4535. ; font card
  4536. public HanOnFont, HanOffFont, GetFontFont, PutFontFont
  4537. GetFontFont:
  4538. mov si,0b800h-2
  4539. mov ds,si
  4540. sub si,si
  4541. cli ; for proper operation
  4542. mov ax,cx
  4543. mov dx,3b6H ; point to 3b6 port
  4544. out dx,ax ; out high byte
  4545. mov cx,16 ; repeat word counter
  4546. rep movsw ; move pattern into es:di
  4547. inc dl
  4548. out dx,al
  4549. sti
  4550. clc
  4551. ret
  4552. PutFontFont:
  4553. mov ax,cx ; save codes
  4554. mov dx,3b6H ; point to 3b6 port
  4555. cli
  4556. out dx,ax
  4557. mov di,0b800h-2
  4558. mov es,di
  4559. xor di,di
  4560. mov cx,16
  4561. rep movsw ; move pattern to put_through RAM
  4562. inc dl
  4563. out dx,al
  4564. sti
  4565. HanOnFont:
  4566. HanOffFont:
  4567. clc
  4568. ret
  4569. ;------------------------------------------------------------------------
  4570. ; << DispEngMonoMulti >>
  4571. ; FUNCTION = english character multi-display in mono
  4572. ; INPUT : ES:AX = graphics buffer position, CX = counter, BL = attr
  4573. ; DS:SI = pattern
  4574. ; OUTPUT : none
  4575. ; PROTECT : none
  4576. ; DispEngMonoMulti(BL,CX,DS,SI,ES,AX/-)
  4577. ; {
  4578. ; if (CX = 1),DispEngMono(BL,DS,SI,ES,DI/-);
  4579. ; else
  4580. ; {
  4581. ; if (CX = 0), return;
  4582. ; DI = AX;
  4583. ; Call MakeEngAttr ;
  4584. ; while (CX = 0, CX-)
  4585. ; /* save register */
  4586. ; DispEngMono(BL,DS,SI,ES,DI/-);
  4587. ; /* restore register */
  4588. ; /* recalc memory address */
  4589. ; }
  4590. ; }
  4591. DispEngMonoMulti:
  4592. cmp cx,1
  4593. jne @f
  4594. call DispEngMono
  4595. ret
  4596. @@:
  4597. jcxz DispEngMonoMultiExit
  4598. mov dl,Byte Ptr [CurPos]
  4599. mov di,ax
  4600. CALL MakeEngAttr
  4601. DispEngMonoMultiLoop:
  4602. @push bx,cx,dx,di,si
  4603. call DispEngMonoDo
  4604. @pop si,di,dx,cx,bx
  4605. inc di
  4606. inc dl
  4607. cmp dl,80
  4608. jb @f
  4609. xor dl,dl
  4610. add di,80*3
  4611. @@:
  4612. loop DispEngMonoMultiLoop
  4613. DispEngMonoMultiExit:
  4614. ret
  4615. ;------------------------------------------------------------------------
  4616. ; << DispEngMonoXorMulti >>
  4617. ; FUNCTION = english character multi-display in mono ( XOR )
  4618. ; INPUT : ES:AX = graphics buffer position, CX = counter, BL = attr
  4619. ; DS:SI = pattern
  4620. ; OUTPUT : none
  4621. ; PROTECT : none
  4622. ;
  4623. ; DispEngMonoXorMulti(BL,CX,DS,SI,ES,AX/-)
  4624. ; {
  4625. ; if (CX = 1),DispEngMonoXor(BL,DS,SI,ES,DI/-);
  4626. ; else
  4627. ; if (CX = 0), return;
  4628. ; DI = AX;
  4629. ; Call MakeEngAttr;
  4630. ; while (CX = 0, CX-)
  4631. ; /* save register */
  4632. ; DispEngMonoXor(BL,DS,SI,ES,DI/-);
  4633. ; /* restore register */
  4634. ; /* recalc memory address */
  4635. ; }
  4636. DispEngMonoXorMulti:
  4637. test bl,80h
  4638. jz DispEngMonoMulti
  4639. cmp cx,1
  4640. jne @f
  4641. call DispEngMonoXor
  4642. ret
  4643. @@:
  4644. jcxz DispEngMonoXorMultiExit
  4645. mov dl,Byte Ptr [CurPos]
  4646. mov di,ax
  4647. CALL MakeEngAttr
  4648. DispEngMonoXorMultiLoop:
  4649. @push bx,cx,dx,di,si
  4650. call DispEngMonoXorDo
  4651. @pop si,di,dx,cx,bx
  4652. inc di
  4653. inc dl
  4654. cmp dl,80
  4655. jb @f
  4656. xor dl,dl
  4657. add di,80*3
  4658. @@:
  4659. loop DispEngMonoXorMultiLoop
  4660. DispEngMonoXorMultiExit:
  4661. ret
  4662. ; �� sub-routine���� ����� attribute control ������ ��������
  4663. ;------------------------------------------------------------------------
  4664. ; << DispHanMono >>
  4665. ; FUNCTION = Font Image Display Routine for Double Byte Font (16*16)
  4666. ; INPUT ES:AX = Video RAM Segment:Offset
  4667. ; DS:SI = Font Data Segment:Offset
  4668. ; BL = Attribute
  4669. ; OUTPUT : none
  4670. ; PROTECT : none
  4671. ;
  4672. ; DispHanMono(BL,DS,SI,ES,AX/-)
  4673. DispHanMono:
  4674. mov di,ax
  4675. CALL MakeHanAttr
  4676. MOV AX,(2000h-2) ; Next Scan Line Value
  4677. MOV BX,(2000h*3-50h+2) ; First Scan Line Return Value
  4678. MOVSW
  4679. ADD DI,AX
  4680. MOVSW
  4681. ADD DI,AX
  4682. MOVSW
  4683. ADD DI,AX
  4684. MOVSW
  4685. SUB DI,BX
  4686. MOVSW
  4687. ADD DI,AX
  4688. MOVSW
  4689. ADD DI,AX
  4690. MOVSW
  4691. ADD DI,AX
  4692. MOVSW
  4693. SUB DI,BX
  4694. MOVSW
  4695. ADD DI,AX
  4696. MOVSW
  4697. ADD DI,AX
  4698. MOVSW
  4699. ADD DI,AX
  4700. MOVSW
  4701. SUB DI,BX
  4702. MOVSW
  4703. ADD DI,AX
  4704. MOVSW
  4705. ADD DI,AX
  4706. MOVSW
  4707. ADD DI,AX
  4708. MOVSW
  4709. RET
  4710. ;------------------------------------------------------------------------
  4711. ; << DispHanMonoXor >>
  4712. ; FUNCTION = Font Image Display Routine for Double Byte Font (16*16)
  4713. ; INPUT ES:AX = Video RAM Segment:Offset
  4714. ; DS:SI = Font Data Segment:Offset
  4715. ; BL = Attribute
  4716. ; OUTPUT : none
  4717. ; PROTECT : none
  4718. ;
  4719. ; DispHanMonoXor(BL,DS,SI,ES,AX/-)
  4720. DispHanMonoXor:
  4721. test bl,80h
  4722. jz DispHanMono
  4723. mov di,ax
  4724. CALL MakeHanAttr
  4725. MOV CX,2000h ; Next Scan Line Value
  4726. MOV BX,(2000h*3-50h) ; First Scan Line Return Value
  4727. LODSW
  4728. XOR ES:[DI],AX
  4729. ADD DI,CX
  4730. LODSW
  4731. XOR ES:[DI],AX
  4732. ADD DI,CX
  4733. LODSW
  4734. XOR ES:[DI],AX
  4735. ADD DI,CX
  4736. LODSW
  4737. XOR ES:[DI],AX
  4738. SUB DI,BX
  4739. LODSW
  4740. XOR ES:[DI],AX
  4741. ADD DI,CX
  4742. LODSW
  4743. XOR ES:[DI],AX
  4744. ADD DI,CX
  4745. LODSW
  4746. XOR ES:[DI],AX
  4747. ADD DI,CX
  4748. LODSW
  4749. XOR ES:[DI],AX
  4750. SUB DI,BX
  4751. LODSW
  4752. XOR ES:[DI],AX
  4753. ADD DI,CX
  4754. LODSW
  4755. XOR ES:[DI],AX
  4756. ADD DI,CX
  4757. LODSW
  4758. XOR ES:[DI],AX
  4759. ADD DI,CX
  4760. LODSW
  4761. XOR ES:[DI],AX
  4762. SUB DI,BX
  4763. LODSW
  4764. XOR ES:[DI],AX
  4765. ADD DI,CX
  4766. LODSW
  4767. XOR ES:[DI],AX
  4768. ADD DI,CX
  4769. LODSW
  4770. XOR ES:[DI],AX
  4771. ADD DI,CX
  4772. LODSW
  4773. XOR ES:[DI],AX
  4774. RET
  4775. ;------------------------------------------------------------------------
  4776. ; << DispEngMono >>
  4777. ; FUNCTION = Font Image Display Routine for One Byte Font
  4778. ; INPUT ES:AX = Video RAM Segment:Offset
  4779. ; DS:SI = Font Data Segment:Offset
  4780. ; BL = Attribute
  4781. ; OUTPUT : none
  4782. ; PROTECT : none
  4783. ;
  4784. ; DispEngMono(BL,DS,SI,ES,AX/-)
  4785. DispEngMono:
  4786. mov di,ax
  4787. CALL MakeEngAttr
  4788. DispEngMonoDo:
  4789. MOV AX,(2000h-1) ; Next Scan Line Value
  4790. MOV BX,(2000h*3-50h+1) ; First Scan Line Return Value
  4791. MOVSB
  4792. ADD DI,AX
  4793. MOVSB
  4794. ADD DI,AX
  4795. MOVSB
  4796. ADD DI,AX
  4797. MOVSB
  4798. SUB DI,BX
  4799. MOVSB
  4800. ADD DI,AX
  4801. MOVSB
  4802. ADD DI,AX
  4803. MOVSB
  4804. ADD DI,AX
  4805. MOVSB
  4806. SUB DI,BX
  4807. MOVSB
  4808. ADD DI,AX
  4809. MOVSB
  4810. ADD DI,AX
  4811. MOVSB
  4812. ADD DI,AX
  4813. MOVSB
  4814. SUB DI,BX
  4815. MOVSB
  4816. ADD DI,AX
  4817. MOVSB
  4818. ADD DI,AX
  4819. MOVSB
  4820. ADD DI,AX
  4821. MOVSB
  4822. RET
  4823. ;------------------------------------------------------------------------
  4824. ; << DispEngMonoXor >>
  4825. ; FUNCTION = Font Image Display Routine for One Byte Font
  4826. ; INPUT ES:AX = Video RAM Segment:Offset
  4827. ; DS:SI = Font Data Segment:Offset
  4828. ; BL = Attribute
  4829. ; OUTPUT : none
  4830. ; PROTECT : none
  4831. ;
  4832. ; DispEngMonoXor(BL,DS,SI,ES,AX/-)
  4833. DispEngMonoXor:
  4834. test bl,80h
  4835. jz DispEngMono
  4836. mov di,ax
  4837. CALL MakeEngAttr
  4838. DispEngMonoXorDo:
  4839. MOV CX,2000h ; Next Scan Line Value
  4840. MOV BX,(2000h*3-50h) ; First Scan Line Return Value
  4841. LODSB
  4842. XOR ES:[DI],AL
  4843. ADD DI,CX
  4844. LODSB
  4845. XOR ES:[DI],AL
  4846. ADD DI,CX
  4847. LODSB
  4848. XOR ES:[DI],AL
  4849. ADD DI,CX
  4850. LODSB
  4851. XOR ES:[DI],AL
  4852. SUB DI,BX
  4853. LODSB
  4854. XOR ES:[DI],AL
  4855. ADD DI,CX
  4856. LODSB
  4857. XOR ES:[DI],AL
  4858. ADD DI,CX
  4859. LODSB
  4860. XOR ES:[DI],AL
  4861. ADD DI,CX
  4862. LODSB
  4863. XOR ES:[DI],AL
  4864. SUB DI,BX
  4865. LODSB
  4866. XOR ES:[DI],AL
  4867. ADD DI,CX
  4868. LODSB
  4869. XOR ES:[DI],AL
  4870. ADD DI,CX
  4871. LODSB
  4872. XOR ES:[DI],AL
  4873. ADD DI,CX
  4874. LODSB
  4875. XOR Es:[DI],AL
  4876. SUB DI,BX
  4877. LODSB
  4878. XOR ES:[DI],AL
  4879. ADD DI,CX
  4880. LODSB
  4881. XOR ES:[DI],AL
  4882. ADD DI,CX
  4883. LODSB
  4884. XOR ES:[DI],AL
  4885. ADD DI,CX
  4886. LODSB
  4887. XOR ES:[DI],AL
  4888. RET
  4889. ;------------------------------------------------------------------------
  4890. ; << CalcScrollParms >>
  4891. ; FUNCTION = Scroll�� ���� �Ķ������� ����
  4892. ; INPUT : AH = Function
  4893. ; : AL = Scroll Line count
  4894. ; : BH = Blank line Attr
  4895. ; : CH:CL = Left Upper Row : Column
  4896. ; : DH:DL = Right Lower Row : Column
  4897. ; OUTPUT : BL = Scroll Line count ( Y' )
  4898. ; : DH = Move count ( Y )
  4899. ; : DL = Window width ( X )
  4900. ; : BP = 80 - DL ( X' )
  4901. ; : DI = CH*80*2 + CL
  4902. ; : SI = (CH+AL)*80*2 + CL
  4903. ; PROTECT : none
  4904. ; -----------------------------------------
  4905. ;  X X' 
  4906. ; --------><------------------><--------- 
  4907. ;    
  4908. ;  (CH,CL) 
  4909. ;  ---- -------------------- 
  4910. ;   di   
  4911. ;     al  
  4912. ;      
  4913. ;  y  -------------------  
  4914. ;   si  
  4915. ;     
  4916. ;     
  4917. ;    si 
  4918. ;  ---- --------------------(DH-AL,DL) 
  4919. ;      
  4920. ;  y'    al  
  4921. ;     di 
  4922. ;  ---- -------------------- 
  4923. ;  (DH,DL) 
  4924. ; ------------------------------------------
  4925. ;
  4926. ; SCROLL UP  SCROLL DOWN
  4927. ; -------------------------------------------------------
  4928. ; CLD  STD
  4929. ;  XCHG CX,DX
  4930. ;  NEG AL
  4931. ; --------------------------------------------------------
  4932. ; X = DL - CL  X = DL - CL
  4933. ; if AL >= 80H , -X  if AL >= 80H , -X
  4934. ; X' = 80 - X  X' = 80 - X
  4935. ; if AL >= 80H , -X'  if AL >= 80H , -X'
  4936. ; Y = DH - CH - AL  Y = DH - CH - AL
  4937. ; DI = CH * 80*2 + CL  DI = CH * 80*2 + CL
  4938. ; SI = (CH+AL)*80*2 + CL SI = (CH+AL)*80*2 + CL
  4939. ; 
  4940. ;
  4941. CalcScrollParms:
  4942. cmp ah,06h
  4943. jz @f ; scroll up
  4944. std ; decrement order
  4945. xchg cx,dx
  4946. neg al
  4947. @@:
  4948. push cx
  4949. mov bl,al ; BL = Y'
  4950. sub dl,cl ; DL = X
  4951. jns @f
  4952. neg dl
  4953. @@:
  4954. inc dl
  4955. sub dh,ch ; Y + Y'
  4956. jns @f
  4957. neg dh
  4958. @@:
  4959. inc dh
  4960. mov al,bl
  4961. or al,al
  4962. jns @f
  4963. neg al
  4964. @@:
  4965. sub dh,al ; Y
  4966. mov bp,80
  4967. mov al,dl
  4968. xor ah,ah
  4969. sub bp,ax ; BP = X'
  4970. shl bp,1 ; word size
  4971. mov al,80
  4972. mul ch
  4973. xor ch,ch
  4974. mov di,ax
  4975. add di,cx ; (ch*80)*2 + cl
  4976. shl di,1
  4977. mov si,di
  4978. mov al,bl
  4979. or al,al
  4980. jns @f
  4981. neg al
  4982. @@:
  4983. mov ah,80*2
  4984. mul ah
  4985. mov cl,bl
  4986. or cl,cl
  4987. jns @f
  4988. sub si,ax
  4989. jmp short Continue
  4990. @@:
  4991. add si,ax
  4992. Continue:
  4993. or bl,bl
  4994. jns @f
  4995. neg bp
  4996. @@:
  4997. pop cx
  4998. ret
  4999. ;------------------------------------------------------------------------
  5000. ; << TextBufferScroll >>
  5001. ; FUNCTION = Text Buffer�� Scroll
  5002. ; INPUT : ES:AX = CodeBuffer�� ���׸�Ʈ�� �ɼ�
  5003. ; : BH = Blank line attribute
  5004. ; : BL = Scroll Line count ( Y' )
  5005. ; : DH = Move count ( Y )
  5006. ; : DL = Window width ( X )
  5007. ; : BP = 80 - DL ( X' )
  5008. ; : DI = CH*80*2 + CL
  5009. ; : SI = (CH+AL)*80*2 + CL
  5010. ; OUTPUT : none
  5011. ; PROTECT : BX,CX,DX,DS,SI,DI
  5012. TextBufferScroll:
  5013. @push bx,cx,dx,ds,di,si
  5014. or bl,bl
  5015. jns @f
  5016. neg bl ; Positive
  5017. @@:
  5018. add di,ax ; ES:DI = destination
  5019. add si,ax ; DS:SI = source
  5020. mov cx,es
  5021. mov ds,cx
  5022. xor ch,ch
  5023. or dh,dh
  5024. jz MgaTextFill
  5025. @@:
  5026. mov cl,dl ; restore width
  5027. rep movsw
  5028. add si,bp
  5029. add di,bp
  5030. dec dh
  5031. jnz @b
  5032. MgaTextFill:
  5033. mov ah,bh ; restore attribute
  5034. mov al,' ' ; space character
  5035. @@:
  5036. mov cl,dl
  5037. rep stosw ; AX = attribute : ' '
  5038. add di,bp
  5039. dec bl
  5040. jnz @b
  5041. @pop si,di,ds,dx,cx,bx
  5042. ret
  5043. ;------------------------------------------------------------------------
  5044. ; << MgaGrpScroll >>
  5045. ; FUNCTION = Mono Graphic Screen Scroll
  5046. ; INPUT : BH = Blank line Attr
  5047. ; : BL = Scroll Line count ( Y' )
  5048. ; : DH = Move count ( Y )
  5049. ; : DL = Window width ( X )
  5050. ; : CX = Row : Column
  5051. ; OUTPUT : none
  5052. ; PROTECT : none
  5053. MgaGrpScroll:
  5054. les di,[GrpBufAddr]
  5055. mov ax,es
  5056. mov ds,ax ; ES = DS
  5057. mov bp,cx
  5058. xchg cx,dx ; save DX
  5059. mov ax,80*4
  5060. mov dl,dh
  5061. xor dh,dh
  5062. mul dx
  5063. mov dx,bp
  5064. xor dh,dh
  5065. add ax,dx
  5066. add di,ax
  5067. mov si,di
  5068. mov dl,bl
  5069. or dl,dl
  5070. jns @f
  5071. neg dl
  5072. @@:
  5073. mov bp,80*4
  5074. mov al,dl
  5075. xor ah,ah
  5076. mul bp
  5077. or bl,bl
  5078. jns @f
  5079. sub si,ax
  5080. jmp short MF3
  5081. @@:
  5082. add si,ax
  5083. MF3:
  5084. xchg cx,dx ; restore DX
  5085. xor ah,ah
  5086. mov al,dl ; restore width
  5087. mov bp,2000h
  5088. or bl,bl
  5089. jns @f
  5090. add bp,ax
  5091. jmp short MF4
  5092. @@:
  5093. sub bp,ax ; 2000h-window width:next scan line
  5094. MF4:
  5095. xor al,al
  5096. or bh,bh
  5097. jz MF1
  5098. cmp bh,0ffh
  5099. jz MF2
  5100. and bh,77h
  5101. cmp bh,70h
  5102. jz MF2
  5103. and bh,00000111b
  5104. cmp bh,1 ; undeline
  5105. jnz MF1
  5106. or cs:[ScrUpDnFlag],10000000b
  5107. jmp Short MF1
  5108. MF2:
  5109. not al ; al=0ffh
  5110. MF1:
  5111. mov ah,bl ; set fill count
  5112. mov ch,bl
  5113. mov bx,(8000h-50h)
  5114. or ah,ah
  5115. jns @f
  5116. neg ah
  5117. @@:
  5118. push ax
  5119. sub bx,bp
  5120. xor ch,ch
  5121. or dh,dh
  5122. jnz MonoScrollLoop
  5123. jmp MonoFill
  5124. MonoScrollLoop:
  5125. mov cl,dl ; 1
  5126. rep movsb
  5127. add si,bp
  5128. add di,bp
  5129. mov cl,dl ; 2
  5130. rep movsb
  5131. add si,bp
  5132. add di,bp
  5133. mov cl,dl ; 3
  5134. rep movsb
  5135. add si,bp
  5136. add di,bp
  5137. mov cl,dl ; 4
  5138. rep movsb
  5139. sub si,bx
  5140. sub di,bx
  5141. mov cl,dl ; 5
  5142. rep movsb
  5143. add si,bp
  5144. add di,bp
  5145. mov cl,dl ; 6
  5146. rep movsb
  5147. add si,bp
  5148. add di,bp
  5149. mov cl,dl ; 7
  5150. rep movsb
  5151. add si,bp
  5152. add di,bp
  5153. mov cl,dl ; 8
  5154. rep movsb
  5155. sub si,bx
  5156. sub di,bx
  5157. mov cl,dl ; 9
  5158. rep movsb
  5159. add si,bp
  5160. add di,bp
  5161. mov cl,dl ; 10
  5162. rep movsb
  5163. add si,bp
  5164. add di,bp
  5165. mov cl,dl ; 11
  5166. rep movsb
  5167. add si,bp
  5168. add di,bp
  5169. mov cl,dl ; 12
  5170. rep movsb
  5171. sub si,bx
  5172. sub di,bx
  5173. mov cl,dl ; 13
  5174. rep movsb
  5175. add si,bp
  5176. add di,bp
  5177. mov cl,dl ; 14
  5178. rep movsb
  5179. add si,bp
  5180. add di,bp
  5181. mov cl,dl ; 15
  5182. rep movsb
  5183. add si,bp
  5184. add di,bp
  5185. mov cl,dl ; 16
  5186. rep movsb
  5187. sub si,bx
  5188. sub di,bx
  5189. or ah,ah
  5190. test cs:[ScrUpDnFlag],00000010b
  5191. jz @f ; down
  5192. sub si,80*4*2
  5193. sub di,80*4*2
  5194. @@:
  5195. dec dh ; decrement scroll Height
  5196. jz MonoFill
  5197. jmp MonoScrollLoop
  5198. MonoFill:
  5199. pop ax
  5200. MonoFillLoop:
  5201. mov cl,dl ; 1
  5202. rep stosb
  5203. add di,bp
  5204. mov cl,dl ; 2
  5205. rep stosb
  5206. add di,bp
  5207. mov cl,dl ; 3
  5208. rep stosb
  5209. add di,bp
  5210. mov cl,dl ; 4
  5211. rep stosb
  5212. sub di,bx
  5213. mov cl,dl ; 5
  5214. rep stosb
  5215. add di,bp
  5216. mov cl,dl ; 6
  5217. rep stosb
  5218. add di,bp
  5219. mov cl,dl ; 7
  5220. rep stosb
  5221. add di,bp
  5222. mov cl,dl ; 8
  5223. rep stosb
  5224. sub di,bx
  5225. mov cl,dl ; 9
  5226. rep stosb
  5227. add di,bp
  5228. mov cl,dl ; 10
  5229. rep stosb
  5230. add di,bp
  5231. mov cl,dl ; 11
  5232. rep stosb
  5233. add di,bp
  5234. mov cl,dl ; 12
  5235. rep stosb
  5236. sub di,bx
  5237. mov cl,dl ; 13
  5238. rep stosb
  5239. add di,bp
  5240. mov cl,dl ; 14
  5241. rep stosb
  5242. add di,bp
  5243. mov cl,dl ; 15
  5244. rep stosb
  5245. add di,bp
  5246. test cs:[ScrUpDnFlag],80h ; scroll down/undeline
  5247. jz @f
  5248. mov al,0ffh
  5249. mov cl,dl ; 16
  5250. rep stosb
  5251. xor al,al
  5252. jmp Short Normal1
  5253. @@:
  5254. mov cl,dl ; 16
  5255. rep stosb
  5256. Normal1:
  5257. sub di,bx
  5258. test cs:[ScrUpDnFlag],00000010b
  5259. jz @f
  5260. sub di,80*4*2
  5261. @@:
  5262. dec ah ; decrement scroll count
  5263. jz @f
  5264. jmp MonoFillLoop
  5265. @@:
  5266. ret
  5267. ;------------------------------------------------------------------------
  5268. ; << MgaWritePixel >>
  5269. ; FUNCTION = write pixel
  5270. ; INPUT : DX row number
  5271. ; : CX column number
  5272. ; : AL color value
  5273. ; OUTPUT : none
  5274. ; PROTECT : none
  5275. ; if bit 7 of al = 1, then color value is XORed
  5276. ; with the current contents of the dot
  5277. ; MgaWritePixel(AL,CX,DX/-)
  5278. MgaWritePixel:
  5279. mov bh,al ; save color value
  5280. call MgaGetPos
  5281. test bh,10000000b ; is bit 7 set?
  5282. jz MgaWriteDotNormal
  5283. and bh,00000001B ; maskout other than color bit
  5284. ror bh,1 ; reside to MSB
  5285. shr bh,cl ; get target bit position in that byte
  5286. xor al,bh ; XORing color value of raw bit
  5287. stosb ; write dot
  5288. ret
  5289. MgaWriteDotNormal:
  5290. and bh,00000001B ; maskout other than color bit
  5291. ror bh,1 ; reside to MSB
  5292. shr bh,cl ; get target bit position in that byte
  5293. not bl ; inverse masking bits (1's complement)
  5294. and al,bl ; maskout target bit
  5295. or al,bh ; set color value into target bit
  5296. stosb ; write dot
  5297. ret
  5298. MgaGetPos:
  5299. mov di,dx ; save row number
  5300. mov ax,80
  5301. shr dx,1 ; rows/4
  5302. shr dx,1
  5303. mul dl
  5304. mov dx,di ; restore row number
  5305. mov di,ax ; rows/4 * 80
  5306. and dx,0000000000000011B ; rows mod 4
  5307. ror dx,1 ; mapping to x000H(0/2000H/4000H/6000H)
  5308. ror dx,1
  5309. ror dx,1
  5310. add di,dx ; target VRAM addr for given rows
  5311. mov ax,cx ; get column number
  5312. shr ax,1 ; cols/8
  5313. shr ax,1
  5314. shr ax,1
  5315. add di,ax ; target VRAM addr for given rows/cols
  5316. and cx,00000111B ; get remainder
  5317. mov ax,80h
  5318. shr ax,cl ; get target bit position in that byte
  5319. mov bl,al ; save it
  5320. mov al,es:[di] ; get target byte
  5321. ret
  5322. ;------------------------------------------------------------------------
  5323. ; << MgaReadPixel >>
  5324. ; FUNCTION = read pixel
  5325. ; INPUT : DX row number
  5326. ; : CX column number
  5327. ; OUTPUT : AL returned color value the dot read
  5328. ; PROTECT : none
  5329. ;
  5330. ;MgaReadPixel(BH,CX,DX/-)
  5331. MgaReadPixel:
  5332. call MgaGetPos
  5333. and al,bl ; extract target bit
  5334. not cl
  5335. and cl,00000111B ; get shift counter (cl=7-cl)
  5336. shr al,cl ; return color value
  5337. ret
  5338. ;------------------------------------------------------------------------
  5339. ; << CalcTextBlock >>
  5340. ; FUNCTION = parm. calculation for block move/copy
  5341. ; INPUT : BX = Target
  5342. ; : CX = UL
  5343. ; : DX = LR
  5344. ; : BP = Move/Copy : Attr
  5345. ; OUTPUT : SI = Source position
  5346. ; DI = Target position
  5347. ; DL = Window weidth ( X )
  5348. ; DH = Window height ( Y )
  5349. ; BP = Screen width - Window width ( X' )
  5350. ; BH:BL = Move/Copy : Attr
  5351. ; PROTECT : none
  5352. ; CalcBlockText(BX,CX,DX/-)
  5353. ;
  5354. ; -------------------------------------------
  5355. ;  X X' 
  5356. ; --------><------------------><
  5357. ;    
  5358. ;  (CH,CL) (CH,DL) 
  5359. ;  ---- -------------------- 
  5360. ;     
  5361. ;     
  5362. ;  y   (BH,BL)  (BH,DL-CL+BL)
  5363. ;    ---------�---------- 
  5364. ;       
  5365. ;       
  5366. ;  ---- ----------�--------  
  5367. ;  (DH,CL)  (DH,DL)  
  5368. ;    
  5369. ;    
  5370. ;  -------------------- 
  5371. ;  (DH-CH+BH,BL) (DH-CH+BH,DL-CL-BL)
  5372. ;  
  5373. ; ---------------------------------------------
  5374. ;
  5375. ; CASE1(Tail to Left) BH > CH
  5376. ; BL >= CL
  5377. ; STD
  5378. ; Y (BlkHeight) = DH - CH
  5379. ; X'(NextLine) = - (80 - X)
  5380. ; X (BlkWidth) = DL - CL
  5381. ; SI = DH * 80 * 2 + DL
  5382. ; DI = (DH - CH + BH) * 80 * 2 + (DL - CL + BL)
  5383. ;
  5384. ; CASE2(Left to Head) BH =< CH
  5385. ; BL > CL
  5386. ; STD
  5387. ; Y (BlkHeight) = DH - CH
  5388. ; X'(NextLine) = 80 + X
  5389. ; X (BlkWidth) = DL - CL
  5390. ; SI = CH * 80 * 2 + DL
  5391. ; DI = BH * 80 * 2 + (DL - CL + BL)
  5392. ;
  5393. ; CASE3(Head to Right) BH < CH
  5394. ; BL =< CL
  5395. ; CLD
  5396. ; Y (BlkHeight) = DH - CH
  5397. ; X'(NextLine) = 80 - X
  5398. ; X (BlkWidth) = DL - CL
  5399. ; SI = CH * 80 * 2 + CL
  5400. ; DI = BH * 80 * 2 + BL
  5401. ;
  5402. ; CASE4(Left to Tail) BH >= CH
  5403. ; BL < CL
  5404. ; CLD
  5405. ; Y (BlkHeight) = DH - CH
  5406. ; X'(NextLine) = - (80 + X)
  5407. ; X (BlkWidth) = DL - CL
  5408. ; SI = DH * 80 * 2 + CL
  5409. ; DI = (DH - CH + BH) * 80 * 2 + BL
  5410. ;
  5411. CalcTextBlock:
  5412. sub dl,cl
  5413. jnc @f
  5414. neg dl
  5415. @@:
  5416. inc dl ; x
  5417. sub dh,ch
  5418. jnc @f
  5419. neg dh
  5420. @@:
  5421. inc dh ; y
  5422. mov al,80
  5423. mul bh
  5424. xor bh,bh
  5425. mov di,ax
  5426. add di,bx ; DI
  5427. shl di,1
  5428. mov al,80
  5429. mul ch
  5430. xor ch,ch
  5431. mov si,ax
  5432. add si,cx ; SI
  5433. shl si,1
  5434. mov bx,80
  5435. sub bl,dl
  5436. shl bx,1
  5437. xchg bx,bp
  5438. or bh,bh
  5439. js @f ; jump if MSB = 1
  5440. neg bp
  5441. @@:
  5442. add bp,[BlockAdj]
  5443. ret
  5444. ;------------------------------------------------------------------------
  5445. ; << BlockText >>
  5446. ; FUNCTION = text buffer block move Move/Copy
  5447. ; INPUT : SI = Source position
  5448. ; DI = Target position
  5449. ; DL = Window weidth ( X )
  5450. ; DH = Window height ( Y )
  5451. ; BP = Screen width - Window width ( X' )
  5452. ; BH:BL = Move/Copy : Attr
  5453. ; OUTPUT : none
  5454. ; PROTECT : DS,SI,DI,DX,BX,BP
  5455. ; BlockText(segment:offset/-)
  5456. BlockText:
  5457. @push si,di,dx
  5458. add di,ax
  5459. add si,ax
  5460. mov ax,ds
  5461. mov es,ax
  5462. xor ch,ch
  5463. test bh,1
  5464. jnz @f
  5465. mov ch,bl
  5466. mov cl,20h
  5467. @@:
  5468. test bh,1
  5469. jz BlockTextMove
  5470. mov cl,dl
  5471. rep movsw
  5472. jmp short BlockTextEnd
  5473. BlockTextMove:
  5474. push dx
  5475. BlockTextMoveLp:
  5476. mov ax,[si]
  5477. stosw
  5478. xchg si,di
  5479. mov ax,cx
  5480. stosw
  5481. xchg si,di
  5482. dec dl
  5483. jnz BlockTextMoveLp
  5484. pop dx
  5485. BlockTextEnd:
  5486. add di,bp ; BP = x'
  5487. add si,bp ; BP = x'
  5488. dec dh ; DH = y
  5489. jnz @b
  5490. mov ax,cs
  5491. mov ds,ax
  5492. @pop dx,di,si
  5493. ret
  5494. ;------------------------------------------------------------------------
  5495. ; << MgaGrpBlock >>
  5496. ; FUNCTION = graphic buffer block move/copy
  5497. ; INPUT : DI = Target ( BX )
  5498. ; SI = Source ( CX )
  5499. ; DL = Window weidth ( X )
  5500. ; DH = Window height ( Y )
  5501. ; BP = Screen width - Window width ( X' )
  5502. ; BH:BL = Move/Copy : Attr
  5503. ; OUTPUT : none
  5504. ; PROTECT : none
  5505. ; MgaGrpBlock(bx,dx,bp/-)
  5506. MgaGrpBlock:
  5507. @pop bx,di
  5508. mov ax,di
  5509. mov al,ah
  5510. mov ah,80
  5511. mul ah
  5512. shl ax,1
  5513. shl ax,1
  5514. and di,0ffh
  5515. add di,ax
  5516. pop si
  5517. mov ax,si
  5518. mov al,ah
  5519. mov ah,80
  5520. mul ah
  5521. shl ax,1
  5522. shl ax,1
  5523. and si,0ffh
  5524. add si,ax ; DI
  5525. sub bp,[BlockAdj]
  5526. sar [BlockAdj],1
  5527. neg [BlockAdj]
  5528. sar bp,1 ; make byte length
  5529. add bp,2000h-80
  5530. add [BlockAdj],8000h-80
  5531. or bh,bh
  5532. js @f ; jump if MSB = 1
  5533. add bp,80*2
  5534. add [BlockAdj],80*2
  5535. @@:
  5536. test bh,40h
  5537. jnz @f
  5538. add di,(4-1)*80
  5539. add si,(4-1)*80
  5540. @@:
  5541. les ax,[GrpBufAddr]
  5542. mov ax,es
  5543. mov ds,ax
  5544. xchg bl,bh
  5545. push bx
  5546. and bh,01110111B
  5547. mov ax,-1
  5548. cmp bh,70h
  5549. jz @f
  5550. inc al
  5551. cmp bh,1
  5552. jz @f
  5553. inc ah
  5554. @@:
  5555. pop bx
  5556. xchg ax,bx
  5557. mov ah,al
  5558. test ah,1
  5559. jz @f
  5560. xor ch,ch
  5561. @@:
  5562. call BlockMono4Line
  5563. call BlockMono4Line
  5564. call BlockMono4Line
  5565. call BlockLine
  5566. add di,bp ; BX = x'
  5567. add si,bp ; BX = x'
  5568. call BlockLine
  5569. add di,bp
  5570. add si,bp
  5571. call BlockLine
  5572. add di,bp
  5573. add si,bp
  5574. xchg bl,bh
  5575. call BlockLine
  5576. xchg bl,bh
  5577. add di,bp
  5578. add si,bp
  5579. sub di,cs:[BlockAdj]
  5580. sub si,cs:[BlockAdj]
  5581. dec dh ; AX = y
  5582. jnz @b
  5583. mov ax,cs
  5584. mov ds,ax
  5585. ret
  5586. ;-------------------------------
  5587. BlockMono4Line:
  5588. call BlockLine
  5589. add di,bp
  5590. add si,bp
  5591. call BlockLine
  5592. add di,bp
  5593. add si,bp
  5594. call BlockLine
  5595. add di,bp
  5596. add si,bp
  5597. call BlockLine
  5598. add di,bp
  5599. add si,bp
  5600. sub di,cs:[BlockAdj]
  5601. sub si,cs:[BlockAdj]
  5602. ret
  5603. ;-------------------------------
  5604. BlockLine:
  5605. test ah,1
  5606. jz BlockGrpMove
  5607. mov cl,dl
  5608. rep movsb
  5609. ret
  5610. BlockGrpMove:
  5611. push dx
  5612. @@:
  5613. mov al,[si]
  5614. stosb
  5615. xchg si,di
  5616. mov al,bl
  5617. stosb
  5618. xchg si,di
  5619. dec dl
  5620. jnz @b
  5621. pop dx
  5622. ret
  5623. ;------------------------------------------------------------------------
  5624. ; << FullScrollText >>
  5625. ; FUNCTION = text buffer full scroll
  5626. ; INPUT : ES:DI = text buffer, BL = attribute
  5627. ; OUTPUT : none
  5628. ; PROTECT : BH
  5629. ;
  5630. ; FullScrollText(ES,DI/BL)
  5631. ;
  5632. FullScrollText:
  5633. mov dx,ds
  5634. mov ax,es
  5635. mov ds,ax
  5636. mov si,di
  5637. mov ax,80*2
  5638. add si,ax
  5639. shr al,1
  5640. mov ah,byte ptr cs:[MaxRows]
  5641. dec ah
  5642. mul ah
  5643. mov cx,ax
  5644. rep movsw
  5645. mov bl,[di+1]
  5646. mov ah,bl
  5647. mov al,' '
  5648. mov cl,80*2/2
  5649. rep stosw
  5650. mov ds,dx
  5651. ret
  5652. ;------------------------------------------------------------------------
  5653. ; << FullScrollMono >>
  5654. ; FUNCTION = mono buffer full scroll
  5655. ; INPUT : ES:DI = graphics buffer, BL = attribute
  5656. ; OUTPUT : none
  5657. ; PROTECT : none
  5658. ;
  5659. ; FullScrollMono(ES,DI,BL/-)
  5660. ;
  5661. FullScrollMono:
  5662. mov ax,es
  5663. mov ds,ax
  5664. mov si,di
  5665. add si,80*16/4
  5666. mov dx,2000h-80
  5667. mov cx,24*16/4
  5668. @@:
  5669. push cx
  5670. mov cl,80/2
  5671. rep movsw
  5672. add di,dx
  5673. add si,dx
  5674. mov cl,80/2
  5675. rep movsw
  5676. add di,dx
  5677. add si,dx
  5678. mov cl,80/2
  5679. rep movsw
  5680. add di,dx
  5681. add si,dx
  5682. mov cl,80/2
  5683. rep movsw
  5684. sub di,6000h
  5685. sub si,6000h
  5686. pop cx
  5687. loop @b
  5688. mov ax,-1
  5689. and bl,01110111b
  5690. cmp bl,70
  5691. jz @f
  5692. xor al,al
  5693. and bl,00000111b
  5694. cmp bl,1
  5695. jz @f
  5696. xor ah,ah
  5697. @@:
  5698. mov bx,2000h-80
  5699. mov cl,4
  5700. @@:
  5701. push cx
  5702. mov cl,80
  5703. rep stosb
  5704. add di,bx
  5705. mov cl,80
  5706. rep stosb
  5707. add di,bx
  5708. mov cl,80
  5709. rep stosb
  5710. add di,bx
  5711. mov cl,80
  5712. rep stosb
  5713. sub di,6000h
  5714. pop cx
  5715. loop @b
  5716. ret
  5717. ;=======================================================================
  5718. public VideoParms, Cga40h, Mda70h, Cga23h, Mda07h, CrtcSet, RegSize
  5719. VideoParms label byte
  5720. db 38H,28H,2dH,0aH,1fH,06H,19H,1cH,02H,07H,06H,07H,0,0,0,0
  5721. Cga23H db 71H,50H,5aH,0aH,1fH,06H,19H,1cH,02H,07H,06H,07H,0,0,0,0
  5722. db 38H,28H,2dH,0aH,7fH,06H,64H,70H,02H,01H,06H,07H,0,0,0,0
  5723. Mda07H db 61H,50H,52H,0fH,19H,06H,19H,19H,02H,0fH,0bH,0cH,0,0,0,0
  5724. RegSize dw 2048, 4096, 16384, 4096
  5725. NoCols db 40, 40, 80, 80, 40, 40, 80, 80
  5726. CrtcSet db 2cH,28H,2dH,29H,2aH,2eH,1eH,29H
  5727. Cga40H db 38H,28H,2dH,0aH,7fH,06H,64H,70H,02H,01H,2eH,0fH,0,0,0,0
  5728. Mda70H db 33H,28H,2aH,07H,68H,02H,64H,65H,02H,03H,2eH,0fH,0,0,0,0
  5729. dw 0, 0, 32768, 32768
  5730. db 0, 0, 80, 80, 0, 0, 80, 80
  5731. CrtcSetGrp db 0, 0, 1EH, 1EH, 0, 0, 1EH, 0AH
  5732. ;========================================================================;
  5733. ; ;
  5734. ; REAL TIME INTERRUPT 08H ;
  5735. ; ;
  5736. ;========================================================================;
  5737. ; FUNCTION = text emulation & cursor display
  5738. ; INPUT : none
  5739. ; OUTPUT : none (cursor on/off)
  5740. ; PROTECT :
  5741. ; Int8()
  5742. ; +CS:[TextEmuTick]
  5743. ; /* call [OldRtcInt] */
  5744. ; if (CS:[VideoActive] == 0)
  5745. ; {
  5746. ; save AX,DS,ES;
  5747. ; DS = CS;
  5748. ; ES = 0;
  5749. ; +[VideoActive];
  5750. ; TextEmu(-/-);
  5751. ; AL = ES:[rTimerLow];
  5752. ; if (AL == 4, && [CursorStat] == CursorOn), ToggleCursor(-/-);
  5753. ; -[VideoActive]
  5754. ; restore AX,DS,ES;
  5755. ; }
  5756. ; iret;
  5757. PUBLIC Int8
  5758. Int8:
  5759. if Debug
  5760. pushf
  5761. cli
  5762. push ax
  5763. push bx
  5764. mov ax,cs:[DebugData]
  5765. mov bx,ax
  5766. and bx,0fh
  5767. and ax,0fff0h
  5768. add bx,1
  5769. and bx,0fh
  5770. or ax,bx
  5771. out 10h,ax
  5772. mov cs:[DebugData],ax
  5773. pop bx
  5774. pop ax
  5775. popf
  5776. endif ; if Debug
  5777. if WINNT
  5778. cmp cs:[ActiveCodePage], WanSungCP ; If ACP is US, don't call Text Emulation
  5779. jz @f ; For NT 5.0
  5780. inc cs:[TimerTick]
  5781. pushf
  5782. call cs:[OldRtcInt]
  5783. jmp short RealTimeIntBye
  5784. @@:
  5785. endif
  5786. inc cs:[TimerTick]
  5787. pushf
  5788. call cs:[OldRtcInt]
  5789. cmp cs:[VideoActive],0
  5790. jz @f
  5791. jmp short RealTimeIntBye
  5792. @@:
  5793. @push ax,es,ds
  5794. mov ax,cs
  5795. mov ds,ax
  5796. xor ax,ax
  5797. mov es,ax
  5798. inc [VideoActive]
  5799. mov al,byte ptr es:[rTimerLow]
  5800. and al,2
  5801. or al,[CursorStat]
  5802. test al,(2 or CursorOn)
  5803. jpo @f
  5804. call ToggleCursor
  5805. @@:
  5806. cmp [TimerTick],3
  5807. jb @f
  5808. pushf
  5809. sti
  5810. call TextEmu
  5811. popf
  5812. mov [TimerTick],0
  5813. @@:
  5814. @pop ds,es,ax
  5815. dec cs:[VideoActive]
  5816. RealTimeIntBye:
  5817. if Debug
  5818. pushf
  5819. cli
  5820. push ax
  5821. push bx
  5822. mov ax,cs:[DebugData]
  5823. mov bx,ax
  5824. and bx,0fh
  5825. and ax,0fff0h
  5826. sub bx,1
  5827. and bx,0fh
  5828. or ax,bx
  5829. out 10h,ax
  5830. mov cs:[DebugData],ax
  5831. pop bx
  5832. pop ax
  5833. popf
  5834. endif ; if Debug
  5835. iret
  5836. dw 512 dup(0)
  5837. BiosStack dw 0
  5838. StackSs dw 0
  5839. StackSp dw 0
  5840. ;------------------------------------------------------------------------
  5841. ; << TextEmu >>
  5842. ; TextEmu(-/-)
  5843. ; {
  5844. ; if (TextEmulation)
  5845. ; {
  5846. ; /* save all register */
  5847. ; /* compare code buffer */
  5848. ; if defferent value, TextEmuChar(AX,ES,DI,BP/-);
  5849. ; /* restore all register */
  5850. ; }
  5851. ; }
  5852. TextEmu:
  5853. test [ModeStat],TextEmulation
  5854. jz NotScan
  5855. cmp [VideoActive],1
  5856. jbe GotoScan
  5857. NotScan:
  5858. ret
  5859. GotoScan:
  5860. cli
  5861. push ax
  5862. mov cs:[StackSs],ss
  5863. mov cs:[StackSp],sp
  5864. mov ax,cs
  5865. mov ss,ax
  5866. mov sp,offset BiosStack
  5867. sti
  5868. @push bx,cx,dx,si,di,es,ds,bp
  5869. pushf
  5870. cld
  5871. inc [VideoActive]
  5872. mov bl,80
  5873. mov cx,[rCrtStart]
  5874. les di,[CodeBuf2Addr]
  5875. lds si,[CodeBuf1Addr]
  5876. shr cx,1
  5877. shr cx,1
  5878. shr cx,1
  5879. shr cx,1
  5880. mov dx,ds
  5881. add cx,dx
  5882. mov ds,cx
  5883. xor ch,ch
  5884. mov cl,25
  5885. ScanScreenLoop:
  5886. mov ax,[si]
  5887. call CheckCodeRange1st
  5888. jnc ScanCheckHan
  5889. ScanEngCode:
  5890. cmpsw
  5891. jz ScanScreenEnd
  5892. mov bp,0
  5893. call TextEmuChar
  5894. jmp ScanScreenEnd
  5895. ScanCheckHan:
  5896. cmp bl,1
  5897. jbe ScanEngCode
  5898. mov dx,[si+2]
  5899. mov ah,al
  5900. mov al,dl
  5901. call CheckCodeRangeWord
  5902. jc ScanEngCode
  5903. cmpsw
  5904. jnz WriteCharTe
  5905. cmp dx,es:[di]
  5906. jnz WriteCharTe
  5907. cmpsw
  5908. dec bl
  5909. jmp ScanScreenEnd
  5910. WriteCharTe:
  5911. mov bp,1
  5912. call TextEmuChar
  5913. cmpsw
  5914. dec bl
  5915. ScanScreenEnd:
  5916. dec bl
  5917. jnz ScanScreenLoop
  5918. mov bl,80
  5919. loop ScanScreenLoop
  5920. ScanExit:
  5921. dec cs:[VideoActive]
  5922. popf
  5923. @pop bp,ds,es,di,si,dx,cx,bx
  5924. cli
  5925. mov ss,cs:[StackSs]
  5926. mov sp,cs:[StackSp]
  5927. sti
  5928. pop ax
  5929. ret
  5930. ;------------------------------------------------------------------------
  5931. ; << TextEmuChar >>
  5932. ;
  5933. ;TextEmuChar(AX,ES,DI,BP/-)
  5934. ; {
  5935. ; if (english char)
  5936. ; GetPatternEng(ES,DI/carry)
  5937. ; {
  5938. ; if (VGA card)
  5939. ; DispEngColor(BL,DS,SI,ES,DI/-);
  5940. ; else
  5941. ; DispEngMono(BL,DS,SI,ES,DI/-);
  5942. ; }
  5943. ; else
  5944. ; GetPattern(ES,DI/carry)
  5945. ; {
  5946. ; if (VGA card)
  5947. ; DispHanColor(BL,DS,SI,ES,DI/-);
  5948. ; else
  5949. ; DispHanMono(BL,DS,SI,ES,DI/-);
  5950. ; }
  5951. ; }
  5952. PUBLIC TextEmuChar
  5953. TextEmuChar:
  5954. @push bx,cx,si,di,es,ds
  5955. dec si
  5956. dec si
  5957. mov ax,si
  5958. shr ax,1
  5959. mov dl,80
  5960. div dl
  5961. test cs:[Card1st],00001100b
  5962. jnz @f
  5963. call MonoVideoOffset
  5964. jmp PuttoEsDi
  5965. @@:
  5966. call ColorVideoOffset
  5967. PuttoEsDi:
  5968. mov cx,[si+2]
  5969. mov si,[si]
  5970. mov bx,seg Data
  5971. mov ds,bx
  5972. mov bl,ds:[rCurPage]
  5973. shl bx,1
  5974. cmp dx,ds:[bx+rCurPos]
  5975. jne @f
  5976. and cs:[CursorStat],not CursorOn
  5977. @@:
  5978. mov bx,si
  5979. cmp bp,0
  5980. jz EngTextEmuChar
  5981. cmp dl,80-1
  5982. jb HanTextEmuChar
  5983. EngTextEmuChar:
  5984. xor cx,cx
  5985. mov cl,bl
  5986. mov es:[di-2],bx
  5987. mov bl,bh
  5988. mov si,cs
  5989. mov es,si
  5990. mov di,offset PatternBuf
  5991. call GetPatternEng
  5992. mov si,es
  5993. mov ds,si
  5994. mov si,di
  5995. les di,cs:[GrpBufAddr]
  5996. add ax,di
  5997. test cs:[Card1st],00001100b
  5998. jnz @f
  5999. call DispEngMono
  6000. jmp TextEmuCharRet
  6001. @@:
  6002. call DispEngColor
  6003. jmp TextEmuCharRet
  6004. HanTextEmuChar:
  6005. mov es:[di-2],bx
  6006. mov es:[di],cx
  6007. xchg ch,bl
  6008. mov si,cs
  6009. mov es,si
  6010. mov di,offset PatternBuf
  6011. call GetPattern
  6012. mov si,es
  6013. mov ds,si
  6014. mov si,di
  6015. les di,cs:[GrpBufAddr]
  6016. add ax,di
  6017. test cs:[Card1st],00001100b
  6018. jnz @f
  6019. call DispHanMono
  6020. jmp TextEmuCharRet
  6021. @@:
  6022. call DispHanColor
  6023. TextEmuCharRet:
  6024. @pop ds,es,di,si,cx,bx
  6025. ret
  6026. MonoVideoOffset:
  6027. mov cx,si
  6028. xchg ah,al
  6029. mov dx,ax
  6030. sub ah,ah
  6031. sub cx,ax
  6032. sub cx,ax
  6033. shl cx,1
  6034. add ax,cx
  6035. ret
  6036. ColorVideoOffset:
  6037. mov dx,ax
  6038. xchg dl,dh
  6039. xor ah,ah
  6040. mov cl,4
  6041. shl ax,cl
  6042. mov bx,80
  6043. mov cx,dx
  6044. mul bx
  6045. mov dx,cx
  6046. add al,dl
  6047. adc ah,0
  6048. ret
  6049. if hdos60
  6050. public ChangeCodeR
  6051. ChangeCodeR:
  6052. @push bx,cx,dx,si,di,es,ds,ax
  6053. mov bx,cs
  6054. mov ds,bx
  6055. mov es,bx
  6056. mov bl,[CodeStat]
  6057. mov [OldCodeStat],bl
  6058. and [CodeStat],not (HangeulMode or Chab or WSung or WSung7)
  6059. cmp al,2 ;al=2 english
  6060. jz @f ;al=1 chohab
  6061. shl al,1 ;al=0 wansung
  6062. or al,HangeulMode
  6063. or [CodeStat],al
  6064. @@:
  6065. mov al, 0ffh ; [CHM001]
  6066. cmp [BilingCall], al ; [CHM001]
  6067. jz GoDirectSet ; [CHM001]
  6068. mov al,[CodeStat]
  6069. cmp [OldCodeStat],al
  6070. jz @f
  6071. GoDirectSet:
  6072. mov ah, 0 ; [CHM001]
  6073. mov [BilingCall], ah ; [CHM001]
  6074. or [KbMisc],RunningHot
  6075. or [KbStat],ReqEnvrChg
  6076. inc [VideoActive]
  6077. mov ah,0fh
  6078. int 10h
  6079. call ChgEnvrDo
  6080. dec [VideoActive]
  6081. and [KbStat],not ReqEnvrChg
  6082. and [KbMisc],not RunningHot
  6083. @@:
  6084. @pop ax,ds,es,di,si,dx,cx,bx
  6085. ChangeCodeRoutineRet:
  6086. ret
  6087. endif ;hdos60
  6088. if Hwin31Sw
  6089. ;========================================================================;
  6090. ; ;
  6091. ; DOS INTERRUPT 2FH, 88H ;
  6092. ; ;
  6093. ;========================================================================;
  6094. ; FUNCTION = Code stat conversion program
  6095. ; INPUT : AH=88H
  6096. ; AL=0:�ϼ�
  6097. ; 1:����
  6098. ; 2:����
  6099. ; OUTPUT : none (cursor on/off)
  6100. ; PROTECT : none
  6101. ;------------------------------------------------------------------------
  6102. public int2f
  6103. SIS Db 3, 10
  6104. SISnext dd ?
  6105. dd 0
  6106. dd 0
  6107. dw offset IDP
  6108. IDPseg dw 0
  6109. IDP dw offset StartInst
  6110. Iseg dw 0
  6111. dw SizeInst
  6112. dd 0
  6113. dw 0
  6114. hWin31Flag db 0
  6115. VxdAddr dd 0
  6116. ;hWin31Flag
  6117. ValidVxd = 00000001b
  6118. FullDosMode = 00000010b
  6119. OnMemReq = 00000100b
  6120. ;------------------------------------------------------------------------
  6121. WinModeSet:
  6122. test [hWin31Flag],ValidVxd
  6123. jz WinOrg
  6124. test [CodeStat],HangeulMode
  6125. jz WinMemRel
  6126. mov bl,al
  6127. and bl,01111111b
  6128. test [hWin31Flag],FullDosMode
  6129. jz WinBox
  6130. call CmpModeVal
  6131. jz WinMemAlloc
  6132. WinMemRel:
  6133. call WinMem2
  6134. WinOrg:
  6135. call ModeSet2
  6136. WinModeSetRet:
  6137. ret
  6138. WinMemAlloc:
  6139. test [CodeStat],Chab or Wsung7
  6140. jnz @f
  6141. test [Card1st],HanCard
  6142. jnz WinMemRel
  6143. test [Card1st],DualMnt
  6144. jnz WinMemRel
  6145. @@:
  6146. call WinMem1
  6147. call ModeSet2
  6148. call Set64k
  6149. ret
  6150. WinBox:
  6151. cmp bl,60h
  6152. jz WinMode60
  6153. cmp bl,40h
  6154. jz WinModeSetRet
  6155. cmp bl,70h
  6156. jz WinModeSetRet
  6157. test [CodeStat],Chab or Wsung7
  6158. jnz @f
  6159. test [Card1st],HanCard
  6160. jnz WinMemRel
  6161. test [Card1st],DualMnt
  6162. jnz WinMemRel
  6163. @@:
  6164. push word ptr [CodeStat]
  6165. and [CodeStat],not HangeulMode
  6166. call WinMem2
  6167. call ModeSet2
  6168. pop ax
  6169. mov [CodeStat],al
  6170. or [KbStat],HanKeyinMode
  6171. and [CodeStat],not HangeulVideoMode
  6172. CALL callKBSE
  6173. ret
  6174. WinMode60:
  6175. call WinMem2
  6176. and al,10000000b
  6177. or al,12h
  6178. call ModeSet2
  6179. push es
  6180. xor ax,ax
  6181. mov es,ax
  6182. mov es:[rCrtMode],60h
  6183. mov es:[rRows],25-1
  6184. mov [MaxRows],25
  6185. mov [HjMenuLine],24
  6186. pop es
  6187. ret
  6188. callKBSE:
  6189. mov ah,[OrgHjStat]
  6190. or [HjStat],ah
  6191. and [KbStat],not (HEStat or JJStat)
  6192. mov [HanStat],0
  6193. mov [HjMenuStat],0
  6194. mov [HjMenuLine],24
  6195. RET
  6196. ;------------------------------------------------------------------------
  6197. Int2f:
  6198. pushf
  6199. if WINNT
  6200. cmp ah,0aeh ; For NT 5.0
  6201. jnz Int2fh16xx
  6202. push ax
  6203. push bx
  6204. mov ax, 4f01h
  6205. xor bx, bx
  6206. int 2fh ;Check active code page
  6207. mov cs:[ActiveCodePage],bx
  6208. cmp cs:[ActiveCodePage], WanSungCP
  6209. jz @f
  6210. and cs:[KbStat],not HanKeyinMode
  6211. pop bx
  6212. pop ax
  6213. jmp Int2fh16xx
  6214. @@:
  6215. or cs:[KbStat],HanKeyinMode
  6216. pop bx
  6217. pop ax
  6218. Int2fh16xx:
  6219. endif
  6220. cmp ah,16h
  6221. jz @f
  6222. popf
  6223. jmp cs:[OldInt2f]
  6224. @@:
  6225. call cs:[OldInt2f]
  6226. cmp ax,1605h
  6227. jnz Int2fh1606
  6228. test dx,1
  6229. jnz @f
  6230. mov cs:[IDPSeg],cs
  6231. mov cs:[Iseg],cs
  6232. mov word ptr cs:[SISNext],bx
  6233. mov word ptr cs:[SISNext+2],es
  6234. mov bx,offset SIS
  6235. push cs
  6236. pop es
  6237. @@:
  6238. iret
  6239. Int2fh1606:
  6240. cmp ax,1606h
  6241. jnz @f
  6242. mov cs:[hWin31Flag],0
  6243. iret
  6244. @@:
  6245. cmp ax,1608h
  6246. jnz @f
  6247. call Int2fh1608
  6248. iret
  6249. @@:
  6250. iret
  6251. Int2fh1608:
  6252. @push ax,bx,di,es
  6253. xor di,di
  6254. mov es,di
  6255. mov ax,1684h
  6256. if WINNT
  6257. mov bx,0065h ; From Win97 mshbios.com
  6258. else
  6259. mov bx,0028h
  6260. endif
  6261. int 2fh
  6262. mov word ptr cs:[VxdAddr],di
  6263. mov word ptr cs:[VxdAddr+2],es
  6264. mov ax,es
  6265. or ax,di
  6266. jz @f
  6267. mov ax,cs
  6268. mov es,ax
  6269. lea bx,cs:[Win31Proc]
  6270. xor ax,ax
  6271. call cs:[VxdAddr]
  6272. cmp ax,0100h
  6273. jb @f
  6274. or cs:[hWin31Flag],ValidVxd
  6275. @@:
  6276. @pop es,di,bx,ax
  6277. ret
  6278. ;------------------------------------------------------------------------
  6279. Win31Proc:
  6280. @push ax,bx,cx,dx,si,di,bp,ds,es
  6281. pushf
  6282. mov ax,cs
  6283. mov ds,ax
  6284. mov es,ax
  6285. cmp dx,0
  6286. jnz extTESet
  6287. TextmodeSet:
  6288. and [hWin31Flag],not FullDosMode
  6289. jmp @f
  6290. GrpSet:
  6291. or al,080h
  6292. int 10h
  6293. jmp Win31ProcRet
  6294. extTESet:
  6295. cmp dx,1
  6296. jnz CmpDx2
  6297. or [hWin31Flag],FullDosMode
  6298. @@:
  6299. mov ah,0fh
  6300. int 10h ; get page #
  6301. mov bl,al
  6302. and bl,01111111b
  6303. call CmpModeVal
  6304. jnz GrpSet
  6305. push ax
  6306. or [KbMisc],RunningHot
  6307. or [KbStat],ReqEnvrChg
  6308. inc [VideoActive]
  6309. call SaveCodeBuffer
  6310. pop ax
  6311. mov ah,00h
  6312. int 10h
  6313. call RestoreCodeBuffer
  6314. dec [VideoActive]
  6315. and [KbStat],not ReqEnvrChg
  6316. and [KbMisc],not RunningHot
  6317. jmp Win31ProcRet
  6318. CmpDx2:
  6319. cmp dx,2
  6320. jnz @f
  6321. or [hWin31Flag],FullDosMode
  6322. jmp Win31ProcRet
  6323. @@:
  6324. cmp dx,3
  6325. jnz Win31ProcRet
  6326. and [hWin31Flag],not FullDosMode
  6327. jmp Win31ProcRet
  6328. Win31ProcRet:
  6329. popf
  6330. @pop es,ds,bp,di,si,dx,cx,bx,ax
  6331. retf
  6332. Set64k:
  6333. @push ax,dx
  6334. test [Card1st],00001100b
  6335. jz @f
  6336. mov dx,03ceh
  6337. mov al,06h
  6338. out dx,al
  6339. inc dx
  6340. in al,dx
  6341. test al,00001100b
  6342. jnz @f
  6343. or al,00000100b
  6344. out dx,al
  6345. @@:
  6346. @pop dx,ax
  6347. ret
  6348. WinMem1:
  6349. push ax
  6350. mov ax,0001
  6351. call [VxdAddr]
  6352. or [hWin31Flag],OnMemReq
  6353. pop ax
  6354. @@:
  6355. ret
  6356. WinMem2:
  6357. test [hWin31Flag],OnMemReq
  6358. jz @f
  6359. push ax
  6360. mov ax,0002
  6361. call [VxdAddr]
  6362. and [hWin31Flag],not OnMemReq
  6363. pop ax
  6364. @@:
  6365. ret
  6366. CmpModeVal:
  6367. cmp bl,2
  6368. jz @f
  6369. cmp bl,3
  6370. jz @f
  6371. cmp bl,7
  6372. @@:
  6373. ret
  6374. ;=======================================================================
  6375. endif ; Hwin31Sw
  6376. public EngFont, VgaService, ChgCode, VideoEnd, HotKeySrv ; for .MAP file
  6377. HotKeySrv:
  6378. INCLUDE DUAL.INC
  6379. EngFont label byte
  6380. ;INCLUDE ENG.PAT
  6381. INCLUDE ascii.inc
  6382. VgaService:
  6383. INCLUDE VGA.INC
  6384. ChgCode:
  6385. INCLUDE CHAB.INC
  6386. VideoEnd label byte
  6387. CODE ENDS
  6388. END
  6389.