Skip to content

Commit

Permalink
Ritar perfekt, lagt till fforsta kod for sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
richardwiden committed Apr 23, 2012
1 parent 01fe1ec commit b29dcf6
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 20 deletions.
37 changes: 30 additions & 7 deletions FirstGraphicTest.vhd
Expand Up @@ -54,8 +54,8 @@ architecture Behavioral of FirstGraphicTest is
spriteVgaRed: in std_logic_vector(2 downto 0);
spriteVgaGreen: in std_logic_vector(2 downto 0);
spriteVgaBlue: in std_logic_vector(2 downto 1);
y : in integer range 0 to 521;
x : in integer range 0 to 800;
y : in integer range 0 to 520;
x : in integer range 0 to 799;
vgaRed: OUT std_logic_vector(2 downto 0);
vgaGreen: OUT std_logic_vector(2 downto 0);
vgaBlue: OUT std_logic_vector(2 downto 1)
Expand All @@ -68,10 +68,23 @@ architecture Behavioral of FirstGraphicTest is
rst : IN std_logic;
vsynk : OUT std_logic;
hsynk : OUT std_logic;
y : inout integer range 0 to 521;
x : inout integer range 0 to 800
y : inout integer range 0 to 520;
x : inout integer range 0 to 799
);
END COMPONENT;

COMPONENT SpriteGpu
PORT( clk : in STD_LOGIC;
x : in integer;
y : in integer;
spriteVgaRed: out std_logic_vector(2 downto 0);
spriteVgaGreen: out std_logic_vector(2 downto 0);
spriteVgaBlue: out std_logic_vector(2 downto 1);
collision: out std_logic;
rst : in STD_LOGIC);

END COMPONENT;


--Inputs

Expand All @@ -84,8 +97,8 @@ architecture Behavioral of FirstGraphicTest is
signal spriteVgaGreen: std_logic_vector(2 downto 0) := (others => '1');
signal spriteVgaBlue: std_logic_vector(2 downto 1) := (others => '0');

signal y : integer range 0 to 521 := 0 ;
signal x : integer range 0 to 800 := 0 ;
signal y : integer range 0 to 520 := 0 ;
signal x : integer range 0 to 799 := 0 ;



Expand All @@ -95,6 +108,7 @@ architecture Behavioral of FirstGraphicTest is
-- Clock period definitions
constant clk_period : time := 1 ns;
signal resetcounter : integer range 0 to 20 :=0;
signal collision : std_logic;
begin
picker: GraphicsPicker PORT MAP (
clk => clk,
Expand All @@ -119,7 +133,16 @@ begin
x => x,
y => y
);

gpu: SpriteGpu PORT MAP (
clk => clk,
rst => rst,
x => x,
y => y,
spriteVgaRed=> spriteVgaRed,
spriteVgaGreen=> spriteVgaGreen,
spriteVgaBlue=> spriteVgaBlue,
collision=> collision
);
clk_process :process

begin
Expand Down
33 changes: 24 additions & 9 deletions GraphicsPicker.vhd
Expand Up @@ -40,28 +40,43 @@ entity GraphicsPicker is
spriteVgaRed: in std_logic_vector(2 downto 0);
spriteVgaGreen: in std_logic_vector(2 downto 0);
spriteVgaBlue: in std_logic_vector(2 downto 1);
y : in integer range 0 to 521;
x : in integer range 0 to 800;
y : in integer range 0 to 520;
x : in integer range 0 to 799;
vgaRed: OUT std_logic_vector(2 downto 0);
vgaGreen: OUT std_logic_vector(2 downto 0);
vgaBlue: OUT std_logic_vector(2 downto 1)
);
end GraphicsPicker;

architecture Behavioral of GraphicsPicker is
signal whiteVgaRed: std_logic_vector(2 downto 0) := "111";
signal whiteVgaGreen: std_logic_vector(2 downto 0) := "000";
signal whiteVgaBlue: std_logic_vector(2 downto 1) := "00";
signal blackVgaRed: std_logic_vector(2 downto 0) := "000";
signal blackVgaGreen: std_logic_vector(2 downto 0) := "000";
signal blackVgaBlue: std_logic_vector(2 downto 1) := "11";

begin

process(clk)
begin
if rising_edge(clk) then
if y>200 and x>200 then
vgaRed<=spriteVgaRed;
vgaGreen<=spriteVgaGreen;
vgaBlue<=spriteVgaBlue;
if y>200 and y<480 then
if x<640 then
vgaRed<=spriteVgaRed;
vgaGreen<=spriteVgaGreen;
vgaBlue<=spriteVgaBlue;
end if;
elsif y<=200 then
if x<640 then
vgaRed<=tileVgaRed;
vgaGreen<=tileVgaGreen;
vgaBlue<=tileVgaBlue;
end if;
else
vgaRed<=tileVgaRed;
vgaGreen<=tileVgaGreen;
vgaBlue<=tileVgaBlue;
vgaRed<="000";
vgaGreen<="000";
vgaBlue<="00";
end if;
end if;
end process;
Expand Down
8 changes: 4 additions & 4 deletions sraknare.vhd
Expand Up @@ -33,8 +33,8 @@
rst : in STD_LOGIC;
vsynk : out STD_LOGIC;
hsynk : out STD_LOGIC;
y : inout integer range 0 to 521;
x : inout integer range 0 to 800
y : inout integer range 0 to 520;
x : inout integer range 0 to 799
);
end sraknare;
architecture Behavioral of sraknare is
Expand All @@ -60,9 +60,9 @@ else
counter <= 3;
else
counter <= 0;
if x=800 then --800
if x=799 then --800
x<=0; --0
if y=521 then --521
if y=520 then --521
y<=0; --0
else
y<=y + 1;
Expand Down

0 comments on commit b29dcf6

Please sign in to comment.