#include <sys/bios.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <e:/ed310/wwitch/il/sound/il_sound.h>
#include <resource.h>
#include "teki_R.h"
#include "teki_L.h"
#include "teki2_R.h"
#include "teki2_L.h"
#include "teki3.h"
#include "rei.h"
#include "bom3.h"
#include "knife.h"
#include "item.h"
#include "waku1.h" /*screen1*/
#include "waku2.h"
#include "yoko.h"
#include "yoko1.h"
#include "yoko3.h"
#include "hunsya.h"
#include "mych.h" /*自キャラ*/
#include "cht.h" /*敵キャラ*/
#include "ray.h" /*自光線*/
#include "ray2.h"
#include "ray3.h"
#include "ray_t.h" /*敵光線*/
#include "bomber.h"
#include "bomber2.h"
#include "b_bom_center.h"
#include "b_bom_left.h"
#include "b_bom_right.h"
#include "wall_break1.h"
#include "wall_break2.h"
#include "wall_break3.h"
#include "ki.h"
#include "start.h"
#include "stage.h"
#include "end.h"
#include "end2.h"
#include "bv.h" /*背景*/
#include "teki_boss1.h"
#include "teki_boss2.h"
#include "teki_boss1b.h"
#include "teki_boss2b.h"
#include "BOSS_RAY_B.h"
#include "BOSS_RAY_L.h"
#include "BOSS_RAY_R.h"
#include "BOSS_RAY_S.h"
#include "BOSS_RAY_TL.h"
#include "BOSS_RAY_TR.h"
#include "BOSS_RAY_TS.h"
#include "boss_ray_t1.h"
#include "boss_ray_t2.h" 
#include "boom1.h"
#include "boom2.h"
#include "boom3.h"
#include "boom4.h"
#include "boom5.h"
#include "razer.h"
#include "item_boss.h"
#include "boss_engo.h"
#include "boss_engo_ray.h"
#include "haikei_bv.h"
#include "my_hp1.h"
#include "my_hp2.h"
#include "my_hp3.h"
#include "my_hp4.h"
#include "my_hp5.h"
#include "my_hp6.h"
#include "my_hp7.h"
#include "my_hp8.h"

/*音楽*/
SoundIL soundIL;
extern void far *_resource;
int bgm_n=0,i;

/*広域変数*/
#define X_WIDTH 8
#define X_BLIT 208	/*ボスの移動できるXの最大値*/
#define Y_BLIT 112	/*ボスの移動できるYの最大値*/
#define X_SLIT 0	/*ボスの移動できるXの最小値*/
#define Y_SLIT 0	/*ボスの移動できるYの最小値*/

struct stat statbuf;
int  ret_code; /*キー入力のコード*/
int  ret_code_b;/*前回のキー入力*/
int  ret_code2=0;
int  ret_code_open;
int  mych[2]={100,136}; /*mych:[0]x,[1]y*/
int  p1[18],p2[90],p3[109+48]; /*枠*/
int  ti[18*28];
int  wait[5]={0,0,0,0,0}; /*敵の間取り*/
long teki[6][6]={{16,40,0,0,0,0},{44,40,0,0,0,0},{74,40,0,0,0,0},  
					{102,40,0,0,0,0}, {132,40,0,0,0,0}, {160,40,0,0,0,0}};
long teki2[6][6]={{16,25,0,0,0,0},{44,25,0,0,0,0},{74,25,0,0,0,0},  
					{102,25,0,0,0,0}, {132,25,0,0,0,0}, {160,25,0,0,0,0}};
long teki3[6][6]={{16,10,0,0,0,0},{44,10,0,0,0,0},{74,10,0,0,0,0},  
					{102,10,0,0,0,0}, {132,10,0,0,0,0}, {160,10,0,0,0,0}};
long teki4[6][6]={{16,10,0,0,0,0},{44,10,0,0,0,0},{74,10,0,0,0,0},  
					{102,10,0,0,0,0}, {132,10,0,0,0,0}, {160,10,0,0,0,0}};
long teki5[6][2]={{16,10},{44,10},{74,10},{102,10},{132,10},{160,10}};
long teki6[7]={16,44,74,102,132,160,10}; /*動的座標配列*/
long teki7[8]={0,0,0,0,0,0,0,0}; /*スプライト番号　記憶*/
/*座標準備*/
int  move_f[12]= {0,0,0,0,0,0,1,1,1,1,1,1};
int  move_f2[12]={0,0,0,0,0,0,2,2,2,2,2,2};
int  move_f3[12]={0,0,0,0,0,0,3,3,3,3,3,3};
int  move_f4[12]={2,2,2,2,2,2,4,4,4,4,4,4};
int  atack_f[6] ={0,0,0,0,0,0};
int  atack_f2[6]={0,0,0,0,0,0}; /*当たった時のフラグ*/
int  atack_f3[6]={0,0,0,0,0,0};
int  atack_f4[6]={0,0,0,0,0,0};
int  flag[7]={0,1,0,0,0,0,0}; 
int  s_flag[6]= {0,0,0,0,0,0};
int  s_flag2[6]={0,0,0,0,0,0};
int  s_flag3[6]={0,0,0,0,0,0};
int  s_flag4[6]={0,0,0,0,0,0};
int  info[2]={1,1};
int  nami=0;
int  nami2=0;
long beam2[5]={0,0,0,0,0};
long ray[6][4] ={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
long ray2[6][4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
long ray3[6][4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
long ray4[6][4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};
long hit[6]={0,0,0,0,0,0}; /*自弾発射*/
long block[8][4] ={{52,112,0,0},{60,112,0,0},{68,112,0,0},{76,112,0,0},
					{116,112,0,0},{124,112,0,0},{132,112,0,0},{140,112,0,0}};
long block2[8][4]={{52,120,0,0},{60,120,0,0},{68,120,0,0},{76,120,0,0},
					{116,120,0,0},{124,120,0,0},{132,120,0,0},{140,120,0,0}};
int  block_tahu[8] ={1,1,1,1,1,1,1,1};
int  block_tahu2[8]={1,1,1,1,1,1,1,1};
long tairyoku[6][2]={{196,88},{204,88},{212,88}, /*気座標*/
				{196,96},{204,96},{212,96}};
long item1[6]={0,0,0,0,0,0};
long item2[5][2]={{196,104},{204,104},{212,104}};
int  item3[3]={0,0,0}; /*アイテムフラグ*/
int	 fire[2]={0,0}; /*噴射するよ*/
int  end_f=0;
int  end=0;		/*これで終了よ*/	
long sco=0;		/*スコア*/
int  end_sco[10]={0,0,0,0,0,0,0,0,0,0};
int  spe_x=2;	/*自機のスピード*/
int  spe_t=4;	/*敵が一回に動く幅*/
int  haba=4;	/*横に動く回数*/
int  spe_b=3;	/*自機の弾のスピード*/
int  spe_bxl=1;		/*左端の弾のｘのスピード*/
int  spe_bxr=1;		/*右端の弾のｘのスピード*/
int  spe_by=3;		/*自機の弾の上へのスピード（Ｂ）*/
int  spe_bt=1;	/*敵の弾のスピード*/
int  spe_bt2=2; /*敵2の弾のスピード*/
int  spe_bt3=3; /*敵3の弾のスピード*/
int  ray_x=60;
int  ray2_x=70;
int  ray3_x=80;
int  ray4_x=90;
int  bang=8;	/*敵３の弾の角度*/
int  high=4;	/*縦の動く幅*/
int  tahu=1;	/*敵の体力*/
int  tahu_s=3;	/*自機の体力*/
int  blocker=3;
int  blocker1=6;
int  blocker2=8;
int  spe_t2=30; /*敵のスピード〜少ないほど早い〜*/
int  dansu=2;   /*偶数じゃないといけないよ*/
int  kazu[7]={0,0,0,18,0,0,0};	/*倒した数*/
int  kazu_s=35; /*出現数*/
int  stage=1;	/*ステージ番号*/
int  block_f=0;
int  tairyoku_f[2]={0,0};
int  i,j,k,scr;
long g;
int  x_flag[6]={0,0,0,0,0,0}; /*敵の弾のｘの範囲のためのフラグ*/
int  x_flag2[6]={0,0,0,0,0,0};
int  x_flag3[6]={0,0,0,0,0,0};
int  x_flag4[6]={0,0,0,0,0,0};
int  a[6]={0,0,0,0,0,0};
int  a2[6]={0,0,0,0,0,0};
int  a3[6]={0,0,0,0,0,0};
int  a4[6]={0,0,0,0,0,0};
int  loop=0;
long beam[12]={0,0,0,0,0,0,0,0,0,0,0,0}; /*自キャラの弾の座標*/
long bren[2]={0,0};/*弾ニ連射*/
long dan[7]={0,0,1,0,1,0,0}; /*下に行った回数を計算*/
int  pow=0;
/*beam[6]	左の弾のX_beam[7]   中の弾のX_beam[8]   右の弾のX
  beam[9]	左の弾のY_beam[10]	中の弾のY_beam[11]	右の弾のY*/
int  gun_f[4]={0,0,0,0};
int  flag_b[4]={0,0,0,0};		
/*flag_b[]:[0]Ｂの弾の発射確認フラグ       [1]Ｂの左の弾が当たったかどうか
		   [2]Ｂの中の弾が当たったかどうか [3]Ｂの右の弾が当たったかどうか*/
/*gun_f[]: [0]:Aボタンの弾       [1]:Ｂボタンの弾(左)
		   [2]:Ｂボタンの弾(中)  [3]:Ｂボタンの弾(右)*/
int  limit1=0; /*Ｂボタンの弾の当たった数(弾用)*/
int  wait_f=1;
long ring=0;
int senter_d_x=X_SLIT+((X_BLIT-X_SLIT)-((X_BLIT-X_SLIT)%2))/2;	/*ボスの移動できる画面のX座標の中心*/
int senter_d_y=Y_SLIT+((Y_BLIT-Y_SLIT)-((Y_BLIT-Y_SLIT)%2))/2;	/*ボスの移動できる画面のY座標の中心*/
int ma_dori[34]={/*0*/0,5,0,3,0,/*5*/60,0,5,0,2,/*10*/0,100,0,5,0,/*15*/5,0,10,0,1,/*20*/0,3,0,5,0,/*25*/2,0,4,0,1,/*30*/0,5,0,5};
/*[0]:move_bossの間取りの現在の値 [1]:move_bossの間取りの上限値
  [2]:ボス表示の間取りの現在の値 [3]:ボス表示の間取りの上限値
  [4]:ボスが中央に来た時の間取りの現在の値 [5]:ボスが中央に来た時の間取りの上限値
  [6]:moveの間取りの現在の値 [7]:moveの間取りの上限値
  [8]:shotの間取りの現在の値 [9]:shotの間取りの上限値
  [10]:move_bakuの間取りの現在の値 [11]:move_bakuの間取りの上限値
  [12]:boss_shot1の間取りの現在の値(追跡弾) [13]:boss_shot1の間取りの上限値(追跡弾)
  [14]:boss_shot2の間取りの現在の値 [15]:boss_shot2の間取りの上限値
  [16]:boss_shot3の間取りの現在の値 [17]:boss_shot3の間取りの上限値
  [18]:boss_shot4の間取りの現在の値(レーザー) [19]:boss_shot4の間取りの上限値(レーザー)
  [20]: [21]:
  [22]:boss_engo_moveの間取りの現在の値 [23]:boss_engo_moveの間取りの上限値
  [24]:engo_shotの間取りの現在の値 [25]:engo_shotの間取りの上限値
  [26]: [27]:
  [28]:engo_shot2の間取りの現在の値 [29]:engo_shot2の間取りの上限値
  [30]:engo_shot3の間取りの現在の値 [31]:engo_shot3の間取りの上限値
  [32]:engo_shot4の間取りの現在の値 [33]:engo_shot4の間取りの上限値*/
int sps[6]={0,-1,0,0,0,50};
/*[0]:ボスの絵の切り替え表示フラグ [1]:ボスの絵の切り替え表示フラグの増加量
  [2]:爆発の絵の切り替え表示フラグ [3]:ボスの絵の表示折り返しフラグ
  [4]:ボスの絵の表示折り返し回数の現在の値 [5]:ボスの絵の表示折り返し回数の上限値*/
int stop_flag[7]={0,0,0,1,0,0,0}; /*[0]:ボスが死んだときのフラグ [1]:move_bakuの終始フラグ
[2]:hantei_mychの終了フラグ [3]:boss_shot1の終始フラグ [4]:boss_shot2の終始フラグ
[5]:boss_shot3の終始フラグ [6]:boss_engo_moveの終始フラグ*/
int boss_x2[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int boss_y2[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int sta_flag=0;			/*ボスが出現するときのフラグ*/
int boss_x[2]={1,86};
/*[0]:ボスのX軸方向への移動量
  [1]:ボスのX座標の初期値(現在の値)*/
int boss_y[2]={1,-32};
/*[0]:ボスのY軸方向への移動量
  [1]:ボスのY座標の初期値(現在の値)*/
int turn[7]={0,0,0,0,0,0,0};
/*[0]:壁に跳ね返った回数1　　　　				[1]:方向決めフラグ
  [2]:跳ね返り切り替え替えフラグ				[3]:ボスのX座標が中央かどうか判断するフラグ
  [4]:ボスのY座標が中央かどうか判断するフラグ   [5]:壁に跳ね返った回数2 				
  [6]:動作繰り返しフラグ*/
long temp1[4]={0,0,0,0};
/*ボスの当り判定のときに計算した座標を入れる([0]:X座標 [1]:Y座標)
  自キャラの当り判定のときに計算した座標を入れる([2]:X座標 [3]:Y座標)*/
long temp_x2[5];
long temp_y2[5];
long temp_x;
long temp_y;
int tahu_boss[2]={0,20}; /*[0]:ボスの体力現在の値(保存用) [1]:ボスの体力の上限*/
int boss_bm[3]={0,0,0}; /*[0]:boss_shot1の中の弾発射開始/発射中フラグ
[1]:boss_shot2の中の弾発射開始/発射中フラグ [2]:boss_shot3の中の弾発射開始/発射中フラグ*/
int boss_ray_x1[4]={0,0,1,1};/*[2 3]:移動量*/
int boss_ray_y1[3]={0,0,1};
int boss_ray_f1[5]={0,0,0,0,0};/*[2]:弾の個数のカウント [3 4]:追跡弾がまっすぐ飛んでいく*/
int down[2]={-4,4};
int tahu_mych[2]={0,20}; /*[0]:自キャラの体力現在の値 [1]:自キャラの体力の上限*/
int boss_ray_x2[14]={-15,-15,-15,-15,-15,0,0,0,0,0,0,0,0,0};
int boss_ray_y2[6]={0,0,0,0,0,1};
int boss_ray_f2[6]={0,0,0,0,0,0};
int boss_ray_x3[7]={0,0,0,0,0,0,0};
int boss_ray_mx3[7]={0,0,0,0,0,0,0};
int boss_ray_y3[7]={0,0,0,0,0,0,0};
int boss_ray_my3[7]={2,2,2,2,2,2,2};
int sps3_now[7]={0,0,0,0,0,0,0};/*[0]:壁に跳ね返る弾の表示の間取りの現在の値*/
int sps3_lim[7]={10,10,10,10,10,10,10};/*[0]:壁に跳ね返る弾の表示の間取りの上限値*/
int sps3[7]={0,0,0,0,0,0,0};
int boss_ray_st3[2]={0,0};
int dan_p=7;
int boss_ray_f3[7]={1,1,1,1,1,1,1};
int dan_temp1=0;
int dan_temp2=0;
long temp_x3[7];
long temp_y3[7];
int boss_ray_sf=0;
int boss_br_f=0;
int dan_flag=0;
int razer_x[5]={0,0,0,0,0};
int razer_y[5]={0,0,0,0,0};
int razer_mf[5]={9,0,0,0,0};
int razer_mx[5]={0,0,0,0,0};
int razer_my[5]={1,1,1,1,1};
int razer_f[6]={0,0,0,0,0,0};
int razer_off=0;
int stmych=0;
long temp_x4[5];
long temp_y4[5];
int bk;
int boss_ray_clear=0;
int boss_razer_sf=0;
int boss_engo_ms=0;
int boss_engo_x[4]={104,0,0,0};
int boss_engo_y[4]={0,0,0,0};
int boss_engo_mx=1;
int engo_shot_s=0;
int engo_shot_x=0;
int engo_shot_y=0;
int engo_shot_f=0;
int engo_shot_my=1;
long engo_temp_x=0;
long engo_temp_y=0;
long engo_temp_x2=0;
long engo_temp_y2=0;
long engo_temp_x3=0;
long engo_temp_y3=0;
int tahu_engo[2]={0,5};
int bv[126];
int b_scr=0;
int end_flag[3]={0,0,0};/*[1]:boss [2]:mych*/
int spe_y=1;				/*自機のスピード(y)*/
int my_gage_x[3]={216,216,216};
int my_gage_y[3]={136,128,120};
int my_gage_f[3]={0,0,1};
int engo_razer_off=0;
int engo_razer_f[6]={0,0,0,0,0,0};
int engo_razer_x[5]={0,0,0,0,0};
int engo_razer_y[5]={0,0,0,0,0};
int engo_razer_sf=0;
int engo_razer_mf[5]={9,0,0,0,0};
int engo_razer_mx[5]={0,0,0,0,0};
int engo_razer_my[5]={1,1,1,1,1};
long temp_x5[5];
long temp_y5[5];
int engo_bm[3]={0,0,0};
int engo_ray_x3[14]={-15,-15,-15,-15,-15,0,0,0,0,0,0,0,0,0};
int engo_ray_y3[6]={0,0,0,0,0,1};
int engo_ray_f3[6]={0,0,0,0,0,0};
long engo_temp_x4[5];
long engo_temp_y4[5];
int engo_ray_x4[4]={0,0,1,1};
int engo_ray_y4[3]={0,0,1};
int engo_ray_f4[5]={0,0,0,0,0};
long temp_x6;
long temp_y6;

/*関数*/
void text();	/*表示*/
void open1();	/*MENU*/
void open2();	/*STATUS*/
void open3();	/*LEVEL*/
void open4();	/*BLOCK*/
void cleardisplay();	/*画面の初期化*/
void g_colortv();		/*画面､色の設定*/
int  gnumber_ch(int);	/*キャラクタ番号設定*/
void gnumber_sp();		/*スプライト設定*/
void move();			/*mych移動*/
void move_t();			/*teki移動*/
void shot();			/*Aで弾を撃つ*/
void shot2();			/*連射*/
void b_shot();			/*Bでボムを撃つ*/
void wall();			/*壁表示*/
void gen1();			/*敵４を表現*/
void gen2();
void sha();
void item();			/*アイテムを出現*/
void score();			/*得点*/
void hantei_t();		/*敵の当たり判定*/
void hantei_t2();
void shot_t();			/*敵が撃ってくるよ*/
void hantei();			/*自機の当たり判定*/
void newhero();			/*敵をかっこよく出現*/
void teki_down();       /*下方向移動*/
void nobi();
void title();			/*タイトル画面*/
void sound_cl();		/*音源のクローズ*/
void time();			/*ポーズ*/
void opening();			/*ファースト画面*/
void starting();
void format();
void stage1();
void end1();			/*gameclear*/
void end2();			/*gameover*/
void staff();
void staff2();
void staff3();
void staff4();
void staff5();
void staff6();
void staff7();
void staff8();
void staff9();
void ending();
void ending1();
void ending2();
void ending3();
void move_boss();		/*ボスの移動*/
void shot1();
void move1();
void display();
void move_boss();
void get_point();
void hantei_boss();
void move_baku();
void boss_shot1();
void boss_shot2();
void boss_shot3();
void tuiseki();
void hantei_mych();
void boss_shot4();
void ray_ray();
void get_point2();
void boss_engo_move();
void engo_shot();
void hantei_engo();
void put_bv();
void move_m();
void score2();
void boss_init();
void my_gage();
void engo_shot2();
void engo_shot3();
void engo_shot4();
void tuiseki2();

unsigned short bmp_clear[]={ /*画面の初期化*/
	0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000
};

void main(int argc,char *argv[]) /*MAINプログラム*/
{
/*音源の初期化--------------------------------------------------------*/
	void far *res=_pc->_resource;
	void far *bgm;
	void far *bgm2;
	void far *bgm3;
	void far *bgm4;
	void far *bgm5;
	void far *bgm6;
	void far *bgm7;
	void far *se;
	if(open_sound_il(&soundIL) != E_FS_SUCCESS) { /* ドライバが存在しない */
        return;
    }
	sounddrv_init();
	sound_open();
	for(i=0;i<8;i++){
		switch(((res_t far *)res)->type){
			case RESID_MUSIC:
				if(bgm_n==0){
					bgm=(res_music_t far *)res;
					bgm_n=1;
				}else{
					if(bgm_n==1){
						bgm2=(res_music_t far *)res;
						bgm_n=2;
					}
					else{
						if(bgm_n==2){
							bgm3=(res_music_t far *)res;
							bgm_n=3;
						}else{
							if(bgm_n==3){
								bgm4=(res_music_t far *)res;
								bgm_n=4;
							}
							else{
								if(bgm_n==4){
									bgm5=(res_music_t far *)res;
									bgm_n=5;
								}
								else{
									if(bgm_n==5){
										bgm6=(res_music_t far *)res;
										bgm_n=6;
									}
									else{
										if(bgm_n==6){
											bgm7=(res_music_t far *)res;
											bgm_n=7;
										}
									}
								}
							}
						}
					}
				}
				break;
			case RESID_SE:
				se=(res_se_t far *)res;
				break;
			default:
				break;
		}
		res=(BYTE far *)res+(((res_t far *)res)->size<<4); /*リソースをひとつ進ます*/
	}
	se_play(se, -1);
/*-------------------------------------------------------------------------------------音*/
	title();
	bgm_play(bgm3,PLAY_LOOP);
	text();
	if(end_f!=1){
		opening();
		cleardisplay();
		ret_code=key_press_check();
		while(1){
			if(stage%2==1){
				bgm_stop();
				if(info[0]==1) bgm_play(bgm,PLAY_LOOP);
				if(info[0]==2) bgm_play(bgm7,PLAY_LOOP);
				if(info[0]==3) bgm_play(bgm4,PLAY_LOOP);
				while(1){
					sys_wait(wait_f);
					ret_code_b=ret_code;
					ret_code=key_press_check();
					screen_set_scroll(SCREEN1,0,-scr);/*スクロール*/
					scr++;
					if(((ret_code_b&KEY_A)==0)&&(ret_code&KEY_A&&pow==0)
								||(flag[0]==1)) shot();/*一発目*/
					if(((ret_code_b&KEY_A)==0)&&(ret_code&KEY_A&&pow==0)
						||(flag[6]==1)) shot2();/*2発目*/
					if(((ret_code_b&KEY_A)==0)&&(ret_code&KEY_A&&pow==1)||
						((flag_b[0]==1)&&(limit1!=3))) b_shot();
					if(key_press_check()&KEY_B) time();			
					ring++;
					move_t();
					if(end!=2){ /*敵が下まで来てない時*/
						hantei();
						if(hit[0]!=tahu_s){ /*倒されてない時*/
							shot_t();    item();  hantei_t();
							hantei_t2(); move();  teki_down(); 
							newhero();   score(); wall();
						}
						else{ /*死んだとき*/
							nobi();
							bgm_stop();
							bgm_play(bgm5,PLAY_LOOP);
							end2(); end_f=1; 
							break;
						}
					}
					if(kazu[0]==kazu_s){ /*数を倒したとき*/
						sha(); 
						end=1; break;
					}
					if((ret_code&KEY_Y3)!=0){ /*リセット*/
						end_f=2; break;
					}
				}
			}
			else{
				bgm_stop();
				bgm_play(bgm6,PLAY_LOOP);
				display();
				get_point();
				ret_code=key_press_check();
				bk=ret_code;
				if(info[0]==1){
					tahu_boss[1]+=2;
					tahu_engo[1]+=2;
				}
				if(info[0]==2){
					tahu_boss[1]+=3;
					tahu_engo[1]+=3;
				}
				if(info[0]==3){
					tahu_boss[1]+=4;
					tahu_engo[1]+=4;
				}
				for(i=0;i<3;i++) sprite_set_location(i+42,my_gage_x[i],my_gage_y[i]);
				while(end_flag[0]==0){
					score2();
					screen_set_scroll(SCREEN1,0,b_scr);
					if(ma_dori[26]>=ma_dori[27]){
						ma_dori[26]=0;
						b_scr++;
					}
					else ma_dori[26]++;
					get_point();		
					if(stop_flag[0]==0){
						move_boss();
						hantei_boss();
						if((stop_flag[3]==0)||(boss_bm[0]==1)) boss_shot1();
						if((stop_flag[4]==0)||(boss_bm[1]==1)) boss_shot2();
						if((stop_flag[5]==0)&&(boss_bm[2]==1||boss_ray_st3[0]==1)) boss_shot3();
						if(razer_off==1||razer_f[5]==1) boss_shot4();
					}
					hantei_mych();
					if(stop_flag[1]==1) move_baku();
					if((key_press_check()&KEY_A)||flag[0]==1) shot1();
					if(key_press_check()&KEY_B) time();
					if(stmych==0) move_m();
					else if(boss_ray_clear==0){
						boss_ray_clear=1;
						for(i=0;i<5;i++){
							boss_ray_x2[i]=boss_ray_y2[i]=-15;
							sprite_set_location(i+20,boss_ray_x2[i],boss_ray_y2[i]);
						}
					}
					if(stop_flag[6]==0){
						boss_engo_move();
						engo_shot();
						if(stage>=4) engo_shot3();
						if(stage>=6) engo_shot2();
						if(stage>=8) engo_shot4();
						hantei_engo();
					}
					my_gage();
					bk=ret_code;
					ret_code=key_press_check();
					if(end_flag[1]==1||end_flag[2]==1){
						end_flag[0]=1;
						end_sco[stage-1]=sco;
						if(end_flag[1]==1) end=1;
						if(end_flag[2]==1) end=2;
					}
					if(end==2){ /*死んだとき*/
						bgm_stop();
						bgm_play(bgm5,PLAY_LOOP);
						end_sco[stage-1]=sco;
						end2(); end_f=1;
						break;
					}
					if((ret_code&KEY_Y3)!=0){ /*リセット*/
						end_f=2;
						break;
					}
				}
			}
			if(end==1){ /*クリアーしたとき*/
				bgm_stop();
				bgm_play(bgm3,PLAY_LOOP);
				if(stage==10) end1();
				else          stage1(); 
			}
			
			if(end_f==1){ /*死んだー＞得点*/
				ending(); staff(); 
				staff2(); 
				break;
			}
			if(end_f==2) break; /*リセット*/
			if(stage!=10 && end_f==0){ /*次のステージへ*/
				end_sco[stage-1]=sco;
				stage++; end=0; sco=0;
				if(stage%2==1) format(); /*DX*/
				else boss_init(); /*BOSS*/
				opening();
				cleardisplay();
				bgm_stop();
				bgm_play(bgm,PLAY_LOOP);
			}
			else{
				end_sco[stage-1]=sco;
				ending(); staff3(); 
				staff4(); staff5();
				staff6(); staff7();
				staff8(); staff9();
				break;
			}
		}
		sound_cl();
	}
}

void sha()
{
	ring=0;
	for(i=0;i<50000;i++);
	while(1){
		ring++;
		if(ring%200==0){
			sprite_set_location(0,mych[0],mych[1]);
			sprite_set_location(79,mych[0],mych[1]+8);
			mych[1]--;
		}
		if(mych[1]==-10)
			break;
	}
}

void starting()
{
	sprite_set_location(92,mych[0],mych[1]);
	sprite_set_location(91,mych[0]+8,mych[1]);
	for(i=0;i<90;i++){
		mych[0]++;
		sprite_set_location(92,mych[0],mych[1]);
		sprite_set_location(91,mych[0]+8,mych[1]);
		for(i=0;i<1000;i++);
	}
	mych[0]+=8;
	sprite_set_location(1,mych[0],mych[1]);
}

void open1()
{
	text_screen_init();
	text_put_string(4,2,"MENU");
	text_put_string(4,6,"START");
	text_put_string(4,8,"STATUS");
	text_put_string(4,10,"EXIT");
	text_put_char(2,2,0x02);
	text_put_char(2,6,0x18);
	text_put_char(2,8,0x1A);
	text_put_char(2,10,0x42);
}

void open2()
{
	text_screen_init();
	text_put_string(4,3,"STATUS");
	text_put_string(4,7,"LEVEL");
	text_put_string(4,9,"BLOCK");
	text_put_string(4,11,"BACK");
	text_put_char(2,3,0x01);
	text_put_char(2,7,0x18);
	text_put_char(2,9,0x1A);
	text_put_char(2,11,0x42);
}

void open3()
{
	text_screen_init();
	text_put_string(4,2,"LEVEL");
	text_put_string(4,6,"B RANK");
	text_put_string(4,8,"A RANK");
	text_put_string(4,10,"S RANK");
	text_put_string(4,14,"B:BACK");
	text_put_char(2,2,0x0d);
	text_put_char(2,6,0x18);
	text_put_char(2,8,0x1a);
	text_put_char(2,10,0x19);
}

void open4()
{
	text_screen_init();
	text_put_string(4,2,"BLOCK");
	text_put_string(4,6,"B RANK");
	text_put_string(4,8,"A RANK");
	text_put_string(4,10,"S RANK");
	text_put_string(4,14,"B:BACK");
	text_put_char(2,2,0x0e);
	text_put_char(2,6,0x18);
	text_put_char(2,8,0x1a);
	text_put_char(2,10,0x19);
}

void opening()
{
	bgm_stop();
	text_screen_init();
	for(i=0;i<1000;i++){
		text_put_string(5,8,"STAGE ");
		text_put_numeric(11,8,1,NUM_SIGNED,stage);
		if(info[0]==1) text_put_char(1,8,0x42);
		if(info[0]==2) text_put_char(1,8,0x41);
		if(info[0]==3) text_put_char(1,8,0x53);
		text_put_char(2,8,0x2d);
		if(info[1]==1) text_put_char(3,8,0x42);
		if(info[1]==2) text_put_char(3,8,0x41);
		if(info[1]==3) text_put_char(3,8,0x53);
	}
}

void text()
{
	open1();
	while(1){
		ret_code_open=key_press_check();
		if((ret_code_open&KEY_X1)!=0){
			se_play_n(2); opening();
			if(info[0]==2){
				kazu_s=45; wait_f=0;
			}
			if(info[0]==3){
				kazu_s=55; wait_f=0;
			}
			if(info[1]==2){
				blocker=2; blocker1=4; blocker2=6;
			}
			if(info[1]==3){
				blocker=2; blocker1=3; blocker2=4;
			}
			break;
		}
		if((ret_code_open&KEY_X2)!=0){ /*設定押したとき*/
			se_play_n(2);
			open2();
			for(i=0;i<50000;i++);
			while(1){
				ret_code_open=key_press_check();
				if((ret_code_open&KEY_X1)!=0){ /*LEVEL*/
					se_play_n(2);
					open3();
					for(i=0;i<50000;i++);
					while(1){
						ret_code_open=key_press_check();
						if((ret_code_open&KEY_X1)!=0){ /*BRANK*/
							se_play_n(2);
							info[0]=1; open2();
							for(i=0;i<50000;i++);
							ret_code_open=key_press_check();
							break;
						}
						if((ret_code_open&KEY_X2)!=0){ /*ARANK*/
							se_play_n(2);
							info[0]=2; open2();
							for(i=0;i<50000;i++);
							ret_code_open=key_press_check();
							break;
						}
						if((ret_code_open&KEY_X3)!=0){ /*SRANK*/
							se_play_n(2);
							info[0]=3; open2(); 
							for(i=0;i<50000;i++);
							ret_code_open=key_press_check();
							break;
						}
						if((ret_code_open&KEY_B)!=0){  /*BACK*/
							se_play_n(2);
							open2();
							for(i=0;i<50000;i++);
							ret_code_open=key_press_check();
							break;
						}
					}
				}
				if((ret_code_open&KEY_X2)!=0){ /*BLOCK*/
					se_play_n(2);
					open4();
					for(i=0;i<50000;i++);
					while(1){
						ret_code_open=key_press_check();
						if((ret_code_open&KEY_X1)!=0){ /*BRANK*/
							se_play_n(2);
							info[1]=1; open2();
							for(i=0;i<50000;i++);
							ret_code_open=key_press_check();
							break;
						}
						if((ret_code_open&KEY_X2)!=0){ /*ARANK*/
							se_play_n(2);
							info[1]=2; open2();   
							for(i=0;i<50000;i++);
							ret_code_open=key_press_check();
							break;
						}
						if((ret_code_open&KEY_X3)!=0){ /*SRANK*/
							se_play_n(2);
							info[1]=3; open2();   
							for(i=0;i<50000;i++);
							ret_code_open=key_press_check();
							break;
						}
						if((ret_code_open&KEY_B)!=0){  /*BACK*/
							se_play_n(2);
							open2();   
							for(i=0;i<50000;i++);
							ret_code_open=key_press_check();
							break;
						}
					}
				}
				if((ret_code_open&KEY_B)!=0){ /*BACK押したとき*/
					se_play_n(2);
					open1(); 
					for(i=0;i<50000;i++);
					ret_code_open=key_press_check();
					break;
				}
			}
		}
		if((ret_code_open&KEY_B)!=0){
			se_play_n(2);
			end_f=1; break;
		}
	}
}

void item()
{
	if(kazu[0]!=0 && kazu[0]%8==0 && item1[2]==0
		&& item1[4]<=2 && kazu[5]!=kazu[0]){ /*アイテム出現*/
		kazu[5]=kazu[0];
		item1[0]=teki5[tairyoku_f[1]-1][0]; /*X座標*/
		item1[1]=teki5[tairyoku_f[1]][1]; /*Y座標*/
		sprite_set_location(75+item1[4],item1[0],item1[1]);
		item1[2]=1;
	}
	if(item1[2]==1){ /*進める*/
		item1[1]+=1;
		sprite_set_location(75+item1[4],item1[0],item1[1]);
	}
	if(item1[1]>144){ /*取れずに画面外へ*/
		item1[0]=item1[1]=-15;
		sprite_set_location(75+item1[4],item1[0],item1[1]);
		item1[2]=0;
	}
	if((((mych[0]-item1[0])*(mych[0]-item1[0])				
		+(mych[1]-item1[1])*(mych[1]-item1[1]))<64)
		&& item1[2]==1){ /*取得*/
		se_play_n(1); /*取得効果音*/
		item1[0]=item1[1]=-15;
		item1[2]=0; item3[item1[4]]=1;
		sprite_set_location(75+item1[4],item2[item1[4]][0],item2[item1[4]][1]);
		for(i=0;i<3;i++){ /*次のアイテムを設定*/
			if(item3[i]==0){
				item1[4]=i; break;
			}
		}
	}
	if(item3[0]==1&&item3[1]==1&&item3[2]==1){ /*Bボタン使用可能*/
		pow=1; ray_x=10; ray3_x=20;
		ray2_x=30; ray4_x=30; item1[4]=3;
	}
	else{
	    pow=0; ray_x=20;  ray2_x=30;
		ray3_x=40; ray4_x=50;
	}
}

void wall()/*ブロック*/
{
	if(block_f==0){
		for(i=0;i<8;i++){
			sprite_set_location(i+53,block[i][0],block[i][1]);
			sprite_set_location(i+61,block2[i][0],block2[i][1]);
		}
		block_f=1;
	}
	if(loop==5)  loop=0;
	else		 loop++;
	for(i=0;i<8;i++){
		/*当たり判定*/
		if((((block[i][0]-ray[loop][0])*(block[i][0]-ray[loop][0])
		+(block[i][1]-ray[loop][1])*(block[i][1]-ray[loop][1]))<64)
		&& block[i][3]==0 && move_f[loop+6]!=4)
			block[i][3]=1;
		if((((block[i][0]-ray2[loop][0])*(block[i][0]-ray2[loop][0])
		+(block[i][1]-ray2[loop][1])*(block[i][1]-ray2[loop][1]))<64)
		&& block[i][3]==0 && move_f2[loop+6]!=4)
			block[i][3]=2;
		if((((block[i][0]-ray3[loop][0])*(block[i][0]-ray3[loop][0])
		+(block[i][1]-ray3[loop][1])*(block[i][1]-ray3[loop][1]))<64)
		&& block[i][3]==0 && move_f3[loop+6]!=4)
			block[i][3]=3;
		if((((block[i][0]-ray4[loop][0])*(block[i][0]-ray4[loop][0])
		+(block[i][1]-ray4[loop][1])*(block[i][1]-ray4[loop][1]))<64)
		&& block[i][3]==0 && move_f4[loop+6]!=4)
			block[i][3]=4;
		if(block[i][3]!=0 && block[i][3]<=4){ /*当たったら*/
			if(block[i][2]==0){ /*壁@消去*/
				if(block_tahu[i]==blocker) block[i][2]=1;
				block_tahu[i]++;
			}
			if(block[i][2]==2){ /*壁A消去*/
				if(block_tahu[i]==blocker1) block[i][2]=3;
				block_tahu[i]++;
			}
			if(block[i][2]==4){ /*壁B消去*/
				if(block_tahu[i]==blocker2){ 
					block[i][2]=5; block[i][0]=block[i][1]=-17;
					sprite_set_location(i+53,-17,-17);
				}
				block_tahu[i]++;
			}
			if(block[i][3]==1){ /*一号弾*/
				ray[loop][0]=ray[loop][1]=-17;   ray[loop][2]=0;
				sprite_set_location(loop+25,-17,-17);
			}
			if(block[i][3]==2){ /*二号弾*/
				ray2[loop][0]=ray2[loop][1]=-17; ray2[loop][2]=0;
				sprite_set_location(loop+31,-17,-17);
			}
			if(block[i][3]==3){ /*三号弾*/
				ray3[loop][0]=ray3[loop][1]=-17; ray3[loop][2]=0;
				sprite_set_location(loop+37,-17,-17);
			}
			if(block[i][3]==4){ /*四号弾*/
				ray4[loop][0]=ray4[loop][1]=-17; ray4[loop][2]=0;
				sprite_set_location(loop+43,-17,-17);
			}
			block[i][3]=0;
		}
		if((((block2[i][0]-ray[loop][0])*(block2[i][0]-ray[loop][0])
		+(block2[i][1]-ray[loop][1])*(block2[i][1]-ray[loop][1]))<64)
		&& block2[i][3]==0 && move_f[loop+6]!=4)
			block2[i][3]=1;
		if((((block2[i][0]-ray2[loop][0])*(block2[i][0]-ray2[loop][0])
		+(block2[i][1]-ray2[loop][1])*(block2[i][1]-ray2[loop][1]))<64)
		&& block2[i][3]==0 && move_f2[loop+6]!=4)
			block2[i][3]=2;
		if((((block2[i][0]-ray3[loop][0])*(block2[i][0]-ray3[loop][0])
		+(block2[i][1]-ray3[loop][1])*(block2[i][1]-ray3[loop][1]))<64)
		&& block2[i][3]==0 && move_f3[loop+6]!=4)
			block2[i][3]=3;
		if((((block2[i][0]-ray4[loop][0])*(block2[i][0]-ray4[loop][0])
		+(block2[i][1]-ray4[loop][1])*(block2[i][1]-ray4[loop][1]))<64)
		&& block2[i][3]==0 && move_f4[loop+6]!=4)
			block2[i][3]=4;
		if(block2[i][3]!=0 && block2[i][3]<=4){ /*当たったら*/
			if(block2[i][2]==0){ /*壁@消去*/
				if(block_tahu2[i]==blocker) block2[i][2]=1;
				block_tahu2[i]++;
			}
			if(block2[i][2]==2){ /*壁A消去*/
				if(block_tahu2[i]==blocker1) block2[i][2]=3;
				block_tahu2[i]++;
			}
			if(block2[i][2]==4){ /*壁B消去*/
				if(block_tahu2[i]==blocker2){ 
					block2[i][2]=5; block2[i][0]=block2[i][1]=-17;
					sprite_set_location(i+61,-17,-17);
				}
				block_tahu2[i]++;
			}
			if(block2[i][3]==1){ /*一号弾*/
				ray[loop][0]=ray[loop][1]=-17; ray[loop][2]=0;
				sprite_set_location(loop+25,-17,-17);
			}
			if(block2[i][3]==2){ /*二号弾*/
				ray2[loop][0]=ray2[loop][1]=-17; ray2[loop][2]=0;
				sprite_set_location(loop+31,-17,-17);
			}
			if(block2[i][3]==3){ /*三号弾*/
				ray3[loop][0]=ray3[loop][1]=-17; ray3[loop][2]=0;
				sprite_set_location(loop+37,-17,-17);
			}
			if(block2[i][3]==4){ /*四号弾*/
				ray4[loop][0]=ray4[loop][1]=-17; ray4[loop][2]=0;
				sprite_set_location(loop+43,-17,-17);
			}
			block2[i][3]=0;
		}
		if(block[i][2]==1){
			sprite_set_char(i+53,17); /*ブロック2の設定*/
			sprite_set_location(i+53,block[i][0],block[i][1]);
			block[i][2]=2;
		}
		if(block[i][2]==3){
			sprite_set_char(i+53,18); /*ブロック3の設定*/
			sprite_set_location(i+53,block[i][0],block[i][1]);
			block[i][2]=4;
		}
		if(block2[i][2]==1){
			sprite_set_char(i+61,17); /*ブロック2の設定*/
			sprite_set_location(i+61,block2[i][0],block2[i][1]);
			block2[i][2]=2;
		}
		if(block2[i][2]==3){
			sprite_set_char(i+61,18); /*ブロック3の設定*/
			sprite_set_location(i+61,block2[i][0],block2[i][1]);
			block2[i][2]=4;
		}
	}
}

void move() /*自キャラの移動*/
{
	if(ret_code&KEY_X2 && hit[3]==0){ /*左移動*/
		if(mych[0]<=174){
			mych[0]+=spe_x;
			sprite_set_location(0,mych[0],mych[1]);
		}
		else
			return;
	}
	if(ret_code&KEY_X4 && hit[3]==0){ /*右移動*/
		if(9<=mych[0]){
			mych[0]-=spe_x;
			sprite_set_location(0,mych[0],mych[1]);
		}
		else
			return;
	}
}


void cleardisplay() /*画面の初期化*/
{
	int cnt=29; /*cnt:カウントキャラクタ*/
	for(i=0;i<2;i++)
		p1[i]=cnt+i;
	for(i=0;i<2;i++)
		p2[i]=cnt+3+i;
	for(i=0;i<6;i++)
		p3[i]=cnt+6+i;
	g_colortv();
	gnumber_ch(cnt);
	gnumber_sp();
	/*画面(screen1)の初期化*/
	screen_fill_char(SCREEN1,0,0,32,32,0x0000);
	/*画面(screen1)の表示*/
	for(i=0;i<32;i+=2)
		screen_set_char(SCREEN1,0,i,1,2,p1);
	for(j=0;j<31;j+=2){
		for(i=1;i<25;i+=3){
		screen_set_char(SCREEN1,i,j,3,2,p3);
		}
	}
	for(i=0;i<32;i++)
		screen_set_char(SCREEN1,23,i,2,2,p2);
}

void g_colortv()	/*画面,色の設定*/
{
	display_control(0);                   /*SPR/SCR2/SCR1 ALL OFF*/
	lcd_set_color(0x6420,0xfca8);         /*色の設定*/
	palette_set_color(0,0X7650);          /*パレットの設定*/
	screen_set_scroll(SCREEN1,0,0);		  /*スクロールしない*/
	display_control(DCM_SCR1|DCM_SCR2|DCM_SPR|DCM_SCR2_WIN_INSIDE); /*SPR/SCR1/SCR2 ON*/
	screen2_set_window(24*8,3*8,4*8,6*8); /*windowの設定*/
	text_window_init(24,3,4,6,340);     /*windowの初期化*/
}

int gnumber_ch(int cnt) /*キャラクタ番号の設定*/
{
	font_set_colordata(0,1,bmp_clear);	      /*白*/
	font_set_colordata(1,1,bmp_mych);         /*自機*/
	font_set_colordata(2,1,bmp_cht);          /*敵*/
	font_set_colordata(3,1,bmp_ray);          /*自機の弾*/
	font_set_colordata(4,1,bmp_bomber);       /*ボム１*/
	font_set_colordata(5,1,bmp_bomber2);      /*ボム２*/
	font_set_colordata(6,1,bmp_ray_t);        /*敵の弾*/
	font_set_colordata(7,1,bmp_teki_R);       /*敵右向き*/
	font_set_colordata(8,1,bmp_teki_L);       /*敵左向き*/
	font_set_colordata(9,1,bmp_knife);        /*ナイフ*/
	font_set_colordata(10,1,bmp_bom3);        /*敵２の弾*/
	font_set_colordata(11,1,bmp_teki2_R);     /*敵２右向き*/
	font_set_colordata(12,1,bmp_teki2_L);     /*敵２左向き*/
	font_set_colordata(13,1,bmp_b_bom_center);/*自機の中央の弾*/
	font_set_colordata(14,1,bmp_b_bom_left);  /*自機の左の弾*/
	font_set_colordata(15,1,bmp_b_bom_right); /*自機の右の弾*/
	font_set_colordata(16,1,bmp_wall_break1); /*壁１*/
	font_set_colordata(17,1,bmp_wall_break2); /*壁２*/
	font_set_colordata(18,1,bmp_wall_break3); /*壁３*/
	font_set_colordata(19,1,bmp_ki);          /*気*/
	font_set_colordata(20,1,bmp_teki3);       /*敵３*/
	font_set_colordata(21,1,bmp_rei);         /*敵３の弾*/
	font_set_colordata(22,1,bmp_item);        /*アイテム*/
	font_set_colordata(23,1,bmp_yoko);		  /*横　〜@号〜*/
	font_set_colordata(24,1,bmp_yoko1);	      /*横２〜@号〜*/
	font_set_colordata(25,1,bmp_hunsya);	  /*噴射〜@号〜*/
	font_set_colordata(26,1,bmp_yoko3);       /*横３〜@号〜*/
	font_set_colordata(27,1,bmp_ray2);
	font_set_colordata(28,1,bmp_ray3);
	font_set_colordata(cnt,2,bmp_waku2);      /*left枠*/
	font_set_colordata(cnt+3,2,bmp_waku1);    /*right枠*/
	font_set_colordata(cnt+6,6,bmp_bv);       /*背景*/
}

void gnumber_sp() /*スプライトの設定*/
{
	sprite_set_char(0,1);    /*自機*/
	for(i=1;i<=6;i++)        /*敵１*/
		sprite_set_char(i,2);
	for(i=7;i<=12;i++)       /*敵２*/
		sprite_set_char(i,7);
	for(i=13;i<=18;i++)      /*敵３*/
		sprite_set_char(i,11);
	for(i=19;i<=24;i++)      /*敵４*/
		sprite_set_char(i,20);
	for(i=25;i<=30;i++)      /*敵弾1*/
		sprite_set_char(i,6);
	for(i=31;i<=36;i++)      /*敵弾2*/
		sprite_set_char(i,9);
	for(i=37;i<=42;i++)      /*敵弾3*/
		sprite_set_char(i,10);
	for(i=43;i<=48;i++)      /*敵弾4*/
		sprite_set_char(i,21);
	sprite_set_char(49,3);   /*自機弾*/
	sprite_set_char(50,14);  /*左-中央-右*/
	sprite_set_char(51,13);
	sprite_set_char(52,15);
	for(i=53;i<=68;i++)      /*壁*/
		sprite_set_char(i,16);
	for(i=69;i<=74;i++)      /*気*/
		sprite_set_char(i,19);
	for(i=75;i<=77;i++)		 /*アイテム*/
		sprite_set_char(i,22);
	sprite_set_char(78,3);	 /*自機弾連*/
	for(i=79;i<=90;i++)		 /*噴射*/
		sprite_set_char(i,25);
	sprite_set_char(91,23); /*横向き１*/
	sprite_set_char(92,24); /*横向き２*/
	sprite_set_char(93,26); /*横向き３*/
	sprite_set_char(94,27); /*ARANK弾*/
	sprite_set_char(95,28); /*SRANK弾*/
	sprite_set_char(96,27); /*ARANK弾２*/
	sprite_set_char(97,28); /*SRANK弾２*/
	sprite_set_range(0,98);  /*スプライトの個数*/
	/*スプライトの初期化*/
	for(i=0;i<98;i++)
		sprite_set_location(i,-15,-15);
	sprite_set_location(0,mych[0],mych[1]); 
	for(i=0;i<16;i++)       /*壁を表示*/
		sprite_set_location(i+53,block[i][0],block[i][1]);
	for(i=0;i<tahu_s;i++)        /*気を表示*/
		sprite_set_location(i+69,tairyoku[i][0],tairyoku[i][1]);
	tairyoku_f[1]=tahu_s;
}

void move_t()
{
	if(flag[1]==1){ /*右方向移動*/
		for(i=0;i<6;i++){
			teki6[i]+=spe_t; 
			if(move_f[i]==0){
				teki[i][0]+=spe_t;
				if(move_f[i+6]==2) sprite_set_char(i+1,7);
				if(move_f[i+6]==3) sprite_set_char(i+1,11);
				sprite_set_location(i+1,teki[i][0],teki[i][1]);
			}
			if(move_f2[i]==0){
				teki2[i][0]+=spe_t;
				if(move_f2[i+6]==2) sprite_set_char(i+7,7);
				if(move_f2[i+6]==3) sprite_set_char(i+7,11);
				sprite_set_location(i+7,teki2[i][0],teki2[i][1]);
			}
			if(move_f3[i]==0){
				teki3[i][0]+=spe_t;
				if(move_f3[i+6]==2) sprite_set_char(i+13,7);
				if(move_f3[i+6]==3) sprite_set_char(i+13,11);
				sprite_set_location(i+13,teki3[i][0],teki3[i][1]);
			}
			if(move_f4[i]==0){
				teki4[i][0]+=spe_t;
				if(move_f4[i+6]==2) sprite_set_char(i+19,7);
				if(move_f4[i+6]==3) sprite_set_char(i+19,11);
				sprite_set_location(i+19,teki4[i][0],teki4[i][1]);
			}
		}
		wait[1]++; /*移動回数計算*/
		wait[0]=0; /*間取りフラグ初期化*/
		flag[1]=0; /*次　間を取る*/
		if(wait[1]==haba){
			if(wait[3]==0){
				teki6[6]+=high; wait[3]=1; flag[1]=3;
				wait[2]=1; dan[0]++; /*下方向移動*/
				for(i=0;i<6;i++){
					teki6[i]-=spe_t; 
					if(move_f[i]==0){
						teki[i][0]-=spe_t;
						sprite_set_location(i+1,teki[i][0],teki[i][1]);
					}
					if(move_f2[i]==0){
						teki2[i][0]-=spe_t;
						sprite_set_location(i+7,teki2[i][0],teki2[i][1]);
					}
					if(move_f3[i]==0){
						teki3[i][0]-=spe_t; 
						sprite_set_location(i+13,teki3[i][0],teki3[i][1]);
					}
					if(move_f4[i]==0){
						teki4[i][0]-=spe_t;
						sprite_set_location(i+19,teki4[i][0],teki4[i][1]);
					}
				}
			}
		}
	}
	if(flag[1]==2){ /*左方向移動*/
		for(i=0;i<6;i++){
			teki6[i]-=spe_t; 
			if(move_f[i]==0){
				teki[i][0]-=spe_t;
				if(move_f[i+6]==2) sprite_set_char(i+1,8);
				if(move_f[i+6]==3) sprite_set_char(i+1,12);
				sprite_set_location(i+1,teki[i][0],teki[i][1]);
			}
			if(move_f2[i]==0){
				teki2[i][0]-=spe_t;
				if(move_f2[i+6]==2) sprite_set_char(i+7,8);
				if(move_f2[i+6]==3) sprite_set_char(i+7,12);
				sprite_set_location(i+7,teki2[i][0],teki2[i][1]);
			}
			if(move_f3[i]==0){
				teki3[i][0]-=spe_t;
				if(move_f3[i+6]==2) sprite_set_char(i+13,8);
				if(move_f3[i+6]==3) sprite_set_char(i+13,12);
				sprite_set_location(i+13,teki3[i][0],teki3[i][1]);
			}
			if(move_f4[i]==0){
				teki4[i][0]-=spe_t;
				if(move_f4[i+6]==2) sprite_set_char(i+19,8);
				if(move_f4[i+6]==3) sprite_set_char(i+19,12);
				sprite_set_location(i+19,teki4[i][0],teki4[i][1]);
			}
		}
		wait[1]++; /*移動回数計算*/
		wait[0]=0; /*間取りフラグ初期化*/
		flag[1]=0; /*次　間を取る*/
		if(wait[1]==haba){
			if(wait[3]==0){
				teki6[6]+=high; dan[0]++; flag[1]=3; 
				wait[2]=0; wait[3]=1;/*下方向移動*/
				for(i=0;i<6;i++){
					teki6[i]+=spe_t;
					if(move_f[i]==0){
						teki[i][0]+=spe_t;
						sprite_set_location(i+1,teki[i][0],teki[i][1]);
					}
					if(move_f2[i]==0){
						teki2[i][0]+=spe_t;
						sprite_set_location(i+7,teki2[i][0],teki2[i][1]);
					}
					if(move_f3[i]==0){
						teki3[i][0]+=spe_t;	
						sprite_set_location(i+13,teki3[i][0],teki3[i][1]);
					}
					if(move_f4[i]==0){
						teki4[i][0]+=spe_t;
						sprite_set_location(i+19,teki4[i][0],teki4[i][1]);
					}
				}
			}
		}
	}
	if(dan[0]==dansu && dan[1]==0) gen1();
	if(kazu[0]!=0 && dan[1]==1 && dan[3]!=-1 && kazu[1]!=kazu[0] 
		&& (kazu[6]==9||kazu[6]==10||kazu[6]==11) && dan[3]!=-2) gen2();
	for(i=0;i<6;i++){ /*GAME OVER*/
		if(teki[i][1]  >130) end=2;
		if(teki2[i][1] >130) end=2;
		if(teki3[i][1] >130) end=2;
		if(teki4[i][1] >130) end=2;
	}
	if(flag[1]==0) /*間を取る*/
		wait[0]++; /*間取りフラグ増加*/
	if(wait[0]==spe_t2){ /*間取り終了*/
		if(flag[1]==0 && wait[2]==1)
			flag[1]=2; /*左方向移動フラグON*/
		if(flag[1]==0 && wait[2]==0)
			flag[1]=1; /*右方向移動フラグON*/
	}
}

void teki_down()
{
	if(wait[1]==haba&&flag[1]==3){
		if(wait[3]==1&&wait[4]!=high){
			if(ring%2==0){
				wait[4]++;
				for(i=0;i<6;i++){
					if(move_f[i]==0){
						teki[i][1]++;
						if(move_f[i+6]==1&&fire[0]!=6){
							sprite_set_location(fire[0]+79,teki[i][0],teki[i][1]-8);
							fire[0]++;
						}
						if(move_f[i+6]==2) sprite_set_char(i+1,8);
						if(move_f[i+6]==3) sprite_set_char(i+1,12);
						if(move_f[i+6]==4&&fire[1]!=6){
							sprite_set_location(fire[1]+85,teki[i][0],teki[i][1]-8);
							fire[1]++;
						}
						sprite_set_location(i+1,teki[i][0],teki[i][1]);
					}
					if(move_f2[i]==0){
						teki2[i][1]++;
						if(move_f2[i+6]==1&&fire[0]!=6){
							sprite_set_location(fire[0]+79,teki2[i][0],teki2[i][1]-8);
							fire[0]++;
						}
						if(move_f2[i+6]==2) sprite_set_char(i+7,8);
						if(move_f2[i+6]==3) sprite_set_char(i+7,12);
						if(move_f2[i+6]==4&&fire[1]!=6){
							sprite_set_location(fire[1]+85,teki2[i][0],teki2[i][1]-8);
							fire[1]++;
						}
						sprite_set_location(i+7,teki2[i][0],teki2[i][1]);
					}
					if(move_f3[i]==0){
						teki3[i][1]++;   
						if(move_f3[i+6]==1&&fire[0]!=6){
							sprite_set_location(fire[0]+79,teki3[i][0],teki3[i][1]-8);
							fire[0]++;
						}
						if(move_f3[i+6]==2) sprite_set_char(i+13,8);
						if(move_f3[i+6]==3) sprite_set_char(i+13,12);
						if(move_f3[i+6]==4&&fire[1]!=6){
							sprite_set_location(fire[1]+85,teki3[i][0],teki3[i][1]-8);
							fire[1]++;
						}
						sprite_set_location(i+13,teki3[i][0],teki3[i][1]);
					}
					if(move_f4[i]==0&&dan[0]!=2){
						teki4[i][1]++;   
						if(move_f4[i+6]==1&&fire[0]!=6){
							sprite_set_location(fire[0]+79,teki4[i][0],teki4[i][1]-8);
							fire[0]++;
						}
						if(move_f4[i+6]==2) sprite_set_char(i+19,8);
						if(move_f4[i+6]==3) sprite_set_char(i+19,12);
						if(move_f4[i+6]==4&&fire[1]!=6){
							sprite_set_location(fire[1]+85,teki4[i][0],teki4[i][1]-8);
							fire[1]++;
						}
						sprite_set_location(i+19,teki4[i][0],teki4[i][1]);
					}
				}
			}
		}
		if(wait[4]==high){
			wait[4]=wait[3]=wait[1]=fire[0]=fire[1]=0;
			flag[1]=0;
			for(i=0;i<6;i++){
				sprite_set_location(i+79,-15,-15);
				sprite_set_location(i+85,-15,-15);
			}
		}
	}
}

void gen2()
{
	if(teki6[6]<25){ /*キャラとキャラとの間を保つ処理*/
		teki6[6]=25-teki6[6]; /*座標差を取得*/
		for(i=0;i<6;i++){
			if(move_f[i]==0){
				teki[i][1] +=teki6[6];
				sprite_set_location(i+1,teki[i][0],teki[i][1]);
			}
			if(move_f2[i]==0){
				teki2[i][1] +=teki6[6];
				sprite_set_location(i+7,teki2[i][0],teki2[i][1]);
			}
			if(move_f3[i]==0){
				teki3[i][1] +=teki6[6];
				sprite_set_location(i+13,teki3[i][0],teki3[i][1]);
			}
			if(move_f4[i]==0){
				teki4[i][1] +=teki6[6];
				sprite_set_location(i+19,teki4[i][0],teki4[i][1]);
			}
		}
	}
	kazu[1]=kazu[0]; kazu[6]-=6; teki6[6]=10;
	for(i=0;i<6;i++){
		if(ray[i][3]==0 && ray[i][2]==0 && move_f[i]==2 && dan[3]!=6){
			teki[i][0]=teki6[dan[3]]; teki[i][1]=0;
			if(dan[4]==1){ sprite_set_char(i+25,6);  move_f[i+6]=1;
			sprite_set_char(i+1,2);}
			if(dan[4]==2){ sprite_set_char(i+25,9);  move_f[i+6]=2;
			sprite_set_char(i+1,7);}
			if(dan[4]==3){ sprite_set_char(i+25,10); move_f[i+6]=3;
			sprite_set_char(i+1,11);}
			if(dan[4]==4){ sprite_set_char(i+25,21); move_f[i+6]=4;
			sprite_set_char(i+1,20);}
			teki7[dan[3]]=i+1; /*スプライト番号の格納*/
			dan[3]++; move_f[i]=3; kazu[3]++;
			sprite_set_location(i+1,teki[i][0],teki[i][1]);
			if(kazu[3]==kazu_s){ dan[3]=-2; break;}
			if(dan[3]==6) break;
		}
		if(ray2[i][3]==0 && ray2[i][2]==0 && move_f2[i]==2 && dan[3]!=6){
			teki2[i][0]=teki6[dan[3]];
			teki2[i][1]=0;
			if(dan[4]==1){ sprite_set_char(i+31,6);  move_f2[i+6]=1;
			sprite_set_char(i+7,2);}
			if(dan[4]==2){ sprite_set_char(i+31,9);  move_f2[i+6]=2;
			sprite_set_char(i+7,7);}
			if(dan[4]==3){ sprite_set_char(i+31,10); move_f2[i+6]=3;
			sprite_set_char(i+7,11);}
			if(dan[4]==4){ sprite_set_char(i+31,21); move_f2[i+6]=4;
			sprite_set_char(i+7,20);}
			teki7[dan[3]]=i+7; /*スプライト番号の格納*/
			dan[3]++; move_f2[i]=3; kazu[3]++;
			sprite_set_location(i+7,teki2[i][0],teki2[i][1]);
			if(kazu[3]==kazu_s){ dan[3]=-2; break;}
			if(dan[3]==6) break;
		}
		if(ray3[i][3]==0 && ray3[i][2]==0 && move_f3[i]==2 && dan[3]!=6){
			teki3[i][0]=teki6[dan[3]];
			teki3[i][1]=0;
			if(dan[4]==1){ sprite_set_char(i+37,6);  move_f3[i+6]=1;
			sprite_set_char(i+13,2);}
			if(dan[4]==2){ sprite_set_char(i+37,9);  move_f3[i+6]=2;
			sprite_set_char(i+13,7);}
			if(dan[4]==3){ sprite_set_char(i+37,10); move_f3[i+6]=3;
			sprite_set_char(i+13,11);}
			if(dan[4]==4){ sprite_set_char(i+37,21); move_f3[i+6]=4;
			sprite_set_char(i+13,20);}
			teki7[dan[3]]=i+13; /*スプライト番号の格納*/
			dan[3]++; move_f3[i]=3; kazu[3]++;
			sprite_set_location(i+13,teki3[i][0],teki3[i][1]);
			if(kazu[3]==kazu_s){ dan[3]=-2; break;}
			if(dan[3]==6) break;
		}
		if(ray4[i][3]==0 && ray4[i][2]==0 && move_f4[i]==2 && dan[3]!=6){
			teki4[i][0]=teki6[dan[3]];
			teki4[i][1]=0;
			if(dan[4]==1){ sprite_set_char(i+43,6);  move_f4[i+6]=1;
			sprite_set_char(i+19,2);}
			if(dan[4]==2){ sprite_set_char(i+43,9);  move_f4[i+6]=2;
			sprite_set_char(i+19,7);}
			if(dan[4]==3){ sprite_set_char(i+43,10); move_f4[i+6]=3;
			sprite_set_char(i+19,11);}
			if(dan[4]==4){ sprite_set_char(i+43,21); move_f4[i+6]=4;
			sprite_set_char(i+19,20);}
			teki7[dan[3]]=i+19; /*スプライト番号の格納*/
			dan[3]++; move_f4[i]=3; kazu[3]++;
			sprite_set_location(i+19,teki4[i][0],teki4[i][1]);
			if(kazu[3]==kazu_s){ dan[3]=-2; break;}
			if(dan[3]==6) break;
		}
	}
	if(dan[3]!=-2&&dan[4]==1&&dan[6]==0){ dan[4]=2; dan[6]=1; dan[3]=0;}
	if(dan[3]!=-2&&dan[4]==2&&dan[6]==0){ dan[4]=3; dan[6]=1; dan[3]=0;}
	if(dan[3]!=-2&&dan[4]==3&&dan[6]==0){ dan[4]=4; dan[6]=1; dan[3]=0;}
	if(dan[3]!=-2&&dan[4]==4&&dan[6]==0){ dan[4]=1; dan[6]=1; dan[3]=0;}
	dan[6]=0; teki7[6]=1; /*newhero 発動*/
}

void newhero()
{
	if(teki7[6]==1){
		if(teki7[7]==10){ /*終了*/
			teki7[6]=teki7[7]=0;
			for(i=0;i<6;i++){ /*活動再開*/
				if(1<=teki7[i] && teki7[i]<=6 && move_f[teki7[i]-1]==3 && teki7[i]!=0){
					move_f[teki7[i]-1]=0;
					teki[teki7[i]-1][0]=teki6[i]; teki[teki7[i]-1][1]=10;
					sprite_set_location(teki7[i],teki[teki7[i]-1][0],teki[teki7[i]-1][1]);
				}
				if(7<=teki7[i] && teki7[i]<=12 && move_f2[teki7[i]-7]==3 && teki7[i]!=0){
					move_f2[teki7[i]-7]=0;
					teki2[teki7[i]-7][0]=teki6[i]; teki2[teki7[i]-7][1]=10;
					sprite_set_location(teki7[i],teki2[teki7[i]-7][0],teki2[teki7[i]-7][1]);
				}
				if(13<=teki7[i] && teki7[i]<=18 && move_f3[teki7[i]-13]==3 && teki7[i]!=0){
					move_f3[teki7[i]-13]=0;
					teki3[teki7[i]-13][0]=teki6[i]; teki3[teki7[i]-13][1]=10;
					sprite_set_location(teki7[i],teki3[teki7[i]-13][0],teki3[teki7[i]-13][1]);
				}
				if(19<=teki7[i] && teki7[i]<=24 && move_f4[teki7[i]-19]==3 && teki7[i]!=0){
					move_f4[teki7[i]-19]=0;
					teki4[teki7[i]-19][0]=teki6[i]; teki4[teki7[i]-19][1]=10;
					sprite_set_location(teki7[i],teki4[teki7[i]-19][0],teki4[teki7[i]-19][1]);
				}
				teki7[i]=0;
			}
		}
		else{
			if(ring%2==0){
				teki7[7]++; /*１０になるまで*/
				for(i=0;i<6;i++){
					if(teki7[i]!=0)
						sprite_set_location(teki7[i],teki6[i],teki7[7]);
				}
			}
		}
	}
}

void gen1() /*復活プログラム！！*/
{
	for(i=0;i<6;i++){
		move_f4[i]=0; /*活動開始*/
		sprite_set_location(i+19,teki4[i][0],teki4[i][1]);
		teki[i][1] +=4; teki2[i][1]+=4;
		teki3[i][1]+=4;
		sprite_set_location(i+1,teki[i][0],teki[i][1]);
		sprite_set_location(i+7,teki2[i][0],teki2[i][1]);
		sprite_set_location(i+13,teki3[i][0],teki3[i][1]);
	} 
	teki6[6]=10; dan[1]=1; kazu[3]+=6;
}

void score()
{
	text_put_string(0,0,"スコア");
	text_put_numeric(0,1,4,NUM_SIGNED,sco);
	text_put_string(0,3,"テキ");
	text_put_numeric(0,4,2,NUM_SIGNED,kazu[0]);
	text_put_string(2,4,"ひき");
	for(i=0;i<3;i++)
		sprite_set_location(i+91,196+i*8,120);
}

void shot() /*自機ショット*/
{
	int w;
	if(flag[0]==0){
		w=beam[1]=mych[1]; /*自機のy座標の記憶*/
		beam[0]=mych[0]; /*	自機のx座標の記憶*/
		flag[0]=1; /*発射FLAG ON*/
	}
	if(flag[0]==1){
		beam[1]-=spe_b;
		if(info[0]==1)
			sprite_set_location(49,beam[0],beam[1]); /*弾表示*/
		if(info[0]==2)
			sprite_set_location(94,beam[0],beam[1]); /*弾表示*/
		if(info[0]==3)
			sprite_set_location(95,beam[0],beam[1]); /*弾表示*/
		if(beam[1]==w-spe_b){
			se_play_n(0);/*Aボタン効果音*/
		}
		if(beam[1]>=5&&112>=beam[1]) flag[7]=1; /*2発目の弾と1発目の間隔*/
		else flag[7]=0;
		if(beam[1]<-8){ /*弾が外に行ったよ*/
			flag[0]=0;
			if(info[0]==1)
				sprite_set_location(49,-15,-15); /*弾表示*/
			if(info[0]==2)
				sprite_set_location(94,-15,-15); /*弾表示*/
			if(info[0]==3)
				sprite_set_location(95,-15,-15); /*弾表示*/
		}
	}
}

void shot2()
{
	int w;
	if(flag[6]==0&&flag[7]==1){
		w=bren[1]=mych[1]; /*自機のy座標の記憶*/
		bren[0]=mych[0]; /*	自機のx座標の記憶*/
		flag[6]=1; /*発射FLAG ON*/
	}
	if(flag[6]==1){
		bren[1]-=spe_b;
		if(info[0]==1)
			sprite_set_location(78,bren[0],bren[1]); /*連打弾表示*/
		if(info[0]==2)
			sprite_set_location(96,bren[0],bren[1]); /*連打弾表示*/
		if(info[0]==3)
			sprite_set_location(97,bren[0],bren[1]); /*連打弾表示*/
		if(bren[1]==w-spe_b){
			se_play_n(0);/*Aボタン効果音*/
		}
		if(bren[1]<-8){ /*連打弾が外に行ったよ*/
			flag[6]=0;
			if(info[0]==1)
				sprite_set_location(78,-15,-15); /*連打弾表示*/
			if(info[0]==2)
				sprite_set_location(96,-15,-15); /*連打弾表示*/
			if(info[0]==3)
				sprite_set_location(97,-15,-15); /*連打弾表示*/
		}
	}
}
void hantei_t() /*敵の当たり判定*/
{	
	for(i=0;i<6;i++){
		if(((teki[i][0]-beam[0])*(teki[i][0]-beam[0])
			+(teki[i][1]-beam[1])*(teki[i][1]-beam[1]))<64 && move_f[i]==0){			/*Ａボタンの弾（敵１）*/
				se_play_n(3);
				atack_f[i]=1;
				gun_f[0]=1; 
		}
		if(((teki[i][0]-bren[0])*(teki[i][0]-bren[0])
			+(teki[i][1]-bren[1])*(teki[i][1]-bren[1]))<64 && move_f[i]==0){			/*Ａ2ボタンの弾（敵１）*/
				se_play_n(3);
				atack_f[i]=1;
				gun_f[0]=2; 
		}
		if((((teki[i][0]-beam[6])*(teki[i][0]-beam[6])
			+(teki[i][1]-beam[9])*(teki[i][1]-beam[9]))<64)&&
			((flag_b[1]==1)&&(limit1!=3)) && move_f[i]==0){			/*Ｂボタンの弾（左）*/
				se_play_n(3);
				atack_f[i]=1; 
				gun_f[1]=1; 
		}
		if((((teki[i][0]-beam[7])*(teki[i][0]-beam[7])
			+(teki[i][1]-beam[10])*(teki[i][1]-beam[10]))<64)&&
			((flag_b[2]==1)&&(limit1!=3)) && move_f[i]==0){			/*Ｂボタンの弾（中）*/
				se_play_n(3);				
				atack_f[i]=1;
				gun_f[2]=1; 
		}
		if((((teki[i][0]-beam[8])*(teki[i][0]-beam[8])
			+(teki[i][1]-beam[11])*(teki[i][1]-beam[11]))<64)&&
			((flag_b[3]==1)&&(limit1!=3)) && move_f[i]==0){			/*Ｂボタンの弾（右）*/
				se_play_n(3);			
				atack_f[i]=1; 
				gun_f[3]=1; 
		}	
		if(((teki2[i][0]-beam[0])*(teki2[i][0]-beam[0])
			+(teki2[i][1]-beam[1])*(teki2[i][1]-beam[1]))<64 && move_f2[i]==0){			/*Ａボタンの弾（敵１）*/
				se_play_n(3);
				atack_f2[i]=1;
				gun_f[0]=1; 
		}
		if(((teki2[i][0]-bren[0])*(teki2[i][0]-bren[0])
			+(teki2[i][1]-bren[1])*(teki2[i][1]-bren[1]))<64 && move_f2[i]==0){			/*Ａ2ボタンの弾（敵１）*/
				se_play_n(3);
				atack_f2[i]=1;
				gun_f[0]=2; 
		}
		if((((teki2[i][0]-beam[6])*(teki2[i][0]-beam[6])
			+(teki2[i][1]-beam[9])*(teki2[i][1]-beam[9]))<64)&&
			((flag_b[1]==1)&&(limit1!=3)) && move_f2[i]==0){			/*Ｂボタンの弾（左）*/
				se_play_n(3);				
				atack_f2[i]=1; 
				gun_f[1]=1; 
		}
		if((((teki2[i][0]-beam[7])*(teki2[i][0]-beam[7])
			+(teki2[i][1]-beam[10])*(teki2[i][1]-beam[10]))<64)&&
			((flag_b[2]==1)&&(limit1!=3)) && move_f2[i]==0){			/*Ｂボタンの弾（中）*/
				se_play_n(3);				
				atack_f2[i]=1;
				gun_f[2]=1; 
		}
		if((((teki2[i][0]-beam[8])*(teki2[i][0]-beam[8])
			+(teki2[i][1]-beam[11])*(teki2[i][1]-beam[11]))<64)&&
			((flag_b[3]==1)&&(limit1!=3)) && move_f2[i]==0){			/*Ｂボタンの弾（右）*/
				se_play_n(3);			
				atack_f2[i]=1; 
				gun_f[3]=1; 
		}
		if(((teki3[i][0]-beam[0])*(teki3[i][0]-beam[0])
			+(teki3[i][1]-beam[1])*(teki3[i][1]-beam[1]))<64 && move_f3[i]==0){			/*Ａボタンの弾（敵１）*/
				se_play_n(3);
				atack_f3[i]=1;
				gun_f[0]=1; 
		}
		if(((teki3[i][0]-bren[0])*(teki3[i][0]-bren[0])
			+(teki3[i][1]-bren[1])*(teki3[i][1]-bren[1]))<64 && move_f3[i]==0){			/*Ａ2ボタンの弾（敵１）*/
				se_play_n(3);
				atack_f3[i]=1;
				gun_f[0]=2; 
		}
		if((((teki3[i][0]-beam[6])*(teki3[i][0]-beam[6])
			+(teki3[i][1]-beam[9])*(teki3[i][1]-beam[9]))<64)&&
			((flag_b[1]==1)&&(limit1!=3)) && move_f3[i]==0){			/*Ｂボタンの弾（左）*/
				se_play_n(3);				
				atack_f3[i]=1; 
				gun_f[1]=1; 
		}
		if((((teki3[i][0]-beam[7])*(teki3[i][0]-beam[7])
			+(teki3[i][1]-beam[10])*(teki3[i][1]-beam[10]))<64)&&
			((flag_b[2]==1)&&(limit1!=3)) && move_f3[i]==0){			/*Ｂボタンの弾（中）*/
				se_play_n(3);				
				atack_f3[i]=1;
				gun_f[2]=1; 
		}
		if((((teki3[i][0]-beam[8])*(teki3[i][0]-beam[8])
			+(teki3[i][1]-beam[11])*(teki3[i][1]-beam[11]))<64)&&
			((flag_b[3]==1)&&(limit1!=3)) && move_f3[i]==0){			/*Ｂボタンの弾（右）*/
				se_play_n(3);	
				atack_f3[i]=1; 
				gun_f[3]=1; 
		}
		if(((teki4[i][0]-beam[0])*(teki4[i][0]-beam[0])
			+(teki4[i][1]-beam[1])*(teki4[i][1]-beam[1]))<64 && move_f4[i]==0){			/*Ａボタンの弾（敵１）*/
				se_play_n(3);
				atack_f4[i]=1;
				gun_f[0]=1; 
		}
		if(((teki4[i][0]-bren[0])*(teki4[i][0]-bren[0])
			+(teki4[i][1]-bren[1])*(teki4[i][1]-bren[1]))<64 && move_f4[i]==0){			/*Ａ2ボタンの弾（敵１）*/
				se_play_n(3);
				atack_f4[i]=1;
				gun_f[0]=2; 
		}
		if((((teki4[i][0]-beam[6])*(teki4[i][0]-beam[6])
			+(teki4[i][1]-beam[9])*(teki4[i][1]-beam[9]))<64)&&
			((flag_b[1]==1)&&(limit1!=3)) && move_f4[i]==0){			/*Ｂボタンの弾（左）*/
				se_play_n(3);
				atack_f4[i]=1; 
				gun_f[1]=1; 
		}
		if((((teki4[i][0]-beam[7])*(teki4[i][0]-beam[7])
			+(teki4[i][1]-beam[10])*(teki4[i][1]-beam[10]))<64)&&
			((flag_b[2]==1)&&(limit1!=3)) && move_f4[i]==0){			/*Ｂボタンの弾（中）*/
				se_play_n(3);		
				atack_f4[i]=1;
				gun_f[2]=1; 
		}
		if((((teki4[i][0]-beam[8])*(teki4[i][0]-beam[8])
			+(teki4[i][1]-beam[11])*(teki4[i][1]-beam[11]))<64)&&
			((flag_b[3]==1)&&(limit1!=3)) && move_f4[i]==0){			/*Ｂボタンの弾（右）*/
				se_play_n(3);			
				atack_f4[i]=1; 
				gun_f[3]=1; 
		}	
	}
	if(gun_f[0]==1){
		if(info[0]==1)
			sprite_set_location(49,-20,-15);	/*Aボタンの弾 消去*/ 
		if(info[0]==2)
			sprite_set_location(94,-20,-15);	/*Aボタンの弾 消去*/ 
		if(info[0]==3)
			sprite_set_location(95,-20,-15);	/*Aボタンの弾 消去*/ 
		beam[0]=beam[1]=0;				/*ray初期化*/
		flag[0]=0; gun_f[0]=0;
	}
	if(gun_f[0]==2){
		if(info[0]==1)
			sprite_set_location(78,-20,-15);	/*A2ボタンの弾 消去*/ 
		if(info[0]==2)
			sprite_set_location(96,-20,-15);	/*A2ボタンの弾 消去*/ 
		if(info[0]==3)
			sprite_set_location(97,-20,-15);	/*A2ボタンの弾 消去*/ 
		bren[0]=bren[1]=0;				/*ray初期化*/
		flag[6]=0; gun_f[0]=0;
	}
	if(gun_f[1]==1){
		sprite_set_location(50,-20,-15);/*Ｂボタンの弾（左） 消去*/ 
		beam[6]=beam[9]=0;				/*ray初期化*/
		flag_b[1]=0; gun_f[1]=0; limit1++;					/*Ｂの左の弾は当たりました*/
	}
	if(gun_f[2]==1){
		sprite_set_location(51,-20,-15);/*Ｂボタンの弾（中） 消去*/  
		beam[7]=beam[10]=0;				/*ray初期化*/
		flag_b[2]=0; gun_f[2]=0; limit1++;			/*Ｂの中の弾は当たりました*/
	}
	if(gun_f[3]==1){ 
		sprite_set_location(52,-20,-15);/*Ｂボタンの弾（右） 消去*/  
		beam[8]=beam[11]=0;				/*ray初期化*/
		flag_b[3]=0; gun_f[3]=0; limit1++;				/*Ｂの右の弾は当たりました*/
	}
	if(limit1==3){	/*Ｂボタンのフラグ初期化*/
		flag_b[0]=flag_b[1]=flag_b[2]=flag_b[3]=0;
		limit1=0;    
	}
}

void hantei_t2()
{
	for(i=0;i<6;i++){
		if(atack_f[i]==1 && move_f[i]==0){ /*倒したとき*/
			move_f[i]=1; teki[i][4]=1; /*爆発のフラグ*/
			teki[i][2]=teki[i][0]; 
			teki[i][3]=teki[i][1]; 
			atack_f[i]=0; sco+=100;
			teki[i][0]=teki[i][1]=-17;
			sprite_set_char(i+1,4); /*敵１-＞ボム１*/
			sprite_set_location(i+1,teki[i][2],teki[i][3]);
		} 
		if(atack_f2[i]==1 && move_f2[i]==0){ /*倒したとき*/
			move_f2[i]=1; teki2[i][4]=1; /*爆発のフラグ*/
			teki2[i][2]=teki2[i][0]; 
			teki2[i][3]=teki2[i][1];
			atack_f2[i]=0; sco+=100; 
			teki2[i][0]=teki2[i][1]=-17;
			sprite_set_char(i+7,4); /*敵１-＞ボム１*/
			sprite_set_location(i+7,teki2[i][2],teki2[i][3]);
		} 
		if(atack_f3[i]==1 && move_f3[i]==0){ /*倒したとき*/
			move_f3[i]=1; teki3[i][4]=1; /*爆発のフラグ*/
			teki3[i][2]=teki3[i][0];  
			teki3[i][3]=teki3[i][1];
			atack_f3[i]=0; sco+=100;
			teki3[i][0]=teki3[i][1]=-17;
			sprite_set_char(i+13,4); /*敵１-＞ボム１*/
			sprite_set_location(i+13,teki3[i][2],teki3[i][3]);
		}
		if(atack_f4[i]==1 && move_f4[i]==0){ /*倒したとき*/
			move_f4[i]=1; teki4[i][4]=1; /*爆発のフラグ*/
			teki4[i][2]=teki4[i][0]; 
			teki4[i][3]=teki4[i][1];
			atack_f4[i]=0; sco+=100; 
			teki4[i][0]=teki4[i][1]=-17;
			sprite_set_char(i+19,4); /*敵１-＞ボム１*/
			sprite_set_location(i+19,teki4[i][2],teki4[i][3]);
		}
		if(atack_f[i]==0  && teki[i][4]==1  && move_f[i]==1)  
			teki[i][5]++;  
		if(atack_f2[i]==0 && teki2[i][4]==1 && move_f2[i]==1) 
			teki2[i][5]++;
		if(atack_f3[i]==0 && teki3[i][4]==1 && move_f3[i]==1) 
			teki3[i][5]++;
		if(atack_f4[i]==0 && teki4[i][4]==1 && move_f4[i]==1) 
			teki4[i][5]++;
		if(teki[i][5]==20 && move_f[i]==1 && teki[i][4]==1){ /*一号機*/
			sprite_set_char(i+1,5); /*ボム1-＞ボム2*/
			sprite_set_location(i+1,teki[i][2],teki[i][3]);
			teki[i][4]=2;  
		}
		if(teki2[i][5]==20 && move_f2[i]==1 && teki2[i][4]==1){ /*一号機*/
			sprite_set_char(i+7,5); /*ボム1-＞ボム2*/
			sprite_set_location(i+7,teki2[i][2],teki2[i][3]);
			teki2[i][4]=2;
		}
		if(teki3[i][5]==20 && move_f3[i]==1 && teki3[i][4]==1){ /*一号機*/
			sprite_set_char(i+13,5); /*ボム1-＞ボム2*/
			sprite_set_location(i+13,teki3[i][2],teki3[i][3]);
			teki3[i][4]=2; 
		}
		if(teki4[i][5]==20 && move_f4[i]==1 && teki[i][4]==1){ /*一号機*/
			sprite_set_char(i+19,5); /*ボム1-＞ボム2*/
			sprite_set_location(i+19,teki4[i][2],teki4[i][3]);
			teki4[i][4]=2; 
		}
		if(teki[i][4]==2)  teki[i][5]++;
		if(teki2[i][4]==2) teki2[i][5]++;
		if(teki3[i][4]==2) teki3[i][5]++;
		if(teki4[i][4]==2) teki4[i][5]++;
		if(teki[i][5]==40){ 
			sprite_set_location(i+1,-17,-17);
			teki[i][4]=teki[i][5]=0; move_f[i]=2;
			s_flag[i]=0; kazu[6]++; kazu[0]++;
		}
		if(teki2[i][5]==40){ 
			sprite_set_location(i+7,-17,-17);
			teki2[i][4]=teki2[i][5]=0; move_f2[i]=2;
			s_flag2[i]=0; kazu[6]++; kazu[0]++;
		}
		if(teki3[i][5]==40){ 
			sprite_set_location(i+13,-17,-17);
			teki3[i][4]=teki3[i][5]=0; move_f3[i]=2;
			s_flag3[i]=0; kazu[6]++; kazu[0]++;
		}
		if(teki4[i][5]==40){ 
			sprite_set_location(i+19,-17,-17);
			teki4[i][4]=teki4[i][5]=0; move_f4[i]=2;
			s_flag4[i]=0; kazu[6]++; kazu[0]++;
		}
	}
}

void shot_t()
{
	for(i=0;i<6;i++){
		if(ray[i][2]==0 && move_f[i]==0 && ray[i][3]==0){
			if(ring%ray_x==0  && move_f[i+6]==1) ray[i][3]=1;
			if(ring%ray2_x==0 && move_f[i+6]==2) ray[i][3]=1;
			if(ring%ray3_x==0 && move_f[i+6]==3) ray[i][3]=1;
			if(ring%ray4_x==0 && move_f[i+6]==4) ray[i][3]=1;
		}
		if(ray2[i][2]==0 && move_f2[i]==0 && ray2[i][3]==0){
			if(ring%ray_x==0  && move_f2[i+6]==1) ray2[i][3]=1;
			if(ring%ray2_x==0 && move_f2[i+6]==2) ray2[i][3]=1;
			if(ring%ray3_x==0 && move_f2[i+6]==3) ray2[i][3]=1;
			if(ring%ray4_x==0 && move_f2[i+6]==4) ray2[i][3]=1;
		}
		if(ray3[i][2]==0 && move_f3[i]==0 && ray3[i][3]==0){
			if(ring%ray_x==0  && move_f3[i+6]==1) ray3[i][3]=1;
			if(ring%ray2_x==0 && move_f3[i+6]==2) ray3[i][3]=1;
			if(ring%ray3_x==0 && move_f3[i+6]==3) ray3[i][3]=1;
			if(ring%ray4_x==0 && move_f3[i+6]==4) ray3[i][3]=1;
		}
		if(ray4[i][2]==0 && move_f4[i]==0 && ray4[i][3]==0){
			if(ring%ray_x==0  && move_f4[i+6]==1) ray4[i][3]=1;
			if(ring%ray2_x==0 && move_f4[i+6]==2) ray4[i][3]=1;
			if(ring%ray3_x==0 && move_f4[i+6]==3) ray4[i][3]=1;
			if(ring%ray4_x==0 && move_f4[i+6]==4) ray4[i][3]=1;
		}
	}
	for(i=0;i<6;i++){
		if(ray[i][3]==1){
			if((move_f[i+6]==1 || move_f[i+6]==2 ||
				move_f[i+6]==4) && ray[i][3]==1){ /*弾表示@,A,B*/
				ray[i][0]=teki[i][0]; ray[i][1]=teki[i][1]+8;
				sprite_set_location(i+25,ray[i][0],ray[i][1]);
				ray[i][3]=0; ray[i][2]=1;
			}
			if(move_f[i+6]==3){
				if(flag[1]==1){ /*右向き*/
					if(move_f[i+6]==3 && ray[i][3]==1){
						ray[i][0]=teki[i][0]+8; ray[i][1]=teki[i][1];
						sprite_set_location(i+25,ray[i][0],ray[i][1]);
						ray[i][2]=1; ray[i][3]=0;
					}
				}
				if(flag[1]==2){ /*左向き*/
					if(move_f[i+6]==3 && ray[i][3]==1){
						ray[i][0]=teki[i][0]-8; ray[i][1]=teki[i][1];
						sprite_set_location(i+25,ray[i][0],ray[i][1]);
						ray[i][2]=2; ray[i][3]=0;
					}
				}
			}
		}
		if(ray2[i][3]==1){
			if((move_f2[i+6]==1 || move_f2[i+6]==2 ||
				move_f2[i+6]==4) && ray2[i][3]==1){ /*弾表示@,A,B*/
				ray2[i][0]=teki2[i][0]; ray2[i][1]=teki2[i][1]+8;
				sprite_set_location(i+31,ray2[i][0],ray2[i][1]);
				ray2[i][3]=0; ray2[i][2]=1;
			}
			if(move_f2[i+6]==3){
				if(flag[1]==1){ /*右向き*/
					if(move_f2[i+6]==3 && ray2[i][3]==1){
						ray2[i][0]=teki2[i][0]+8; ray2[i][1]=teki2[i][1];
						sprite_set_location(i+31,ray2[i][0],ray2[i][1]);
						ray2[i][2]=1; ray2[i][3]=0;
					}
				}
				if(flag[1]==2){ /*左向き*/
					if(move_f2[i+6]==3 && ray2[i][3]==1){
						ray2[i][0]=teki2[i][0]-8; ray2[i][1]=teki2[i][1];
						sprite_set_location(i+31,ray2[i][0],ray2[i][1]);
						ray2[i][2]=2; ray2[i][3]=0;
					}
				}
			}
		}
		if(ray3[i][3]==1){
			if((move_f3[i+6]==1 || move_f3[i+6]==2 ||
				move_f3[i+6]==4) && ray3[i][3]==1){ /*弾表示@,A,B*/
				ray3[i][0]=teki3[i][0]; ray3[i][1]=teki3[i][1]+8;
				sprite_set_location(i+37,ray3[i][0],ray3[i][1]);
				ray3[i][3]=0; ray3[i][2]=1;
			}
			if(move_f3[i+6]==3){
				if(flag[1]==1){ /*右向き*/
					if(move_f3[i+6]==3 && ray3[i][3]==1){
						ray3[i][0]=teki3[i][0]+8; ray3[i][1]=teki3[i][1];
						sprite_set_location(i+37,ray3[i][0],ray3[i][1]);
						ray3[i][2]=1; ray3[i][3]=0;
					}
				}
				if(flag[1]==2){ /*左向き*/
					if(move_f3[i+6]==3 && ray3[i][3]==1){
						ray3[i][0]=teki3[i][0]-8; ray3[i][1]=teki3[i][1];
						sprite_set_location(i+37,ray3[i][0],ray3[i][1]);
						ray3[i][2]=2; ray3[i][3]=0;
					}
				}
			}
		}
		if(ray4[i][3]==1){
			if((move_f4[i+6]==1 || move_f4[i+6]==2 ||
				move_f4[i+6]==4) && ray4[i][3]==1){ /*弾表示@,A,B*/
				ray4[i][0]=teki4[i][0]; ray4[i][1]=teki4[i][1]+8;
				sprite_set_location(i+43,ray4[i][0],ray4[i][1]);
				ray4[i][3]=0; ray4[i][2]=1;
			}
			if(move_f4[i+6]==3){
				if(flag[1]==1){ /*右向き*/
					if(move_f4[i+6]==3 && ray4[i][3]==1){
						ray4[i][0]=teki4[i][0]+8; ray4[i][1]=teki4[i][1];
						sprite_set_location(i+43,ray4[i][0],ray4[i][1]);
						ray4[i][2]=1; ray4[i][3]=0;
					}
				}
				if(flag[1]==2){ /*左向き*/
					if(move_f4[i+6]==3 && ray4[i][3]==1){
						ray4[i][0]=teki4[i][0]-8; ray4[i][1]=teki4[i][1];
						sprite_set_location(i+43,ray4[i][0],ray4[i][1]);
						ray4[i][2]=2; ray4[i][3]=0;
					}
				}
			}
		}
	}
	for(i=0;i<6;i++){
		if(ray[i][2]==1 || ray[i][2]==2){
			if(ring%2==0){
				if(move_f[i+6]==1 && ray[i][2]==1){ /*一号機*/
					if(nami==1){
						if(ring%2==0){
							if(x_flag[i]==0){ /*右下への弾（最初）*/
								ray[i][0]+=1;
								a[i]+=1;
								if(a[i]==X_WIDTH) x_flag[i]=1;
							}
							if(x_flag[i]==1){ /*左下への弾*/
								ray[i][0]-=1;
								a[i]-=1;
								if(a[i]==-X_WIDTH) x_flag[i]=2;
							}
							if(x_flag[i]==2){ /*右下への弾*/
								ray[i][0]+=1;
								a[i]+=1;
								if(a[i]==X_WIDTH) x_flag[i]=1;
							}
							ray[i][1]+=spe_bt;
						}
					}
					else
						ray[i][1]+=spe_bt;
				}
				if(move_f[i+6]==2 && ray[i][2]==1){  /*二号機*/
					ray[i][1]+=spe_bt2;
					if(nami2==1){
						if(ring%3==0){
							if(ray[i][0]<mych[0])
								ray[i][0]++;
							else
								ray[i][0]--;
						}
					}
				}
				if(move_f[i+6]==3 && ray[i][2]==1){ /*三号機（右）*/
					ray[i][1]+=spe_bt3;
					if(ring%bang==0) ray[i][0]+=1;
				}
				if(move_f[i+6]==3 && ray[i][2]==2){ /*三号機（左）*/
					ray[i][1]+=spe_bt3;
					if(ring%bang==0) ray[i][0]-=1;
				}
				if(move_f[i+6]==4 && ray[i][2]==1)  /*四号機*/
					ray[i][1]+=spe_bt;
			}
			sprite_set_location(i+25,ray[i][0],ray[i][1]);
		}
		if(ray2[i][2]==1 || ray2[i][2]==2){
			if(ring%2==0){
				if(move_f2[i+6]==1 && ray2[i][2]==1){  /*一号機*/
					if(nami==1){
						if(ring%2==0){
							if(x_flag2[i]==0){ /*右下への弾（最初）*/
								ray2[i][0]+=1;
								a2[i]+=1;
								if(a2[i]==X_WIDTH) x_flag2[i]=1;
							}
							if(x_flag2[i]==1){ /*左下への弾*/
								ray2[i][0]-=1;
								a2[i]-=1;
								if(a2[i]==-X_WIDTH) x_flag2[i]=2;
							}
							if(x_flag2[i]==2){ /*右下への弾*/
								ray2[i][0]+=1;
								a2[i]+=1;
								if(a2[i]==X_WIDTH) x_flag2[i]=1;
							}					
							ray2[i][1]+=spe_bt;
						}
					}
					else
						ray2[i][1]+=spe_bt;
				}
				if(move_f2[i+6]==2 && ray2[i][2]==1){  /*二号機*/
					ray2[i][1]+=spe_bt2;
					if(nami2==1){
						if(ring%3==0){
							if(ray2[i][0]<mych[0])
								ray2[i][0]++;
							else
								ray2[i][0]--;
						}
					}
				}
				if(move_f2[i+6]==3 && ray2[i][2]==1){ /*三号機（右）*/
					ray2[i][1]+=spe_bt3;
					if(ring%bang==0) ray2[i][0]+=1;
				}
				if(move_f2[i+6]==3 && ray2[i][2]==2){ /*三号機（左）*/
					ray2[i][1]+=spe_bt3;
					if(ring%bang==0) ray2[i][0]-=1;
				}
				if(move_f2[i+6]==4 && ray2[i][2]==1)
					ray2[i][1]+=spe_bt;
			}
			sprite_set_location(i+31,ray2[i][0],ray2[i][1]);
		}
		if(ray3[i][2]==1 || ray3[i][2]==2){ 
			if(ring%2==0){
				if(move_f3[i+6]==1 && ray3[i][2]==1){  /*一号機*/
					if(nami==1){
						if(ring%3==0){
							if(x_flag3[i]==0){ /*右下への弾（最初）*/
								ray3[i][0]+=1;
								a3[i]+=1;
								if(a3[i]==X_WIDTH) x_flag3[i]=1;
							}
							if(x_flag3[i]==1){ /*左下への弾*/
								ray3[i][0]-=1;
								a3[i]-=1;
								if(a3[i]==-X_WIDTH) x_flag3[i]=2;
							}
							if(x_flag3[i]==2){ /*右下への弾*/
								ray3[i][0]+=1;
								a3[i]+=1;
								if(a3[i]==X_WIDTH) x_flag3[i]=1;
							}
							ray3[i][1]+=spe_bt;
						}
					}
					else
						ray3[i][1]+=spe_bt;
				}
				if(move_f3[i+6]==2 && ray3[i][2]==1){  /*二号機*/
					ray3[i][1]+=spe_bt2;
					if(nami2==1){
						if(ring%3==0){
							if(ray3[i][0]<mych[0])
								ray3[i][0]++;
							else
								ray3[i][0]--;
						}
					}
				}
				if(move_f3[i+6]==3 && ray3[i][2]==1){ /*三号機（右）*/
					ray3[i][1]+=spe_bt3;
					if(ring%bang==0) ray3[i][0]+=1;
				}
				if(move_f3[i+6]==3 && ray3[i][2]==2){ /*三号機（左）*/
					ray3[i][1]+=spe_bt3;
					if(ring%bang==0) ray3[i][0]-=1;
				}
				if(move_f3[i+6]==4 && ray3[i][2]==1)
					ray3[i][1]+=spe_bt;
			}
			sprite_set_location(i+37,ray3[i][0],ray3[i][1]);
		}
		if(ray4[i][2]==1 || ray4[i][2]==2){ 
			if(ring%2==0){
				if(move_f4[i+6]==1 && ray4[i][2]==1){  /*一号機*/
					if(nami==1){
						if(ring%2==0){
							if(x_flag4[i]==0){ /*右下への弾（最初）*/
								ray4[i][0]+=1;
								a4[i]+=1;
								if(a4[i]==X_WIDTH) x_flag4[i]=1;
							}
							if(x_flag4[i]==1){ /*左下への弾*/
								ray4[i][0]-=1;
								a4[i]-=1;
								if(a4[i]==-X_WIDTH) x_flag4[i]=2;
							}
							if(x_flag4[i]==2){ /*右下への弾*/
								ray4[i][0]+=1;
								a4[i]+=1;
								if(a4[i]==X_WIDTH) x_flag4[i]=1;
							}
							ray4[i][1]+=spe_bt;
						}
					}
					else
						ray4[i][1]+=spe_bt;
				}
				if(move_f4[i+6]==2 && ray4[i][2]==1){  /*二号機*/
					ray4[i][1]+=spe_bt2;
					if(nami2==1){
						if(ring%3==0){
							if(ray4[i][0]<mych[0])
								ray4[i][0]++;
							else
								ray4[i][0]--;
						}
					}
				}
				if(move_f4[i+6]==3 && ray4[i][2]==1){ /*三号機（右）*/
					ray4[i][1]+=spe_bt3;
					if(ring%bang==0) ray4[i][0]+=1;
				}
				if(move_f4[i+6]==3 && ray4[i][2]==2){ /*三号機（左）*/
					ray4[i][1]+=spe_bt3;
					if(ring%bang==0) ray4[i][0]-=1;
				}
				if(move_f4[i+6]==4 && ray4[i][2]==1)
					ray4[i][1]+=spe_bt;
			}
			sprite_set_location(i+43,ray4[i][0],ray4[i][1]);
		}
	}
	for(i=0;i<6;i++){
		if(ray[i][1]>144){       /*敵弾消去*/
			sprite_set_location(i+25,-17,-17);
			ray[i][2]=0;
			if(move_f[i+6]==1){ /*一号機*/
				x_flag[i]=0; a[i]=0;
			}
		}
		if(ray2[i][1]>144){       /*敵弾消去*/
			sprite_set_location(i+31,-17,-17);
			ray2[i][2]=0;
			if(move_f2[i+6]==1){ /*一号機*/
				x_flag2[i]=0; a2[i]=0;
			}
		}
		if(ray3[i][1]>144){       /*敵弾消去*/
			sprite_set_location(i+37,-17,-17);
			ray3[i][2]=0;
			if(move_f3[i+6]==1){ /*一号機*/
				x_flag3[i]=0; a3[i]=0;
			}
		}
		if(ray4[i][1]>144){       /*敵弾消去*/
			sprite_set_location(i+43,-17,-17);
			ray4[i][2]=0;
			if(move_f4[i+6]==1){ /*一号機*/
				x_flag4[i]=0; a4[i]=0;
			}
		}
	}
}

void hantei() /*自機の当たり判定*/
{
	for(i=0;i<6;i++){
		if((((mych[0]-ray[i][0])*(mych[0]-ray[i][0]))+
		((mych[1]-ray[i][1])*(mych[1]-ray[i][1]))<64)){
				if(hit[0]!=tahu_s){
					flag[4]=1; s_flag[i]=1; sco-=100;
				}
		}
		if((((mych[0]-ray2[i][0])*(mych[0]-ray2[i][0]))+
		((mych[1]-ray2[i][1])*(mych[1]-ray2[i][1]))<64)){
				if(hit[0]!=tahu_s){
					flag[4]=1; s_flag2[i]=1; sco-=100;
				}
		}
		if((((mych[0]-ray3[i][0])*(mych[0]-ray3[i][0]))+
		((mych[1]-ray3[i][1])*(mych[1]-ray3[i][1]))<64)){
				if(hit[0]!=tahu_s){
					flag[4]=1; s_flag3[i]=1; sco-=100;
				}
		}
		if((((mych[0]-ray4[i][0])*(mych[0]-ray4[i][0]))+
		((mych[1]-ray4[i][1])*(mych[1]-ray4[i][1]))<64)){
				if(hit[0]!=tahu_s){
					flag[4]=1; s_flag4[i]=1; sco-=100;
				}
		}
	}
	if(flag[4]==1){ /*ヒットした時*/
		hit[0]++; /*回数計算*/
		flag[4]=0; /*当たりフラグ初期化*/
		sprite_set_location(69+tairyoku_f[1]-1,-17,-17);
		tairyoku_f[1]--;
		if(item1[2]==0&&item3[0]){ /*アイテムを進めていないとき*/
			if(item1[4]==1&&item3[0]==1){
				item3[0]=0; item1[4]=0;
				sprite_set_location(75,-15,-15);
			}
			if(item1[4]==2&&item3[1]==1){
				item3[1]=0; item1[4]=1;
				sprite_set_location(76,-15,-15);
			}
			if(item1[4]==3&&item3[2]==1){
				item3[2]=0; item1[4]=2;
				sprite_set_location(77,-15,-15);
			}
		}
		if(item1[2]==1 && item1[4]!=0){ /*アイテムが落ちているとき*/
			if(item3[2]==1){
				item3[2]=0; sprite_set_location(77,-15,-15);
			}
			if(item3[1]==1&&item3[2]==0){
				item3[1]=0; sprite_set_location(76,-15,-15);
			}
			if(item3[0]==1&&item3[1]==0&&item3[2]==0){
				item3[0]=0; sprite_set_location(75,-15,-15);
			}
			item1[5]=1;
		}
		for(i=0;i<6;i++){ /*敵弾消去*/
			if(s_flag[i]==1){
				ray[i][0]=ray[i][1]=-15;   ray[i][2]=0; s_flag[i]=0;
				sprite_set_location(i+25,-15,-15);
			}
			if(s_flag2[i]==1){
				ray2[i][0]=ray2[i][1]=-15; ray2[i][2]=0; s_flag2[i]=0;
				sprite_set_location(i+31,-15,-15);
			}
			if(s_flag3[i]==1){
				ray3[i][0]=ray3[i][1]=-15; ray3[i][2]=0; s_flag3[i]=0;
				sprite_set_location(i+37,-15,-15);
			}
			if(s_flag4[i]==1){
				ray4[i][0]=ray4[i][1]=-15; ray4[i][2]=0; s_flag4[i]=0;
				sprite_set_location(i+43,-15,-15);
			}
		}
	}
	if(item1[2]==0 && item1[5]==1){ /*落下が終わったら*/
		for(i=0;i<3;i++){
			if(item3[i]==0){
				item1[4]=i; break;
			}
		}
		item1[5]=0;
	}
}

void nobi()
{
	end_sco[stage-1]=sco;
	hit[1]=mych[0];/*ｘ座標の記憶*/
	hit[2]=mych[1];/*Ｙ座標の記憶*/
	hit[3]=1; flag[1]=3; /*敵を止める*/
	for(i=0;i<6;i++){ /*弾を止める*/
		ray[i][2]=3;
		ray2[i][2]=3;
		ray3[i][2]=3;
		ray4[i][2]=3;
	}
	mych[0]=mych[1]=-15;
	sprite_set_char(0,4);
	sprite_set_location(0,hit[1],hit[2]);
	hit[4]=1; hit[0]=0; /*ヒット回数の初期化*/
	while(1){
		if(hit[4]==1) hit[5]++;
		if(hit[5]==10000){
			hit[4]=2; hit[6]=1;
			sprite_set_char(0,5);
			sprite_set_location(0,hit[1],hit[2]);
		}
		if(hit[4]==2) hit[5]++;
		if(hit[5]==20000){
			sprite_set_location(0,-15,-15);
			break;
		}
	}
}

void sound_cl()
{
	sound_close();                      /* HBLANK割り込み停止 */
    sounddrv_release();                 /* ドライバ用ワークの開放 */
}

void stage1()
{
	int p_e1[18*28];
	display_control(0); /*SPR/SCR2/SCR1 ALL OFF*/
	lcd_set_color(0x6420,0xfca8); /*色の設定*/
	palette_set_color(0,0x7650); /*パレットの設定*/
	display_control(DCM_SCR1); /*SCR1 ON*/
	screen_set_scroll(SCREEN1,0,0); /*スクロールしない*/	
	font_set_colordata(0,504,bmp_stage);
	for(i=0;i<18*28;i++)
		p_e1[i]=i;
	screen_set_char(SCREEN1,0,0,28,18,p_e1);
	while((ret_code&KEY_START)==0){
			ret_code=key_press_check();
	}
}

void title() /*タイトル画面*/
{
	display_control(0); /*SPR/SCR2/SCR1 ALL OFF*/
	lcd_set_color(0x6420,0xfca8); /*色の設定*/
	palette_set_color(0,0x7650); /*パレットの設定*/
	display_control(DCM_SCR1); /*SCR1 ON*/
	for(i=0;i<28*18;i++)
		ti[i]=i;
	screen_set_char(SCREEN1,0,0,28,18,ti);
	font_set_colordata(0,504,bmp_start);
	while((ret_code&KEY_START)==0){
		ret_code=key_press_check();
	}
}

void end1() /*GAME OVER画面*/
{
	int p_e1[18*28];
	display_control(0); /*SPR/SCR2/SCR1 ALL OFF*/
	lcd_set_color(0x6420,0xfca8); /*色の設定*/
	palette_set_color(0,0x7650); /*パレットの設定*/
	display_control(DCM_SCR1); /*SCR1 ON*/
	screen_set_scroll(SCREEN1,0,0); /*スクロールしない*/	
	font_set_colordata(0,504,bmp_end);
	for(i=0;i<18*28;i++)
		p_e1[i]=i;
	screen_set_char(SCREEN1,0,0,28,18,p_e1);
	while((ret_code&KEY_START)==0){
			ret_code=key_press_check();
	}
}

void end2() /*GAME CLEAR画面*/
{
	int p_e2[18*28];
	display_control(0); /*SPR/SCR2/SCR1 ALL OFF*/
	lcd_set_color(0x6420,0xfca8); /*色の設定*/
	palette_set_color(0,0x7650); /*パレットの設定*/
	display_control(DCM_SCR1); /*SCR1 ON*/
	screen_set_scroll(SCREEN1,0,0);	/*スクロールしない*/
	font_set_colordata(0,504,bmp_end2);
	for(i=0;i<18*28;i++)
		p_e2[i]=i;
	screen_set_char(SCREEN1,0,0,28,18,p_e2);
	while((ret_code&KEY_START)==0){
			ret_code=key_press_check();
	} 
}

void ending1()
{
	text_screen_init();
	text_put_char(3,2,0x2d);
	text_put_string(4,2,"POINT");
	text_put_char(9,2,0x2d);
	text_put_string(2,4,"LEVEL");
	text_put_string(2,6,"BLOCK");
	if(info[0]==1)  text_put_string(8,4,"B RANK");
	if(info[0]==2)	text_put_string(8,4,"A RANK");
	if(info[0]==3)	text_put_string(8,4,"S RANK");
	if(info[1]==1)	text_put_string(8,6,"B RANK");
	if(info[1]==2)	text_put_string(8,6,"A RANK");
	if(info[1]==3)	text_put_string(8,6,"S RANK");
	text_put_char(3,9,0x18);
	text_put_char(3,11,0x1a);
	text_put_string(4,9,"DX");
	text_put_string(4,11,"BOSS DX");
	text_put_string(4,16,"EXIT");
	text_put_string(3,16,"B:GOOD BYE");
	text_put_char(13,16,0x21);
}

void ending2()
{
	text_screen_init();
	text_put_string(1,4,"STAGE 1");
	text_put_numeric(9,4,4,NUM_SIGNED,end_sco[0]);
	text_put_string(1,6,"STAGE 3");
	text_put_numeric(9,6,4,NUM_SIGNED,end_sco[2]);
	text_put_string(1,8,"STAGE 5");
	text_put_numeric(9,8,4,NUM_SIGNED,end_sco[4]);
	text_put_string(1,10,"STAGE 7");
	text_put_numeric(9,10,4,NUM_SIGNED,end_sco[6]);
	text_put_string(1,12,"STAGE 9");
	text_put_numeric(9,12,4,NUM_SIGNED,end_sco[8]);
	text_put_string(4,16,"B:BACK");
	while(1){
		ret_code_open=key_press_check();
		if((ret_code_open&KEY_B)!=0){
			ending1(); break;
		}
	}
}

void ending3()
{
	text_screen_init();
	text_put_string(1,4,"STAGE 2");
	text_put_numeric(10,4,4,NUM_SIGNED,end_sco[1]);
	text_put_string(1,6,"STAGE 4");
	text_put_numeric(10,6,4,NUM_SIGNED,end_sco[3]);
	text_put_string(1,8,"STAGE 6");
	text_put_numeric(10,8,4,NUM_SIGNED,end_sco[5]);
	text_put_string(1,10,"STAGE 8");
	text_put_numeric(10,10,4,NUM_SIGNED,end_sco[7]);
	text_put_string(1,12,"STAGE 10");
	text_put_numeric(10,12,4,NUM_SIGNED,end_sco[9]);
	text_put_string(4,16,"B:BACK");
	while(1){
		ret_code_open=key_press_check();
		if((ret_code_open&KEY_B)!=0){
			ending1(); break;
		}
	}
}

void staff()
{
	text_screen_init();
	text_put_string(1,2,"ぐっちーたい　スタッフ１");
	text_put_string(0,5,"ぐっちーたいちょう　そうかんとく");
	text_put_string(0,6,"ＢＯＳＳ　プログラミング");
	text_put_string(3,8,"かわぐち　はやと");
	text_put_char(2,8,0x0f);
	text_put_string(0,11,"ぐっちーふくたいちょう");
	text_put_string(0,12,"いんべーだーＤＸ　プログラミング");
	text_put_string(3,14,"みうら　けんいち");
	text_put_char(2,14,0x02);
	key_wait();
}

void staff2()
{
	text_screen_init();
	text_put_string(1,2,"ぐっち〜たい　スタッフ２");
	text_put_string(0,5,"おとさくせい：えいぞう");
	text_put_string(0,6,"にれんしゃ　プログラミング");
	text_put_string(3,8,"のもと　のぶよし");
	text_put_char(2,8,0x0b);
	text_put_string(0,11,"ウェイブビーム　プログラミング");
	text_put_string(0,12,"はっぴょうげんこうさくせい");
	text_put_string(3,14,"ふじおか　だいすけ");
	text_put_char(2,14,0x0e);
	text_put_string(0,16,"つぎがんばってね！！");
	key_wait();
}

void staff3()
{
	text_screen_init();
	text_put_string(1,2,"ぐっちーたい　スタッフ");
	text_put_string(0,4,"そうかんとく　そうしれい");
	text_put_string(2,5,"かわぐち　はやと");
	text_put_string(0,7,"ぐっちーたいちょう");
	text_put_string(2,8,"かわぐち　はやと");
	text_put_string(0,10,"ぐっちーふくたいちょう");
	text_put_string(2,11,"みうら　けんいち");
	text_put_string(0,13,"いんべーだーＤＸメインプログラミング");
	text_put_string(2,14,"みうら　けんいち");
	text_put_string(0,16,"ＢＯＳＳ　メインプログラミング");
	text_put_string(2,17,"かわぐち　はやと");
	key_wait();
}

void staff4()
{
	text_screen_init();
	text_put_string(1,2,"ぐっちーたい　スタッフ");
	text_put_string(0,4,"ＢＧＭ　こうかおん　さくせい");
	text_put_string(2,5,"のもと　のぶよし");
	text_put_string(0,7,"アドバイザー");
	text_put_string(2,8,"おがさわら　まなぶ");
	text_put_string(0,10,"しりょう　ていきょう");
	text_put_string(2,11,"おがさわら　まなぶ");
	text_put_string(0,13,"サブ　プログラマー");
	text_put_string(2,14,"ふじおか　だいすけ");
	text_put_string(0,16,"えいぞう");
	text_put_string(2,17,"のもと　のぶよし");
	key_wait();
}

void staff5()
{
	text_screen_init();
	text_put_string(1,2,"ぐっちーたい　スタッフ");
	text_put_string(0,4,"がめんこうせい");
	text_put_string(2,5,"みうら　けんいち");
	text_put_string(0,7,"キャラクターデザイン");
	text_put_string(2,8,"みうら　けんいち");
	text_put_string(2,9,"ふじおか　だいすけ");
	text_put_string(2,10,"かわぐち　はやと");
	text_put_string(0,12,"キャラクター　とくべつさんか");
	text_put_string(2,13,"たかおか　としあき");
	text_put_string(0,15,"テストプレイヤー");
	text_put_string(2,16,"かむら　よしのり");
	key_wait();
}

void staff6()
{
	text_screen_init();
	text_put_string(1,2,"ぐっちーたい　スタッフ");
	text_put_string(0,4,"ウェイブビーム　プログラミング");
	text_put_string(2,5,"ふじおか　だいすけ");
	text_put_string(0,7,"ブロック　プログラミング");
	text_put_string(2,8,"ふじおか　だいすけ");
	text_put_string(0,10,"にれんしゃ　プログラミング");
	text_put_string(2,11,"のもと　のぶよし");
	text_put_string(0,13,"スリーウェイ　プログラミング");
	text_put_string(2,14,"かわぐち　はやと");
	text_put_string(0,16,"はいけいスクロール　プログラミング");
	text_put_string(2,17,"のもと　のぶよし");
	key_wait();
}

void staff7()
{
	text_screen_init();
	text_put_string(1,2,"ぐっちーたい　スタッフ");
	text_put_string(0,4,"ムードメーカー");
	text_put_string(2,5,"ふじおか　だいすけ");
	text_put_string(0,7,"まじぎれ　あそびにん　インターネット好き");
	text_put_string(2,8,"かわぐち　はやと");
	text_put_string(0,10,"プログラム　めったうち");
	text_put_string(2,11,"みうら　けんいち");
	text_put_string(0,13,"もりあげやく なやみやく");
	text_put_string(2,14,"のもと　のぶよし");
	text_put_string(0,16,"はっぴょうげんこう　さくせい");
	text_put_string(2,17,"ふじおか　だいすけ");
	key_wait();
}

void staff8()
{
	text_screen_init();
	text_put_string(1,2,"ぐっちーたい　スタッフ");
	text_put_string(0,4,"うらみます");
	text_put_string(2,5,"なかじま　みゆき");
	text_put_string(0,7,"ＢＧＭ　作曲");
	text_put_string(2,8,"のもと　のぶよし");
	text_put_string(0,10,"クリア　おめでとう！！");
	if(info[0]==1 || info[0]==2) text_put_string(2,11,"次のランクへ");
	if(info[0]==3) text_put_string(2,11,"あなたはほんとにすごい！！");
	key_wait();
}

void staff9()
{
	text_screen_init();
	text_put_string(1,2,"ぐっちーたい　スタッフ");
	text_put_string(0,4,"かつどうかいし");
	text_put_string(2,5,"なつやすみ");
	text_put_string(0,7,"かつどうじかん（へいじつ）");
	text_put_string(2,8,"ＰＭ８：００〜９：００ぐらいまで");
	text_put_string(0,10,"おせわになったせんせい");
	text_put_string(2,11,"いまいせんせい");
	text_put_string(2,12,"もりかわせんせい");
	text_put_string(2,13,"おがさわらせんせい");
	text_put_string(0,15,"そうごうプロデュース");
	text_put_string(2,17,"ｂｙ　ぐっちーたい");
	key_wait();
}

void ending()
{
	ending1();
	while(1){
		ret_code_open=key_press_check();
		if((ret_code_open&KEY_X1)!=0){
			ending2();
			for(i=0;i<50000;i++);
			ret_code_open=key_press_check();
		}
		if((ret_code_open&KEY_X2)!=0){
			ending3();
			for(i=0;i<50000;i++);
			ret_code_open=key_press_check();
		}
		if((ret_code_open&KEY_B)!=0)
			break;
	}
}

void b_shot() /*自機ショット(ボム)*/
{
	int w;
	if(flag_b[0]==0){
		limit1=0;
		w=beam[9]=beam[10]=beam[11]=mych[1]; /*自機のy座標の記憶*/
		beam[6]=beam[7]=beam[8]=mych[0]; /*	自機のx座標の記憶*/
		flag_b[0]=flag_b[1]=flag_b[2]=flag_b[3]=1; /*発射FLAG ON*/
	}
	if(flag_b[0]==1){
		if(flag_b[1]==1){	/*弾表示（左）*/
			if(ring%2==0) beam[6]-=spe_bxl;
			beam[9]-=spe_by;
			sprite_set_location(50,beam[6],beam[9]);
			if(beam[9]==w-spe_by){
				se_play_n(0);/*Bボタン効果音*/
			}
			if(beam[6]<9){
				limit1++;
				sprite_set_location(50,-15,-15);
				flag_b[1]=0;
			}
			if(beam[9]<0){
				sprite_set_location(50,-15,-15);
				flag_b[1]=0; flag_b[0]=0; limit1=0;
			}
		}
		if(flag_b[2]==1){	/*弾表示（中）*/
			beam[10]-=spe_by;
			sprite_set_location(51,beam[7],beam[10]);
			if(beam[10]<0){
				sprite_set_location(51,-15,-15);
				flag_b[2]=0; flag_b[0]=0; limit1=0;
			}
		}
		if(flag_b[3]==1){	/*弾表示（右）*/
			if(ring%2==0) beam[8]+=spe_bxr;	
			beam[11]-=spe_by;
			sprite_set_location(52,beam[8],beam[11]);
			if(beam[8]>174){
				limit1++;
				sprite_set_location(52,-15,-15);
				flag_b[3]=0;
			}
			if(beam[11]<0){
				sprite_set_location(52,-15,-15);
				flag_b[3]=0; flag_b[0]=0; limit1=0;
			}
		}
	}
}


void format()	/*ステージが変わるときの初期化*/
{
	block_f=0; 
	if(stage==7){
		nami=1; nami2=0;
	}
	if(stage==3) nami2=1;
	/*敵の能力の変更を挿入*/
	if(info[0]==1){ /*BRANKのとき*/
		ray_x-=10;  ray2_x-=10;
		ray3_x-=10; ray4_x-=10;
		kazu_s+=10;
		if(stage==5){
			tahu_s++; blocker--;
			blocker1--; blocker2--;
		}
		if(stage==7) tahu_s++;
		if(stage==9){
			tahu_s++; spe_t2-=10;
		}
	}
	if(info[0]==2){ /*BRANKのとき*/
		ray_x-=10;  ray2_x-=10;
		ray3_x-=10; ray4_x-=10;
		kazu_s+=10;
		if(stage==5){
			tahu_s++; blocker--;
			blocker1--; blocker2--;
		}
		if(stage==7){
			tahu_s++; spe_t2-=10;
		}
		if(stage==9){
			tahu_s++; spe_t2-=10;
		}
	}
	if(info[0]==3){ /*BRANKのとき*/
		ray_x-=10;  ray2_x-=10;
		ray3_x-=10; ray4_x-=10;
		kazu_s+=10;
		if(stage==5){
			tahu_s++; blocker--;
			blocker1--; blocker2--;
		}
		if(stage==7){
			tahu_s++; spe_t2-=10;
		}
		if(stage==9){
			tahu_s++; spe_t2-=5;
			ray_x=1;  ray2_x=10;
			spe_b++;  spe_x++;
		}
	}
	mych[0]=100; mych[1]=136; teki6[6]=0;
	for(i=0;i<6;i++){
		for(j=0;j<4;j++){
			ray[i][j]=0;  ray2[i][j]=0;
			ray3[i][j]=0; ray4[i][j]=0;
		}
	}
	for(i=0;i<2;i++){
		fire[i]=0;  bren[i]=0;  tairyoku_f[i]=0;
	}
	for(i=0;i<3;i++){
		tairyoku[i][0]=tairyoku[i+3][0]=196+i*8;
		tairyoku[i][1]=88;
		tairyoku[i+3][1]=96;
		item2[i][0]=196+i*8; item2[i][1]=104;
		item3[i]=0;
	}
	for(i=0;i<4;i++){
		block[i][0]=52+i*8;    block2[i][0]=52+i*8;
		block[i+4][0]=116+i*8; block2[i+4][0]=116+i*8;
		block[i][1]=112;       block[i+4][1]=112;
		block2[i][1]=120;      block2[i+4][1]=120;
		gun_f[i]=0;  flag_b[i]=0;
	}
	for(i=0;i<5;i++){
		wait[i]=0;
		beam2[i]=0;
	}
	for(i=0;i<6;i++){	/*配列tekiの初期化*/
		teki[i][0]=16+i*28;  teki2[i][0]=16+i*28;
		teki3[i][0]=16+i*28; teki4[i][0]=16+i*28;
		teki[i][1]=40;       teki2[i][1]=25;
		teki3[i][1]=10;	  teki4[i][1]=10;
		teki5[i][1]=10;
		for(j=2;j<6;j++){
			teki[i][j]=0;  teki2[i][j]=0;
			teki3[i][j]=0; teki4[i][j]=0;
		}
		teki5[i][0]=teki6[i]=16+i*28;  
		move_f[i]=0;  move_f[i+6]=1;  move_f2[i]=0;  move_f2[i+6]=2;
		move_f3[i]=0; move_f3[i+6]=3; move_f4[i]=2;  move_f4[i+6]=4;
		atack_f[i]=0; atack_f2[i]=0;  atack_f3[i]=0; atack_f4[i]=0;
		s_flag[i]=0;  s_flag2[i]=0;   s_flag3[i]=0;  s_flag4[i]=0;
		hit[i]=0;	  item1[i]=0;	  
		x_flag[i]=0;  x_flag2[i]=0;   x_flag3[i]=0;  x_flag4[i]=0;
		a[i]=0;       a2[i]=0;        a3[i]=0;       a4[i]=0;
		beam[i]=beam[i+6]=0;
	}
	for(i=0;i<7;i++){
		if(i==1) flag[i]=1;
		else	 flag[i]=0;
	}
	for(i=0;i<7;i++){
		if(i==2 || i==4)
			dan[i]=1;
		else
			dan[i]=0;
	}
	for(i=0;i<7;i++){
		if(i==3)
			kazu[i]=18;
		else
			kazu[i]=0;
	}
	for(i=0;i<8;i++){
		teki7[i]=0;
		block[i][2]=block[i][3]=0;
		block2[i][2]=block2[i][3]=0;
		block_tahu[i]=block_tahu2[i]=1;
	}
}

void time()
{
	for(i=0;i<50000;i++);
	while(ret_code2==0){
		if(key_press_check()&KEY_B) ret_code2=1;
		for(i=0;i<30000;i++);
	}
	ret_code2=0;
}

void display()
{
/*画面 224*144*/
	display_control(0);
	lcd_set_color(0x6420,0xfca8);         /*色の設定*/
	palette_set_color(0,0X7650);          /*パレットの設定*/
	screen_set_scroll(SCREEN1,0,0);
	display_control(DCM_SCR1|DCM_SCR2|DCM_SPR|DCM_SCR2_WIN_INSIDE);
	screen_fill_char(SCREEN1,0,0,28,18,0x0000);
	screen2_set_window(23*8,17*8,4*8,2*8); /*windowの設定*/
	text_window_init(23,17,4,2,340);     /*windowの初期化*/
/*0〜511の番号 (キャラクタフォント)*/
	font_set_colordata(1,1,bmp_mych);/*1 自キャラ*/
	font_set_colordata(2,1,bmp_ray);/*2 自キャラの弾*/
	font_set_colordata(3,16,bmp_teki_boss1);/*3〜18 ボス1*/
	font_set_colordata(19,16,bmp_teki_boss1b);/*19〜34 壊れたボス1*/
	font_set_colordata(35,16,bmp_teki_boss2);/*35〜50 ボス2*/
	font_set_colordata(51,16,bmp_teki_boss2b);/*51〜66 壊れたボス2*/
	font_set_colordata(67,16,bmp_boom1);/*67〜82 爆発1*/
	font_set_colordata(83,16,bmp_boom2);/*83〜98 爆発2*/
	font_set_colordata(99,16,bmp_boom3);/*99〜114 爆発3*/
	font_set_colordata(115,16,bmp_boom4);/*115〜130 爆発4*/
	font_set_colordata(131,16,bmp_boom5);/*131〜146 爆発5*/
	font_set_colordata(147,1,bmp_BOSS_RAY_L);/*147 ボスの画面左側の弾*/
	font_set_colordata(148,1,bmp_BOSS_RAY_S);/*148 ボスの画面中心の弾*/
	font_set_colordata(149,1,bmp_BOSS_RAY_R);/*149 ボスの画面右側の弾*/
	font_set_colordata(150,1,bmp_BOSS_RAY_TL);/*150 ボスの画面左側の弾(追跡弾)*/
	font_set_colordata(151,1,bmp_BOSS_RAY_TR);/*151 ボスの画面右側の弾(追跡弾)*/
	font_set_colordata(152,1,bmp_BOSS_RAY_TS);/*152 ボスの画面中心の弾(追跡弾)*/
	font_set_colordata(153,1,bmp_boss_ray_t1);/*153 壁に跳ね返る弾1(ボス用)*/
	font_set_colordata(154,1,bmp_boss_ray_t2);/*154 壁に跳ね返る弾2(ボス用)*/
	font_set_colordata(155,1,bmp_razer);/*155 ボスのレーザー*/
	font_set_colordata(156,1,bmp_item_boss);/*156 ボス戦のアイテム*/
	font_set_colordata(157,4,bmp_boss_engo);/*157〜160 ボスの援護*/
	font_set_colordata(161,1,bmp_boss_engo_ray);/*161 ボスの援護の弾*/
	font_set_colordata(162,126,bmp_haikei_bv);/*背景*/
	font_set_colordata(288,1,bmp_my_hp1);
	font_set_colordata(289,1,bmp_my_hp2);
	font_set_colordata(290,1,bmp_my_hp3);
	font_set_colordata(291,1,bmp_my_hp4);
	font_set_colordata(292,1,bmp_my_hp5);
	font_set_colordata(293,1,bmp_my_hp6);
	font_set_colordata(294,1,bmp_my_hp7);
	font_set_colordata(295,1,bmp_my_hp8);
	font_set_colordata(296,1,bmp_ray2);
	font_set_colordata(297,1,bmp_ray3);
	/*最大128個　１水平ライン上には32個(スプライト)*/
	for(i=0;i<16;i++){
		sprite_set_char(i,i+3);
		sprite_set_location(i,-15,-15);
	}
	sprite_set_char(16,1);
	sprite_set_location(16,mych[0],mych[1]);
	sprite_set_char(17,2);
	sprite_set_location(17,-15,-15);
/*boss_shot1*/
	for(i=0;i<2;i++){ 
		sprite_set_char(i+18,152);
		sprite_set_location(i+18,-15,-15);
	}
/*boss_shot2*/
	sprite_set_char(20,147);
	sprite_set_char(21,147);
	sprite_set_char(22,148);
	sprite_set_char(23,149);
	sprite_set_char(24,149);
	for(i=0;i<5;i++) sprite_set_location(i+20,-15,-15);
/*boss_shot3*/
	for(i=0;i<7;i++){/*1*/
		sprite_set_char(i+25,153);
		sprite_set_location(i+25,-15,-15);
	}
/*boss_shot4*/
	for(i=0;i<5;i++){
		sprite_set_char(i+32,155);
		sprite_set_location(i+32,-15,-15);
	}
/*boss_engo*/
	for(i=0;i<4;i++){
		sprite_set_char(i+37,i+157);
		sprite_set_location(i+37,-15,-15);
	}
/*engo_shot*/
	sprite_set_char(41,161);
	sprite_set_location(41,-15,-15);
/*my_gage*/
	sprite_set_char(42,295);
	sprite_set_char(43,295);
	sprite_set_char(44,291);
	for(i=0;i<3;i++) sprite_set_location(i+42,my_gage_x[i],my_gage_y[i]);
/*----------*/
	mych[0]=112;mych[1]=136;
	sprite_set_location(0,mych[0],mych[1]);
	sprite_set_char(47,296);
	sprite_set_char(48,297);
/*engo_shot2*/
	for(i=0;i<5;i++){
		sprite_set_char(i+49,155);
		sprite_set_location(i+49,-15,-15);
	}
/*engo_shot3*/
	sprite_set_char(54,147);
	sprite_set_char(55,147);
	sprite_set_char(56,148);
	sprite_set_char(57,149);
	sprite_set_char(58,149);
	for(i=0;i<5;i++) sprite_set_location(i+54,-15,-15);
/*engo_shot4*/
	for(i=0;i<2;i++){ 
		sprite_set_char(i+59,152);
		sprite_set_location(i+59,-15,-15);
	}
/*---------*/
	sprite_set_range(0,61);/**/
	put_bv();
}

void put_bv()
{
	for(i=0;i<126;i++) bv[i]=162+i;
	for(i=0;i<=42;i+=14){
		for(j=0;j<=27;j+=9){
			screen_set_char(SCREEN1,i,j,14,9,bv);
		}
	}
}

void hantei_engo()
{
	engo_temp_x=(mych[0]+4)-(engo_shot_x+4);
	engo_temp_y=(mych[1]+4)-(engo_shot_y+4);
	if(((engo_temp_x*engo_temp_x+engo_temp_y*engo_temp_y)<64)&&engo_shot_f==0){
		engo_shot_x=engo_shot_y=-15;
		sprite_set_location(41,engo_shot_x,engo_shot_y);
		engo_shot_f=1;
		tahu_mych[0]++;
		sco-=100;
		if(tahu_mych[0]==tahu_mych[1]){
			mych[0]=mych[1]=-15;
			sprite_set_location(16,mych[0],mych[1]);
			stop_flag[2]=stmych=1;
			end_flag[2]=1;
		}
	}
	engo_temp_x2=(mych[0]+4)-(boss_engo_x[0]+8);
	engo_temp_y2=(mych[1]+4)-(boss_engo_y[0]+8);
	if((engo_temp_x2*engo_temp_x2+engo_temp_y2*engo_temp_y2)<144){
		tahu_mych[0]++;
		if(tahu_mych[0]==tahu_mych[1]){
			mych[0]=mych[1]=-15;
			sprite_set_location(16,mych[0],mych[1]);
			stop_flag[2]=stmych=1;
			end_flag[2]=1;
		}
	}
	engo_temp_x3=(beam[0]+4)-(boss_engo_x[0]+8);
	engo_temp_y3=(beam[1]+4)-(boss_engo_y[0]+8);
	if((engo_temp_x3*engo_temp_x3+engo_temp_y3*engo_temp_y3)<144){
		tahu_engo[0]++;
		beam[0]=beam[1]=(-15);
		sprite_set_location(24,beam[0],beam[1]);
		sco+=100;
		if(tahu_engo[0]==tahu_engo[1]){
			for(i=0;i<4;i++){
				boss_engo_x[i]=boss_engo_y[i]=-15;
				sprite_set_location(i+37,boss_engo_x[i],boss_engo_y[i]);
			}
			stop_flag[6]=1;
			engo_shot_x=engo_shot_y=-15;
			sprite_set_location(41,engo_shot_x,engo_shot_y);
			engo_shot_f=1;
			for(i=0;i<5;i++){
				engo_razer_x[i]=engo_razer_y[i]=-15;
				sprite_set_location(i+49,engo_razer_x[i],engo_razer_y[i]);
			}
			for(i=0;i<5;i++){
				engo_ray_x3[i]=engo_ray_y3[i]=-15;
				sprite_set_location(i+54,engo_ray_x3[i],engo_ray_y3[i]);
			}
			for(i=0;i<2;i++){
				engo_ray_x4[i]=engo_ray_y4[i]=-15;
				sprite_set_location(i+59,engo_ray_x4[i],engo_ray_y4[i]);
			}
		}
	}
	if((stop_flag[4]==0)||(engo_bm[1]==1)){
		for(i=0;i<5;i++){
			engo_temp_x4[i]=(mych[0]+4)-(engo_ray_x3[i]+4);
			engo_temp_y4[i]=(mych[1]+4)-(engo_ray_y3[i]+4);
			if((engo_temp_x4[i]*engo_temp_x4[i]+engo_temp_y4[i]*engo_temp_y4[i])<64){
				engo_ray_x3[i]=engo_ray_y3[i]=-15;
				sprite_set_location(i+54,engo_ray_x3[i],engo_ray_y3[i]);
				tahu_mych[0]++;
				engo_ray_f3[i]=1;
				engo_ray_f3[5]++;
				sco-=100;
				if(tahu_mych[0]==tahu_mych[1]){
					mych[0]=mych[1]=-15;
					sprite_set_location(16,mych[0],mych[1]);
					stop_flag[2]=stmych=1;
					end_flag[2]=1;
				}
			}
		}
	}
}

void hantei_mych()
{
	if((stop_flag[3]==0)||(boss_bm[0]==1)){
		for(i=0;i<2;i++){
			temp1[2]=(mych[0]+4)-(boss_ray_x1[i]+4);
			temp1[3]=(mych[1]+4)-(boss_ray_y1[i]+4);
			if((temp1[2]*temp1[2]+temp1[3]*temp1[3])<64){
				boss_ray_x1[i]=boss_ray_y1[i]=-15;
				sprite_set_location(i+18,boss_ray_x1[i],boss_ray_y1[i]);
				tahu_mych[0]++;
				boss_ray_f1[i]=1;
				boss_ray_f1[2]++;
				sco-=100;
				if(tahu_mych[0]==tahu_mych[1]){
					mych[0]=mych[1]=-15;
					sprite_set_location(16,mych[0],mych[1]);
					stop_flag[2]=stmych=1;
					end_flag[2]=1;
				}
			}
		}
	}
	if((stop_flag[4]==0)||(boss_bm[1]==1)){
		for(i=0;i<5;i++){
			temp_x2[i]=(mych[0]+4)-(boss_ray_x2[i]+4);
			temp_y2[i]=(mych[1]+4)-(boss_ray_y2[i]+4);
			if((temp_x2[i]*temp_x2[i]+temp_y2[i]*temp_y2[i])<64){
				boss_ray_x2[i]=boss_ray_y2[i]=-15;
				sprite_set_location(i+20,boss_ray_x2[i],boss_ray_y2[i]);
				tahu_mych[0]++;
				boss_ray_f2[i]=1;
				boss_ray_f2[5]++;
				sco-=100;
				if(tahu_mych[0]==tahu_mych[1]){
					mych[0]=mych[1]=-15;
					sprite_set_location(16,mych[0],mych[1]);
					stop_flag[2]=stmych=1;
					end_flag[2]=1;
				}
			}
		}
	}
	if((stop_flag[5]==0)&&(boss_bm[2]==1||boss_ray_st3[0]==1)){
		for(i=0;i<dan_p;i++){
			temp_x3[i]=(mych[0]+4)-(boss_ray_x3[i]+4);
			temp_y3[i]=(mych[1]+4)-(boss_ray_y3[i]+4);
			if((temp_x3[i]*temp_x3[i]+temp_y3[i]*temp_y3[i])<64){
				boss_ray_x3[i]=boss_ray_y3[i]=-15;
				sprite_set_location(i+25,boss_ray_x3[i],boss_ray_y3[i]);
				tahu_mych[0]++;
				boss_ray_f3[i]=1;
				sco-=100;
				if(tahu_mych[0]==tahu_mych[1]){
					mych[0]=mych[1]=-15;
					sprite_set_location(16,mych[0],mych[1]);
					stop_flag[2]=stmych=1;
					end_flag[2]=1;
				}
			}
		}
	}
	if(stop_flag[0]==0){
		temp_x=(mych[0]+4)-(boss_x[1]+16);
		temp_y=(mych[1]+4)-(boss_y[1]+16);
		if((temp_x*temp_x+temp_y*temp_y)<400){
			tahu_mych[0]++;
			sco-=100;
			if(tahu_mych[0]==tahu_mych[1]){
				mych[0]=mych[1]=-15;
				sprite_set_location(16,mych[0],mych[1]);
				stop_flag[2]=stmych=1;
				end_flag[2]=1;
			}
		}
	}
	if(razer_off==1||razer_f[5]==1){
		for(i=0;i<5;i++){
			temp_x4[i]=(mych[0]+4)-(razer_x[i]+4);
			temp_y4[i]=(mych[1]+4)-(razer_y[i]+4);
			if((temp_x4[i]*temp_x4[i]+temp_y4[i]*temp_y4[i])<64){
				tahu_mych[0]++;
				razer_f[i]=1;
				sco-=100;
				razer_x[i]=razer_y[i]=-15;
				sprite_set_location(i+32,razer_x[i],razer_y[i]);
				if(tahu_mych[0]==tahu_mych[1]){
					mych[0]=mych[1]=-15;
					sprite_set_location(16,mych[0],mych[1]);
					stop_flag[2]=stmych=1;
					end_flag[2]=1;
				}
			}
		}
	}
	if(engo_razer_off==1||engo_razer_f[5]==1){
		for(i=0;i<5;i++){
			temp_x5[i]=(mych[0]+4)-(engo_razer_x[i]+4);
			temp_y5[i]=(mych[1]+4)-(engo_razer_y[i]+4);
			if((temp_x5[i]*temp_x5[i]+temp_y5[i]*temp_y5[i])<64){
				tahu_mych[0]++;
				engo_razer_f[i]=1;
				sco-=100;
				engo_razer_x[i]=engo_razer_y[i]=-15;
				sprite_set_location(i+49,engo_razer_x[i],engo_razer_y[i]);
				if(tahu_mych[0]==tahu_mych[1]){
					mych[0]=mych[1]=-15;
					sprite_set_location(16,mych[0],mych[1]);
					stop_flag[2]=stmych=1;
					end_flag[2]=1;
				}
			}
		}
	}
	if((stop_flag[3]==0)||(engo_bm[0]==1)){
		for(i=0;i<2;i++){
			temp_x6=(mych[0]+4)-(engo_ray_x4[i]+4);
			temp_y6=(mych[1]+4)-(engo_ray_y4[i]+4);
			if((temp_x6*temp_x6+temp_y6*temp_y6)<64){
				engo_ray_x4[i]=engo_ray_y4[i]=-15;
				sprite_set_location(i+59,engo_ray_x4[i],engo_ray_y4[i]);
				tahu_mych[0]++;
				engo_ray_f4[i]=1;
				engo_ray_f4[2]++;
				sco-=100;
				if(tahu_mych[0]==tahu_mych[1]){
					mych[0]=mych[1]=-15;
					sprite_set_location(16,mych[0],mych[1]);
					stop_flag[2]=stmych=1;
					end_flag[2]=1;
				}
			}
		}
	}
}

void engo_shot()
{
	if(ma_dori[24]>=ma_dori[25]){
		ma_dori[24]=0;
		if(engo_shot_s==0){
			engo_shot_s=1;
			engo_shot_x=boss_engo_x[0]+4;
			engo_shot_y=boss_engo_y[0]+16;
		}
		if(engo_shot_s==1){
			if(engo_shot_f==0){
				sprite_set_location(41,engo_shot_x,engo_shot_y);
				engo_shot_y+=engo_shot_my;
				if(engo_shot_y>=144){
					engo_shot_f=1;
					engo_shot_x=engo_shot_y=-15;
					sprite_set_location(41,engo_shot_x,engo_shot_y);
				}
			}
		}
		if(engo_shot_f==1){
			engo_shot_f=0;
			engo_shot_s=0;
		}
	}
	else ma_dori[24]++;
}

void engo_shot2()/*援護のレーザー*/
{
	if(ma_dori[28]>=ma_dori[29]){
		ma_dori[28]=0;
		if(engo_razer_off==1||engo_razer_f[5]==1){
			if(engo_razer_f[5]==0){
				for(i=0;i<5;i++){
					engo_razer_x[i]=boss_engo_x[1]+4;
					engo_razer_y[i]=boss_engo_y[1]+16;
					engo_razer_f[i]=0;
				}
				engo_razer_f[5]=1;
				engo_razer_sf=0;
			}
			if(engo_razer_f[5]==1){
				for(i=0;i<5;i++){
					if(engo_razer_f[i]==0){
						sprite_set_location(i+49,engo_razer_x[i],engo_razer_y[i]);
						if(engo_razer_mf[i]>8){
							engo_razer_x[i]+=engo_razer_mx[i];
							engo_razer_y[i]+=engo_razer_my[i];
							if(i!=4) engo_razer_mf[i+1]+=engo_razer_my[i];
						}
						if(engo_razer_y[i]>144){
							engo_razer_y[i]=0;
							engo_razer_f[i]=1;
							if(engo_razer_f[0]==1&&engo_razer_f[1]==1&&engo_razer_f[2]==1&&engo_razer_f[3]==1&&engo_razer_f[4]==1){
								engo_razer_f[5]=0;
								for(i=1;i<5;i++) engo_razer_mf[i]=0;
							}
						}
					}
					if(engo_razer_f[0]==1&&engo_razer_f[1]==1&&engo_razer_f[2]==1&&engo_razer_f[3]==1&&engo_razer_f[4]==1){
						engo_razer_f[5]=0;
						engo_razer_sf=1;
						for(i=1;i<5;i++) engo_razer_mf[i]=0;
					}
					if(engo_razer_sf==0){
						if(i!=4){
							if(engo_razer_f[i]==1&&engo_razer_f[i+1]==0){
								engo_razer_mf[i+1]=9;
							}
						}
					}
				}
			}
		}
	}
	else ma_dori[28]++;
}

void engo_shot3()/*援護の五方向の弾*/
{
	if(ma_dori[30]>=ma_dori[31]){
		ma_dori[30]=0;
		if(engo_bm[1]==0){
			for(i=0;i<5;i++){
				engo_ray_x3[i]=boss_engo_x[1]+4;
				engo_ray_y3[i]=boss_engo_y[1]+16;
			}
			engo_bm[1]=1;
		}
		if(engo_bm[1]==1){
			for(i=0;i<5;i++){
				if(engo_ray_f3[i]==0){
					sprite_set_location(i+54,engo_ray_x3[i],engo_ray_y3[i]);
					if(i==0||i==1){
						engo_ray_x3[i+5]=0;
						engo_ray_x3[i+10]++;
						if(i==0){
							if(engo_ray_x3[i+10]==1){
								engo_ray_x3[i+10]=0;
								engo_ray_x3[i+5]=-1;
							}
						}
						else{
							if(engo_ray_x3[i+10]==2){
								engo_ray_x3[i+10]=0;
								engo_ray_x3[i+5]=-1;
							}
						}
					}
					if(i==3||i==4){
						engo_ray_x3[i+5]=0;
						engo_ray_x3[i+9]++;
						if(i==3){
							if(engo_ray_x3[i+9]==1){
								engo_ray_x3[i+9]=0;
								engo_ray_x3[i+5]=1;
							}
						}
						else{
							if(engo_ray_x3[i+9]==2){
								engo_ray_x3[i+9]=0;
								engo_ray_x3[i+5]=1;
							}
						}
					}
					engo_ray_x3[i]+=engo_ray_x3[i+5];
					engo_ray_y3[i]+=engo_ray_y3[5];
					if(engo_ray_y3[i]>144){
						engo_ray_f3[i]=1;
						engo_ray_f3[5]++;
						engo_ray_x3[i]=engo_ray_y3[i]=-15;
						sprite_set_location(i+54,engo_ray_x3[i],engo_ray_y3[i]);
					}
				}
				if(engo_ray_f3[5]==5){
					engo_bm[1]=0;
					for(i=0;i<6;i++) engo_ray_f3[i]=0;
				}
			}
		}
	}
	else ma_dori[30]++;
}

/*---------------------------------------------------------------------------------------------------------------------*/

void engo_shot4()/*追跡弾*/
{
	if(ma_dori[32]>=ma_dori[33]){
		ma_dori[32]=0;
		if(engo_bm[0]==0){
			engo_ray_x4[0]=boss_engo_x[1];
			engo_ray_x4[1]=boss_engo_x[1]+8;
			engo_ray_y4[0]=engo_ray_y4[1]=boss_engo_y[1]+16;
			engo_bm[0]=1;
		}
		else{
			for(i=0;i<2;i++){
				if(engo_ray_f4[i]!=1){
					sprite_set_location(i+59,engo_ray_x4[i],engo_ray_y4[i]);
					if(engo_ray_y4[i]<=144) engo_ray_y4[i]+=engo_ray_y4[2];
					if((engo_ray_x4[i]!=(mych[0]+down[i]))&&(engo_ray_f4[i+3]==0)) tuiseki2();
					if(engo_ray_x4[i]==(mych[0]+down[i])){
						sprite_set_char(i+59,152);
						engo_ray_x4[i+2]=0;
						engo_ray_f4[i+3]=1;
					}
					if(engo_ray_y4[i]<=144) engo_ray_x4[i]+=engo_ray_x4[i+2];
					if(engo_ray_y4[i]>144){
						engo_ray_f4[i]=1;
						engo_ray_f4[2]++;
						engo_ray_x4[i]=engo_ray_y4[i]=-15;
						sprite_set_location(i+59,engo_ray_x4[i],engo_ray_y4[i]);
					}
				}
			}
			if(engo_ray_f4[2]==2){
				engo_bm[0]=0;
				engo_ray_f4[0]=engo_ray_f4[1]=engo_ray_f4[2]=engo_ray_f4[4]=0;
				for(i=0;i<2;i++){
					sprite_set_char(i+59,152);
					engo_ray_f4[i+3]=0;
				}
			}
		}
	}
	else ma_dori[32]++;
}

void tuiseki2()
{
	if(engo_ray_x4[i]>(mych[0]+down[i])){
		sprite_set_char(i+59,150);
		engo_ray_x4[i+2]=-1;
	}
	if(engo_ray_x4[i]<(mych[0]+down[i])){
		sprite_set_char(i+59,151);
		engo_ray_x4[i+2]=1;
	}
}
/*----------------------------------------------------------------------------------------------------------------------*/

void boss_engo_move()
{
	if(ma_dori[22]>=ma_dori[23]){
		ma_dori[22]=0;
		if(boss_engo_ms==0){
			boss_engo_x[0]=104;
			boss_engo_y[0]=0;
			boss_engo_ms=1;
			get_point2();
		}
		if(boss_engo_ms==1){
			for(i=0;i<4;i++) sprite_set_location(i+37,boss_engo_x[i],boss_engo_y[i]);
			boss_engo_x[0]+=boss_engo_mx;
			get_point2();
			if((boss_engo_x[3]>208)||(boss_engo_x[0]<0)){
				boss_engo_mx=-boss_engo_mx;
				get_point2();
			}
		}
	}
	else ma_dori[22]++;
}

void move1() /*自キャラの移動*/
{
	if(ma_dori[6]>=ma_dori[7]){
		ma_dori[6]=0;
		if(ret_code&KEY_X2){ /*右移動*/
			if(mych[0]<216) mych[0]+=spe_x;
		}
		if(ret_code&KEY_X4){ /*左移動*/
			if(mych[0]>0)mych[0]-=spe_x;
		}
		if(ret_code&KEY_X1){ /*上移動*/
			if(mych[1]>0) mych[1]-=spe_y;
		}
		if(ret_code&KEY_X3){ /*下移動*/
			if(mych[1]<128) mych[1]+=spe_y;
		}
		sprite_set_location(16,mych[0],mych[1]);
	}
	else ma_dori[6]++;
}

void shot1() /*自機ショット*/
{
	int w;
	if(((bk&KEY_A)==0)&&(ret_code&KEY_A)){
		if(flag[0]==0){
			w=beam[1]=mych[1]; /*自機のy座標の記憶*/
			beam[0]=mych[0]; /*	自機のx座標の記憶*/
			flag[0]=1; /*発射FLAG ON*/
		}
	}
	if(flag[0]==1){
		if(ma_dori[8]>=ma_dori[9]){
			ma_dori[8]=0;
			if(ret_code&KEY_Y4) beam[0]--;
			if(ret_code&KEY_Y2) beam[0]++;
			beam[1]-=spe_b;
			if(info[0]==1)
				sprite_set_location(17,beam[0],beam[1]); /*弾表示*/
			if(info[0]==2)
				sprite_set_location(47,beam[0],beam[1]);
			if(info[0]==3)
				sprite_set_location(48,beam[0],beam[1]);
			if(beam[1]<-8){ /*弾が外に行ったよ*/
				flag[0]=0;
				beam[0]=beam[1]=(-15);
				sprite_set_location(17,beam[0],beam[1]);
			}
			if(beam[1]==w-spe_b){
				se_play_n(0);
			}
		}
		else ma_dori[8]++;
	}
}

void boss_shot4()/*レーザー*/
{
	if(ma_dori[18]>=ma_dori[19]){
		ma_dori[18]=0;
		if(razer_off==1||razer_f[5]==1){
			if(razer_f[5]==0){
				for(i=0;i<5;i++){
					razer_x[i]=boss_x[1]+12;
					razer_y[i]=boss_y[1]+32;
					razer_f[i]=0;
				}
				razer_f[5]=1;
				boss_razer_sf=0;
			}
			if(razer_f[5]==1){
				for(i=0;i<5;i++){
					if(razer_f[i]==0){
						sprite_set_location(i+32,razer_x[i],razer_y[i]);
						if(razer_mf[i]>8){
							razer_x[i]+=razer_mx[i];
							razer_y[i]+=razer_my[i];
							if(i!=4) razer_mf[i+1]+=razer_my[i];
						}
						if(razer_y[i]>144){
							razer_y[i]=0;
							razer_f[i]=1;
							if(razer_f[0]==1&&razer_f[1]==1&&razer_f[2]==1&&razer_f[3]==1&&razer_f[4]==1){
								razer_f[5]=0;
								for(i=1;i<5;i++) razer_mf[i]=0;
							}
						}
					}
					if(razer_f[0]==1&&razer_f[1]==1&&razer_f[2]==1&&razer_f[3]==1&&razer_f[4]==1){
						razer_f[5]=0;
						boss_razer_sf=1;
						for(i=1;i<5;i++) razer_mf[i]=0;
					}
					if(boss_razer_sf==0){
						if(i!=4){
							if(razer_f[i]==1&&razer_f[i+1]==0){
								razer_mf[i+1]=9;
							}
						}
					}
				}
			}
		}
	}
	else ma_dori[18]++;
}

void boss_shot3()/*あたるまで消えない弾*/
{
	if(ma_dori[16]>=ma_dori[17]){
		ma_dori[16]=0;
		if(ma_dori[20]>=ma_dori[21]){
			ma_dori[20]=0;
			if(boss_ray_st3[0]==1){
				dan_flag=1;
				for(i=0;i<dan_p&&dan_temp1==0;i++){
					if(boss_ray_f3[i]==1){
						dan_temp1=1;
						dan_temp2=i;
						boss_ray_f3[i]=0;
						dan_flag=0;
					}
				}
				if(dan_flag==0){
					if(boss_ray_f3[dan_temp2]==0){
						boss_ray_x3[dan_temp2]=boss_x[1]+12;
						boss_ray_y3[dan_temp2]=boss_y[1]+32;
						if((boss_x[1]+16)>=(mych[0]+4))	boss_ray_mx3[dan_temp2]=-2;
						else boss_ray_mx3[dan_temp2]=2;
						if(boss_ray_my3[dan_temp2]<0) boss_ray_my3[dan_temp2]=(-boss_ray_my3[dan_temp2]);
					}
				}
				boss_bm[2]=1;
				boss_ray_st3[0]=0;
				dan_temp1=0;
			}
		}
		else ma_dori[20]++;
		if(boss_bm[2]==1){
			for(i=0;i<dan_p;i++){
				if(boss_ray_f3[i]==0){
					sprite_set_location(i+25,boss_ray_x3[i],boss_ray_y3[i]);
					if(sps3_now[i]==sps3_lim[i]){
						sps3_now[i]=0;
						if(sps3[i]==0){
							sprite_set_char(i+25,153);
							sps3[i]=1;
						}
						if(sps3[i]==1){
							sprite_set_char(i+25,154);
							sps3[i]=0;
						}
					}
					else sps3_now[i]++;
					if(boss_ray_f3[i]==0) boss_ray_x3[i]+=boss_ray_mx3[i];
					if((boss_ray_x3[i]>X_BLIT)||(boss_ray_x3[i]<X_SLIT)){
						boss_ray_x3[i]-=boss_ray_mx3[i];
						boss_ray_mx3[i]=(-boss_ray_mx3[i]);
					}
					if(boss_ray_f3[i]==0) boss_ray_y3[i]+=boss_ray_my3[i];
					if((boss_ray_y3[i]>136)||(boss_ray_y3[i]<0)){
						boss_ray_y3[i]-=boss_ray_my3[i];
						boss_ray_my3[i]=(-boss_ray_my3[i]);
					}
				}
			}
		}
	}
	else ma_dori[16]++;
}

void boss_shot2()/*五方向の弾*/
{
	if(ma_dori[14]>=ma_dori[15]){
		ma_dori[14]=0;
		if(boss_bm[1]==0){
			for(i=0;i<5;i++){
				boss_ray_x2[i]=boss_x[1]+12;
				boss_ray_y2[i]=boss_y[1]+32;
			}
			boss_bm[1]=1;
		}
		if(boss_bm[1]==1){
			for(i=0;i<5;i++){
				if(boss_ray_f2[i]==0){
					sprite_set_location(i+20,boss_ray_x2[i],boss_ray_y2[i]);
					if(i==0||i==1){
						boss_ray_x2[i+5]=0;
						boss_ray_x2[i+10]++;
						if(i==0){
							if(boss_ray_x2[i+10]==1){
								boss_ray_x2[i+10]=0;
								boss_ray_x2[i+5]=-1;
							}
						}
						else{
							if(boss_ray_x2[i+10]==2){
								boss_ray_x2[i+10]=0;
								boss_ray_x2[i+5]=-1;
							}
						}
					}
					if(i==3||i==4){
						boss_ray_x2[i+5]=0;
						boss_ray_x2[i+9]++;
						if(i==3){
							if(boss_ray_x2[i+9]==1){
								boss_ray_x2[i+9]=0;
								boss_ray_x2[i+5]=1;
							}
						}
						else{
							if(boss_ray_x2[i+9]==2){
								boss_ray_x2[i+9]=0;
								boss_ray_x2[i+5]=1;
							}
						}
					}
					boss_ray_x2[i]+=boss_ray_x2[i+5];
					boss_ray_y2[i]+=boss_ray_y2[5];
					if(boss_ray_y2[i]>144){
						boss_ray_f2[i]=1;
						boss_ray_f2[5]++;
						boss_ray_x2[i]=boss_ray_y2[i]=-15;
						sprite_set_location(i+20,boss_ray_x2[i],boss_ray_y2[i]);
					}
				}
				if(boss_ray_f2[5]==5){
					boss_bm[1]=0;
					for(i=0;i<6;i++) boss_ray_f2[i]=0;
				}
			}
		}
	}
	else ma_dori[14]++;
}

void boss_shot1()/*追跡弾*/
{
	if(ma_dori[12]>=ma_dori[13]){
		ma_dori[12]=0;
		if(boss_bm[0]==0){
			boss_ray_x1[0]=boss_x[1];
			boss_ray_x1[1]=boss_x[1]+24;
			boss_ray_y1[0]=boss_ray_y1[1]=boss_y[1]+32;
			boss_bm[0]=1;
		}
		else{
			for(i=0;i<2;i++){
				if(boss_ray_f1[i]!=1){
					sprite_set_location(i+18,boss_ray_x1[i],boss_ray_y1[i]);
					if(boss_ray_y1[i]<=144) boss_ray_y1[i]+=boss_ray_y1[2];
					if((boss_ray_x1[i]!=(mych[0]+down[i]))&&(boss_ray_f1[i+3]==0)) tuiseki();
					if(boss_ray_x1[i]==(mych[0]+down[i])){
						sprite_set_char(i+18,152);
						boss_ray_x1[i+2]=0;
						boss_ray_f1[i+3]=1;
					}
					if(boss_ray_y1[i]<=144) boss_ray_x1[i]+=boss_ray_x1[i+2];
					if(boss_ray_y1[i]>144){
						boss_ray_f1[i]=1;
						boss_ray_f1[2]++;
						boss_ray_x1[i]=boss_ray_y1[i]=-15;
						sprite_set_location(i+18,boss_ray_x1[i],boss_ray_y1[i]);
					}
				}
			}
			if(boss_ray_f1[2]==2){
				boss_bm[0]=0;
				boss_ray_f1[0]=boss_ray_f1[1]=boss_ray_f1[2]=boss_ray_f1[4]=0;
				for(i=0;i<2;i++){
					sprite_set_char(i+18,152);
					boss_ray_f1[i+3]=0;
				}
			}
		}
	}
	else ma_dori[12]++;
}

void tuiseki()
{
	if(boss_ray_x1[i]>(mych[0]+down[i])){
		sprite_set_char(i+18,150);
		boss_ray_x1[i+2]=-1;
	}
	if(boss_ray_x1[i]<(mych[0]+down[i])){
		sprite_set_char(i+18,151);
		boss_ray_x1[i+2]=1;
	}
}

void move_baku()
{
	if(sps[2]==0){
		if(sps[0]==0&&sps[2]==0){
			for(i=0;i<16;i++) sprite_set_char(i,i+131);
			sps[2]=1;
			sps[3]=1;
			sps[4]++;
			bgm_stop();
			se_play_n(3);
		}
		if(sps[0]==1&&sps[2]==0){
			for(i=0;i<16;i++) sprite_set_char(i,i+115);
			sps[2]=1;
		}
		if(sps[0]==2&&sps[2]==0){
			for(i=0;i<16;i++) sprite_set_char(i,i+99);
			sps[2]=1;
		}
		if(sps[0]==3&&sps[2]==0){
			for(i=0;i<16;i++) sprite_set_char(i,i+83);
			sps[2]=1;
			se_play_n(3);
		}
		if(sps[0]==4&&sps[2]==0){
			for(i=0;i<16;i++) sprite_set_char(i,i+67);
			sps[2]=1;
			sps[3]=1;
		}
		if(sps[3]==1){
			sps[1]=(-sps[1]);
			sps[3]=0;
			bgm_stop();
			se_play_n(3);
		}
		for(i=0;i<16;i++) sprite_set_location(i,boss_x2[i],boss_y2[i]);
		sps[0]+=sps[1];
		if(sps[4]!=sps[5]) sps[2]=0;
	}
	else{
		for(i=0;i<16;i++) sprite_set_location(i,-15,-15);
		stop_flag[1]=0;
		end_flag[1]=1;
	}
}

void hantei_boss()
{
	if(stop_flag[0]==0){
		temp1[0]=(boss_x[1]+16)-(beam[0]+4);
		temp1[1]=(boss_y[1]+16)-(beam[1]+4);
		if((temp1[0]*temp1[0]+temp1[1]*temp1[1])<400){
			beam[0]=beam[1]=(-15);
			sprite_set_location(24,beam[0],beam[1]);
			tahu_boss[0]++;
			sco+=100;
			if(tahu_boss[0]==tahu_boss[1]){
				for(i=0;i<7;i++) stop_flag[i]=1;
				razer_off=0;
				for(i=0;i<2;i++){ 
					boss_ray_x1[i]=boss_ray_y1[i]=-15;
					sprite_set_location(i+18,boss_ray_x1[i],boss_ray_y1[i]);
				}
				for(i=0;i<5;i++){
					boss_ray_x2[i]=boss_ray_y2[i]=-15;
					sprite_set_location(i+20,boss_ray_x2[i],boss_ray_y2[i]);
				}
				for(i=0;i<7;i++){
					boss_ray_x3[i]=boss_ray_y3[i]=-15;
					sprite_set_location(i+25,boss_ray_x3[i],boss_ray_y3[i]);
				}
				for(i=0;i<5;i++){
					razer_x[i]=razer_y[i]=-15;
					sprite_set_location(i+32,razer_x[i],razer_y[i]);
				}
				for(i=0;i<4;i++){
					boss_engo_x[i]=boss_engo_y[i]=-15;
					sprite_set_location(i+37,boss_engo_x[i],boss_engo_y[i]);
				}
				for(i=0;i<5;i++){
					engo_razer_x[i]=engo_razer_y[i]=-15;
					sprite_set_location(i+49,engo_razer_x[i],engo_razer_y[i]);
				}
				for(i=0;i<5;i++){
					engo_ray_x3[i]=engo_ray_y3[i]=-15;
					sprite_set_location(i+54,engo_ray_x3[i],engo_ray_y3[i]);
				}
				for(i=0;i<2;i++){
					engo_ray_x4[i]=engo_ray_y4[i]=-15;
					sprite_set_location(i+59,engo_ray_x4[i],engo_ray_y4[i]);
				}
				engo_shot_x=engo_shot_y=-15;
				sprite_set_location(41,engo_shot_x,engo_shot_y);
			}
			if(tahu_boss[0]==((tahu_boss[1]-(tahu_boss[1]%2))/2)) boss_br_f=1;
		}
	}
}

void move_boss()
{
	if(ma_dori[0]>=ma_dori[1]){
		ma_dori[0]=0;
		if(stop_flag[0]==0){
			for(i=0;i<16;i++) sprite_set_location(i,boss_x2[i],boss_y2[i]);
			if(ma_dori[2]==ma_dori[3]){
				ma_dori[2]=0;
				if(boss_br_f==0){
					if(sps[0]==0){
						for(i=0;i<16;i++) sprite_set_char(i,i+3);
						sps[0]=1;
					}
					else{
						for(i=0;i<16;i++) sprite_set_char(i,i+35);
						sps[0]=0;
					}
				}
				if(boss_br_f==1){
					if(sps[0]==0){
						for(i=0;i<16;i++) sprite_set_char(i,i+19);
						sps[0]=1;
					}
				else{
						for(i=0;i<16;i++) sprite_set_char(i,i+51);
						sps[0]=0;
					}
				}
			}
			else ma_dori[2]++;
			if(sta_flag==0){		/*ボス前進(登場シーン)*/
				boss_y[1]+=boss_y[0];
				if((sta_flag==0)&&(boss_y[1]==32)){
					sta_flag=1;
					razer_off=1;
					engo_razer_off=1;
				}
			}
			if(sta_flag==1){
				if(turn[2]!=1){		/*ボス左右に移動*/
					if(turn[1]==0) boss_x[1]-=boss_x[0]; /*ボス左移動*/
					if(boss_x[1]<X_SLIT){
						turn[0]++;
						turn[1]=1;
					}
					if(turn[1]==1) boss_x[1]+=boss_x[0]; /*ボス右移動*/
					if(boss_x[1]>=X_BLIT-16){
						turn[0]++;
						turn[1]=0;
					}
					if(turn[0]==2&&boss_x[1]<senter_d_x){/*次の動作に切り替える*/
						turn[2]=1;
						turn[0]=0;
					}
				}
				if(turn[2]==1){		/*ボスが壁にあたると跳ね返る*/
					if(ma_dori[4]<ma_dori[5]&&turn[6]==0){
						ma_dori[4]++;
						ray_ray();
						boss_ray_st3[1]=0;
					}
					if(ma_dori[4]==ma_dori[5]&&turn[6]==0){
						stop_flag[3]=0;
						stop_flag[4]=1;
						if(turn[3]==0){			/*X方向の移動*/
							boss_x[1]+=boss_x[0];
							if(boss_x[1]>=X_BLIT+8-teki_boss1_width*8 || boss_x[1]<X_SLIT){
								boss_x[1]-=boss_x[0];
								boss_x[0]=(-boss_x[0]);
								turn[5]++;
							}
						}
						if(turn[4]==0){			/*Y方向の移動*/
							boss_y[1]+=boss_y[0];
							if(boss_y[1]>=Y_BLIT-teki_boss1_height*8 || boss_y[1]<Y_SLIT){
								boss_y[1]-=boss_y[0];
								boss_y[0]=(-boss_y[0]);
								turn[5]++;
							}
						}
					}
					if(turn[5]>5){	/*ボスを画面の中心まで移動させる*/
						if(senter_d_x==boss_x[1]){		/*ボスのX座標が中心にきたかどうか判断する*/
							if(boss_x[1]<0) boss_x[1]=(-boss_x[1]);
							turn[3]=1;
						}
						if(senter_d_y==boss_y[1]){		/*ボスのY座標が中心にきたかどうか判断する*/
							if(boss_y[1]<0) boss_y[1]=(-boss_y[1]);
							turn[4]=1;
						}
						if(turn[3]==1&&turn[4]==1){		/*ボスが画面の中心にきたかどうか判断する*/
							turn[5]=0;
							turn[6]=1;
							razer_off=0;
						}
					}
					if(turn[6]==1){	/*ボスの突撃*/
						if(boss_y[1]<144) boss_y[1]++;
						if(boss_y[1]>=144){	/*はじめの動作に戻る(フラグなどの初期化)*/
							boss_y[1]=(-32);
							turn[0]=turn[1]=turn[2]=turn[3]=turn[4]=turn[5]=turn[6]=0;
							ma_dori[4]=0;
							sta_flag=0;
							stop_flag[3]=1;
							stop_flag[4]=0;
						}
					}
				}
			}
		}
	}
	else ma_dori[0]++;
}

void get_point()
{
	boss_x2[0]=boss_x2[4]=boss_x2[8]=boss_x2[12]=boss_x[1];
	boss_x2[1]=boss_x2[5]=boss_x2[9]=boss_x2[13]=boss_x[1]+8;
	boss_x2[2]=boss_x2[6]=boss_x2[10]=boss_x2[14]=boss_x[1]+16;
	boss_x2[3]=boss_x2[7]=boss_x2[11]=boss_x2[15]=boss_x[1]+24;
	boss_y2[0]=boss_y2[1]=boss_y2[2]=boss_y2[3]=boss_y[1];
	boss_y2[4]=boss_y2[5]=boss_y2[6]=boss_y2[7]=boss_y[1]+8;
	boss_y2[8]=boss_y2[9]=boss_y2[10]=boss_y2[11]=boss_y[1]+16;
	boss_y2[12]=boss_y2[13]=boss_y2[14]=boss_y2[15]=boss_y[1]+24;
}

void ray_ray()
{
	if(boss_ray_st3[1]==0){
		boss_ray_st3[0]=1;
		boss_ray_st3[1]=1;
		if(boss_ray_sf==0){
			boss_ray_sf=1;
		}
	}
}

void get_point2()
{
	boss_engo_x[1]=boss_engo_x[3]=boss_engo_x[0]+8;boss_engo_x[2]=boss_engo_x[0];
	boss_engo_y[1]=boss_engo_y[0];boss_engo_y[2]=boss_engo_y[3]=boss_engo_y[0]+8;
}

void move_m() /*自キャラの移動*/
{
	if(ma_dori[6]>=ma_dori[7]){
		ma_dori[6]=0;
		if(ret_code&KEY_X2){ /*右移動*/
			if(mych[0]<216) mych[0]+=spe_x;
		}
		if(ret_code&KEY_X4){ /*左移動*/
			if(mych[0]>0)mych[0]-=spe_x;
		}
		if(ret_code&KEY_X1){ /*上移動*/
			if(mych[1]>0) mych[1]-=spe_y;
		}
		if(ret_code&KEY_X3){ /*下移動*/
			if(mych[1]<136) mych[1]+=spe_y;
		}
		sprite_set_location(16,mych[0],mych[1]);
	}
	else ma_dori[6]++;
}

void score2()
{
	text_put_numeric(0,0,4,NUM_SIGNED,sco);
}

void boss_init()/*初期化*/
{
	for(i=0;i<3;i++) end_flag[i]=0;
	if(stage==2){
		tahu_boss[1]+=15;
		tahu_engo[1]+=5;
	}
	if(stage==4){
		tahu_boss[1]+=15;
		tahu_engo[1]+=5;
	}
	if(stage==6){
		tahu_boss[1]+=15;
		tahu_engo[1]+=5;
	}
	if(stage==8){
		tahu_boss[1]+=15;
		tahu_engo[1]+=5;
	}
	if(stage==10){
		tahu_boss[1]+=15;
		tahu_engo[1]+=5;
	}
	tahu_boss[0]=0;
	tahu_mych[0]=0;
	for(i=0;i<7;i++){
		if(i!=3) stop_flag[i]=0;
		else stop_flag[i]=1;
	}
	boss_ray_clear=0;
	stmych=0;
	sps[0]=0;sps[1]=-1;sps[2]=0;sps[3]=0;sps[4]=0;sps[5]=50;
	for(i=0;i<16;i++) boss_x2[i]=boss_y2[i]=0;
	sta_flag=0;
	boss_x[0]=1;boss_x[1]=86;
	boss_y[0]=1;boss_y[1]=-32;
	for(i=0;i<7;i++) turn[i]=0;
	for(i=0;i<4;i++) temp1[i]=0;
	for(i=0;i<3;i++) boss_bm[i]=0;
	boss_ray_x1[0]=boss_ray_x1[1]=0;
	boss_ray_x1[2]=boss_ray_x1[3]=1;
	boss_ray_y1[0]=boss_ray_y1[1]=0;
	boss_ray_y1[2]=1;
	for(i=0;i<5;i++) boss_ray_f1[i]=0;
	down[0]=-4;down[1]=4;
	for(i=0;i<5;i++) boss_ray_x2[i]=-15;
	for(i=5;i<14;i++) boss_ray_x2[i]=0;
	for(i=0;i<5;i++) boss_ray_y2[i]=0;
	boss_ray_y2[5]=1;
	for(i=0;i<6;i++) boss_ray_f2[i]=0;
	for(i=0;i<7;i++) boss_ray_x3[i]=0;
	for(i=0;i<7;i++) boss_ray_mx3[i]=0;
	for(i=0;i<7;i++) boss_ray_y3[i]=0;
	for(i=0;i<7;i++) boss_ray_my3[i]=2;
	for(i=0;i<7;i++) sps3_now[i]=0;
	for(i=0;i<7;i++) sps3_lim[i]=10;
	for(i=0;i<7;i++) sps3[i]=0;
	for(i=0;i<2;i++) boss_ray_st3[i]=0;
	dan_p=7;
	for(i=0;i<7;i++) boss_ray_f3[i]=1;
	dan_temp1=0;dan_temp2=0;
	boss_ray_sf=0;boss_br_f=0;dan_flag=0;
	for(i=0;i<5;i++){
		razer_x[i]=0;
		razer_y[i]=0;
		razer_my[i]=1;
	}
	razer_mf[0]=9;
	for(i=1;i<5;i++) razer_mf[i]=0;
	for(i=0;i<6;i++) razer_f[i]=0;
	razer_off=0;
	boss_ray_clear=0;boss_razer_sf=0;
	boss_engo_ms=0;boss_engo_x[0]=104;
	boss_engo_y[0]=0;
	for(i=1;i<4;i++){
		boss_engo_x[i]=0;
		boss_engo_y[i]=0;
	}
	boss_engo_mx=1;engo_shot_s=0;
	engo_shot_x=0;engo_shot_y=0;
	engo_shot_f=0;engo_shot_my=1;
	engo_temp_x=0;engo_temp_y=0;
	engo_temp_x2=0;engo_temp_y2=0;
	engo_temp_x3=0;engo_temp_y3=0;
	tahu_engo[0]=0;
	for(i=0;i<2;i++) my_gage_f[i]=0;
	my_gage_f[2]=1;
	sprite_set_char(42,295);
	sprite_set_char(43,295);
	sprite_set_char(44,291);
	for(i=0;i<3;i++) sprite_set_location(i+42,-15,-15);
	my_gage_x[0]=my_gage_x[1]=my_gage_x[2]=216;
	my_gage_y[0]=136;my_gage_y[1]=128;my_gage_y[2]=120;
	engo_razer_off=0;
	for(i=0;i<5;i++){
		engo_razer_f[i]=0;
		engo_razer_x[i]=0;
		engo_razer_y[i]=0;
	}
	engo_razer_sf=0;
	engo_razer_mf[0]=9;engo_razer_mf[1]=0;engo_razer_mf[2]=0;engo_razer_mf[3]=0;engo_razer_mf[4]=0;
	engo_bm[0]=0;engo_bm[1]=0;engo_bm[2]=0;
	engo_ray_x3[0]=-15;engo_ray_x3[1]=-15;engo_ray_x3[2]=-15;engo_ray_x3[3]=-15;engo_ray_x3[4]=-15;engo_ray_x3[5]=0;
	engo_ray_x3[6]=0;engo_ray_x3[7]=0;engo_ray_x3[8]=0;engo_ray_x3[9]=0;engo_ray_x3[10]=0;engo_ray_x3[11]=0;
	engo_ray_x3[12]=0;engo_ray_x3[13]=0;
	engo_ray_y3[0]=0;engo_ray_y3[1]=0;engo_ray_y3[2]=0;engo_ray_y3[3]=0;engo_ray_y3[4]=0;engo_ray_y3[5]=1;
	engo_ray_f3[0]=0;engo_ray_f3[1]=0;engo_ray_f3[2]=0;engo_ray_f3[3]=0;engo_ray_f3[4]=0;engo_ray_f3[5]=0;
	engo_ray_x4[0]=0;engo_ray_x4[1]=0;engo_ray_x4[2]=1;engo_ray_x4[3]=1;
	engo_ray_y4[0]=0;engo_ray_y4[1]=0;engo_ray_y4[2]=1;
	engo_ray_f4[0]=0;engo_ray_f4[1]=0;engo_ray_f4[2]=0;engo_ray_f4[3]=0;engo_ray_f4[4]=0;
}

void my_gage()
{
	for(i=0;i<3;i++){
		if(my_gage_f[i]==1){
			if(i==2){
				if(tahu_mych[0]==1) sprite_set_char(44,290);
				if(tahu_mych[0]==2) sprite_set_char(44,289);
				if(tahu_mych[0]==3) sprite_set_char(44,288);
				if(tahu_mych[0]==4){
					my_gage_f[i]=0;
					my_gage_f[i-1]=1;
					my_gage_x[i]=my_gage_y[i]=-15;
					sprite_set_location(44,my_gage_x[i],my_gage_y[i]);
				}
				sprite_set_location(44,my_gage_x[i],my_gage_y[i]);
			}
			if(i==1){
				if(tahu_mych[0]==5) sprite_set_char(43,294);
				if(tahu_mych[0]==6) sprite_set_char(43,293);
				if(tahu_mych[0]==7) sprite_set_char(43,292);
				if(tahu_mych[0]==8) sprite_set_char(43,291);
				if(tahu_mych[0]==9) sprite_set_char(43,290);
				if(tahu_mych[0]==10) sprite_set_char(43,289);
				if(tahu_mych[0]==11) sprite_set_char(43,288);
				if(tahu_mych[0]==12){
					my_gage_f[i]=0;
					my_gage_f[i-1]=1;
					my_gage_x[i]=my_gage_y[i]=-15;
					sprite_set_location(43,my_gage_x[i],my_gage_y[i]);
				}
				sprite_set_location(43,my_gage_x[i],my_gage_y[i]);
			}
			if(i==0){
				if(tahu_mych[0]==13) sprite_set_char(42,294);
				if(tahu_mych[0]==14) sprite_set_char(42,293);
				if(tahu_mych[0]==15) sprite_set_char(42,292);
				if(tahu_mych[0]==16) sprite_set_char(42,291);
				if(tahu_mych[0]==17) sprite_set_char(42,290);
				if(tahu_mych[0]==18) sprite_set_char(42,289);
				if(tahu_mych[0]==19) sprite_set_char(42,288);
				if(tahu_mych[0]==20){
					my_gage_f[i]=0;
					my_gage_f[i-1]=1;
					my_gage_x[i]=my_gage_y[i]=-15;
					sprite_set_location(42,my_gage_x[i],my_gage_y[i]);
				}
				sprite_set_location(42,my_gage_x[i],my_gage_y[i]);
			}
		}
		sprite_set_location(i+42,my_gage_x[i],my_gage_y[i]);
	}
}


