This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

NES palette

NES palette
by on (#174798)
Hello NES developers :D

I have a question related to NES palette colours

https://www.google.com.eg/search?hl=ar& ... i6nFo8M%3A

I know that each colour is of 6 bits ( 2 bits -> red , 2 bits -> green and 2 bits-> blue)

I want to write a software concerning the pattern tables, attributes ...etc , my question is how the 24 bits of the color codes (the rgb we use ) are mapped to only 6 bits ?

I mean if I have the 6 bits of the NES colours , how to know their 24 bit-equivalent colour ? what operations to do ?

Thank's in advance
Re: NES palette
by on (#174799)
Muhammad_R4 wrote:
I know that each colour is of 6 bits ( 2 bits -> red , 2 bits -> green and 2 bits-> blue)

The NES colours are not made of RGB components. It's more like 2 bits for intensity, and 4 bits for hue.

Muhammad_R4 wrote:
I mean if I have the 6 bits of the NES colours , how to know their 24 bit-equivalent colour ? what operations to do ?

Most emulators just use a palette table to map the NES colours to RGB colours for the output system.

Here's an example generator to make that kind of palette: http://bisqwit.iki.fi/utils/nespalette.php

More accurate emulation will try to simulate the effects of NTSC signal generation, which are a lot more complicated than just mapping to a single RGB colour.

Example: http://slack.net/~ant/libs/ntsc.html
Re: NES palette
by on (#174800)
Quote:
Most emulators just use a palette table to map the NES colours to RGB colours for the output system.


that's good, now how they map the 2 and the 4 bits to an RGB 24 bit color code ?
Re: NES palette
by on (#174802)
They don't map to RGB color codes at all.
They generate a square wave of NTSC signal that goes up and down between a high and low voltage level, and the phase of the wave determines the hue.
There's an article for this on the Nesdev Wiki, which has more information than you ever wanted to know about how NTSC TVs work.

A couple of random illustrations from the wiki:
Code:
 1.0               +--+
 0.9               |  |
 0.8               |  |
 0.7            +--+  | +-+ +-+
 0.6            |     | | | | |
 0.5            |     | | | | |
 0.4         +--+     | | | | |
 0.3      +--+        | | | | |
 0.2      |           | | | | |
 0.1      |           | | | | |
 0.0 . +--+ . . . . . +-+ +-+ + . .
-0.1 --+
     0D 0F 2D 00 10 30   11

Image

So if you want to do all the complicated calculations of converting to the YIQ color space, then to YUV, then finally getting RGB out of that, that's fine. Or you could build of someone else's work. Nintendulator has a very nice NES palette.
If you want to generate NTSC composite video directly, you can make the same square wave patterns that the NES does.
Re: NES palette
by on (#174806)
Muhammad_R4 wrote:
I know that each colour is of 6 bits ( 2 bits -> red , 2 bits -> green and 2 bits-> blue)

That's actually the Master System palette.

The NES palette is notoriously hard to convert to RGB, because there are a lot of steps in between, and the final result never pleases everyone, because each person had a different TV that rendered the colors differently, so they have different memories of what the NES palette looks like.

Other consoles also suffered from all the processing that happened to the colors until they reached people's eyes, but since many of them used RGB internally, it's hard to argue with that...
Re: NES palette
by on (#174807)
I took the liberty of running Bisqwit's tool to make something that looks fairly realistic.

Image
Default parameters were used, except saturation at 1.2 and gamma at 2.0


The RGB PPUs (2C03, 2C04, and 2C05) have three 3-bit DACs and an internal lookup table from 6-bit palette values to 3-bit-per-channel RGB. These are also ripped, and they can be used without modification if you want a Genesis game's palette to match that of a PlayChoice, Famicom Titler, or the "garish" mode of the NESRGB.