Why only 52 colors instead of 256?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Why only 52 colors instead of 256?

Post by DRW »

On the NES, each palette entry of the 2 x 4 on-screen palettes takes one byte, i.e. each palette entry can have a value of 0-255.

So, is there a technical reason why the total number of colors on the NES is only 64 (52 + a few black entries) instead of 256?

I would understand it if the palettes occupied only 24 bytes (6 bits for each of the 2 x 4 x 4 entries). But they take the full 32 bytes (8 bits for each of the 2 x 4 x 4 entries).
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Why only 52 colors instead of 256?

Post by calima »

Money.
User avatar
Bregalad
Posts: 8055
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Why only 52 colors instead of 256?

Post by Bregalad »

I'm sorry but those kinds of questions, such as "why are nametables 32x32 tiles", "why are tiles 8x8 pixels", "why is the screen resolution 256x240", or "why is there only 8 sprites per line", "why isn't the A15 adress line passed to the cartridge edge", "why the square channels contains an almost useless length counter feature", etc... have already been asked over and over and there's no answer. This is just how Nintendo designed the console. Only Nintendo knows. Asking here is irrelevant. Your quesiton is unanswerable for us.
User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Re: Why only 52 colors instead of 256?

Post by DRW »

Those questions are not analoguous since I'm not asking for arbitrary design decisions.
(For example, I didn't ask why the last few colors are filled with black instead of real values.)

My question was basically:

Is the color spectrum of the NES a collection of 256 colors where 204 colors are simply chosen to be black.
I.e. they could have added more colors without changing anything else since the slots already exist, they just chose not to fill them with meaningful values.

Or is there a technical reason that there are only 64 colors?
I.e. the PPU value might be one byte, but when it gets converted to the actual color, the NES reads from a six-bits-per-entry table, so adding new colors would have changed the overall logic.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
AWJ
Posts: 433
Joined: Mon Nov 10, 2008 3:09 pm

Re: Why only 52 colors instead of 256?

Post by AWJ »

DRW wrote:On the NES, each palette entry of the 2 x 4 on-screen palettes takes one byte, i.e. each palette entry can have a value of 0-255.
No, they can't. The PPU's internal palette RAM is only six bits wide. When you write to it, the upper bits are simply discarded--you can verify this by reading it back via $2007.

As for why the palette isn't packed 4 entries in 3 bytes like you suggest, that would have had more drawbacks than benefits. Software would have to write very slightly less data in vblank to update the full palette, but updating individual colors, or doing arithmetic on palette entries for fade-outs, etc., would have become significantly more difficult with bit-packed entries.

And as for why the NES didn't support more than 4 levels of luma, I guess that would have made the DAC take up more PPU die space than the engineers could spare. The Atari TIAs (video chips in the 2600, 5200, 7800, and the 8-bit computers) had 3 or 4 bits of luma, but they needed external DACs--the video signals coming out of the chip were digital.
Rahsennor
Posts: 479
Joined: Thu Aug 20, 2015 3:09 am

Re: Why only 52 colors instead of 256?

Post by Rahsennor »

The PPU only stores 6 bits per entry because that's all it can use. They don't simply index a table like you assume, because such a table would be far too big for the technology of the time. Instead it has a convoluted and actually rather clever chain of logic to generate the entire image using a single square wave. The square wave sequencer has 12 steps, allowing it to be offset in 12 phases, and there are four sets of levels for the low and high parts of the wave. But that doesn't include black and white, so there is logic to switch the square wave off and generate a constant signal, either the high level or the low level.

That gives you 14×4 = 56 different possible combinations, though since the level table has to pull double duty not all of them are very different.
User avatar
Bregalad
Posts: 8055
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Re: Why only 52 colors instead of 256?

Post by Bregalad »

DRW wrote:Those questions are not analoguous since I'm not asking for arbitrary design decisions.
Yes, you are indeed asking for arbitrary design desicion. The 56 palette is part of the console's design.
Is the color spectrum of the NES a collection of 256 colors where 204 colors are simply chosen to be black.
No.
I.e. they could have added more colors without changing anything else since the slots already exist, they just chose not to fill them with meaningful values.
Yes they could have added more colours, but for some reason they didn't.
Or is there a technical reason that there are only 64 colors?
Yes, only 6 bits of memory are used. They could still have used more colours with 6 bits, for example having 15 hues instead of only 12, but for some reason they didn't.
User avatar
Dwedit
Posts: 4921
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Re: Why only 52 colors instead of 256?

Post by Dwedit »

After reading about how the NES generates those colors, you never think about the NES palette the same way again.

It's a square wave between a bright gray level and a darker gray level, and it can be shifted to 12 different phases, left as light gray, or left as dark gray.
They picked up to 4 levels of brightness for the palette. But yes, they could have used more.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Sumez
Posts: 919
Joined: Thu Sep 15, 2016 6:29 am
Location: Denmark (PAL)

Re: Why only 52 colors instead of 256?

Post by Sumez »

Bregalad wrote:there's no answer. This is just how Nintendo designed the console. Only Nintendo knows. Asking here is irrelevant. Your quesiton is unanswerable for us.
That in itself would be an answer, if it were true. I would imagine there's a technical (/financial) limitation behind the descision. I'm certain that the NES would have had a 256 color palette if it doesn't make the PPU more expensive produce.
User avatar
Fisher
Posts: 1249
Joined: Sat Jul 04, 2015 9:58 am
Location: -29.794229 -55.795374

Re: Why only 52 colors instead of 256?

Post by Fisher »

Bregalad wrote:"why isn't the A15 adress line passed to the cartridge edge"
Well, I found a clone that has it on the cartridge edge: :lol:
Phantom connector.jpg
I just don't know for what it would be useful :roll: , unless you want to make something that works only with this clone and not with the real thing... :D
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Why only 52 colors instead of 256?

Post by tepples »

It was die size cost. Name a way it could have been extended to 256 colors, and someone might explain how that would have been more expensive. In addition, a 3:3:2-bit (rrrgggbb) format wouldn't have produced pure grays.
User avatar
pubby
Posts: 583
Joined: Thu Mar 31, 2016 11:15 am

Re: Why only 52 colors instead of 256?

Post by pubby »

When I finish my NES time machine I'm going to go back to the 80s and tell Mr. Nintendo to fire the guy implementing color emphasis bits. Then I'm going to tell him to hire a palette engineer that knows all 256 colors, including the exotic yellow one.
User avatar
Gilbert
Posts: 564
Joined: Sun Dec 12, 2010 10:27 pm
Location: Hong Kong
Contact:

Re: Why only 52 colors instead of 256?

Post by Gilbert »

Or, better, fire the one who decided 4 sub-palettes were already enough for the Mega Drive, backgrounds and sprites combined.
Though as explained in the Famicom's case here, there were many reasonable... er... reasons to this, Sega seemed to be quite bad in this area. The Game Gear is another odd ball, as it has a HUGE master palette despite having only 2 sub-palettes (though some games did change colours mid-screen), and this is more or less the only improvement over the original SMS (and the reduced resolution, if you call this an improvement).

What I really want to do with time traveling though, is to let the PC Engine have a larger master palette (4096 colours is enough). This can certainly make its arcade and PC conversions much more accurate. And AFAIK this is relatively "easy" to pull off too. You only need to change the VCE and keep the original VDC, which was already done by some arcade games using the same VDC and probably the PC-FX, which I'm not very familiar with its specs, but I think its VDC was just a minor upgrade from the PCE one.
lidnariq
Posts: 11429
Joined: Sun Apr 13, 2008 11:12 am

Re: Why only 52 colors instead of 256?

Post by lidnariq »

The DAC inside the 2C02 has 10 taps; one could certainly specify palettes in a much more expanded manner where you directly specified which tap for the high and low phases instead of 2 bits specifying some pair. This would afford you 12·10·10=1200 different nominal colors, although a huge number of them would be duplicates (tons of greys and every color would be present twice), and lots of them would be completely out of gamut, too. (After all, these taps include the sync voltages)

The amount of die area needed to hold the palette would double, and addressing it (since it's now more than 8 bits) would be more complicated.

Furthermore, the location of the individual bits within the 2C02's palette RAM initially appears a little oddly interleaved, so even though there is enough area to hold the extra bits of RAM to hold a bigger RAM, there isn't enough width:

Code: Select all

3f00&1 3f04&1 3f08&1 3f0c&1 3f00&2 3f04&2 3f08&2 3f0c&2 3f00&4 ... 3f0c&20
3f12&1 ...
3f02&1
3f11&1
3f01&1
3f13&1
3f03&1  remainder omitted for clarity
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Why only 52 colors instead of 256?

Post by tepples »

A more practical refinement of that idea: For one additional bit per color, the PPU could have had a set of desaturated colors.

Of the 7 taps actually used for picture, $0D and $1D are very close, $2D and $00 are kind of close, and $3D and $10 are very close. So this leaves us four easy-to-distinguish taps: $1D, $00, $10, and $20.

Code: Select all

bbaa xppp
||||  +++- Phase (0 to 5) in twelfths of a color subcarrier
||||       Corresponds to a pair of opposing hues
||++------ In-phase tap (7.5, 40, 70, or 100 IRE)
++-------- Out-of-phase tap

All the grays $0x, $5x, $Ax, and $Fx would be duplicates.

This would produce 12 sequences of two distinct taps times 6 hue pairs plus four grays = 76 colors without adding much complexity to the signal generator.
Post Reply