#include "../include/GV.h"

extern void load_story();

void input_bullet_info(bullet_info_t *binfo,int size_x,int size_y,int col_num,double range,int kaiten){
	binfo->size_x =size_x;	binfo->size_y =size_y;
	binfo->col_num=col_num;	binfo->range  =range;
	binfo->kaiten=kaiten;
}

//stage_title_count[STAGE_NUM]に使う
int st_title_cnt[STAGE_NUM]={
	200,
};

//stage_boss_num[STAGE_NUM]の初期化に使う
int st_boss_num[STAGE_NUM]={
	0,1,2,3,4,11,13,14,15
};


//boss.appear_cnt[BOSS_MAX]の設定に利用する
int bos_appear_cnt[BOSS_MAX]={
	1700,1700,1700,1700,1700,
};

//boss.danmaku_num[BOSS_MAX]の設定に利用する
int bos_danmaku_num[BOSS_MAX]={
  0,1,2,3,4,
};

//弾幕のHP(耐久は0以下とする)
int boss_hp[DANMAKU_MAX]={
	5000,10000,8000,20000,30000,
};

//弾幕中の背景の種類
int back_knd[DANMAKU_MAX]={
	1,1,0,1,1,
};
//弾幕名設定に利用
char dan_name[DANMAKU_MAX][100]=
{"-テ-",
"-ス-  パーフェクトフリーズ",
"-ト-  サイレントセレナ",
"-ダ-  ケロちゃん",
"-ヨ-  反魂蝶",
"--",
};


//一番最初の初期化
void first_ini(){
	configpad.down=0;
	configpad.left=1;
	configpad.right=2;
	configpad.up=3;
	configpad.bom=4;
	configpad.shot=5;
	configpad.slow=11;
	configpad.start=13;
	configpad.change=6;

	input_bullet_info(&bullet_info[0],76, 76, 5,17.0,0);
	input_bullet_info(&bullet_info[1],22, 22, 6, 4.0,0);
	input_bullet_info(&bullet_info[2], 5,120,10, 2.5,0);
	input_bullet_info(&bullet_info[3],19, 34, 5, 2.0,0);
	input_bullet_info(&bullet_info[4],38, 38,10, 2.0,0);
	input_bullet_info(&bullet_info[5],14, 16, 3, 3.5,0);
	input_bullet_info(&bullet_info[6],14, 18, 3, 2.0,0);
	input_bullet_info(&bullet_info[7],16, 16, 9, 2.5,1);
	input_bullet_info(&bullet_info[8],12, 18,10, 1.5,0);
	input_bullet_info(&bullet_info[9],13, 19, 3, 2.0,0);
	input_bullet_info(&bullet_info[10],8,  8, 8, 1.0,0);
	input_bullet_info(&bullet_info[11],35,32, 8, 2.0,0);


	//ステージタイトルのタイミング
	//ステージ最後のボスの番号
	for(int i=0;i<STAGE_NUM;i++){
		stage_title_count[i]=st_title_cnt[i];
		stage_boss_num[i]=st_boss_num[i];
	}
	//ボスの出現タイミング
	//最後の弾幕の番号
	for(int i=0;i<BOSS_MAX;i++){
		boss.appear_count[i]=bos_appear_cnt[i];
		boss.danmaku_num[i]=bos_danmaku_num[i];
	}
	//弾幕の体力
	//弾幕の背景
	//弾幕の名前
	for(int i=0;i<DANMAKU_MAX;i++){
		boss.set_hp[i]=boss_hp[i];
		boss.back_knd[i]=back_knd[i];
		for(int j=0;j<100;j++){
			boss.danmaku_name[i][j]=dan_name[i][j];
		}
	}
	boss.hp_max=1;//graph_boss内0割りエラー回避

	option_bb[0].img=img_cshot[2];//オプションボンボンの画像代入(49)
	option_bb[1].img=img_cshot[2];

}

//ゲームの初期化
void game_ini(){
	//自機の初期化
	ch.extend=100;
	ch.flag=0;
	ch.graze=0;
	ch.mutekicnt=0;
	ch.num=4;
	ch.point=0;
	ch.power=400;//初期パワー(41)
	ch.score=0;

	//ボスの初期化
	boss.ang=0;
	boss.boss_num=0;
	boss.knd=-1;//enter_bossで1足されるため
	boss.dx=0;
	boss.dy=0;
	boss.cnt=0;
	boss.flag=0;
	boss.graph_flag=0;

	//ステージ情報の初期化
	stage=0;

}

void stage_ini(){

	Ini3Dbackground();//(60)

	stage_count=1;
	memset(enemy,0,sizeof(enemy_t)*ENEMY_MAX);
	memset(lazer,0,sizeof(lazer_t)*LAZER_MAX);
	memset(enemy_order,0,sizeof(enemy_order_t)*ENEMY_ORDER_MAX);
	memset(shot,0,sizeof(shot_t)*SHOT_MAX);
	memset(cshot,0,sizeof(cshot_t)*CSHOT_MAX);
	memset(effect,0,sizeof(effect_t)*EFFECT_MAX);
	memset(del_effect,0,sizeof(del_effect_t)*DEL_EFFECT_MAX);
	memset(&bom,0,sizeof(bom_t));
	memset(&bright_set,0,sizeof(bright_set_t));
	memset(&dn,0,sizeof(dn_t));
	memset(child,0,sizeof(child_t)*CHILD_MAX);
	memset(&stage_title,0,sizeof(stage_title_t));
	memset(item,0,sizeof(item_t)*ITEM_MAX);
	memset(&area,0,sizeof(area_t));//(48)
	memset(option_bb,0,sizeof(option_bb_t)*2);//(49)

	ch.x=FMX/2;
	ch.y=FMY*3/4;
	ch.used_bom=0;
	ch.damage=0;
	ch.cnt=0;
	ch.shot_mode=0;

	stage_title.appear_cnt=stage_title_count[stage];

	clear_state=0;
	clear_count=0;

	area.bgm.flag=0;//音楽再生フラグを初期化(48)
	area.bgm.knd[0]=0;//通常BGMをどういうタイミングで再生するか、取り決めはmusic.cpp(48)
	area.bgm.knd[1]=0;//ボスBGMをどういうタイミングで再生するか、取り決めはmusic.cpp(48)
	area.bgm.loop_pos[0]=26672;//通常BGMのループ位置(48)
	area.bgm.loop_pos[1]=27010;//ボスBGMのループ位置(48)


	bright_set.brt=255;//初期輝度は最大

	load_story();//ステージデータ読み込み
}
