chains
Member
I've found the problem.
The background code is working ok, but the sprite changing is not because of the flag to update the screen in the next cycle.
If you see the code responsible to load the palettes in $2007 registry, you will see something like this:
Note that the flag that needs to be set is the 7th and in this code we are setting the 8th:
The final working version is:
Another thing is, if you run this script ONCE, it will darken the colors of the pals, ONCE, and for ALL sprites on the screen.
If you don't want this, you can control which pal index you want to darken in the second portion of the code (goNextSpritePal). It controls the pal index (0-12).
So when you add this to your object details, you can make an action to Fade the Object, repeat a couple of times until all the 4 colors in the pal are turned black (#0F), and then move to DestroyObject.
I hope that this helps someone out there. @9Panzer could you try this and tell me if you managed?
What we've learned today? Don't copy someone else's code without proper understanding.
The background code is working ok, but the sprite changing is not because of the flag to update the screen in the next cycle.
If you see the code responsible to load the palettes in $2007 registry, you will see something like this:
Code:
doPaletteUpdates:
.include SCR_LOAD_PALETTES
JMP skipScreenUpdates
+
LDA updateScreenData
AND #%00000010
BNE doSpritePaletteUpdates:
JMP +
doSpritePaletteUpdates:
.include SCR_LOAD_SPRITE_PALETTES
;;; this code above is in the SRC:
LoadSpritePal_NMI:
LDA sprPal,x
STA $2007
INX
CPX #$10
BNE LoadSpritePal_NMI
LDA updateScreenData
AND #%11111101
STA updateScreenData
Note that the flag that needs to be set is the 7th and in this code we are setting the 8th:
Code:
LDA #$01
STA updateScreenData
The final working version is:
Code:
LDX #$00
doFadeCurrentSpritePal:
LDA sprPal,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 sprPal,x ;; store it back into pallete
JMP goNextSpritePal;; jump to the next pal2
+
LDA #$0F ;; set accumalator to 0F which is (black)
STA sprPal,x ;; store it into pallete
goNextSpritePal:
INX
CPX #4
BEQ goNextSpritePal
CPX #8
BEQ goNextSpritePal
CPX #12
BEQ goNextSpritePal
CPX #16
BCC doFadeCurrentSpritePal
LDA #%00000010
STA updateScreenData
RTS
Another thing is, if you run this script ONCE, it will darken the colors of the pals, ONCE, and for ALL sprites on the screen.
If you don't want this, you can control which pal index you want to darken in the second portion of the code (goNextSpritePal). It controls the pal index (0-12).
So when you add this to your object details, you can make an action to Fade the Object, repeat a couple of times until all the 4 colors in the pal are turned black (#0F), and then move to DestroyObject.
I hope that this helps someone out there. @9Panzer could you try this and tell me if you managed?
What we've learned today? Don't copy someone else's code without proper understanding.