PAL color palette emulation
Moderator: Moderators
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/Capture/6538 ... SVideo.PNG
http://savepic.su/5582426.png
Bucky O'Hare:
http://hwm.us.to/famimusic/Capture/6538 ... 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/Capture/6538 ... posite.PNG
http://hwm.us.to/famimusic/Capture/6538 ... posite.png
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/Capture/6538 ... SVideo.PNG
http://savepic.su/5582426.png
Bucky O'Hare:
http://hwm.us.to/famimusic/Capture/6538 ... 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/Capture/6538 ... posite.PNG
http://hwm.us.to/famimusic/Capture/6538 ... posite.png
- Attachments
-
- fceux-PAL.7z
- (1.05 MiB) Downloaded 612 times
Last edited by feos on Sat Dec 22, 2018 2:18 pm, edited 1 time in total.
Re: PAL color palette emulation
I added some cheap notch filter simulation, it reduces the effect of moire mask up to totally killing it.
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.
Code: Select all
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;
}
}
EDIT: attached the proper file with notch slider.
- Attachments
-
- fceux-pal-notch.7z
- (1.05 MiB) Downloaded 553 times
Last edited by feos on Sun May 10, 2015 5:05 pm, edited 1 time in total.
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.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Re: PAL color palette emulation
PAL filter is in Video config dialog, tweaks for it are in Palette config dialog. Enable hardware acceleration for more similarity.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.
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...
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...
Re: PAL color palette emulation
Can you elaborate or send me elsewhere for further reading?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...
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
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.
* 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.
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
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
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.
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.
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.
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 536 times
Re: PAL color palette emulation
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.feos wrote:First of all, there's not just chroma merging, there's total color bleeding in some cases, even through gray!
In that thread, we figured out that thefox's capture card doesn't do any vertical chroma subsampling.While that video doesn't do it:
viewtopic.php?p=125781#p125781
Re: PAL color palette emulation
LOL. So it's done on TVs and not on some capture cards?lidnariq wrote:In that thread, we figured out that thefox's capture card doesn't do any vertical chroma subsampling.
Wait, it still should not blend with black or white?
download/file.php?id=1950&mode=view
http://savepic.ru/5783665.jpg
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)
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)