Skip to content

Commit

Permalink
shouse: implement screen flip (#691)
Browse files Browse the repository at this point in the history
  • Loading branch information
gyurco committed Aug 4, 2024
1 parent 207817f commit 61f6ef5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
12 changes: 4 additions & 8 deletions cores/shouse/hdl/jtshouse_obj.v
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ always @* begin
3: ypos = -(oram_dout[15:8] - 8'd28); // 4
endcase

ydiff = (vrender[7:0] + yoffset + 8'h10) - ypos;
ydiff = ({1'b0, (flip ? ~(vrender[7:0] - 8'h20) : vrender[7:0])} + yoffset + 8'h10) - ypos;
ydiff[8] = 0;

case(vsize)
Expand Down Expand Up @@ -130,7 +130,7 @@ assign rom_addr = { pre_addr[17-:11],
dr_hsize[0] ? dr_hmsb[0] : pre_addr[6] /* H8 */ };

always @(posedge clk) begin
xoffset <= pre_xos-(flip ? 9'd3 : 9'd75); //+{debug_bus[7],debug_bus};
xoffset <= pre_xos-(flip ? -9'd7 : 9'd8); //+{debug_bus[7],debug_bus};
yoffset <= pre_yos+(flip ? 9'd1 : -9'd1);
end

Expand Down Expand Up @@ -166,18 +166,14 @@ always @(posedge clk, posedge rst) begin
1: begin // read 13, 12
attr[6:0] <= oram_dout[7:1];
// xraw <= {oram_dout[0], oram_dout[15:8]};
xpos <= ({1'b0,oram_dout[0], oram_dout[15:8]}+xoffset)^{10{flip}};
xpos <= ({1'b0,oram_dout[0], oram_dout[15:8]}+xoffset);
scan_sub <= 1;
end
2: begin // read 11, 10
code <= { oram_dout[2:0], oram_dout[15:8] };
hsize <= oram_dout[7:6];
hos <= oram_dout[4:3]; // H offset
hflip <= oram_dout[5]^flip;
xpos <= xpos + (!flip?10'h43:(
oram_dout[7:6]==0?10'h45:
oram_dout[7:6]==1?10'h4d:
oram_dout[7:6]==2?10'h35:10'h51));
hflip <= oram_dout[5];
end
3: begin
if( !dr_bsy ) begin
Expand Down
15 changes: 10 additions & 5 deletions cores/shouse/hdl/jtshouse_scr.sv
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ parameter [ 8:0] VB_END = 9'h120;
localparam [ 8:0] HMARGIN=9'h8,
HSTART=9'h40-HMARGIN,
HEND=9'd288+HSTART+(HMARGIN<<1); // hdump is non blank from 'h40 to 'h160
localparam [15:0] VSCR =-16'd28;

wire [15:0] hoff0 = flip ? 16'h71 : -16'h0f;
wire [15:0] hoff1 = flip ? hoff0 + 16'h2 : hoff0 - 16'h2;
Expand Down Expand Up @@ -138,7 +137,11 @@ always @(posedge clk, posedge rst) begin
hcnt2 <= (-hscr[2][2:0] ^ {3{~flip}})+hoff2[2:0];
hcnt3 <= (-hscr[3][2:0] ^ {3{~flip}})+hoff3[2:0];

if(vdump[2:0]==0) lin_row <= vdump[8:3]==6'h24 ? 10'd1 : lin_row+10'd36;
if(vdump[2:0]==0)
if (flip)
lin_row <= vdump[8:3]==6'h24 ? 10'd973 : lin_row-10'd36;
else
lin_row <= vdump[8:3]==6'h24 ? 10'd1 : lin_row+10'd36;
// if(vrender[2:0]==7) lin_row <= vrender[8:3]==6'h24 ? 10'd1 : lin_row+10'd36;
// if(vrender==9'h120 ) lin_row <= 1;
end
Expand All @@ -157,9 +160,11 @@ always @* begin
if( mlyr>3 )
{ vpos, hpos } = { 7'd0, vdump, 7'd0, hcnt };
else
{ vpos, hpos } = { {7'd0, vdump}-(vscr[mlyr[1:0]] ^ {16{~flip}}) + (flip ? VSCR : -VSCR + 16'd219),
{ vpos, hpos } = { {7'd0, vdump}+vscr[mlyr[1:0]] + 16'd248,
{7'd0, hcnt}-(hscr[mlyr[1:0]] ^ {16{~flip}}) + hoff};

if ( flip ) vpos = ~vpos;

// Determines the active layer
win = 5;
cprio = 0;
Expand Down Expand Up @@ -246,7 +251,7 @@ jtframe_linebuf #(.DW(14)) u_buffer(
.wr_addr ( buf_a ),
.wr_data ({bpxl,bprio}),
.we ( buf_we ),
.rd_addr ( hdump ),
.rd_addr ( flip ? ~hdump - 9'h5e : hdump ),
.rd_data ({pxl,prio} ),
.rd_gated ( )
);
Expand Down Expand Up @@ -287,4 +292,4 @@ always @(posedge miss) begin
end
`endif

endmodule
endmodule

0 comments on commit 61f6ef5

Please sign in to comment.