spr piexel priority

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
Anes
Posts: 702
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

spr piexel priority

Post by Anes »

im have unclear how sprite pixel priority and colour 0 is managed.

I change my spr render engine to a pixel one, i mean i apply what brad taylor says in his 2C02 reference, i think its the best way, cos its accurate as possible, but my unclear question is that he says that multiplexer do the following to choose if a spr pixel or bk pixel is drawn:

Code: Select all

if ((ObjPrioriy == FORGROUND) || (PFPixel == Transparent)) && (ObjPixel != Transparent))
PrintObjPixel()
else
PrintBKPixel
well this method works in some games but other gives me sprite errors, like some sprites dont display well, the first sprite that i let entry in the sprtemp mem is sprite 0 and his flag, of course, (if it its in range, of course again), and i count to 63 down to 0 to determine the in-range sprite, but...

what about colour 0, when its drawn? some docs says that if bk pixel is xparent and sprite pixel is xparent it uses color 0. Am i wrong?
ANes
User avatar
Disch
Posts: 1848
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch »

Color 0 is transparent for both BG and sprites.

The idea is simple:

If both sprite and BG pixels are transparent, output background color (ppu$3F00 when rendering is enabled). Otherwise:

If Sprite is in foreground:
- if sprite pixel is transparent (0), output BG pixel
- else, output sprite pixel

Else -- sprite is in backgroud:
- if BG pixel is transparent, output sprite pixel
- else, output BG pixel
User avatar
Anes
Posts: 702
Joined: Tue Dec 21, 2004 8:35 pm
Location: Mendoza, Argentina

Post by Anes »

that worked disch.

Now i have problems when 2 or more sprites overllaps them self. I mean priority is well but when sprites are in the same scanline there are flickering as if one sprite fights against other.
Something that can help me?

thanks.
ANes
User avatar
Quietust
Posts: 1920
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Post by Quietust »

If you have two nontransparent sprite pixels at the same location, the one belonging to the lowest numbered sprite wins. Always. Even if it's behind the background (in which case you will see the background instead of *either* of the sprites).
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper »

In other words - you can go from sprite 0 up to 7. If there's a sprite pixel and priority is high, then you don't plot it.
User avatar
hap
Posts: 355
Joined: Thu Mar 24, 2005 3:17 pm
Contact:

Post by hap »

There's a game where you can test that behaviour. I think it's one of the Megaman games, where you have to jump over the powerbar. Sorry I don't remember the details, but I'm sure someone else does.
Muchaserres
Posts: 96
Joined: Sat Nov 13, 2004 6:25 am

Post by Muchaserres »

hap wrote:There's a game where you can test that behaviour. I think it's one of the Megaman games, where you have to jump over the powerbar. Sorry I don't remember the details, but I'm sure someone else does.
Megaman 2, if I'm not wrong.. You can see it easily at the begining of Airman's stage.
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Post by Bregalad »

Megaman 2, if I'm not wrong.. You can see it easily at the begining of Airman's stage.
That's what's written into a PPU doc I've read, but It's pretty frustrating to test because megaman and the bar will alternate their priorities (sprite cyclinge).
The better way to check this is begin a Castlevania game. When you enter in the castle, if Simon passes *trough* the door, the sprite priority is okay. If he passes *in front of* the door, you're not emulating this right.
Useless, lumbering half-wits don't scare us.
User avatar
Quietust
Posts: 1920
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Post by Quietust »

An even easier test for this is Super Mario Bros. 3, which uses such sprite masking to make it appear that items come out of [?] bricks and that piranha plants come out of pipes - without proper sprite masking, they will appear in front instead.
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
Post Reply