SMB3 sprite question

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
SMB3 sprite question
by on (#78616)
I've noticed something on SMB3. When mushrooms appear from blocks, the sprite-priority bit isn't used but instead the block seems to be "hidden" by invisible sprites.
Does anyone know why it was designed this way? Why not use the sprite-priority instead?

by on (#78617)
I guess they used sprite priority in SBM1.
I guess the reason they did it this way is that so the metatile right above the question mark doesn't HAVE to be made only of BG color. If anything else is on the metatile just above the question mark, the mushroom (or wathever powerup) sprite would also appear behind it if only the sprite priority bit was used like in SMB1.

by on (#78621)
Interesting, thanks.

How do you guys emulate this behaviour in your emulators? Looping through all sprites (for every sprite) to see if they collide seems a bit slow?
What's the trick? :)

by on (#78623)
I thought they just overplayed sprites that look like the block you just hit on top of the mushroom. There's nothing special you need to do for that. The sprites with the lower OAM addresses will be rendered on top, hiding the bottom of the power-up.

by on (#78624)
qbradq wrote:
I thought they just overplayed sprites that look like the block you just hit on top of the mushroom. There's nothing special you need to do for that. The sprites with the lower OAM addresses will be rendered on top, hiding the bottom of the power-up.


Ok but how does it work with SMB3? I imagine it uses transparent sprites (or am I wrong?) to create the mushroom-powerup effect? Assuming a sprite is transparent, it won't hide anything?

by on (#78626)
Nah man, the sprites that are masking the mushroom look identical to the top tiles of the question block or brick they came from (I am guessing). Play it in Nintendulator and look at the sprite display in the Video Debug screen. I'll bet you will notice two sprites that look like the top of the block.

by on (#78627)
oRBIT2002 wrote:
How do you guys emulate this behaviour in your emulators?

I'm sure someone will give you the exact formula for each screen pixel (and it can also be found in several old threads), but the basic idea is that a high priority (i.e. lower index) sprite will always be in front of a low priority (i.e. higher index) one, even if the high priority sprite has the "behind background" bit set, which causes the high priority sprite to mask the low priority one.

by on (#78641)
I tend to think of it as the highest-priority sprite is the one that sets the sprite-vs-background priority for each (opaque) pixel. The mistake is to think of z-order as a factor. It is a bit unintuitive that a sprite behind the background can be in front of a sprite in front of the background, and even more-so the result when they overlap.

by on (#78826)
Now that we're on the subject of layering in SMB3, it reminds me of a question I thought of asking a few days ago.

Did Nintendo purposely stick to 3-colored background tiles for SMB3 just for the Mario-behind-scenery trick in World 1 Stage 3. They could've used black as the transparency color because everything was outlined in black in SMB3.

by on (#78828)
Seems logical to me.

by on (#78843)
I think there were a few other levels atleast where he goes behind the background. It's been so long though I can't remember it that well.

by on (#78846)
I know that you can go behind the scenes in 1-1 and 1-3. I thought you could do it in 4-6 as well, but now that I review the map there does not appear to be any white boxes to duck on.

I could have sworn there was at least one other level in a later world that you could do this in. However only level 1-3 did anything special with it.