
; Display Example 14. -- Scroll Value Tricks --

; A rippling reflection at the bottom of the display.

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

; First, 'poke' address of bit planes into Copper list.

Main		COPBPLC		CopPlanes,bitplane,(320/8)*256,4

; Define address of Copper List

		STARTCOP	#MyCopper

; Enable bitplane and Copper DMA.

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

; Install vertical blank interrupt handler and enable it.

		move.l		#NewLevel3,$6c		install
		
		move.w		#SETIT!INTEN!VERTB,INTENA(a5)


; Wait for user to press the left mouse button

mouse		btst		#6,CIAAPRA
		bne.s		mouse

; And exit.

		rts

;		************************
;		* Vert Blank Interrupt *
;		************************

; This handler calls the routine that creates the ripple effect.

; Note that the Ripple routine is only called every other interrupt. If
;called every interrupt, it wobbles much to fast!

NewLevel3	lea		$dff000,a5		a5->hardware base

		not.w		toggle
		beq.s		NoGo

		bsr		Ripple
		
NoGo		move.w		INTREQR(a5),d0		get bits
		and.w		#VERTB!COPER!BLIT,d0
		move.w		d0,INTREQ(a5)		clear request
		rte					back to user mode

toggle		dc.w		0

;		***************************
;		*   Rotate Scroll Values  *
;		***************************

; Creates the rippling effect by rotating the scroll values in the Copper
;list each vertical blank.

Ripple		lea		CopScroll,a0		a0->into Copper list
		move.w		2(a0),d1		copy 1st scroll val

		moveq.l		#47,d0			line counter
RippleLoop	move.w		10(a0),2(a0)
		addq.l		#8,a0			next line
		dbra		d0,RippleLoop
		
		move.w		d1,2(a0)		last line

		rts

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

;section		data custom,chip
		Section		Fish,DATA_C

MyCopper	CMOVE		DIWSTRT,$2c81		PAL -- 256 lines
		CMOVE		DIWSTOP,$2cc1
		CMOVE		DDFSTRT,$0030		LoRes
		CMOVE		DDFSTOP,$00d0
		CMOVE		BPL1MOD,-2		Account for scroll
		CMOVE		BPL2MOD,-2
		CMOVE		BPLCON0,$4200		4 bitplanes & colour
		CMOVE		BPLCON1,$00ff		show all
		CMOVE		BPLCON2,$0000		Ignore priority

CopPlanes	CMOVE		BPL1PTH,0		Bit plane pointers
		CMOVE		BPL1PTL,0		filled in by the
		CMOVE		BPL2PTH,0		program!
		CMOVE		BPL2PTL,0
		CMOVE		BPL3PTH,0
		CMOVE		BPL3PTL,0
		CMOVE		BPL4PTH,0
		CMOVE		BPL4PTL,0

CopColours	CMOVE		COLOR00,$0000		The colours will be
		CMOVE		COLOR01,$0000		filled in by the
		CMOVE		COLOR02,$0000		program!
		CMOVE		COLOR03,$0000
		CMOVE		COLOR04,$0000
		CMOVE		COLOR05,$0000
		CMOVE		COLOR06,$0000
		CMOVE		COLOR07,$0000
		CMOVE		COLOR08,$0000
		CMOVE		COLOR09,$0000
		CMOVE		COLOR10,$0000
		CMOVE		COLOR11,$0000
		CMOVE		COLOR12,$0000
		CMOVE		COLOR13,$0000
		CMOVE		COLOR14,$0000
		CMOVE		COLOR15,$0000

; Reflect the screen at line 255.

		CWAIT		112,255
		CMOVE		BPL1MOD,-122
		CMOVE		BPL2MOD,-122

		CWAIT		0,0
CopScroll	CMOVE		BPLCON1,$00ff
		CWAIT		0,1
		CMOVE		BPLCON1,$00ee
		CWAIT		0,2
		CMOVE		BPLCON1,$00dd
		CWAIT		0,3
		CMOVE		BPLCON1,$00bb
		CWAIT		0,4
		CMOVE		BPLCON1,$00bb
		CWAIT		0,5
		CMOVE		BPLCON1,$00dd
		CWAIT		0,6
		CMOVE		BPLCON1,$00ee
		CWAIT		0,7
		CMOVE		BPLCON1,$00ff
		CWAIT		0,8
		CMOVE		BPLCON1,$00ff
		CWAIT		0,9
		CMOVE		BPLCON1,$00ee
		CWAIT		0,10
		CMOVE		BPLCON1,$00dd
		CWAIT		0,11
		CMOVE		BPLCON1,$00bb
		CWAIT		0,12
		CMOVE		BPLCON1,$00bb
		CWAIT		0,13
		CMOVE		BPLCON1,$00dd
		CWAIT		0,14
		CMOVE		BPLCON1,$00ee
		CWAIT		0,15
		CMOVE		BPLCON1,$00ff
		CWAIT		0,16
		CMOVE		BPLCON1,$00ee
		CWAIT		0,17
		CMOVE		BPLCON1,$00dd
		CWAIT		0,18
		CMOVE		BPLCON1,$00bb
		CWAIT		0,19
		CMOVE		BPLCON1,$00bb
		CWAIT		0,20
		CMOVE		BPLCON1,$00dd
		CWAIT		0,21
		CMOVE		BPLCON1,$00ee
		CWAIT		0,22
		CMOVE		BPLCON1,$00ff
		CWAIT		0,23
		CMOVE		BPLCON1,$00ee
		CWAIT		0,24
		CMOVE		BPLCON1,$00dd
		CWAIT		0,25
		CMOVE		BPLCON1,$00bb
		CWAIT		0,26
		CMOVE		BPLCON1,$00dd
		CWAIT		0,27
		CMOVE		BPLCON1,$00ee
		CWAIT		0,28
		CMOVE		BPLCON1,$00ff
		CWAIT		0,29
		CMOVE		BPLCON1,$00ee
		CWAIT		0,30
		CMOVE		BPLCON1,$00dd
		CWAIT		0,31
		CMOVE		BPLCON1,$00bb
		CWAIT		0,32
		CMOVE		BPLCON1,$00bb
		CWAIT		0,33
		CMOVE		BPLCON1,$00dd
		CWAIT		0,34
		CMOVE		BPLCON1,$00ee
		CWAIT		0,35
		CMOVE		BPLCON1,$00ff
		CWAIT		0,36
		CMOVE		BPLCON1,$00ee
		CWAIT		0,37
		CMOVE		BPLCON1,$00dd
		CWAIT		0,38
		CMOVE		BPLCON1,$00bb
		CWAIT		0,39
		CMOVE		BPLCON1,$00bb
		CWAIT		0,40
		CMOVE		BPLCON1,$00dd
		CWAIT		0,41
		CMOVE		BPLCON1,$00ee
		CWAIT		0,42
		CMOVE		BPLCON1,$00ff
		CWAIT		0,43
		CMOVE		BPLCON1,$00ee
		CWAIT		0,44
		CMOVE		BPLCON1,$00dd
		CWAIT		0,45
		CMOVE		BPLCON1,$00bb
		CWAIT		0,46
		CMOVE		BPLCON1,$00bb
		CWAIT		0,47
		CMOVE		BPLCON1,$00dd
		CWAIT		0,48
		CMOVE		BPLCON1,$00ee

		CEND					end of list

bitplane	incbin		'pic2.bm'

		end

		
