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.

1882 lines
57 KiB

  1. ASSUME CS:CODE, DS:CODE, ES:DATA
  2. if WINNT
  3. ;------------------------------------------------------------------------
  4. EgaMAllModeTbl db 7, 40h, 70h, -1
  5. EgaCAllModeTbl db 0, 1, 2, 3, 40h, 70h, 60h, -1
  6. McgaAllModeTbl label byte
  7. VgaAllModeTbl db 0, 1, 2, 3, 7, 40h, 70h
  8. db 60h, -2
  9. EgaModeTbl label byte
  10. db 03h,0*2,03h,0b8h,0b8h,10h,000h,01001000b,25 ; han
  11. dw 0, offset Mode3E,0d0eh
  12. db 83h,4*2,12h,0b8h,0a0h,10h,080h,11001101b,25 ; single
  13. dw (31-18)*64, offset Mode3Ega,0d0eh
  14. db 93h,4*2,12h,000h,0b8h,00h,080h,01000101b,25 ; dual
  15. dw (31-18)*64, offset Mode3Ega,0d0eh
  16. db 07h,0*2,07h,0b0h,0b0h,10h,000h,00001000b,25 ; han
  17. dw 0, offset Mode7,0d0eh
  18. db 87h,3*2,0fh,0b0h,0b8h,10h,080h,10001100b,25 ; single
  19. dw (32-17)*64, offset Mode7Ega,0d0eh
  20. db 97h,3*2,0fh,000h,0b0h,00h,080h,00000100b,25 ; dual
  21. dw (32-17)*64, offset Mode7Ega,0d0eh
  22. db 40h,5*2,12h,000h,0b8h,00h,080h,01100100b,25 ;
  23. dw (24-18)*64, offset Mode40E,2e0fh
  24. db 70h,5*2,0fh,000h,0b0h,00h,080h,00100100b,25 ;
  25. dw (25-17)*64, offset Mode70E,2e0fh
  26. db 60h,6*2,12h,000h,0a0h,00h,080h,01100000b,25 ;
  27. dw (23-18)*64, offset Mode60E,0000h
  28. VgaModeTbl label byte
  29. db 03h,0*2,03h,0b8h,0b8h,10h,000h,01001000b,25 ; han
  30. dw 0, offset Mode23,0d0eh
  31. db 83h,4*2,03h,0b8h,0a0h,10h,080h,11001101b,25 ; single
  32. dw (29-18)*64, offset Mode3V,0d0eh
  33. db 93h,4*2,03h,000h,0b8h,00h,080h,01000101b,25 ; dual
  34. dw (29-18)*64, offset Mode3V,0d0eh
  35. db 07h,0*2,07h,0b0h,0b0h,10h,000h,00001000b,25 ; han
  36. dw 0, offset Mode07,0d0eh
  37. db 87h,3*2,0fh,0b0h,0a8h,10h,080h,10001100b,25 ; single
  38. dw (30-17)*64, offset Mode07V,0d0eh
  39. db 97h,3*2,0fh,000h,0b0h,00h,080h,00000100b,25 ; dual
  40. dw (30-17)*64, offset Mode07V,0d0eh
  41. db 40h,5*2,12h,000h,0b8h,00h,080h,01100100b,25 ;
  42. dw (9-18)*64, offset Mode40,2e0fh
  43. db 70h,5*2,0fh,000h,0b0h,00h,080h,00100100b,25 ;
  44. dw (10-17)*64, offset Mode70,2e0fh
  45. db 60h,6*2,12h,000h,0a0h,00h,080h,01100000b,25 ;
  46. dw (8-18)*64, offset Mode60,0000h
  47. db 11h,6*2,11h,000h,0a0h,00h,0a0h,01100000b,30 ;
  48. dw 0, offset Mode11,0000h
  49. db 12h,6*2,12h,000h,0a0h,00h,0a0h,01100000b,30 ;
  50. dw 0, offset Mode12,0000h
  51. else
  52. ;------------------------------------------------------------------------
  53. EgaMAllModeTbl db 7, 0fh, 40h, 70h, -1
  54. EgaCAllModeTbl db 0, 1, 2, 3, 4, 5, 6, 0dh, 0eh, 10h, 40h, 70h, 60h, -1
  55. McgaAllModeTbl label byte
  56. VgaAllModeTbl db 0, 1, 2, 3, 4, 5, 6, 7, 0dh, 0eh, 0fh, 10h, 40h, 70h
  57. db 60h, 10h, 11h, 12h, 13h, -2
  58. EgaModeTbl label byte
  59. db 03h,0*2,03h,0b8h,0b8h,10h,000h,01001000b,25 ; han
  60. dw 0, offset Mode3E,0d0eh
  61. db 83h,4*2,10h,0b8h,0a0h,10h,080h,11001101b,25 ; single
  62. dw (31-18)*64, offset Mode3Ega,0d0eh
  63. db 93h,4*2,10h,000h,0b8h,00h,080h,01000101b,25 ; dual
  64. dw (31-18)*64, offset Mode3Ega,0d0eh
  65. db 07h,0*2,07h,0b0h,0b0h,10h,000h,00001000b,25 ; han
  66. dw 0, offset Mode7,0d0eh
  67. db 87h,3*2,0fh,0b0h,0b8h,10h,080h,10001100b,25 ; single
  68. dw (32-17)*64, offset Mode7Ega,0d0eh
  69. db 97h,3*2,0fh,000h,0b0h,00h,080h,00000100b,25 ; dual
  70. dw (32-17)*64, offset Mode7Ega,0d0eh
  71. db 40h,5*2,10h,000h,0b8h,00h,080h,01100100b,25 ;
  72. dw (24-18)*64, offset Mode40E,2e0fh
  73. db 70h,5*2,0fh,000h,0b0h,00h,080h,00100100b,25 ;
  74. dw (25-17)*64, offset Mode70E,2e0fh
  75. db 60h,6*2,10h,000h,0a0h,00h,080h,01100000b,25 ;
  76. dw (23-18)*64, offset Mode60E,0000h
  77. VgaModeTbl label byte
  78. db 03h,0*2,03h,0b8h,0b8h,10h,000h,01001000b,25 ; han
  79. dw 0, offset Mode23,0d0eh
  80. db 83h,4*2,10h,0b8h,0a0h,10h,080h,11001101b,25 ; single
  81. dw (29-18)*64, offset Mode3V,0d0eh
  82. db 93h,4*2,10h,000h,0b8h,00h,080h,01000101b,25 ; dual
  83. dw (29-18)*64, offset Mode3V,0d0eh
  84. db 07h,0*2,07h,0b0h,0b0h,10h,000h,00001000b,25 ; han
  85. dw 0, offset Mode07,0d0eh
  86. db 87h,3*2,0fh,0b0h,0a8h,10h,080h,10001100b,25 ; single
  87. dw (30-17)*64, offset Mode07V,0d0eh
  88. db 97h,3*2,0fh,000h,0b0h,00h,080h,00000100b,25 ; dual
  89. dw (30-17)*64, offset Mode07V,0d0eh
  90. db 40h,5*2,10h,000h,0b8h,00h,080h,01100100b,25 ;
  91. dw (9-18)*64, offset Mode40,2e0fh
  92. db 70h,5*2,0fh,000h,0b0h,00h,080h,00100100b,25 ;
  93. dw (10-17)*64, offset Mode70,2e0fh
  94. db 60h,6*2,10h,000h,0a0h,00h,080h,01100000b,25 ;
  95. dw (8-18)*64, offset Mode60,0000h
  96. db 11h,6*2,11h,000h,0a0h,00h,0a0h,01100000b,30 ;
  97. dw 0, offset Mode11,0000h
  98. db 12h,6*2,12h,000h,0a0h,00h,0a0h,01100000b,30 ;
  99. dw 0, offset Mode12,0000h
  100. endif
  101. ;------------------------------------------------------------------------
  102. ModeSetVgaText:
  103. call ClearGrpBuf
  104. if KseVga
  105. test [KseCard],00000001b
  106. jz @f
  107. call ChgParmH2E
  108. @@:
  109. endif ; if KseVga
  110. pushf
  111. call [OldVideo]
  112. if KseVga
  113. test [KseCard],00000001b
  114. jz @f
  115. call ChgParmE2H
  116. @@:
  117. endif ; if KseVga
  118. call LoadEngPattern
  119. jmp short CrtProgram
  120. ModeSetVgaGrp:
  121. call ClearGrpBuf
  122. if WINNT
  123. pushf
  124. call [OldVideo]
  125. call LoadEngPattern
  126. else
  127. mov di,word ptr [HanSavePtr]
  128. add di,[si+sAdjParms]
  129. xchg di,word ptr [HanSavePtr]
  130. pushf
  131. call [OldVideo]
  132. xchg di,word ptr [HanSavePtr]
  133. endif
  134. CrtProgram:
  135. if KseVga
  136. test [KseCard],00000001b
  137. jz @f
  138. call KseVgaKey
  139. @@:
  140. endif ; if KseVga
  141. push si
  142. call OffScreen
  143. mov si,[si+sParms]
  144. mov dx,GrpIndex
  145. mov ah,[si].cMap
  146. mov al,6
  147. out dx,ax
  148. mov dl,(MiscReg AND 0ffh)
  149. mov al,[si].cMisc
  150. out dx,al
  151. mov dl,0d4h
  152. test al,00000001b
  153. jnz @f
  154. mov dl,0b4h
  155. @@:
  156. mov [rAddr6845],dx
  157. add si,cCrtc
  158. mov cx,25
  159. mov ax,0111h
  160. out dx,ax ; release CRTC reg 0-7
  161. xor ah,ah
  162. @@:
  163. lodsb
  164. xchg al,ah
  165. out dx,ax
  166. xchg al,ah
  167. inc ah
  168. loop @b
  169. test [rMiscFlags],00001000b
  170. jnz NoWritePalet ; default palette loading is disable
  171. add dl,0ah-4
  172. in al,dx ; reset F/F
  173. in al,dx ; reset F/F
  174. mov cl,20
  175. xor ah,ah
  176. mov dl,(AttrReg AND 0ffh)
  177. @@:
  178. mov al,ah
  179. out dx,al
  180. lodsb
  181. out dx,al
  182. inc ah
  183. loop @b
  184. mov al,3fh
  185. out dx,al ; enable screen
  186. NoWritePalet:
  187. call OnScreen
  188. pop si
  189. ret
  190. ClearGrpBuf:
  191. test [CurMode],10000000b
  192. jnz @f
  193. cmp [si].sModeId,5*2 ; EGA/VGA mode 40, 70
  194. jnz @f
  195. push ax
  196. push es
  197. les di,[GrpBufAddr]
  198. mov cx,8000h/2
  199. xor ax,ax
  200. rep stosw
  201. pop es
  202. pop ax
  203. @@:
  204. ret
  205. LoadEngPattern:
  206. push es
  207. push si
  208. mov dx,SeqIndex
  209. mov ax,100h ; 0100 synchronous reset
  210. cli
  211. out dx,ax
  212. ; inc al ; 0101 select char clock 8 dot(640x400)
  213. ; out dx,ax
  214. mov ax,402h ; 0402 writes only to map 2
  215. out dx,ax
  216. mov ax,704h ; 0704 sequencial addressing
  217. out dx,ax
  218. mov ax,300h ; 0300 clear syncronous reset
  219. out dx,ax
  220. mov dl,(GrpIndex and 0ffh)
  221. sti
  222. mov ax,204h ; 0204 select map 2 for CPU reads
  223. out dx,ax
  224. mov ax,5 ; 0005 disable odd/even addressing
  225. out dx,ax
  226. inc ax ; 0006 map starts at A000:0000
  227. out dx,ax
  228. mov ax,0a000h
  229. mov es,ax
  230. xor di,di ; es:di = start VRAM addr of CG
  231. push si
  232. mov si,offset EngFont
  233. xor dl,dl
  234. xor ch,ch
  235. @@:
  236. mov cl,16
  237. rep movsb
  238. add di,16
  239. inc dl
  240. jnz @b
  241. pop si
  242. mov si,[si+sParms]
  243. mov dl,(SeqIndex and 0ffh)
  244. mov ax,100h ; 0 synchronous reset
  245. cli
  246. out dx,ax
  247. inc al ; 1
  248. ; mov ah,[si+5]
  249. ; out dx,ax
  250. inc al ; 2
  251. mov ah,[si+6]
  252. out dx,ax
  253. mov al,4 ; 4
  254. mov ah,[si+8]
  255. out dx,ax
  256. mov ax,300h ; 0 clear syncronous reset
  257. out dx,ax
  258. sti
  259. mov dl,(GrpIndex and 0ffh)
  260. mov al,4 ; 4
  261. mov ah,[si+59]
  262. out dx,ax
  263. inc al ; 5
  264. mov ah,[si+60]
  265. out dx,ax
  266. inc al ; 6
  267. mov ah,[si+61]
  268. out dx,ax
  269. pop si
  270. pop es
  271. ret
  272. OnScreen:
  273. if KseVga
  274. test [KseCard],00000001b
  275. jz @f
  276. test cs:[ModeStat],GrpMode
  277. jnz @f
  278. push dx
  279. push ax
  280. mov dx,3c4h
  281. mov al,1
  282. out dx,al
  283. inc dl
  284. in al,dx
  285. and al,11011111b
  286. out dx,al
  287. pop ax
  288. pop dx
  289. @@:
  290. endif ; if KseVga
  291. ret
  292. OffScreen:
  293. if KseVga
  294. test [KseCard],00000001b
  295. jz @f
  296. test cs:[ModeStat],GrpMode
  297. jnz @f
  298. push dx
  299. push ax
  300. mov dx,3c4h
  301. mov al,1
  302. out dx,al
  303. inc dl
  304. in al,dx
  305. or al,21h
  306. out dx,al
  307. pop ax
  308. pop dx
  309. @@:
  310. endif ; if KseVga
  311. ret
  312. ;------------------------------------------------------------------------
  313. ; << DispEngColorMulti >>
  314. ; FUNCTION = english character multi-display in color
  315. ; INPUT : ES:AX = graphics buffer position, CX = counter, BL = attr
  316. ; DS:SI = pattern
  317. ; OUTPUT : none
  318. ; PROTECT : none
  319. ; DispEngColorMulti(BL,CX,DS,SI,ES,AX/-)
  320. ; {
  321. ; if (CX = 1),DispEngColor(BL,DS,SI,ES,DI/-);
  322. ; else
  323. ; if (CX = 0), return;
  324. ; while (CX = 0, CX-)
  325. ; /* save register */
  326. ; DispEngColor(BL,DS,SI,ES,DI/-);
  327. ; /* restore register */
  328. ; /* recalc memory address */
  329. ; }
  330. DispEngColorMulti:
  331. cmp cx,1
  332. jnz @f
  333. call DispEngColor
  334. ret
  335. @@:
  336. jcxz DispEngColorMultiExit
  337. mov dl,Byte Ptr [CurPos]
  338. DispEngColorMultiLoop:
  339. @push ax,bx,cx,dx,si
  340. call DispEngColor
  341. @pop si,dx,cx,bx,ax
  342. inc ax ; AX = DI
  343. inc dl
  344. cmp dl,80
  345. jb @f
  346. xor dl,dl
  347. add ax,80*15
  348. @@:
  349. loop DispEngColorMultiLoop
  350. DispEngColorMultiExit:
  351. ret
  352. ;------------------------------------------------------------------------
  353. ; << DispEngColorXorMulti >>
  354. ; FUNCTION = english character multi-display in color ( XOR )
  355. ; INPUT : ES:AX = graphics buffer position, CX = counter, BL = attr
  356. ; DS:SI = pattern
  357. ; OUTPUT : none
  358. ; PROTECT : none
  359. ; DispEngColorXorMulti(BL,CX,DS,SI,ES,AX/-)
  360. ; {
  361. ; if (CX = 1),DispEngColorXor(BL,DS,SI,ES,DI/-);
  362. ; else
  363. ; if (CX = 0), return;
  364. ; while (CX = 0, CX-)
  365. ; /* save register */
  366. ; DispEngColorXor(BL,DS,SI,ES,DI/-);
  367. ; /* restore register */
  368. ; /* recalc memory address */
  369. ; }
  370. DispEngColorXorMulti:
  371. cmp cx,1
  372. jnz @f
  373. call DispEngColorXor
  374. ret
  375. @@:
  376. jcxz DispEngColorXorMultiExit
  377. mov dl,Byte Ptr [CurPos]
  378. DispEngColorXorMultiLoop:
  379. @push ax,bx,cx,dx,si
  380. call DispEngColorXor
  381. @pop si,dx,cx,bx,ax
  382. inc ax ; AX = DI
  383. inc dl
  384. cmp dl,80
  385. jb @f
  386. xor dl,dl
  387. add ax,80*15
  388. @@:
  389. loop DispEngColorXorMultiLoop
  390. DispEngColorXorMultiExit:
  391. ret
  392. CheckHwScr:
  393. mov di,ax
  394. test cs:[ModeStat],HwScroll
  395. jz @f
  396. call GetCrtStartAddr
  397. add di,ax
  398. cmp di,80*16*25
  399. jb @f
  400. sub di,80*16*25
  401. @@:
  402. ret
  403. ;------------------------------------------------------------------------
  404. ; << DispEngColor >>
  405. ; FUNCTION = Font Image Display Routine for One Byte Font
  406. ; INPUT ES:AX = Video RAM Segment:Offset
  407. ; DS:SI = Font Data Segment:Offset
  408. ; BL = Attribute
  409. ; OUTPUT : none
  410. ; PROTECT : none
  411. ;
  412. ; DispEngColor(BL,DS,SI,ES,AX/-) /* HwScroll */
  413. DispEngColor:
  414. call CheckHwScr
  415. test cs:[Card1st],00000100b
  416. jnz DispEngEgaColor
  417. CLI
  418. MOV DX,SeqIndex ; Sequencer Register
  419. MOV AX,0F02h ; All Color Plane Enable
  420. OUT DX,AX
  421. MOV DX,GrpIndex ; Graphic Controller
  422. MOV AX,0
  423. OUT DX,AX
  424. TEST CS:[ModeStat],GrpMode
  425. JZ EngColorBackground
  426. ; Graphic Mode Only
  427. MOV AX,0305h ; Write Mode 3 (VGA Only)
  428. OUT DX,AX
  429. MOV AH,0FFh
  430. MOV ES:[DI],AH
  431. JMP short EngColorGraphicAttr
  432. EngColorBackground:
  433. MOV AX,0205h ; Write Mode 2
  434. OUT DX,AX
  435. CALL MakeEngAttr ; BL = Attr, AL = Background Attr Return
  436. ; MOV AH,AL
  437. MOV ES:[DI],AL
  438. ;English Color Foreround
  439. MOV AX,0305h ; Set Write Mode 2, Read Mode 0
  440. OUT DX,AX ; Graphic Mode Register
  441. EngColorGraphicAttr:
  442. MOV AH,ES:[DI] ; Set Latches From VRAM
  443. MOV AL,0 ; Set/Reset Register
  444. MOV AH,BL ; Character Attribute Value
  445. OUT DX,AX
  446. MOV BX,(50h-1)
  447. mov cx,16
  448. DispEngColorLoop:
  449. MOVSB
  450. ADD DI,BX
  451. LOOP DispEngColorLoop
  452. ; Reset Bit Mask Register
  453. DispHEColorRet:
  454. MOV AX,0FF08h ; Pixel Mask All Enable
  455. OUT DX,AX
  456. MOV AX,005h ; Graphic Mode = 0
  457. ; test [Win31Flag],SetExtTE
  458. ; JZ @F
  459. ; MOV AH,01H
  460. ;@@:
  461. OUT DX,AX
  462. MOV AX,1
  463. OUT DX,AX ; All Disable Set/Reset Register
  464. MOV AX,0
  465. OUT DX,AX ; Clear Set/Reset Value
  466. STI
  467. RET
  468. DispEngEgaColor:
  469. call MakeEngAttr
  470. mov ah,al
  471. TEST CS:[ModeStat],GrpMode
  472. JZ @f
  473. xor ah,ah ; background color in graphics mode
  474. @@:
  475. mov dx,GrpIndex ; grp ctrl index register
  476. mov al,5 ; mode register
  477. out dx,al
  478. inc dx ; grp ctrl data register(=3CFh)
  479. mov al,2 ; write mode 2
  480. out dx,al
  481. mov al,ah
  482. mov cx,16 ; set repeat counter
  483. mov dx,(80-1)
  484. mov bp,di
  485. VgaWriteEngSingleBgLp:
  486. stosb ; clear 1st scan line
  487. add di,dx ; next VRAM addr
  488. loop VgaWriteEngSingleBgLp
  489. mov di,bp
  490. VgaWriteEngSingleFg:
  491. call GetAddrGrp
  492. mov bx,(80-1)
  493. VgaGetFontEngSingleLp:
  494. lodsb
  495. out dx,al
  496. stosb ; write 1st pattern
  497. add di,bx ; next VRAM addr
  498. loop VgaGetFontEngSingleLp
  499. mov al,-1 ; default config (enable all bits)
  500. out dx,al
  501. dec dx ; get addr of grp ctrl index register
  502. mov ax,1 ; get addr of grp ctrl data register
  503. out dx,ax ; disable the set/reset register
  504. xor ax,ax ; set/reset register
  505. out dx,ax ; clear set/reset register value
  506. ret
  507. GetAddrGrp:
  508. mov dx,GrpIndex ; get addr of grp ctrl index register
  509. mov ax,5 ; get addr of grp ctrl data register
  510. out dx,ax ; write mode 0
  511. GetAddrGrpP:
  512. mov ax,0ff01h ; get addr of grp ctrl data register
  513. out dx,ax ; load enable set/reset value into reg
  514. xor al,al ; set/reset register
  515. mov ah,bl ; load set/reset value into reg
  516. out dx,ax
  517. mov al,es:[di] ; set latch register
  518. mov dx,GrpIndex ; get addr of grp ctrl index register
  519. mov al,8 ; bit mask register
  520. out dx,al
  521. inc dx
  522. mov cx,16 ; set counter
  523. ret
  524. ;------------------------------------------------------------------------
  525. ; << DispEngColorXor >>
  526. ; FUNCTION = Font Image Display Routine for One Byte Font
  527. ; INPUT ES:AX = Video RAM Segment:Offset
  528. ; DS:SI = Font Data Segment:Offset
  529. ; BL = Attribute
  530. ; OUTPUT : none
  531. ; PROTECT : none
  532. ;
  533. ; DispEngColorXor(BL,DS,SI,ES,AX/-)
  534. @@:
  535. jmp DispEngColor
  536. DispEngColorXor:
  537. test bl,80h
  538. jz @b
  539. call CheckHwScr
  540. CALL MakeEngAttr ; BL = Attr, AL = Background Attr Return
  541. mov dx,GrpIndex ; get addr of grp ctrl index register
  542. mov ax,5 ; get addr of grp ctrl data register
  543. out dx,ax ; write mode 0
  544. mov ax,1803h ; get addr of grp ctrl data register
  545. out dx,ax ; data XORed with latch contents
  546. mov ax,0ff01h ; get addr of grp ctrl data register
  547. out dx,ax ; load enable set/reset value into reg
  548. xor al,al ; set/reset register
  549. mov ah,bl ; load set/reset value into reg
  550. out dx,ax
  551. mov dx,GrpIndex ; get addr of grp ctrl index register
  552. mov al,8 ; bit mask register
  553. out dx,al
  554. inc dx
  555. mov bx,(80-1) ; for addressing next VRAM addr
  556. mov cx,16 ; set counter
  557. VgaWriteEngSingleXorLp:
  558. lodsb
  559. out dx,al
  560. mov al,es:[di] ; set latch register
  561. stosb ; write 1st pattern
  562. add di,bx ; next VRAM addr
  563. loop VgaWriteEngSingleXorLp
  564. VgaWriteSingleFg16Xor:
  565. dec dx ; get addr of grp ctrl index register
  566. mov ax,3 ; get addr of grp ctrl data register
  567. out dx,ax ; data unmodified (off XORing)
  568. mov al,8 ; bit mask register
  569. out dx,al
  570. inc dx
  571. mov al,-1 ; default config (enable all bits)
  572. out dx,al
  573. dec dx ; get addr of grp ctrl index register
  574. mov ax,1 ; get addr of grp ctrl data register
  575. out dx,ax ; disable the set/reset register
  576. xor ax,ax ; set/reset register
  577. out dx,ax ; clear set/reset register value
  578. ret
  579. ;------------------------------------------------------------------------
  580. ; << DispHanColor >>
  581. ; FUNCTION = Font Image Display Routine for Double Byte Font
  582. ; INPUT ES:AX = Video RAM Segment:Offset
  583. ; DS:SI = Font Data Segment:Offset
  584. ; BL = Attribute
  585. ; OUTPUT : none
  586. ; PROTECT : none
  587. ; DispHanColor(BL,DS,SI,ES,AX/-) /* HwScroll */
  588. DispHanColor:
  589. call CheckHwScr
  590. test cs:[Card1st],00000100b
  591. jnz DispHanEgaColor
  592. CLI
  593. MOV DX,SeqIndex ; Sequencer Register
  594. MOV AX,0F02h ; All Color Plane Enable
  595. OUT DX,AX
  596. MOV DX,GrpIndex ; Graphic Controller
  597. MOV AX,0
  598. OUT DX,AX
  599. TEST CS:[ModeStat],GrpMode
  600. JZ HanColorBackground
  601. ; Graphic Mode Only
  602. MOV AX,0305h ; Write Mode 3 (VGA Only)
  603. OUT DX,AX
  604. MOV AH,0FFh
  605. MOV ES:[DI],AH
  606. JMP short HanColorGraphicAttr
  607. HanColorBackground:
  608. MOV AX,0205h ; Write Mode 2
  609. OUT DX,AX
  610. CALL MakeHanAttr ; BL = Attr, AL = Background Attr Return
  611. MOV AH,AL
  612. MOV ES:[DI],AH
  613. ;Hanguel Color Foreround
  614. MOV AX,0305h ; Set Write Mode 3, Read Mode 0 (VGA Only)
  615. OUT DX,AX ; Graphic Mode Register
  616. HanColorGraphicAttr:
  617. MOV AH,ES:[DI] ; Set Latches From VRAM
  618. MOV AL,0 ; Set/Reset Register
  619. MOV AH,BL ; Character Attribute Value
  620. OUT DX,AX
  621. MOV BX,(50h-2)
  622. mov cx,16
  623. DispHanColorLoop:
  624. MOVSW
  625. ADD DI,BX
  626. LOOP DispHanColorLoop
  627. ; Reset Bit Mask Register
  628. jmp DispHEColorRet
  629. DispHanEgaColor:
  630. call MakeHanAttr
  631. mov ah,al
  632. TEST CS:[ModeStat],GrpMode
  633. JZ @f
  634. xor ah,ah ; background color in graphics mode
  635. @@:
  636. mov dx,GrpIndex ; grp ctrl index register
  637. mov al,5 ; mode register
  638. out dx,al
  639. inc dx ; grp ctrl data register(=3CFh)
  640. mov al,2 ; write mode 2
  641. out dx,al
  642. mov al,ah
  643. mov cx,16 ; set repeat counter
  644. mov dx,(80-2)
  645. mov bp,di
  646. VgaWriteHanSingleBgLp:
  647. stosb ; clear 1st scan line
  648. stosb ; clear 1st scan line
  649. add di,dx ; next VRAM addr
  650. loop VgaWriteHanSingleBgLp
  651. mov di,bp
  652. VgaWriteHanSingleFg:
  653. call GetAddrGrp
  654. mov bx,(80-2)
  655. VgaGetFontHanSingleLp:
  656. lodsb
  657. out dx,al
  658. stosb ; write 1st pattern
  659. lodsb
  660. out dx,al
  661. stosb
  662. add di,bx ; next VRAM addr
  663. loop VgaGetFontHanSingleLp
  664. mov al,-1 ; default config (enable all bits)
  665. out dx,al
  666. dec dx ; get addr of grp ctrl index register
  667. mov ax,1 ; get addr of grp ctrl data register
  668. out dx,ax ; disable the set/reset register
  669. xor ax,ax ; set/reset register
  670. out dx,ax ; clear set/reset register value
  671. ret
  672. ;------------------------------------------------------------------------
  673. ; << DispHanColorXor >>
  674. ; FUNCTION = Font Image Display Routine for Double Byte Font
  675. ; INPUT ES:AX = Video RAM Segment:Offset
  676. ; DS:SI = Font Data Segment:Offset
  677. ; BL = Attribute
  678. ; OUTPUT : none
  679. ; PROTECT : none
  680. ; DispHanColorXor(BL,DS,SI,ES,AX/-)
  681. @@:
  682. jmp DispHanColor
  683. DispHanColorXor:
  684. test bl,80h
  685. jz @b
  686. mov di,ax
  687. test cs:[ModeStat],HwScroll
  688. jz @f
  689. call GetCrtStartAddr
  690. add di,ax
  691. cmp di,80*16*25
  692. jb @f
  693. sub di,80*16*25
  694. @@:
  695. CALL MakeHanAttr ; BL = Attr, AL = Background Attr Return
  696. mov dx,GrpIndex ; get addr of grp ctrl index register
  697. mov ax,5 ; get addr of grp ctrl data register
  698. out dx,ax ; write mode 0
  699. mov ax,1803h ; get addr of grp ctrl data register
  700. out dx,ax ; data XORed with latch contents
  701. call GetAddrGrpP
  702. mov bx,(80-2) ; for addressing next VRAM addr
  703. VGFHSLp:
  704. lodsb
  705. out dx,al
  706. mov al,es:[di] ; set latch register
  707. stosb ; write 1st pattern
  708. lodsb
  709. out dx,al
  710. mov al,es:[di] ; set latch register
  711. stosb
  712. add di,bx ; next VRAM addr
  713. loop VGFHSLp
  714. dec dx ; get addr of grp ctrl index register
  715. mov ax,3 ; get addr of grp ctrl data register
  716. out dx,ax ; data unmodified (off XORing)
  717. mov al,8 ; bit mask register
  718. out dx,al
  719. inc dx
  720. mov al,-1 ; default config (enable all bits)
  721. out dx,al
  722. dec dx ; get addr of grp ctrl index register
  723. mov ax,1 ; get addr of grp ctrl data register
  724. out dx,ax ; disable the set/reset register
  725. xor ax,ax ; set/reset register
  726. out dx,ax ; clear set/reset register value
  727. ret
  728. ;------------------------------------------------------------------------
  729. ; << VgaGrpScroll >>
  730. ; FUNCTION = Color Graphic Screen Scroll
  731. ; INPUT : BH = Blank line Attr
  732. ; : BL = Scroll Line count ( Y' )
  733. ; : CX = Row : Column
  734. ; : DH = Move count ( Y )
  735. ; : DL = Window width ( X )
  736. ; : BP = Next scan line
  737. ; OUTPUT : none
  738. ; PROTECT : none
  739. ; VgaGrpScroll(BX,CX,DX/-)
  740. VgaGrpScroll:
  741. push bp
  742. mov bp,cx
  743. xchg cx,dx
  744. mov ax,80*16
  745. mov dl,dh
  746. xor dh,dh
  747. mul dx
  748. mov dx,bp
  749. xor dh,dh
  750. add ax,dx
  751. les di,[GrpBufAddr]
  752. mov dl,bl
  753. or dl,dl
  754. jns @f
  755. add di,80*15
  756. @@:
  757. add di,ax
  758. mov si,di
  759. mov dx,bp
  760. mov bp,80*16
  761. mov al,bl
  762. xor ah,ah
  763. mul bp
  764. add si,ax
  765. call HwScrollAdjust
  766. pop bp
  767. sar bp,1
  768. xchg cx,dx
  769. mov cx,dx ; save DX
  770. mov dx,SeqIndex ; sequencer
  771. mov ax,0f02h ; all plane enable
  772. out dx,ax
  773. mov dl,0ceh ; 3CEh = Graphic controller
  774. mov ax,0003h ; function clear
  775. out dx,ax
  776. mov ax,0105h ; write mode 01, Latch write
  777. out dx,ax
  778. mov dx,cx ; restore DX
  779. mov al,bh
  780. test [ModeStat],GrpMode
  781. jnz RunGrp
  782. cmp [ModeId],2*3 ; EGA/VGA mode 7
  783. jnz @f
  784. mov al,0
  785. test bh,01110111B
  786. jz @f
  787. mov al,1
  788. test bh,01111000B
  789. jz @f
  790. mov al,bh
  791. and al,01111000B
  792. cmp al,00001000B
  793. mov al,4
  794. jz @f
  795. mov al,10h
  796. test bh,00000111B
  797. jz @f
  798. mov al,11h
  799. test bh,00001000B
  800. jz @f
  801. mov al,40h
  802. @@:
  803. shr al,1
  804. shr al,1
  805. shr al,1
  806. shr al,1
  807. RunGrp:
  808. mov cx,es
  809. mov ds,cx ; ES = DS
  810. mov cl,bl
  811. or cl,cl
  812. jns @f
  813. neg bl
  814. @@:
  815. xor ch,ch
  816. or dh,dh
  817. mov bh,dl
  818. jz ColorFill
  819. mov dl,dh
  820. xor dh,dh
  821. shl dx,1
  822. shl dx,1
  823. shl dx,1
  824. shl dx,1
  825. @@:
  826. call HwScrollAdjustI
  827. mov cl,bh
  828. rep movsb
  829. add si,bp
  830. add di,bp
  831. dec dx
  832. jnz @b
  833. ColorFill:
  834. mov dl,bh
  835. xor bh,bh
  836. mov cl,4
  837. shl bx,cl
  838. mov si,ax
  839. mov cx,dx
  840. mov dx,GrpIndex ; graphic controller
  841. mov ax,0205h ; write mode 2
  842. out dx,ax
  843. mov dx,cx
  844. mov ax,si
  845. xor ch,ch
  846. ColorClearLoop:
  847. call HwScrollAdjustDi
  848. mov cl,dl ; window width
  849. rep stosb
  850. add di,bp
  851. dec bx
  852. jnz ColorClearLoop
  853. mov dx,GrpIndex ; graphic controller
  854. mov ax,0005h ; write mode 0
  855. out dx,ax
  856. ret
  857. HwScrollAdjustI:
  858. test cs:[ModeStat],HwScroll
  859. jz VgaGrpScrollLpDo
  860. cmp si,80*16*26
  861. jbe @f
  862. add si,80*16*25
  863. @@:
  864. cmp si,80*16*25
  865. jb HwScrollAdjustDi
  866. sub si,80*16*25
  867. HwScrollAdjustDi:
  868. test cs:[ModeStat],HwScroll
  869. jz VgaGrpScrollLpDo
  870. cmp di,80*16*26
  871. jbe @f
  872. add di,80*16*25
  873. @@:
  874. cmp di,80*16*25
  875. jb VgaGrpScrollLpDo
  876. sub di,80*16*25
  877. VgaGrpScrollLpDo:
  878. ret
  879. HwScrollAdjust:
  880. push ax
  881. test cs:[ModeStat],HwScroll
  882. jz HwScrollAdjustEnd
  883. call GetCrtStartAddr
  884. add si,ax
  885. cmp si,80*16*25
  886. jb @f
  887. sub si,80*16*25
  888. @@:
  889. add di,ax
  890. cmp di,80*16*25
  891. jb HwScrollAdjustEnd
  892. sub di,80*16*25
  893. HwScrollAdjustEnd:
  894. pop ax
  895. ret
  896. ;------------------------------------------------------------------------
  897. ; << VgaWritePixel >>
  898. ; FUNCTION = write pixel
  899. ; INPUT : AL,CX,DX
  900. ; OUTPUT : none
  901. ; PROTECT : none
  902. ; VgaWritePixel(AL,CX,DX/-)
  903. VgaWritePixel:
  904. mov bl,al
  905. call CalcPixelColor
  906. WriteDotColorDo:
  907. cli
  908. mov dx,GrpIndex
  909. or bl,bl
  910. jns @f ; jump if MSB = 0
  911. mov ax,1803h
  912. out dx,ax
  913. @@:
  914. xor al,al
  915. mov ah,bl
  916. out dx,ax
  917. mov ax,0ff01h
  918. out dx,ax
  919. mov al,8
  920. mov ah,ch
  921. out dx,ax
  922. mov ah,es:[di]
  923. stosb
  924. mov ah,-1
  925. out dx,ax
  926. mov ax,3
  927. out dx,ax
  928. xor ax,ax
  929. out dx,ax
  930. inc ax
  931. out dx,ax
  932. sti
  933. ret
  934. CalcPixelColor:
  935. mov ax,80
  936. mul dx
  937. mov dx,cx
  938. shr cx,1
  939. shr cx,1
  940. shr cx,1
  941. add ax,cx
  942. and dl,7
  943. mov cx,dx
  944. mov ch,10000000b
  945. shr ch,cl
  946. les di,[GrpBufAddr]
  947. add di,ax
  948. ret
  949. ;------------------------------------------------------------------------
  950. ; << VgaReadPixel >>
  951. ; FUNCTION = read pixel
  952. ; INPUT : BH,CX,DX
  953. ; OUTPUT : al = color
  954. ; PROTECT : none
  955. ; VgaReadPixel(BH,CX,DX/-)
  956. ;
  957. VgaReadPixel:
  958. call CalcPixelColor
  959. ReadDotColorDo:
  960. cli
  961. mov al,7
  962. sub al,cl
  963. mov cl,al
  964. mov dx,GrpIndex
  965. mov ax,4
  966. out dx,ax
  967. mov bl,es:[di]
  968. and bl,ch
  969. shr bl,cl
  970. mov bh,bl
  971. inc ah
  972. out dx,ax
  973. mov bl,es:[di]
  974. and bl,ch
  975. shr bl,cl
  976. shl bl,1
  977. or bh,bl
  978. inc ah
  979. out dx,ax
  980. mov bl,es:[di]
  981. and bl,ch
  982. shr bl,cl
  983. shl bl,1
  984. shl bl,1
  985. or bh,bl
  986. inc ah
  987. out dx,ax
  988. mov bl,es:[di]
  989. and bl,ch
  990. shr bl,cl
  991. shl bl,1
  992. shl bl,1
  993. shl bl,1
  994. xor ah,ah
  995. out dx,ax
  996. mov al,bl
  997. or al,bh
  998. sti
  999. ret
  1000. ;------------------------------------------------------------------------
  1001. ; << VgaGrpBlock >>
  1002. ; FUNCTION = Color Graphic Screen Block Move/Copy
  1003. ; INPUT : DI = Target ( BX )
  1004. ; SI = Source ( CX )
  1005. ; DL = Window weidth ( X )
  1006. ; DH = Window height ( Y )
  1007. ; BP = Screen width - Window width ( X' )
  1008. ; BH:BL = Move/Copy : Attr
  1009. ; OUTPUT : none
  1010. ; PROTECT : none
  1011. ; VgaGrpBlock(bx,dx,bp/-)
  1012. VgaGrpBlock :
  1013. pop bx
  1014. mov es,dx
  1015. pop di
  1016. mov ax,di
  1017. mov al,ah
  1018. xor ah,ah
  1019. mov dx,80*16
  1020. mul dx
  1021. and di,0ffh
  1022. add di,ax
  1023. pop si
  1024. mov ax,si
  1025. mov al,ah
  1026. xor ah,ah
  1027. mov dx,80*16
  1028. mul dx
  1029. and si,0ffh
  1030. add si,ax ; DI
  1031. sar bp,1 ; make byte length
  1032. test bh,40h ; jump if positive value
  1033. jnz @f
  1034. add di,80*15
  1035. add si,80*15
  1036. @@:
  1037. call HwScrollAdjust
  1038. lds ax,[GrpBufAddr]
  1039. mov dx,GrpIndex
  1040. mov ax,105h
  1041. out dx,ax
  1042. mov dx,es
  1043. mov al,dh
  1044. mov dh,16
  1045. mul dh ; AX = y
  1046. mov cs:[BlockAdj],ax
  1047. mov dx,es
  1048. mov ax,ds
  1049. mov es,ax
  1050. xchg bl,bh
  1051. mov al,bh
  1052. cmp cs:[ModeId],2*3 ; EGA/VGA mode 7
  1053. jnz @f
  1054. mov al,0
  1055. test bh,01110111B
  1056. jz @f
  1057. mov al,1
  1058. test bh,01111000B
  1059. jz @f
  1060. mov al,bh
  1061. and al,01111000B
  1062. cmp al,00001000B
  1063. mov al,4
  1064. jz @f
  1065. mov al,10h
  1066. test bh,00000111B
  1067. jz @f
  1068. mov al,11h
  1069. test bh,00001000B
  1070. jz @f
  1071. mov al,40h
  1072. @@:
  1073. shr al,1
  1074. shr al,1
  1075. shr al,1
  1076. shr al,1
  1077. xchg ax,bx
  1078. mov bh,al
  1079. xor ch,ch
  1080. @@:
  1081. call HwScrollAdjustI
  1082. mov cl,dl
  1083. test bh,1
  1084. jz BlockGrpMove2
  1085. rep movsb
  1086. jmp short BlockGrpMove2End
  1087. BlockGrpMove2:
  1088. push dx
  1089. mov dx,GrpIndex
  1090. BlockGrpMove2Lp:
  1091. mov al,[si]
  1092. stosb
  1093. mov ax,205h
  1094. out dx,ax
  1095. xchg si,di
  1096. mov al,bl
  1097. stosb
  1098. xchg si,di
  1099. mov ax,105h
  1100. out dx,ax
  1101. loop BlockGrpMove2Lp
  1102. pop dx
  1103. BlockGrpMove2End:
  1104. add di,bp
  1105. add si,bp
  1106. dec cs:[BlockAdj]
  1107. jnz @b
  1108. mov dx,GrpIndex
  1109. mov ax,5 ; write mode 0
  1110. out dx,ax
  1111. mov ax,cs
  1112. mov ds,ax
  1113. ret
  1114. ;------------------------------------------------------------------------
  1115. ; << FullScrollColor >>
  1116. ;
  1117. ; FUNCTION = color buffer full scroll
  1118. ; INPUT : ES:DI = graphics buffer, BL = attribute
  1119. ; OUTPUT : none
  1120. ; PROTECT : none
  1121. ;
  1122. ; FullScrollColor(ES,DI,BL/-)
  1123. ;
  1124. FullScrollColor:
  1125. mov dx,GrpIndex ; get addr of grp ctrl index register
  1126. test cs:[ModeStat],HwScroll
  1127. jnz HwFullScrollDo
  1128. mov ax,es
  1129. mov ds,ax
  1130. mov si,di
  1131. add si,80*16
  1132. mov ax,105h
  1133. out dx,ax
  1134. mov cx,24*16*80
  1135. cmp cs:[MaxRows],25
  1136. jbe @f
  1137. mov cx,29*16*80
  1138. @@:
  1139. rep movsb
  1140. FullScrollFill:
  1141. mov ax,205h
  1142. out dx,ax
  1143. mov cx,16*80
  1144. xor al,al
  1145. test cs:[ModeStat],GrpMode
  1146. jnz @f
  1147. mov al,bl
  1148. shr al,1
  1149. shr al,1
  1150. shr al,1
  1151. shr al,1
  1152. @@:
  1153. rep stosb
  1154. mov ax,5
  1155. out dx,ax
  1156. ret
  1157. HwFullScrollDo:
  1158. call GetCrtStartAddr
  1159. mov di,ax
  1160. add ax,80*16
  1161. cmp ax,80*16*25
  1162. jb @f
  1163. xor ax,ax
  1164. @@:
  1165. call HwFullScroll
  1166. mov dl,(GrpIndex AND 0ffh)
  1167. jmp short FullScrollFill
  1168. HwFullScroll:
  1169. mov dx,3dah
  1170. mov cx,ax
  1171. cli
  1172. @@:
  1173. in al,dx
  1174. test al,8
  1175. jnz @b
  1176. @@:
  1177. in al,dx
  1178. test al,8
  1179. jz @b
  1180. mov ax,cx
  1181. or ax,ax
  1182. jz HwFullScroll2
  1183. mov dl,0d4h
  1184. mov al,0ch
  1185. out dx,ax
  1186. mov ax,cx
  1187. xor dx,dx
  1188. mov cx,80
  1189. div cx
  1190. mov cx,16*25-1
  1191. sub cx,ax
  1192. mov dx,3d4h
  1193. mov ah,cl
  1194. mov al,18h
  1195. out dx,ax ; set scan lines - bit 0-7
  1196. mov ax,1f07h
  1197. test ch,00000001b
  1198. jnz @f
  1199. mov ah,0fh
  1200. @@:
  1201. out dx,ax ; set scan lines - bit 8
  1202. mov ax,9
  1203. out dx,ax ; set scan lines - bit 9
  1204. sti
  1205. ret
  1206. HwFullScroll2:
  1207. mov dl,0d4h
  1208. mov ax,0ch
  1209. out dx,ax
  1210. mov dl,0dah
  1211. @@:
  1212. in al,dx
  1213. test al,8
  1214. jnz @b
  1215. @@:
  1216. in al,dx
  1217. test al,8
  1218. jz @b
  1219. mov dl,0d4h
  1220. mov ax,9
  1221. out dx,ax ; set scan lines - bit 9
  1222. mov ax,1f07h
  1223. out dx,ax ; set scan lines - bit 8
  1224. mov ax,8f18h
  1225. out dx,ax ; set scan lines - bit 0 - 7
  1226. sti
  1227. ret
  1228. GetCrtStartAddr:
  1229. pushf
  1230. cli
  1231. push dx
  1232. push bx
  1233. mov dx,3d4h
  1234. in al,dx
  1235. mov bl,al
  1236. mov al,0ch
  1237. out dx,al
  1238. inc dx
  1239. in al,dx
  1240. mov ah,al
  1241. xor al,al
  1242. xchg bx,ax
  1243. dec dx
  1244. out dx,al
  1245. xchg bx,ax
  1246. pop bx
  1247. pop dx
  1248. popf
  1249. ret
  1250. ;------------------------------------------------------------------------
  1251. ; << ToggleColorCursor >>
  1252. ; FUNCTION = color cursor toggle
  1253. ; INPUT : none
  1254. ; OUTPUT : none
  1255. ; PROTECT : DS,SI
  1256. ; ToggleColorCursor(-/-)
  1257. ToggleColorCursor:
  1258. mov cx,[rCurType] ; BIOS Cursor Type Information Read
  1259. test [rInfo],00000001b
  1260. jnz @f
  1261. cmp [ModeId],3*2 ; 3 - text emulation mode 7, EGA/VGA
  1262. jz @f
  1263. shl cx,1 ; Cursor Mode * 2 ( COLOR )
  1264. add cx,201h
  1265. @@:
  1266. cmp ch,20h ; Check Not Display Cursor Type
  1267. jb @f
  1268. ret
  1269. @@:
  1270. and cx,0f0fh ; Get Low 4 Bits
  1271. sub cl,ch
  1272. jnc @f
  1273. ret
  1274. @@:
  1275. cli
  1276. inc cl
  1277. mov ax,[OrgCurType]
  1278. mov dx,[OrgCurPos]
  1279. test [CursorStat],CursorOn
  1280. jnz @f
  1281. mov bl,[CurPage]
  1282. xor bh,bh
  1283. shl bx,1
  1284. mov dx,[bx+rCurPos]
  1285. mov [OrgCurPos],dx
  1286. mov ax,cx
  1287. @@:
  1288. cmp dl,80
  1289. jae ToggleColorCursorExit
  1290. cmp dh,[MaxRows]
  1291. jae ToggleColorCursorExit
  1292. mov [OrgCurType],ax
  1293. mov cx,ax
  1294. les di,[GrpBufAddr]
  1295. mov ax,80
  1296. mul dh
  1297. shl ax,1
  1298. shl ax,1
  1299. shl ax,1
  1300. shl ax,1
  1301. xor dh,dh
  1302. add di,dx
  1303. add di,ax ; 80 * 16 * Rows +Cols
  1304. mov ax,80
  1305. mul ch ; Row * 80
  1306. add di,ax
  1307. test cs:[ModeStat],HwScroll
  1308. jz @f
  1309. call GetCrtStartAddr
  1310. add di,ax
  1311. cmp di,80*16*25
  1312. jb @f
  1313. sub di,80*16*25
  1314. @@:
  1315. mov dx,SeqIndex ; EGA/VGA Sequence Register
  1316. mov ax,702h ; Color Plan Write Enable Register
  1317. out dx,ax ; Enable Plan 0,1,2
  1318. mov dx,GrpIndex ; EGA/VGA Graphic Controller
  1319. mov ax,1803h ; Write Data XOR & None Rotation
  1320. out dx,ax
  1321. mov al,0FFh ; Mask Patten Value
  1322. xor ch,ch ; Clear CH
  1323. @@:
  1324. mov ah,es:[di] ; Latched Data Load
  1325. mov es:[di],al ; XOR & Mask
  1326. add di,80
  1327. loop @b ; CX = Counter Value = Low - High
  1328. mov ax,3 ; Write Data Unmodified & None Rotation
  1329. out dx,ax
  1330. mov ax,0F02h ; All Plan Enable
  1331. mov dx,SeqIndex ; EGA/VGA Sequence Register
  1332. out dx,ax
  1333. xor [CursorStat],CursorOn
  1334. ToggleColorCursorExit:
  1335. sti
  1336. ret
  1337. ;------------------------------------------------------------------------
  1338. public HanSavePtr, VideoParmsTbl, Mode2E, Mode3E, Mode23, Mode7, Mode07
  1339. public Mode3V, Mode07V, Mode3Ega, Mode7Ega
  1340. VideoParmsTbl label byte
  1341. db 64*2 dup(?) ; 0, 1
  1342. Mode2 db 64 dup(?) ; 2
  1343. Mode3 db 64*4 dup(?) ; 3, 4, 5, 6
  1344. Mode7 db 64 dup(?) ; 7
  1345. Mode60 label byte ; 8
  1346. db 80,24,16,0,080h ,1,0Fh,0,6 ,063h ; gen, seq, misc
  1347. db 5Fh,4Fh,50h,82h,54h,80h,0BFh,1Fh,0,40h,0,0,0,0,0,0 ; crtc
  1348. db 9Ch,0Eh,8Fh,28h,0FH,96h,0B9h,0E3h,0FFh ; crtc
  1349. db 0,1,2,3,4,5,14h,7,38h,39h,3Ah,3Bh,3Ch,3Dh,3Eh,3Fh ; attr
  1350. db 1,0,0Fh,0 ; attr
  1351. db 0,0,0,0,0,0,5,0Fh,0FFh ; grp
  1352. Mode40 label byte ; 9
  1353. db 80,24,16,0,80h ,1,1,0,6 ,063h
  1354. db 5Fh,4Fh,50h,82h,54h,80h,0BFh,1Fh,0,43h,2EH,0FH,0,0,0,0
  1355. db 9Ch,0Eh,8Fh,28h,0FH,96h,0B9h,0C0h,0FFh
  1356. db 0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 ; normal white
  1357. db 1,0,1,0
  1358. db 0,0,0,0,0,0,0Dh,0,0FFh
  1359. Mode70 label byte ; 10
  1360. db 80,24,16,0,80h ,1,1,0,6 ,062h
  1361. db 5Fh,4Fh,50h,82h,54h,80h,0BFh,1Fh,0,43h,2EH,0FH,0,0,0,0
  1362. db 9Ch,0Eh,8Fh,28h,0FH,96h,0B9h,0C0h,0FFh
  1363. db 0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 ; normal white
  1364. db 1,0,1,0
  1365. db 0,0,0,0,0,0,09h,0,0FFh
  1366. db 64*6 dup(?) ; 11, 12, 13, 14, 15, 16
  1367. ModeFGt64 db 64 dup(?) ; 17
  1368. Mode10Gt64 db 64*3 dup(?) ; 18, 19, 20
  1369. Mode2E db 64 dup(?) ; 21
  1370. Mode3E db 64 dup(?) ; 22 (EGA)
  1371. Mode01 label byte ; 23
  1372. Mode60E label byte ; 23
  1373. db 80,24,16,0,080h ,1,0Fh,0,6 ,0A7h
  1374. db 5Bh,4Fh,53h,37h,52h,00h,09Fh,1Fh,0,0,0DH,0EH,0,0,0,0 ; crtc
  1375. db 90h,2Bh,8Fh,28h,0FH,95h,1Dh,0E3h,0FFh ; crtc
  1376. db 0,1,2,3,4,5,14h,7,38h,39h,3Ah,3Bh,3Ch,3Dh,3Eh,3Fh ; attr
  1377. db 1,0,0Fh,0
  1378. db 0,0,0,0,0,0,5,0Fh,0FFh
  1379. Mode23 label byte ; 24
  1380. Mode40E label byte ; 24
  1381. db 80,24,16,0,80h ,1,1,0,6 ,0A7h
  1382. db 5Bh,4Fh,53h,37h,52h,00h,09Fh,1Fh,0,3,2EH,0FH,0,0,0,0 ; crtc
  1383. db 90h,2Bh,8Fh,28h,0FH,95h,1Dh,0C0h,0FFh ; crtc
  1384. db 0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 ; normal white
  1385. db 1,0,1,0
  1386. db 0,0,0,0,0,0,0Dh,0,0FFh
  1387. Mode07 label byte ; 25
  1388. Mode70E label byte ; 25
  1389. db 80,24,16,0,80h ,1,1,0,6 ,0A6h
  1390. db 5Bh,4Fh,53h,37h,52h,00h,09Fh,1Fh,0,3,2EH,0FH,0,0,0,0 ; crtc
  1391. db 90h,2Bh,8Fh,28h,0FH,95h,1Dh,0C0h,0FFh ; crtc
  1392. db 0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 ; normal white
  1393. db 1,0,1,0
  1394. db 0,0,0,0,0,0,09h,0,0FFh
  1395. Mode11 db 64 dup(?) ; 26
  1396. Mode12 db 64*2 dup(?) ; 27, 28
  1397. ; graphics VGA mode 2, 3, 7
  1398. Mode3V label byte ; 29
  1399. db 80,24,16,0,010h ,1,0Fh,0,6 ,063h ; gen, seq, misc
  1400. db 5Fh,4Fh,50h,82h,54h,80h,0BFh,1Fh,0,40h,0DH,0EH,0,0,0,0; crtc
  1401. db 9Ch,0Eh,8Fh,28h,0FH,96h,0B9h,0E3h,0FFh ; crtc
  1402. db 0,1,2,3,4,5,14h,7,38h,39h,3Ah,3Bh,3Ch,3Dh,3Eh,3Fh ; attr
  1403. db 1,0,0Fh,0 ; attr
  1404. db 0,0,0,0,0,0,1,0Fh,0FFh ; grp
  1405. Mode07V label byte ; 30
  1406. db 80,24,16,0,10h ,1,0Fh,0,6 ,062h
  1407. db 5Fh,4Fh,50h,82h,54h,80h,0BFh,1Fh,0,40h,0DH,0EH,80H,0,0,0
  1408. db 9Ch,0Eh,8Fh,28h,0FH,96h,0B9h,0E3h,0FFh
  1409. db 0,8,0,0,18h,18h,0,0,0,8,0,0,0,8,0,0
  1410. db 03H,0,05H,0
  1411. db 0,0,0,0,0,0,01h,05H,0FFh
  1412. ; graphics EGA mode 2, 3, 7
  1413. Mode3Ega label byte ; 31
  1414. db 80,24,16,0,010h ,1,0Fh,0,6 ,0A7h
  1415. db 5Bh,4Fh,53h,37h,52h,00h,09Fh,1Fh,0,0,0DH,0EH,0,0,0,0 ; crtc
  1416. db 90h,2Bh,8Fh,28h,0FH,95h,1Dh,0E3h,0FFh ; crtc
  1417. db 0,1,2,3,4,5,14h,7,38h,39h,3Ah,3Bh,3Ch,3Dh,3Eh,3Fh ; attr
  1418. db 1,0,0Fh,0
  1419. db 0,0,0,0,0,0,1,0Fh,0FFh
  1420. Mode7Ega label byte ; 32
  1421. db 80,24,16,0,10h ,1,0FH,0,6 ,0A6h
  1422. db 5Bh,4Fh,53h,37h,52h,00h,09Fh,1Fh,0,0,0DH,0EH,0,80h,0,0; crtc
  1423. db 90h,2Bh,8Fh,28h,0FH,95h,1Dh,0E3h,0FFh ; crtc
  1424. db 0,8,0,0,18h,18h,0,0,0,8,0,0,0,8,0,0
  1425. db 03H,0,05H,0
  1426. db 0,0,0,0,0,0,01h,05H,0FFh
  1427. ;------------------------------------------------------------------------
  1428. ;------------------------------------------------------------------------
  1429. public HanOnEga, HanOffEga, GetFontEga, PutFontEga
  1430. HanOnEga:
  1431. HanOffEga:
  1432. GetFontEga:
  1433. PutFontEga:
  1434. stc
  1435. ret
  1436. ;------------------------------------------------------------------------
  1437. if AtiVga
  1438. public AtiHanOnVga, AtiHanOffVga, AtiGetFontVga, AtiPutFontVga
  1439. AtiHanOnVga:
  1440. mov dx,3ddh
  1441. mov ax,101h
  1442. out dx,ax
  1443. mov dx,1ceh
  1444. mov al,0bfh
  1445. mov ah,al
  1446. out dx,al
  1447. inc dx
  1448. in al,dx
  1449. or al,00100000b
  1450. dec dx
  1451. xchg al,ah
  1452. out dx,ax
  1453. ret
  1454. AtiHanOffVga:
  1455. mov dx,3ddh
  1456. mov ax,1
  1457. out dx,ax
  1458. mov dx,1ceh
  1459. mov al,0bfh
  1460. mov ah,al
  1461. out dx,al
  1462. inc dx
  1463. in al,dx
  1464. and al,11011111b
  1465. dec dx
  1466. xchg al,ah
  1467. out dx,ax
  1468. ret
  1469. AtiGetFontVga:
  1470. mov dx,es
  1471. mov ds,dx
  1472. mov dx,3ddh
  1473. mov ah,ch
  1474. mov al,10h
  1475. cli
  1476. out dx,ax
  1477. mov ah,cl
  1478. mov al,8
  1479. out dx,ax
  1480. mov ax,201h
  1481. mov cl,4
  1482. cmp ch,0feh ; assume FExx
  1483. jnz @f
  1484. mov ah,6 ; set C9xx
  1485. mov cl,2
  1486. @@:
  1487. cmp ch,0c9h
  1488. jnz @f
  1489. mov cl,2
  1490. @@:
  1491. out dx,ax
  1492. mov al,cl
  1493. out dx,al
  1494. inc dx
  1495. mov bx,di
  1496. mov cx,16
  1497. @@:
  1498. in al,dx
  1499. stosb
  1500. inc di
  1501. loop @b
  1502. mov di,bx
  1503. mov cl,16
  1504. @@:
  1505. inc di
  1506. in al,dx
  1507. stosb
  1508. loop @b
  1509. dec dx
  1510. mov ax,1
  1511. out dx,ax
  1512. sti
  1513. clc
  1514. ret
  1515. AtiPutFontVga:
  1516. mov dx,3ddh
  1517. mov ah,cl
  1518. mov al,8
  1519. cli
  1520. out dx,ax
  1521. mov ax,201h
  1522. cmp ch,0feh ; assume FExx
  1523. jnz @f
  1524. mov ah,6 ; set C9xx
  1525. @@:
  1526. out dx,ax
  1527. mov al,2
  1528. out dx,al
  1529. inc dx
  1530. mov bx,si
  1531. mov cx,16
  1532. @@:
  1533. lodsw
  1534. out dx,al
  1535. loop @b
  1536. mov si,bx
  1537. mov cl,16
  1538. @@:
  1539. lodsw
  1540. mov al,ah
  1541. out dx,al
  1542. loop @b
  1543. dec dx
  1544. mov ax,1
  1545. out dx,ax
  1546. sti
  1547. clc
  1548. ret
  1549. endif ; AtiVga
  1550. ;------------------------------------------------------------------------
  1551. if KseVga
  1552. public KseHanOnVga, KseHanOffVga, KseGetFontVga, KsePutFontVga
  1553. KseHanOnVga:
  1554. call KseVgaKey
  1555. mov ax,0832h
  1556. out dx,ax
  1557. mov al,34h
  1558. out dx,al
  1559. inc dx
  1560. in al,dx
  1561. and al,11111101b
  1562. out dx,al ; set 8 bit bus
  1563. dec dx
  1564. mov al,35h
  1565. out dx,al
  1566. inc dx
  1567. in al,dx
  1568. and al,01111111b
  1569. out dx,al ; set 8 bit bus
  1570. dec dx
  1571. mov al,36h
  1572. out dx,al
  1573. inc dx
  1574. in al,dx
  1575. and al,10110111b
  1576. out dx,al ; set 8 bit bus
  1577. dec dx
  1578. mov al,37h
  1579. out dx,al
  1580. inc dl
  1581. in al,dx
  1582. and al,11111110b
  1583. or al,00000010b
  1584. out dx,al
  1585. mov dl,0c4h
  1586. mov al,1
  1587. out dx,al
  1588. inc dl
  1589. in al,dx
  1590. or al,1
  1591. out dx,al
  1592. mov dx,258h
  1593. mov ax,0e8f0h ; enable hangeul
  1594. out dx,ax
  1595. mov al,0f4h
  1596. out dx,al
  1597. inc dx
  1598. in al,dx
  1599. or al,10000000b
  1600. and al,11111011b
  1601. out dx,al ; set english
  1602. dec dl
  1603. mov ax,0fff5h
  1604. out dx,ax
  1605. push dx
  1606. mov ah,3
  1607. mov bh,cs:[CurPage]
  1608. pushf
  1609. call cs:[OldVideo]
  1610. mov ah,1
  1611. pushf
  1612. call cs:[OldVideo]
  1613. call KseVEop
  1614. pop dx
  1615. ret
  1616. KseHanOffVga:
  1617. call KseVgaKey
  1618. mov ax,832h
  1619. out dx,ax
  1620. mov al,34h
  1621. out dx,al
  1622. inc dx
  1623. in al,dx
  1624. and al,11111101b
  1625. or al,00001000b
  1626. out dx,al
  1627. dec dx
  1628. mov al,35h
  1629. out dx,al
  1630. inc dx
  1631. in al,dx
  1632. and al,01111111b
  1633. out dx,al ; set 8 bit bus
  1634. dec dx
  1635. mov al,36h
  1636. out dx,al
  1637. inc dx
  1638. in al,dx
  1639. and al,11110111b
  1640. out dx,al ; set 8 bit bus
  1641. dec dx
  1642. mov al,37h
  1643. out dx,al
  1644. inc dl
  1645. in al,dx
  1646. and al,11111110b
  1647. or al,00000010b
  1648. out dx,al
  1649. mov dx,258h
  1650. mov ax,0f0h
  1651. mov ah,20
  1652. out dx,ax ; set english
  1653. mov al,0f4h
  1654. out dx,al
  1655. inc dx
  1656. in al,dx
  1657. and al,01110111b
  1658. or al,00001000b
  1659. out dx,al ; set english
  1660. ; border color off
  1661. mov dx,257h
  1662. in al,dx
  1663. mov al,2 ;index 2
  1664. out dx,al
  1665. mov al,0
  1666. out dx,al
  1667. ret
  1668. KseVgaKey:
  1669. mov dx,3bfh
  1670. mov al,3
  1671. out dx,al
  1672. mov dx,3cch
  1673. in al,dx
  1674. mov dl,0d4h
  1675. test al,1
  1676. jnz @f
  1677. mov dl,0b4h
  1678. @@:
  1679. add dl,4
  1680. mov al,0a0h
  1681. out dx,al
  1682. sub dl,4
  1683. mov al,11h
  1684. out dx,al
  1685. inc dl
  1686. in al,dx
  1687. and al,not 80h
  1688. out dx,al
  1689. dec dl
  1690. ret
  1691. KseVEop:
  1692. mov bx,ax
  1693. call KseVgaKey
  1694. mov dx,3cch
  1695. in al,dx
  1696. mov dl,0d4h
  1697. test al,1
  1698. jnz @f
  1699. mov dl,0b4h
  1700. @@:
  1701. mov al,-1
  1702. out dx,al ; dumy for mode 7
  1703. mov dl,0bfh
  1704. mov al,cs:[Port3bf]
  1705. out dx,al
  1706. mov ax,bx
  1707. ret
  1708. KseGetFontVga:
  1709. mov bx,ax
  1710. mov dx,258h
  1711. mov al,0f4h
  1712. out dx,al
  1713. inc dx
  1714. in al,dx
  1715. and al,11110111b
  1716. out dx,al
  1717. dec dx
  1718. mov al,0f0h ; access enable
  1719. out dx,al
  1720. inc dx
  1721. in al,dx
  1722. and al,11111110b
  1723. or al,00000010b
  1724. out dx,al
  1725. mov si,255h
  1726. shl cl,1
  1727. shr cx,1
  1728. mov ax,32
  1729. mul cx
  1730. mov cx,dx
  1731. mov dx,250h
  1732. mov bl,al
  1733. out dx,al
  1734. inc dx
  1735. mov al,ah
  1736. out dx,al
  1737. inc dx
  1738. mov al,cl
  1739. out dx,al
  1740. mov cx,32
  1741. @@:
  1742. mov dx,si
  1743. in al,dx
  1744. stosb
  1745. mov dl,50h
  1746. inc bl
  1747. mov al,bl
  1748. out dx,al
  1749. loop @b
  1750. KseVGetEnd:
  1751. mov dl,58h
  1752. mov al,0f0h
  1753. out dx,al
  1754. inc dl
  1755. in al,dx
  1756. and al,11111100b
  1757. out dx,al
  1758. clc
  1759. ret
  1760. KsePutFontVga:
  1761. mov dx,258h ;**ket bit
  1762. mov al,0f4h
  1763. out dx,al ;read-inx
  1764. inc dx
  1765. in al,dx
  1766. and al,11110111b
  1767. out dx,al
  1768. dec dx ;.**
  1769. mov al,0f0h ;**access enable
  1770. out dx,al
  1771. inc dx
  1772. in al,dx
  1773. or al,00000011b
  1774. out dx,al
  1775. mov di,255h
  1776. shl cl,1
  1777. shr cx,1
  1778. mov ax,32
  1779. mul cx
  1780. mov cx,dx
  1781. mov dx,250h
  1782. mov bl,al
  1783. out dx,al
  1784. inc dx
  1785. mov al,ah
  1786. out dx,al
  1787. inc dx
  1788. mov al,cl
  1789. out dx,al
  1790. mov cx,32
  1791. @@:
  1792. mov dl,58h
  1793. mov al,0f0h
  1794. out dx,al
  1795. inc dx
  1796. in al,dx
  1797. and al,11111110b
  1798. or al,00000010b
  1799. out dx,al
  1800. mov dl,53h
  1801. in al,dx
  1802. out dx,al
  1803. inc dl
  1804. in al,dx
  1805. out dx,al
  1806. inc dl
  1807. in al,dx
  1808. out dx,al
  1809. mov dl,58h
  1810. mov al,0f0h
  1811. out dx,al ;read-inx
  1812. inc dx
  1813. in al,dx
  1814. or al,00000011b
  1815. out dx,al
  1816. mov dx,di
  1817. lodsb
  1818. out dx,al
  1819. mov dl,56h
  1820. out dx,al
  1821. mov dl,50h
  1822. inc bl
  1823. mov al,bl
  1824. out dx,al
  1825. loop @b
  1826. jmp KseVGetEnd
  1827. endif ; if KseVga
  1828.