Skip to content

Commit

Permalink
CRTC: attempt to fix constantly re-triggered VSYNC in the same row
Browse files Browse the repository at this point in the history
(Onescreen Colonies #0 remix)
  • Loading branch information
gyurco committed Dec 9, 2020
1 parent 8e51c70 commit 2116e05
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions UM6845R.v
Expand Up @@ -19,7 +19,7 @@

module UM6845R
(
input CLOCK,
input CLOCK,
input CLKEN,
input nRESET,
input CRTC_TYPE,
Expand Down Expand Up @@ -204,29 +204,32 @@ end

// vertical output
reg vde;

always @(posedge CLOCK) begin
reg [3:0] vsc;
reg old_hs;
reg vsync_allow;

if (ENABLE & ~nCS & ~R_nW & addr == 5'd07) vsync_allow <= 1;

if(~nRESET) begin
vsc <= 0;
vde <= 0;
VSYNC <= 0;
vsync_allow <= 1;
end
else if (CLKEN) begin
if(row_new) begin
if((frame_new & row !=0) | row_next != row) vsync_allow <= 1;
if(frame_new) vde <= 1;
if(row_next == R6_v_displayed) vde <= 0;
end

// separate 2 concatenated VSYNCs
old_hs <= HSYNC;
if(old_hs && ~HSYNC && !vsc) VSYNC <= 0;

if(field ? (hcc_next == {1'b0, R0_h_total[7:1]}) : line_new) begin
if(vsc) vsc <= vsc - 1'd1;
else if (field ? (row == R7_v_sync_pos && !line) : (row_next == R7_v_sync_pos && line_last)) begin
else if (vsync_allow & (field ? (row == R7_v_sync_pos && !line) : (row_next == R7_v_sync_pos && line_last))) begin
VSYNC <= 1;
// Don't allow a new vsync until a new row (Onescreen Colonies) or the R7 is written (PHX)
vsync_allow <= 0;
vsc <= (CRTC_TYPE ? 4'd0 : R3_v_sync_width) - 1'd1;
end
else VSYNC <= 0;
Expand Down

0 comments on commit 2116e05

Please sign in to comment.