**********************************************
* S  T  A  R  S  coded by QUASAR OF DAWN/ACU *
**********************************************

st:	lea	$dff000,a6
	move	#$4000,$9a(a6)
	move.l	#copper,$84(a6)
	clr	$8a(a6)
	bsr	makestars

main	cmp.b	#-1,6(A6)	;main loop
	bne.s	main

	bsr	stars

	btst	#6,$bfe001	;chack mouse
	bne.s	main		;if not press then go back up
	move	#$c000,$9a(A6)	; else return to System
	rts

*-----------------
nostars = 268 		; lines worth

mkstar:	macro		; makes random X-coord for every star/sprite
	moveq	#0,d2		;and a continious Y-coord
	move	6(a6),d3	;make random number by multipling
	mulu	#$3a458,d3	; clock + VH pos
	add	6(A6),d3
	muls	$bfe800,d3
	muls	#13463911,d3
	add	d4,d3
	add	#24,d4
	move.b	d0,(a0)		;store Y coord
	move.b	d3,1(a0)	;store X coord
	move.b	d1,2(a0)	;store Y+1 coord
	cmp	#$ff,d0		; if Y > $ff then set high bits
	dc.w	$6f02		;ble.s PC+2
	moveq	#%110,d2	;set high bits here !!!
	move.b	d2,3(a0)	;store bits !!!!
	move.l	#$00380058,4(a0)	;star texture here !!!!!!!!!
endm

; 8 sprite list pointers
stars1	dc.l	0*nostars*8+star_data
stars2	dc.l	1*nostars*8+star_data
stars3	dc.l	2*nostars*8+star_data
stars4	dc.l	3*nostars*8+star_data
stars5	dc.l	4*nostars*8+star_data
stars6	dc.l	5*nostars*8+star_data
stars7	dc.l	6*nostars*8+star_data
stars8	dc.l	7*nostars*8+star_data

makestars
	lea	star_data(pc),a0
	moveq	#$24,d0		;Y start
	moveq	#$25,d1		;Y stop
	moveq	#34,d4

makestars2
	move	#nostars-1,d7
mkstarsLP			;do the 8 sprites !!
	move.l	stars1(pc),a0
	mkstar
	move.l	stars2(pc),a0
	mkstar
	move.l	stars3(pc),a0
	mkstar
	move.l	stars4(pc),a0
	mkstar
	move.l	stars5(pc),a0
	mkstar
	move.l	stars6(pc),a0
	mkstar
	move.l	stars7(pc),a0
	mkstar

	moveq	#8,d6		;update sprite list pointers
	lea	stars1(pc),a0
	add.l	d6,(a0)
	add.l	d6,04(a0)
	add.l	d6,08(a0)
	add.l	d6,12(a0)
	add.l	d6,16(a0)
	add.l	d6,20(a0)
	add.l	d6,24(a0)
	add.l	d6,28(a0)

	addq	#2,d0
	addq	#2,d1
	dbf	d7,mkstarsLP

	lea	spr(pc),a0	; set up sprite pointers
	moveq	#7,d7
	move.l	#star_data,d1
mkpoint	move	d1,6(a0)
	swap	D1
	move	d1,2(a0)
	swap	d1
	add.l	#nostars*8,d1
	addq.l	#8,a0
	dbf	d7,mkpoint
	rts

*-------
stars	lea	star_data(pc),a0
	move	#nostars*2-1,d7
	moveq	#32,d6
star_lp	sub.b	#1,1(a0)	; the 4 layers are here !!
	sub.b	#2,9(a0)	; change subtracting values
	sub.b	#3,17(a0)	; for different speeds
	sub.b	#4,25(a0)	; and directions
	add.l	d6,a0
	dbf	d7,star_lp
	rts


copper	dc.l $01000300
	dc.l $008e2370,$009032d8,$00920038,$009400d8 ; overscan
	dc.l $00e00000,$00e20000,$01800000,$01820000
	dc.l $0108ffd6

bit	dc.l $00e00000,$00e203d4,$01001300

spr	dc.l $01200000,$01220000
	dc.l $01240000,$01260000
	dc.l $01280000,$012a0000
	dc.l $012c0000,$012e0000
	dc.l $01300000,$01320000
	dc.l $01340000,$01360000
	dc.l $01380000,$013a0000
	dc.l $013c0000,$013e0000

color	dc.l $01a20fff,$01a40999,$01a60444
	dc.l $01aa0ddf,$01ac0779,$01ae0334
	dc.l $01b20bbf,$01b40669,$01b60224
	dc.l $01ba099f,$01bc0559,$01be0114

	dc.l $2109fffe,$01800001
	dc.l $2209fffe,$01800112
	dc.l $2309fffe,$01800223
	dc.l $2409fffe,$01800334
	dc.l $2509fffe,$01800445
	dc.l $2609fffe,$01800556
	dc.l $2709fffe,$01800667
	dc.l $2809fffe,$01800778
	dc.l $2909fffe,$01800889
	dc.l $2a09fffe,$0180099a
	dc.l $2b09fffe,$01800aab
	dc.l $2c09fffe,$01800bbc
	dc.l $2d09fffe,$01800ccd
	dc.l $2e09fffe,$01800dde
	dc.l $2f09fffe,$01800eef
	dc.l $3009fffe,$01800aab
	dc.l $3109fffe,$01800667
	dc.l $3209fffe,$01800334
	dc.l $3309fffe,$01800112
	dc.l $3409fffe,$01800000

	dc.l $ffdffffe

	dc.l $1c09fffe,$01800112
	dc.l $1d09fffe,$01800334
	dc.l $1e09fffe,$01800667
	dc.l $1f09fffe,$01800aab
	dc.l $2009fffe,$01800eef
	dc.l $2109fffe,$01800dde
	dc.l $2209fffe,$01800ccd
	dc.l $2309fffe,$01800bbc
	dc.l $2409fffe,$01800aab
	dc.l $2509fffe,$0180099a
	dc.l $2609fffe,$01800889
	dc.l $2709fffe,$01800778
	dc.l $2809fffe,$01800667
	dc.l $2909fffe,$01800556
	dc.l $2a09fffe,$01800445
	dc.l $2b09fffe,$01800334
	dc.l $2c09fffe,$01800223
	dc.l $2d09fffe,$01800112
	dc.l $2e09fffe,$01800001
	dc.l $2f09fffe,$01800000
	dc.l $3809fffe,$008a0000,-2
star_data	blk.b	nostars*8*8
