
; Blitter Example 7. - Pixel Positioning Using Blitter Scroll & -ve Modulo -

		include		hardware.i
		include		HW_Macros.i
		include		HW_Start.i

; First, 'poke' address of bit plane into Copper list

Main		move.l		#Screen,d0		d0=addr of bitplane
		lea		CopPlanes,a0		a0->into Copper list

		move.w		d0,6(a0)		low word of address
		swap		d0
		move.w		d0,2(a0)		high word of address

; Enable bitplane, Copper and Blitter DMA.

		move.w		#SETIT!DMAEN!COPEN!BPLEN!BLTEN,DMACON(a5)

; Now strobe the Copper list.

		move.l		#MyCopper,COP1LCH(a5)	address of list
		move.w		#0,COPJMP1(a5)		strobe Copper

; Call subroutine to blit the graphic to the screen

		moveq.l		#0,d7			y counter
		moveq.l		#0,d6			x counter

BLoop1		move.l		d6,d0
		move.l		d7,d1
		bsr		BlitBob

		addq.w		#2,d6
		addq.w		#2,d7
		cmp.w		#244,d7
		blt		BLoop1

; Wait for user to press the left mouse button

mouse		btst		#6,CIAAPRA
		bne.s		mouse

0; And exit.

		rts

;		***************************
;		*     Blit Graphic	  *
;		***************************

; Entry		d0= x pixel coordinate of bob
;		d1= y pixel coordinate of bob

BlitBob		mulu		#40,d1			start of line offset
		ror.l		#4,d0			isolate scrl & offset
		asl.w		#1,d0			multiply offset by 2
		add.w		d0,d1			byte offset
		add.l		#Screen,d1		dest start address
		swap		d0			get scroll bits
		move.w		d0,d2			copy scroll bits
		or.w		#$0fca,d0		add minterm & usage

BWait		btst		#14,DMACONR(a5)		wait for Blitter
		bne.s		BWait

		move.l		#BobMask,BLTAPTH(a5)	A address
		move.l		#Bob,BLTBPTH(a5)	B address
		move.l		d1,BLTCPTH(a5)		C address
		move.l		d1,BLTDPTH(a5)		D address
		move.w		#-2,BLTAMOD(a5)		A modulo
		move.w		#-2,BLTBMOD(a5)		B modulo
		move.w		#34,BLTCMOD(a5)		C modulo
		move.w		#34,BLTDMOD(a5)		D modulo
		move.w		#-1,BLTAFWM(a5)		A first mask
		move.w		#0,BLTALWM(a5)		A last mask
		move.w		d0,BLTCON0(a5)		Use A,B,C,D: D=AB+aC
		move.w		d2,BLTCON1(a5)		no special modes
		move.w		#10<<6!3,BLTSIZE(a5)	3 words by 10 lines

		rts

;		***************************
;		*     CHIP Memory Data    *
;		***************************

section		data custom,chip		****  Use this for A68K  ****

;		Section		custom,data_C	**** Use this for Devpac ****

MyCopper	CMOVE		DIWSTRT,$2c81		PAL -- 256 lines
		CMOVE		DIWSTOP,$2cc1
		CMOVE		DDFSTRT,$0038		LoRes
		CMOVE		DDFSTOP,$00d0
		CMOVE		BPL1MOD,$0000		No modulos
		CMOVE		BPL2MOD,$0000
		CMOVE		BPLCON0,$1200		1 bitplane & colour
		CMOVE		BPLCON1,$0000		No scrolling
		CMOVE		BPLCON2,$0000		Ignore priority

CopPlanes	CMOVE		BPL1PTH,0		Bit plane pointer
		CMOVE		BPL1PTL,0

		CMOVE		COLOR00,$0000		black background
		CMOVE		COLOR01,$0fff		white foreground

		CEND					end of list

Screen		dcb.b		40*256,%10101010	40 bytes by 256 lines

Bob		dc.w		%0000000000000000,%0000000000000000
		dc.w		%0111111111111111,%1111111111111110
		dc.w		%0100000000000000,%0000000000000010
		dc.w		%0010000000000000,%0000000000000100
		dc.w		%0001000000000000,%0000000000001000
		dc.w		%0001000000000000,%0000000000001000
		dc.w		%0010000000000000,%0000000000000100
		dc.w		%0100000000000000,%0000000000000010
		dc.w		%0111111111111111,%1111111111111110
		dc.w		%0000000000000000,%0000000000000000

; Background shows through only where there are 0 bits in the mask.

BobMask		dc.w		%1111111111111111,%1111111111111111
		dc.w		%1111111111111111,%1111111111111111
		dc.w		%1111111111111111,%1111111111111111
		dc.w		%0111111111111111,%1111111111111110
		dc.w		%0011111111000000,%0000001111111100
		dc.w		%0011111111000000,%0000001111111100
		dc.w		%0111111111111111,%1111111111111110
		dc.w		%1111111111111111,%1111111111111111
		dc.w		%1111111111111111,%1111111111111111
		dc.w		%1111111111111111,%1111111111111111

		end

		
