Rotating Colors on a Sub Palette for NESMaker 4.5.6

Post Reply
User avatar
Artix
Posts: 21
Joined: Wed Nov 21, 2018 3:41 am
Location: Tampa, Floridas
Contact:

Rotating Colors on a Sub Palette for NESMaker 4.5.6

Post by Artix » Wed Aug 19, 2020 3:44 am

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: Select all

;; 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:
User avatar
dale_coop
Posts: 5752
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: Rotating Colors on a Sub Palette for NESMaker 4.5.6

Post by dale_coop » Wed Aug 19, 2020 2:13 pm

<3
-----
I know... my english is not perfect
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
nathanlurker
Posts: 67
Joined: Tue Apr 07, 2020 3:56 pm
Location: Montreal, Canada

Re: Rotating Colors on a Sub Palette for NESMaker 4.5.6

Post by nathanlurker » Thu Aug 20, 2020 5:59 pm

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.
User avatar
PasseGaming
Posts: 239
Joined: Sun May 31, 2020 2:27 am
Location: Philadelphia
Contact:

Re: Rotating Colors on a Sub Palette for NESMaker 4.5.6

Post by PasseGaming » Tue Sep 01, 2020 5:26 pm

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.
Remember; wherever you go, there you are. :mrgreen:

My Projects: Spirit Impel
User avatar
drexegar
Posts: 236
Joined: Wed Mar 21, 2018 12:33 pm

Re: Rotating Colors on a Sub Palette for NESMaker 4.5.6

Post by drexegar » Thu Sep 03, 2020 1:07 pm

PasseGaming wrote:
Tue Sep 01, 2020 5:26 pm
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.
User avatar
PasseGaming
Posts: 239
Joined: Sun May 31, 2020 2:27 am
Location: Philadelphia
Contact:

Re: Rotating Colors on a Sub Palette for NESMaker 4.5.6

Post by PasseGaming » Thu Sep 03, 2020 3:12 pm

Ah, couldn't see that on my phone. I gotcha, thank you!
Remember; wherever you go, there you are. :mrgreen:

My Projects: Spirit Impel
User avatar
Bucket Mouse
Posts: 460
Joined: Wed Mar 07, 2018 2:25 am

Re: Rotating Colors on a Sub Palette for NESMaker 4.5.6

Post by Bucket Mouse » Wed Sep 16, 2020 6:16 am

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: Select all

;; 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:
Post Reply