OpenCores
URL https://opencores.org/ocsvn/2d_game_console/2d_game_console/trunk

Subversion Repositories 2d_game_console

[/] [2d_game_console/] [trunk/] [Processor_ModelSim/] [Sprite_Processor.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 lucas.vbal
module Sprite_Processor(
2
        R_in,
3
        G_in,
4
        B_in,
5
        clk,
6
        rst,
7
        sprite_id,
8
        sprite_x,
9
        sprite_y,
10
        sprite_color,
11
        sprite_shape,
12
        V_pos_in,
13
        H_pos_in,
14
 
15
        R_out,
16
        G_out,
17
        B_out
18
);
19
 
20
 
21
        input clk;
22
        input rst;
23
        input   [7:0]            R_in;
24
        input   [7:0]            G_in;
25
        input   [7:0]            B_in;
26
        input   [9:0]            H_pos_in;
27
        input   [9:0]            V_pos_in;
28
 
29
        input   [383:0]  sprite_id;
30
        input   [639:0]  sprite_x;
31
        input   [639:0]  sprite_y;
32
        input   [1023:0] sprite_color;
33
        input   [1023:0] sprite_shape;
34
 
35
        output  reg     [7:0]            R_out;
36
        output  reg     [7:0]            G_out;
37
        output  reg     [7:0]            B_out;
38
 
39
 
40
 
41
        always @ (posedge clk)
42
        begin
43
 
44
                if (rst)
45
                begin
46
 
47
                end
48
 
49
                else
50
                begin
51
                        // SPRITE LEVEL 15 - START
52
                        if      (
53
                                V_pos_in >= sprite_y[(15*10)+9 : 15*10] &&
54
                                V_pos_in <= sprite_y[(15*10)+9 : 15*10] + 15 &&
55
                                H_pos_in >= sprite_x[(15*10)+9 : 15*10] &&
56
                                H_pos_in <= sprite_x[(15*10)+9 : 15*10] + 15 &&
57
                                sprite_shape[ (15*16) + 15 - (H_pos_in - sprite_x[(15*10)+9 : 15*10]) ]
58
                                )
59
                        begin
60
                                R_out [2:0]      <=      3'b000;
61
                                G_out [1:0]      <=      2'b00;
62
                                B_out [2:0]      <=      3'b000;
63
                                R_out   [7:3]   <=      sprite_color[(15*16)+4  : (15*16)+0];
64
                                G_out   [7:2]   <=      sprite_color[(15*16)+10 : (15*16)+5];
65
                                B_out   [7:3]   <=      sprite_color[(15*16)+15 : (15*16)+11];
66
                        end
67
 
68
                        else
69
                        begin
70
 
71
                        // SPRITE LEVEL 14 - START
72
                        if      (
73
                                V_pos_in >= sprite_y[(14*10)+9 : 14*10] &&
74
                                V_pos_in <= sprite_y[(14*10)+9 : 14*10] + 15 &&
75
                                H_pos_in >= sprite_x[(14*10)+9 : 14*10] &&
76
                                H_pos_in <= sprite_x[(14*10)+9 : 14*10] + 15 &&
77
                                sprite_shape[ (14*16) + 15 - (H_pos_in - sprite_x[(14*10)+9 : 14*10]) ]
78
                                )
79
                        begin
80
                                R_out [2:0]      <=      3'b000;
81
                                G_out [1:0]      <=      2'b00;
82
                                B_out [2:0]      <=      3'b000;
83
                                R_out   [7:3]   <=      sprite_color[(14*16)+4  : (14*16)+0];
84
                                G_out   [7:2]   <=      sprite_color[(14*16)+10 : (14*16)+5];
85
                                B_out   [7:3]   <=      sprite_color[(14*16)+15 : (14*16)+11];
86
                        end
87
 
88
                        else
89
                        begin
90
 
91
                        // SPRITE LEVEL 13 - START
92
                        if      (
93
                                V_pos_in >= sprite_y[(13*10)+9 : 13*10] &&
94
                                V_pos_in <= sprite_y[(13*10)+9 : 13*10] + 15 &&
95
                                H_pos_in >= sprite_x[(13*10)+9 : 13*10] &&
96
                                H_pos_in <= sprite_x[(13*10)+9 : 13*10] + 15 &&
97
                                sprite_shape[ (13*16) + 15 - (H_pos_in - sprite_x[(13*10)+9 : 13*10]) ]
98
                                )
99
                        begin
100
                                R_out [2:0]      <=      3'b000;
101
                                G_out [1:0]      <=      2'b00;
102
                                B_out [2:0]      <=      3'b000;
103
                                R_out   [7:3]   <=      sprite_color[(13*16)+4  : (13*16)+0];
104
                                G_out   [7:2]   <=      sprite_color[(13*16)+10 : (13*16)+5];
105
                                B_out   [7:3]   <=      sprite_color[(13*16)+15 : (13*16)+11];
106
                        end
107
 
108
                        else
109
                        begin
110
 
111
                        // SPRITE LEVEL 12 - START
112
                        if      (
113
                                V_pos_in >= sprite_y[(12*10)+9 : 12*10] &&
114
                                V_pos_in <= sprite_y[(12*10)+9 : 12*10] + 15 &&
115
                                H_pos_in >= sprite_x[(12*10)+9 : 12*10] &&
116
                                H_pos_in <= sprite_x[(12*10)+9 : 12*10] + 15 &&
117
                                sprite_shape[ (12*16) + 15 - (H_pos_in - sprite_x[(12*10)+9 : 12*10]) ]
118
                                )
119
                        begin
120
                                R_out [2:0]      <=      3'b000;
121
                                G_out [1:0]      <=      2'b00;
122
                                B_out [2:0]      <=      3'b000;
123
                                R_out   [7:3]   <=      sprite_color[(12*16)+4  : (12*16)+0];
124
                                G_out   [7:2]   <=      sprite_color[(12*16)+10 : (12*16)+5];
125
                                B_out   [7:3]   <=      sprite_color[(12*16)+15 : (12*16)+11];
126
                        end
127
 
128
                        else
129
                        begin
130
 
131
                        // SPRITE LEVEL 11 - START
132
                        if      (
133
                                V_pos_in >= sprite_y[(11*10)+9 : 11*10] &&
134
                                V_pos_in <= sprite_y[(11*10)+9 : 11*10] + 15 &&
135
                                H_pos_in >= sprite_x[(11*10)+9 : 11*10] &&
136
                                H_pos_in <= sprite_x[(11*10)+9 : 11*10] + 15 &&
137
                                sprite_shape[ (11*16) + 15 - (H_pos_in - sprite_x[(11*10)+9 : 11*10]) ]
138
                                )
139
                        begin
140
                                R_out [2:0]      <=      3'b000;
141
                                G_out [1:0]      <=      2'b00;
142
                                B_out [2:0]      <=      3'b000;
143
                                R_out   [7:3]   <=      sprite_color[(11*16)+4  : (11*16)+0];
144
                                G_out   [7:2]   <=      sprite_color[(11*16)+10 : (11*16)+5];
145
                                B_out   [7:3]   <=      sprite_color[(11*16)+15 : (11*16)+11];
146
                        end
147
 
148
                        else
149
                        begin
150
 
151
                        // SPRITE LEVEL 10 - START
152
                        if      (
153
                                V_pos_in >= sprite_y[(10*10)+9 : 10*10] &&
154
                                V_pos_in <= sprite_y[(10*10)+9 : 10*10] + 15 &&
155
                                H_pos_in >= sprite_x[(10*10)+9 : 10*10] &&
156
                                H_pos_in <= sprite_x[(10*10)+9 : 10*10] + 15 &&
157
                                sprite_shape[ (10*16) + 15 - (H_pos_in - sprite_x[(10*10)+9 : 10*10]) ]
158
                                )
159
                        begin
160
                                R_out [2:0]      <=      3'b000;
161
                                G_out [1:0]      <=      2'b00;
162
                                B_out [2:0]      <=      3'b000;
163
                                R_out   [7:3]   <=      sprite_color[(10*16)+4  : (10*16)+0];
164
                                G_out   [7:2]   <=      sprite_color[(10*16)+10 : (10*16)+5];
165
                                B_out   [7:3]   <=      sprite_color[(10*16)+15 : (10*16)+11];
166
                        end
167
 
168
                        else
169
                        begin
170
 
171
                        // SPRITE LEVEL 9 - START
172
                        if      (
173
                                V_pos_in >= sprite_y[(9*10)+9 : 9*10] &&
174
                                V_pos_in <= sprite_y[(9*10)+9 : 9*10] + 15 &&
175
                                H_pos_in >= sprite_x[(9*10)+9 : 9*10] &&
176
                                H_pos_in <= sprite_x[(9*10)+9 : 9*10] + 15 &&
177
                                sprite_shape[ (9*16) + 15 - (H_pos_in - sprite_x[(9*10)+9 : 9*10]) ]
178
                                )
179
                        begin
180
                                R_out [2:0]      <=      3'b000;
181
                                G_out [1:0]      <=      2'b00;
182
                                B_out [2:0]      <=      3'b000;
183
                                R_out   [7:3]   <=      sprite_color[(9*16)+4   : (9*16)+0];
184
                                G_out   [7:2]   <=      sprite_color[(9*16)+10  : (9*16)+5];
185
                                B_out   [7:3]   <=      sprite_color[(9*16)+15 : (9*16)+11];
186
                        end
187
 
188
                        else
189
                        begin
190
 
191
                        // SPRITE LEVEL 8 - START
192
                        if      (
193
                                V_pos_in >= sprite_y[(8*10)+9 : 8*10] &&
194
                                V_pos_in <= sprite_y[(8*10)+9 : 8*10] + 15 &&
195
                                H_pos_in >= sprite_x[(8*10)+9 : 8*10] &&
196
                                H_pos_in <= sprite_x[(8*10)+9 : 8*10] + 15 &&
197
                                sprite_shape[ (8*16) + 15 - (H_pos_in - sprite_x[(8*10)+9 : 8*10]) ]
198
                                )
199
                        begin
200
                                R_out [2:0]      <=      3'b000;
201
                                G_out [1:0]      <=      2'b00;
202
                                B_out [2:0]      <=      3'b000;
203
                                R_out   [7:3]   <=      sprite_color[(8*16)+4   : (8*16)+0];
204
                                G_out   [7:2]   <=      sprite_color[(8*16)+10  : (8*16)+5];
205
                                B_out   [7:3]   <=      sprite_color[(8*16)+15 : (8*16)+11];
206
                        end
207
 
208
                        else
209
                        begin
210
 
211
                        // SPRITE LEVEL 7 - START
212
                        if      (
213
                                V_pos_in >= sprite_y[(7*10)+9 : 7*10] &&
214
                                V_pos_in <= sprite_y[(7*10)+9 : 7*10] + 15 &&
215
                                H_pos_in >= sprite_x[(7*10)+9 : 7*10] &&
216
                                H_pos_in <= sprite_x[(7*10)+9 : 7*10] + 15 &&
217
                                sprite_shape[ (7*16) + 15 - (H_pos_in - sprite_x[(7*10)+9 : 7*10]) ]
218
                                )
219
                        begin
220
                                R_out [2:0]      <=      3'b000;
221
                                G_out [1:0]      <=      2'b00;
222
                                B_out [2:0]      <=      3'b000;
223
                                R_out   [7:3]   <=      sprite_color[(7*16)+4   : (7*16)+0];
224
                                G_out   [7:2]   <=      sprite_color[(7*16)+10  : (7*16)+5];
225
                                B_out   [7:3]   <=      sprite_color[(7*16)+15 : (7*16)+11];
226
                        end
227
 
228
                        else
229
                        begin
230
 
231
                        // SPRITE LEVEL 6 - START
232
                        if      (
233
                                V_pos_in >= sprite_y[(6*10)+9 : 6*10] &&
234
                                V_pos_in <= sprite_y[(6*10)+9 : 6*10] + 15 &&
235
                                H_pos_in >= sprite_x[(6*10)+9 : 6*10] &&
236
                                H_pos_in <= sprite_x[(6*10)+9 : 6*10] + 15 &&
237
                                sprite_shape[ (6*16) + 15 - (H_pos_in - sprite_x[(6*10)+9 : 6*10]) ]
238
                                )
239
                        begin
240
                                R_out [2:0]      <=      3'b000;
241
                                G_out [1:0]      <=      2'b00;
242
                                B_out [2:0]      <=      3'b000;
243
                                R_out   [7:3]   <=      sprite_color[(6*16)+4   : (6*16)+0];
244
                                G_out   [7:2]   <=      sprite_color[(6*16)+10  : (6*16)+5];
245
                                B_out   [7:3]   <=      sprite_color[(6*16)+15 : (6*16)+11];
246
                        end
247
 
248
                        else
249
                        begin
250
 
251
                        // SPRITE LEVEL 5 - START
252
                        if      (
253
                                V_pos_in >= sprite_y[(5*10)+9 : 5*10] &&
254
                                V_pos_in <= sprite_y[(5*10)+9 : 5*10] + 15 &&
255
                                H_pos_in >= sprite_x[(5*10)+9 : 5*10] &&
256
                                H_pos_in <= sprite_x[(5*10)+9 : 5*10] + 15 &&
257
                                sprite_shape[ (5*16) + 15 - (H_pos_in - sprite_x[(5*10)+9 : 5*10]) ]
258
                                )
259
                        begin
260
                                R_out [2:0]      <=      3'b000;
261
                                G_out [1:0]      <=      2'b00;
262
                                B_out [2:0]      <=      3'b000;
263
                                R_out   [7:3]   <=      sprite_color[(5*16)+4   : (5*16)+0];
264
                                G_out   [7:2]   <=      sprite_color[(5*16)+10  : (5*16)+5];
265
                                B_out   [7:3]   <=      sprite_color[(5*16)+15 : (5*16)+11];
266
                        end
267
 
268
                        else
269
                        begin
270
 
271
                        // SPRITE LEVEL 4 - START
272
                        if      (
273
                                V_pos_in >= sprite_y[(4*10)+9 : 4*10] &&
274
                                V_pos_in <= sprite_y[(4*10)+9 : 4*10] + 15 &&
275
                                H_pos_in >= sprite_x[(4*10)+9 : 4*10] &&
276
                                H_pos_in <= sprite_x[(4*10)+9 : 4*10] + 15 &&
277
                                sprite_shape[ (4*16) + 15 - (H_pos_in - sprite_x[(4*10)+9 : 4*10]) ]
278
                                )
279
                        begin
280
                                R_out [2:0]      <=      3'b000;
281
                                G_out [1:0]      <=      2'b00;
282
                                B_out [2:0]      <=      3'b000;
283
                                R_out   [7:3]   <=      sprite_color[(4*16)+4   : (4*16)+0];
284
                                G_out   [7:2]   <=      sprite_color[(4*16)+10  : (4*16)+5];
285
                                B_out   [7:3]   <=      sprite_color[(4*16)+15 : (4*16)+11];
286
                        end
287
 
288
                        else
289
                        begin
290
 
291
                        // SPRITE LEVEL 3 - START
292
                        if      (
293
                                V_pos_in >= sprite_y[(3*10)+9 : 3*10] &&
294
                                V_pos_in <= sprite_y[(3*10)+9 : 3*10] + 15 &&
295
                                H_pos_in >= sprite_x[(3*10)+9 : 3*10] &&
296
                                H_pos_in <= sprite_x[(3*10)+9 : 3*10] + 15 &&
297
                                sprite_shape[ (3*16) + 15 - (H_pos_in - sprite_x[(3*10)+9 : 3*10]) ]
298
                                )
299
                        begin
300
                                R_out [2:0]      <=      3'b000;
301
                                G_out [1:0]      <=      2'b00;
302
                                B_out [2:0]      <=      3'b000;
303
                                R_out   [7:3]   <=      sprite_color[(3*16)+4   : (3*16)+0];
304
                                G_out   [7:2]   <=      sprite_color[(3*16)+10  : (3*16)+5];
305
                                B_out   [7:3]   <=      sprite_color[(3*16)+15 : (3*16)+11];
306
                        end
307
 
308
                        else
309
                        begin
310
 
311
                        // SPRITE LEVEL 2 - START
312
                        if      (
313
                                V_pos_in >= sprite_y[(2*10)+9 : 2*10] &&
314
                                V_pos_in <= sprite_y[(2*10)+9 : 2*10] + 15 &&
315
                                H_pos_in >= sprite_x[(2*10)+9 : 2*10] &&
316
                                H_pos_in <= sprite_x[(2*10)+9 : 2*10] + 15 &&
317
                                sprite_shape[ (2*16) + 15 - (H_pos_in - sprite_x[(2*10)+9 : 2*10]) ]
318
                                )
319
                        begin
320
                                R_out [2:0]      <=      3'b000;
321
                                G_out [1:0]      <=      2'b00;
322
                                B_out [2:0]      <=      3'b000;
323
                                R_out   [7:3]   <=      sprite_color[(2*16)+4   : (2*16)+0];
324
                                G_out   [7:2]   <=      sprite_color[(2*16)+10  : (2*16)+5];
325
                                B_out   [7:3]   <=      sprite_color[(2*16)+15 : (2*16)+11];
326
                        end
327
 
328
                        else
329
                        begin
330
 
331
                        // SPRITE LEVEL 1 - START
332
                        if      (
333
                                V_pos_in >= sprite_y[(1*10)+9 : 1*10] &&
334
                                V_pos_in <= sprite_y[(1*10)+9 : 1*10] + 15 &&
335
                                H_pos_in >= sprite_x[(1*10)+9 : 1*10] &&
336
                                H_pos_in <= sprite_x[(1*10)+9 : 1*10] + 15 &&
337
                                sprite_shape[ (1*16) + 15 - (H_pos_in - sprite_x[(1*10)+9 : 1*10]) ]
338
                                )
339
                        begin
340
                                R_out [2:0]      <=      3'b000;
341
                                G_out [1:0]      <=      2'b00;
342
                                B_out [2:0]      <=      3'b000;
343
                                R_out   [7:3]   <=      sprite_color[(1*16)+4   : (1*16)+0];
344
                                G_out   [7:2]   <=      sprite_color[(1*16)+10  : (1*16)+5];
345
                                B_out   [7:3]   <=      sprite_color[(1*16)+15 : (1*16)+11];
346
                        end
347
 
348
                        else
349
                        begin
350
 
351
                        // SPRITE LEVEL 0 - START
352
                        if      (
353
                                V_pos_in >= sprite_y[(0*10)+9 : 0*10] &&
354
                                V_pos_in <= sprite_y[(0*10)+9 : 0*10] + 15 &&
355
                                H_pos_in >= sprite_x[(0*10)+9 : 0*10] &&
356
                                H_pos_in <= sprite_x[(0*10)+9 : 0*10] + 15 &&
357
                                sprite_shape[ (0*16) + 15 - (H_pos_in - sprite_x[(0*10)+9 : 0*10]) ]
358
                                )
359
                        begin
360
                                R_out [2:0]      <=      3'b000;
361
                                G_out [1:0]      <=      2'b00;
362
                                B_out [2:0]      <=      3'b000;
363
                                R_out   [7:3]   <=      sprite_color[(0*16)+4    : (0*16)+0];
364
                                G_out   [7:2]   <=      sprite_color[(0*16)+10   : (0*16)+5];
365
                                B_out   [7:3]   <=      sprite_color[(0*16)+15 : (0*16)+11];
366
                        end
367
 
368
                        else
369
                        begin
370
 
371
                                R_out [2:0]      <=      3'b000;
372
                                G_out [1:0]      <=      2'b00;
373
                                B_out [2:0]      <=      3'b000;
374
                                R_out   [7:3]   <=      R_in    [7:3];
375
                                G_out   [7:2]   <=      G_in    [7:2];
376
                                B_out   [7:3]   <=      B_in    [7:3];
377
                        end     // SPRITE LEVEL 0 - ELSE END
378
                        end     // SPRITE LEVEL 1 - ELSE END
379
                        end     // SPRITE LEVEL 2 - ELSE END
380
                        end     // SPRITE LEVEL 3 - ELSE END
381
                        end     // SPRITE LEVEL 4 - ELSE END
382
                        end     // SPRITE LEVEL 5 - ELSE END
383
                        end     // SPRITE LEVEL 6 - ELSE END
384
                        end     // SPRITE LEVEL 7 - ELSE END
385
                        end     // SPRITE LEVEL 8 - ELSE END
386
                        end     // SPRITE LEVEL 9 - ELSE END
387
                        end     // SPRITE LEVEL 10 - ELSE END
388
                        end     // SPRITE LEVEL 11 - ELSE END
389
                        end     // SPRITE LEVEL 12 - ELSE END
390
                        end     // SPRITE LEVEL 13 - ELSE END
391
                        end     // SPRITE LEVEL 14 - ELSE END
392
                        end     // SPRITE LEVEL 15 - ELSE END
393
 
394
                end   // RST - ELSE END
395
 
396
        end   // ALWAYS END
397
 
398
 
399
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.