spr piexel priority

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

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

spr piexel priority

Post by Anes » Wed Jun 08, 2005 5:05 pm

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: 1849
Joined: Wed Nov 10, 2004 6:47 pm

Post by Disch » Wed Jun 08, 2005 5:20 pm

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: 604
Joined: Tue Dec 21, 2004 8:35 pm
Location: Argentina
Contact:

Post by Anes » Thu Jun 09, 2005 2:39 pm

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: 1492
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Post by Quietust » Thu Jun 09, 2005 2:45 pm

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: 3190
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Post by Zepper » Thu Jun 09, 2005 4:58 pm

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 » Fri Jun 10, 2005 3:34 am

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 » Fri Jun 10, 2005 5:16 pm

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: 7766
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Post by Bregalad » Sat Jun 11, 2005 9:06 am

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.
Life is complex: it has both real and imaginary components.

User avatar
Quietust
Posts: 1492
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Post by Quietust » Sat Jun 11, 2005 11:13 am

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