startx:	equ	180
starty:	equ	100
endx:	equ	300
endy:	equ	170
lcount:	blk.w	1,0

light:
	move.w	#5,linecolor
	moveq	#0,d4
	moveq	#0,d5
	moveq	#0,d6
	moveq	#0,d7
	move.w	#startx,d4
	move.w	#starty,d5
	move.w	mx,d6
	move.w	my,d7
	sub.w	d4,d6		;d6 has amount to add to x
	sub.w	d5,d7		;d7 likewise for y
	asr.w	#3,d6		;div by 4 gives 4 sections
	asr.w	#3,d7		;div by 4
*	move.w	#startx,d0
*	move.w	#starty,d1
	move.w	#5,d0
	bsr	random
	move.w	d0,d2
	move.w	#5,d0
	bsr	random
	move.w	d0,d3
	move.w	d4,d0
	move.w	d5,d1
	add.w	d0,d2
	add.w	d1,d3
	add.w	d6,d2
	add.w	d7,d3
	movem.l	d0-d7,-(sp)
	bsr	clipit
	movem.l	(sp)+,d0-d7
	move.w	#5,lcount

lightloop:
	move.w	#5,d0
	bsr	random
	move.w	d0,d4
	move.w	#5,d0
	bsr	random
	move.w	d0,d5
	move.w	d2,d0
	move.w	d3,d1
	add.w	d6,d2
	add.w	d7,d3
	add.w	d4,d2
	add.w	d5,d3
	movem.l	d0-d7,-(sp)
	bsr	clipit
	movem.l	(sp)+,d0-d7
	subq.w	#1,lcount
	bpl	lightloop
	move.w	d2,d0
	move.w	d3,d1
	move.w	mx,d2
	move.w	my,d3
	movem.l	d0-d7,-(sp)
	bsr	clipit
	movem.l	(sp)+,d0-d7
	rts

