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

Three color-related questions

Three color-related questions
by on (#55107)
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?
Re: Three color-related questions
by on (#55108)
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.

Quote:
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.

Quote:
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.

Quote:
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.

by on (#55112)
A lot of people who don't emulate remember the NES through a filter of 1. nostalgia and 2. a miscalibrated television.

by on (#55116)
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.

by on (#55138)
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.

by on (#55172)
Totally Rad! / Magic John also uses one of those "illegal" greys for the floor of its first level.

by on (#55265)
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?

by on (#55278)
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.)

by on (#55285)
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.

Quote:
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.

Quote:
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.

Quote:
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.

by on (#55294)
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.

Quote:
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.

Quote:


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.

by on (#55305)
people say PAL is better than NTSC? Why is that?

by on (#55307)
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.

by on (#55308)
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.

by on (#55328)
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.

Quote:
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.

by on (#55345)
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.

by on (#55350)
Super Spy Hunter used the color de-emphasis bits to darken the screen when you paused the game, and Fantastic Adventures of Dizzy used them to darken the rolled-up part of the scroll on the story screen (this game, along with much of the Codemasters library including the Game Genie, also used color $0D extensively and thus caused many older TVs to malfunction).

Monochrome mode doesn't seem to have been used much at all; the only game I ever played that used it was Isolated Warrior, in order to (very effectively) flash the screen during bomb explosions and boss battles.

Given FCEU's limited palette space, I'm assuming it would be incapable of showing all the various combinations of monochrome and de-emphasis settings on a single screen without an overhaul of the video rendering code. Do any demos even attempt to do this?

by on (#55353)
lidnariq wrote:
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.

Sorry to state the opposite, but USA, Cananda and Japan are the ONLY countries in the world to use NTSC.
Quote:


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.

Does the intro of Batman look any good on your NTSC TV ?

by on (#55358)
Bregalad wrote:
lidnariq wrote:
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

Sorry to state the opposite, but USA, Cananda and Japan are the ONLY countries in the world to use NTSC.

And guess what the world's richest countries were in the NES era.

Quote:
Does the intro of Batman look any good on your NTSC TV ?

I don't have that game, but I can see some flicker in other things that flash at 30 Hz.

by on (#55365)
tepples wrote:
Bregalad wrote:
lidnariq wrote:
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

Sorry to state the opposite, but USA, Cananda and Japan are the ONLY countries in the world to use NTSC.

And guess what the world's richest countries were in the NES era.

Precisely. You can't go purely by number of countries, you have to look at the population who is ready and willing to purchase a NES.

Yes, there were many African nations that were technically PAL, but how many sales does that represent?

by on (#55367)
Bregalad wrote:
Does the intro of Batman look any good on your NTSC TV ?


It looks horrible on a 1980 Sony Trinitron.
But I'm sure it looks a lot better on a HDTV which treats it as a single field from an interlaced display, rather than a whole frame.

by on (#55374)
BMF54123 wrote:
Given FCEU's limited palette space, I'm assuming it would be incapable of showing all the various combinations of monochrome and de-emphasis settings on a single screen without an overhaul of the video rendering code. Do any demos even attempt to do this?

This one does.

by on (#55415)
Quote:
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.


From what I've heard (it might be on the Wikipedia article for NTSC), when the US was developing its broadcast television standard (NTSC), it chose 60Hz because that was the frequency that AC power was and is sent at in the US. It made it easier to make TV cameras, because you could just sync the camera shutter to the AC power frequency instead of having to use an oscillator. In Europe, AC power is sent at 50Hz, so that's what they used.

by on (#55435)
CartCollector wrote:
From what I've heard, when the US was developing its broadcast television standard (NTSC), it chose 60Hz because that was the frequency that AC power was and is sent at in the US. It made it easier to make TV cameras, because you could just sync the camera shutter to the AC power frequency instead of having to use an oscillator.


I understand the simplification of the TV was more important than that of the camera -- the early TVs didn't have a good enough power supply (at least not without being much more expensive) to be able to redraw the screen at a rate that differed from mains without the beat pattern being visible. By using the nation's mains supply as a nationwide genlock, it made everything easier.

In any case, there exist phosphors that would make an image look fine without flicker when recharged at 50Hz -- although maybe not all of RGB. If nothing else, old glass oscilloscope phosphors often don't have flicker appear to me until I was refreshing at less than 20 Hz.

by on (#55623)
BMF54123 wrote:
Monochrome mode doesn't seem to have been used much at all; the only game I ever played that used it was Isolated Warrior, in order to (very effectively) flash the screen during bomb explosions and boss battles.


Final Fantasy uses monochrome mode to produce the effect that you see when you relight one of the ORBS.

Final Fantasy 3 and, IIRC, at least one of the Dragon Warrior games uses it to flash the screen when you get in a battle (FF1 and FF2 use the color emphasis bits to produce a different kind of flash, as mentioned already)