Skip to content

Commit

Permalink
Issue657 (#755)
Browse files Browse the repository at this point in the history
Fix for #657
- cps1: fix color DMA (wr_page advances too soon) ()
- cps1: try BFF as blank color (#657)
- cps2: blank to black after the color DMA fix (#657)
- cps2: don't blank over sprites (#657)
- cps2: simplify obj/scr mux (by paulb-nl) (#657)
  • Loading branch information
gyurco committed Aug 9, 2024
1 parent 97efd18 commit 6a5f2f8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
7 changes: 4 additions & 3 deletions cores/cps1/hdl/jtcps1_colmix.v
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,11 @@ always @(*) begin
endcase
end

`ifdef CPS2
localparam [13:0] BLANK_PXL = { 2'b11, 12'hBFF }; // according to DL-0921 RE but it doesn't look
// good on CPS1/CPS1.5 games. CPS2 is fine with that
`ifndef CPS2
localparam [13:0] BLANK_PXL = { 2'b11, 12'hBFF }; // according to DL-0921 RE
`else
// CPS2 seems to blank to black, as the programmed color in CPS1 is expanding to the back porch area,
// confusing the black level calibration on displays.
localparam [13:0] BLANK_PXL = ~14'd0;
`endif

Expand Down
10 changes: 8 additions & 2 deletions cores/cps1/hdl/jtcps1_dma.v
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ localparam MW = 3; // miss hit counter
reg [15:0] vrenderf, vscr1, vscr2, vscr3, row_scr_next;
reg [11:0] scan;
wire [11:0] wr_pal_addr;
wire [15:0] pal_ram_q;
reg [10:0] vn, hn, hstep;
reg [ 9:0] obj_cnt, obj_wr_cnt;
reg [ 8:0] pal_cnt, pal_wr_cnt, vram_scr_base;
Expand Down Expand Up @@ -236,10 +237,13 @@ jtframe_dual_ram #(.DW(16), .AW(12)) u_pal_ram(
.addr1 ( colmix_addr ),
.we1 ( 1'b0 )
`ifndef FORCE_GRAY
,.q1 ( pal_data )
,.q1 ( pal_ram_q )
`endif
);

// handle artificial CPS2 blank color (FFF)
assign pal_data = colmix_addr == 12'hFFF ? 16'h0 : pal_ram_q;

`ifdef FORCE_GRAY
assign pal_data = {4'hf, {3{colmix_addr[3:0]}} };
`endif
Expand Down Expand Up @@ -483,11 +487,13 @@ always @(posedge clk) begin
end
if( |cur_task[PAL5:PAL0] ) begin
pal_cnt <= pal_cnt + 9'd1;
if( &pal_cnt ) begin
if( &pal_wr_cnt ) begin
tasks[PAL5:PAL0] <= tasks[PAL5:PAL0] & ~cur_task[PAL5:PAL0];
adv <= 1;
// Update palette page
pal_wr_page <= pal_wr_page+3'd1;
end
if( &pal_cnt ) begin
pal_rd_page<=pal_rd_page+3'd1;
end
end
Expand Down
7 changes: 3 additions & 4 deletions cores/cps2/hdl/jtcps2_colmix.v
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module jtcps2_colmix(
localparam [2:0] OBJ=3'b0, SCR1=3'b1, SCR2=3'd2, SCR3=3'd3, STA=3'd4;
localparam [3:1] OBJ_PRIO = 3'b010;

reg obj1st, mux_sel;
reg obj1st, obj_sel;
reg [ 3:0] scr_prio;
reg [15:0] lyr_prio;

Expand All @@ -61,7 +61,7 @@ always @(*) begin
default: scr_prio = 4'd7;
endcase
obj1st = obj_prio > scr_prio[2:0];
mux_sel = obj1st ? blank(obj_pxl) : ~blank(scr_pxl);
obj_sel = ~blank(obj_pxl) & (obj1st | blank(scr_pxl));
end

always @(posedge clk) begin
Expand All @@ -72,8 +72,7 @@ always @(posedge clk) begin
end

always @(posedge clk) if(pxl_cen) begin
pxl <= !obj_en ? scr_pxl :
( mux_sel ? scr_pxl : {3'd0, obj_pxl[8:0]} );
pxl <= (obj_en & obj_sel) ? {3'd0, obj_pxl[8:0]} : scr_pxl;
end

`ifdef PRIO_SIM
Expand Down

0 comments on commit 6a5f2f8

Please sign in to comment.