PICBLIT


;blitter routine by henrik stolpe
;coded by henrik stolpe
;load static 8 bitmap in $58000
s:
	lea	$58000,a0		;ladda bild i a0
	lea	$58000,a1		;ladda bild i a1
	lea 	copper,a0		;lagg copper i a0
	move.l 	a0,$dff080		;lagg copper i cop1lch
	move 	$dff088,d0		;lagg copjmp1 i d0
	move 	#$83e0,$dff096	;enable DMA
;	move.w	#$0020,$dff096	;disable sprite

	move	#8,d3
	lea	colors,a3
	lea	$5f802,a2		;farg avstand icop=4
	add	#2,a3

colorloop:
	move	(a2),(a3)	
	add	#2,a2
	add	#4,a3
	subq	#1,d3
	cmp	#1,d3
	bne	colorloop


r:
clearmem:
	clr	d0
	lea	$88000,a0
	move	#50000,d0
c:
	move.b	#$00,(a0)+
	dbf	d0,c
	clr	d0

	move.l	#$88000,d4
	move.l	#$8a800,d5

interupt:
	cmp.b	#$00,$dff006	;test beamposition
	bne	wait		;fardig hoppa wait
	and	#1,$dff004		;inte fardig,satt LOF
	beq	interupt		;testa igen
	
blit:
	btst	#14,$dff002	;testa om blitterbusy
	bne	blit		
	move.l	#$58000,$dff050	;blitterpointer to sA
	move.l	d4,$dff054		;blitterpointer to dest D
	clr.l	$dff064		;rensa blittermodulo A
	move.l	#$ffffffff,$dff044	;wordmask for sA
	move	#$e9f0,$dff040	;enable blittercontrol bits
	move	#$0fff,$dff058	;blit start/size,win h,b
	
	add	#1,d4	

;	btst	#14,$dff002	;testa om blitterbusy
;	bne	blit		
	move.l	#$5a800,$dff050	;blitterpointer to sA
	move.l	d5,$dff054		;blitterpointer to dest D
	clr.l	$dff064		;rensa blittermodulo for A
	move.l	#$ffffffff,$dff044	;wordmask for sA
	move	#$e9f0,$dff040	;enable blittercontrol bits
	move	#$0fff,$dff058	;blit start/size,win h,b

	add	#1,d5




wait:
	btst	#6,$bfe001		;testa musknapp
	bne	interupt		;inte hoppa tryagin
slut:
	move.l	4,a6		;avsluta bildhantering
	lea	gfxname,a1
	jsr	-408(a6)
	move.l	d0,a1
	move.l	38(a1),$dff080
	jsr	-414(a6)
	rts	

gfxname:
	dc.b	'graphics.library',0
	even
copper:
	dc.w	$008e,$2c81,$0090,$1fa1	;set display window (start,stop)
	dc.w	$0092,$0038,$0094,$00d0 ;set bitplane datafetch horis pos
	dc.w	$0180,$0000 		;set bitplan con0,bakgrund svart
	dc.w	$0100,$3200		;set bitplan con0
					;i 0090 lbyte=hor,ubyte=vert
bitplan:
	dc.w	$00e0,$0008,$00e2,$8000	;bpl1   pa $58000
	dc.w	$00e4,$0008,$00e6,$a800 ;bpl2   pa $58000+2800
	dc.w	$00e8,$0008,$00ea,$d000	;bpl3	pa $58000+(2800)x2


colors:	
	dc.w	$0182,$0000,$0184,$0000,$0186,$0000
	dc.w	$0188,$0000,$018a,$0000,$018c,$0000	
	dc.w	$018e,$0000,$0190,$0000
	dc.w	$ffff,$fffe