Можете, пожалуйста, помочь разобраться с процедурой отрисовки окружности?
;-----------------------------Рисуем вертикальные линии-------------------------------------
proc drawHorLine uses es di cx ax,\
x1, x2, y, color
mov ax, $A000
mov es, ax
mov al, byte[y]
mov cx, 320
mul cx
mov di, ax
add di, [x1]
mov cx, [x2]
sub cx, [x1]
mov al, byte[color]
rep stosb
ret
endp
;-------------------------------------------------------------------------------------------
;----------------------------Рисуем окружность-----------------------------------------------
proc drawCircleSim uses bx si di ax,\
x,y,xc,yc,color, mode
mov ax, [x]
add ax, [xc]
mov bx, [y]
add bx, [yc]
stdcall putpixel, ax, bx,[color]
cmp [mode], Mode_NoBorder
je @F
mov dx, [xc]
sub dx, [x]
push ax
push dx
push bx
stdcall drawHorLine, dx, ax, bx, [color]
pop bx
pop dx
pop ax
add ax, 2
dec dx
dec bx
stdcall drawHorLine, dx, ax, bx, [color]
@@:
mov ax, [x]
add ax, [xc]
mov bx, [yc]
sub bx, [y]
stdcall putpixel, ax,bx,[color]
cmp [mode], Mode_NoBorder
je @F
mov dx, [xc]
sub dx, [x]
push ax
push dx
push bx
stdcall drawHorLine, dx, ax, bx, [color]
pop bx
pop dx
pop ax
add ax, 2
dec dx
add bx, 1
stdcall drawHorLine, dx, ax, bx, [color]
@@:
mov ax, [xc]
sub ax, [x]
mov bx, [yc]
sub bx, [y]
stdcall putpixel, ax,bx,[color]
mov ax, [xc]
sub ax, [x]
mov bx, [y]
add bx, [yc]
stdcall putpixel, ax,bx,[color]
mov ax, [y]
add ax, [xc]
mov bx, [x]
add bx, [yc]
stdcall putpixel, ax,bx,[color]
cmp [mode], Mode_NoBorder
je @F
mov dx, [xc]
sub dx, [x]
stdcall drawHorLine, dx, ax, bx, [color]
@@:
mov ax, [y]
add ax, [xc]
mov bx, [yc]
sub bx, [x]
stdcall putpixel, ax,bx,[color]
cmp [mode], Mode_NoBorder
je @F
mov dx, [xc]
sub dx, [x]
stdcall drawHorLine, dx, ax, bx, [color]
@@:
mov ax, [xc]
sub ax, [y]
mov bx, [yc]
sub bx, [x]
stdcall putpixel, ax,bx,[color]
cmp [mode], Mode_NoBorder
je @F
mov dx, [xc]
sub dx, [x]
stdcall drawHorLine, ax, dx, bx, [color]
@@:
mov ax, [xc]
sub ax, [y]
mov bx, [x]
add bx, [yc]
stdcall putpixel, ax,bx,[color]
cmp [mode], Mode_NoBorder
je @F
mov dx, [xc]
sub dx, [x]
stdcall drawHorLine, ax, dx, bx, [color]
@@:
ret
endp
;-------------------------------------------------------------------------------------------
;-------------------------Рисуем круг-------------------------------------------------------
proc drawCircle uses es si ax cx bx dx,\
xc, yc, r, color, mode
mov ax, [y]
add ax, [y]
mov dx, 3
sub dx, ax ; d = dx
mov [d], dx
mov [x], 0
mov si, [r]
mov [y], si
.While:
stdcall drawCircleSim, [x], [y], [xc], [yc], [color], [mode]
mov dx, [d]
cmp dx, 0 ;if d<0
js .Minus
mov ax, [x] ; else begin
sub ax, [y] ;d:=d+4*(x-y)+10;
mov cx, ax
add ax, cx
add ax, cx
add ax, cx
add ax, 10
add [d], ax
dec [y]
jmp .Skip
.Minus: ;then d:=d+4*x+6
mov ax, [x]
add ax, [x]
add ax, [x]
add ax, [x]
add ax, 6
add [d], ax
.Skip:
inc [x]
mov ax, [y]
cmp [x],ax
js .While
ret
endp
;-------------------------------------------------------------------------------------------
;--------------------------Рисуем попиксельно-----------------------------------------------
proc putpixel uses es di bx ax cx,\
x,y, color
mov ax, $A000
mov es, ax
mov al, byte[y]
mov cx, 320
mul cx
mov di, ax
add di, [x]
mov al, byte[color]
mov [es:di], al
ret
endp