It is currently Fri May 26, 2017 10:00 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Thu Jun 16, 2016 10:41 pm 
Offline
User avatar

Joined: Mon Feb 07, 2011 12:46 pm
Posts: 886
tepples wrote:
Another way would involve a "preview" tool that works on BMP or PNG images.
  1. Load a screenshot of an NES game
  2. Convert RGB values to closest NES color numbers
  3. Run filter on each line
  4. Save filtered screenshot
The Farbfeld Utilities I have written can do all of these things, except for loading/saving BMP images (it does support PNG). However, there is one step you missed which is to generate the NTSC signal; that is the thing I do not have.

_________________
.


Top
 Profile  
 
PostPosted: Mon Jun 20, 2016 8:21 pm 
Offline
User avatar

Joined: Mon Jan 01, 2007 11:12 am
Posts: 203
I copy this posts here form there.

I'm trying rebuild CVBS using PPU rules. For now it first approach to NTSC. I use 9 levels DAC (8 bit R-2R DAC with 9 different level values) and CPLD.
Image
I set phase 8 as color burst (according this) and get this:
Image
As you can see, red and green is swapped. And I don't know why. All phases are correct - I tested it with logic analyzer. Any thoughts?
tepples wrote:
If only columns 2 (+U) and 8 (-U) have the correct hue, try generating the phases backward. You'll need to add a feature to control the direction of the phases when you add PAL anyway.

First - you're right about order - it is backward.
Second - color burst phase is wrong at Wiki. If I set 8 I've got this (first picture is composite capturing, second S-Video, there are present frequency beating - do not pay attention, phase order is 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1):
Image
Image
But, if I set phase 4 as color burst, I get this:
Image
Image
If I left phase 8 as color burst, the phase order must be 4, 3, 2, 1, 12, 11, 10, 9, 8, 7, 6, 5.


Top
 Profile  
 
PostPosted: Mon Jun 20, 2016 10:42 pm 
Offline
User avatar

Joined: Mon Jan 01, 2007 11:12 am
Posts: 203
feos wrote:
If not inside an emulator, then how did you test it?

By the way, you always can set palette to FCEUx with colors values as index from $00 to $3F in each of RGB subpixel. And then record uncompressed AVI.


Top
 Profile  
 
PostPosted: Tue Jun 21, 2016 3:06 am 
Offline
User avatar

Joined: Fri Oct 14, 2011 1:09 am
Posts: 248
Make sure your blue and red are not swapped (RGB v.s. BGR).


Top
 Profile  
 
PostPosted: Tue Jun 21, 2016 3:32 am 
Offline
User avatar

Joined: Mon Jan 01, 2007 11:12 am
Posts: 203
Bisqwit wrote:
Make sure your blue and red are not swapped (RGB v.s. BGR).

How can it possible? It's just a 12 square waveforms with linear phase shift.


Top
 Profile  
 
PostPosted: Tue Jun 21, 2016 3:38 am 
Offline
User avatar

Joined: Fri Oct 14, 2011 1:09 am
Posts: 248
HardWareMan wrote:
Bisqwit wrote:
Make sure your blue and red are not swapped (RGB v.s. BGR).

How can it possible? It's just a 12 square waveforms with linear phase shift.

I presume you are doing NTSC signal to RGB conversions. The code I pasted generates 32-bit integers where certain eight bits represent blue, certain eight bits represent green, and certain eight bits represent red. (Lowest-order eight bits are red IIRC.) It's up to the user to ensure they map the relevant channel into correct channel.


Top
 Profile  
 
PostPosted: Tue Jun 21, 2016 3:44 am 
Offline
User avatar

Joined: Mon Jan 03, 2005 10:36 am
Posts: 2816
Location: Tampere, Finland
He's generating the composite signal with a CPLD+DAC, there's no RGB conversion (except in the television/capture card).

_________________
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: kkfos.aspekt.fi


Top
 Profile  
 
PostPosted: Tue Jun 21, 2016 3:46 am 
Offline
User avatar

Joined: Mon Jan 01, 2007 11:12 am
Posts: 203
Bisqwit wrote:
I presume you are doing NTSC signal to RGB conversions. The code I pasted generates 32-bit integers where certain eight bits represent blue, certain eight bits represent green, and certain eight bits represent red. (Lowest-order eight bits are red IIRC.) It's up to the user to ensure they map the relevant channel into correct channel.

I'm doing:
HardWareMan wrote:
I'm trying rebuild CVBS using PPU rules. For now it first approach to NTSC. I use 9 levels DAC (8 bit R-2R DAC with 9 different level values) and CPLD.
Image

So, I build CVBS within PPU rules and feed it to TV tuner. Where I can swap R and B?


Last edited by HardWareMan on Tue Jun 21, 2016 4:01 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Tue Jun 21, 2016 3:47 am 
Offline
User avatar

Joined: Fri Oct 14, 2011 1:09 am
Posts: 248
HardWareMan wrote:
So, I build CVBS within PPU rules and feed it to TV tuner. Where I can swap R and B?

I did see your post earlier, but I don't know what a CVBS is. So I made the assumption that your post is related to the topic.


Top
 Profile  
 
PostPosted: Tue Jun 21, 2016 3:58 am 
Offline
User avatar

Joined: Mon Jan 01, 2007 11:12 am
Posts: 203
Composite Video Blanking Synchronizing signal


Top
 Profile  
 
PostPosted: Tue Jun 21, 2016 4:01 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1243
HardWareMan wrote:


That's kind of a mix of Composite Video and what CVBS stands for...
Quote:
often designated by the CVBS initialism, for color, video, blanking and sync


Top
 Profile  
 
PostPosted: Sun Jul 03, 2016 2:45 am 
Offline
User avatar

Joined: Mon Jan 01, 2007 11:12 am
Posts: 203
I've got right palette with phase 8 in CPLD generator. Here is verilog:
Code:
module PAL_NTSC_Gen(
    input       NTSC_Clk,     // 21.4772 MHz
    input       PAL_Clk,      // 53.2034 MHz
    output      [7:0]DAC,
    output      [3:0]COUT,
    output      [12:1]PHOUT
);
// For test purpose
assign COUT[3:0] = HCOUNT[7:4];
assign PHOUT[12:1] = PH[12:1];

// Регистры
reg [2:0]PH_PSC;        // Phase prescaler
reg [12:1]PH;           // Color subcarrier phases
reg [3:0]PIX_PSC;       // Pixelclock prescaler
reg PIX_CLK;            // Pixelclock strobe
reg [9:0]HCOUNT;        // Horizontal counter
reg [9:0]VCOUNT;        // Vertical counter
reg HSYNC;              // Horizontal sync
reg BURST;              // Color burst
reg HSCREEN;            // Active video in scanline
reg VSYNC;              // Vertical sync
reg VSCREEN;            // Active video in frame

// used levels
wire [7:0]L0;
wire [7:0]L1;
wire [7:0]L2;
wire [7:0]L3;
wire [7:0]L4;
wire [7:0]L5;
wire [7:0]L6;
wire [7:0]L7;
wire [7:0]L8;
wire [7:0]L9;
// NTSC
assign L0 = 8'h00;
assign L1 = 8'h10;
assign L2 = 8'h18;
assign L3 = 8'h20;
assign L4 = 8'h32;
assign L5 = 8'h36;
assign L6 = 8'h3C;
assign L7 = 8'h4E;
assign L8 = 8'h55;
assign L9 = 8'h6E;

// Luma
wire [7:0]LUMAL;
wire [7:0]LUMAH;
assign LUMAL[7:0] = (~VCOUNT[6]) ?
                        (~VCOUNT[5]) ? L2[7:0] : L3[7:0]
                    :
                        (~VCOUNT[5]) ? L5[7:0] : L8[7:0];
assign LUMAH[7:0] = (~VCOUNT[6]) ?
                        (~VCOUNT[5]) ? L6[7:0] : L7[7:0]
                    : L9[7:0];

// Chroma
wire [7:0]CHROMA;
assign CHROMA[7:0] =    (~HCOUNT[7]) ?
                            (~HCOUNT[6]) ?
                                (~HCOUNT[5]) ?
                                    (~HCOUNT[4]) ?
                                        LUMAH[7:0]
                                        :
                                        (PH[1]) ? LUMAH[7:0] : LUMAL[7:0]
                                :
                                    (~HCOUNT[4]) ?
                                        (PH[2]) ? LUMAH[7:0] : LUMAL[7:0]
                                        :
                                        (PH[3]) ? LUMAH[7:0] : LUMAL[7:0]
                            :
                                (~HCOUNT[5]) ?
                                    (~HCOUNT[4]) ?
                                        (PH[4]) ? LUMAH[7:0] : LUMAL[7:0]
                                        :
                                        (PH[5]) ? LUMAH[7:0] : LUMAL[7:0]
                                :
                                    (~HCOUNT[4]) ?
                                        (PH[6]) ? LUMAH[7:0] : LUMAL[7:0]
                                        :
                                        (PH[7]) ? LUMAH[7:0] : LUMAL[7:0]
                        :
                            (~HCOUNT[6]) ?
                                (~HCOUNT[5]) ?
                                    (~HCOUNT[4]) ?
                                        (PH[8]) ? LUMAH[7:0] : LUMAL[7:0]
                                        :
                                        (PH[9]) ? LUMAH[7:0] : LUMAL[7:0]
                                :
                                    (~HCOUNT[4]) ?
                                        (PH[10]) ? LUMAH[7:0] : LUMAL[7:0]
                                        :
                                        (PH[11]) ? LUMAH[7:0] : LUMAL[7:0]
                            :
                                (~HCOUNT[5]) ?
                                    (~HCOUNT[4]) ?
                                        (PH[12]) ? LUMAH[7:0] : LUMAL[7:0]
                                        :
                                        LUMAL[7:0]
                                :
                                    (~HCOUNT[4]) ?
                                        L3[7:0]
                                        :
                                        L3[7:0];
// Video output
assign DAC[7:0] = (VSYNC | HSYNC) ?
                     // This is correct composite sync
                     (VSYNC & HSYNC) ? L3[7:0] : L0[7:0]
                  :  (BURST) ?
                        // This is color burst
                        (PH[8]) ? L4[7:0] : L1[7:0]
                     :    (VSCREEN & HSCREEN) ?
                              // this is picture
                              CHROMA[7:0]
                          // Otherwise it is blank
                          : L3[7:0];

// Because I don't have 42,9544 MHz generator and CPLD don't allow sync always block on both edge we update only even phases at negedge.
always @(negedge NTSC_Clk) begin
    {PH[11],PH[9],PH[7],PH[5],PH[3],PH[1]} <= {PH[12],PH[11],PH[9],PH[7],PH[5],PH[3]};
end
// Video generator
always @(posedge NTSC_Clk) begin
    // Color subcarrier phase prescaler
    if (PH_PSC[1] & !PH_PSC[0])
    begin
        PH_PSC[2:0] <= 3'h0; PH[12] <= !PH[12];
    end else PH_PSC[2:0] <= PH_PSC[2:0] + 3'h1;
    {PH[10],PH[8],PH[6],PH[4],PH[2]} <= {PH[12],PH[10],PH[8],PH[6],PH[4]};
   
    // Pixelclock prescaler
    PIX_PSC[3:0] <= PIX_PSC[3:0] + 4'h1;
    PIX_CLK <= !PIX_PSC[1] & !PIX_PSC[0];

    // HV COUNTERS: 341 pixels and 262 scanlines
    if (PIX_CLK)
    begin
        if (HCOUNT[9:0] == 9'd340)
        begin
            HCOUNT[9:0] <= 9'd000;
            if (VCOUNT[9:0] == 9'd261) VCOUNT[9:0] <= 9'd000; else VCOUNT[9:0] <= VCOUNT[9:0] + 9'd001;
        end else HCOUNT[9:0] <= HCOUNT[9:0] + 9'd001;
    end

    // Active video in scanline
    if (HCOUNT[9:0] == 9'd000) HSCREEN <= 1'b1;
    if (HCOUNT[9:0] == 9'd255) HSCREEN <= 1'b0;
    // Horizontal sync
    if (HCOUNT[9:0] == 9'd280) HSYNC <= 1'b1;
    if (HCOUNT[9:0] == 9'd305) HSYNC <= 1'b0;
    // Color burst
    if (HCOUNT[9:0] == 9'd309) BURST <= 1'b1;
    if (HCOUNT[9:0] == 9'd325) BURST <= 1'b0;
    // Vertical sync
    if (VCOUNT[9:0] == 9'd244) VSYNC <= 1'b1;
    if (VCOUNT[9:0] == 9'd248) VSYNC <= 1'b0;
    // Active video in frame
    if (VCOUNT[9:0] == 9'd000) VSCREEN <= 1'b1;
    if (VCOUNT[9:0] == 9'd240) VSCREEN <= 1'b0;
end
// end
endmodule

Image
Image
Image

Palette from RP2C02G-0:
Image

Now I can make NTSC PPU with native S-Video output. Need to proceed with PAL and we get PAL PPU with S-Video with high quality video and without any dot crawl.


Top
 Profile  
 
PostPosted: Tue Dec 27, 2016 3:33 pm 
Offline
User avatar

Joined: Sat Apr 18, 2009 4:36 am
Posts: 255
Location: Russia
Sour implemented bisqwit's NTSC-decoder to Mesen:
https://github.com/SourMesen/Mesen/comm ... 8c365f39cf
compiled binary (windows):
https://yadi.sk/d/MXLsD9eL35QBEu

New filter is amazing! It looks very close to NTSC Famicom AV.
Color-generation is accurate too.
Sour wrote:
There might be some bugs left, though. Let me know what you think!


Top
 Profile  
 
PostPosted: Wed Dec 28, 2016 9:02 am 
Offline
User avatar

Joined: Tue Apr 19, 2011 11:26 am
Posts: 106
Location: RU
Bisqwit, can you run your filter against this ROM:
viewtopic.php?f=2&t=15080


Top
 Profile  
 
PostPosted: Thu Dec 29, 2016 2:58 am 
Offline
User avatar

Joined: Fri Oct 14, 2011 1:09 am
Posts: 248
feos wrote:
Bisqwit, can you run your filter against this ROM:
viewtopic.php?f=2&t=15080

Thusly complied.


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

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] 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