1 ;-----------------------------------------------------------
\r
3 ; MXCL.ASM - Bresenham circle
\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 mx_ClipX1 : WORD
\r
19 EXTRN mx_ClipY1 : WORD
\r
20 EXTRN mx_ClipX2 : WORD
\r
21 EXTRN mx_ClipY2 : WORD
\r
23 ;-----------------------------------------------------------
\r
25 ; Draws a circle using the Bresenham algorithm.
\r
28 ; XC, YC = center coordinates
\r
29 ; Radius = circle radius
\r
30 ; Color = circle color
\r
34 ; computes only points in the first octant, all other
\r
35 ; points are obtained by symmetry.
\r
42 LOCAL Delta:WORD = AUTO_SIZE
\r
47 mov di, [Radius] ; Y
\r
51 mov [Delta], ax ; Delta = 3-R*2
\r
53 mov ds, [mx_VideoSegment]
\r
57 jg @@Done ; Exit when X > Y
\r
91 ; Moves coordinates to next point
\r
113 ;---------------------------------------
\r
114 ; Put pixel function.
\r
116 ; BX = X coordinate (relative to center)
\r
117 ; AX = Y coordinate (relative to center)
\r
118 ; DS = video segment
\r
120 add bx, [XC] ; Get absolute coordinates
\r
123 cmp bx, [mx_ClipX1] ; Clip pixel
\r
125 cmp bx, [mx_ClipX2]
\r
127 cmp ax, [mx_ClipY1]
\r
129 cmp ax, [mx_ClipY2]
\r
132 mul [mx_BytesPerLine] ; Get pixel offset
\r
133 mov cx, bx ; Save X coordinate
\r
135 add bx, ax ; DS:BX = pixel offset
\r
137 and cl, 3 ; Set write plane
\r
143 mov al, [Color] ; Write pixel
\r