
	include blit.i
;:ts=12

;copy_lines_blit(s, d, planesize, linebytes, lines, planes)
;PLANEPTR	s,d;	source and dest planes of _contiguous_ data
;long	planesize;	offset to next plane
;WORD	linebytes;	offset to next line in plane
;WORD	lines;	lines in each plane
;WORD	planes;	# of planes

	public	_copy_lines_blit
clbregs	reg	a2/a3/a4/a5/d3
firstp	set 5*4+4
s	set firstp
d	set firstp+4
planesize	set firstp+8
linebytes	set firstp+12
lines	set firstp+16
planes	set firstp+20
_copy_lines_blit
	jsr	_OwnBlitter
	jsr	_WaitBlit
	movem.l	clbregs,-(sp)

	move.l	s(sp),a0
	move.l	d(sp),a1
	move.l	#(CUSTOMREGS+bltcon0),a2	;get blitter regs
	move.w	#COPY_MINTERM,(a2)+ ;minterm in con0
	move.w	#0,(a2)+	;zero out con1
	move.w	#-1,(a2)+	;full first word
	move.w	#-1,(a2)+	;full last word mask
	add.w	#(bltamod-bltcpt),a2	;skip to a modulus

	move.l	planesize(sp),d0
	move.l	#0,d1
	move.l	linebytes(sp),d1
	sub.w	d1,d0	;make modulus in d0
	move.w	d0,(a2)+	;store a modulus
	move.w	d0,(a2)	;store d modulus

	move.w	d1,d2
	asr.w	#1,d2	;d2 has words per line
	move.l	planes(sp),d0;
	asl.w	#6,d0;
	or.w	d0,d2	;d2 now has size according to blitter

	;a2 -> blitsize (ie start it up) register
	add.w	#bltsize-bltdmod,a2
	lea	bltapt-bltsize(a2),a3	;a3 -> apt
	lea	bltdpt-bltsize(a2),a4	;a4 -> dpt
	lea	dmaconr-bltsize(a2),a5  ;a5 -> where to check if done
	move.w	#$8400,dmacon-dmaconr(a5) ;nasty hog

	move.l	lines(sp),d3	;set up counter in d0
	bra	zcplblits
cplblits	move.l	a0,(a3)	;store a (source) pointer
	move.l	a1,(a4)	;store d (dest) pointer
	move.w	d2,(a2)	;feed blitter size and start it up
	adda.w	d1,a0	;go to next line of source
	adda.w	d1,a1	;and next line of dest
	nop
waitblt	move.w	(a5),d0	;grab bits to see if blitter is
	btst	#14,d0	;done yet
	bne	waitblt
zcplblits	dbra	d3,cplblits

	move.w	#$0400,dmacon-dmaconr(a5) ; unhog

	movem.l	(sp)+,clbregs
	jsr	_DisownBlitter
	rts

	;public	_skip_beam
	;public	_mskip_beam
;_mskip_beam	move.l	#$1800,d0
	;bra	skbeam
;_skip_beam
	;move.l	#$800,d0
;skbeam
	;move.l	#CUSTOMREGS+vposr,a0
	;move.l	#$e000,d1
;skwait	
	;move.l	(a0),d2	;fetch beam position
	;and.l	#$3ffff,d2	;mask off that wierd 9...
	;cmp.l	d2,d0
	;bhi	endskwait
	;cmp.l	d2,d1
	;bhi	skwait
;endskwait	rts


	public	_poll_beam
_poll_beam	
	move.l	#CUSTOMREGS+vposr,a0
	move.l	4(sp),a1
	move.w	8(sp),d0
	bra	zpblp
pblp	
	move.l	(a0),(a1)+
	move.w	#100,d1
p	
	nop
	dbra	d1,p
zpblp	dbra	d0,pblp
	rts

