Question concerning bg color and transparency

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Question concerning bg color and transparency

Post by GradualGames »

Is there ever any use for every fourth palette entry since they are treated as transparent? Are these ever used as "codes" when doing sprite collision, etc.?

Regards,
-Zom
NES Noob
User avatar
Disch
Posts: 1848
Joined: Wed Nov 10, 2004 6:47 pm

Re: Question concerning bg color and transparency

Post by Disch »

ZomCoder wrote:Is there ever any use for every fourth palette entry since they are treated as transparent?
No, they're always transparent. The only way they can be visible on screen is if you exploit the palette trick when the PPU is off. During normal rendering they will never be used.

EDIT - except for $3Fx0, which of course is used as the background color.
Are these ever used as "codes" when doing sprite collision, etc.?
No.
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

Every fourth palette entry except the first exists mainly because it's simpler in hardware to have them than not. Tiles have two bits per pixel, which only specify four possible values. The zero value is transparent, while the other three are combined with attribute bits to form a palette index. Thus, the fourth palette entries can't even be specified by anything. Behind everything is a solid background of palette entry zero, which shows through anything transparent.

So, the fourth palette entries aren't "treated as transparent"; it's that they can't be specified at all (ignoring disabling PPU rendering). Since the attributes aren't even examined when a tile's pixel is transparent, all transparent pixels are alike.
Post Reply