; include file
#dontinclude



function	sega_setupsprite	sega_setupsprite_sine,sega_setupsprite_draw,sega_setupsprite_write,sega_setupsprite_display,sega_setupsprite_rad2,sega_setupsprite_angle,sega_setupsprite_size
rem	sega_setupsprite( sine_table.l , sprite_table.l , save_table.l , display buffer 2316 size , rad.b, angle.b, size.b )
rem	sprite table must be byte form. rad range is 2-24. angle 0-255 . size 0-3 (1 tile to 16) 
rem	use sega_loadtile(#200,#16,#sega_setupsprite_write) to load graphics in
rem	uses stack & d7    

def	sega_setupsprite_sine	long
def	sega_setupsprite_draw	long
def	sega_setupsprite_angle	byte
def	sega_setupsprite_a2	byte

def	sega_setupsprite_rad	byte
def	sega_setupsprite_rad2	byte

def	sega_setupsprite_display	long	;string	2316
def	sega_setupsprite_write	long
; 32x32

def	sega_setupsprite_size	word

; 576 bytes

def	sega_setupsprite_xp2	word
def	sega_setupsprite_yp2	word
def	sega_setupsprite_xp1	word
def	sega_setupsprite_yp1	word
def	sega_setupsprite_xp3	word
def	sega_setupsprite_yp3	word
def	sega_setupsprite_xp4	word
def	sega_setupsprite_yp4	word


; more adds
def	sega_setupsprite_xld1	word
def	sega_setupsprite_xdir1	word	;test for quicker
def	sega_setupsprite_yld1	word
def	sega_setupsprite_ydir1	word
def	sega_setupsprite_xcnt1	word
def	sega_setupsprite_ycnt1	word
def	sega_setupsprite_wn1	word
def	sega_setupsprite_wn2	word
; more adds
def	sega_setupsprite_xld2	word
def	sega_setupsprite_yld2	word
def	sega_setupsprite_xcnt2	word
def	sega_setupsprite_ycnt2	word
def	sega_setupsprite_xxdir1	word
def	sega_setupsprite_xxdir2	word
def	sega_setupsprite_yydir1	word
def	sega_setupsprite_yydir2	word
; wb counters
def	sega_setupsprite_wbc1	word
def	sega_setupsprite_wbc2	word
; extra
def	sega_setupsprite_wb	word	;biggest of the lines =wn1 or wn2
; old

def	sega_setupsprite_col	word
def	sega_setupsprite_cola	word
def	sega_setupsprite_x1	word
def	sega_setupsprite_y1	word
def	sega_setupsprite_x2	word
def	sega_setupsprite_y2	word
def	sega_setupsprite_xd	word
def	sega_setupsprite_yd	word
def	sega_setupsprite_xc	word
def	sega_setupsprite_yc	word
def	sega_setupsprite_wn	word
def	sega_setupsprite_cnt	word
def	sega_setupsprite_bbc	word	;big boy counter
; new additions for test
def	sega_setupsprite_coldst1	word	;distance
def	sega_setupsprite_coldst2	word	;distance
def	sega_setupsprite_colcnt1	word	;counter for color swap
def	sega_setupsprite_colcnt2	word	;counter for color swap
def	sega_setupsprite_cwn1	word	;whole fraction
def	sega_setupsprite_cwn2	word	;whole fraction
def	sega_setupsprite_colc	word


stack	a0-a6/d1-d6
; 24 x 24 bytes to crunch
;32x32 now

sega_setupsprite

	clr.l	d7
	clr.l	d6
	clr.l	d5
	clr.l	d4
	clr.l	d3
	clr.l	d2
	clr.l	d1

	move.l	sega_setupsprite_draw,a6
	move.w	(a6),d6
	and.w	#$ff,d6
	move.w	d6,sega_setupsprite_coldst1
	move.w	d6,sega_setupsprite_coldst2



; sprite sizes can be 8x8 , 16x16 , 24x24 , 32x32
; must be square

	if	w,sega_setupsprite_size=>#3
	move.w	#3,sega_setupsprite_size
	endif

	





	if	b,sega_setupsprite_rad2<#2
	move.b	#2,sega_setupsprite_rad2
	endif

; 12 on other

	if	b,sega_setupsprite_rad2>#24
	move.b	#24,sega_setupsprite_rad2
	endif



	clr.l	d7
	move.l	sega_setupsprite_display,a6

	move.l	#578,d6

sega_setupsprite_clear

	move.l	d7,(a6)+
	dbra	d6,sega_setupsprite_clear






	move.w	#3,d4	;counter
	move.l	#sega_setupsprite_xp2,a4

	add.b	#32,sega_setupsprite_angle
sega_setupsprite_loop3


; plot angle code start
	clr.l	d7
	clr.l	d6
	clr.l	d5


	move.l	sega_setupsprite_sine,a6	;sinetable
	move.b	sega_setupsprite_angle,d7	;angle
	and.w	#$ff,d7
	mulu.w	#2,d7
	lea	(a6,d7.w),a6
	move.l	sega_setupsprite_sine,a5	;cosinetable
	clr.w	d7
	move.b	sega_setupsprite_angle,d7	;angle
	add.b	#64,d7
	mulu.w	#2,d7
	lea	(a5,d7.w),a5
; both tables should be good
	move.w	(a6),d7
	move.w	sega_setupsprite_rad,d6	;radx
	mulu.w	d6,d7
	move.b	d7,d6	;b on d6
	lsr.w	#8,d7	;a on d7
	and.w	#255,d7
	asl.b	#1,d6
	roxl.b	#1,d7
	add.w	#24,d7	;x position	was 12

	sub.w	sega_setupsprite_rad,d7	;radx
	move.w	d7,(a4)+

	move.w	(a5),d7
	move.w	sega_setupsprite_rad,d6	;rady
	add.w	#1,d7
	mulu.w	d6,d7
	move.b	d7,d6	;b on d6
	lsr.w	#8,d7	;a on d7
	and.w	#255,d7
	asl.b	#1,d6
	roxl.b	#1,d7
	add.w	#24,d7	;y pos 12

	sub.w	sega_setupsprite_rad,d7	;rad y
	move.w	d7,(a4)+


	add.b	#64,sega_setupsprite_angle

	dbra	d4,sega_setupsprite_loop3

;fixed shape





; lines 3d




sega_setupsprite_start

	clr.l	sega_setupsprite_xxdir1
	clr.l	sega_setupsprite_yydir1

	move.w	sega_setupsprite_xp1,d6
	cmp.w	sega_setupsprite_xp3,d6
	bls	sega_setupsprite_lons1
	sub.w	sega_setupsprite_xp3,d6
	move.w	d6,sega_setupsprite_xld1
	bra	sega_setupsprite_lons2
sega_setupsprite_lons1

	move.w	sega_setupsprite_xp3,d6
	sub.w	sega_setupsprite_xp1,d6
	sub.w	#1,sega_setupsprite_xxdir1
	move.w	d6,sega_setupsprite_xld1

sega_setupsprite_lons2

	move.w	sega_setupsprite_yp1,d6
	cmp.w	sega_setupsprite_yp3,d6
	bls	sega_setupsprite_lons3
	sub.w	sega_setupsprite_yp3,d6
	move.w	d6,sega_setupsprite_yld1
	bra	sega_setupsprite_lons4

sega_setupsprite_lons3
	move.w	sega_setupsprite_yp3,d6
	sub.w	sega_setupsprite_yp1,d6
	sub.w	#1,sega_setupsprite_yydir1
	move.w	d6,sega_setupsprite_yld1

; which is greater?
sega_setupsprite_lons4

	move.w	sega_setupsprite_yld1,d6
	cmp.w	sega_setupsprite_xld1,d6
	blo	sega_setupsprite_lons5	;y is lower then goto lins5
	move.w	d6,sega_setupsprite_wn1	;x is lower so save y as whole fraction
	bra	sega_setupsprite_lans0	;done

sega_setupsprite_lons5
	move.w	sega_setupsprite_xld1,d6
	move.w	d6,sega_setupsprite_wn1

; second line track
sega_setupsprite_lans0

	move.w	sega_setupsprite_xp2,d6
	cmp.w	sega_setupsprite_xp4,d6
	bls	sega_setupsprite_lans1

	sub.w	sega_setupsprite_xp4,d6
	move.w	d6,sega_setupsprite_xld2
	bra	sega_setupsprite_lans2

sega_setupsprite_lans1

	move.w	sega_setupsprite_xp4,d6
	sub.w	sega_setupsprite_xp2,d6
	sub.w	#1,sega_setupsprite_xxdir2
	move.w	d6,sega_setupsprite_xld2

sega_setupsprite_lans2

	move.w	sega_setupsprite_yp2,d6
	cmp.w	sega_setupsprite_yp4,d6
	bls	sega_setupsprite_lans3
	sub.w	sega_setupsprite_yp4,d6
	move.w	d6,sega_setupsprite_yld2
	bra	sega_setupsprite_lans4



sega_setupsprite_lans3

	move.w	sega_setupsprite_yp4,d6
	sub.w	sega_setupsprite_yp2,d6
	sub.w	#1,sega_setupsprite_yydir2
	move.w	d6,sega_setupsprite_yld2

; which is greater?
sega_setupsprite_lans4

	move.w	sega_setupsprite_yld2,d6
	cmp.w	sega_setupsprite_xld2,d6

	blo	sega_setupsprite_lans5	;y is lower then goto lins5
	move.w	d6,sega_setupsprite_wn2	;x is lower so save y as whole fraction
	bra	sega_setupsprite_lbns0	;done

sega_setupsprite_lans5
	move.w	sega_setupsprite_xld2,d6	;nope y is lower so save x as whole fraction
	move.w	d6,sega_setupsprite_wn2	;stored it

; which line is bigger
sega_setupsprite_lbns0

	move.w	sega_setupsprite_wn1,d6
	cmp.w	sega_setupsprite_wn2,d6


	blo	sega_setupsprite_lbns1	;y is lower then goto lins5
	move.w	d6,sega_setupsprite_wb	;big num fraction
	move.w	d6,sega_setupsprite_bbc
	bra	sega_setupsprite_lbnsdn	;done
sega_setupsprite_lbns1



	move.w	sega_setupsprite_wn2,d6	;nope y is lower so save x as whole fraction
	move.w	d6,sega_setupsprite_wb	;stored it
	move.w	d6,sega_setupsprite_bbc

; ok lets get this line going clear the start
sega_setupsprite_lbnsdn


	clr.w	sega_setupsprite_colc
	clr.w	sega_setupsprite_xcnt1	;x counter
	clr.w	sega_setupsprite_ycnt1	;y counter

	clr.w	sega_setupsprite_wbc1	;line counter
	clr.w	sega_setupsprite_wbc2
	clr.w	sega_setupsprite_xcnt2	;x counter
	clr.w	sega_setupsprite_ycnt2	;y counter
; new track



	move.w	sega_setupsprite_wb,d6
	sub.w	#1,d6
	move.w	d6,sega_setupsprite_cwn2	;color
	clr.w	sega_setupsprite_colcnt2	;half boost start




sega_setupsprite_mainline
	move.l	sega_setupsprite_xp1,d6
	move.l	d6,sega_setupsprite_x1
	move.l	sega_setupsprite_xp2,d6
	move.l	d6,sega_setupsprite_x2
; saved page
; ****************************************************************************************************** base loop

	clr.w	sega_setupsprite_xdir1	;test
	clr.w	sega_setupsprite_ydir1
	move.w	sega_setupsprite_x1,d6	;ok no swapping just get distances
	cmp.w	sega_setupsprite_x2,d6
	bls	sega_setupsprite_lins1	;if x1 is lower
	sub.w	sega_setupsprite_x2,d6	;its greater so sub x2
	move.w	d6,sega_setupsprite_xd	;save x distance
	bra	sega_setupsprite_lins2

sega_setupsprite_lins1

	move.w	sega_setupsprite_x2,d6
	sub.w	sega_setupsprite_x1,d6
	move.w	d6,sega_setupsprite_xd
	sub.w	#1,sega_setupsprite_xdir1	;test

sega_setupsprite_lins2

	move.w	sega_setupsprite_y1,d6	;ok now lets look at y
	cmp.w	sega_setupsprite_y2,d6
	bls	sega_setupsprite_lins3	;y1 is lower?
	sub.w	sega_setupsprite_y2,d6
	move.w	d6,sega_setupsprite_yd	;save y distance
	bra	sega_setupsprite_lins4

sega_setupsprite_lins3

	move.w	sega_setupsprite_y2,d6
	sub.w	sega_setupsprite_y1,d6
	move.w	d6,sega_setupsprite_yd
	sub.w	#1,sega_setupsprite_ydir1	;test

; which is greater?
sega_setupsprite_lins4

	move.w	sega_setupsprite_yd,d6
	cmp.w	sega_setupsprite_xd,d6
	blo	sega_setupsprite_lins5	;y is lower then goto lins5
	move.w	d6,sega_setupsprite_wn	;x is lower so save y as whole fraction
	bra	sega_setupsprite_lins6	;done

sega_setupsprite_lins5

	move.w	sega_setupsprite_xd,d6	;nope y is lower so save x as whole fraction
	move.w	d6,sega_setupsprite_wn	;stored it
; ok now the main loop

sega_setupsprite_lins6

	clr.w	sega_setupsprite_xc	;x counter
	clr.w	sega_setupsprite_yc	;y counter
	move.w	sega_setupsprite_wn,d6
	move.w	d6,sega_setupsprite_cnt	;set counter
	add.w	#1,sega_setupsprite_cnt
; setup color test y axis

	move.l	sega_setupsprite_draw,a3
	lea	(2,a3),a3
	move.w	sega_setupsprite_colc,d6
	move.w	sega_setupsprite_coldst2,d5
	mulu.w	d5,d6
	lea	(a3,d6.w),a3


; setup x axis color
	move.w	sega_setupsprite_wn,d6
	move.w	d6,sega_setupsprite_cwn1	;colors is longer
	clr.w	sega_setupsprite_colcnt1	;half boost start
; main loop of original line
; no this is dot

sega_setupsprite_line22

;dot 24x24
	move.l	sega_setupsprite_display,a4
	move.w	#48,d5
	move.w	sega_setupsprite_y1,d6
	mulu.w	d5,d6
	add.w	sega_setupsprite_x1,d6
	lea	(a4,d6.w),a4

	move.b	(a3),(a4)+
	move.b	(a4),d5


	if	b,d5=#0
	move.b	(a3),(a4)
	endif


; check color advancement
; done	
sega_setupsprite_done2

	move.w	sega_setupsprite_colcnt1,d6
	add.w	sega_setupsprite_coldst1,d6
	cmp.w	sega_setupsprite_cwn1,d6
	bls	sega_setupsprite_carryon
; continue loop
sega_setupsprite_carrym
	sub.w	sega_setupsprite_cwn1,d6
	lea	(1,a3),a3
	cmp.w	sega_setupsprite_cwn1,d6
	bhi	sega_setupsprite_carrym

sega_setupsprite_carryon
	move.w	d6,sega_setupsprite_colcnt1	;save it
; color check done
; end test


	move.w	sega_setupsprite_xc,d6
	add.w	sega_setupsprite_xd,d6	;add distance to xc counter
	cmp.w	sega_setupsprite_wn,d6	;has it gone over or same as our whole fraction?
	bhs	sega_setupsprite_adv2	;it has on x.... lets advance it
	move.w	d6,sega_setupsprite_xc	;nope keep counting 
	bra	sega_setupsprite_chk2	;lets check y now

sega_setupsprite_adv2

	sub.w	sega_setupsprite_wn,d6	;advance the x counter....subtract the whole fraction
	move.w	d6,sega_setupsprite_xc	;store remainder to play with next loop
	move.w	sega_setupsprite_xdir1,d6
	bpl	sega_setupsprite_advx2
	add.w	#1,sega_setupsprite_x1	;increase y plot or dec?
	bra	sega_setupsprite_chk2
sega_setupsprite_advx2
	sub.w	#1,sega_setupsprite_x1
sega_setupsprite_chk2
	move.w	sega_setupsprite_yc,d6	;now the y axis.... loader up
	add.w	sega_setupsprite_yd,d6	;add its distance
	cmp.w	sega_setupsprite_wn,d6	;has it gone over or the same as our whole fraction
	bhs	sega_setupsprite_advy2	;it has on y.... lets advance it
	move.w	d6,sega_setupsprite_yc	;nope... keep counting
	bra	sega_setupsprite_chkx2	;done
; advance it

sega_setupsprite_advy2
	sub.w	sega_setupsprite_wn,d6	;subtract the whole number from y counter
	move.w	d6,sega_setupsprite_yc	;store the remainder for next loop
	move.w	sega_setupsprite_ydir1,d6
	bpl	sega_setupsprite_ady2
	add.w	#1,sega_setupsprite_y1	;increase y plot or dec?
	bra	sega_setupsprite_chkx2
sega_setupsprite_ady2
	sub.w	#1,sega_setupsprite_y1
; done?

sega_setupsprite_chkx2
	sub.w	#1,sega_setupsprite_cnt	;check the counter
	bne	sega_setupsprite_line22	;nope keep plotting the line
; 
; end of original line
; 
; use to be done....   now we need to advance other two lines
; 
; line 1


	move.w	sega_setupsprite_wbc1,d6	;line 1 counter
	add.w	sega_setupsprite_wn1,d6	;add distance to xc counter
	cmp.w	sega_setupsprite_wb,d6	;big boy number
	bhs	sega_setupsprite_wadv2	;it has on x.... lets advance it*****************************************************
	move.w	d6,sega_setupsprite_wbc1	;nope keep counting	
; line 2
sega_setupsprite_wchk2

	move.w	sega_setupsprite_wbc2,d6	;line 2 counter
	add.w	sega_setupsprite_wn2,d6	;add distance to xc counter
	cmp.w	sega_setupsprite_wb,d6	;big boy number
	bhs	sega_setupsprite_wadv3	;it has on x.... lets advance it *****************************************************
	move.w	d6,sega_setupsprite_wbc2	;nope keep counting 
; end lets loop
; check color advancement


sega_setupsprite_lastcnt

	move.w	sega_setupsprite_colcnt2,d6
	add.w	sega_setupsprite_coldst2,d6
	cmp.w	sega_setupsprite_cwn2,d6
	bls	sega_setupsprite_carryon2
; continue loop

sega_setupsprite_carrym2

	sub.w	sega_setupsprite_cwn2,d6
	add.w	#1,sega_setupsprite_colc	;the advancer
	cmp.w	sega_setupsprite_cwn2,d6
	bhi	sega_setupsprite_carrym2

sega_setupsprite_carryon2

	move.w	d6,sega_setupsprite_colcnt2	;save it
	sub.w	#1,sega_setupsprite_bbc	;big boy counter
	move.w	sega_setupsprite_bbc,d6
	bne	sega_setupsprite_mainline
	bra	sega_setupsprite_done3d

; correct
sega_setupsprite_wadv2
	sub.w	sega_setupsprite_wb,d6	;advance the x counter....subtract the whole fraction
	move.w	d6,sega_setupsprite_wbc1	;store remainder to play with next loop
; move  down line1 here

	move.w	sega_setupsprite_xcnt1,d6
	add.w	sega_setupsprite_xld1,d6	;add distance to xc counter
	cmp.w	sega_setupsprite_wn1,d6	;has it gone over or same as our whole fraction?
	bhs	sega_setupsprite_aadv2	;it has on x.... lets advance it

	move.w	d6,sega_setupsprite_xcnt1	;nope keep counting 
	bra	sega_setupsprite_achk2	;lets check y now

sega_setupsprite_aadv2

	sub.w	sega_setupsprite_wn1,d6	;advance the x counter....subtract the whole fraction
	move.w	d6,sega_setupsprite_xcnt1	;store remainder to play with next loop
	move.w	sega_setupsprite_xxdir1,d6
	bpl	sega_setupsprite_aadvx2

	add.w	#1,sega_setupsprite_xp1	;increase y plot or dec?
	bra	sega_setupsprite_achk2

sega_setupsprite_aadvx2
	sub.w	#1,sega_setupsprite_xp1
sega_setupsprite_achk2


	move.w	sega_setupsprite_ycnt1,d6	;now the y axis.... loader up
	add.w	sega_setupsprite_yld1,d6	;add its distance
	cmp.w	sega_setupsprite_wn1,d6	;has it gone over or the same as our whole fraction
	bhs	sega_setupsprite_aadvy2	;it has on y.... lets advance it
	move.w	d6,sega_setupsprite_ycnt1	;nope... keep counting

	bra	sega_setupsprite_wchk2	;done lets look at other line

; advance it
sega_setupsprite_aadvy2

	sub.w	sega_setupsprite_wn1,d6	;subtract the whole number from y counter
	move.w	d6,sega_setupsprite_ycnt1	;store the remainder for next loop
	move.w	sega_setupsprite_yydir1,d6	;yp1
	bpl	sega_setupsprite_aady2

	add.w	#1,sega_setupsprite_yp1	;increase y plot or dec?
	bra	sega_setupsprite_wchk2


sega_setupsprite_aady2
	sub.w	#1,sega_setupsprite_yp1
	bra	sega_setupsprite_wchk2

; done that line
sega_setupsprite_wadv3
	sub.w	sega_setupsprite_wb,d6	;advance the x counter....subtract the whole fraction
	move.w	d6,sega_setupsprite_wbc2	;store remainder to play with next loop
; move  down line1 here
	move.w	sega_setupsprite_xcnt2,d6
	add.w	sega_setupsprite_xld2,d6	;add distance to xc counter
	cmp.w	sega_setupsprite_wn2,d6	;has it gone over or same as our whole fraction?
	bhs	sega_setupsprite_badv2	;it has on x.... lets advance it

	move.w	d6,sega_setupsprite_xcnt2	;nope keep counting 
	bra	sega_setupsprite_bchk2	;lets check y now

sega_setupsprite_badv2

	sub.w	sega_setupsprite_wn2,d6	;advance the x counter....subtract the whole fraction
	move.w	d6,sega_setupsprite_xcnt2	;store remainder to play with next loop
	move.w	sega_setupsprite_xxdir2,d6	;xp2

	bpl	sega_setupsprite_badvx2
	add.w	#1,sega_setupsprite_xp2	;increase y plot or dec?
	bra	sega_setupsprite_bchk2


sega_setupsprite_badvx2
	sub.w	#1,sega_setupsprite_xp2
sega_setupsprite_bchk2
	move.w	sega_setupsprite_ycnt2,d6	;now the y axis.... loader up
	add.w	sega_setupsprite_yld2,d6	;add its distance
	cmp.w	sega_setupsprite_wn2,d6	;has it gone over or the same as our whole fraction
	bhs	sega_setupsprite_badvy2	;it has on y.... lets advance it
	move.w	d6,sega_setupsprite_ycnt2	;nope... keep counting

	bra	sega_setupsprite_lastcnt
; advance it
sega_setupsprite_badvy2
	sub.w	sega_setupsprite_wn2,d6	;subtract the whole number from y counter
	move.w	d6,sega_setupsprite_ycnt2	;store the remainder for next loop
	move.w	sega_setupsprite_yydir2,d6	;yp2
	bpl	sega_setupsprite_bady2
	add.w	#1,sega_setupsprite_yp2	;increase y plot or dec?

	bra	sega_setupsprite_lastcnt
sega_setupsprite_bady2	
	sub.w	#1,sega_setupsprite_yp2
	bra	sega_setupsprite_lastcnt






sega_setupsprite_done3d






; 3x3

	if	w,sega_setupsprite_size=#3

; ram that into a sprite tile set test
	move.l	sega_setupsprite_display,a6
	lea	(392,a6),a6	;jump over first 392

	move.l	sega_setupsprite_write,a5
	move.l	#3,d4	;was 2
sega_setupsprite_loop2

	move.l	#31,d5	;was 23
sega_setupsprite_loop1
;	and.b	#$F,(a6)
	move.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$F,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
; next 2 bytes
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
; write d7 as first 8
	move.l	d7,(a5)+
	lea	(40,a6),a6	;move 16 pixels and do next line
	dbra	d5,sega_setupsprite_loop1
; ****************************************************************************************************** d5

	move.l	sega_setupsprite_display,a6
	lea	(392,a6),a6	;jump over first 392

	lea	(8,a6),a6

	if	l,d4=#1
	lea	(16,a6),a6
	endif

	if	l,d4=#2
	lea	(8,a6),a6
	endif


	dbra	d4,sega_setupsprite_loop2
; ***************************************************************************************************** d4
;ok its moved


	rts

	endif




; 2x2
	if	w,sega_setupsprite_size=#2

; ram that into a sprite tile set test
	move.l	sega_setupsprite_display,a6
	lea	(588,a6),a6	;jump over first 392

	move.l	sega_setupsprite_write,a5
	move.l	#2,d4	;was 2
sega_setupsprite_loop5

	move.l	#23,d5	;was 23
sega_setupsprite_loop4
;	and.b	#$F,(a6)
	move.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$F,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
; next 2 bytes
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
; write d7 as first 8
	move.l	d7,(a5)+
	lea	(40,a6),a6	;move 16 pixels and do next line
	dbra	d5,sega_setupsprite_loop4
; ****************************************************************************************************** d5

	move.l	sega_setupsprite_display,a6
	lea	(588,a6),a6	;jump over first 392

	lea	(8,a6),a6


	if	l,d4=#1
	lea	(8,a6),a6
	endif


	dbra	d4,sega_setupsprite_loop5
; ***************************************************************************************************** d4
;ok its moved


	rts

	endif






; 1x1
	if	w,sega_setupsprite_size=#1

; ram that into a sprite tile set test
	move.l	sega_setupsprite_display,a6
	lea	(784,a6),a6	;jump over first 392

	move.l	sega_setupsprite_write,a5
	move.l	#1,d4	;was 2
sega_setupsprite_loop7

	move.l	#15,d5	;was 23
sega_setupsprite_loop6
;	and.b	#$F,(a6)
	move.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$F,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
; next 2 bytes
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
; write d7 as first 8
	move.l	d7,(a5)+
	lea	(40,a6),a6	;move 16 pixels and do next line
	dbra	d5,sega_setupsprite_loop6
; ****************************************************************************************************** d5

	move.l	sega_setupsprite_display,a6
	lea	(784,a6),a6	;jump over first 392

	lea	(8,a6),a6



	dbra	d4,sega_setupsprite_loop7
; ***************************************************************************************************** d4
;ok its moved


	rts

	endif









; 0x0
	if	w,sega_setupsprite_size=#0

; ram that into a sprite tile set test
	move.l	sega_setupsprite_display,a6
	lea	(980,a6),a6	;jump over first 392

	move.l	sega_setupsprite_write,a5


	move.l	#7,d5	;was 23
sega_setupsprite_loop9
;	and.b	#$F,(a6)
	move.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$F,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
; next 2 bytes
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
	lsl.l	#4,d7
;	and.b	#$f,(a6)
	add.b	(a6)+,d7
; write d7 as first 8
	move.l	d7,(a5)+
	lea	(40,a6),a6	;move 16 pixels and do next line
	dbra	d5,sega_setupsprite_loop9
; ****************************************************************************************************** d5
; ***************************************************************************************************** d4
;ok its moved


	rts

	endif







endfunction


























