module Imagen( input clk, reset, input [9:0]posx, input [9:0]posy, input [9:0]posbarrax, input [9:0]poscaja1y, input [9:0]poscaja1x, input [9:0]poscaja2y, input [9:0]poscaja2x, input [9:0]poscaja3y, input [9:0]poscaja3x, input [9:0]poscaja4y, input [9:0]poscaja4x, input [9:0]poscaja5y, input [9:0]poscaja5x, input [9:0]poscaja6y, input [9:0]poscaja6x, //input [9:0]poscaja7y, //input [9:0]poscaja7x, //input [9:0]poscaja8y, //input [9:0]poscaja8x, //input [9:0]poscaja9y, //input [9:0]poscaja9x, input [2:0]sw, input creeper, input [2:0]sw2, output hsync, vsync, output [2:0] rgb ); //signal declaration reg [2:0] rgb_reg; wire video_on; wire [9:0] x,y; //instantiate vga sync circuit vga_sync vsync_unit (.clk(clk), .reset(reset), .hsync(hsync), . vsync(vsync), .video_on(video_on), . p_tick(), .pixel_x(x), .pixel_y(y)); //rgb buffer always @(posedge clk, posedge reset) begin if (reset) rgb_reg <= 0; else begin if (x>=posx & x<=(20+posx) & y>=posy & y<=(20+posy)) rgb_reg<=sw2; //Se colorea el borde else if (x>=0 & x<=10 & y>=0 & y<=480) rgb_reg<=3'b011; //Borde lateral izq else if (x>=630 & x<=640 & y>=0 & y<=480) rgb_reg<=3'b111; //Borde lateral der else if (x>=0 & x<=640 & y>=0 & y<=10) rgb_reg<=3'b111; //Borde superior else if (x>=0 & x<=640 & y>=470 & y<=480) rgb_reg<=3'b001; //Borde inferior //FIN Se colorea el borde //Colorea la barra que se mueve else if (x>=posbarrax & x<=(100+posbarrax) & y>=430 & y<=440) rgb_reg<=3'b111; //Colorea los bloques else if (x>=poscaja1x & x<=(120+poscaja1x) & y>=poscaja1y & y<=(90+poscaja1y)) rgb_reg<=3'b110; else if (x>=poscaja2x & x<=(120+poscaja2x) & y>=poscaja2y & y<=(90+poscaja2y)) rgb_reg<=3'b110; else if (x>=poscaja3x & x<=(120+poscaja3x) & y>=poscaja3y & y<=(90+poscaja3y)) rgb_reg<=3'b110; else if (x>=poscaja4x & x<=(120+poscaja4x) & y>=poscaja4y & y<=(90+poscaja4y)) rgb_reg<=3'b001; else if (x>=poscaja5x & x<=(120+poscaja5x) & y>=poscaja5y & y<=(90+poscaja5y)) rgb_reg<=3'b110; else if (x>=poscaja6x & x<=(120+poscaja6x) & y>=poscaja6y & y<=(90+poscaja6y)) rgb_reg<=3'b101; //else if (x>=poscaja7x & x<=(120+poscaja7x) & y>=poscaja7y & y<=(90+poscaja7y)) rgb_reg<=3'b110; //else if (x>=poscaja8x & x<=(120+poscaja8x) & y>=poscaja8y & y<=(90+poscaja8y)) rgb_reg<=3'b101; //else if (x>=poscaja9x & x<=(120+poscaja9x) & y>=poscaja9y & y<=(90+poscaja9y)) rgb_reg<=3'b111; //FIN Colorea la barra que se mueve //Creeper else if (creeper==1) if (x>=220 & x<=280 & y>=310 & y<=460) rgb_reg<=3'b011;//boca else if (x>=360 & x<=420 & y>=310 & y<=460) rgb_reg<=3'b011;//boca else if (x>=280 & x<=360 & y>=210 & y<=360) rgb_reg<=3'b011;//boca else if (x>=180 & x<=280 & y>=110 & y<=210) rgb_reg<=3'b011;//ojos else if (x>=360 & x<=460 & y>=110 & y<=210) rgb_reg<=3'b011;//ojos //fin Creeper else rgb_reg <= sw; end end // output assign rgb = (video_on) ? rgb_reg : 3'b000; endmodule