Fade to Black [4.5.6]

AllDarnDavey

Active member
Fade in from black is a trickier, but fade to black is pretty easy. So I ported over dale_coop's fade to black code to 4.5.6
Split it into background and sprite fade versions.

Fade background palettes to black
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for background pals - code by dale_coop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDX #$00 
doFadeCurrentBckPal:
	LDA bckPal,x ;; loads joes pallete for background (0-3) (4-7) (8-11) (12-15) 4,8,and 12 is not needed since its the same bgcolor as 0
	CMP #$10 ;; compares 10
	BCC + ;; if less than 10 skip to p1, if not continue below
	SEC ;; needs for subtraction
	SBC #$10 ;; subtract #$10
	STA bckPal,x ;; store it back into pallete
	JMP goNextBckPal;; jump to the next pal2
	+ 
	LDA #$0F ;; set accumalator to 0F which is (black)
	STA bckPal,x ;; store it into pallete
goNextBckPal:
	INX	
	CPX #4
	BEQ goNextBckPal
	CPX #8
	BEQ goNextBckPal
	CPX #12
	BEQ goNextBckPal
	CPX #16
	BCC doFadeCurrentBckPal
	LDA #$01
	STA updateScreenData	
RTS

Fade Sprites to black
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for sprite pals - code by dale_coop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDX #$00 
doFadeCurrentSpritePal:
	LDA spritePalFade,x ;; loads joes pallete for background (0-3) (4-7) (8-11) (12-15) 4,8,and 12 is not needed since its the same color as 0
	CMP #$10 ;; compares 10
	BCC + ;; if less than 10 skip to p1, if not continue below
	SEC ;; needs for subtraction
	SBC #$10 ;; subtract #$10
	STA spritePalFade,x ;; store it back into pallete
	JMP goNextSpritePal;; jump to the next pal2
	+ 
	LDA #$0F ;; set accumalator to 0F which is (black)
	STA spritePalFade,x ;; store it into pallete
goNextSpritePal:
	INX	
	CPX #4
	BEQ goNextSpritePal
	CPX #8
	BEQ goNextSpritePal
	CPX #12
	BEQ goNextSpritePal
	CPX #16
	BCC doFadeCurrentSpritePal
	LDA #$01
	STA updateScreenData	
RTS
 

5kids2feed

Active member
4.6.9 problem with first code...

This worked for me when I did 4.5.6 but not on the update..

Says label already defined for 5 & 16..

5 is... doFadeCurrentBckPal:
16 is.. goNextBckPal:

Anybody know how to work around this?
 
Last edited:

Jonny

Active member
4.6.9 problem with first code...

This worked for me when I did 4.5.6 but not on the update..

Says label already defined for 5 & 16..

5 is... doFadeCurrentBckPal:
16 is.. goNextBckPal:

Anybody know how to work around this?

You could try doing a search of all scripts to see where they're first defined. Maybe a different routine is messing things up.

Question: Where would this code by used? As a monster action or somewhere else?
 

5kids2feed

Active member
Ah I see.. Weird.. I didn't have it anywhere else..

I changed all the doFadeCurrentBckPal & goNextBckPal to have an extra L at the end.. then it worked.. kinda.. it doesn't fade.. just turns black for a second then goes to the next screen. hmm.

Do I need to setup a pallete somehow? Think that's what i'm missing.
 

Jonny

Active member
Fade in from black is a trickier, but fade to black is pretty easy. So I ported over dale_coop's fade to black code to 4.5.6
Split it into background and sprite fade versions.

For the sprite fade, where is "spritePalFade" from? Is that a variable that need to be set up in user variables? I can't find it in a search both for 4.5.6 and 4.5.9
 

Jonny

Active member
The variable name should be sprPal for 4.5.X.
Cheers, I actually tried sprPal shortly afterwards. It looked like the nearest thing. Still can't get anything to change. Maybe there's something I'm not understanding, do the colours of palettes being used have to be set up a certain way. The only way I can get any change at all is using 'spriteSubPal2'. Sounds like its super easy from the comments so I must be missing something. Background fade seems to work fine.
 

9Panzer

Active member
Did you get it working @Jonny ? I ran into the same issue. Background is no issue at all but nothing happens with the sprites.
 
Top Bottom