-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframe.sv.bak
84 lines (73 loc) · 3.15 KB
/
frame.sv.bak
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
module frame( input Clk, // 50 MHz clock
Reset, // Active-high reset signal
frame_clk, // The clock indicating a new frame (~60Hz)
input [9:0] DrawX, DrawY, fighter_X_Pos, fighter_Y_Pos,
output logic [7:0] VGA_R, VGA_G, VGA_B )
logic [9:0] frame_X_Pos = 10'd0; // Leftmost point on the X axis
logic [9:0] frame_Y_Pos = 10'd0; // Topmost point on the Y axis
logic [9:0] frame_Height = 10'd479; // frame height
logic [9:0] frame_Width = 10'd639;
logic [0:5] color, next_color;
logic [0:11][0:143][0:1] dive_health_bar, kick_health_bar;
logic [0:479][0:639][0:5] image;
logic [0:71][0:104][0:5] player1;
background background_instance(
.clk(clk),
.dive_health_bar(dive_health_bar),
.kick_health_bar(kick_health_bar)
.background(image));
color_mapper( .color(color),
.VGA_R(VGA_R),
.VGA_G(VGA_G),
.VGA_B(VGA_B));
logic frame_clk_delayed, frame_clk_rising_edge;
always_ff @ (posedge Clk)
begin
frame_clk_delayed <= frame_clk;
frame_clk_rising_edge <= (frame_clk == 1'b1) && (frame_clk_delayed == 1'b0);
if (Reset)
begin
color <= next_color;
end
else
begin
color <= next_color
end
end
logic [9:0] frame_currentX, frame_currentY;
assign frame_currentX <= frame_X_Pos + DrawX;
assign frame_currentX <= frame_Y_Pos + DrawY;
logic [9:0] health_bottom = 10'd22;
logic [9:0] health_top = 10'd10;
logic [9:0] left_bar_left = 10'd10;
logic [9:0] left_bar_right = 10'd154;
logic [9:0] right_bar_left = 10'd486;
logic [9:0] right_bar_right = 10'd630;
logic [9:0] fighter_Height = 10'd105; // fighter height
logic [9:0] fighter_Width = 10'd72; // fighter width
logic [9:0] fighter_current_x, fighter_current_y;
assign fighter_current_x = fighter_X_Pos;
always_comb
begin
// if (frame_clk_rising_edge)
// begin
// end
if(((DrawY<=health_bottom) && (DrawY>health_top))&& ((DrawX>=left_bar_left) && (DrawX<left_bar_right)))
begin
next_color = dive_health_bar[DrawY-health_bottom][DrawX-left_bar_left];
end
else if(((DrawY<=health_bottom) && (DrawY>health_top))&& ((DrawX>=right_bar_left) && (DrawX<right_bar_right)))
begin
next_color = kick_health_bar[DrawY-health_bottom][DrawX-right_bar_left];
end
else if((fighter_X_Pos>=DrawX && fighter_X_Pos+fighter_Width<DrawX ) &&(fighter_Y_Pos>=DrawY&& fighter_Y_Pos+fighter_Height<DrawY))
begin
next_color = 5'd3;
end
else
begin
// next_color = background[frame_currentY][frame_currentX];
next_color = 5'd7;
end
end
endmodule