_clrbig0bp	=35600
_clrbig1bp	=36150
_clrbig2bp	=34950
_clrbig3bp	=34450
_clrbig4bp	=34250
_clrbig5bp	=34350
_clrbig6bp	=34250
;Make interleaved bobmasks. min. 2 bpls or this routines is of no use.
MakeMasks:	;a0,a1,d0.w,d1.w,d2.w,d3.w=src,dst,bltsize,bpls-1,bwid,bpl. Makes bpls maskbpls
	lea (a0,d3.w),a2	;first mix bpl 0 & 1, overwr dst
	sub.w d3,d2		;calc modulo & duplicate
	move.w d2,d4
	swap d2
	move.w d4,d2		;d4=d2 swapped (modulos)
	BLIT3 d0,$0dfc0000,d2,d2	;a1=a0 or a2 (D=A or B)
	move.w d1,d4		;save for copyloop
	subq.w #2,d1		;2 bpls ored already
	bmi.s .copy
	move.l a2,a0
.bpll:	add.w d3,a0		;3rd etc bpls
	BLIT d0,$0dfc0000,d2	;D=A or B(pts to dest)
	dbf d1,.bpll
.copy:	subq.w #1,d4		;will never be < 0. *min 2 bpls)
	move.l a1,a0
.cpyl:	add.w d3,a1
	BLIT d0,$09f00000,d2
	dbf d4,.cpyl
	RTS



CopyC:	;a0,a1,d0.w=src,dest,length/2. copy up to 128K with two blits
	move.w d0,d1
	and.w #63,d1
	beq.s .big
	add.w #1<<6,d1
	BLIT d1,#$09f00000
	and.w #63,d1
	add.w d1,d1
	add.w d1,a0
	add.w d1,a1
.big:	and.l #-64,d0
	bne.s .dorest
	RTS
.dorest:BLIT d0,#$09f00000
	add.l d0,d0		;increment src and dst
	add.l d0,a0
	add.l d0,a1
	RTS

CopyF:	;a0,a1,d0.l=src,dst,len <512K. Uses d0/d1. a1 pts to stop adr on exit
	move.w a1,d1
	btst #0,d1
	beq.s .even
.odd:	move.b (a0)+,(a1)+	;cpy leading odd byte to make even addr
	subq.l #1,d0
.even:	moveq #7,d1
	and.w d0,d1		;last 1-7 bytes
	lsr.l #3,d0
	subq.w #1,d0
	bmi.s .skipb
.bigl:	move.l (a0)+,(a1)+
	move.l (a0)+,(a1)+
	dbf d0,.bigl
.skipb:	subq.w #1,d1
	bmi.s .skips
.smll:	move.b (a0)+,(a1)+
	dbf d1,.smll
.skips:	RTS

FillSml:	;d1=fillbyte
	move.b d1,d2
	swap d1
	move.b d2,d1		;xxddxxdd
	lsl.l #8,d1		;ddxxddxx
	move.b d2,d1		;ddxxdddd
	swap d1			;ddddddxx
	move.b d2,d1		;dddddddd
	bra.s CScont	

ClrSml:	;a1=dst,d0.w=BYTE len. Destroys d0-d2. a1 pts to stop adr on exit
	moveq #0,d1
CScont:	move.w a1,d2
	btst #0,d2
	beq.s .even
.odd:	move.b d1,(a1)+		;clr leading odd byte to make even addr
	subq.w #1,d0
.even:	moveq #7,d2
	and.w d0,d2		;last 1-7 bytes
	lsr.w #3,d0
	subq.w #1,d0
	bmi.s .skipb
.bigl:	move.l d1,(a1)+
	move.l d1,(a1)+
	dbf d0,.bigl
.skipb:	subq.w #1,d2
	bmi.s .skips
.smll:	move.b d1,(a1)+
	dbf d2,.smll
.skips:	RTS

blksiz=21	;movem-repetitions. 7 is optimum while clearing 5bpl 320x256.
ClrBig:	;a1=EVEN dest,d0.w=WORD len, d1.w=bltpart/65536 (0=fastmem). Max 256KB
	moveq #0,d2
	move.w d0,d2
	mulu d1,d0			;blit part of the clr, 34250/65536 for 6bpdma
	swap d0
	move.l d2,d1			;smart clr hi d1

	and.w #-64,d0
	beq.s .skipb
	sub.w d0,d1			;rest (words)
      ;----blit----
	WAITBLIT2
	clr.w $66-C(A6)			;Anytime:BLTMODA,D (in bytes!)
	move.l #$01000000,$40-C(A6)	;First:u=useABCD,x=1=xfill,d=2=icdl
	move.l a1,$54-C(A6)	;Anytime:BLTDPTL.
	move.w d0,$58-C(A6)	;Last*:<2 srces leaves all CPU MA free!
.skipb:	divu #14*2*blksiz,d1		;free!
.cpu:	add.l d2,d2
	add.l d2,a1			;stop addr
	movem.l a1/a5-a7,RegSave-R(A5)
	movem.l Black(PC),d0/d2-d7/a0/a2-a7	;zeroes, 14 regs, d0 already 0
	subq.w #1,d1
	bmi.w .nor2
.mvml:	REPT blksiz
	movem.l d0/d2-d7/a0/a2-a7,-(a1)
	ENDR
	dbf d1,.mvml
.nor2:
      ;--- big rest ----------
	swap d1				;rest
	bra.s .cont1
.bigl:	movem.l d0/d2-d7/a0/a2-a7,-(a1)
.cont1:	sub.w #14*2,d1
	bpl.s .bigl
	add.w #14*2,d1
      ;--- small rest ----------
	lsr.w #1,d1
	bcc.s .now
	move.w d0,-(a1)
.now:	subq.w #1,d1
	bmi.s .nor1
.l:	move.l d0,-(a1)
	dbf d1,.l
.nor1:
	movem.l RegSave(PC),a1/a5-a7
	RTS			;all regs trashed except a5-a7.
