*****************************************
*	rotate scroll stuff		*
* prerotate and write out blocks for background
*****************************************
prerotate:
	lea	scrolltated,a5
	lea	multi,a6
	moveq	#15,d7			;do normal
	bsr	dor
	lea	scrolltated2,a5
	lea	back,a6
	lea	front,a4
	moveq	#15,d7
	bsr	dortwo
illegal
	rts

dortwo:
	move.l	a5,a1
	moveq	#0,d0		;scroll value 1
	moveq	#0,d1		;scroll value 2
prloopb:
	move.l	a4,a0		;front one
	move.l	a6,a2
	move.w	d7,d2		;count for height
prloop2b:
	move.w	(a0),d3
	or.w	2(a0),d3
	or.w	4(a0),d3
	or.w	6(a0),d3	;make a amask
	eor.w	#-1,d3
	ror.w	d0,d3		;thats our mask
	move.w	d3,d6		;save it

	move.w	d0,d1
	asr.w	#1,d1		;halve it

	move.w	(a2)+,d3
	ror.w	d1,d3
	and.w	d6,d3		;cut hole in it
	move.w	(a0)+,d4
	ror.w	d0,d4
	or.w	d4,d3		;put it in the hole
	move.w	d3,(a1)+	;final

	move.w	(a2)+,d3
	ror.w	d1,d3
	and.w	d6,d3		;cut hole in it
	move.w	(a0)+,d4
	ror.w	d0,d4
	or.w	d4,d3		;put it in the hole
	move.w	d3,(a1)+	;final

	move.w	(a2)+,d3
	ror.w	d1,d3
	and.w	d6,d3		;cut hole in it
	move.w	(a0)+,d4
	ror.w	d0,d4
	or.w	d4,d3		;put it in the hole
	move.w	d3,(a1)+	;final

	move.w	(a2)+,d3
	ror.w	d1,d3
	and.w	d6,d3		;cut hole in it
	move.w	(a0)+,d4
	ror.w	d0,d4
	or.w	d4,d3		;put it in the hole
	move.w	d3,(a1)+	;final

	dbf	d2,prloop2b
	addq.w	#1,d0
	cmpi.w	#15,d0
	ble	prloopb
	rts




dor:
	move.l	a5,a1
	moveq	#0,d0
prloop:
	move.l	a6,a0
	move	d7,d1
prloop2:
	move.w	(a0)+,d3
	ror.w	d0,d3
	move.w	d3,(a1)+
	move.w	(a0)+,d3
	ror.w	d0,d3
	move.w	d3,(a1)+
	move.w	(a0)+,d3
	ror.w	d0,d3
	move.w	d3,(a1)+
	move.w	(a0)+,d3
	ror.w	d0,d3
	move.w	d3,(a1)+
	dbf	d1,prloop2
	addq.w	#1,d0
	cmpi.w	#15,d0
	ble	prloop
	rts



scrolltated:	blk.w	1024,0
scrolltated2:	blk.w	1024,0
sc:
back:
	 dc.w	$FFFF,$0000,$7070,$7070,$FFFF,$0000,$7676,$7676
	 dc.w	$FFFF,$0000,$8A8A,$8A8A,$FFFF,$0000,$CCCC,$CCCC
	 dc.w	$FFFF,$0000,$C5C5,$C5C5,$FFFF,$0000,$2929,$2929
	 dc.w	$FFFF,$0000,$0101,$0101,$FFFF,$0000,$4040,$4040
	 dc.w	$FFFF,$0000,$CECE,$CECE,$FFFF,$0000,$F6F6,$F6F6
	 dc.w	$FFFF,$0000,$8080,$8080,$FFFF,$0000,$9191,$9191
	 dc.w	$FFFF,$0000,$3333,$3333,$FFFF,$0000,$7373,$7373
	 dc.w	$FFFF,$0000,$4040,$4040,$FFFF,$0000,$8C8C,$8C8C

front:
	 dc.w	$0002,$C000,$8003,$4000,$0004,$E001,$6007,$8000
	 dc.w	$1008,$6002,$700E,$0000,$0810,$2004,$381C,$0000
	 dc.w	$0420,$1008,$1C38,$0000,$0240,$0810,$0E70,$0000
	 dc.w	$0100,$04A0,$07E0,$0000,$0000,$0240,$03C0,$0000
	 dc.w	$0040,$0300,$01C0,$0200,$0020,$0780,$06E0,$0100
	 dc.w	$0810,$0240,$0E70,$0000,$1008,$0420,$1C38,$0000
	 dc.w	$2004,$0810,$381C,$0000,$4002,$1008,$700E,$0000
	 dc.w	$8001,$2004,$E007,$0000,$0000,$4002,$C003,$0000

multi:
	 dc.w	$B9EB,$018B,$FE74,$FFFF,$BEEB,$028B,$FD74,$FFFF
	 dc.w	$3FF7,$2317,$DCE8,$FFFF,$5DD7,$4117,$BEE8,$FFFF
	 dc.w	$5FDB,$430A,$BCF5,$FFFF,$5FD7,$4306,$BCF9,$FFFF
	 dc.w	$AEE7,$2284,$DD7B,$FFFF,$ACFB,$2082,$DF7D,$FFFF
	 dc.w	$DEF7,$1206,$EDF9,$FFFF,$DDEB,$010A,$FEF5,$FFFF
	 dc.w	$D9E3,$0102,$FEFD,$FFFF,$3DC3,$0D02,$F2FD,$FFFF
	 dc.w	$BDC7,$8507,$7AF8,$FFFF,$7EC4,$4604,$B9FB,$FFFF
	 dc.w	$3AC8,$0A08,$F5F7,$FFFF,$3478,$0438,$FBC7,$FFFF
