PIC32


;32 color picture display routine
;coded by henrik stolpe
;load bitmap in $158000
s:
	lea	$158000,a0		;ladda bild i a0
	lea	$158000,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	#32,d3
	lea	colors,a3
	lea	$164802,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
interupt:
	cmp.b	#$00,$dff006	;test beamposition
	bne	wait		;fardig hoppa wait
	and	#1,$dff004		;inte fardig,satt LOF
	beq	interupt		;testa igen
	
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 		;bakgrund svart
	dc.w	$0100,$5200		;set bitplan con0
					;i 0090 lbyte=hor,ubyte=vert
bitplan:
	dc.w	$00e0,$0015,$00e2,$8000	;bpl1   pa $58000
	dc.w	$00e4,$0015,$00e6,$a800 ;bpl2   pa $58000+2800
	dc.w	$00e8,$0015,$00ea,$d000	;bpl3	pa $58000+(2800)x2
	dc.w	$00ec,$0015,$00ee,$f800 ;bpl4	pa $58000+(2800)x3
	dc.w	$00f0,$0016,$00f2,$2000 ;bpl5   pa $58000+(2800)x4
colors:	
	dc.w	$0182,$0000,$0184,$0000,$0186,$0000
	dc.w	$0188,$0000,$018a,$0000,$018c,$0000	
	dc.w	$018e,$0000,$0190,$0000,$0192,$0000
	dc.w	$0194,$0000,$0196,$0000,$0198,$0000
	dc.w	$019a,$0000,$019c,$0000,$019e,$0000
	dc.w	$01a0,$0000,$01a2,$0000,$01a4,$0000
	dc.w	$01a6,$0000,$01a8,$0000,$01aa,$0000	
	dc.w	$01ac,$0000,$01ae,$0000,$01b0,$0000
	dc.w	$01b2,$0000,$01b4,$0000,$01b6,$0000
	dc.w	$01b8,$0000,$01ba,$0000,$01bc,$0000
	dc.w	$01be,$0000
	dc.w	$ffff,$fffe