typedef volatile unsigned short hword;

#define KEY 0x4000130
#define VRAM 0x06000000
void back(hword);
void draw_point (hword,hword,hword);
void player_head(hword,hword,hword);
void player_body(hword,hword,hword);
void canon(hword,hword,hword);
void target(hword,hword,hword);
void canon_move(hword,hword,hword,hword);
void target_move(hword,hword,hword,hword);

int main (void){
	hword *ptr;
	*(hword *)0x04000000 = 0xF03;
	ptr = (hword*) VRAM ;
	hword color, color1, color2;

	hword *key;
	hword x1, y1, x2, y2, x3, y3, x4, y4;
	x1 = 90;
	y1 = 136;
	x2 = 105;
	y2 = 120;	
	x3 = 116;	
	y3 = 119;
	x4 = 0;
	y4 = 10;
	color = 0x7FE0;
	color1 = 0x7C1F;

	color2 = 0x001F;


	back(color);
	player_body(x1,y1,color1);
	player_head(x2,y2,color1);
	while(1){	
		key = (hword*) KEY;
		if((*key & 0x0002) == 0x0000){
			canon_move(x3,y3,color2,color);
			if()
		}
		if(x4<240){
		target(x4,y4,color2);
		target(x4,y4,color);
		x4++;
		}
		else if(x4==240){	
			x4=0;
		}
	}
	return 0 ;
}
void draw_point(hword l,hword k,hword color1){

		hword*ptr;

		ptr = (hword*) VRAM;

		ptr = ptr + l + k * 240;

		*ptr = color1;

}

void back(hword color){
	hword *ptr;
	ptr = (hword*) VRAM;

	hword m,n;
	for(m=0; m<160;m++){

		for(n=0; n<240;n++){

		*ptr = color;

		ptr = ptr + 1;

		}

	}
}
void player_body(hword x, hword y, hword color){
	hword m,n;
	for(m=y;m<=y+14;m++){

		for(n=x;n<=x+60;n++){

			draw_point(n,m,color);

		}

	}


}
void player_head(hword x, hword y, hword color){
	hword m,n;
	for(m=y;m<=y+15;m++){

		for(n=x;n<=x+30;n++){

			draw_point(n,m,color);

		}

	}


}
void target(hword x, hword y, hword color){
	hword m,n;
	for(m=y;m<=y+10;m++){
		for(n=x;n<=x+15;n++){
			draw_point(n,m,color);

	
		}
	}
}
void canon(hword x, hword y,hword color){
	hword m,n;
	for(m=y;m>=y-2;m--){

			for(n=x;n<=x+2;n++){

				draw_point(n,m,color);

			}

	}


}
void canon_move(hword x,hword y, hword color1, hword color2){
	while(y > 0){
			canon(x,y,color2);
			y--;
			if(y == 1){
				y=119;
			}
			canon(x,y,color1);
			int i;
			for(i=0 ; i < 1000 ; i++){
				
			}
	}
}
