	SECTION	chipmemory,DATA_C
							;BY BLAINE EVANS
							;1 ERITH WAY
							;PONTYBODKIN
							;NR MOLD
							;CLWYD
							;CH7 4TR
							;TEL O352-771673


	opt	c-,d+

	move.l	4.w,a6			;FIND EXEC BASE
	lea	gfxlib,a1		;LOAD GRAPHICS LIBRARY IN A1
	moveq	#$00,d0			;VERSION 0
	jsr	-552(a6)		;OPEN LIBRARY
	move.l	d0,_gfxbase		;STORE D0 (GFX ADDRESS )
	beq	nolib_exit		;ELSE EXIT
	lea	$dff000,a6

	bsr	Foreground_addresses	;BRANCH TO FOREGROUND ADDRESSES
	move.l	_gfxbase,a0		;LOAD ADDRESS OF GRAPHICS LIB IN A0
	move.l	50(a0),oldcop		;STORE CURRENT COPPER,ETC TO RETRIEVE LATER
S
	move.l	#newcop,50(a0)		;POINT TO OUR COPPERLIST
	bsr	Fade_Colors_Init

wait					;WAIT LOOP

	cmp.b	#255,$dff006		;VERTICAL BLANKING GAP 
	bne.s	wait			;
;	move.w	#$fff,$180(a6)		;REMOVE TO MEASURE RASTER TIME
	bsr	Pause
	bsr	Fade_Colors
;	move.w	#$000,$180(a6)		;REMOVE TO MEASURE RASTER TIME
	Btst	#6,$bfe001		;QUIT LEFT MOUSE PRESSED
	bne.s	wait
ended					;ELSE LOOP TO WAIT
	move.l	_gfxbase,a0		;LOAD GRAPHICS LIB ADDRESS IN A0
	move.l	oldcop,50(a0)		;RESTORE OLD COPPER TO RETURN TO EDITTER
nomem_exit	
	move.l	4.w,a6			;FIND EXEC BASE
	move.l	_gfxbase,a1		;LOAD GRAPHICS BASE IN A1
	jsr	-414(a6)		;CLOSE LIBRARY
nolib_exit
	rts				;RETURN TO EDITER
Foreground_addresses			;START OF FOREGROUND DATA
	move.l	#Foreground,d0
	move.w	d0,Bpl0ptl		;LOW WORD IN BIT PLANE 0 LOW
	swap	d0				
	move.w	d0,Bpl0pth		;HIGH WORD IN BIT PLANE 0 HIGH
	swap	d0
	add.l	#200*40,d0
	move.w	d0,Bpl1ptl		;LOW WORD IN BIT PLANE 1 LOW
	swap	d0				
	move.w	d0,Bpl1pth		;HIGH WORD IN BIT PLANE 1 HIGH	
	swap	d0
	add.l	#200*40,d0
	move.w	d0,Bpl2ptl		;LOW WORD IN BIT PLANE 2 LOW
	swap	d0				
	move.w	d0,Bpl2pth		;HIGH WORD IN BIT PLANE 2 HIGH
	swap	d0
	rts
**********************************************************
* This will fade in color 01 as you requested providing registers a2,a3 are
* not changed at all.Just change values in 'Fade_C'to your requirements
* Blaine
*********************************************************
Pause					;Pause to slow things down
	move.l	#$ffff,d1
Pa	dbra	d1,Pa
	rts

Fade_Colors_Init			;Initiate registers with values
	lea	Colors,a2
	lea	6(a2),a2		;get to color01
	lea	Fade_C,a3		;colors to fade in 
	rts
Fade_Colors				;lets Fade
	cmp.w	#$0000,(a3)		;is it black yet
	beq	Reset			;yes reset a1 back to start of list
	move.w	(a3)+,(a2)		;else new color please
	rts
Reset
	lea	Fade_C,a3		;re-load fade colors
	rts
************************************************************

gfxlib	dc.b	"graphics.library",0	
	even
_gfxbase	dc.l	0		;LONG WORD TO STORE GFX ADDRESS
oldcop		dc.l	0		;OLD COPPERLIST ADDRESS
         EVEN
	even
;	SECTION		chipmemory,data_c	

newcop
	dc.w	$0100,%0011001000000000		;3 PLANES 
	dc.w	$0102
scroll0	dc.w	$0000				;SCROLL VALUE
	dc.w	$0104,%0000000000011011		;PRIORITIES
	dc.w	$0108,$0000,$010a,$0000		;MODULAS
	dc.w	$0092,$0038,$0094,$00d0		;200*40 SCREEN
	dc.w	$008e,$3781,$0090,$fec1		;VISIBLE AREA
						
planes						;PLANE CONTROL WORDS
	dc.w	$00e0
Bpl0pth	dc.w	$0000
	dc.w	$00e2
Bpl0ptl	dc.w	$0000		
	dc.w	$00e4
Bpl1pth	dc.w	$0000
	dc.w	$00e6
Bpl1ptl	dc.w	$0000
	dc.w	$00e8
Bpl2pth	dc.w	$0000
	dc.w	$00ea
Bpl2ptl	dc.w	$0000
	dc.w	$00ec
Bpl3pth	dc.w	$0000
	dc.w	$00ee
Bpl3ptl	dc.w	$0000	
	dc.w	$00f0
Bpl4pth	dc.w	$0000
	dc.w	$00f2
Bpl4ptl	dc.w	$0000
	dc.w	$00f4
Bpl5pth	dc.w	$0000
	dc.w	$00f6
Bpl5ptl	dc.w	$0000

sprites						;SPRITES CONTROL WORDS
	dc.w	$0120
Spl0pth	dc.w	$0000,$0122
Spl0ptl	dc.w	$0000,$0124
Spl1pth	dc.w	$0000,$0126
Spl1ptl	dc.w	$0000,$0128
Spl2pth	dc.w	$0000,$012a
Spl2ptl	dc.w	$0000,$012c
Spl3pth	dc.w	$0000,$012e
Spl3ptl	dc.w	$0000,$0130
Spl4pth	dc.w	$0000,$0132
Spl4ptl	dc.w	$0000,$0134
Spl5pth	dc.w	$0000,$0136
Spl5ptl	dc.w	$0000,$0138
Spl6pth	dc.w	$0000,$013a
Spl6ptl	dc.w	$0000,$013c
Spl7pth	dc.w	$0000,$013e
Spl7ptl	dc.w	$0000

Colors
	dc.w	$0180,$0000,$0182,$0000		;COLORS PLAY 1

	dc.w	$0184,$0f20,$0186,$0f40
	dc.w	$0188,$0f60,$018a,$0f8f
	dc.w	$018c,$0f90,$018e,$0ff0

	dc.w	$0190,$0000,$0192,$0283		;COLORS PLAY 2
	dc.w	$0194,$08f4,$0196,$0095
	dc.w	$0198,$0243,$019a,$00ff
	dc.w	$019c,$0ff0,$019e,$0fa0

	dc.w	$01a0,$0000,$01a2,$0fff		;SPRITE COLORS
	dc.w	$01a4,$0f00,$01a6,$0b00
	dc.w	$01a8,$0600,$01aa,$0F40
	dc.w	$01ac,$0F80,$01ae,$0Fa0
	dc.w	$01b0,$0Ff0,$01b2,$000f
	dc.w	$01b4,$004f,$01b6,$008f
	dc.w	$01b8,$00ff,$01ba,$00f0
	dc.w	$01bc,$0283,$01be,$0f0f

	dc.w	$ffff,$fffe			;END OF COPPERLIST
Foreground		dcb.b	(200*40),$ff
			dcb.b	(200*40),$00
			dcb.b	(200*40),$00
Fade_C
	DC.W	$0001,$0002,$0003,$0004,$0005,$0006,$0007,$0008
	DC.W	$0009,$000a,$000b,$000c,$000d,$000e,$000f
	DC.W	$000e,$000d,$000c,$000b,$000a,$0009,$0008,$0007
	DC.W	$0006,$0005,$0004,$0003,$0002,$0001,$0000

