I have one scenario where the text color clashes with the rest of the background. This cause that I cannot set that background tile to the proper color because of the overlap.
Since I will need to change mid-frame the chr bank to display the text (it doesn't fit with the rest of the background), maybe it would be possible to change the color to alleviate this issue?
What are the things that I should be careful about? I think if I only change 1 color of the palette by closing rendering then in vblank put back the BG color then it would be fine?
What are the pitfalls?
The main pitfalls with changing the palette mid-frame are:
1- You have to disable rendering mid-frame, which can corrupt OAM on the next frame (the corruption will happen at the start of the next frame, so even a full OAM DMA during vblank won't prevent that). It seems it's safe to disable rendering in scanlines where there are no sprites or if you do it as close to the end of the scanline as possible (I don't know the details).
2- Accessing palette RAM during rendering time will cause the color pointed by the VRAM address register to be displayed on screen, so if you don't want any color glitches, you only have the time of hblank to change colors.
The good news is that you don't want to do it in the middle of the action, so you'll probably be able to avoid the sprite problem, and can also spare a few scanlines to make sure that the critical stuff is done during successive hblanks.
If you can (and I'm understanding correctly that you'd be able to do what you wanted if the 16 pixel tall size were smaller), I'd probably look into mid-frame scrolling changes first, since they seem a lot less messy. Klax uses them to achieve 16x8 attributes, just skipping every other row in the nametable.
I'll be the person that asks the dumb question. Are there more than four total background palette sets on screen? If not, the bg attribute limitation probably doesn't need to be a huge factor:
You'll see the text scroll up "off grid" seemingly ignoring the attribute grid. No palette changes are needed.
So is the issue that the palettes for the scene itself don't contain the text color/background color in the same palette? If there IS a palette that contains them both, it's a much easier problem.
That has to be a screen split. You can't get pixel perfect scrolling like that otherwise.
I know it's a screen split, but it's NOT is a palette change mid frame which is what the topic is asking about. I was trying to get information about whether a scroll change would suffice, because a palette change is a little harder and maybe not necessary for the end goal.
Unexpected answers in the thread but actually it would make sense for that screen. Since I need to split it 3 times, the last part where the bank must be switched could have a gap of 8 pixels, allowing the text to be in the next row where attributes are fine and I would just switch the bank and scroll the Y 8 pixel lower to make it looks like to original target.
Now I know about what possible with palette and tricks for attributes. thanks everyone!
You should definitely look at Wizards & Warrior games and see how they do this for their status bar, basically you'll have to do the same. (If I remember well W&W1 and 3 does this, but not W&W 2; I could be wrong). Personally if I'd want to "do things the NES way" I'd avoid doing this whether possible, and only use this at last ressort if I really badly need more colours. Using trickery to re-use the same colours for different objects is more "the NES way to do it".