1 ;-----------------------------------------------------------
\r
3 ; MXEL.ASM - Mid-point ellipse
\r
4 ; Copyright (c) 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 an ellipse using the mid-point algorithm.
\r
28 ; XC, YC = center coordinates
\r
29 ; A = horizontal radius
\r
30 ; B = vertical radius
\r
31 ; Color = ellipse color
\r
35 ; computes only points in the first quadrant, all other
\r
36 ; points are obtained by symmetry.
\r
53 .chk386 mxEllipse, @@Exit
\r
55 ; Initialize variables
\r
60 mov [DD], eax ; DD = A*A
\r
62 mov [CC], eax ; CC = 2*A*A
\r
64 mov [A2], eax ; A2 = 4*A*A
\r
67 mul edx ; EAX = 4*A*A*B
\r
68 sub [DD], eax ; DD = A*A - 4*A*A*B
\r
71 shl eax, 2 ; EAX = 4*B*B
\r
72 mov [B2], eax ; B2 = 4*B*B
\r
73 add [CC], eax ; CC = 2*A*A + 4*B*B
\r
74 add [D1], eax ; DD = A*A - 4*A*A*B + 4*B*B
\r
76 ; Draw initial points
\r
81 mov eax, [X] ; Check slope
\r
87 sub eax, [CC] ; EAX = Y*A2 - X*B2 - CC
\r
88 jle @@Done1 ; Crossed critical point, jump to next loop
\r
90 mov ecx, [DD] ; Get error
\r
91 test ecx, ecx ; Positive?
\r
92 jl @@Draw1 ; No, use default step
\r
98 add ecx, eax ; Bump error
\r
99 dec WORD PTR [Y] ; Decrement Y coordinate
\r
106 add ecx, eax ; Bump error
\r
107 mov [DD], ecx ; Save error
\r
108 inc WORD PTR [X] ; Increment X coordinate
\r
110 call subPlot4 ; Draw points
\r
114 ; Initialize variables
\r
135 cmp WORD PTR [Y], 0
\r