It is currently Mon Dec 11, 2017 5:58 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: NTSC Color Generator
PostPosted: Tue Mar 08, 2016 9:27 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6508
Location: Seattle
beannaich wrote:
lidnariq wrote:
edit: I think you're not generating the "pulse" (the rarely missing) pixel correctly; phase 0 is always brighter than anything else on the same row in the 2C02 palette.
Do you mean the pixel between the black and left border at h:329? If so, I am currently sending it out as DC, but perhaps AM would be more appropriate.
No, it should definitely be DC, but my interpretation of the wiki saying "pulse (background color in grayscale)" is the same sense of greyscale as $2001 1s bit.


Top
 Profile  
 
 Post subject: Re: NTSC Color Generator
PostPosted: Tue Mar 08, 2016 10:11 pm 
Offline

Joined: Wed Mar 31, 2010 12:40 pm
Posts: 207
lidnariq wrote:
beannaich wrote:
lidnariq wrote:
edit: I think you're not generating the "pulse" (the rarely missing) pixel correctly; phase 0 is always brighter than anything else on the same row in the 2C02 palette.
Do you mean the pixel between the black and left border at h:329? If so, I am currently sending it out as DC, but perhaps AM would be more appropriate.
No, it should definitely be DC, but my interpretation of the wiki saying "pulse (background color in grayscale)" is the same sense of greyscale as $2001 1s bit.


Well I don't know what the real background color used in that frame is (just used memory dumps from a working emulator to generate that pictures), so I used $1d as the background, and $10 as the pulse color.

If I loop through only the screen and decode everything as color, I get the following image:

Image

I believe the color-burst is supposed to be yellow, no?


Top
 Profile  
 
 Post subject: Re: NTSC Color Generator
PostPosted: Tue Mar 08, 2016 11:10 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6508
Location: Seattle
Colorburst is pure hue -U, kind of yellow-green. (See wikipedia:YUV, wikipedia:File:Vectorscope graticule.png and my combined version in this post)

(edit) Also, colorburst is at <Y,U,V>=<0,-.375,0>, which will clip a lot on the final conversion to RGB.


Top
 Profile  
 
 Post subject: Re: NTSC Color Generator
PostPosted: Sat Mar 12, 2016 9:53 am 
Offline

Joined: Wed Mar 31, 2010 12:40 pm
Posts: 207
lidnariq wrote:
As far as the other point ... because the PPU generates 227+⅓ colorburst periods per scanline, so each scanline should be earlier by ⅓ of a period...


I'm not understanding this one. But the code I have for encoding is pretty straightforward, so unless I overlooked something I might need some clarification here...


Top
 Profile  
 
 Post subject: Re: NTSC Color Generator
PostPosted: Sat Mar 12, 2016 10:55 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6508
Location: Seattle
Looking at your code I have no idea why it's doing the wrong thing. All I can do is draw some ASCII art instead:

A scanline is 341 pixels. That's 2728 half-master-clocks.
There are 12 half-master-clocks for a NTSC chroma period. So there's 227+1/3 chroma periods on a scanline.
Every 3 pixels the chroma-pixel phase realigns, so we can skip any multiple of 3 pixels and have the chroma phase be the same before and after:
Code:
11111100 [... 339 pixels ...] 00001111
11000000 [... 339 pixels ...] 11111100
00001111 [... 339 pixels ...] 11000000
11111100 [... 339 pixels ...] 00001111
11000000 [... 339 pixels ...] 11111100
00001111 [... 339 pixels ...] 11000000


I have to assume that somehow, somewhere, the for (auto &counter : counters) { counter = (counter + 1) % 12; } isn't being tickled exactly 2728 times per scanline.


Top
 Profile  
 
 Post subject: Re: NTSC Color Generator
PostPosted: Sat Mar 12, 2016 11:58 am 
Offline

Joined: Wed Mar 31, 2010 12:40 pm
Posts: 207
lidnariq wrote:
A scanline is 341 pixels. That's 2728 half-master-clocks.
There are 12 half-master-clocks for a NTSC chroma period. So there's 227+1/3 chroma periods on a scanline.
Every 3 pixels the chroma-pixel phase realigns, so we can skip any multiple of 3 pixels and have the chroma phase be the same before and after:
Code:
11111100 [... 339 pixels ...] 00001111
11000000 [... 339 pixels ...] 11111100
00001111 [... 339 pixels ...] 11000000
11111100 [... 339 pixels ...] 00001111
11000000 [... 339 pixels ...] 11111100
00001111 [... 339 pixels ...] 11000000


This was very informative, thank you!

lidnariq wrote:
I have to assume that somehow, somewhere, the for (auto &counter : counters) { counter = (counter + 1) % 12; } isn't being tickled exactly 2728 times per scanline.

I have confirmed that the void out(double sample) function is being called 2,728 times per scanline in every for (int v = a; v < b; v++) loop. And also that the function is called 714,736 per frame (assuming a frame where the idle cycle is not dropped). And just for fun, I made sure the numbers used in each loop added up to 341.

I really don't know what else to verify. I know the NTSC standard talks about 262.5 scanlines per field for 480i, but the simulation is only doing 262.


Top
 Profile  
 
 Post subject: Re: NTSC Color Generator
PostPosted: Sat Mar 12, 2016 3:38 pm 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6508
Location: Seattle
beannaich wrote:
I have confirmed that the void out(double sample) function is being called 2,728 times per scanline in every for (int v = a; v < b; v++) loop.
Just for curiosity's sake, if you look at the contents of counters[0] at the beginning of each scanline, what do you see?

Quote:
I really don't know what else to verify. I know the NTSC standard talks about 262.5 scanlines per field for 480i, but the simulation is only doing 262.
That's just 240p vs 480i differences. Shouldn't be related to what you're seeing here.


Top
 Profile  
 
 Post subject: Re: NTSC Color Generator
PostPosted: Sat Mar 12, 2016 5:32 pm 
Offline

Joined: Wed Mar 31, 2010 12:40 pm
Posts: 207
lidnariq wrote:
Just for curiosity's sake, if you look at the contents of counters[0] at the beginning of each scanline, what do you see?

A repeating pattern of 0,4,8,0,4,8.


Top
 Profile  
 
 Post subject: Re: NTSC Color Generator
PostPosted: Sun Mar 13, 2016 10:03 am 
Offline

Joined: Wed Mar 31, 2010 12:40 pm
Posts: 207
Found the problem, and the crosstalk pattern is now going at a 45° angle:

Image

The problem code was in the decoder:

Code:
for (int v = 0; v < 262; v++) {
  for (int h = 0; h < 341 * 2; h++) {
    auto center = (v * 8 * 341) + ((h / 2) * 8);
    auto x1 = center - 4;
    auto x2 = center + 4;


The formula for the center variable should instead be:

Code:
    auto center = (v * 8 * 341) + ((h * 8) / 2);


Otherwise you fall victim to integer math truncating the remainder.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 6 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