MiSTer-devel / Template_MiSTer

Template with latest framework for MiSTer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Direct Video interlace

paulb-nl opened this issue · comments

Some cores like Genesis and PSX have 2 interlaced modes: normal(240 lines) and high resolution(480 lines). The normal mode is more like 240p and does not need to be deinterlaced by the scaler so the cores keep VGA_F1 at 0 every field.

This causes sync issues with Direct Video because it uses the field signal to generate the vde signal and the cores still output 2 different line counts every field.

Template_MiSTer/sys/sys_top.v

Lines 1162 to 1170 in c1080e2

if(~old_hs && vga_hs_osd) begin
old_vs <= vga_vs_osd;
if(~&vcnt) vcnt <= vcnt + 1'd1;
if(~old_vs & vga_vs_osd & ~f1) vsz <= vcnt;
if(old_vs & ~vga_vs_osd) vcnt <= 0;
if(vcnt == 1) vde <= 1;
if(vcnt == vsz - 3) vde <= 0;
end

To fix this we can either change the cores to always output the field when Direct Video is enabled or change the framework to not use the field signal but detect the different field lengths. Although there might be some cores like Atari 2600/7800 which don't have the field available.

I have tested below with some cores and it works well.

Change this

if(~old_vs & vga_vs_osd & ~f1) vsz <= vcnt;

to

if(~old_vs & vga_vs_osd) begin
    if (vcnt != vcnt_ll || vcnt < vcnt_l) vsz <= vcnt;
    vcnt_l <= vcnt;
    vcnt_ll <= vcnt_l;
end

i'm fine with this if it works. I suggest to try it with Minimig as well. It uses interlace modes often. And you can test it in workbench simply by changing video modes in preferences.