ce_pix fix (#48)

* One more fix for the changed system clock with separate video clock

* "Wider" operation of the artifacting, PAL/NTSC separate.

* XEX loader init fix, NO IDEA why this has to be like this, but it does!

* Artifacting color choice independent of PAL/NTSC
This commit is contained in:
Wojciech Mostowski
2025-07-20 12:38:19 +02:00
committed by GitHub
parent f1b7ecb00b
commit d10e1ea201
5 changed files with 95 additions and 15 deletions

View File

@@ -336,6 +336,7 @@ wire [7:0] R,G,B;
wire HBlank,VBlank;
wire VSync, HSync;
wire ce_pix;
wire ce_pix_raw;
assign CLK_VIDEO = clk_vdo;
@@ -381,7 +382,7 @@ atari5200top atari5200top
.VGA_B(B),
.VGA_G(G),
.VGA_R(R),
.VGA_PIXCE(ce_pix),
.VGA_PIXCE(ce_pix_raw),
.HBLANK(HBlank),
.VBLANK(VBlank),
@@ -447,6 +448,13 @@ assign VGA_SL = scale ? scale[1:0] - 1'd1 : 2'd0;
wire [2:0] scale = status[19:17];
reg ce_pix_raw_old = 0;
assign ce_pix = ce_pix_raw & ~ce_pix_raw_old;
always @(posedge CLK_VIDEO) begin
ce_pix_raw_old <= ce_pix_raw;
end
video_mixer #(.GAMMA(1)) video_mixer
(
.*,

View File

@@ -220,7 +220,7 @@ wire [5:0] CPU_SPEEDS[8] ='{6'd1,6'd2,6'd4,6'd8,6'd16,6'd0,6'd0,6'd0};
// 0 1 2 3 4 5 6
// 01234567890123456789012345678901 23456789012345678901234567890123
// 0123456789ABCDEFGHIJKLMNOPQRSTUV 0123456789ABCDEFGHIJKLMNOPQRSTUV
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXX
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXX
`include "build_id.v"
localparam CONF_STR = {
@@ -276,6 +276,7 @@ localparam CONF_STR = {
"P3OMN,Aspect ratio,Original,Full Screen,[ARC1],[ARC2];",
"P3OHJ,Scandoubler FX,None,HQ2x,CRT 25%,CRT 50%,CRT 75%;",
"P3OV,NTSC/PAL artifacting,No,Yes;",
"d3P3oK,Artifacting colors,Set 1,Set 2;",
"P3o2,Clip sides,Disabled,Enabled;",
"P3OTU,Scale,Normal,V-Integer,Narrower HV-Integer,Wider HV-Integer;",
"d0P3OO,Vertical Crop,Disabled,216p(5x);",
@@ -374,7 +375,7 @@ hps_io #(.CONF_STR(CONF_STR), .VDNUM(8)) hps_io
.buttons(buttons),
.status(status),
.status_menumask({~status[2] & status[42], status[2],en216p}),
.status_menumask({status[31], ~status[2] & status[42], status[2], en216p}),
.forced_scandoubler(forced_scandoubler),
.gamma_bus(gamma_bus),
@@ -407,6 +408,7 @@ wire [7:0] R,G,B, Ro,Go,Bo;
wire HBlank,VBlank,HBlank_o,VBlank_o;
wire VSync, HSync, VSync_o, HSync_o;
wire ce_pix;
wire ce_pix_raw;
assign CLK_VIDEO = clk_vdo;
@@ -461,7 +463,7 @@ atari800top atari800top
.VGA_B(Bo),
.VGA_G(Go),
.VGA_R(Ro),
.VGA_PIXCE(ce_pix),
.VGA_PIXCE(ce_pix_raw),
.HBLANK(HBlank_o),
.VBLANK(VBlank_o),
@@ -550,6 +552,13 @@ assign VGA_SL = scale ? scale[1:0] - 1'd1 : 2'd0;
wire [2:0] scale = status[19:17];
reg ce_pix_raw_old = 0;
assign ce_pix = ce_pix_raw & ~ce_pix_raw_old;
always @(posedge CLK_VIDEO) begin
ce_pix_raw_old <= ce_pix_raw;
end
reg hsync_o, vsync_o;
always @(posedge CLK_VIDEO) begin
if(ce_pix) begin
@@ -564,6 +573,7 @@ articolor articolor
.ce_pix(ce_pix),
.enable(status[31]),
.colorset(~status[52]),
.r_in(Ro),
.g_in(Go),

View File

@@ -431,7 +431,7 @@ void actions()
// Clean reboot, but hold it for now
reboot(1, 1);
// Reinitialize the whole memory to 0 rather than the DRAM pattern
memset32(SDRAM_BASE, 0x00, main_ram_size/4);
memset8(SDRAM_BASE, 0x00, main_ram_size);
xex_reloc = get_xexloc() ? 1 : XEX_LOADER_LOC;

View File

@@ -152,8 +152,8 @@ CONTENT BEGIN
0470: 52765191 853F84BA 3976862E 09810680 C1388151 F1B23F80 51F1DB3F 8C180878;
0478: 56567583 38755574 52805190 DD3F8052 8151F3FD 3F908090 0870880A 07908090;
0480: 0C559080 900870F7 0A069080 900C5583 F1397685 2E098106 81DB388C 1808802E;
0488: 83E03877 83C4FC0C 810B83C5 800C8151 F0D63F80 51F0FF3F 81528151 F3B33F81;
0490: 80805380 5282800A 51F2DE3F 90808408 70842A70 81065151 55815674 83388756;
0488: 83E03877 83C4FC0C 810B83C5 800C8151 F0D63F80 51F0FF3F 81528151 F3B33F84;
0490: 80805380 5282800A 51F2BF3F 90808408 70842A70 81065151 55815674 83388756;
0498: 7583C6AC 3475882B 8E800684 80800583 C6B40C80 C6548053 848E8052 80ECE451;
04A0: 80C3803F 83C6AC33 7081FF06 56567487 2E863875 848EA334 800B8484 C434810B;
04A8: 8487F834 800B8487 FA349080 84087083 2A708106 51515574 953880DC 0B8486BD;

View File

@@ -24,6 +24,7 @@ module articolor
input ce_pix,
input enable,
input colorset,
input [7:0] r_in, g_in, b_in,
input hbl_in, vbl_in, hs_in, vs_in,
@@ -44,10 +45,10 @@ always @(posedge clk) begin
mix <= 0;
if(enable) begin
if(r_d[0] >= 238 && g_d[0] >= 238 && b_d[0] >= 238 && !r_in && !g_in && !b_in && !r_d[1] && !g_d[1] && !b_d[1]) begin
if(r_d[0] >= 10 && r_d[0] == g_d[0] && g_d[0] == b_d[0] && !r_in && !g_in && !b_in && !r_d[1] && !g_d[1] && !b_d[1]) begin
mix <= {1'b1,n};
end
else if(!r_d[0] && !g_d[0] && !b_d[0] && r_in >= 238 && g_in >= 238 && b_in >= 238 && r_d[1] >= 238 && g_d[1] >= 238 && b_d[1] >= 238) begin
else if(!r_d[0] && !g_d[0] && !b_d[0] && r_in >= 10 && r_in == g_in && g_in == b_in && r_d[1] == r_in && g_d[1] == g_in && b_d[1] == b_in) begin
mix <= {1'b1,~n};
end
end
@@ -78,14 +79,75 @@ always @(posedge clk) begin
if(mix[1]) begin
if(mix[0]) begin
r_out <= 0;
g_out <= 141;
b_out <= 255;
// This is more general and may work with colors other than B/W
if (colorset) begin
// PAL
r_out <= 0;
g_out <= (unsigned'(g_d[0] | g_d[1]) * 141) >> 8;
b_out <= (unsigned'(b_d[0] | b_d[1]) * 255) >> 8;
end
else begin
// NTSC
r_out <= (unsigned'(r_d[0] | r_d[1]) * 134) >> 8;
g_out <= (unsigned'(g_d[0] | g_d[1]) * 248) >> 8;
b_out <= (unsigned'(b_d[0] | b_d[1]) * 113) >> 8;
end
// This is only for PAL and Atari palette
//r_out <= 0;
//case (r_d[0] | r_d[1])
// 8'h11 : begin g_out <= 9; b_out <= 17; end
// 8'h22 : begin g_out <= 19; b_out <= 34; end
// 8'h33 : begin g_out <= 28; b_out <= 51; end
// 8'h44 : begin g_out <= 38; b_out <= 68; end
// 8'h55 : begin g_out <= 47; b_out <= 85; end
// 8'h66 : begin g_out <= 56; b_out <= 102; end
// 8'h77 : begin g_out <= 66; b_out <= 119; end
// 8'h88 : begin g_out <= 75; b_out <= 136; end
// 8'h99 : begin g_out <= 85; b_out <= 153; end
// 8'haa : begin g_out <= 94; b_out <= 170; end
// 8'hbb : begin g_out <= 103; b_out <= 187; end
// 8'hcc : begin g_out <= 113; b_out <= 204; end
// 8'hdd : begin g_out <= 122; b_out <= 221; end
// 8'hee : begin g_out <= 132; b_out <= 238; end
// 8'hff : begin g_out <= 141; b_out <= 255; end
// default: ;
//endcase
end
else begin
r_out <= 207;
g_out <= 109;
b_out <= 3;
// This is more general and may work with colors other than B/W
if (colorset) begin
// PAL
r_out <= (unsigned'(r_d[0] | r_d[1]) * 207) >> 8;
g_out <= (unsigned'(g_d[0] | g_d[1]) * 109) >> 8;
b_out <= (unsigned'(b_d[0] | b_d[1]) * 3) >> 8;
end
else begin
// NTSC
r_out <= (unsigned'(r_d[0] | r_d[1]) * 255) >> 8;
g_out <= (unsigned'(g_d[0] | g_d[1]) * 133) >> 8;
b_out <= (unsigned'(b_d[0] | b_d[1]) * 250) >> 8;
end
// This is only for PAL and Atari palette
//b_out <= 2;
//case (r_d[0] | r_d[1])
// 8'h11 : begin r_out <= 14; g_out <= 7; b_out <= 0; end
// 8'h22 : begin r_out <= 28; g_out <= 15; b_out <= 0; end
// 8'h33 : begin r_out <= 41; g_out <= 22; b_out <= 1; end
// 8'h44 : begin r_out <= 55; g_out <= 29; b_out <= 1; end
// 8'h55 : begin r_out <= 69; g_out <= 36; b_out <= 1; end
// 8'h66 : begin r_out <= 83; g_out <= 44; b_out <= 1; end
// 8'h77 : begin r_out <= 97; g_out <= 51; b_out <= 1; end
// 8'h88 : begin r_out <= 110; g_out <= 58; end
// 8'h99 : begin r_out <= 124; g_out <= 65; end
// 8'haa : begin r_out <= 138; g_out <= 73; end
// 8'hbb : begin r_out <= 152; g_out <= 80; end
// 8'hcc : begin r_out <= 166; g_out <= 87; end
// 8'hdd : begin r_out <= 179; g_out <= 94; b_out <= 3; end
// 8'hee : begin r_out <= 193; g_out <= 102; b_out <= 3; end
// 8'hff : begin r_out <= 207; g_out <= 109; b_out <= 3; end
// default: ;
//endcase
end
end