*	A is osize B is how far

start:
	move.l	#5,a
	move.l	#20,d0
	asr.l	#1,d0
	move.l	d0,b
	bsr	plotelipse


arrange:
	move.l	elipseend,a0	;the end of our coord list
	lea	array,a1
	sub.l	#2,a0		;now pointing at last coord pair
atl:
	move.w	(a0),d0		;are we at the top of the list?
	bmi	atp1		;yep well move on
	move.w	d0,(a1)+
	move.w	d0,d6
	sub.l	#2,a0
	bra	atl
atp1:
	move.w	d6,d1		;save last value
	move.w	d1,d2
	lea	coords,a0	;start at top this time
	add.l	#2,a0
atl2:
	move.w	(a0)+,d0		;are we at the top of the list?
	bmi	atp2		;yep well move on
	cmp.w	d0,d1
	beq	sameold
	addq.w	#1,d2
	move.w	d0,d1
sameold:
	move.w	d2,(a1)+	;store the distance
	bra	atl2
atp2:
	nop
	nop
	nop


*******************************************************************
a:	dc.l	5
b:	dc.l	20
xe:	dc.l	0
ye:	dc.l	0
asquare:	dc.l	0
bsquare:	dc.l	0
a22:		dc.l	0
b22:		dc.l	0
xslope:		dc.l	0
yslope:		dc.l	0
fmid:		dc.l	0

plotelipse:
	move.w	#4,value
	lea	coords,a0
	move.w	#-1,(a0)+	;end of list reverse
	move.l	a,xe		;x=a
	move.l	#0,ye		;y=0
	move.l	a,d0
	mulu	d0,d0		;asquare=a*a
	move.l	d0,asquare
	move.l	b,d1		;bsquare=b*b
	mulu	d1,d1
	move.l	d1,bsquare
	add.l	d0,d0
	add.l	d1,d1
	move.l	d0,a22		;a22=asquare+asquare
	move.l	d1,b22		;b22=bsquare+bsquare
	move.l	a,d2
	muls.l	d1,d2
	

	move.l	d2,xslope
	move.l	#0,yslope	;yslope=0
	move.l	bsquare,d0
	move.l	a,d1
	neg.l	d1
	muls.l	d1,d0
	
	add.l	asquare,d0
	move.l	d0,fmid		;fmid=bsquare*(.25-a)+asquare
	move.l	xe,d0
	move.l	ye,d1
	move.l	xslope,d2
	move.l	yslope,d3
	move.l	fmid,d4
	move.l	asquare,d5
	move.l	a22,d6
	move.l	b22,d7
eloop1:
	cmp.l	d3,d2
	ble	beginnext

*	move.w	d0,pixelx
*	move.w	d1,pixely
*	bsr	putpixel

*	move.w	d0,(a0)+
*	move.w	d1,(a0)+
	move.w	value,(a0)+
	addq.l	#1,d1		;y=y+1
	add.l	d6,d3
	tst.l	d4		;if fmid<0
	bgt.s	fmt1
	add.l	d3,d4		;fmid=fmid+yslope+asquare
	add.l	d5,d4
	bra.s	eloop1
fmt1:
	sub.w	#1,value
	subq.l	#1,d0		;x=x-1
	sub.l	d7,d2		;xslope=xslope-b22
	sub.l	d2,d4		;fmid=fmid-xslope+yslope+asquare
	add.l	d3,d4
	add.l	d5,d4
	bra	eloop1

beginnext:
	move.l	d2,d5
	add.l	d3,d5		;(yslope+xslope)/2
	asr.l	#1,d5
	sub.l	d5,d4
	move.l	bsquare,d5
eloop2:
	subq.l	#1,d0		;x=x-1
	sub.l	d7,d2		;xslope=xslope-b22
	tst.l	d4		;if fmid<0
	blt.s	fmt2
	sub.l	d2,d4
	add.l	d5,d4
	tst.l	d0
	bge	eloop2
	move.l	a0,elipseend
	move.w	#-1,(a0)+	;signify end of coord list
	rts
fmt2:
*	move.w	d0,pixelx
*	move.w	d1,pixely
*	bsr	putpixel

*	move.w	d0,(a0)+	;fill, otherwise only add 1 point per y
*	move.w	d1,(a0)+
	move.w	value,(a0)+
skipcoadd2:
	addq.l	#1,d1		;y=y+1
	add.l	d6,d3		;yslope=yslope+a22
	sub.l	d2,d4		;fmid=fmid-xslope+yslope+bsquare
	add.l	d3,d4
	add.l	d5,d4
	tst.l	xe
	bge	eloop2
	move.l	a0,elipseend
	move.w	#-1,(a0)+	;signify end of coord list
	rts

elipseend:	dc.l	0
value:		dc.w	0
coords:		ds.w	1000

array:		ds.w	1000