-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColor_Mapper.sv
351 lines (315 loc) · 9.65 KB
/
Color_Mapper.sv
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
//-------------------------------------------------------------------------
// Color_Mapper.sv --
// Stephen Kempf --
// 3-1-06 --
// --
// Modified by David Kesler 07-16-2008 --
// Translated by Joe Meng 07-07-2013 --
// --
// Fall 2014 Distribution --
// --
// For use with ECE 385 Lab 7 --
// University of Illinois ECE Department --
//-------------------------------------------------------------------------
module color_mapper ( input [9:0] DrawX, DrawY,cloudX1, cloudY1,cloudX2, cloudY2, cloudW, cloudH,hp1_w, hp1_x, hp1_y, hp1_h,hp2_w, hp2_x, hp2_y, hp2_h,
player_h, player_w, player_x1, player_y1,player_x2, player_y2, ball_x1, ball_y1, ball_x2, ball_y2, ball_h, ball_w,
input [8:0] player_action1, player_action2, ball_action1, ball_action2,
input face1, face2, ball_face1, ball_face2, ending1, ending2, summoned_ball1, summoned_ball2,
input [0:39][0:79][0:3] cloud,
input [0:79][0:79][0:3] player_w0, player_w1, player_w2, player_w3,
player_j0, player_j1, player_j2,
player_a0, player_a1, player_a2,player_a3, player_a4, player_a5,
input [0:39][0:39][0:3] ball0, ball1, ball2,
output logic [7:0] Red, Green, Blue );
logic [3:0] cloud_on1, cloud_on2, player_on1, player_on2, ball_on1, ball_on2;
logic hp1_on,hp2_on, ground_on;
logic [9:0] vDraw1, vDraw2, hDraw1, hDraw2;
logic [9:0] vBallDraw1, hBallDraw1;
logic [9:0] vBallDraw2, hBallDraw2;
assign vDraw1 = DrawY-player_y1;
assign vDraw2 = DrawY-player_y2;
assign hDraw1 = face1 == 0 ? DrawX-player_x1 : 80-DrawX+player_x1;
assign hDraw2 = face2 == 0 ? DrawX-player_x2 : 80-DrawX+player_x2;
assign vBallDraw1 = DrawY-ball_y1;
assign hBallDraw1 = ball_face1 == 0 ? DrawX-ball_x1 : 40-DrawX+ball_x1;
assign vBallDraw2 = DrawY-ball_y2;
assign hBallDraw2 = ball_face2 == 0 ? DrawX-ball_x2 : 40-DrawX+ball_x2;
always_comb
begin:CloudSprite1
if ((DrawX >= cloudX1) && (DrawX <= cloudX1 + cloudW) && (DrawY >= cloudY1) &&(DrawY <= cloudY1 + cloudH))
begin
cloud_on1 = cloud[39-(DrawY-cloudY1)][79-(DrawX-cloudX1)];
end
else
begin
cloud_on1 = 4'b0;
end
end
always_comb
begin:CloudSprite2
if ((DrawX >= cloudX2) && (DrawX <= cloudX2 + cloudW) && (DrawY >= cloudY2) &&(DrawY <= cloudY2 + cloudH))
cloud_on2 = cloud[DrawY-cloudY2][DrawX-cloudX2];
else
cloud_on2 = 4'b0;
end
always_comb
begin:hp1
if((DrawX >= hp1_x) && (DrawX < hp1_x+hp1_w) &&(DrawY >= hp1_y) && (DrawY <= hp1_y + hp1_h) )
hp1_on = 1;
else
hp1_on = 0;
end
always_comb
begin:hp2
if((640-DrawX >= hp2_x) && (640-DrawX < hp2_x+hp2_w) &&(DrawY >= hp2_y) && (DrawY <= hp2_y + hp2_h))
begin
hp2_on = 1;
end
else
begin
hp2_on = 0;
end
end
always_comb
begin:ground
if(DrawY >= 380)
begin
ground_on = 1;
end
else begin
ground_on = 0;
end
end
always_comb
begin: player_draw
if ((DrawX >= player_x1) && (DrawX <= player_x1 + player_w) && (DrawY >= player_y1) &&(DrawY <= player_y1 + player_h))
begin
if(player_action1 <= 5)
player_on1 = player_w0[vDraw1][hDraw1];
else if(player_action1 <= 11)
player_on1 = player_w1[vDraw1][hDraw1];
else if (player_action1 <= 17)
player_on1 = player_w2[vDraw1][hDraw1];
else if(player_action1 <= 23)
player_on1 = player_w3[vDraw1][hDraw1];
else if (player_action1 <= 29)
player_on1 = player_j0[vDraw1][hDraw1];
else if (player_action1 <= 35)
player_on1 = player_j1[vDraw1][hDraw1];
else if (player_action1 <= 71)
player_on1 = player_j2[vDraw1][hDraw1];
else if (player_action1 <= 77)
player_on1 = player_j1[vDraw1][hDraw1];
else if (player_action1 <= 83)
player_on1 = player_j0[vDraw1][hDraw1];
else if (player_action1 <= 89)
player_on1 = player_w0[vDraw1][hDraw1];
else if (player_action1 <= 101)
player_on1 = player_a0[vDraw1][hDraw1];
else if (player_action1 <= 113)
player_on1 = player_a1[vDraw1][hDraw1];
else if (player_action1 <= 125)
player_on1 = player_a2[vDraw1][hDraw1];
else if (player_action1 <= 137)
player_on1 = player_a3[vDraw1][hDraw1];
else if (player_action1 <= 149)
player_on1 = player_a4[vDraw1][hDraw1];
else if (player_action1 <= 161)
player_on1 = player_a5[vDraw1][hDraw1];
else if (player_action1 <= 173)
player_on1 = player_a4[vDraw1][hDraw1];
else if (player_action1 <= 185)
player_on1 = player_w0[vDraw1][hDraw1];
else if (player_action1 <= 197)
player_on1 = player_a0[vDraw1][hDraw1];
else
player_on1 = player_a1[vDraw1][hDraw1];
end
else
player_on1 = 4'b0;
end
always_comb
begin: player_draw2
if ((DrawX >= player_x2) && (DrawX <= player_x2 + player_w) && (DrawY >= player_y2) &&(DrawY <= player_y2 + player_h))
begin
player_on2 = player_w0[vDraw2][hDraw2];
if(player_action2 <= 5)
player_on2 = player_w0[vDraw2][hDraw2];
else if(player_action2 <= 11)
player_on2 = player_w1[vDraw2][hDraw2];
else if (player_action2 <= 17)
player_on2 = player_w2[vDraw2][hDraw2];
else if(player_action2 <= 23)
player_on2 = player_w3[vDraw2][hDraw2];
else if (player_action2 <= 29)
player_on2 = player_j0[vDraw2][hDraw2];
else if (player_action2 <= 35)
player_on2 = player_j1[vDraw2][hDraw2];
else if (player_action2 <= 71)
player_on2 = player_j2[vDraw2][hDraw2];
else if (player_action2 <= 77)
player_on2 = player_j1[vDraw2][hDraw2];
else if (player_action2 <= 83)
player_on2 = player_j0[vDraw2][hDraw2];
else if (player_action2 <= 89)
player_on2 = player_w0[vDraw2][hDraw2];
else if (player_action2 <= 101)
player_on2 = player_a0[vDraw2][hDraw2];
else if (player_action2 <= 113)
player_on2 = player_a1[vDraw2][hDraw2];
else if (player_action2 <= 125)
player_on2 = player_a2[vDraw2][hDraw2];
else if (player_action2 <= 137)
player_on2 = player_a3[vDraw2][hDraw2];
else if (player_action2 <= 149)
player_on2 = player_a4[vDraw2][hDraw2];
else if (player_action2 <= 161)
player_on2 = player_a5[vDraw2][hDraw2];
else if (player_action2 <= 173)
player_on2 = player_a4[vDraw2][hDraw2];
else if (player_action2 <= 185)
player_on2 = player_w0[vDraw2][hDraw2];
else if (player_action2 <= 197)
player_on2 = player_a0[vDraw2][hDraw2];
else
player_on2 = player_a1[vDraw2][hDraw2];
end
else
player_on2 = 4'b0;
end
always_comb
begin:draw_ball1
if(summoned_ball1 && (DrawX >= ball_x1) &&(DrawX <= ball_x1 + ball_w) && (DrawY >= ball_y1) && (DrawY <= ball_y1 + ball_h)) begin
if(ball_action1 <= 5)
ball_on1 = ball0[vBallDraw1][hBallDraw1];
else if(ball_action1 <= 11)
ball_on1 = ball1[vBallDraw1][hBallDraw1];
else if(ball_action1 <= 17)
ball_on1 = ball2[vBallDraw1][hBallDraw1];
else
ball_on1 = ball0[vBallDraw1][hBallDraw1];
end
else
ball_on1 = 4'b0;
end
always_comb
begin:draw_ball2
if(summoned_ball2 && (DrawX >= ball_x2) &&(DrawX <= ball_x2 + ball_w) && (DrawY >= ball_y2) && (DrawY <= ball_y2 + ball_h)) begin
if(ball_action2 <= 5)
ball_on2 = ball0[vBallDraw2][hBallDraw2];
else if(ball_action2 <= 11)
ball_on2 = ball1[vBallDraw2][hBallDraw2];
else if(ball_action2 <= 17)
ball_on2 = ball2[vBallDraw2][hBallDraw2];
else
ball_on2 = ball0[vBallDraw2][hBallDraw2];
end
else
ball_on2 = 4'b0;
end
always_comb
begin:RGB_Display
if(cloud_on1 == 4'b0110)
begin
Red <= 8'hBD;
Green <= 8'hBD;
Blue <= 8'hBD;
end
else if(cloud_on1 == 4'b0100)
begin
Red <= 8'hFF;
Green <= 8'hFF;
Blue <= 8'hFF;
end
else if(cloud_on1 == 4'b0111)
begin
Red <= 8'hE7;
Green <= 8'hE7;
Blue <= 8'hE7;
end
else if(cloud_on2 == 4'b0110)
begin
Red <= 8'hBD;
Green <= 8'hBD;
Blue <= 8'hBD;
end
else if(cloud_on2 == 4'b0100)
begin
Red <= 8'hFF;
Green <= 8'hFF;
Blue <= 8'hFF;
end
else if(cloud_on2 == 4'b0111)
begin
Red <= 8'hE7;
Green <= 8'hE7;
Blue <= 8'hE7;
end
else if(hp1_on == 1||hp2_on == 1)
begin
Red <= 8'hFF;
Green <= 8'h00;
Blue <= 8'h00;
end
else if(ball_on1 == 4'b0001)
begin
Red<=8'hff;
Green<=8'hff;
Blue<=8'hff;
end
else if(ball_on1 == 4'b0010)
begin
Red<=8'ha6;
Green<=8'h08;
Blue<=8'h00;
end
else if(ball_on1 == 4'b0011)
begin
Red<=8'hff;
Green<=8'he2;
Blue<=8'h00;
end
else if(ball_on2 == 4'b0001)
begin
Red<=8'hff;
Green<=8'hff;
Blue<=8'hff;
end
else if(ball_on2 == 4'b0010)
begin
Red<=8'hb1;
Green<=8'h9c;
Blue<=8'hd9;
end
else if(ball_on2 == 4'b0011)
begin
Red<=8'h6c;
Green<=8'h00;
Blue<=8'h6c;
end
else if(ground_on == 1)
begin
Red <= 8'h66;
Green <= 8'h33;
Blue <= 8'h00;
end
else if(player_on1==4'b1 && ending1 == 1)
begin
Red <= 8'hdc;
Green <= 8'h14;
Blue <= 8'h3c;
end
else if(player_on2==4'b1 && ending2 == 1)
begin
Red <= 8'h00;
Green <= 8'h00;
Blue <= 8'h84;
end
else
begin
Red = 8'h0;
Green = 8'hBF;
Blue = 8'hFF;
end
end
endmodule