module ROMdecoder(
input logic clk,
input logic inBullet1,inBullet2,inBullet3,inEnemy1,inEnemy2,inEnemy3,
				inExplosion1,inExplosion2,inExplosion3,inNumber1, inNumber2, inNumber3,
//chara
input logic[23:0] charap1,
input logic[23:0] charap2,
input logic[23:0] charap3,
input logic[23:0] shoot1p,
input logic[23:0] shoot2p,
input logic[23:0] falling1p,
input logic[23:0] falling2p,
input logic[23:0] fell1p,
input logic[23:0] fell2p,
input logic[23:0] fell3p,
input logic[23:0] fell4p,
//enemy
input logic[23:0] enemyA1p,enemyA2p,enemyB1p,enemyB2p,
//bullet
input logic[23:0] bulletp1,
input logic[23:0] bulletp2,
//back
input logic[23:0] floorp,brickp,
//explosion
input logic[23:0] explosionp,
//air
input logic[23:0] left1p,
input logic[23:0] left2p,
input logic[23:0] right1p,
input logic[23:0] right2p,
input logic[23:0] straight1p,
input logic[23:0] straight2p,
//number
input logic[23:0] number1p,number2p,number3p,number4p,number5p,number6p,number7p,number8p,number9p,number10p,
input logic[23:0] pressp,
input logic[23:0] overp,

input logic[23:0] powerp, energyp,

//coordinate
input logic[9:0] hchara,
input logic[9:0] vchara,
input logic[9:0] henemy1,henemy2,henemy3,
input logic[9:0] venemy1,venemy2,venemy3,
//input logic[9:0]
input logic[9:0] vbullet1,vbullet2,vbullet3,
input logic[9:0] hbullet1,hbullet2,hbullet3,
input logic[9:0] hair,
input logic[9:0] vair,
input logic[9:0] hfloor,
input logic[9:0] vfloor,
input logic[9:0] hbrick,
input logic[9:0] vbrick,
input logic[9:0] hexplosion1,hexplosion2,hexplosion3,
input logic[9:0] vexplosion1,vexplosion2,vexplosion3,
//
input logic[9:0] hnumber1,hnumber2,hnumber3,
input logic[9:0] vnumber1,vnumber2,vnumber3,
//
input logic[9:0] hpress,vpress,
input logic[9:0] hover,vover,
//
input logic[9:0] hpower, vpower,
//
input logic[9:0] henergy, venergy,
//chara1
output logic[7:0] chara1R,
output logic[7:0] chara1G,
output logic[7:0] chara1B,
output logic[7:0] chara2R,
output logic[7:0] chara2G,
output logic[7:0] chara2B,
output logic[7:0] chara3R,
output logic[7:0] chara3G,
output logic[7:0] chara3B,
output logic[7:0] shoot1R,
output logic[7:0] shoot1G,
output logic[7:0] shoot1B,
output logic[7:0] shoot2R,
output logic[7:0] shoot2G,
output logic[7:0] shoot2B,
output logic[7:0] falling1R,
output logic[7:0] falling1G,
output logic[7:0] falling1B,
output logic[7:0] falling2R,
output logic[7:0] falling2G,
output logic[7:0] falling2B,
output logic[7:0] fell1R,
output logic[7:0] fell1G,
output logic[7:0] fell1B,
output logic[7:0] fell2R,
output logic[7:0] fell2G,
output logic[7:0] fell2B,
output logic[7:0] fell3R,
output logic[7:0] fell3G,
output logic[7:0] fell3B,
output logic[7:0] fell4R,
output logic[7:0] fell4G,
output logic[7:0] fell4B,
output logic[11:0] chara1add,
output logic[11:0] chara2add,
output logic[11:0] chara3add,
output logic[11:0] shoot1add,
output logic[11:0] shoot2add,
output logic[11:0] falling1add,
output logic[11:0] falling2add,
output logic[11:0] fell1add,
output logic[11:0] fell2add,
output logic[11:0] fell3add,
output logic[11:0] fell4add,

//air
output logic[7:0] left1R,
output logic[7:0] left1G,
output logic[7:0] left1B,
output logic[7:0] left2R,
output logic[7:0] left2G,
output logic[7:0] left2B,
output logic[7:0] right1R,
output logic[7:0] right1G,
output logic[7:0] right1B,
output logic[7:0] right2R,
output logic[7:0] right2G,
output logic[7:0] right2B,
output logic[7:0] straight1R,
output logic[7:0] straight1G,
output logic[7:0] straight1B,
output logic[7:0] straight2R,
output logic[7:0] straight2G,
output logic[7:0] straight2B,
output logic[10:0] left1add,
output logic[10:0] left2add,
output logic[10:0] right1add,
output logic[10:0] right2add,
output logic[10:0] straight1add,
output logic[10:0] straight2add,
////////////////////////
///enemy
output logic[7:0] enemyA1R,
output logic[7:0] enemyA1G,
output logic[7:0] enemyA1B,
output logic[7:0] enemyA2R,
output logic[7:0] enemyA2G,
output logic[7:0] enemyA2B,
output logic[7:0] enemyB1R,
output logic[7:0] enemyB1G,
output logic[7:0] enemyB1B,
output logic[7:0] enemyB2R,
output logic[7:0] enemyB2G,
output logic[7:0] enemyB2B,
output logic[13:0] enemyA1add,
output logic[13:0] enemyA2add,
output logic[13:0] enemyB1add,
output logic[13:0] enemyB2add,
//bullet1
output logic[7:0] bullet1R,
output logic[7:0] bullet1G,
output logic[7:0] bullet1B,
output logic[9:0] bullet1add,
//bullet2
output logic[7:0] bullet2R,
output logic[7:0] bullet2G,
output logic[7:0] bullet2B,
output logic[9:0] bullet2add,

//floor
output logic[7:0] floorR,
output logic[7:0] floorG,
output logic[7:0] floorB,
output logic[11:0] flooradd,
//brick
output logic[7:0] brickR,
output logic[7:0] brickG,
output logic[7:0] brickB,
output logic[10:0] brickadd,
//explosion
output logic[7:0] explosionR,
output logic[7:0] explosionG,
output logic[7:0] explosionB,
output logic[11:0] explosionadd,

//number
output logic[7:0] number1R, number1G, number1B, 
						number2R, number2G, number2B,
						number3R, number3G, number3B,
						number4R, number4G, number4B,
						number5R, number5G, number5B,
						number6R, number6G, number6B,
						number7R, number7G, number7B,
						number8R, number8G, number8B,
						number9R, number9G, number9B,
						number10R, number10G, number10B,
output logic[10:0] number1add, number2add,number3add, number4add, number5add, number6add, number7add,
                   number8add, number9add, number10add,
//press overp
output logic[7:0] pressR,pressG,pressB, overR, overG, overB,
output logic[12:0] pressadd, overadd ,

output logic [7:0] powerR, powerG, powerB, energyR, energyG, energyB,
output logic [8:0] poweradd,
output logic [10:0] energyadd
);





//////////////////////////////////////////////////////////////////////////////////////////////////////
//chara1
assign chara1add=vchara*60+hchara;
assign chara1B=charap1[7:0];
assign chara1G=charap1[15:8];
assign chara1R=charap1[23:16];

//chara2
assign chara2add=vchara*60+hchara;
assign chara2B=charap2[7:0];
assign chara2G=charap2[15:8];
assign chara2R=charap2[23:16];

//chara3
assign chara3add=vchara*60+hchara;
assign chara3B=charap3[7:0];
assign chara3G=charap3[15:8];
assign chara3R=charap3[23:16];

//shoot1
assign shoot1add=vchara*60+hchara;
assign shoot1B=shoot1p[7:0];
assign shoot1G=shoot1p[15:8];
assign shoot1R=shoot1p[23:16];

//shoot2
assign shoot2add=vchara*60+hchara;
assign shoot2B=shoot2p[7:0];
assign shoot2G=shoot2p[15:8];
assign shoot2R=shoot2p[23:16];

//falling1
assign falling1add=vchara*60+hchara;
assign falling1B=falling1p[7:0];
assign falling1G=falling1p[15:8];
assign falling1R=falling1p[23:16];

//falling2
assign falling2add=vchara*60+hchara;
assign falling2B=falling2p[7:0];
assign falling2G=falling2p[15:8];
assign falling2R=falling2p[23:16];

//fell1
assign fell1add=vchara*60+hchara;
assign fell1B=fell1p[7:0];
assign fell1G=fell1p[15:8];
assign fell1R=fell1p[23:16];
//fell2
assign fell2add=vchara*60+hchara;
assign fell2B=fell2p[7:0];
assign fell2G=fell2p[15:8];
assign fell2R=fell2p[23:16];
//fell3
assign fell3add=vchara*60+hchara;
assign fell3B=fell3p[7:0];
assign fell3G=fell3p[15:8];
assign fell3R=fell3p[23:16];
//fell4
assign fell4add=vchara*60+hchara;
assign fell4B=fell4p[7:0];
assign fell4G=fell4p[15:8];
assign fell4R=fell4p[23:16];


//enemy1
always begin
if(inEnemy1==1)
	begin
 enemyA1add=venemy1*60+henemy1;
 enemyA2add=venemy1*60+henemy1;
 enemyB1add=venemy1*60+henemy1;
 enemyB2add=venemy1*60+henemy1;
 
 enemyA1B=enemyA1p[7:0];
 enemyA1G=enemyA1p[15:8];
 enemyA1R=enemyA1p[23:16];
 
 enemyA2B=enemyA2p[7:0];
 enemyA2G=enemyA2p[15:8];
 enemyA2R=enemyA2p[23:16];
 
 enemyB1B=enemyB1p[7:0];
 enemyB1G=enemyB1p[15:8];
 enemyB1R=enemyB1p[23:16];
 
 enemyB2B=enemyB2p[7:0];
 enemyB2G=enemyB2p[15:8];
 enemyB2R=enemyB2p[23:16];
 end
 else if(inEnemy2==1)
begin
 enemyA1add=venemy2*60+henemy2;
 enemyA2add=venemy2*60+henemy2;
 enemyB1add=venemy2*60+henemy2;
 enemyB2add=venemy2*60+henemy2;
 
 enemyA1B=enemyA1p[7:0];
 enemyA1G=enemyA1p[15:8];
 enemyA1R=enemyA1p[23:16];
 
 enemyA2B=enemyA2p[7:0];
 enemyA2G=enemyA2p[15:8];
 enemyA2R=enemyA2p[23:16];
 
 enemyB1B=enemyB1p[7:0];
 enemyB1G=enemyB1p[15:8];
 enemyB1R=enemyB1p[23:16];
 
 enemyB2B=enemyB2p[7:0];
 enemyB2G=enemyB2p[15:8];
 enemyB2R=enemyB2p[23:16];
 end
 
 else if(inEnemy3==1)
 begin
 enemyA1add=venemy3*60+henemy3;
 enemyA2add=venemy3*60+henemy3;
 enemyB1add=venemy3*60+henemy3;
 enemyB2add=venemy3*60+henemy3;
 
 enemyA1B=enemyA1p[7:0];
 enemyA1G=enemyA1p[15:8];
 enemyA1R=enemyA1p[23:16];
 
 enemyA2B=enemyA2p[7:0];
 enemyA2G=enemyA2p[15:8];
 enemyA2R=enemyA2p[23:16];
 
 enemyB1B=enemyB1p[7:0];
 enemyB1G=enemyB1p[15:8];
 enemyB1R=enemyB1p[23:16];
 
 enemyB2B=enemyB2p[7:0];
 enemyB2G=enemyB2p[15:8];
 enemyB2R=enemyB2p[23:16];
 end
 end




//bullet1,2
always begin
if (inBullet1==1)
 begin
 bullet1add=vbullet1*30+hbullet1;
 bullet2add=vbullet1*30+hbullet1;
 bullet1B=bulletp1[7:0];
 bullet1G=bulletp1[15:8];
 bullet1R=bulletp1[23:16];
 bullet2B=bulletp2[7:0];
 bullet2G=bulletp2[15:8];
 bullet2R=bulletp2[23:16];
 end
else if(inBullet2==1)
 begin
 bullet1add=vbullet2*30+hbullet2;
 bullet2add=vbullet2*30+hbullet2;
 bullet1B=bulletp1[7:0];
 bullet1G=bulletp1[15:8];
 bullet1R=bulletp1[23:16];
 bullet2B=bulletp2[7:0];
 bullet2G=bulletp2[15:8];
 bullet2R=bulletp2[23:16];
 end
else if(inBullet3==1)
 begin
 bullet1add=vbullet3*30+hbullet3;
 bullet2add=vbullet3*30+hbullet3;
 bullet1B=bulletp1[7:0];
 bullet1G=bulletp1[15:8];
 bullet1R=bulletp1[23:16];
 bullet2B=bulletp2[7:0];
 bullet2G=bulletp2[15:8];
 bullet2R=bulletp2[23:16];
 end
end




//left1
assign left1add=vair*40+hair;
assign left1B=left1p[7:0];
assign left1G=left1p[15:8];
assign left1R=left1p[23:16];

//left2
assign left2add=vair*40+hair;
assign left2B=left2p[7:0];
assign left2G=left2p[15:8];
assign left2R=left2p[23:16];

//right1
assign right1add=vair*40+hair;
assign right1B=right1p[7:0];
assign right1G=right1p[15:8];
assign right1R=right1p[23:16];

//right2
assign right2add=vair*40+hair;
assign right2B=right2p[7:0];
assign right2G=right2p[15:8];
assign right2R=right2p[23:16];

//straight1
assign straight1add=vair*40+hair;
assign straight1B=straight1p[7:0];
assign straight1G=straight1p[15:8];
assign straight1R=straight1p[23:16];

//straight2
assign straight2add=vair*40+hair;
assign straight2B=straight2p[7:0];
assign straight2G=straight2p[15:8];
assign straight2R=straight2p[23:16];





//floor
assign flooradd=vfloor*60+hfloor;
assign floorB=floorp[7:0];
assign floorG=floorp[15:8];
assign floorR=floorp[23:16];

//brick
assign brickadd=vbrick*40+hbrick;
assign brickB=brickp[7:0];
assign brickG=brickp[15:8];
assign brickR=brickp[23:16];





//explosion
always begin
if(inExplosion1==1)
begin
 explosionadd=vexplosion1*60+hexplosion1;
 explosionB=explosionp[7:0];
 explosionG=explosionp[15:8];
 explosionR=explosionp[23:16];
end

if(inExplosion2==1)
begin
 explosionadd=vexplosion2*60+hexplosion2;
 explosionB=explosionp[7:0];
 explosionG=explosionp[15:8];
 explosionR=explosionp[23:16];
end

if(inExplosion3==1)
begin
 explosionadd=vexplosion3*60+hexplosion3;
 explosionB=explosionp[7:0];
 explosionG=explosionp[15:8];
 explosionR=explosionp[23:16];
end
end

//number1
always begin
	if(inNumber1)
	begin
	number1add=hnumber1+vnumber1*40;
	number2add=hnumber1+vnumber1*40;
	number3add=hnumber1+vnumber1*40;
	number4add=hnumber1+vnumber1*40;
	number5add=hnumber1+vnumber1*40;
	number6add=hnumber1+vnumber1*40;
	number7add=hnumber1+vnumber1*40;
	number8add=hnumber1+vnumber1*40;
	number9add=hnumber1+vnumber1*40;
	number10add=hnumber1+vnumber1*40;
	
	number1B=number1p[7:0];
   number1G=number1p[15:8];
   number1R=number1p[23:16];
	//
	number2B=number2p[7:0];
   number2G=number2p[15:8];
   number2R=number2p[23:16];
	//
	number3B=number3p[7:0];
   number3G=number3p[15:8];
   number3R=number3p[23:16];
	//
	number4B=number4p[7:0];
   number4G=number4p[15:8];
   number4R=number4p[23:16];
	//
	number5B=number5p[7:0];
   number5G=number5p[15:8];
   number5R=number5p[23:16];
	//
	number6B=number6p[7:0];
   number6G=number6p[15:8];
   number6R=number6p[23:16];
	//
	number7B=number7p[7:0];
   number7G=number7p[15:8];
   number7R=number7p[23:16];
	//
	number8B=number8p[7:0];
   number8G=number8p[15:8];
   number8R=number8p[23:16];
	//
	number9B=number9p[7:0];
   number9G=number9p[15:8];
   number9R=number9p[23:16];
	//
	number10B=number10p[7:0];
   number10G=number10p[15:8];
   number10R=number10p[23:16];
	//

	
	end
	else if(inNumber2)
	begin
	number1add=hnumber2+vnumber2*40;
	number2add=hnumber2+vnumber2*40;
	number3add=hnumber2+vnumber2*40;
	number4add=hnumber2+vnumber2*40;
	number5add=hnumber2+vnumber2*40;
	number6add=hnumber2+vnumber2*40;
	number7add=hnumber2+vnumber2*40;
	number8add=hnumber2+vnumber2*40;
	number9add=hnumber2+vnumber2*40;
	number10add=hnumber2+vnumber2*40;
	
	number1B=number1p[7:0];
   number1G=number1p[15:8];
   number1R=number1p[23:16];
	//
	number2B=number2p[7:0];
   number2G=number2p[15:8];
   number2R=number2p[23:16];
	//
	number3B=number3p[7:0];
   number3G=number3p[15:8];
   number3R=number3p[23:16];
	//
	number4B=number4p[7:0];
   number4G=number4p[15:8];
   number4R=number4p[23:16];
	//
	number5B=number5p[7:0];
   number5G=number5p[15:8];
   number5R=number5p[23:16];
	//
	number6B=number6p[7:0];
   number6G=number6p[15:8];
   number6R=number6p[23:16];
	//
	number7B=number7p[7:0];
   number7G=number7p[15:8];
   number7R=number7p[23:16];
	//
	number8B=number8p[7:0];
   number8G=number8p[15:8];
   number8R=number8p[23:16];
	//
	number9B=number9p[7:0];
   number9G=number9p[15:8];
   number9R=number9p[23:16];
	//
	number10B=number10p[7:0];
   number10G=number10p[15:8];
   number10R=number10p[23:16];
	end
	else if(inNumber3)
	begin
	number1add=hnumber3+vnumber3*40;
	number2add=hnumber3+vnumber3*40;
	number3add=hnumber3+vnumber3*40;
	number4add=hnumber3+vnumber3*40;
	number5add=hnumber3+vnumber3*40;
	number6add=hnumber3+vnumber3*40;
	number7add=hnumber3+vnumber3*40;
	number8add=hnumber3+vnumber3*40;
	number9add=hnumber3+vnumber3*40;
	number10add=hnumber3+vnumber3*40;
	
	number1B=number1p[7:0];
   number1G=number1p[15:8];
   number1R=number1p[23:16];
	//
	number2B=number2p[7:0];
   number2G=number2p[15:8];
   number2R=number2p[23:16];
	//
	number3B=number3p[7:0];
   number3G=number3p[15:8];
   number3R=number3p[23:16];
	//
	number4B=number4p[7:0];
   number4G=number4p[15:8];
   number4R=number4p[23:16];
	//
	number5B=number5p[7:0];
   number5G=number5p[15:8];
   number5R=number5p[23:16];
	//
	number6B=number6p[7:0];
   number6G=number6p[15:8];
   number6R=number6p[23:16];
	//
	number7B=number7p[7:0];
   number7G=number7p[15:8];
   number7R=number7p[23:16];
	//
	number8B=number8p[7:0];
   number8G=number8p[15:8];
   number8R=number8p[23:16];
	//
	number9B=number9p[7:0];
   number9G=number9p[15:8];
   number9R=number9p[23:16];
	//
	number10B=number10p[7:0];
   number10G=number10p[15:8];
   number10R=number10p[23:16];
	end
end

//press
assign pressadd=hpress+vpress*200;
assign pressB=pressp[7:0];
assign pressG=pressp[15:8];
assign pressR=pressp[23:16];

assign overadd=hover+vover*200;
assign overB=overp[7:0];
assign overG=overp[15:8];
assign overR=overp[23:16];

//energy
assign energyadd=henergy+venergy*200;
assign energyB=energyp[7:0];
assign energyG=energyp[15:8];
assign energyR=energyp[23:16];

//power
assign poweradd=hpower+vpower*20;
assign powerB=powerp[7:0];
assign powerG=powerp[15:8];
assign powerR=powerp[23:16];

endmodule


//every second read from the ROM 24bit data and parse it into 3 R G B data
//output to the VGA