*****************************************
*	rotate scroll stuff		*
* prerotate and write out blocks for background
*****************************************
prerotate:
	lea	scrolltated1,a5
	lea	multi1,a6
	moveq	#10,d7			;do normal
	bsr	dor
	lea	scrolltated2,a5
	lea	multi2,a6
	moveq	#5,d7			;do normal
	bsr	dor
	lea	scrolltated3,a5
	lea	multi3,a6
	moveq	#2,d7			;do normal
	bsr	dor
	lea	scrolltated4,a5
	lea	multi4,a6
	moveq	#1,d7			;do normal
	bsr	dor

*********************************************************
*	Note in this case all are normal		*
*	but others may use dortwo for masking		*
*********************************************************

	lea	scrolltated5,a5
	lea	multi5,a6
	moveq	#34,d7			;do normal
	bsr	dor
illegal


	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


sc1:
scrolltated1:	blk.w	704,0
scrolltated2:	blk.w	384,0
scrolltated3:	blk.w	192,0
scrolltated4:	blk.w	128,0
scrolltated5:	blk.w	2240,0
sc2:

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

multi1:
	 dc.w	$D9E3,$0102,$FEFD,$FFFF,$DDEB,$010A,$FEF5,$FFFF
	 dc.w	$DEF7,$1206,$EDF9,$FFFF,$ACFB,$2082,$DF7D,$FFFF
	 dc.w	$AEE7,$2284,$DD7B,$FFFF,$5FD7,$4306,$BCF9,$FFFF
	 dc.w	$5FDB,$430A,$BCF5,$FFFF,$5DD7,$4117,$BEE8,$FFFF
	 dc.w	$3FF7,$2317,$DCE8,$FFFF,$BEEB,$028B,$FD74,$FFFF
	 dc.w	$B9EB,$018B,$FE74,$FFFF

multi2:
	 dc.w	$E9EF,$2183,$DE7C,$FFFF,$ECC5,$2080,$DF7F,$FFFF
	 dc.w	$ECEB,$2082,$DF7D,$FFFF,$9CF7,$1004,$EFFB,$FFFF
	 dc.w	$9EF7,$0000,$FFFF,$FFFF,$1FD7,$0110,$FEEF,$FFFF

multi3:
	 dc.w	$DAEF,$0004,$FFFB,$FFFF,$FBEF,$4082,$BF7D,$FFFF
	 dc.w	$A65D,$0000,$FFFF,$FFFF

multi4:
	 dc.w	$6AF5,$0000,$FFFF,$FFFF,$DB2E,$0000,$FFFF,$FFFF

multi5:
	 dc.w	$DEFA,$2104,$5EFB,$7FFF,$DE75,$2188,$DE76,$FFFE
	 dc.w	$DF75,$2088,$DF76,$FFFE,$CF05,$30F8,$CF46,$FFBE
	 dc.w	$0F3E,$F0C5,$2F3C,$DFF9,$E7BB,$1840,$E7BD,$FFFD
	 dc.w	$F30B,$0CF0,$F30D,$FFFD,$7AEC,$851B,$7AE8,$FFF3
	 dc.w	$78FF,$8708,$7AFB,$FDF3,$93F7,$6C00,$93FB,$FFFB
	 dc.w	$C7F7,$3800,$E7FB,$DFFB,$CFF7,$3000,$DFFB,$EFFB
	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