**********************************************************************
*								     *
*		        -Colour Spread Routine-			     *
*								     *
*  Hi,with this routine you can calculate colour tints. Just put in  *
* colour00 and in colour01 a colour. Put in -steps- how many colours *
* you want.In -list- is standing, after running, the tints. The nice *
* thing of this routine is,that for one whole "horizon", the routine *
*    only calculates 3 numbers (counterINCvalue R,G,B) You simply    *
*  increase the -Colour00- RGB nibbles with these numbers,and after  *
*   -Steps- times -Colour01- is appearing.I know the routine isn`t   *
*     very exactly, but in the game I wrote it for, time was more    *
*  important. (In the game there is a horizon and while playing the  *
*   sun goes down and the horizon become slightly blue)              *
*								     *
* I hope you can use it. See Yha!	      Erik Volkerink/MASSIVE *
*								     *
****************** (!!! LOOK OUT FOR OUR GAME !!!)  ******************



Colour00=		$0000	
Colour01=		$0fff	
Steps=			16	


	bsr	calcincvalues	
	bsr	storecolours
	rts
				

Calcincvalues:
	move.l	#colour00,d0	
	move.l	#colour01,d1	 
	move.w	#steps,d2	
	lea	counterINCval,a0;Pointer to RGB counter INC-table
	lea	RGBcounters,a1	;Pointer to RGB counters
	jmp	CalcINCValue	;Calculate counter INC values.

Storecolours:
	lea	counterINCval,a0;Pointer to RGB Counter INC-table
	lea	RGBcounters,a1	;Pointer to RGB counters
	lea	tints,a2	;Destination pointer for colours
	move.l	#steps-1,d4			
	lus:			
	bsr	nextcol		
	move.w	d3,(a2)+	
	dbra	d4,lus		
	rts			

NextCol:movem.w	(a0),d0-d2	;store CounterINCValue RGB to d0/d1/d2
	add.w	d0,(a1)		;Increase red counter
	add.w	d1,2(a1)	;Increase green counter
	add.w	d2,4(a1)	;Increase blue counter

	move.w	(a1),d3		;
	and.w	#$f00,d3	;d3=red
	move.w	2(a1),d1	;
	and.w	#$f00,d1	;
	lsr.w	#4,d1		; 
	add.w	d1,d3		;d3=red+green
	move.w	4(a1),d1	;
	and.w	#$f00,d1	;
	lsr.w	#8,d1		;
	add.w	d1,d3		;d3 is complete word ($0RGB)
	rts			;

CalcINCValue:	
	movem.w	d0-d1,-(a7)	

	;Calculate Red INC Value
	and.l	#$0f00,d0	;Get red nibble of colour00
	and.l	#$0f00,d1	;Get red nibble of colour01
	move.w	d0,(a1)		;Start value of red*256
	sub.l	d0,d1		;d1=Space which have to be tide over
	divs	d2,d1		;(in d2(=number of tints) times)
	move.w	d1,(a0)		;Red INC Value*256  

	movem.w (a7),d0-d1	;Get colours again 

	;Calculate Green INC Value
	and.l	#$00f0,d0	;Get green nibble of colour00
	and.l	#$00f0,d1	;Get green nibble of colour01
	lsl.l	#4,d0		;*16 (Shift nibble one nibble to left)
	lsl.l	#4,d1		;*16 (  "     "    "     "    "   "  )
	move.w	d0,2(a1)	;Start value of green*256
	sub.l	d0,d1		;d1=Space which have to be tide over
	divs	d2,d1		;(in d2(=number of tints) times)
	move.w	d1,2(a0)	;Green INC Value*256

	movem.w (a7)+,d0-d1	;Get colours again (a7 ptr back to 
				;normal)

	;Calculate Blue INC Value
	and.l	#$000f,d0	;Get blue nibble of colour00
	and.l	#$000f,d1	;Get blue nibble of colour01
	lsl.l	#8,d0		;*256 (shift nibble 2 nibbles to left)
	lsl.l	#8,d1		;*256 (  "     "    "   "      "   "
	move.w	d0,4(a1)	;Start value of blue*256
	sub.l	d0,d1		;d1=Space which have to be tide over
	divs	d2,d1		;(in d2(=number of tints) times)
	move.w	d1,4(a0)	;Blue INC Value*256
	rts			

CounterINCVal:	dc.w	0,0,0   ;Counter INC values (R,G,B)
RGBcounters:	dc.w	0,0,0   ;Counters (R,G,B)
					
Tints:		blk.w	steps,0 
