; new version of sky converter - really this should be replaced by a set of modified palettes and proper palette control system

.text
.if 0
Greyer::
	movem.l	d0-d3/a0,-(a7)
	movea.l	#bit_store,a0
	move.l	#1024*128-1,d0		; pixel count
	swap	d0
.lp0:	swap	d0
.lp:	move.b	(a0)+,d1		; colour code
	move.b	(a0)+,d2		; intensity value

.gs:	subq.l	#2,a0
	and.b	#$f0,d1
	lsr.b	#2,d1
	move.w	#$5760,d2		; dark grey as a base colour
	sub.b	d1,d2
.ok:	move.w	d2,(a0)+

.ex:	dbra	d0,.lp
	swap	d0
	dbra	d0,.lp0

	movem.l	(a7)+,d0-d3/a0
rts
.endif

Darker::	; to darken the steering and cockpit animations 
	movem.l	d0-d2/a0,-(a7)
	movea.l	#cockpit,a0
	move.l	#$3FFFF,d0		; all the way up to top of ram !

	swap	d0
.lp0:	swap	d0
.lp1:	move.w	(a0),d1			; read cry colour
	move.b	d1,d2			; get the byte holding intensity
	lsr.b	#2,d2			; get 25%
	sub.b	d2,d1			; remove from original
	move.w	d1,(a0)+		; write back

	dbra	d0,.lp1
	swap	d0
	dbra	d0,.lp0

	movem.l	(a7)+,d0-d2/a0
rts

Blacker::	; to darken the steering and cockpit animations for night time
	movem.l	d0-d2/a0,-(a7)
	movea.l	#cockpit,a0
	move.l	#$3FFFF,d0		; all the way up to top of ram !

	swap	d0
.lp0:	swap	d0
.lp1:	move.w	(a0),d1			; read cry colour
	lsr.b	#2,d1			; get 25% intensity
	move.w	d1,(a0)+		; write back

	dbra	d0,.lp1
	swap	d0
	dbra	d0,.lp0

	movea.l	#Mapdisp,a0
	move.w	#$5000/2-1,d0
	move.w	#$8860,d1		; light colour for map

.lp:	tst.w	(a0)+
	dbne	d0,.lp
	beq.b	.ex
	move.w	d1,-2(a0)
	dbra	d0,.lp

.ex:	movem.l	(a7)+,d0-d2/a0
	rts

.if 0
Fogger::
	movem.l	d0-d2/a0,-(a7)
	movea.l	#bit_store,a0
	move.l	#1024*128-1,d0		; pixel count
	swap	d0
.lp0:	swap	d0
.lp:	move.b	(a0)+,d1		; colour mods
	move.b	(a0)+,d2

.gs:	subq.l	#2,a0
	and.b	#$f0,d1
	lsr.b	#3,d1
	move.w	#$57b0,d2		; foggy grey as a base colour
	add.b	d1,d2
.ok:	move.w	d2,(a0)+

.ex:	dbra	d0,.lp
	swap	d0
	dbra	d0,.lp0

	movem.l	(a7)+,d0-d2/a0
rts
	
.endif
