Rotating Colors on a Sub Palette for NESMaker 4.5.6

Artix

New member
Hiya Guys,

If you want to add effects like water, flicker, or rotate your colors... we modified Dale Coop's previous version for the new NESMaker 4.5.6

If anyone has any improvements, please post and I will merge them in.

Battle on!
Artix



Code:
;; Palette Color Rotation
 ;; NESMaker 4.5.6 
 ;; Modified by Artix & the UltimateGilby (Hacked together from Dale Coop's code from 4.5.1...
 ;;
 ;; IMPORTANT!
 ;; Add these variables to your zero page RAM
 ;; palettesCycleTimer
 ;; tempArtix
 ;;
 ;_; It is so cruel not having Dale Coop Help X_X
 ;_; I feel like I am wandering in a desert, seeing code mirages of 6502 ASM....
 ;; 
 ;; Add this code to your Handle_Game_Timer
 ;; It will rotate one of your sub palletes
 ;; The default is the first one (#$00)...
 ;; 
 ;; I am terrible at this. It probably breaks something. You were warned! XD
 ;; 
 
 
    LDA palettesCycleTimer          ;; Load the Timer
    BNE PaletteCycleTimerCountDown ;; If it is not 0, we are still counting down. Hop down.
    JSR CycleThyPalettes            ;; It is time to cycle the palette!
    LDA #19                         ;; SPEED (This will cycle it every 29 frames)
    STA palettesCycleTimer
    
PaletteCycleTimerCountDown:
    DEC palettesCycleTimer          ;; Decrease the Timer
    JMP SeeYaLaterPalleteMallet     ;; No updates on this round! 
 
CycleThyPalettes:
    ;; ----------------------
    ;; Which Subpallete do you want to cycle?
    ;; #$00 = the 1st
    ;; #$01 = the 2nd
    ;; #$02 = the 3rd
    ;; #$03 = the 4th
    LDA #$00    
    
    ;; ------------------------
    
    
    ;; Palette Cycle
    ASL ;; x2
    ASL ;; x2
    TAX ;; Transfer accumulator into X
    LDA bckPal+1,x ;pocket colour 1 in reg y
    STA tempArtix
    LDA bckPal+2,x 
    STA bckPal+1,x ;move colour 2 to 1
    LDA bckPal+3,x 
    STA bckPal+2,x ;move colour 3 to 2
    LDA tempArtix
    STA bckPal+3,x ;move pocket (y) to 3
    LDA #$01
    STA updateScreenData ;; Writing a 1 to this tells NESmaker it needs to update palettes.
    ;; Although, we might need to protect the other bits if something else is going on
    ;; But I do not know how to do that... Kasumi!? HELP!
    RTS

SeeYaLaterPalleteMallet:
 
Thank you, I will definitely use this. just a little bit for effects. I probably want a background tile that's a television set with static effect done with the cycling.
 

PasseGaming

Active member
Has anyone tested this out? I'm thinking I'd like to add it into my game, just trying to figure out where I would use it.
 

drexegar

Member
PasseGaming said:
Has anyone tested this out? I'm thinking I'd like to add it into my game, just trying to figure out where I would use it.

It says in the document Add this code to your "Handle_Game_Timer" script

I will be trying it out now ill give you the results.
 

Bucket Mouse

Active member
Here's an alternate version I tweaked that just rotates colors 2 and 3 (or 3 and 4 if you're not counting from zero the way the NES does).

The 3-color rotation is fine for effects like water or fire. But sometimes you want a stationary color for the background, so you use Color 1 as that background and alternate between 2 and 3.

Code:
;; Palette Color Rotation
 ;; NESMaker 4.5.6 
 ;; Modified by Artix & the UltimateGilby (Hacked together from Dale Coop's code from 4.5.1...
 ;;
 ;; IMPORTANT!
 ;; Add these variables to your zero page RAM
 ;; palettesCycleTimer
 ;; tempArtix
 ;;
 ;_; It is so cruel not having Dale Coop Help X_X
 ;_; I feel like I am wandering in a desert, seeing code mirages of 6502 ASM....
 ;; 
 ;; Add this code to your Handle_Game_Timer
 ;; It will rotate one of your sub palletes
 ;; The default is the first one (#$00)...
 ;; 
 ;; I am terrible at this. It probably breaks something. You were warned! XD
 ;; 
 
 LDA #$01
 CMP palletteFlag
 BEQ +
 JMP SeeYaLaterPalleteMallet
 +
 
    LDA palettesCycleTimer          ;; Load the Timer
    BNE PaletteCycleTimerCountDown ;; If it is not 0, we are still counting down. Hop down.
    JSR CycleThyPalettes            ;; It is time to cycle the palette!
    LDA #19                         ;; SPEED (This will cycle it every 29 frames)
    STA palettesCycleTimer
    
PaletteCycleTimerCountDown:
    DEC palettesCycleTimer          ;; Decrease the Timer
    JMP SeeYaLaterPalleteMallet     ;; No updates on this round! 
 
CycleThyPalettes:
    ;; ----------------------
    ;; Which Subpallete do you want to cycle?
    ;; #$00 = the 1st
    ;; #$01 = the 2nd
    ;; #$02 = the 3rd
    ;; #$03 = the 4th
    LDA #$00    
    
    ;; ------------------------
    
    
    ;; Palette Cycle
    ASL ;; x2
    ASL ;; x2
    TAX ;; Transfer accumulator into X
    LDA bckPal+2,x ;pocket colour 1 in reg y
    STA tempArtix
;    LDA bckPal+2,x 
;    STA bckPal+1,x ;move colour 2 to 1  altered to cycle the second and third palettes only
    LDA bckPal+3,x 
    STA bckPal+2,x ;move colour 3 to 2
    LDA tempArtix
    STA bckPal+3,x ;move pocket (y) to 3
    LDA #$01
    STA updateScreenData ;; Writing a 1 to this tells NESmaker it needs to update palettes.
    ;; Although, we might need to protect the other bits if something else is going on
    ;; But I do not know how to do that... Kasumi!? HELP!
    RTS

SeeYaLaterPalleteMallet:
 

Logana

Well-known member
did you make the user variable, also in the original post someone made a conversion, i used it for the monster slayer demo for byte off, worked fine
 

Logana

Well-known member
on wait you posted in in the blank document, just remove it and make a new folder for that type off stuff, changing any pre existing code can severly screws with the entire engine, especially the blank one because they are used as plac holders
 

Logana

Well-known member
yeah, it should be in the screen settings, its unused for the most part, so they hijacked it for the on or off button for each screen of pallet cycleing
 

Logana

Well-known member
hmmm, did you change the handle timer thing to the script you made for pallet cycleing ?
 

CutterCross

Active member
yeah, it should be in the screen settings, its unused for the most part, so they hijacked it for the on or off button for each screen of pallet cycleing
screenSpeed isn't used in that script, so the screen speed settings in Screen Info has nothing to do with this.
 

Logana

Well-known member
oh, hu idk that's just how i got pallet swaping worked for me guess i did something wrong, but it works anyway and I can switch it on and off for an on screen basis
 

vanderblade

Active member
Thanks for this. I see this isn't using the screenspeed, so what is it using to determine which screens cycle palettes and which do not? Is it a screenflag?
 

CutterCross

Active member
Thanks for this. I see this isn't using the screenspeed, so what is it using to determine which screens cycle palettes and which do not? Is it a screenflag?
Looking at Artix's original code, nothing. There's nothing that determines when cycling doesn't happen, it'll always cycle by default. Adding in an extra conditional like that is something you have to do.
 

vanderblade

Active member
I see that now and after implementing. Quick question that will help me a ton now and down the line. I was able to customize the code for just the color numbers I need to swap. However...

I see Bucket Mouse did add a conditional at the beginning of their script.

Code:
 LDA #$01
 CMP palletteFlag
 BEQ +
 JMP SeeYaLaterPalleteMallet
 +

Is anybody able to break the above down for me. My question is where exactly do I establish screenflags in 4.5.x. What is the #$01 referencing exactly? Basically, it's like, if the screen in question is flagged, continue on. If not, jump to the end. I understand the logic. Just looking for the how-to of it.
 

CutterCross

Active member
I see that now and after implementing. Quick question that will help me a ton now and down the line. I was able to customize the code for just the color numbers I need to swap. However...

I see Bucket Mouse did add a conditional at the beginning of their script.

Code:
 LDA #$01
CMP palletteFlag
BEQ +
JMP SeeYaLaterPalleteMallet
+

Is anybody able to break the above down for me. My question is where exactly do I establish screenflags in 4.5.x. What is the #$01 referencing exactly? Basically, it's like, if the screen in question is flagged, continue on. If not, jump to the end. I understand the logic. Just looking for the how-to of it.
Pretty sure Bucket Mouse just made a custom variable for that, so that alone wouldn't help you.

ScreenFlags00 represents the first 8 screen flags in Screen Info (for 4.5.6), which you should be familiar with from 4.1.5. Don't ask me why the name was slightly changed. You could just use one of those flags to act as your "palette cycle flag" and just AND against it to check for the bit you want.
 
Top Bottom