I think I read this from bunny's tutorial. My question is can sprites be piled? or I can only use 1 background tile and 1 sprite title at the same place, which means 6 colors at most?(7 if bg color counted as 4?)
Of course sprites can be piled; Super Mario Bros. 2 and the entire Mega Man series use this to add detail to the hero's face. You just don't see it often because of the NES PPU's 25% sprite overdraw limit: sprites start to flicker and drop out if more than eight are on a scanline. (The Super NES has 100% sprite overdraw, and the GBA and DS have closer to 400%.)
Contra and Kart Fighter draw the top half of a character with one palette and the bottom half with another.
Yeah, you can do this, you just can't do it a lot because of the low limit of sprites per scanline (8). If you start to pile them up too much, that limit is reached pretty quickly.
In the sonic Game I expect to finish some day, Sonic uses stacked sprites which make use of two palettes (one has white, blue and dark blue while the other has the skin and red tones). When designing the sprites I try to use as few of them as possible in the same scanlines, trying to use in most cases 3 sprites and at most 4, so that there are enough left to draw the rest of the game objects without too much flickering.
By using vertical scrolling tricks, you can get palettes assigned per 16x8 area instead of every 16x16 area. Klax does it.
I see. I can pile the sprites up to get more detailed picture.
I'd like to ask, through the whole game, only 4 sub palettes can be used? Can I change them? like in the town uses 4, and change to another 4 after entering a battle.
In sprite sub palette, the first color is transparent, so it doesn't matter what color I place there, am I correct? And how about the background sub palette? The first color will be the universal background color. What will happen if I put different color in the first place of each sub pal?
Yeah, you can change the palette anytime (well almost anytime, as long as it's during vblank or an otherwise safe time for writing $2006/$2007). Normally what I do to make things simpler in my code is keep the palette in RAM, and copy it into VRAM on every NMI. I figure it takes more time to skip updating it. And that makes it really easy to update the palette from your main loop. And actually if you do scrolling, a similar system is what you should use for the nametable writes as well.
chmaster wrote:
What will happen if I put different color in the first place of each sub pal?
They all point to the same spot in memory, so they will overwrite eachother and the last one written will the one that becomes the background/transparent color.
I see. Thank you very much.
Memblers wrote:
Normally what I do to make things simpler in my code is keep the palette in RAM, and copy it into VRAM on every NMI. I figure it takes more time to skip updating it. And that makes it really easy to update the palette from your main loop. And actually if you do scrolling, a similar system is what you should use for the nametable writes as well.
But time is limited during vertical blanking. You might consider setting up your VRAM update code such that palette updates are delayed until a frame when you're not copying a row of nametable. The logic might look like this:
Code:
if nt_row_dest_addr_hi != 0:
copy_nametable_row()
nt_row_dest_addr_hi = 0
else:
copy_palette()
Yeah, in my platformer I do a lot of alternating PPU updates, and some of them have higher priority than others. The palette has less priority, because even with palette animations, fading and things like that, a delay of 1 or 2 frames is hardly noticeable.