Three color-related questions

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

JohnJohn
Warned
Posts: 42
Joined: Fri Jan 08, 2010 3:05 am

Three color-related questions

Post by JohnJohn » Tue Jan 12, 2010 12:44 am

I've got three color-related questions about the NES and I think, since you program for the NES, you maybe can answer them.

Question 1:
Please have a look at these two pictures:
Image Image
They were made with FCE Ultra. The second image is the one where the option "NTSC Color Emulation" is enabled. I live in Germany, so I have PAL. And on my TV screen, "Super Mario Bros." looks like the first image. So far so good. The strange thing now is: Once, I asked Americans which image comes closer to the game on a real NES and all said that it's the first one. Same with this American commercial where the "Super Mario Bros." background clearly looks blue and not purple.
So, my question: What's the deal with that NTSC color emulation? Obviously, in reality, the game on a real NES looks like the first picture, no matter if it's shown on a PAL or an NTSC screen. So, why is this specific "NTSC palette" actually there? And where does it come from?

Question 2:
O.k., this is basically the NES palette:
Image
Now, when I make a screenshot with FCE Ultra and inspect its color palette (256 color PNG), then it looks like that:
Image
The NES palette is in the upper part of the lower half. But I always wondered what the lower colors (the last four rows) are for. Then I found out:
Image
"Dragon's Lair" uses them.
My question: How is that done on a real NES? How can "Dragon's Lair" use other colors than the ones of the regular NES palette? I mean, with an emulator, that's no problem. But how did they achieve that on a real NES?
Additional question: Does anybody know what these colors at the top of the screenshoot palette (light yellow, gray, red, green and blue) are good for? Are they just for any FCE Ultra's on-screen information or are they used in games?

Question 3:
Again the NES palette:
Image
These two gray colors on the right side: Were they ever used in a commercial game?
Once, I did the following: I shot a bunch of screenshots of different games and then I looked if there is a color that was never used. I found out that all colors are in use in one game or another. It took me a while, but I finally found an appearance of every single color from the palette. Except for the two gray colors on the right. Besides being almost indistinguishable from the other two grays:
Image
they are never used. Whenever a game uses gray, it always takes the two left ones, never the right ones. So, do you know of a game that actually uses them?

User avatar
tokumaru
Posts: 11744
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Three color-related questions

Post by tokumaru » Tue Jan 12, 2010 2:21 am

Before I even say anything, let me just tell you that FCE Ultra is a pretty old emulator already, and a lot of stuff has been discovered/invented after it's been abandoned, so it's not the best one to use as reference.
JohnJohn wrote:So, my question: What's the deal with that NTSC color emulation?
A lot of consoles generate RGB video, and since computers also use that color model it's easy to get the colors right. The NES, however, uses a hue based scheme that's hard to get right in RGB. A few years back people noticed a certain logic in the palette and made palette simulators, but they obviously didn't get it right, as we can see in the screenshot.

More recently, Blargg made a great breakthrough regarding NES video: he developed a library that actually simulates the generation of the analog video signal the console does, so the result is pretty damn accurate, not only the color, but everything else looks terribly similar to a what you see on a real TV. If you haven't seen it already, you can see it in Nestopia (you have to activate it), a very good and up to date emulator. A few other emulators also have it.

But even then, each TV is different, and is calibrated differently (When you go to a TV store and there are a bunch of them lined up showing the same video you can easily see that the colors vary a lot from one TV to the other - much less with HDTVs and digital video, but still), and PC monitors are also all calibrated differently, so you can never have an emulator output colors that are 100% right, because there isn't such a thing.
How is that done on a real NES?
The NES has a configuration called "color emphasis". There are 3 bits you can mess with that shift the whole palette towards red, green or blue, or combinations of those colors. But in reality emphasizing one color is actually de-emphasizing the other 2, so when you try to emphasize all 3 at the same time the whole palette becomes darker. I don't remember if FCEU emulates the individual emphasized colors, but since these palettes are not in the image you posted I guess it doesn't.
Are they just for any FCE Ultra's on-screen information
Yup. It's for texts like "state saved", "slot 0 selected", things like that.
These two gray colors on the right side: Were they ever used in a commercial game?
I can't say for sure that they weren't, but they were avoided (Nintendo probably advised developers against using them) because not all versions of the PPU had those colors, a few special versions of the PPU that output RGB video (never used in regular NES consoles) had just black there, so if games used those grays they'd look wrong in systems that used this different PPU.

EDIT: I just checked FCEUXD, and it does emulate the emphasis bits. Here's a screen from Noah's Ark:

Image

At the bottom of the screen, blue emphasis is used along with monochrome mode to simulate the water.

Here's the palette from that image:

Image

The bottom palette is the one shifted towards blue. I don't know why there are 2 copies of the basic palette at the top.

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

Post by tepples » Tue Jan 12, 2010 5:02 am

A lot of people who don't emulate remember the NES through a filter of 1. nostalgia and 2. a miscalibrated television.

User avatar
Dwedit
Posts: 4328
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit » Tue Jan 12, 2010 7:52 am

If you use Nesticle to take screenshots, you will get the original color indexes and current NES palette in the image file.
Image Image
Almost all emulators do not take screenshots that way, since the NES can have the palette reassigned multiple times within a frame. Nesticle doesn't even emulate that. But it is the only emulator that takes screenshots which preserve the original color indexes, despite its horrible NES palette.


Three Stooges uses the extra gray colors for the title screen.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!

Drag
Posts: 1314
Joined: Mon Sep 27, 2004 2:57 pm
Contact:

Post by Drag » Tue Jan 12, 2010 7:50 pm

The NES generates its palette by generating a wave for each pixel, which NTSC televisions interpret as hue (from phase), luminance (from a DC offset), and saturation (from amplitude of the wave).

As I understand it, the NES creates this wave by alternating between the two sets of grays.

For example, to create the color $11, the nes outputs xxxxxxyyyyyy, where x is the gray at $01, and y is the gray at $d1. This makes a square wave.

xxxxxxyyyyyy is color $1x, yxxxxxxyyyyy is $2x (or is it $cx?), yyxxxxxxyyyy being the next color after that, etc etc.

Those grays aren't waves though, they're just plain flat voltages. However, by alternating between those two flat voltages, that's how the wave is created, and like I said, $0x is one peak, and $dx is the other peak.

ccovell
Posts: 1014
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Post by ccovell » Wed Jan 13, 2010 4:46 pm

Totally Rad! / Magic John also uses one of those "illegal" greys for the floor of its first level.

JohnJohn
Warned
Posts: 42
Joined: Fri Jan 08, 2010 3:05 am

Post by JohnJohn » Sun Jan 17, 2010 11:42 am

Thanks for the answers. I really learned something new.
tokumaru wrote:A few years back people noticed a certain logic in the palette and made palette simulators, but they obviously didn't get it right, as we can see in the screenshot.
[...]
But even then, each TV is different, and is calibrated differently (When you go to a TV store and there are a bunch of them lined up showing the same video you can easily see that the colors vary a lot from one TV to the other - much less with HDTVs and digital video, but still), and PC monitors are also all calibrated differently, so you can never have an emulator output colors that are 100% right, because there isn't such a thing.
Well, it's clear that all monitors are different and that there are no concrete definite absolute values for the NES colors. But to me that's more an issue related to customizable palettes and setting the tint. But why are there two different default palettes? The so-called NTSC palette could be an alternative loadable palette. But it isn't. It's a completely distinct feature to enable the "NTSC palette", independently from loading palette files. So why is this the case? If the NTSC palette is supposed to be more accurate (which it isn't) why isn't it the default? The emulators all have a default palette. Then they have the ability to load custom palettes. Why is there that completely different third option of enabling an "NTSC palette"?

The stuff with being able to darken the colors was new to me. But it's not done very often in games, is it?
tokumaru wrote:I can't say for sure that they weren't, but they were avoided (Nintendo probably advised developers against using them) because not all versions of the PPU had those colors
Why did they even include them? They could have left them black.
tokumaru wrote:Here's the palette from that image:
[...]
The bottom palette is the one shifted towards blue. I don't know why there are 2 copies of the basic palette at the top.
With my version of FCE Ultra, the palette is not there two times. There is the regular palette, the blue-shifted palette and the darker palette from my post above. That darker palette is a constant in the screenshots even if it's not used while individual shifts are only included when really used.
Dwedit wrote:Three Stooges uses the extra gray colors for the title screen.
Right, but only one of them: The dark one. The light one is still the normal version.
ccovell wrote:Totally Rad! / Magic John also uses one of those "illegal" greys for the floor of its first level.
Yes, the light one. Now I have seen every single color used in one game or another. Except for...Well, let's have a look at the palette again:
Image
As you can see, on the right side are the two not-to-be-used-but-still-used-now-and-then gray colors and two times black. But now look at the palette when "NTSC color emulation" is turned on:
Image
Now there is a third, even darker gray that's not visible when the default palette is turned on. Is this gray used anywhere?

By the way, do you have any idea why they have two whites instead of white and another gray?

ccovell
Posts: 1014
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Post by ccovell » Sun Jan 17, 2010 5:22 pm

JohnJohn wrote:Now there is a third, even darker gray that's not visible when the default palette is turned on. Is this gray used anywhere?

By the way, do you have any idea why they have two whites instead of white and another gray?
Check out this post by Kevtris. It explains how the hues of the NES are generated by cycling the voltage between the two extremes (colours x0 and xD). Kev's doc was eye-opening, and explained a few things that I'd always suspected.

Anyway, the designers of the NES/FC PPU had to step up the luminance and saturation together in only 6 steps (black, white, plus 4 intermediary levels for the hues) so they chose those x0 and xD levels for this purpose (even if it means two repeated whites.)

User avatar
tokumaru
Posts: 11744
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru » Sun Jan 17, 2010 8:32 pm

JohnJohn wrote:Why is there that completely different third option of enabling an "NTSC palette"?
I guess that, at one point in time, emulator authors were excited about the fact that there was some logic to the NES palette, and that an algorithm that approximated it was available.

I don't care too much about palettes nowadays, because even if each individual color is 100% correct, each color behaves differently depending on the surrounding colors, and even on the scrolling. The only way to faithfully predict what a real NES would show is using blargg's NTSC filter. And even then I end up changing a couple of colors in my programs after seeing the results on my console and TV.
The stuff with being able to darken the colors was new to me. But it's not done very often in games, is it?
No, it's not very common. I'm not aware of many games that used the color emphasis bits, individually or combined. There are a few, maybe someone feels like listing the ones they know.
tokumaru wrote:Why did they even include them? They could have left them black.
I don't have an answer for that. I don't know which type of PPU came first, the one with the grays or the one without them, but maybe there was some hardware constraint that prevented them from reproducing the same colors on that different PPU, or maybe the grays aren't even intentional, being just a side effect of picking those specific color indexes. Well, like I said, I don't have an answer for that, I simply avoid those colors.
Now there is a third, even darker gray that's not visible when the default palette is turned on. Is this gray used anywhere?
I don't know if that gray even exists or if it's just a mistake made by the palette generator, but since it's in the "illegal" column, it probably wasn't used and you shouldn't use it either. Some of these illegal colors can even confuse some televisions, which interpret them as syncing signals and such instead of as colors.
By the way, do you have any idea why they have two whites instead of white and another gray?
I wish there was another gray. I wish the NES palette would make more sense, but it is what it is. In my recent programs I have rearranged the palette a bit (using look-up tables), to make it more friendly to my fading routines.

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

Post by Bregalad » Mon Jan 18, 2010 3:05 am

About color $0d, I tried the "8 sprites per line" demo on my PowerPak, and my TV was always "resetting" the image. (I could try to film that with my cellphone if someone request it - but I doubt the result would be high quality :wink: )
Guess what ? It uses color $0d for the BG. So I can confirm this color should be avoided. $xD should be avoided as well, because they will become $0d as your palette fades out.
The stuff with being able to darken the colors was new to me. But it's not done very often in games, is it?
Some games (Just Breed, Felix the Cat) always darken all 3 colors, Final Fantasy 1 & 2 darken random colors when you enter in battle (which looks quite good IMO), and of course Noas Ark does it for the water. I don't remember any other games using that - they are especially usefull in combination with the grayscale bit because normal color don't beed much.


I don't care too much about palettes nowadays, because even if each individual color is 100% correct, each color behaves differently depending on the surrounding colors, and even on the scrolling. The only way to faithfully predict what a real NES would show is using blargg's NTSC filter. And even then I end up changing a couple of colors in my programs after seeing the results on my console and TV.
This is true. You should also understand that different human eyes sees colors slightly differently, and that a colors can appear different to the brain depending on the colors arround it.
For example, light yellow will look light yellow if surrounded by white, but will look white if surrounded by black - there is a million of other examples.

Tokumaru is right about scrolling to affect colors. This can be seen in a few places - if one pixel in the background is significantly different than the ones surrounding it it will seem to flicker as it scroll, because of the color filter on the TV screen (can be seen on the eyes on the statues at the begining of Castelvania) - maybe this is a PAL only trick or somehting specific to my TV tough.
Life is complex: it has both real and imaginary components.

CKY-2K/Clay Man
Posts: 215
Joined: Sun Apr 01, 2007 2:10 pm

Post by CKY-2K/Clay Man » Mon Jan 18, 2010 7:38 am

people say PAL is better than NTSC? Why is that?
Image
Here to at least get an idea of how the NES works. I mean I know alot of the basic things, but this place'll help me grasp more how NES functions.
Major respect to NES developers.

lidnariq
Posts: 9492
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Post by lidnariq » Mon Jan 18, 2010 8:45 am

CKY-2K/Clay Man wrote:people say PAL is better than NTSC? Why is that?
Forever and ever and ever and ever ago, we had trouble producing clock sources that would reliably maintain the exact frequency needed to recover color from the combined signal that's sent over the air. This frequency drift would cause the hue to shift as you went from left to right on the screen.

The PAL workaround (after having seen/predicted the problems with NTSC) was to make every other line's color information backwards (hence Phase Alternating Line) so that, even though they couldn't fix the clock issue, they could at least guarantee the symptom would be losing saturation of color rather than incorrect hue.

Nowadays? Technology made up for that weakness.

Specifically in the case of the NES, a PAL machine gives you an extra 70 scanlines' time to redraw the screen, which is nice.

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

Post by tepples » Mon Jan 18, 2010 9:18 am

lidnariq wrote:Specifically in the case of the NES, a PAL machine gives you an extra 70 scanlines' time to redraw the screen, which is nice.
Unless it's a PAL/M machine from Brazil, which is more like an NTSC machine because it uses a daughterboard to convert NTSC to PAL/M.

The disadvantage of regular PAL is flicker. Lots of flicker. I can't see flicker at 60 Hz but I can see it at 50 Hz. The other disadvantage, in the case of the NES, is more visible artifacts at the top and bottom in certain mirroring modes.

User avatar
tokumaru
Posts: 11744
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru » Mon Jan 18, 2010 1:51 pm

tepples wrote:Unless it's a PAL/M machine from Brazil, which is more like an NTSC machine because it uses a daughterboard to convert NTSC to PAL/M.
That's true. From a programmer's point of view, a PAL-M console is just like an NTSC console.
The disadvantage of regular PAL is flicker. Lots of flicker. I can't see flicker at 60 Hz but I can see it at 50 Hz. The other disadvantage, in the case of the NES, is more visible artifacts at the top and bottom in certain mirroring modes.
Also true. The extra VBlank time is nice, but the problems mentioned above are just too annoying. Also, making use of the extra VBlank time breaks compatibility with NTSC consoles, meaning that these "NES programs" are not compatible with a great portion of NES consoles.

lidnariq
Posts: 9492
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Post by lidnariq » Mon Jan 18, 2010 9:26 pm

tepples wrote:The disadvantage of regular PAL is flicker. Lots of flicker. I can't see flicker at 60 Hz but I can see it at 50 Hz.
I've convinced myself (but I have no idea if this is right) that the tremendously huger market for NTSC sets meant that only CRTs with phosphors meant to be refreshed at 60Hz were findable -- and Europe simply wasn't a big enough market to legitimize research into finding good slower green and blue phosphors.

Post Reply