1 ;-----------------------------------------------------------
\r
3 ; MXFB.ASM - Fill box function
\r
4 ; Copyright (c) 1993,1994 by Alessandro Scotti
\r
6 ;-----------------------------------------------------------
\r
13 MX_TEXT SEGMENT USE16 PARA PUBLIC 'CODE'
\r
14 ASSUME cs:MX_TEXT, ds:NOTHING, es:NOTHING
\r
16 EXTRN mx_BytesPerLine : WORD
\r
17 EXTRN mx_VideoSegment : WORD
\r
18 EXTRN subClipBox : NEAR
\r
19 EXTRN subHorizontalLineInfo : NEAR
\r
21 ;-----------------------------------------------------------
\r
23 ; Raster op functions. Raster op is limited to OP_MOVE,
\r
24 ; OP_AND, OP_OR and OP_XOR. The VGA hardware is used to
\r
25 ; perform the selected logical functions on up to four
\r
28 subRepFill PROC NEAR
\r
45 subRepMove PROC NEAR
\r
48 mov ah, ds:[si] ; Dummy read to latch the data
\r
57 mov ah, ds:[bx] ; Dummy read to latch the data
\r
64 ;-----------------------------------------------------------
\r
66 ; Fills a rectangle with a specified color.
\r
69 ; X, Y = X, Y coordinates of rectangle
\r
70 ; Width = width of rectangle
\r
71 ; Height = height of rectangle
\r
72 ; Color = fill color
\r
73 ; Op = raster operator
\r
77 ; Note: raster op is limited to OP_MOVE, OP_AND, OP_OR and OP_XOR.
\r
86 LOCAL LeftMask:BYTE, \
\r
88 FillFunction:WORD, \
\r
89 RepFillFunction:WORD = AUTO_SIZE
\r
91 .push ds, si, es, di
\r
100 jc @@Exit ; Full clipped
\r
102 mov [Height], dx ; Save clipped height
\r
103 call subHorizontalLineInfo ; Get additional info, init DI
\r
106 mov [RightMask], ah
\r
108 ; Initialize segments
\r
109 mov ax, [mx_VideoSegment]
\r
110 mov es, ax ; ES:DI points to pixel
\r
112 cld ; Clear direction flag
\r
114 ; Select fill functions
\r
115 mov [FillFunction], OFFSET subFill
\r
116 mov [RepFillFunction], OFFSET subRepFill
\r
117 mov ax, [Op] ; Get raster op
\r
119 ja @@1 ; Assume it's a fill
\r
126 out dx, ax ; Set GDC logical function
\r
127 mov [FillFunction], OFFSET subMove
\r
128 mov [RepFillFunction], OFFSET subRepMove
\r
135 jz @@C0 ; Nothing to do, go to center block
\r
138 out dx, ax ; Set write plane mask
\r
139 mov dx, [mx_BytesPerLine]
\r
143 call [FillFunction] ; Fill this column
\r
144 inc di ; Update starting video offset
\r
146 ; Fill center block
\r
149 jcxz @@R0 ; Nothing to do, go to right block
\r
152 out dx, ax ; Write to all planes
\r
156 push di ; Save pixel address
\r
158 mov di, bx ; Update video offset
\r
159 call [RepFillFunction] ; Fill current scan line
\r
160 mov cx, [Width] ; Restore byte count
\r
161 add bx, [mx_BytesPerLine] ; Bump to next scan line
\r
162 dec dx ; Done all lines?
\r
163 jnz @@C1 ; No, continue
\r
164 pop di ; Restore pixel address
\r
165 add di, [Width] ; Go to right block
\r
169 mov ah, [RightMask]
\r
171 jz @@Done ; Nothing to do, exit
\r
174 out dx, ax ; Set write plane mask
\r
175 mov dx, [mx_BytesPerLine]
\r
179 call [FillFunction] ; Fill this column
\r
181 ; Restore VGA registers
\r
185 out dx, ax ; Set logical function to "move"
\r
189 .pop ds, si, es, di
\r