4 SC_ADDR equ 3c4h ; sequence controller address register
5 CRTC_ADDR equ 3d4h ; CRTC address register
13 ; disable chain-4 (bit 3 of sequencer memory mode register [4])
17 ; disable double-word addressing (bit 6 of CRTC underline location
22 ; enable byte mode address generation (bit 6 of CRTC mode control
27 ; clear all 256kb of vram
29 mov ax, 0f02h ; map mask reg (2) enable all planes (f)
36 ; initial back buffer is the second page
37 mov dword [_vid_backbuf], 0a4000h
39 ; set initial scanout address to page 0. if we never pageflip, we
40 ; can just draw to a0000 as usual and it will be visible.
41 ; This also makes sure the low byte is 0, because we're not touching it
42 ; while page flipping; we flip by toggling a bit in the high byte.
48 mov ax, 000ch ; 0ch: start address high register
49 mov ax, 000dh ; 0dh: start address low register
80 ; clear the framebuffer 4 pixels at a time
88 mov ax, 0f02h ; map mask reg (2) enable all planes (f)
90 mov edi, [_vid_backbuf]
91 mov ecx, 4000 ; 4000 dwords * 4 planes * 4 bytes = 64000 pixels
101 ; clear area of the framebuffer
102 ; eax: x edx: y ebx: width ecx: height
103 global vid_clearfb_rect_
107 mov edi, [_vid_backbuf]
110 lea eax, [edx * 4 + edx]
117 jle .done ; abort if width or height is negative or zero
121 mov ax, 0f02h ; map mask reg (2) enable all planes (f)
130 ;.foo: mov [xyzzy], eax
131 add ebx, 15 ; round up to next 16-pixel block
132 shr ebx, 4 ; /4 (planes) /4 (stosd) = /16
133 mov edx, ecx ; use edx for height, to free ecx for rep stosd
134 .yloop: mov esi, edi ; save pointer
137 mov edi, esi ; restore pointer
138 add edi, 80 ; advance scanline (320 / 4 planes)
146 ; vid_backbuf is the linear address of the back buffer in video RAM
147 ; either a0000 or a4000. Flipping bit 14 switches between them, and
148 ; masking with ffff gives the CRTC start address.
155 ; set the current backbuffer as the new CRTC scanout start address
156 mov ebx, [_vid_backbuf]
157 mov bl, 0ch ; CRTC start address high register
159 ; only proceed if we're out of vblank, otherwise we might think we've
160 ; set a new scanout address, but it might not be latched until the next
161 ; vblank, and we'll be drawing over the scanout buffer in the meantime.
168 mov ax, bx ; get previously prepared reg addr and value
170 ; clear low bits and flip the backbuffer pointer
172 mov [_vid_backbuf], ax