It is currently Mon Dec 11, 2017 4:08 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 69 posts ]  Go to page 1, 2, 3, 4, 5  Next
Author Message
PostPosted: Sat May 09, 2015 10:47 am 
Offline
User avatar

Joined: Tue Apr 19, 2011 11:26 am
Posts: 106
Location: RU
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 181 times
Top
 Profile  
 
PostPosted: Sun May 10, 2015 7:53 am 
Offline
User avatar

Joined: Tue Apr 19, 2011 11:26 am
Posts: 106
Location: RU
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 153 times


Last edited by feos on Sun May 10, 2015 5:05 pm, edited 1 time in total.
Top
 Profile  
 
PostPosted: Sun May 10, 2015 8:19 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3967
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!


Top
 Profile  
 
PostPosted: Sun May 10, 2015 8:31 am 
Offline
User avatar

Joined: Tue Apr 19, 2011 11:26 am
Posts: 106
Location: RU
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.


Top
 Profile  
 
PostPosted: Sun May 10, 2015 9:22 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6507
Location: Seattle
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...


Top
 Profile  
 
PostPosted: Sun May 10, 2015 9:27 am 
Offline
User avatar

Joined: Tue Apr 19, 2011 11:26 am
Posts: 106
Location: RU
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?


Top
 Profile  
 
PostPosted: Sun May 10, 2015 9:47 am 
Online

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19330
Location: NE Indiana, USA (NTSC)
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


Top
 Profile  
 
PostPosted: Sun May 10, 2015 11:16 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6507
Location: Seattle
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.


Top
 Profile  
 
PostPosted: Sun May 10, 2015 2:03 pm 
Offline
User avatar

Joined: Tue Apr 19, 2011 11:26 am
Posts: 106
Location: RU
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


Top
 Profile  
 
PostPosted: Sun May 10, 2015 2:20 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6507
Location: Seattle
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.


Top
 Profile  
 
PostPosted: Sun May 10, 2015 5:36 pm 
Offline
User avatar

Joined: Sat Apr 18, 2009 4:36 am
Posts: 260
Location: Russia
I set notch slider to "70". Hey, it looks VERY good on Drag's palette.

Image Image Image
Image Image Image


Top
 Profile  
 
PostPosted: Tue May 12, 2015 2:15 pm 
Offline
User avatar

Joined: Tue Apr 19, 2011 11:26 am
Posts: 106
Location: RU
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 141 times
Top
 Profile  
 
PostPosted: Tue May 12, 2015 2:27 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6507
Location: Seattle
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.


Top
 Profile  
 
PostPosted: Tue May 12, 2015 2:33 pm 
Offline
User avatar

Joined: Tue Apr 19, 2011 11:26 am
Posts: 106
Location: RU
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


Top
 Profile  
 
PostPosted: Tue May 12, 2015 2:55 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6507
Location: Seattle
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)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 69 posts ]  Go to page 1, 2, 3, 4, 5  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group