1 ; ====================================================================
\r
3 ; ====================================================================
\r
5 mov ax,13h ;let the BIOS set standard 256-color
\r
6 int 10h ; mode (320x200 linear)
\r
11 ; ====================================================================
\r
12 ; This is MODE-X code from Dr. Dobb's Journal, by Michael Abrash.
\r
13 ; I modified it from 320x240 back to 320x200, and then to 512 virtual
\r
14 ; width, for scrolling purposes.
\r
15 ; ====================================================================
\r
17 ; Mode X (320x240, 256 colors) mode set routine. Works on all VGAs.
\r
18 ; ****************************************************************
\r
19 ; * Revised 6/19/91 to select correct clock; fixes vertical roll *
\r
20 ; * problems on fixed-frequency (IBM 851X-type) monitors. *
\r
21 ; ****************************************************************
\r
22 ; Modified from public-domain mode set code by John Bridges.
\r
24 ; Index/data pairs for CRT Controller registers that differ between
\r
25 ; mode 13h and mode X.
\r
27 ; dw 00d06h ;vertical total
\r
28 ; dw 03e07h ;overflow (bit 8 of vertical counts)
\r
29 ; dw 04109h ;cell height (2 to double-scan)
\r
30 ; dw 0ea10h ;v sync start
\r
31 ; dw 0ac11h ;v sync end and protect cr0-cr7
\r
32 ; dw 0df12h ;vertical displayed = 480
\r
33 dw 00014h ;turn off dword mode *
\r
34 ; dw 0e715h ;v blank start
\r
35 ; dw 00616h ;v blank end
\r
36 dw 0e317h ;turn on byte mode *
\r
38 dw (VIRTUAL_WIDTH*32)+13h ; width of screen = VWid NEW
\r
39 ; dw 09012h ;vertical displayed = 400 (already like this)
\r
40 CRT_PARM_LENGTH equ (($-CRTParms)/2)
\r
42 ModifyForX PROC near
\r
45 out dx,ax ;disable chain4 mode
\r
47 out dx,ax ;synchronous reset while setting Misc
\r
48 ; Output for safety, even though clock
\r
52 out dx,al ;select 25 MHz dot clock & 60 Hz scanning rate
\r
56 out dx,ax ;undo reset (restart sequencer)
\r
58 mov dx,CRTC_INDEX ;reprogram the CRT Controller
\r
59 mov al,11h ;VSync End reg contains register write
\r
60 out dx,al ; protect bit
\r
61 inc dx ;CRT Controller Data register
\r
62 in al,dx ;get current VSync End register setting
\r
63 and al,7fh ;remove write protect on various
\r
64 out dx,al ; CRTC registers
\r
65 dec dx ;CRT Controller Index
\r
69 mov si,offset CRTParms ;point to CRT parameter table
\r
70 mov cx,CRT_PARM_LENGTH ;# of table entries
\r
72 lodsw ;get the next CRT Index/Data pair
\r
73 out dx,ax ;set the next CRT Index/Data pair
\r
74 loop SetCRTParmsLoop
\r
78 out dx,ax ;enable writes to all four planes
\r
79 mov ax,SCREEN_SEG ;now clear all display memory, 8 pixels
\r
80 mov es,ax ; at a time
\r
81 sub di,di ;point ES:DI to display memory
\r
82 sub ax,ax ;clear to zero-value pixels
\r
83 mov cx,8000h ;# of words in display memory
\r
84 rep stosw ;clear all of display memory
\r