start:
	move.w	#10,edgetrans
	move.w	#5,centretrans
	move.w	#32,d1
	move.w	#4,d0
	lea	transxlist,a0
	bsr	calcranges

	clr.w	-(sp)
	trap	#1

startvalue:	dc.w	0
numpixels:	dc.w	0
amplitude:	dc.w	0
startangle:	dc.w	0
reverseflag:	dc.w	0
*************************************************************************
*	Pass translist to fill in a0, transpx after calcs		*
*	in d0, and the width or height in d1(depending			*
*	on the transmode.						*
*	Uses edgetrans, centretrans.					*
*************************************************************************
calcranges:
	move.w	#0,shifter			;this for 1 or 2 active axis
*	cmpi.w	#issphere,transmode
*	beq	skida1
*	move.w	#2,shifter
*skida1:
	moveq	#0,d2
	move.w	d1,d2			;copy number of pixels to calc trans of
	asr.w	#3,d2			;div by 8
	cmpi.w	#7,d0
	bne	isntmax
	move.w	d1,d2
	bra	skipmax
isntmax:
	mulu	d0,d2			;so the first range goes 0 to d2
	tst.w	d2
	beq	nofirstrange
skipmax:
	move.w	#0,startangle
	move.w	d2,numpixels
	move.w	#-1,reverseflag
	move.w	centretrans,d4
	move.w	edgetrans,d5
	move.w	d5,startvalue
	sub.w	d5,d4
	tst.w	d4
	bgt.s	noswaptrans
	move.w	#1,reverseflag
	neg.w	d4		;gives actual number of segments=radius
	move.w	centretrans,startvalue
noswaptrans:
	addq.w	#1,d4
	move.w	d4,amplitude
	movem.w	d0-d2,-(sp)
	bsr	docalcrange
	movem.w	(sp)+,d0-d2
*	move.w	#-1,(a0)+
	cmpi.w	#7,d0
	bne	nofirstrange
	rept	10
	move.w	#-1,(a0)+	;for dither check
	endr
	rts
nofirstrange:
	sub.w	d2,d1
	move.w	d1,d2

	move.w	#95,startangle
	move.w	d2,numpixels
	move.w	centretrans,d5
	move.w	edgetrans,d4
	move.w	d4,startvalue
	cmp.w	d5,d4
	blt	noswapst
	move.w	d5,startvalue
noswapst:
	bsr	docalcrange
	rept	10
	move.w	#-1,(a0)+	;for dither check
	endr
	rts

docalcrange:
	tst.w	reverseflag
	bpl	doreversed
	move.l	#90*256,d0		;to number of angles
	divu	numpixels,d0
	and.l	#$0000ffff,d0
	move.l	d0,angleadd		;amount to add to angle each time through
	moveq	#0,d0		;starting angle
	move.w	startangle,d0
	asl.l	#8,d0		;scale up
	move.w	amplitude,d1	;radius
	move.w	numpixels,d7		;number of segments
	subq.w	#1,d7
	lea	sintab,a1
plotsinloop:
	moveq	#0,d4
	move.w	d0,d5
	asr.l	#8,d5		;scale down
	add.w	d5,d5
	move.w	(a1,d5.w),d4
	mulu	d1,d4
	asl.l	#2,d4		;scale down
	swap	d4		;by shifting 14 right
	add.w	startvalue,d4
	moveq	#0,d5
	move.w	shifter,d5
	lsl.w	d5,d4
	move.w	d4,(a0)+
	add.l	angleadd,d0
	cmp.l	#180*256,d0
	ble.s	aok
	move.l	#180*256,d0
aok:
	dbf	d7,plotsinloop
	rts

doreversed:
	move.l	#90*256,d0		;to number of angles
	divu	numpixels,d0
	and.l	#$0000ffff,d0
	move.l	d0,angleadd		;amount to add to angle each time through
	moveq	#0,d0		;starting angle
	move.w	startangle,d0
	asl.l	#8,d0		;scale up
	move.w	amplitude,d1	;radius
	move.w	numpixels,d7		;number of segments
	subq.w	#1,d7
	lea	sintab,a1
plotsinloop2:
	moveq	#0,d4
	move.w	d0,d5
	asr.l	#8,d5		;scale down
	add.w	d5,d5
	move.w	(a1,d5.w),d4
	mulu	d1,d4
	asl.l	#2,d4		;scale down
	swap	d4		;by shifting 14 right
	move.w	d1,d5
	subq.w	#1,d5
	sub.w	d4,d5
	move.w	d5,d4
	add.w	startvalue,d4
	moveq	#0,d5
	move.w	shifter,d5
	lsl.w	d5,d4
	move.w	d4,(a0)+
	add.l	angleadd,d0
	cmp.l	#180*256,d0
	ble.s	aok2
	move.l	#180*256,d0
aok2:
	dbf	d7,plotsinloop2
	rts


angleadd:	dc.l	0
shifter:	dc.w	0
		dc.w	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
xl:
transxlist:	ds.w	320
		dc.w	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
		dc.w	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
transylist:	ds.w	480
		dc.w	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1


	include	sintab.s

topred:	dc.w	0
bottomred:	dc.w	0
redadd:		dc.w	0
edgetrans:	dc.w	0
centretrans:	dc.w	0
generalvalue:	dc.w	0
y1:		dc.w	0