Screen Fading

User avatar
chronicleroflegends
Posts: 192
Joined: Thu Sep 06, 2018 3:51 am

Screen Fading

Post by chronicleroflegends » Thu Mar 21, 2019 3:44 pm

I know a few people have figured out how to get the partially existing screen fading code working, and I was wondering if anyone is willing to share now that the competition submissions are in.
(I know making a tutorial would have taken quite a bit of time away from working on submissions)

Since I am not using scrolling, I would like to implement a nice screen fade transition from one screen to another similar to the Troll Burner demo.
~Do you believe in legends? ~
My Games: Nix: The Paradox Relic
User avatar
dale_coop
Posts: 5601
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Screen Fading

Post by dale_coop » Thu Mar 21, 2019 3:52 pm

Personnaly, I made a AI script (monster action or End of action/animation), that will fade to black.
Here the script (thanks to drexegar for the first draft):

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for background pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for sprite pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	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 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 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



	;; Important you need to load a non 0 number into updatePalettes and do a RTS so it can work.
	;; If you want to do palletes use "spritePalFade" instead of "bckPal"
	LDA #$01
	STA updatePalettes
RTS
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
drexegar
Posts: 226
Joined: Wed Mar 21, 2018 12:33 pm

Re: Screen Fading

Post by drexegar » Fri Mar 22, 2019 2:32 am

dale_coop wrote:
Thu Mar 21, 2019 3:52 pm
Personnaly, I made a AI script (monster action or End of action/animation), that will fade to black.
Here the script (thanks to drexegar for the first draft):


I just realized that CPX means compare x right? And you did a INX increase X loop which I just learned a few days ago and use CPX to skip the other numbers.

I wanted to do a fade in but I dont want to have to store 20 palletes manually, no documentation so I do not know where the current pallete is stored in memory for backgrounds and sprites.

all I would have to do is just first grab the vaules(whereever they are stored), subtract 10, 20, and 30 depending on its 10 vaule so all the colors can be the darkest shade then add 10 to each color until it matches the stored pallete and then stops.

I cant do it cause I have no clue how to call up the pallet's STORED vaules for comparing.

Do you know where it is dale?
User avatar
dale_coop
Posts: 5601
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Screen Fading

Post by dale_coop » Fri Mar 22, 2019 7:31 am

bckPal And spriteFadePal are the palettes currently loaded (bckPal the screen’s ones 4 palettes of 4 colors... and spriteFadePal are your gameobjects/monsters ones, 4 palettes of 4 colors too).
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
My son's game: KUBO 3
User avatar
drexegar
Posts: 226
Joined: Wed Mar 21, 2018 12:33 pm

Re: Screen Fading

Post by drexegar » Fri Mar 22, 2019 11:56 am

dale_coop wrote:
Fri Mar 22, 2019 7:31 am
bckPal And spriteFadePal are the palettes currently loaded (bckPal the screen’s ones 4 palettes of 4 colors... and spriteFadePal are your gameobjects/monsters ones, 4 palettes of 4 colors too).
yeah but what happens when you change them, I can't get the originals screen colors, unless I store all 26 colors before I attempt a fade in.There is no way to tell the nes to stop raising the color, unless it knows when to stop, I wonder how fade in can work in dimension shift, thorugh nesmaker is must be reading from some sort of table data being stored.
User avatar
Mugi
Posts: 813
Joined: Thu Dec 27, 2018 8:30 pm

Re: Screen Fading

Post by Mugi » Fri Mar 22, 2019 12:54 pm

drexegar wrote:
Fri Mar 22, 2019 11:56 am
I wonder how fade in can work in dimension shift, thorugh nesmaker is must be reading from some sort of table data being stored.
the fade in dimension shift works basically just how it's laid out in the handlefade.asm that is present in the GameEngineData\Routines\Basic\System\HandleFades.asm
all i did to it was repair the missing pieces of this code and put it back in use.

using this file requires you to restore an include to the handlefades.asm into the bank data, restoring all the ZeroPage variables that are commented out (include the handlefades asm and compile the game to see all the errors it spits out, those will tell you which variables you need to enable for it.)

in addition to that, few changes had to be made to the handlefades code itself, and the "load new data" function of the code is commented out because it is non-functioning (i dont use it so dont ask.) in addition to that, handlepalettes needs some changes to accomondate to the working of the fades.

after that, using the macros for fade_darken and fade_lighten can be used to fade the screen in and out.

there is no dark sorcery involved in the way my game does fading. it's all the code joe wrote a long time ago for nesmaker, and in all likelihood, also the same code that was used for trollburner.


edit: i would like to point out that while i am using this code now since it works, it's terribly space-inefficient and a better way would propably just to write something more specific to one's own game, than to attempt to fix the handlefades.asm

for starters, this eats A LOT of zeropage (i literally have 2 bytes left because of this clusterf** of a code) and the whole deal with having to litter the macro to fade in and out everywhere eats tons and tons of space from bank14.
assuming you just want a fadeout/fadein for screen transitions, you're far better off writing something much more compact, and hooking it into handlescreenloads to make it play nice.

the way joe's code is designed, is the typical nesmaker code, as such, it is VERY versatile on how it can be used, but this always comes with the heavy price of extremely high resource usage. (also, it doesnt fade sprites, that's broken too, i didnt fix it since i dont want to fade sprites, so i just left it be.)
"what are you up to?" "Oh, not much... just... Parallaxing"
- Raftronaut
User avatar
chronicleroflegends
Posts: 192
Joined: Thu Sep 06, 2018 3:51 am

Re: Screen Fading

Post by chronicleroflegends » Fri Mar 22, 2019 4:08 pm

dale_coop wrote:
Thu Mar 21, 2019 3:52 pm
Personnaly, I made a AI script (monster action or End of action/animation), that will fade to black.
Here the script (thanks to drexegar for the first draft):
---
Something strange, I cannot seem to use this script as an end of action/animation script.
From nothing, if I add the script exactly as it is and assign it to a blank end action, I get 'label already defined errors'

I looked it up in demo.txt and it seems to be throwing the error because it .includes the script twice, once for end actions and one for end animations.
That doesn't make sense though, because other end actions use labels and it doesn't cause an issue.

Edit: I got it working as a normal AI action, just wanted to mention that above ^^ Not sure why it causes that error.

I'm going to experiment with this and see if I can get similar code working for screen transitions.
~Do you believe in legends? ~
My Games: Nix: The Paradox Relic
User avatar
chronicleroflegends
Posts: 192
Joined: Thu Sep 06, 2018 3:51 am

Re: Screen Fading

Post by chronicleroflegends » Fri Mar 22, 2019 7:18 pm

Progress:

I wrote a script that just does fading in/out. Meant for transitioning between screens.
When assigned to a monster action, it works fine. (Change this script by removing the RTS at the end and setting the animation speed to 1 to get it to work as monster action)
It fades out perfectly, and I think it fades in too (it happens too fast to tell, still working on that.) How it works is it toggles
I am trying to make it a subroutine so I can make the fades happen whenever you touch a screen edge.
What happens though is that the emulator crashes :\

Here is my code so far:

Code: Select all

;;Fade Screen and Sprites
;; Original Fade To Black Code by Dale_Coop
;; Modifications by ChroniclerOfLegends

;; Must Add two variables to ZP RAM and 1 user variable:
;fadeStep - user variable initialized to 3
;bckPalTmp - 16 bytes
;sprPalTmp - 16 bytes

Screen_Transition:

;; Check to see if we need to fade out or in
	LDA fadeStep
	CMP #$00 ;; Screen is not faded out
	BEQ FadeToBlack
	;; Backup palettes
	LDX #$00
	doPalBackup:
		LDA bckPal,x
		STA bckPalTmp,x
		LDA spritePalFade,x
		STA sprPalTmp,x
	getNextPalToBackup:
		INX	
		CPX #4
		BEQ getNextPalToBackup
		CPX #8
		BEQ getNextPalToBackup
		CPX #12
		BEQ getNextPalToBackup
		CPX #16
		BCC doPalBackup
	JMP FadeBackIn

;; The screen is not faded, so we need to fade it out.
FadeToBlack:
	LDA fadeStep
	CMP #$03
	BNE +
	JMP doneWithFades
  +:
	JSR FadeOutOneStep
	JMP FadeToBlack
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for background pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FadeOutOneStep:

	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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for sprite pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	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 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 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



	;; Important you need to load a non 0 number into updatePalettes and do a RTS so it can work.
	;; If you want to do palletes use "spritePalFade" instead of "bckPal"
	LDA #$01
	STA updatePalettes
	
	INC fadeStep
	
	RTS

;;---------------------------------------------------------------------------------------------------------;;

;;;; The Screen was already faded out, so we need to fade it back in now.
FadeBackIn:
	;;Set the screen and sprites to black
	JSR SetPaletteBlack
	
fadeBackInLoop:
	LDA fadeStep
	CMP #$00
	BNE +
	JMP doneWithFades
  +:
	JSR FadeInOneStep
	JMP fadeBackInLoop
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for background pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FadeInOneStep:

	LDX #$00 
doFadeCurrentBckPalIn:
	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
	CLC
	ADC #$10 ;; Add #$10
	CMP bckPalTmp,x
	BCC +
	LDA bckPalTmp,x
  +:
	STA bckPal,x ;; store it back into pallete
	JMP goNextBckPalIn;; jump to the next pal2
goNextBckPalIn:
	INX	
	CPX #4
	BEQ goNextBckPalIn
	CPX #8
	BEQ goNextBckPalIn
	CPX #12
	BEQ goNextBckPalIn
	CPX #16
	BCC doFadeCurrentBckPalIn

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for sprite pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDX #$00 
doFadeCurrentSpritePalIn:
	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 bgcolor as 0
	CLC
	ADC #$10 ;; add #$10
	CMP sprPalTmp,x
	BCC +
	LDA sprPalTmp,x
  +:
	STA spritePalFade,x ;; store it back into pallete
	JMP goNextSpritePalIn;; jump to the next pal2
goNextSpritePalIn:
	INX	
	CPX #4
	BEQ goNextSpritePalIn
	CPX #8
	BEQ goNextSpritePalIn
	CPX #12
	BEQ goNextSpritePalIn
	CPX #16
	BCC doFadeCurrentSpritePalIn


	;; Important you need to load a non 0 number into updatePalettes and do a RTS so it can work.
	;; If you want to do palletes use "spritePalFade" instead of "bckPal"
	LDA #$01
	STA updatePalettes
	
	DEC fadeStep
	
	RTS
	
	
; Set Palette Black Subroutine
SetPaletteBlack:
	LDA #$0F ;; set accumalator to 0F which is (black)
	STA bckPal,x ;; store it into pallete
	STA spritePalFade,x ;; store it into pallete
	LDA #$01
	STA updatePalettes
	RTS
	
	
doneWithFades:
	RTS
Edit: I also don't know if there is a more resource-friendly way of getting your original palettes back when fading in.
I had to use 32 bytes for the temporary palette data :(
~Do you believe in legends? ~
My Games: Nix: The Paradox Relic
User avatar
drexegar
Posts: 226
Joined: Wed Mar 21, 2018 12:33 pm

Re: Screen Fading

Post by drexegar » Sat Mar 23, 2019 12:01 pm

chronicleroflegends wrote:
Fri Mar 22, 2019 7:18 pm
Progress:

I wrote a script that just does fading in/out. Meant for transitioning between screens.
When assigned to a monster action, it works fine. (Change this script by removing the RTS at the end and setting the animation speed to 1 to get it to work as monster action)
It fades out perfectly, and I think it fades in too (it happens too fast to tell, still working on that.) How it works is it toggles
I am trying to make it a subroutine so I can make the fades happen whenever you touch a screen edge.
What happens though is that the emulator crashes :\

Here is my code so far:

Code: Select all

;;Fade Screen and Sprites
;; Original Fade To Black Code by Dale_Coop
;; Modifications by ChroniclerOfLegends

;; Must Add two variables to ZP RAM and 1 user variable:
;fadeStep - user variable initialized to 3
;bckPalTmp - 16 bytes
;sprPalTmp - 16 bytes

Screen_Transition:

;; Check to see if we need to fade out or in
	LDA fadeStep
	CMP #$00 ;; Screen is not faded out
	BEQ FadeToBlack
	;; Backup palettes
	LDX #$00
	doPalBackup:
		LDA bckPal,x
		STA bckPalTmp,x
		LDA spritePalFade,x
		STA sprPalTmp,x
	getNextPalToBackup:
		INX	
		CPX #4
		BEQ getNextPalToBackup
		CPX #8
		BEQ getNextPalToBackup
		CPX #12
		BEQ getNextPalToBackup
		CPX #16
		BCC doPalBackup
	JMP FadeBackIn

;; The screen is not faded, so we need to fade it out.
FadeToBlack:
	LDA fadeStep
	CMP #$03
	BNE +
	JMP doneWithFades
  +:
	JSR FadeOutOneStep
	JMP FadeToBlack
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for background pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FadeOutOneStep:

	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

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for sprite pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	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 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 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



	;; Important you need to load a non 0 number into updatePalettes and do a RTS so it can work.
	;; If you want to do palletes use "spritePalFade" instead of "bckPal"
	LDA #$01
	STA updatePalettes
	
	INC fadeStep
	
	RTS

;;---------------------------------------------------------------------------------------------------------;;

;;;; The Screen was already faded out, so we need to fade it back in now.
FadeBackIn:
	;;Set the screen and sprites to black
	JSR SetPaletteBlack
	
fadeBackInLoop:
	LDA fadeStep
	CMP #$00
	BNE +
	JMP doneWithFades
  +:
	JSR FadeInOneStep
	JMP fadeBackInLoop
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for background pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FadeInOneStep:

	LDX #$00 
doFadeCurrentBckPalIn:
	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
	CLC
	ADC #$10 ;; Add #$10
	CMP bckPalTmp,x
	BCC +
	LDA bckPalTmp,x
  +:
	STA bckPal,x ;; store it back into pallete
	JMP goNextBckPalIn;; jump to the next pal2
goNextBckPalIn:
	INX	
	CPX #4
	BEQ goNextBckPalIn
	CPX #8
	BEQ goNextBckPalIn
	CPX #12
	BEQ goNextBckPalIn
	CPX #16
	BCC doFadeCurrentBckPalIn

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; do fading to black for sprite pals
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	LDX #$00 
doFadeCurrentSpritePalIn:
	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 bgcolor as 0
	CLC
	ADC #$10 ;; add #$10
	CMP sprPalTmp,x
	BCC +
	LDA sprPalTmp,x
  +:
	STA spritePalFade,x ;; store it back into pallete
	JMP goNextSpritePalIn;; jump to the next pal2
goNextSpritePalIn:
	INX	
	CPX #4
	BEQ goNextSpritePalIn
	CPX #8
	BEQ goNextSpritePalIn
	CPX #12
	BEQ goNextSpritePalIn
	CPX #16
	BCC doFadeCurrentSpritePalIn


	;; Important you need to load a non 0 number into updatePalettes and do a RTS so it can work.
	;; If you want to do palletes use "spritePalFade" instead of "bckPal"
	LDA #$01
	STA updatePalettes
	
	DEC fadeStep
	
	RTS
	
	
; Set Palette Black Subroutine
SetPaletteBlack:
	LDA #$0F ;; set accumalator to 0F which is (black)
	STA bckPal,x ;; store it into pallete
	STA spritePalFade,x ;; store it into pallete
	LDA #$01
	STA updatePalettes
	RTS
	
	
doneWithFades:
	RTS
Edit: I also don't know if there is a more resource-friendly way of getting your original palettes back when fading in.
I had to use 32 bytes for the temporary palette data :(
My brain hurts trying to figure some of this stuff, but I see you still have to store temporary data, so the only work around, which only works for a few people, my game uses 3 equal brightness across every pallete, so I just use a formula that picks the correct brightness assuming brightness of the pallete matches, I only need 1 variable to control this, but then I have to work around any levels I use for pallete swapping so a good 2 more would work just for those.
User avatar
chronicleroflegends
Posts: 192
Joined: Thu Sep 06, 2018 3:51 am

Re: Screen Fading

Post by chronicleroflegends » Wed Mar 27, 2019 3:09 am

Mugi wrote:
Fri Mar 22, 2019 12:54 pm
drexegar wrote:
Fri Mar 22, 2019 11:56 am
I wonder how fade in can work in dimension shift, thorugh nesmaker is must be reading from some sort of table data being stored.
the fade in dimension shift works basically just how it's laid out in the handlefade.asm that is present in the GameEngineData\Routines\Basic\System\HandleFades.asm
all i did to it was repair the missing pieces of this code and put it back in use.

using this file requires you to restore an include to the handlefades.asm into the bank data, restoring all the ZeroPage variables that are commented out (include the handlefades asm and compile the game to see all the errors it spits out, those will tell you which variables you need to enable for it.)

in addition to that, few changes had to be made to the handlefades code itself, and the "load new data" function of the code is commented out because it is non-functioning (i dont use it so dont ask.) in addition to that, handlepalettes needs some changes to accomondate to the working of the fades.

after that, using the macros for fade_darken and fade_lighten can be used to fade the screen in and out.

there is no dark sorcery involved in the way my game does fading. it's all the code joe wrote a long time ago for nesmaker, and in all likelihood, also the same code that was used for trollburner.


edit: i would like to point out that while i am using this code now since it works, it's terribly space-inefficient and a better way would propably just to write something more specific to one's own game, than to attempt to fix the handlefades.asm

for starters, this eats A LOT of zeropage (i literally have 2 bytes left because of this clusterf** of a code) and the whole deal with having to litter the macro to fade in and out everywhere eats tons and tons of space from bank14.
assuming you just want a fadeout/fadein for screen transitions, you're far better off writing something much more compact, and hooking it into handlescreenloads to make it play nice.

the way joe's code is designed, is the typical nesmaker code, as such, it is VERY versatile on how it can be used, but this always comes with the heavy price of extremely high resource usage. (also, it doesnt fade sprites, that's broken too, i didnt fix it since i dont want to fade sprites, so i just left it be.)
Taking another shot at this, my custom script is not currently playing nice so I was taking another shot at fixing what was there. I managed to squeeze those variables into my zero page ram (with no room to spare), restore the.include for the fades, and place the macros. No errors, but no fades either. I saw that you said handlepalletes needs fixes too. Silly question but where is handlepalletes? I cannot find that script anywhere.
~Do you believe in legends? ~
My Games: Nix: The Paradox Relic
Post Reply