It is currently Sat Oct 21, 2017 8:52 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: NES palette
PostPosted: Tue Jul 05, 2016 9:18 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
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


Top
 Profile  
 
 Post subject: Re: NES palette
PostPosted: Tue Jul 05, 2016 9:34 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5728
Location: Canada
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


Top
 Profile  
 
 Post subject: Re: NES palette
PostPosted: Tue Jul 05, 2016 9:39 am 
Offline

Joined: Sat Jun 25, 2016 5:33 am
Posts: 66
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 ?


Top
 Profile  
 
 Post subject: Re: NES palette
PostPosted: Tue Jul 05, 2016 10:06 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3943
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.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
 Post subject: Re: NES palette
PostPosted: Tue Jul 05, 2016 10:18 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10065
Location: Rio de Janeiro - Brazil
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...


Top
 Profile  
 
 Post subject: Re: NES palette
PostPosted: Tue Jul 05, 2016 10:21 am 
Online

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19113
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: DragonDePlatino and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group