*****************************************************************************
*								BOOT PICTURE								*
*	CODED BY TANGO/XENTRIX													*
*																			*
*****************************************************************************
	
	section copperbars,code_c
	opt c-
	incdir	df1:
	include	gamemacros


*****************************************************************************
*					KILL O/S AND CALL ROUTINES AND TEST MOUSE				*
*****************************************************************************

	killsys
	
	clr.l	delay
	clr.l	flag
	
	move.l	#$70000,a0
	move.l	#3000,d7
loop:
	clr.l	(a0)+
	dbf		d7,loop
	move.l	#newcopper,$dff080
	lea		custom,a5
	bsr		blitpic
mouse:
	cmp.b	#$ff,$dff006
	bne.s	mouse
	bsr		doform
	bsr		test_exit
	tst.l	flag
	bne.s	exit
	btst	#6,$bfe001
	bne.s	mouse
exit:
	ressys
	clr.l	d0
	rts


*****************************************************************************
*				SEE IF ITS TIME TO EXIT(EVEN IF MOUSE AINT PRESSED!)		*
*****************************************************************************

test_exit:
	cmp.l	#300,delay			; test delay count
	beq.s	enter_cli
	add.l	#1,delay			; add to delay
	rts
enter_cli:
	bset	#1,flag				; set flag
	rts
	
		
*****************************************************************************
*								BLIT PICTURE								*
*****************************************************************************

blitpic:
	lea		$70000,a0
	add.l	#40*100,a0					; mid screen
	lea		pic(pc),a1
	move.w	#0,bltamod(a5)
	move.w	#0,bltdmod(a5)
	move.l	a1,bltapth(a5)
	move.l	a0,bltdpth(a5)
	move.l	#-1,bltafwm(a5)
	move.l	#$09f00000,bltcon0(a5)
	blitwait
	move.w	#16<<6!20,bltsize(a5)
	rts
	
																																									
*****************************************************************************
*							BLIT THE COPPER BARS							*
*****************************************************************************

blitbar:
	lea		coltab(pc),a1
	lea		dest+6(pc),a2				; point to colour 
	lea		bltapth(a5),a3
	lea		bltdpth(a5),a4
	lea		bltsize(a5),a0
	lea		bltcon0(a5),a6
	move.l	#-1,d6
	moveq	#0,d4
	moveq	#6,d5
	add.l	d1,a2						; d1 holds position of bar
	blitwait
	move.w	d4,bltamod(a5)
	move.w	d5,bltdmod(a5)				; 6  (3words to next colour)
	move.l	d6,bltafwm(a5)
	move.l	a1,(a3)						; source
	move.l	a2,(a4)						; dest
	move.l	#$09f00000,(a6)				; minterm D=A
	move.w	#32<<6!1,(a0)				; blitsize
	rts


*****************************************************************************
*					MOVE THE COPPER BARS FROM A SINE TABLE					*
*****************************************************************************

doform:
	move.l	sinptr(pc),a2	; pointer to sine table
	move.l	tabptr(pc),a0	; pointer to table
	move.w	(a0)+,d7		; amount of bars
barlooper:
	move.w	(a0)+,d1		; position in sinetab
	add.w	d1,d1			; even
	and.w	#$fe,d1
	move.w	(a2,d1),d1		; got position
	asl.l	#3,d1			; times by 8 for next line down!
	move.w	(a0)+,d2
	add.w	d2,-4(a0)		; speed
	save_all
	bsr		blitbar
	return_all
	dbf		d7,barlooper
	rts


*****************************************************************************
*						COPPER LIST (JUST A BIG REPEAT!)					*
*****************************************************************************

newcopper:
	cmove	bpl1mod,0
	cmove	bpl2mod,0
	cmove	diwstrt,$2c81
	cmove	diwstop,$2cc1
	cmove	ddfstrt,$38
	cmove	ddfstop,$d0
	cmove	bplcon0,$1200
	cmove	bpl1ptl,$0000
	cmove	bpl1pth,$0007
	cmove	color01,$fff
a	set	80
dest:
	rept	170
	dc.b	a,$09,$ff,$fe
	dc.w	$180,$00			; CHANGE THIS COL!!!
a	set		a+1
	endr
	dc.w	$ffff,$fffe
	

*****************************************************************************
*		   COLOURS FOR BAR (NOTE BAR IS 34 LINES, HENCE 34 COLOURS!)		*
*****************************************************************************

coltab:
	dc.w	$000,$000,$001,$002,$003,$004,$005,$006,$007
	dc.w	$008,$009,$00a,$00b,$00c,$00d,$00e,$00f
	dc.w	$00e,$00d,$00c,$00b,$00a,$009,$008,$007,$006
	dc.w	$005,$004,$003,$002,$001,$000

delay:
	dc.l	0
flag:
	dc.l	0
		
	
*****************************************************************************
*							 BAR FORMATIONS!								*
*****************************************************************************

tabptr:
	dc.l	tab
tab:
	dc.w	10-1				; no of bars to blit
	dc.w	10,1				; offset to sine tab and speed
	dc.w	20,1				; offset to sine tab and speed
	dc.w	30,1
	dc.w	40,1
	dc.w	50,1
	dc.w	60,1
	dc.w	70,1
	dc.w	80,1
	dc.w	90,1
	dc.w	100,1
 

*****************************************************************************
*							THE MEGA SINE TABLE								*
*****************************************************************************

sinptr:	
		dc.l	sintab
sintab:
	dc.w	120,120,120,119,119,118,117,116
	dc.w	115,114,113,111,110,108,106,104
	dc.w	102,100,98,96,93,91,88,86
	dc.w	83,80,77,75,72,69,66,63
	dc.w	60,57,54,51,48,45,43,40
	dc.w	37,34,32,29,27,24,22,20
	dc.w	18,16,14,12,10,9,7,6
	dc.w	5,4,3,2,1,1,0,0
	dc.w	0,0,0,1,1,2,3,4
	dc.w	5,6,7,9,10,12,14,16
	dc.w	18,20,22,24,27,29,32,34
	dc.w	37,40,43,45,48,51,54,57
	dc.w	60,63,66,69,72,75,77,80
	dc.w	83,86,88,91,93,96,98,100
	dc.w	102,104,106,108,110,111,113,114
	dc.w	115,116,117,118,119,119,120,120
	even
sl=*-sintab		

pic:
	incbin	gfx/bootpic
	even
