1 ;-----------------------------------------------------------------------
\r
4 ; Line drawing functions.
\r
10 ; ****** XLIB - Mode X graphics library ****************
\r
11 ; ****** ****************
\r
12 ; ****** Written By Themie Gouthas ****************
\r
14 ; egg@dstos3.dsto.gov.au
\r
15 ; teg@bart.dsto.gov.au
\r
16 ;-----------------------------------------------------------------------
\r
26 mov dx,[_ScrnLogicalByteWidth]
\r
37 ;-----------------------------------------------------------------------
\r
40 ; Line drawing function for all MODE X 256 Color resolutions
\r
41 ; Based on code from "PC and PS/2 Video Systems" by Richard Wilton.
\r
43 ; Compile with Tasm.
\r
48 ;ARG x1:word,y1:word,x2:word,y2:word,Color:word,PgOffs:word
\r
49 LOCAL vertincr:word,incr1:word,incr2:word,routine:word=LocalStk
\r
50 push bp ; Set up stack frame
\r
59 mov dx,SC_INDEX ; setup for plane mask access
\r
61 ; check for vertical line
\r
63 mov si,[_ScrnLogicalByteWidth]
\r
82 ; calc dy = abs(y2 - y1)
\r
94 ; select appropriate routine for slope of line
\r
98 mov [routine],offset LoSlopeLine
\r
101 mov [routine],offset HiSlopeLine
\r
104 ; calc initial decision variable and increments
\r
114 ; calc first pixel address
\r
123 mov ah,al ; duplicate nybble
\r
134 ; routine for verticle lines
\r
156 mov ax, word ptr [bp+12]
\r
166 ; routine for horizontal line
\r
175 mov di,bx ; set dl = first byte mask
\r
179 mov cx,[bp+8] ; set dh = last byte mask
\r
185 ; determine byte offset of first and last pixel in line
\r
190 shr ax,1 ; set ax = last byte column
\r
191 shr bx,1 ; set bx = first byte column
\r
192 shr ax,1 ; set ax = last byte column
\r
193 shr bx,1 ; set bx = first byte column
\r
194 mov cx,ax ; cx = ax - bx
\r
197 mov ax,dx ; mov end byte masks to ax
\r
198 mov dx,SC_INDEX ; setup dx for VGA outs
\r
201 ; set pixels in leftmost byte of line
\r
203 or cx,cx ; is start and end pt in same byte
\r
205 and ah,al ; combine start and end masks
\r
216 ; draw remainder of the line
\r
226 ; set pixels in rightmost byte of line
\r
231 mov byte ptr es:[di],bl
\r
236 ; routine for dy >= dx (slope <= 1)
\r
240 mov bh,byte ptr [bp+12]
\r
249 ; bit mask not shifted out
\r
268 ; bit mask shifted out
\r
285 ; routine for dy > dx (slope > 1)
\r