Why Doesn't the NES Show Artifact Colors?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Great Hierophant
Posts: 745
Joined: Tue Nov 23, 2004 9:35 pm

Why Doesn't the NES Show Artifact Colors?

Post by Great Hierophant » Sun Jun 12, 2016 1:53 pm

Why doesn't the NES show artifact colors like, for example, the Apple II? The NES has 256 pixels and the Apple II has 280 pixels, yet only the latter shows artifacts with alternating pixel/no pixel graphics. From what I have read here and elsewhere, I can come up with the following factors that tend to eliminate most visible artifacting.

1. 5.37MHz Pixel Clock
The NTSC Color Carrier is 3.58MHz, which gives 160 pure horizontal pixels per line. The 5.37MHz pixel clock gives us 256 pixels per line, but because the dot clock exceed the color clock, the pixels are not quite as pure as we would like. The Apple II uses a 7.16MHz pixel clock, which would ordinarily give us 320 pixels per line. Apple blanks out the first 40 pixels for each line, and did this either to save memory or ensure that all graphics would be within the visible area of the monitor. The IBM CGA card also uses a 7.16MHz pixel clock and gives a true 320 pixels per line. We do not have that nice 2:1 ratio that really bring out the artifacts, but still artifacts can exist at 256 pixels, just look at the Sega Master System's Shinobi in Stages 2-1 and 2-3. The background warehouses show something really like artifact color, especially when the screen scrolls.

2. 1/3 Pixel Shift Every Scanline
The NES does not put out an integer number of pixels, the last pixel is a fractional pixel. From the first displayed line, this causes the graphics to shift to the left on the second displayed line. Then the graphics are further shifted on the third line in relation to the second. This is easy to see on a column of colored pixels next to black, the classic example are the Inventory boxes in the Legend of Zelda. This pixel shift helps break up the solid wall of color that artifact colors work best with. However, with those games that do use alternating vertical lines of color like Spy vs. Spy, you can still get something like diagonal artifacting going on.

3. Missing Pixel Every Other Frame
Here is what really kicks the artifact colors to the curb. The NES shifts its its drawing by one pixel back and forth every frame. I think this is what they call the dot crawl effect, but it has the effect of further eliminating the artifact color since to the eye because it is never in the same place long enough to notice. However, many composite capture devices do not seem to get this part right, because instead of showing slightly crooked alternating lines, they give a sort of diagonal artifacting effect, as seen in this video of Spy vs. Spy : https://www.youtube.com/watch?v=LJC7DIP5JIw Is this an issue with capturing itself, whereas the properties of a CRT tend to show something different?

So, did I miss anything here?

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

Re: Why Doesn't the NES Show Artifact Colors?

Post by lidnariq » Sun Jun 12, 2016 2:12 pm

When you say "artifact colors", do you mean "composite artifacts" ? Or do you actually mean artifact colors ?

For the latter, to meaningfully be able to generate useful artifact colors, your pixel clock must be at least twice as fast as the NTSC colorburst. The only thing we've really managed on the NES is tepples's "tvpassfail" test that uses specific pixel choice to cancel the actual chroma content. (In fact, because the pixel clock is less than twice the colorburst frequency, i.e. the colorburst frequency is above the Nyquist rate, nothing else is even possible)

Additionally, for it to be practical, it should be a "nice" ratio with a small denominator in the ratio. 1's easy, 2 or 3 would be ok, 7 would be actively obnoxious.

Great Hierophant
Posts: 745
Joined: Tue Nov 23, 2004 9:35 pm

Re: Why Doesn't the NES Show Artifact Colors?

Post by Great Hierophant » Sun Jun 12, 2016 3:19 pm

lidnariq wrote:When you say "artifact colors", do you mean "composite artifacts" ? Or do you actually mean artifact colors ?

For the latter, to meaningfully be able to generate useful artifact colors, your pixel clock must be at least twice as fast as the NTSC colorburst. The only thing we've really managed on the NES is tepples's "tvpassfail" test that uses specific pixel choice to cancel the actual chroma content. (In fact, because the pixel clock is less than twice the colorburst frequency, i.e. the colorburst frequency is above the Nyquist rate, nothing else is even possible)

Additionally, for it to be practical, it should be a "nice" ratio with a small denominator in the ratio. 1's easy, 2 or 3 would be ok, 7 would be actively obnoxious.
I meant artifact colors like those shown on CGA and Apple II. I thought that is what the Master System was doing with Shinobi.

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

Re: Why Doesn't the NES Show Artifact Colors?

Post by tepples » Sun Jun 12, 2016 6:49 pm

Most early consoles have exactly 228 color burst periods per scanline, in contrast to 227.5 in the official NTSC spec. This causes their artifacts to line up vertically.

Apple II HGR, Atari 7800, and CGA in composite mode have a 456-dot scanline with 2 dots per color burst cycle. Artifact colors are predictable because each dot is exactly half a color burst cycle. Despite that the 7800 has roughly NES-class palette capability by itself, the 7800 port of Nebulus (whose NES version is called Castelian) exploits this for an even wider variety of colors.

The SMS has a 342-dot scanline with 3 dots per 2 color burst cycles. Artifact colors aren't quite as useful here but are still predictable.

The Genesis has a 427.5-dot scanline with 15 dots per 8 color burst cycles. The dot clock is just below twice the color subcarrier, close enough that TVs decode the common vertical line shading effect with a faint "rainbow" effect, especially in Sonic waterfalls.

NES and Super NES are the oddballs with a 341-dot (227.333-color burst period) scanline. This makes the artifact color pattern less predictable. In addition, they have one dot (2/3 of a color burst period) removed from the vertical blanking of every other field to vary the pattern.


[Corrected title of a game]

Great Hierophant
Posts: 745
Joined: Tue Nov 23, 2004 9:35 pm

Re: Why Doesn't the NES Show Artifact Colors?

Post by Great Hierophant » Sun Jun 12, 2016 9:34 pm

tepples wrote:Most early consoles have exactly 228 color burst periods per scanline, in contrast to 227.5 in the official NTSC spec. This causes their artifacts to line up vertically.

Apple II HGR, Atari 7800, and CGA in composite mode have a 456-dot scanline with 2 dots per color burst cycle. Artifact colors are predictable because each dot is exactly half a color burst cycle. Despite that the 7800 has roughly NES-class palette capability by itself, the 7800 port of Nemesis (whose NES version is called Castelian) exploits this for an even wider variety of colors.
I think the game's original name is Nebulus, not Nemesis :) On the 7800 it is called Tower Toppler, perhaps the most descriptive of the three titles. The Atari 5200 and 8-bit computers have a 320x192 artifact color mode, Choplifter uses it in places. The Tandy Color Computer 1 & 2 use artifact colors with a 256x192 resolution that only seems to use the blue/orange pair of the Apple II. However, the Commodore 64 has a 320x200 high color mode that does not use artifact colors, even on an NTSC machine. Clearly resolution does not dictate whether artifact colors can be reliably generated.
tepples wrote:
The SMS has a 342-dot scanline with 3 dots per 2 color burst cycles. Artifact colors aren't quite as useful here but are still predictable.

The Genesis has a 427.5-dot scanline with 15 dots per 8 color burst cycles. The dot clock is just below twice the color subcarrier, close enough that TVs decode the common vertical line shading effect with a faint "rainbow" effect, especially in Sonic waterfalls.

NES and Super NES are the oddballs with a 227.333-pixel scanline. This makes the artifact color pattern less predictable. In addition, they have one dot (2/3 of a color burst period) removed from the vertical blanking of every other field to vary the pattern.
If I read correctly the wiki, the NES and SNES have a 341-dot scanline for all odd frames and a 340-dot scanline for all even frames.

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

Re: Why Doesn't the NES Show Artifact Colors?

Post by lidnariq » Mon Jun 13, 2016 12:02 am

Great Hierophant wrote:If I read correctly the wiki, the NES and SNES have a 341-dot scanline for all odd frames and a 340-dot scanline for all even frames.
It's 341 pixels for every scanline on both even and odd frames, except for: the very first scanline where anything is drawn. That one is 341 or 340 pixels, alternating every other vblank.

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

Re: Why Doesn't the NES Show Artifact Colors?

Post by tepples » Mon Jun 13, 2016 1:33 pm

:oops: Thank you for the corrections.

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

Re: Why Doesn't the NES Show Artifact Colors?

Post by lidnariq » Mon Jun 13, 2016 2:47 pm

Great Hierophant wrote:look at the Sega Master System's Shinobi in Stages 2-1 and 2-3. The background warehouses show something really like artifact color, especially when the screen scrolls.
You're referring to the either purple or flickering red or blue and black somethings?

If the palette entry in the game is originally purple, and it's intended to be red and blue stripes, then I guess they do appear to be cleverly abusing the pixel grid to induce luma-into-chroma crosstalk that's stable ... which is pedantically the definition of artifact color. It's just that when the pixel clock is less than twice the colorburst frequency, the possible results are limited to causing minor phase shifts in the decoded color (in the SMS case, up to 60°)

In fact, I can trivially recreate this effect using blargg's sms_ntsc filter. The only tricky thing about it is that it forces the game to quantize fine scrolling to multiples of three.
Attachments
#A0A purple at different phase shifts (top 3/4); solid (bottom 1/4)
#A0A purple at different phase shifts (top 3/4); solid (bottom 1/4)
filtered.png (1.57 KiB) Viewed 8723 times

Great Hierophant
Posts: 745
Joined: Tue Nov 23, 2004 9:35 pm

Re: Why Doesn't the NES Show Artifact Colors?

Post by Great Hierophant » Mon Jun 13, 2016 7:20 pm

lidnariq wrote:
Great Hierophant wrote:look at the Sega Master System's Shinobi in Stages 2-1 and 2-3. The background warehouses show something really like artifact color, especially when the screen scrolls.
You're referring to the either purple or flickering red or blue and black somethings?

If the palette entry in the game is originally purple, and it's intended to be red and blue stripes, then I guess they do appear to be cleverly abusing the pixel grid to induce luma-into-chroma crosstalk that's stable ... which is pedantically the definition of artifact color. It's just that when the pixel clock is less than twice the colorburst frequency, the possible results are limited to causing minor phase shifts in the decoded color (in the SMS case, up to 60°)

In fact, I can trivially recreate this effect using blargg's sms_ntsc filter. The only tricky thing about it is that it forces the game to quantize fine scrolling to multiples of three.
Please don't rely on the second video to give an accurate visual of what the effect looks like, my video does in 60p :

https://youtu.be/Fyl1n70tmcM

That is a reasonable representation of what the eye will see on a Genesis in SMS mode with an NTSC CRT. I apologize for the lack of sound, the handheld camera and the one-handed playing. When you scroll the screen, if your eyes are sharp enough you can see the alternating lines a bit. The total effect appears like a wall of rolling cylinders, one level rolling left, the next level rolling right and the third rolling left and so on.

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

Re: Why Doesn't the NES Show Artifact Colors?

Post by lidnariq » Mon Jun 13, 2016 8:20 pm

Huh.

I guess I'd personally be inclined to say that that is an example of chroma-into-luma crosstalk, and .... I guess, as a result, pedantically not artifact colors.

That said, my previous misread certainly indicates that some amount of luma-into-chroma crosstalk can be intentionally engineered on the Master System, so I think your point stands.

Great Hierophant
Posts: 745
Joined: Tue Nov 23, 2004 9:35 pm

Re: Why Doesn't the NES Show Artifact Colors?

Post by Great Hierophant » Mon Jun 13, 2016 8:39 pm

I suppose no Master System emulator bothers to emulate this effect. Kega Fusion, the Genesis emulator with which I am most familiar, uses something like a bilinear filter with color averaging on the stripey bits to emulate the NTSC "artifact" effect if you apply that filter. It may be sufficient for the waterfalls other objects on the Genesis, but fails to come close with this Master System effect.

Even though the SMS and the Tandy CoCo use the same resolution, I don't think they use the same dot clock. According to the Tandy CoCo Tech Ref, the dot clock is 3.58MHz and in the artifact mode each pixel is one half of the dot clock. The Tandy displays large borders on the sides, whereas the SMS really does not.

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

Re: Why Doesn't the NES Show Artifact Colors?

Post by tepples » Mon Jun 13, 2016 9:55 pm

CoCo's video chip is an MC6847 Video Display Generator, whose datasheet indeed specifies half a color burst period per pixel. At that, rate, the scanline can reasonably be 454, 455 (standard), or 456 dots long. It turns out, according to note 6 on page 7, that the MC6847's scanline is of the standard length, 455 dots or 227.5 color burst periods, which causes the color burst phase to be opposite from one scanline to the next. Thus artifact colors would appear slightly harder to exploit than they would be on a 228-period video circuit like that of an Apple II or a 7800: you have to make checkerboards rather than vertical lines.

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

Re: Why Doesn't the NES Show Artifact Colors?

Post by tokumaru » Tue Jun 14, 2016 7:52 am

There are implementations of blargg's NTSC filters for Kega Fusion, but filters need to be downloaded separately and put into a folder.

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

Re: Why Doesn't the NES Show Artifact Colors?

Post by tepples » Tue Jun 14, 2016 8:23 am

This is a very cheap filter.
  1. Scale image to 512px width with linear interpolation
  2. Add black border to 518px (next multiple of 7; needed for later PAR correction)
  3. Keep only R, G, B, R, G, B, ... from successive pixels
    In GIMP: Filters > Distorts > Video, Striped, Additive off, Rotated on
  4. Convolve with [1, 1, 1] kernel
  5. Scale to 592px width with linear interpolation and double height with nearest neighbor
alexkidd_fakeartifacts.png
Does the result look anything like a Master System's actual video output? Or like a Master System game played through a Game Gear?

Great Hierophant
Posts: 745
Joined: Tue Nov 23, 2004 9:35 pm

Re: Why Doesn't the NES Show Artifact Colors?

Post by Great Hierophant » Tue Jun 14, 2016 2:46 pm

Blargg's Filters for Kega Fusion look like that second video lidnariq posted.

Post Reply