nesdev.com
http://forums.nesdev.com/

PAL color palette emulation
http://forums.nesdev.com/viewtopic.php?f=3&t=12788
Page 1 of 5

Author:  feos [ Sat May 09, 2015 10:47 am ]
Post subject:  PAL color palette emulation

NTSC emulation is doing very well for a long time, but why not PAL emulation?

Basing on research from HardWareMan, I implemented some kind of PAL subcarrier (moire) emulation in FCEUX, basing on his idea about its phases.
https://sourceforge.net/p/fceultra/code/3112/

Some pics for reference (console+tuner capture vs. fceux):

Kinopio pallette:
http://hwm.us.to/famimusic/Upload/Dendy_Palette_Captured/Kinopio%20test%20(hi-res)/SVideo.PNG
http://savepic.su/5582426.png

Bucky O'Hare:
http://hwm.us.to/famimusic/Upload/Dendy ... Svideo.png
http://savepic.su/5588570.png

Monochrome SMB:
http://savepic.su/440214.gif
http://savepic.su/5590618.png

There are 2 questions now:

1. How to make colors match?
While it might look that it's all about palette loaded, there's actually a Delphi version of that tool (by HWM himself) that outputs slightly different colors, and even makes them brighter! The funniest thing about it is that I used the same calculations on C, and it looks different! FCEUX default palette was used for all of them.
http://savepic.su/5579357.png
http://savepic.su/5586525.png
http://savepic.su/5580381.png

2. How to emulate some sort of rejector filter?
NES/Famicom has no Svideo output, but only plugging it that way one can see really sharp subcarrier mask. Primary output, Composite, gets filtered by reducing Luma (IIRC) to make moire less noticeable.
http://hwm.us.to/famimusic/Upload/Dendy_Palette_Captured/Kinopio%20test%20(hi-res)/Composite.PNG
http://hwm.us.to/famimusic/Upload/Dendy ... posite.png

Attachments:
fceux-PAL.7z [1.05 MiB]
Downloaded 177 times

Author:  feos [ Sun May 10, 2015 7:53 am ]
Post subject:  Re: PAL color palette emulation

I added some cheap notch filter simulation, it reduces the effect of moire mask up to totally killing it.

Code:
if (notch)
   for (int j=0; j<16; j++) {
      if (moire[j] > 1) {
         step = (moire[j] - 1)/100;
         moire[j] -= step*notch;
      } else if (moire[j] < 1) {
         step = (1 - moire[j])/100;
         moire[j] += step*notch;
      }

   }


But there's another problem now. Since everything is calculated per palette tweak, I can't discard notch filter when it's a color border. Otherwise I'd need another 256*16 array of all the moired color values. Any ideas?

EDIT: attached the proper file with notch slider.

Attachments:
fceux-pal-notch.7z [1.05 MiB]
Downloaded 150 times

Author:  Dwedit [ Sun May 10, 2015 8:19 am ]
Post subject:  Re: PAL color palette emulation

I see the FCEUX binary, but how do I actually see the PAL artifacts? I can't seem to find the setting in any obvious place.

Author:  feos [ Sun May 10, 2015 8:31 am ]
Post subject:  Re: PAL color palette emulation

Dwedit wrote:
I see the FCEUX binary, but how do I actually see the PAL artifacts? I can't seem to find the setting in any obvious place.

PAL filter is in Video config dialog, tweaks for it are in Palette config dialog. Enable hardware acceleration for more similarity.

Author:  lidnariq [ Sun May 10, 2015 9:22 am ]
Post subject:  Re: PAL color palette emulation

I assume you read the thread about vertical chroma subsampling on PAL receivers? It looks like the PAL NES and Dendy produce sufficiently non-compliant timing that the exact resulting colors will vary too much from television to television. We don't even know the exact phase of the colorburst yet.

Of course, decoding anything without doing vertical chroma subsampling is still fine...

Actually on topic: The canonical way NTSC receivers do the chroma killer is to remodulate the decoded UV components and subtract that from the original. I assume you can do the same for PAL...

Author:  feos [ Sun May 10, 2015 9:27 am ]
Post subject:  Re: PAL color palette emulation

lidnariq wrote:
The canonical way NTSC receivers do the chroma killer is to remodulate the decoded UV components and subtract that from the original. I assume you can do the same for PAL...

Can you elaborate or send me elsewhere for further reading?

Author:  tepples [ Sun May 10, 2015 9:47 am ]
Post subject:  Re: PAL color palette emulation

PAL chroma merging? was the previous topic. It had these:
  • Page 1: "palblend" test ROM by lidnariq, whose output combines colors on alternating scanlines in a way that looks like the cover of the album 90125 by Yes
  • Pages 3-4: Confirmation that both PAL NES PPU (2C07) and Dendy PPU swap the function of red and green tint bits ($2001 D6/D5) compared to the NTSC PPU (2C02)
  • Page 5-6: "palphase" test ROM by tepples, which combines all 12 colors $11-$1C with similarly luminant gray $00 or color $11-$1C

Author:  lidnariq [ Sun May 10, 2015 11:16 am ]
Post subject:  Re: PAL color palette emulation

For NTSC, at least, it's:

* Capture phase of -U during colorburst
* Generate sine waves at U and V for the scanline (or I and Q if you're doing the specified differential bandwidth)
* Multiply received video by U and V sinusoids, causing demodulation
* Lowpass filter demodulated signals at ~1.5MHz (or 0.6MHz for Q)
* Multiply demodulated U and V signals by said sine waves
* subtract remodulated U and V components from received video
* lowpass filter this difference signal at 4.2MHz to recover Y

The numbers change a little for PAL, and of course there's the colorburst phase switch from scanline to scanline.

Author:  feos [ Sun May 10, 2015 2:03 pm ]
Post subject:  Re: PAL color palette emulation

Now as I've read that thread, I have a question, and I wonder why no one tested it so far: scanlines of 2 alternate colors are blended, plain and simple. But what happens to each of them if there's also a third color scanline? Fourth?

Red becomes Purple
Blue becomes Purple
Red becomes Purple
Blue becomes Purple

Red becomes Yellow?
Green becomes White?
Blue becomes ?
Yellow becomes ?

I can imagine chroma merging is not identical to RGB merging, and it'd only complicate things, but what actually happens to end pixels? Simulating all those sines and cosines and deep hardware events is cool, but it promises to cost an emulator an unjustified amount of time. While simulating the end effect straight away is cheaper effort-wise and speed-wise.

To be clear, here's my actual filter code:
https://sourceforge.net/p/fceultra/code ... t.cpp#l627

Author:  lidnariq [ Sun May 10, 2015 2:20 pm ]
Post subject:  Re: PAL color palette emulation

My understanding of "normal" PAL chroma subsampling is that the chroma for the current scanline is averaged with the chroma from the previous scanline. So red blue red blue does become (unknown) purple purple purple on a "real" PAL signal, but the same colors generated by the NES or SNES may or may not. (e.g. Thefox's TV doesn't. Eugene's / HardWareMan's TVs apparently does)

A sequence of something else would be similar: red green blue yellow would become (unknown) yellow cyan grey... there's no effect beyond just the immediately previous scanline.

Author:  Eugene.S [ Sun May 10, 2015 5:36 pm ]
Post subject:  Re: PAL color palette emulation

I set notch slider to "70". Hey, it looks VERY good on Drag's palette.

Image Image Image
Image Image Image

Author:  feos [ Tue May 12, 2015 2:15 pm ]
Post subject:  Re: PAL color palette emulation

That palmerge thing is really weird.

First of all, there's not just chroma merging, there's total color bleeding in some cases, even through gray!
http://savepic.ru/5769224.png
While that video doesn't do it:
viewtopic.php?p=125781#p125781

Then, it seems too heavy when I simply blend each scanline with its predecessor 50/50. Stripes on Bucky title get washed out.

Here, access the option from Palette config.

Attachments:
fceux-palmegre.7z [1.05 MiB]
Downloaded 136 times

Author:  lidnariq [ Tue May 12, 2015 2:27 pm ]
Post subject:  Re: PAL color palette emulation

feos wrote:
First of all, there's not just chroma merging, there's total color bleeding in some cases, even through gray!
That's definitely as intended, see the C64 game Mayhem in Monsterland: it blends greys and various pure shades to work around the C64's somewhat anemic palette.

Quote:
While that video doesn't do it:
viewtopic.php?p=125781#p125781
In that thread, we figured out that thefox's capture card doesn't do any vertical chroma subsampling.

Author:  feos [ Tue May 12, 2015 2:33 pm ]
Post subject:  Re: PAL color palette emulation

lidnariq wrote:
In that thread, we figured out that thefox's capture card doesn't do any vertical chroma subsampling.

LOL. So it's done on TVs and not on some capture cards?

Wait, it still should not blend with black or white?
download/file.php?id=1950&mode=view
http://savepic.ru/5783665.jpg

Author:  lidnariq [ Tue May 12, 2015 2:55 pm ]
Post subject:  Re: PAL color palette emulation

His capture card pretty clearly added PAL as an afterthought; it's just using the standard BT.601 sample rate (producing 720x576 instead of expected 768x576). I've read that some really early and/or really cheap TV sets didn't implement the vertical chroma subsampling either.

As far as I know, the chroma subsampling should always work. (See lft's Phasor: it abuses this chroma subsampling a LOT). I don't know what exactly will happen on out-of-gamut YUV values, as could happen when combining pure white or black with something colored. Then again, several NES palette entries are already out-of-gamut. (See all the toggles in drag's generator)

Page 1 of 5 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/