Skip to content

Commit

Permalink
Make overlay display 4:3
Browse files Browse the repository at this point in the history
  • Loading branch information
nand2mario committed Feb 1, 2025
1 parent 5317df9 commit 5771a5f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
28 changes: 28 additions & 0 deletions buildall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


set GWSH=..\..\Gowin_V1.9.10.03_x64\IDE\bin\gw_sh

echo
echo "============ Building console60k ==============="
echo
%GWSH% build.tcl console60k

echo
echo "============ Building mega60k ==============="
echo
%GWSH% build.tcl mega60k

echo
echo "============ Building mega138k ==============="
echo
%GWSH% build.tcl mega138k

echo
echo "============ Building mega138k pro ==============="
echo
%GWSH% build.tcl mega138kpro

dir impl\pnr\*.fs

echo "All done."

20 changes: 15 additions & 5 deletions src/gba2hdmi.sv
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ end

//
// Video
// Scale to 1080x720 for GBA video, 960x720 for overlay
//
reg [23:0] rgb; // actual RGB output
reg active /* xsynthesis syn_keep=1 */;
Expand All @@ -142,6 +143,8 @@ assign overlay_x = xx;
assign overlay_y = yy;
localparam XSTART = (1280 - 1080) / 2; // 1080:720 = 3:2
localparam XSTOP = (1280 + 1080) / 2;
localparam XSTART_O = (1280 - 960) / 2; // 960:720 = 4:3
localparam XSTOP_O = (1280 + 960) / 2;

// address calculation
// Assume the video occupies fully on the Y direction, we are upscaling the video by `720/height`.
Expand All @@ -154,19 +157,26 @@ always @(posedge clk_pixel) begin
ycnt_next = ycnt + (overlay ? 224 : height);

active_t = 0;
if (cx == XSTART - 1) begin
if (~overlay && cx == XSTART - 1 || overlay && cx == XSTART_O - 1) begin
active_t = 1;
active <= 1;
end else if (cx == XSTOP - 1) begin
end else if (~overlay && cx == XSTOP - 1 || overlay && cx == XSTOP_O - 1) begin
active_t = 0;
active <= 0;
end

if (active_t | active) begin // increment xx
xcnt <= xcnt_next;
if (xcnt_next >= 1080) begin
xcnt <= xcnt_next - 1080;
xx <= xx + 1;
if (overlay) begin
if (xcnt_next >= 960) begin
xcnt <= xcnt_next - 960;
xx <= xx + 1;
end
end else begin
if (xcnt_next >= 1080) begin
xcnt <= xcnt_next - 1080;
xx <= xx + 1;
end
end
end

Expand Down

0 comments on commit 5771a5f

Please sign in to comment.