Rotating Colors on a Sub Palette for NESMaker 4.5.6

vanderblade

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

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.
 

vanderblade

Member
Thanks, Cutter. One last question. Right now the palette cycling code doesn't play well with scrolling games. It leads to a lot of graphical glitches. Do you -- or anybody else reading this -- know of anyway to "stabilize" it for scrolling.
 

CutterCross

Active member
Thanks, Cutter. One last question. Right now the palette cycling code doesn't play well with scrolling games. It leads to a lot of graphical glitches. Do you -- or anybody else reading this -- know of anyway to "stabilize" it for scrolling.
Drexegar seemed to have made a stable version for Beach Master, but I don't remember if he made that public or not.

I don't use NESmaker's default scrolling engine, so I can't really vouch for a proper solution myself.
 

drexegar

Member
I wish @drexegar had shared his version...

OK dumb simple thing I found a few days ago when my fades corrupted scrolling, I have NOT done full testing with it but works so far.

The third bit of the screen updates is for the map so when you want to change just the bg color during scrolling, I use this...

LDA #%00000101
STA updateScreenData


If you doing both the pallete and sprite then you need to turn the second bit on:
LDA #%00000111
STA updateScreenData

OF course though, if your using to much code, this will definitely fall apart.

Let me know if this works.


The original thing I did was look for a spot in the NMI to control the palletes which I don't want to do anymore if I can avoid it.

oh yeah PRO TIP: Screen flags can only be read once during a screen load, so I just store my flag to another set of bits when I need to use the flag during gameplay.
 
Last edited:

Jonny

Member
I'm looking for a little guidance please if anyone can help...

Using MetroVania Module, I get the following out of range error when I try to implement the above script for palette cycling.

The line where it stops seems to have something to do with Trampolines. I tried commenting out that section just to see what happened and I just got another out of range error in a different .asm

Thank you in advance.

***EDIT*** I've actualy solved this but I would like to learn how. I'd been playing about with a few input scripts, like wall grab, projectiles. When I removed them it compiled and the script for palette cycling works as it should. Curious to learn how the input scripts were causing the problem. Is it to so with whats being stored in RAM at the same time or something?

Ooopsie.png
 
Last edited:

Jonny

Member
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.

I did as mentioned above and it seems to work well. When my screen flag 4 is ticked it jumps the palette cycling. This is what I put at the start...

Code:
LDA ScreenFlags00  
    AND #%00010000  
    CMP ScreenFlags00
    BEQ +      
    JMP SeeYaLaterPalleteMallet      
    +
 
I'm looking for a little guidance please if anyone can help...

Using MetroVania Module, I get the following out of range error when I try to implement the above script for palette cycling.

The line where it stops seems to have something to do with Trampolines. I tried commenting out that section just to see what happened and I just got another out of range error in a different .asm

Thank you in advance.

***EDIT*** I've actualy solved this but I would like to learn how. I'd been playing about with a few input scripts, like wall grab, projectiles. When I removed them it compiled and the script for palette cycling works as it should. Curious to learn how the input scripts were causing the problem. Is it to so with whats being stored in RAM at the same time or something?

View attachment 3840
Value out of range = too much code in the bank
You might need to move or remove some routines to free up space.
Ideally, you'd want palette updates to happen during NMI, though it can get messy if you don't know what you're doing.
 

Jonny

Member
Thank you. I thought it was something along those lines but wasn't sure. As it happens there were a few input scripts I wasn't using (just experimenting with). Once I removed them all was good. I could probably 'trim the fat' in other places to get things more efficient. I've noticed a few things in certain scripts for things I will never use, but I don't know enough about ASM or whether removing those parts of the routines will make any difference.
 
Top Bottom