drawCircle:
	move.w	r(pc),d1	;r in d1
	move.w	d1,d6		;save r -> d6
	; int f = 1-radius
	moveq	#1,d2
	sub.w	d1,d2		; f result in d2
	move.w	d2,f		; f save
				; int ddF_x = 0 -> dc.w 0
	move.w	d1,d3		; r -> d3
	add.w	d3,d3		; d = r * 2
	neg.w	d3		; ddF_y = -2*r
				; nice idea seen at hitchhikr's :D
				; to avoid signed multiplication
	
				; int x = 0 -> dc.b 0
				; int y = r
	move.w	d1,y		; y = r
	; first set of pixels
	; setPixel(x0,y0 + r)
	move.w	x0(pc),d0
	move.w	y0(pc),d1
	move.w	d0,d4		; save x0
	move.w	d1,d5		; save y0
	
	add.w	d6,d1		; add r to y0
	bsr	_dcSetObj
	;setPixel(x0,y0 - r)
	move.w	d4,d0		; get back x0
	move.w	d5,d1		; get back y0
	sub.w	d6,d1		; y0 - r
	bsr	_dcSetObj
	add.w	d6,d0		; x0 + r
	move.w	d5,d1		; get back y0
	bsr	_dcSetObj
	;setPixel(x0 - r,y0)
	move.w	d4,d0		; get back x0
	sub.w	d6,d0		; x0 - r
	bsr	_dcSetObj
	; Pixelloop

	moveq	#0,d6		; ddF_x -> d6
				; ddF_y -> d3
.lp:	move.w	x(pc),d0
	move.w	y(pc),d1
	; while( x < y )
	cmp.w	d1,d0
	bge	.end
	; if( f >= 0 )
	cmpi.w	#0,f
	blt	.skip

	subq.w	#1,d1		; y--;
	addq.w	#2,d3		; ddF_y += 2;	
	add.w	d3,f		; f += ddF_y
.skip:
	addq.w	#1,d0		; x++;
	addq.w	#2,d6		; ddF_x += 2
	move.w	d6,d7		; new ddF_x -> d7
	addq.w	#1,d7
	add.w	d7,f		; f += ddF_x + 1

	move.w	d0,x		;save new x
	move.w	d1,y		;     "   y

	;setPixel(x0 + x,y0 + y)
	moveq	#0,d2
	move.w	y(pc),d2	; load y -> d2
	swap	d2		; swap y to upper word
	move.w	x(pc),d2	; load x -> d2
	move.w	d4,d0		; get back x0
	move.w	d5,d1		; get back y0
	add.w	d2,d0		; x0 + x
	swap	d2		; get y
	add.w	d2,d1		; y0 + y
	bsr	_dcSetObj
	;setPixel(x0 - x,y0 + y)
	move.w	d4,d0		; get back x0
	move.w	d5,d1		; get back y0
	add.w	d2,d1		; y0 + y	
	swap	d2		; get x
	sub.w	d2,d0		; x0 - x
	bsr	_dcSetObj
	;setPixel(x0 + x,y0 - y)
	move.w	d4,d0		; get back x0
	move.w	d5,d1		; get back y0
	add.w	d2,d0		; x0 + x
	swap	d2		; get y
	sub.w	d2,d1		; y0 - y
	bsr	_dcSetObj
	;setPixel(x0 - x,y0 - y)
	move.w	d4,d0		; get back x0
	move.w	d5,d1		; get back y0
	sub.w	d2,d1		; y0 - y
	swap	d2		; get x
	sub.w	d2,d0		; x0 - x
	bsr	_dcSetObj
	;setPixel(x0 + y,y0 + x)
	move.w	d4,d0		; get back x0
	move.w	d5,d1		; get back y0
	add.w	d2,d1		; y0 + x
	swap	d2		; get y
	add.w	d2,d0		; x0 + y
	bsr	_dcSetObj
	;setPixel(x0 - y,y0 + x)
	move.w	d4,d0		; get back x0
	move.w	d5,d1		; get back y0
	sub.w	d2,d0		; x0 - y
	swap	d2		; get x
	add.w	d2,d1		; y0 + x
	bsr	_dcSetObj
	;setPixel(x0 + y,y0 - x)
	move.w	d4,d0		; x0
	move.w	d5,d1		; y0
	sub.w	d2,d1		; y0 - x
	swap	d2		; get y
	add.w	d2,d0		; x0 + y
	bsr	_dcSetObj
	;setPixel(x0 - y,y0 - x)
	move.w	d4,d0		; x0
	move.w	d5,d1		; y0
	sub.w	d2,d0		; x0 - y
	swap	d2		; get x
	sub.w	d2,d1
	bsr	_dcSetObj
	bra	.lp
.end:
	moveq	#0,d0
	move.w	d0,x
	move.w	d0,y
	move.w	d0,f
	rts

_dcSetObj:
	tst.b	_dcObj
	bne	.rect
.pixel:	
	move.w	d0,dpX
	move.w	d1,dpY
	bsr	drawPixel
	bra	.end
.rect:	
	move.w	d0,_dgSrcX
	move.w	d1,_dgSrcY
	bsr	drawRect
.end:	rts
	
x0:	dc.w	160
y0:	dc.w	125
x:	dc.w	0
y:	dc.w	0
r:	dc.w	5
f:	dc.w	0
_dcObj:	dc.b	0