Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 178 lines (153 sloc) 4.218 kb
c5b7afc initiale arbeit getan, coole compentalisierung, außerdem geilomat hinter...
unknown authored
1 library IEEE;
2 use IEEE.STD_LOGIC_1164.ALL;
3 use IEEE.STD_LOGIC_ARITH.ALL;
4 use IEEE.STD_LOGIC_UNSIGNED.ALL;
5
6 entity ball is
c84bbf3 hold on key p
Bubu authored
7 Port ( speed : in std_logic_vector (1 downto 0);
8 hold : in std_logic;
02a3f36 @timfel Revert "this was supposed to add stopping after 9 points, but that didnt...
timfel authored
9 bar_left : in integer range 0 to 430;
10 bar_right : in integer range 0 to 430;
11 X : in integer range 0 to 640;
68716fe game_over_handler integrated into ball and inverter, game_over is now ba...
unknown authored
12 Y : in integer range 0 to 480;
df98831 back to seperate ball_out_handler...
unknown authored
13 ball_out : out bit;
02a3f36 @timfel Revert "this was supposed to add stopping after 9 points, but that didnt...
timfel authored
14 rgb_in : in STD_LOGIC_VECTOR (2 downto 0);
15 rgb_out : out STD_LOGIC_VECTOR (2 downto 0);
68716fe game_over_handler integrated into ball and inverter, game_over is now ba...
unknown authored
16 clk25 : in bit;
31cad9b synchronous pause key and pause omn start and gameover fnally working
unknown authored
17 reset : in bit;
3b4b1d6 added _very_ simple AI
unknown authored
18 forward_game_over : out std_logic;
19 ball_y_pos_out: out integer range 0 to 480);
c5b7afc initiale arbeit getan, coole compentalisierung, außerdem geilomat hinter...
unknown authored
20 end ball;
21
2238a9a @timfel YEAH! FUCK! 8 backgrounds and numerals
timfel authored
22 architecture Behavioral of ball is
23
9cdc863 @timfel nice
timfel authored
24 component score is
02a3f36 @timfel Revert "this was supposed to add stopping after 9 points, but that didnt...
timfel authored
25 Port( pointLeft : in bit;
26 pointRight : in bit;
182cefe ...
unknown authored
27 X : in integer range 0 to 640;
28 Y : in integer range 0 to 480;
02a3f36 @timfel Revert "this was supposed to add stopping after 9 points, but that didnt...
timfel authored
29 rgb_in : in STD_LOGIC_VECTOR (2 downto 0);
30 rgb_out: out STD_LOGIC_VECTOR (2 downto 0);
31 clk25 : in bit;
31cad9b synchronous pause key and pause omn start and gameover fnally working
unknown authored
32 reset : in bit;
68716fe game_over_handler integrated into ball and inverter, game_over is now ba...
unknown authored
33 game_over : out std_logic);
2238a9a @timfel YEAH! FUCK! 8 backgrounds and numerals
timfel authored
34 end component;
9cdc863 @timfel nice
timfel authored
35
3681e76 @timfel Actually playing works now
timfel authored
36 signal lr : bit := '0'; --left/right
2238a9a @timfel YEAH! FUCK! 8 backgrounds and numerals
timfel authored
37 signal ud : bit := '1'; --up/down
62f01f3 @timfel Some more work, like stopping at the end and a round ball!
timfel authored
38 signal deltaX, deltaY : integer range 0 to 640;
075cee3 @timfel still working on gameover
timfel authored
39 signal x_pos : integer range 0 to 640 := 320;
40 signal y_pos : integer range 0 to 480 := 240;
c84bbf3 hold on key p
Bubu authored
41 signal countUp : integer range 0 to 208000 := 0;
0c59d20 works with ps2
Bubu authored
42 signal speedCount : std_logic_vector (1 downto 0);
68716fe game_over_handler integrated into ball and inverter, game_over is now ba...
unknown authored
43 signal ballOut : bit;
430b4b7 flashing on game_over
unknown authored
44 signal ballOut1 : bit;
45 signal ballOut2 : bit;
2238a9a @timfel YEAH! FUCK! 8 backgrounds and numerals
timfel authored
46 signal leftOut, rightOut : bit := '0';
9cdc863 @timfel nice
timfel authored
47 signal intern_rgb : STD_LOGIC_VECTOR (2 downto 0);
430b4b7 flashing on game_over
unknown authored
48 signal intern_game_over: std_logic;
49 signal game_over_count : integer range 0 to 25000000 := 12500000;
df98831 back to seperate ball_out_handler...
unknown authored
50
c5b7afc initiale arbeit getan, coole compentalisierung, außerdem geilomat hinter...
unknown authored
51 begin
2238a9a @timfel YEAH! FUCK! 8 backgrounds and numerals
timfel authored
52
3490d17 @timfel we have real score. i think
timfel authored
53 count : score port map (
54 pointLeft => rightOut,
55 pointRight => leftOut,
9cdc863 @timfel nice
timfel authored
56 X => X,
2238a9a @timfel YEAH! FUCK! 8 backgrounds and numerals
timfel authored
57 Y => Y,
9cdc863 @timfel nice
timfel authored
58 rgb_in => rgb_in,
59 rgb_out => intern_rgb,
2238a9a @timfel YEAH! FUCK! 8 backgrounds and numerals
timfel authored
60 clk25 => clk25,
31cad9b synchronous pause key and pause omn start and gameover fnally working
unknown authored
61 reset => reset,
430b4b7 flashing on game_over
unknown authored
62 game_over => intern_game_over);
3b4b1d6 added _very_ simple AI
unknown authored
63
64 ball_y_pos_out <= y_pos; -- for AI
182cefe ...
unknown authored
65
430b4b7 flashing on game_over
unknown authored
66 game_over: process (intern_game_over, ballOut1, ballOut2)
67 begin
68 if clk25'event and clk25='1' then
69 if intern_game_over = '1' then
70 game_over_count <= game_over_count + 1;
71 if game_over_count > 12500000 then
72 ballOut2 <= '1';
73 else ballOut2 <= '0'; end if;
74 if game_over_count = 25000000 then game_over_count <= 0; end if;
75 end if;
76 end if;
77 end process game_over;
78
79 ballOut <= ballOut1 or ballOut2;
80 forward_game_over <= intern_game_over;
c5b7afc initiale arbeit getan, coole compentalisierung, außerdem geilomat hinter...
unknown authored
81
11fde3b added sensitivity lists, removed useless signals
unknown authored
82 process (intern_rgb, x_pos, y_pos, clk25,X,Y)
c5b7afc initiale arbeit getan, coole compentalisierung, außerdem geilomat hinter...
unknown authored
83 begin
9cdc863 @timfel nice
timfel authored
84 rgb_out <= intern_rgb;
2238a9a @timfel YEAH! FUCK! 8 backgrounds and numerals
timfel authored
85
86 if (x_pos > X - 8)
87 and (x_pos < X + 8)
88 and (y_pos > Y - 8)
075cee3 @timfel still working on gameover
timfel authored
89 and (y_pos < Y + 8) then
90 if (x_pos > X) then
91 deltaX <= x_pos - X + 1;
92 else
93 deltaX <= X - x_pos;
94 end if;
95 if (y_pos > Y) then
96 deltaY <= y_pos - Y + 1;
97 else
98 deltaY <= Y - y_pos;
99 end if;
c5b7afc initiale arbeit getan, coole compentalisierung, außerdem geilomat hinter...
unknown authored
100
075cee3 @timfel still working on gameover
timfel authored
101 if ((deltaY * deltaY) + (deltaX * deltaX)) < 64 then
102 rgb_out <= "001";
2238a9a @timfel YEAH! FUCK! 8 backgrounds and numerals
timfel authored
103 end if;
c5b7afc initiale arbeit getan, coole compentalisierung, außerdem geilomat hinter...
unknown authored
104 end if;
62f01f3 @timfel Some more work, like stopping at the end and a round ball!
timfel authored
105
c5b7afc initiale arbeit getan, coole compentalisierung, außerdem geilomat hinter...
unknown authored
106 if clk25'event and clk25='1' then --for movement
107 countUp <= countUp + 1;
430b4b7 flashing on game_over
unknown authored
108 ballOut1 <= reset;
c84bbf3 hold on key p
Bubu authored
109 if countUp = 52000 then
0c59d20 works with ps2
Bubu authored
110 if speedCount = (not speed(1) & not speed(0)) then
c84bbf3 hold on key p
Bubu authored
111 speedCount <= "00";
0c59d20 works with ps2
Bubu authored
112
113 if x_pos < 27 then
114 if (bar_left < y_pos
115 and bar_left + 50 > y_pos) then
116 lr <= '1';
117 else
118 if x_pos < 9 then
119 leftOut <= '1';
430b4b7 flashing on game_over
unknown authored
120 ballOut1 <= '1';
0c59d20 works with ps2
Bubu authored
121 end if;
62f01f3 @timfel Some more work, like stopping at the end and a round ball!
timfel authored
122 end if;
3681e76 @timfel Actually playing works now
timfel authored
123 end if;
0c59d20 works with ps2
Bubu authored
124
125 if x_pos > 611 then
126 if (bar_right < y_pos
127 and bar_right + 50 > y_pos) then
128 lr <= '0';
129 else
130 if x_pos > 631 then
131 rightOut <= '1';
430b4b7 flashing on game_over
unknown authored
132 ballOut1 <= '1';
0c59d20 works with ps2
Bubu authored
133 end if;
62f01f3 @timfel Some more work, like stopping at the end and a round ball!
timfel authored
134 end if;
3681e76 @timfel Actually playing works now
timfel authored
135 end if;
62f01f3 @timfel Some more work, like stopping at the end and a round ball!
timfel authored
136
0c59d20 works with ps2
Bubu authored
137 if y_pos = 9 then
138 ud <= '1';
139 end if;
140 if y_pos = 471 then
141 ud <= '0';
142 end if;
143
144 if hold = '0' then
145 case lr is
146 when '0' => x_pos <= x_pos - 1;
147 when '1' => x_pos <= x_pos + 1;
148 end case;
149
150 case ud is
151 when '0' => y_pos <= y_pos - 1;
152 when '1' => y_pos <= y_pos + 1;
153 end case;
154 end if;
c84bbf3 hold on key p
Bubu authored
155 else
156 speedCount <= speedCount + "01";
157 end if;
0c59d20 works with ps2
Bubu authored
158 countUp <= 0;
159 end if;
160
68716fe game_over_handler integrated into ball and inverter, game_over is now ba...
unknown authored
161 if ballOut = '1' then -- this has to come synchronized for counting to work
ec6a5cf @timfel fix point counting
timfel authored
162 leftOut <= '0';
163 rightOut <= '0';
164 x_pos <= 320;
165 y_pos <= 240;
68716fe game_over_handler integrated into ball and inverter, game_over is now ba...
unknown authored
166 ball_out <= '1';
ec6a5cf @timfel fix point counting
timfel authored
167 else
68716fe game_over_handler integrated into ball and inverter, game_over is now ba...
unknown authored
168 ball_out <= '0';
0c59d20 works with ps2
Bubu authored
169 end if;
ec6a5cf @timfel fix point counting
timfel authored
170
c5b7afc initiale arbeit getan, coole compentalisierung, außerdem geilomat hinter...
unknown authored
171 end if;
172 end process;
173
174 end Behavioral;
175
176
177
Something went wrong with that request. Please try again.