; modified sky blanker, to generate, using the blitter, a controlled, simple, linear colour gradient from pure blue at the very top - off the screen -
; down to white at the centre line, with a fixed intensity - preset - and then continue from there to green as currently used for the foreground, with
; the intention of reaching pure green in 16 lines

.text

Skyfill::

; new system - use rle dithered sky, decompress then blit the grass in

movea.l	#$100000,a0
moveq.l	#1,d0

bsr	rldin			; run length decoder start point

; now the blitted section
; first of all the bits which are constant for all screen lines and don't need re-setting

move.l	#sky_store,d0		; main address
bsr	WaitBlit
move.l	d0,A1_BASE		; base address
move.l	#$28,A1_FLAGS		; 32bit, pitch 1 (=1 gaps), phrase mode
move.l	#(320*50),A1_PIXEL		; no offset in x, start on y row 100

.if	0	; This section is to generate BANDS of sky, hence no longer needed

	; now get the initial colour, and set up for looping
	move.l	#$00C000C0,d0		; start at medium blue
	move.l	#7,d1			; for 8 blocks of 8 lines - gets us to 08
	
	.loop1:
	move.l	#(160*8+$10000),B_COUNT	; 320*8 pixels, but two at a time
	move.l	d0,B_PATD		; put colour into pattern data
	move.l	d0,B_PATD+4		; and second half
	move.l	#$00010000,B_CMD	; Go
	add.l	#$01000100,d0		; move across palette
	clr.l	blitsem.w
	bsr	WaitBlit
	
	dbra	d1,.loop1
	
	move.l	#7,d1			; for 8 more blocks = 16 altogether - gets to 88
	
	.loop2:
	move.l	#(160*8+$10000),B_COUNT	; 320*8 pixels, but two at a time
	move.l	d0,B_PATD		; put colour into pattern data
	move.l	d0,B_PATD+4		; and second half
	move.l	#$00010000,B_CMD	; Go
	add.l	#$10001000,d0		; move up palette
	clr.l	blitsem.w
	bsr	WaitBlit
	
	dbra	d1,.loop2

.endif

;===================================================
; our new target - the ground colour is now 8e, intensity 80.  We are at 88 C0
; amount to move is 0100 - 0008 = + 00F8
; do this for 14 lines, two at a time, then finish off with a full sweep of 256 - 128 - 14 = 114 lines to the end

;move.l	#6,d1

;.loop3:
;move.l	#(320+$10000),B_COUNT	; two lines of 320 pixels
;move.l	d0,B_PATD		; put colour into pattern data
;move.l	d0,B_PATD+4		; and second half
;move.l	#$00010000,B_CMD	; Go
;add.l	#$00F400F4,d0
;clr.l	blitsem.w
;bsr	WaitBlit

;dbra	d1,.loop3
;==========================================================

move.l	#$88808880,d0		; partial green
move.l	#1,d1		; two lines

.loop3:
move.l	#(160+$10000),B_COUNT	; 320 pixels, but two at a time
add.l	#$03000300,d0
move.l	d0,B_PATD		; put colour into pattern data
move.l	d0,B_PATD+4		; and second half
move.l	#$00010000,B_CMD	; Go
clr.l	blitsem.w
bsr	WaitBlit

dbra	d1,.loop3

move.l	#(320*77+$10000),B_COUNT	; remaining 126 lines
move.l	d0,B_PATD		; put colour into pattern data
move.l	d0,B_PATD+4		; and second half
move.l	#$00010000,B_CMD	; Go
clr.l	blitsem.w

rts

