Skip to content

Commit

Permalink
Added pad overlay and new OSD structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
zwenergy committed Dec 23, 2023
1 parent 7b44c3f commit c3a8f88
Show file tree
Hide file tree
Showing 11 changed files with 505 additions and 171 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ To create a stable video signal without buffering whole frames, but rather
go line-by-line, the quartz crystal of the GBA is removed. Instead,
the FPGA generates the clock signal for the GBA.

## Note
The latest bitstream (v1.4A) only works in conjunction with a Mancloud
shield. I will update the Arduino FW in the upcoming days, so the latest
bitstream can be used with all gbaHD.

## Wiring
You need some basic soldering skills to wire all signals of the GBA to the
FPGA board and the controller to the Arduino. All responsibility is on
Expand Down
Binary file modified bitstream/default_1080p.bit
Binary file not shown.
Binary file modified bitstream/default_480p.bit
Binary file not shown.
Binary file modified bitstream/default_720p.bit
Binary file not shown.
78 changes: 65 additions & 13 deletions hdl/commTransceiver.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use IEEE.std_logic_misc.ALL;

entity commTransceiver is
generic(
packetBits : integer := 8;
packetBits : integer := 16;
clkFreq0 : real; -- kHz
clkFreq1 : real; -- kHz
clkFreqMax : real; -- kHz
Expand All @@ -27,8 +27,23 @@ entity commTransceiver is

--serDatOut : out std_logic;
--txActive : out std_logic;
controllerOut : out std_logic_vector( 5 downto 0 );
controllerOut : out std_logic_vector( 9 downto 0 );
controllerOSDActive : out std_logic;

osdActive : out std_logic;
osdState : out std_logic_vector( 7 downto 0 );
osdStateValid : out std_logic;

-- Settings
osdSmooth2x : out std_logic;
osdSmooth4x : out std_logic;
osdGridActive : out std_logic;
osdGridBright : out std_logic;
osdGridMult : out std_logic;
osdColorCorrection : out std_logic;
osdRate : out std_logic;
osdSettingsValid : out std_logic;

rxValid : out std_logic
);

Expand All @@ -43,6 +58,11 @@ architecture rtl of commTransceiver is
constant cyclesHalfBit0 : integer := cyclesBit0 / 2;
constant cyclesHalfBit1 : integer := cyclesBit1 / 2;

constant prefixLen : integer := 4;
constant controllerOSD_prefix : std_logic_vector( prefixLen - 1 downto 0 ) := "1000";
constant config_prefix : std_logic_vector( prefixLen - 1 downto 0 ) := "0100";
constant osdState_prefix : std_logic_vector( prefixLen - 1 downto 0 ) := "0010";

-- Timeout counter.
signal timeoutCnt : integer range 0 to cyclesTimeout;
-- Bit counter.
Expand All @@ -54,14 +74,11 @@ architecture rtl of commTransceiver is

signal serDatInPrev, serDatIn_filtered : std_logic;
signal serDatFilter : std_logic_vector( 7 downto 0 );
signal osdActive_int : std_logic;


-- A few status bits.
signal rxPacket : std_logic;

begin

osdActive <= osdActive_int;


-- Synch. part.
Expand All @@ -75,10 +92,24 @@ begin
newPacket <= '0';
serDatInPrev <= '0';
rxPacket <= '0';
osdActive_int <= '0';
controllerOut <= ( others => '0' );
rxValid <= '0';
serDatFilter <= ( others => '1' );

controllerOut <= ( others => '0' );
controllerOSDActive <= '0';
osdActive <= '0';
osdState <= ( others => '0' );
osdStateValid <= '0';
osdSmooth2x <= '0';
osdSmooth4x <= '0';
osdGridActive <= '0';
osdGridBright <= '0';
osdGridMult <= '0';
osdColorCorrection <= '0';
osdRate <= '0';
osdSettingsValid <= '0';

serDatIn_filtered <= '1';
--serDatOut <= '1';
--txActive <= '0';
Expand Down Expand Up @@ -127,17 +158,38 @@ begin

-- Controller output related stuff.
if ( newPacket = '1' ) then
controllerOut <= curPacket( packetBits - 1 downto packetBits - 6 );

if ( curPacket( packetBits - 7 ) = '1' ) then
osdActive_int <= '1';
else
osdActive_int <= '0';

-- On screen buttons?
if ( curPacket( packetBits - 1 downto packetBits - prefixLen ) = controllerOSD_prefix ) then
controllerOut <= curPacket( 9 downto 0 );

-- Settings packet?
elsif ( curPacket( packetBits - 1 downto packetBits - prefixLen ) = config_prefix ) then
osdSmooth2x <= curPacket( 0 );
osdSmooth4x <= curPacket( 1 );
osdGridActive <= curPacket( 2 );
osdGridBright <= curPacket( 3 );
osdGridMult <= curPacket( 4 );
osdColorCorrection <= curPacket( 5 );
osdRate <= curPacket( 6 );
controllerOSDActive <= curPacket( 7 );
osdSettingsValid <= '1';

-- OSD state?
elsif ( curPacket( packetBits - 1 downto packetBits - prefixLen ) = osdState_prefix ) then
osdActive <= curPacket( 0 );
osdState( 6 downto 0 ) <= curPacket( 7 downto 1 );
osdState( 7 ) <= '0';
osdStateValid <= '1';

end if;

rxValid <= '1';
else
rxValid <= '0';
osdSettingsValid <= '0';
osdStateValid <= '0';

end if;

end if;
Expand Down
12 changes: 9 additions & 3 deletions hdl/font5x7.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use IEEE.STD_LOGIC_1164.ALL;

entity font5x7 is
port(
char : in integer range 0 to 37;
char : in integer range 0 to 43;
x : in integer range 0 to 4;
y : in integer range 0 to 6;

Expand All @@ -20,7 +20,7 @@ entity font5x7 is
end entity;

architecture rtl of font5x7 is
type tFontRAM is array( 0 to 37 ) of std_logic_vector( 0 to 34 );
type tFontRAM is array( 0 to 43 ) of std_logic_vector( 0 to 34 );
constant font : tFontRAM :=
( "00000000000000000000000000000000000", -- 0, Space
"01110100011000111111100011000110001", -- 1, A
Expand Down Expand Up @@ -59,7 +59,13 @@ constant font : tFontRAM :=
"01110100011000101110100011000101110", -- 34, 8
"01110100011000101111000010000100001", -- 35, 9
"00000000000000000000000000000000100", -- 36, .
"00000010000010000010001000100000000" -- 37, >
"00000010000010000010001000100000000", -- 37, >
"00000000100010001000001000001000000", -- 38, <
"00001000100001000100010000100010000", -- 39, /
"10000010000100000100000100001000001", -- 40, \
"00100001000010000100001000010000100", -- 41, |
"00000001000010000000001000010000000", -- 42, :
"00000000000000011111000000000000000" -- 43, -
);
begin

Expand Down
85 changes: 71 additions & 14 deletions hdl/imageGen.sv
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,20 @@ module imageGenV
input logic audioRIn,

input logic osdEnable,
input logic controllerRXValid,
input logic [5:0] controller,
input logic rxValid,
input logic [9:0] controller,
input logic controllerOSDActive,

input logic [7:0] osdState,
input logic osdStateValid,
input logic osdSmooth2x,
input logic osdSmooth4x,
input logic osdGridActive,
input logic osdGridBright,
input logic osdGridMult,
input logic osdColorCorrection_in,
input logic osdRate_in,
input logic osdSettingsValid,

output logic colorMode,
output logic framerate,
Expand Down Expand Up @@ -238,6 +250,9 @@ begin
end

// Choose which signal outlet.
logic overlayInact;
logic overlayAct;

always_comb
begin
if( drawOSD ) begin
Expand All @@ -251,7 +266,7 @@ begin
greenPxl <= gridGreen;
bluePxl <= gridBlue;

end else if ( smooth2x || smooth4x ) begin
end else if ( ( smooth2x || smooth4x ) && SMOOTHENABLE ) begin
redPxl <= smoothRed;
greenPxl <= smoothGreen;
bluePxl <= smoothBlue;
Expand All @@ -267,6 +282,20 @@ begin
greenPxl <= borderGreen;
bluePxl <= borderBlue;
end

if ( controllerOSDActive ) begin
if ( overlayInact ) begin
redPxl <= 8'b11111111;
greenPxl <= 8'b11111111;
bluePxl <= 8'b11111111;
end

if ( overlayAct ) begin
redPxl <= 8'b11111111;
greenPxl <= 0;
bluePxl <= 0;
end
end
end


Expand Down Expand Up @@ -330,28 +359,56 @@ smooth4x ( .rTL( prevLinePrevPxlRedIn ),


// OSD.
osd #( .smoothEnable( SMOOTHENABLE ),
.scale( maxScaleCnt + 1 ),
osd #( .scale( maxScaleCnt + 1 ),
.frameWidth( FRAMEWIDTH ),
.frameHeight( FRAMEHEIGHT ) )
osd ( .pxlX( cx ),
.pxlY( cy ),
.controller( controller ),
// .controller( controller ),
.osdEnableIn( osdEnable ),
.rxValid( controllerRXValid ),
.rxValid( rxValid ),
.clk( pxlClk ),
.rst( rst ),
.osdEnableOut( drawOSD ),
.osdRed( osdRed ),
.osdGreen( osdGreen ),
.osdBlue( osdBlue ),
.smooth2x( smooth2x ),
.smooth4x( smooth4x ),
.pixelGrid( pxlGrid ),
.bgrid( brightGrid ),
.gridMult( gridMult ),
.colorMode( colorMode ),
.rate( framerate ) );

.smooth2xIn( osdSmooth2x ),
.smooth4xIn( osdSmooth4x ),
.pixelGridIn( osdGridActive ),
.bgridIn( osdGridBright ),
.gridMultIn( osdGridMult ),
.colorModeIn( osdColorCorrection_in ),
.rateIn( osdRate_in ),
.controllerOSDActive( controllerOSDActive ),

.smooth2xOut( smooth2x ),
.smooth4xOut( smooth4x ),
.pixelGridOut( pxlGrid ),
.bgridOut( brightGrid ),
.gridMultOut( gridMult ),
.colorModeOut( colorMode ),
.rateOut( framerate ),

.osdState( osdState ),
.configValid( osdSettingsValid ),
.stateValid( osdStateValid )
);

// Pad overlay.
padOverlay #( .posX( 10 ),
.posY( 10 ),
.scale( maxScaleCnt + 1 ),
.frameWidth( FRAMEWIDTH ),
.frameHeight( FRAMEHEIGHT ) )
padOverlay ( .pxlX( cx ),
.pxlY( cy ),
.buttons( controller ),
.clk( pxlClk ),
.rst( rst ),
.overlayInact( overlayInact ),
.overlayAct( overlayAct ) );


// Border gen.
Expand Down
Loading

0 comments on commit c3a8f88

Please sign in to comment.