PPU Questions

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

tepples
Posts: 21883
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Sun Feb 19, 2006 9:30 am

Palette entries actually range from 0 to 63. The unused values aren't bunched up at the end.

dxprog
Posts: 34
Joined: Thu Nov 17, 2005 2:44 pm

Post by dxprog » Mon Feb 20, 2006 1:12 pm

Bunched up?

tepples
Posts: 21883
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Mon Feb 20, 2006 1:17 pm

The NES color values normally regarded as unused are $0D, $0E, $1D-$20, $2D-$2F, and $3D-$3F. $0D is the sync level, which should be avoided so as not to confuse TVs. $1D, $2D, and $3D are various nearly-duplicate gray levels that don't show up on the PlayChoice PPU, which commercial games tended not to use. The $xE and $xF values other than $0F are duplicates of $0F (canonical black). $20 is a duplicate of $30 (canonical white).

You may have guessed that the unused values were together at the end ($34-$3F), which is what I meant by "bunched up".

Celius
Posts: 2157
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Post by Celius » Mon Feb 20, 2006 1:24 pm

dxprog wrote: New question, though. What do you do when a palette entry is greater than 51?
Greater than 51? You don't do anything special when a pallete entry is greater than 51. Are you refferring to $51? Or 51 in decimal. If you are reffering to hex, I think it's like this:

0 - 3F = color values
40 - 7F = mirror of 0 - 3F
80 - BF = mirror of 0 - 3F
C0 - FF = mirror of 0 - 3F

So if you store 40 in PPU address $3F00, then it will read as color $0, because 40 - 7F is a miror of 00 - 3F. So color $51 would be color $11. I suppose it's not really like a mirror, it's like a color mirror. Do you understand what I mean?

Edit: If tepples answered your question correctly, then I was way off on what you were asking. But yeah, I suggest you use $3F for black. It's like the official black color. Actually, a lot of people use $0F, but it bothers me to use that, because black seems like it should be at the end of the color selection, so I use $3F.

dxprog
Posts: 34
Joined: Thu Nov 17, 2005 2:44 pm

Post by dxprog » Mon Feb 20, 2006 10:54 pm

Yeah, that was 51 decimal (I work primarily in VBasic, sue me :-P).

Celius
Posts: 2157
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Post by Celius » Mon Feb 20, 2006 11:06 pm

Are your questions on that matter answered?

User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg » Mon Feb 20, 2006 11:44 pm

A good convention is to write decimal numbers without a designator: 789, hexadecimal numbers as 0xBEEF, 0BEEFh, or $BEEF. If you need to write a lot of hexadecimal numbers, then announce a temporary "change of default base" to hex.

If we had easy subscripts here, we'd just write

Code: Select all

789
   10

BEEF
    16

dxprog
Posts: 34
Joined: Thu Nov 17, 2005 2:44 pm

Post by dxprog » Tue Feb 21, 2006 12:23 am

When I'm using hex I usually prefix it with $. And, yeah, my question's answered. Wrap after $3F. Thanks :-)

User avatar
Bregalad
Posts: 7813
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Post by Bregalad » Wed Feb 22, 2006 1:16 pm

$bfff or 0xbfff are both good. BFFFh is confusing to be, because you'll try to still read the final "h" as to be the value, and so hex number like that are hard to read.

Could someone tell me the effect of displaying the color $1d ?
Without using $xd color, the darkest available gray is $00, and it isn't very dark, so the NES basically doesn't allow dark grays at all.
But with the use of $xd colors, is it possible to have a drarker gray than $00 ? Because you'd usually like to have a black border arround sprites, but you won't like haing the black border of sprites mess up with black parts of BG. So having dark-gray border arround sprites would be a good choise, but $00 is way too light.
Life is complex: it has both real and imaginary components.

Celius
Posts: 2157
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Post by Celius » Fri Feb 24, 2006 4:31 pm

Well, the effect of $1D all depends on the TV, or so I understand.

$1D will probably show up as black on most emulators. But on a real NES hooked up to a TV, it may show up as a darker gray, which is good. But you probably don't want to take a risk of putting a game with that color code on it onto a cartridge, then having it show up as some weird pink color, or something. If it does show up as a darker gray, than I say go for it, use it. But I wouldn't want to risk using that, then having it show up as a lame pink on a different TV, or something random like that.

I agree. The grays that the NES provides are total shit. For vincents hair in FFVII NES, I use a dark blue, because if his hair was black, and the background was black, it wouldn't show up, and it'd look really dumb. I'm just saying, you could find some ways around it by using another dark color, but they are like way too light, I agree.

tepples
Posts: 21883
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Fri Feb 24, 2006 9:30 pm

Can you get a decent gray by flickering $08 with $02?

Celius
Posts: 2157
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Post by Celius » Fri Feb 24, 2006 9:42 pm

You mean like changing the pallete values every frame to $02 or $08? That's a really annoying subroutine to do. And constant writes to $2006/$2007 isn't healthy, because you could mess up the scroll if your not careful. I've done something like that where every NMI the pallete updates, and it was not healthy. There were alot of scrolling issues. I don't like that EVERY time you write to $2007 you have to restore the scroll. I suppose it doesn't matter that much though.

If you want to save time, I'm sure you'd want to do as little writes as possible. But I just don't like doing constant writes to $2006/$2007. It bothers me. And that'd look kinda ugly, the constant flickering. I don't know, I'll have to try and see.

EDIT: I forgot to say, flickering $00 and $3F would get you a decent dark gray, as apposed to $02 and $08.

tepples
Posts: 21883
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples » Fri Feb 24, 2006 10:02 pm

Celius wrote:And constant writes to $2006/$2007 isn't healthy, because you could mess up the scroll if your not careful. I've done something like that where every NMI the pallete updates, and it was not healthy. There were alot of scrolling issues. I don't like that EVERY time you write to $2007 you have to restore the scroll.
No, you just have to set the scroll after the last VRAM or palette update of vblank. If you have a scrolling game (not a fixed game such as Donkey Kong or something inspired by Tetris), chances are you're already doing this.

Celius
Posts: 2157
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Post by Celius » Fri Feb 24, 2006 10:51 pm

Oh, I guess I'm just retarded then. I thought it was every write to $2006/$2007. Thanks for the info, though.

User avatar
Bregalad
Posts: 7813
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Post by Bregalad » Sat Feb 25, 2006 3:19 am

On a standard configuration, you'll want to do all your PPU updates through $2006 and $2007 during VBlank, and write proper scroll to $2005 and nametable index to $2000 once it's done.
Things are going weird if you want to do anything midframe.

Yeah, having the color black randomly shows up as pink would be RALLY anoying.
Using blue for black hair really is a good idea. Magus has blue hair in Chrono Trigger, but he actually looks like to have a black hair.
Howver, you won't have all your sprites surrounded with a blue shadow.
Flickering is also risked, as it would show nice on some TVs and ugly on some others.
On my TV, sprite flickering is nearly unnoticeable, and under an emulator on my PC it looks awfull. I think the same goes for color flickering.
Life is complex: it has both real and imaginary components.

Post Reply