4.5.9 Temporarily Change The Color Of Text

Bucket Mouse

Active member
I wrote a script that can change the color of the text in your text box, and then change it back to normal in the next box. Why would you need that, you might ask? Well, in my case I wanted to signify when we were hearing a character's thoughts. You can use it for similar moments when you need the text to feel different.

It works the same way as my Uppercase and Lowercase Text Script, which can be found here...in fact, the two scripts are compatible with each other. It uses the fourth special character, while the other script uses the other three. The first thing you need to do is make sure those special characters are active, or the script won't work -- go to HUD And Boxes, click the Tiles tab and assign USER_0 through USER_3 to any symbol on the top row.

Next you need a new variable in Zero Page RAM, tempColor. Open up Project Settings and put it in there.

Now open up doDrawText, and save it as a new version of itself (doDrawText-colors.asm or something). Locate these two lines:

+continueRoutine
LDA temp

Below that, paste this:

Code:
    CMP #_USER_3
    BNE notchar4
    LDA tempColor
    BNE restoreColor
    ;; turn on color
    LDA #$03   
    ASL ;; x2
    ASL ;; x2
    TAX ;; Transfer accumulator into X
    LDA bckPal+3,x
    STA tempColor
    LDA bckPal+2,x 
    STA bckPal+3,x
        LDA #$01
    STA updateScreenData
    JMP skipthischaracter
    ;; restore original color
    restoreColor:
        LDA #$03   
    ASL ;; x2
    ASL ;; x2
    TAX ;; Transfer accumulator into X
    LDA tempColor
    STA bckPal+3,x
    LDA #$00
    STA tempColor
    LDA #$01
    STA updateScreenData
    JMP skipthischaracter
    
skipthischaracter:

Scroll a few lines down and below JMP doneWithText, add this:

Code:
notchar4:

Now open up doDrawBox.asm and save it to a new name as well. Do a Control-F search for "do02endBoxAction." Once you find it, go right below the line with the EraseBox macro and add this:

Code:
    LDA tempColor
    BEQ +
    LDA #$03   
    ASL ;; x2
    ASL ;; x2
    TAX ;; Transfer accumulator into X
    LDA tempColor
    STA bckPal+3,x
    LDA #$00
    STA tempColor
    LDA #$01
    STA updateScreenData
    +

Finally, make a new version of LoadAllSubroutines.asm and change the line with doDrawText to the address of your modified script.

Open up Project Settings in NESMaker and change your regular Draw Box and LoadAllSubroutines to the new ones. You should be good to go.

HOW TO USE IT:
Whenever you want to display a text box in the alternate color, put the % symbol at the beginning of your message. If you put % anywhere else, the entire text box will change color midcrawl -- which could be what you want, I don't know. The third color in your fourth palette will be used (as opposed to the fourth color, usually white).

The script is programmed to change the text back to normal once the box disappears (that's the whole point of what you pasted into doDrawBox). However, if you have a multi-frame message, and you want the next message to be written in the normal color, you can do that too. Simply use the % symbol a second time, like this:

%YAKKITY YAK>
%DONT TALK BACK

By the way, if no one ever told you, a > symbol followed by a space will stop the text and continue it with a new message once A is pressed again. That's what I'm talking about here and for some reason a lot of NESMaker users still aren't aware they can do this.

game_014.png

WARNING: Since this code temporarily changes the HUD palette (which the text box shares), it will temporarily change that color on the HUD as well. You can avoid this by using a sprite HUD, or just using the trick on screens where the HUD is hidden. This is an effect best used on cutscenes, which don't have a HUD anyway.

"Is it possible to just add color to a PORTION of the text?" you might be asking....
Kinda, but it's a whole other can of worms. You can technically do it by using my Uppercase and Lowercase script, making BOTH alphabets uppercase, casting one in a different color, and then using the symbols to section off the parts you want colored. This method also won't affect the HUD like this one will. BUT it has the same flaw the Uppercase and Lowercase script has (you need to reserve a portion of your graphics on each screen for the extra text rows) and you'll ALSO be forced to display the text on every other frame, because the NESMaker engine assigns colors on a 16 x 16 grid and text is 8 x 8. If you're fine with all of that.....that's the way to do it.
 
Top Bottom