/* TOMOYO儌乕僪偱偺晹暘揑弶婜壔張棟 #1.60c7l8 */
void tomoyoInitial(int player) {
	int sbak[20];

	// 弶婜壔偝傟偰偼崲傞傕偺傪僶僢僋傾僢僾偵僐僺乕
	sbak[0]  = stage[player];	// 僗僥乕僕
	sbak[1]  = ltime[player];	// 儕儈僢僩僞僀儉
	sbak[2]  = nextc[player];	// NEXT僇僂儞僩
	sbak[3]  = next[player];		// NEXT僽儘僢僋
	sbak[4]  = time[player];		// 僞僀儉
	sbak[5]  = clearnum[player];	// 僋儕傾僗僥乕僕悢
	sbak[6]  = clearp[player];	// 僋儕傾棪
	sbak[7]  = replay_save[player];	// 婰榐壜擻僼儔僌
	sbak[8]  = time2[player];		// TOMOYO儕僾儗僀梡僾儗僀僞僀儉
	sbak[9]  = bgmlv;			// BGM
	sbak[10] = t_training[player];	// 僩儗乕僯儞僌儌乕僪
	sbak[11] = repversw;	//偙傟傪弶婜壔偝傟偰偼儈儔乕偑偢傟傞 c7t3.1
	sbak[12] = tomoyo_opt[player];
	sbak[13] = laststage[player];	//偙傟傪弶婜壔偝傟傞偲EH丄ACE-TGT偺嵟廔僗僥乕僕偑惓偟偔愝掕偝傟側偄 c7T3.2
	sbak[14] = sc[player];		// F-Point偺僗僐傾
	sbak[15] = fpbas_mode[player];  //FP僄儞僪儗僗儌乕僪
	sbak[16] = lv[player];		//FP梡儗儀儖(堦墳慡偰僉乕僾)

	// 弶婜壔
	playerInitial(player);

	// 弶婜壔偝傟偰偼崲傞傕偺傪僶僢僋傾僢僾偐傜栠偡
	stage[player]       = sbak[0];
	ltime[player]       = sbak[1];
	nextc[player]       = sbak[2];
	next[player]        = sbak[3];
	time[player]        = sbak[4];
	clearnum[player]    = sbak[5];
	clearp[player]      = sbak[6];
	replay_save[player] = sbak[7];
	time2[player]       = sbak[8];
	bgmlv               = sbak[9];
	t_training[player]  = sbak[10];
	repversw            = sbak[11];
	tomoyo_opt[player]  = sbak[12];
	laststage[player]   = sbak[13];
	sc[player]          = sbak[14];
	fpbas_mode[player]  = sbak[15];
	
	if((tomoyo_opt[player]==4)&&(fpbas_mode[player])){
		lv[player] = sbak[16];	//FPBASIC偩偗栠偡懠偺儌乕僪偼弶婜壔
	}
	
	backno = 0;
	
	// 弶婜僗僺乕僪抣偲弶婜wait抣撉傒崬傒 #1.60c7m2
	setStartLevel(player);

	// NEXT僽儘僢僋偺怓傪愝掕 #1.60c7n1
	setNextBlockColors(player, 1);
}

//仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱
//  僗僥乕僞僗No.17 - TOMOYO儌乕僪 僗僥乕僕僋儕傾乛僞僀儉僆乕僶乕
//仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯
void statTomoyoNextStage(int player) {
	int i, j, ext, timelimit_tomoyo;	//laststage[player]偼gamestart傊
	int ltime_s[2],Stage_update;
	ext = 0;
	timelimit_tomoyo = 320*60;	//EX7傊偺懌愗傝
	
	statc[player * 10 + 0]++;
	
	StopSE(32);
	pinch[player] = 0;
	isxray[player] = 0;			// #1.60c7p9ex
	iscolor[player] = 0;		// #1.60c7p9ex
	Stage_update = 0;
	
	// EX柺撍擖慜偵BGM傪徚偡 #1.60c7o8
	if( (stage[player] == 19) && (!t_training[player]) ) {
		StopAllBGM();
		fadelv[player] = 0;
		bgmlv = 9;		// EX柺BGM
	}
	if( (stage[player] == 43) && (!t_training[player]) ) {
		StopAllBGM();
		fadelv[player] = 0;
		bgmlv = 19;
	}

	if(stage[player] <= 26){
	Stage_update = Stage_RankingCheck(player, 6);
	}
	
	// STAGE XX
	printFont(16-(1*((stage[player] >= 45) && (stage[player] <= 67) || (stage[player] >= 100)))-(1*((stage[player] >= 36) && (stage[player] <= 44))) + 24 * player - 12 * maxPlay, 6, "STAGE", 4);
	
	// 21柺埲崀偼EX仜偲昞帵 #1.60c7m4
	if( (stage[player] >= 20) && (stage[player] <= 26) ) {
		sprintf(string[0],"EX%d",stage[player] - 19);
	} else if( (stage[player] >= 27) && (stage[player] <= 44) ){
		sprintf(string[0],"EH%d",stage[player] - 26);
	} else if( (stage[player] >= 45) && (stage[player] <= 71) ){
		sprintf(string[0],"TGT%d",stage[player] - 44);
	} else if(stage[player] >= 100){
		sprintf(string[0],"FP%d",stage[player] - 99);
	} else {
		sprintf(string[0],"%d",stage[player] + 1);
	}
	printFont(22-(1*(stage[player] >= 45) && (stage[player] <= 67) || (stage[player] >= 100))-(1*(stage[player] >= 36) && (stage[player] <= 44)) + 24 * player - 12 * maxPlay, 6, string[0], 0);
	
	// CLEAR/TIME OVER
	if(sclear[player]) {
		printFont(17 + 24 * player - 12 * maxPlay, 8, "CLEAR", 0);
		if((stage[player] >= 0) && (stage[player] <= 26)){
		}
	} else if(stime[player] == 0) {
		printFont(16 + 24 * player - 12 * maxPlay, 8, "TIME OVER", 0);
		if((stage[player] >= 0) && (stage[player] <= 26)){
		}
	} else {
		printFont(17 + 24 * player - 12 * maxPlay, 8, "SKIPED", 0);
		if((stage[player] >= 0) && (stage[player] <= 26)){
		recFaultTime(player);//僗僥乕僕NOT儔儞僉儞僌梡僞僀儉
		}
		// 儕僾儗僀婰榐晄壜擻偵側偭偨帠傪昞帵 #1.60c7n8
		printFont(15 + 24 * player - 12 * maxPlay, 13, "THIS PLAY", 2);
		printFont(15 + 24 * player - 12 * maxPlay, 14, "  CAN'T BE", 2);
		printFont(15 + 24 * player - 12 * maxPlay, 15, "     SAVED", 2);
	}
	
	if(sclear[player]) {
		if(statc[player * 10 + 0] == 1){
		for(i = 0; i < 10; i++)	//僼傿乕儖僪徚嫀 C7T3.2
			for(j = 0; j < 22; j++) {
				fld[i + j * 10 + player * 220] = 0;
				fldt[i + j * 10 + player * 220] = 0;
				fldi[i + j * 10 + player * 220] = 0;
			}
		}
		// 壴壩
		if((statc[player * 10 + 0] % 10 == 0) && (tomoyo_hanabi[player] < 10)) {
			PlaySE(35);
			objectCreate2(player, 7, Rand(80) + 72 + 192 * player - 96 * maxPlay, 32 + Rand(20), 0, 0, Rand(7)+1, 0);
			tomoyo_hanabi[player]++;
		}
		if(stage[player] < 100){
			// TIME EXTEND
			printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 13*8, "Time Extend", 3 );
			
			// 儕儈僢僩僞僀儉憹壛検傪寛傔傞
			if(ctime[player] < 10 * 60) {
				ext = 10;
			}else if(ctime[player] < 20 * 60) {
				ext = 5;
			}
			
			sprintf(string[0],"%2d sec",ext);
			printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 14*8 + 1, string[0], 0 );
		}else{
			printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 13*8, "Score Bonus", 3 );
			sprintf(string[0],"%5d pts",FP_bonus[player]);
			printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 14*8 + 1, string[0], 0 );
		}
		// CLEAR TIME
		printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 16*8, "Clear Time", 3 );
		getTime(ctime[player]);
		printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 17*8 + 1, string[0], 0 );
		
		if(Stage_update) {
			printFont(15 + 24 * player - 12 * maxPlay, 22, "STAGE", 2);
			printFont(15 + 24 * player - 12 * maxPlay, 23, "   RECORD", 2);
		}
	}
	if(stage[player] < 100){
		// LIMIT TIME
		if(ext_s[player] < (ext*60)){
			ext_s[player] = ext_s[player]+4;
		}
		if((timeextend_snd_cnt[player] < ext) && ((statc[player * 10 + 0]-1) % 15 == 0)){
			PlaySE(42);
			timeextend_snd_cnt[player]++;
		}
		
		ltime_s[player] = ltime[player]+ext_s[player];
	}else{
		ltime_s[player] = ltime[player];
	}
	if(!fpbas_mode[player]){
		printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 10*8, "Limit Time", 3 );
		getTime(ltime_s[player]);
		printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 11*8 + 1, string[0], ((count % 4 / 2) * digitc[rots[player]])*(ext != 0) );
	}
	if(!hide_tomoyo_totaltime) {
		printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 19*8, "Total Time", 3);
		getTime(time[player]);
		printSMALLFont( (15 + 24 * player - 12 * maxPlay)*8 + 8, 20*8 + 1, string[0], 0);
	}

	// 僋儕傾棪寁嶼
	if(!t_training[player]) clearp[player] = ((clearnum[player]*100) / (stage[player] + 1 - 27 *(start_stage[player] >= 27) ));
	
	// 儃僞儞傪墴偡偲憗偔師偺僗僥乕僕傊
	if( getPushState(player, 4) ) {
		statc[player * 10 + 0] = 300;
	}
	
	// 師偺僗僥乕僕
	if(statc[player * 10 + 0] >= 300) {
		if(start_stage[player] >= 27) {
			// 帺嶌柺 #1.60c7r6
			if((start_stage[player] >= 27) && (start_stage[player] < 45))
				laststage[player] = 44;	// H-Heart
			else if((start_stage[player] >= 45) && (start_stage[player] < 72))
				laststage[player] = 71;	// ACE-Target
			else if((start_stage[player] >= 69) && (start_stage[player] < 100))
				laststage[player] = 99;	// Edit stage
			else
				laststage[player] = 199;// F-Point
		} else if(t_noborder[player]) {
			// 懌愗傝側偟儌乕僪偺応崌偼忢偵儔僗僩僗僥乕僕傪EX7偵偡傞 #1.60c7m5
			laststage[player] = 26;
		} else {
			/* 僋儕傾棪偱儔僗僩僗僥乕僕傪寛掕偡傞 */
			if(clearp[player] < 90) {
				// 90%埲壓偼EX側偟乮儔僗僩僗僥乕僕偼20乯
				laststage[player] = 19;
			} else if(clearp[player] < 100) {
				// 90乣99%偼EX3傑偱
				laststage[player] = 22;
			} else if((clearp[player] == 100)&(stage[player]==19)){
				// 100%偺応崌偼僗僥乕僕20傑偱偺僞僀儉偱寛傔傞
				if (time[player] < timelimit_tomoyo) {
					// 5暘埲撪側傜嵟屻傑偱
					laststage[player] = 26;
					//EX7峴偒偑寛傑傟偽棳傟惎
					objectCreate2(player, 8, Rand(20) + 180 + 192 * player - 96 * maxPlay, 20 + Rand(10), 0, 0, 0, 0);
					PlaySE(43);
				}else {
					// 5暘挻偊偰偄傞応崌偼EX5
					laststage[player] = 24;
				}
			}
		}
		// 儕儈僢僩僞僀儉憹壛
		ltime[player] = ltime[player] + (ext * 60);
		
		if(stage[player] >= 100)
			sc[player] = sc[player] + FP_bonus[player];

		if( stage[player] == 19 ) ltime[player] = ltime[player] + (60 * 60);	// 20柺僋儕傾偱1暘憹壛 #1.60c7l9
		
		if( !t_training[player] ) {
			stage[player]++;	// 僩儗乕僯儞僌偱側偄側傜師偺僗僥乕僕傊
		}
		// 僩儗乕僯儞僌B偱偼NEXTC傪奐巒帪偵栠偡 #1.60c7o8
		if( t_training[player] == 2 ) {
			nextc[player] = stage_nextc[player];
			next[player] = nextb[nextc[player] + player * 1400];
		}
		// 弶婜壔
		tomoyoInitial(player);
		if((fpbas_mode[player]) || (repversw < 58)){
			if(lv[player] >= 7)lv[player] = 6;
			else if(lv[player] > 0)lv[player]--;
			sp[player] = lvTabletomoyohebo[lv[player]];
		}
		stat[player] = 3;					// Ready
		statc[player * 10] = 0;				// 僗僥乕僞僗僇僂儞僞傪0偵
		statc[player * 10 + 1] = 0;			// 
		if((stage[player] >= 100) && (!t_training[player])){
			stat[player] = 36;				// F-Point僙儗僋僩
			statc[player * 10] = 1;
			statc[player * 10 + 1] = 0;
			statc[player * 10 + 2] = 0;
			statc[player * 10 + 3] = 0;
		}
		
		if( (stage[player] > laststage[player]) && (!t_training[player])) {
			// 儔僗僩僗僥乕僕僋儕傾偱僄儞僨傿儞僌
			// 偨偩偟僩儗乕僯儞僌偱偼柍偟 #1.60c7o7
			PlayWave(28);
			stage[player] = laststage[player];
			ending[player] = 1;
			stat[player] = 13;
			if(laststage[player] == 199)
				sc[player] = sc[player] + 100000;
			end_f[player] = 1 + (stage[player] >= 26);
		} else {
			stage_nextc[player] = nextc[player];	// 僗僥乕僕僗僞乕僩帪偺NEXTC傪婰壇 #1.60c7l9
		}
	}
}

// 僗僥乕僕僋儕傾敾掕 #1.60c7l8
void tomoyoCheckStageClear(int player) {
	if(gameMode[player] == 6) {
		// 巆傝僾儔僠僫僽儘僢僋悢傪悢偊傞
		rest_pblock[player] = getPlatinumBlock(player);
		
		// 僾儔僠僫僽儘僢僋偑0屄側傜僋儕傾僼儔僌ON
		if( (!rest_pblock[player]) && (!sclear[player]) ) {
			sclear[player] = 1;
		}
	}
}

// 僼傿乕儖僪撪偵巆偭偰偄傞僾儔僠僫僽儘僢僋偺悢傪悢偊傞
int getPlatinumBlock(int player) {
	int i, j, result;
	result = 0;
	
	for(i = 0; i < 10; i++)
		for(j = 0; j < 22; j++) {
			if(fld[i + j * 10 + player * 220] >= 11) {
				result++;
			}
		}
	if(tomoyo_rise[player]){	//偣傝偁偑傝偑ON側傜丄傑偩偣傝忋偑偭偰偄側偄晹暘傕僇僂儞僩
		for(i = 0; i < 10; i++)
			for(j = upLineNo[player]; j <= 20; j++) {
				if(tomoyo_rise_fld[i + j * 10 + player * 200] >= 11)
					result++;
			}
	}
	return result;
}

//仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱
//  僗僥乕僞僗No.18 - TOMOYO儌乕僪 僗僥乕僕僄僨傿僞
//仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯
// statc[player * 10]     : 僇乕僜儖埵抲
// statc[player * 10 + 1] : 儊僯儏乕乛僼傿乕儖僪
// statc[player * 10 + 2] : 栠傝愭僗僥乕僞僗
// statc[player * 10 + 3] : 僼傿乕儖僪夋柺偵擖偭偨弖娫僽儘僢僋傪抲偄偰偟傑偆偺傪杊偖僼儔僌
void statTomoyoEditor(int player) {
	int tmp, bx1, by1;
	
	padRepeat(player);
	padRepeat2(player);
	
	/* 仭儊僯儏乕夋柺仭 */
	if( statc[player * 10 + 1] == 0 ) {
		printFont(15 + 24 * player - 12 * maxPlay, 8 + statc[player * 10] +(1*(statc[player * 10] >= 13)) , "b", 1);
		
		sprintf(string[0],"STAGE:%2d",stage[player] + 1);
		printFont(16 + 24 * player - 12 * maxPlay, 8, string[0],  (statc[player * 10] == 0) );
		
		printFont(16 + 24 * player - 12 * maxPlay, 9, "FIELD",    (statc[player * 10] == 1) );
		
		printFont(16 + 24 * player - 12 * maxPlay,10, "MIRROR",   (statc[player * 10] == 2) + (isfmirror[player] * 2) );
		printFont(16 + 24 * player - 12 * maxPlay,11, "ROLL ROLL",(statc[player * 10] == 3) + (rollroll_flag[player] * 2) );
		printFont(16 + 24 * player - 12 * maxPlay,12, "X-RAY",    (statc[player * 10] == 4) + (xray_flag[player] * 2) );
		printFont(16 + 24 * player - 12 * maxPlay,13, "COLOR",    (statc[player * 10] == 5) + (color_flag[player] * 2) );
		printFont(16 + 24 * player - 12 * maxPlay,14, "BIG",      (statc[player * 10] == 6) + (IsBig[player] * 2) );
		printFont(16 + 24 * player - 12 * maxPlay,15, "BLIND",    (statc[player * 10] == 7) + (blind_flag[player] * 2) );
		sprintf(string[0],"SPEED:%4d",min_speed[player]);
		printFont(16 + 24 * player - 12 * maxPlay,16, string[0],   (statc[player * 10] == 8) );
		printFont(16 + 24 * player - 12 * maxPlay,17, "THUNDER",   (statc[player * 10] == 9) + (isthunder[player] * 2) );
		printFont(16 + 24 * player - 12 * maxPlay,18, "HIDE NEXT", (statc[player * 10] == 10) + (hnext_flag[player] * 2) );
		printFont(16 + 24 * player - 12 * maxPlay,19, "BOOST FIRE",(statc[player * 10] == 11) + (tomoyo_waits[player] * 2) );

		if(!tomoyo_rise[player])
			printFont(16 + 24 * player - 12 * maxPlay,20, "RISE:OFF",   (statc[player * 10] == 12));
		else{
			printFont(16 + 24 * player - 12 * maxPlay,20, "RISE:ON",   (statc[player * 10] == 12));
			sprintf(string[0],"INTER:%3d",tomoyo_rise[player]);
			printFont(16 + 24 * player - 12 * maxPlay,21, string[0],   (statc[player * 10] == 12) + 4);
		}
		printFont(16 + 24 * player - 12 * maxPlay,22, " [LOAD]",     (statc[player * 10] == 13) );
		printFont(16 + 24 * player - 12 * maxPlay,23, " [SAVE]",     (statc[player * 10] == 14) );
		
		// 仾
		if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
		if( getPressState(player, 0) ) {
			PlayWave(5);
			statc[player * 10]--;
			if(statc[player * 10] < 0) statc[player * 10] = 14;
		}
		
		// 伀
		if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
		if( getPressState(player, 1) ) {
			PlayWave(5);
			statc[player * 10]++;
			if(statc[player * 10] > 14) statc[player * 10] = 0;
		}
		
		// 仼
		if((mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) || (getPressState(player, 6)))
		if(getPressState(player, 2)) {
			PlayWave(3);
			
			// STAGE
			if(statc[player * 10] == 0) {
				stage[player]--;
				if(stage[player] < 0) stage[player] = 199;
			}
			// MIRROR
			if(statc[player * 10] == 2) {
				isfmirror[player] = !isfmirror[player];
			}
			// ROLL ROLL
			if(statc[player * 10] == 3) {
				rollroll_flag[player] = !rollroll_flag[player];
			}
			// X-RAY #1.60c7p9ex
			if(statc[player * 10] == 4) {
				xray_flag[player] = !xray_flag[player];
			}
			// COLOR #1.60c7p9ex
			if(statc[player * 10] == 5) {
				color_flag[player] = !color_flag[player];
			}
			// BIG #1.60c7l8
			if(statc[player * 10] == 6) {
				IsBig[player] = !IsBig[player];
			}
			// BLIND
			if(statc[player * 10] == 7) {
				blind_flag[player] = !blind_flag[player];
			}
			// 嵟掅懍搙
			if(statc[player * 10] == 8) {
				min_speed[player]--;
				if(min_speed[player] < 0) min_speed[player] = 1200;
			}
			if(statc[player * 10] == 9) {
				isthunder[player] = !isthunder[player];
			}
			if(statc[player * 10] == 10) {
				hnext_flag[player] = !hnext_flag[player];
			}
			if(statc[player * 10] == 11) {
				tomoyo_waits[player] = !tomoyo_waits[player];
			}
			if(statc[player * 10] == 12) {
				tomoyo_rise[player]--;
				if(tomoyo_rise[player] < 0) tomoyo_rise[player] = 99;
			}
		}
		
		// 仺
		if((mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) || (getPressState(player, 6)))
		if(getPressState(player, 3)) {
			PlayWave(3);
			
			// STAGE
			if(statc[player * 10] == 0) {
				stage[player]++;
				if(stage[player] > 199) stage[player] = 0;
			}
			// MIRROR
			if(statc[player * 10] == 2) {
				isfmirror[player] = !isfmirror[player];
			}
			// ROLL ROLL
			if(statc[player * 10] == 3) {
				rollroll_flag[player] = !rollroll_flag[player];
			}
			// X-RAY #1.60c7p9ex
			if(statc[player * 10] == 4) {
				xray_flag[player] = !xray_flag[player];
			}
			// COLOR #1.60c7p9ex
			if(statc[player * 10] == 5) {
				color_flag[player] = !color_flag[player];
			}
			// BIG #1.60c7l8
			if(statc[player * 10] == 6) {
				IsBig[player] = !IsBig[player];
			}
			if(statc[player * 10] == 7) {
				blind_flag[player] = !blind_flag[player];
			}
			if(statc[player * 10] == 8) {
				min_speed[player]++;
				if(min_speed[player] > 1200) min_speed[player] = 0;
			}
			if(statc[player * 10] == 9) {
				isthunder[player] = !isthunder[player];
			}
			if(statc[player * 10] == 10) {
				hnext_flag[player] = !hnext_flag[player];
			}
			if(statc[player * 10] == 11) {
				tomoyo_waits[player] = !tomoyo_waits[player];
			}
			if(statc[player * 10] == 12) {
				tomoyo_rise[player]++;
				if(tomoyo_rise[player] > 99) tomoyo_rise[player] = 0;
			}
		}
		
		// A儃僞儞
		if( getPushState(player, 4) ) {
			PlayWave(10);
			
			// STAGE
			if(statc[player * 10] == 0) {
				loadTomoyoStage(player, stage[player]);
			}
			// FIELD
			if(statc[player * 10] == 1) {
				bx[player] = 0;					// X嵗昗
				by[player] = 1;					// Y嵗昗
				blk[player] = 0;				// 攝抲偡傞僽儘僢僋
				statc[player * 10 + 1] = 1;		// 僗僥乕僞僗僇僂儞僞傪1偵偟偰僼傿乕儖僪夋柺傊
				statc[player * 10 + 3] = 1;		// 偦偺傑傑偩偲夋柺偑愗傝懼傢偭偨弖娫丄僽儘僢僋傪攝抲偟偰偟傑偆偺偱
												// 偦傟傪夞旔偡傞偨傔偺僼儔僌
			}
			// RISE
			if(statc[player * 10] == 12) {
				bx[player] = 0;					// X嵗昗
				by[player] = 1;					// Y嵗昗
				blk[player] = 0;				// 攝抲偡傞僽儘僢僋
				statc[player * 10 + 1] = 2;		// 僗僥乕僞僗僇僂儞僞傪2偵偟偰偣傝忋偑傝僼傿乕儖僪夋柺傊
				statc[player * 10 + 3] = 1;		// 偦偺傑傑偩偲夋柺偑愗傝懼傢偭偨弖娫丄僽儘僢僋傪攝抲偟偰偟傑偆偺偱
												// 偦傟傪夞旔偡傞偨傔偺僼儔僌
			}
			// MIRROR
			if(statc[player * 10] == 2) {
				isfmirror[player] = !isfmirror[player];
			}
			// ROLL ROLL
			if(statc[player * 10] == 3) {
				rollroll_flag[player] = !rollroll_flag[player];
			}
			// X-RAY #1.60c7p9ex
			if(statc[player * 10] == 4) {
				xray_flag[player] = !xray_flag[player];
			}
			// COLOR #1.60c7p9ex
			if(statc[player * 10] == 5) {
				color_flag[player] = !color_flag[player];
			}
			// BIG #1.60c7l8
			if(statc[player * 10] == 6) {
				IsBig[player] = !IsBig[player];
			}
			if(statc[player * 10] == 7) {
				blind_flag[player] = !blind_flag[player];
			}
			if(statc[player * 10] == 9) {
				isthunder[player] = !isthunder[player];
			}
			if(statc[player * 10] == 10) {
				hnext_flag[player] = !hnext_flag[player];
			}
			if(statc[player * 10] == 11) {
				tomoyo_waits[player] = !tomoyo_waits[player];
			}
			// LOAD
			if(statc[player * 10] == 13) {
				loadTomoyoStage(player, stage[player]);
			}
			// SAVE
			if(statc[player * 10] == 14) {
				saveTomoyoStage(player, stage[player]);
			}
		}
		
		// B儃僞儞
		if( getPushState(player, 5) ) {
			stat[player] = statc[player * 10 + 2];	// 栠傝愭傊
			statc[player * 10] = 0;					// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 1] = 0;				// 
			statc[player * 10 + 2] = 0;
		}
	
	/* 仭僼傿乕儖僪夋柺仭 */
	} else if( statc[player * 10 + 1] == 1 ){		// FIELD
		// 僇乕僜儖昞帵
		bx1 = (bx[player] + 15 + 24 * player - 12 * maxPlay) * 8;
		by1 = (by[player] + 3) * 8;
		
		ExBltFastRect(3,  bx1 - 1, by1 - 1, 0, 34, 10, 10);
		ExBltFastRect(getBlockPlaneNo(player, blk[player]), bx1, by1, blk[player] * 8 - (blk[player] >= 10) * 80, 0, 8, 8);
		
		// 仾
		if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
		if( getPressState(player, 0) ) {
			PlayWave(5);
			by[player]--;
			if(by[player] < 1) by[player] = fldsizeh[player];
		}
		
		// 伀
		if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
		if( getPressState(player, 1) ) {
			PlayWave(5);
			by[player]++;
			if(by[player] > fldsizeh[player]) by[player] = 1;
		}
		
		// 仼
		if( (mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) )
		if( getPressState(player, 2) ) {
			PlayWave(5);
			
			// 僽儘僢僋慖戰
			if( getPressState(player, 6) ) {
				blk[player]--;
				if(blk[player] < 0) blk[player] = 16;
			}
			// 僇乕僜儖堏摦
			else {
				bx[player]--;
				if(bx[player] < 0) bx[player] = fldsizew[player] - 1;
			}
		}
		
		// 仺
		if( (mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) )
		if( getPressState(player, 3) ) {
			PlayWave(5);
			
			// 僽儘僢僋慖戰
			if( getPressState(player, 6) ) {
				blk[player]++;
				if(blk[player] > 16) blk[player] = 0;
			}
			// 僇乕僜儖堏摦
			else {
				bx[player]++;
				if(bx[player] > fldsizew[player] - 1) bx[player] = 0;
			}
		}
		
		// A儃僞儞偱攝抲
		if( getPressState(player, 4) && !statc[player * 10 + 3] ) {
			if(fld[bx[player] + by[player] * fldsizew[player] + player * 220] != blk[player] + 1) {
				PlayWave(3);
			}
			fld[bx[player] + by[player] * fldsizew[player] + player * 220] = blk[player] + 1;
			fldt[bx[player] + by[player] * fldsizew[player] + player * 220] = -1;
		}
		if( !getPressState(player, 4) ) {
			statc[player * 10 + 3] = 0;
		}
		
		// HOLD儃僞儞偱僽儘僢僋徚嫀
		if( getPressState(player, 7) ) {
			if(fld[bx[player] + by[player] * fldsizew[player] + player * 220] != 0) {
				PlayWave(3);
			}
			fld[bx[player] + by[player] * fldsizew[player] + player * 220] = 0;
			fldt[bx[player] + by[player] * fldsizew[player] + player * 220] = 0;
		}
		
		// B儃僞儞偱栠傞
		if( getPushState(player, 5) ) {
			statc[player * 10 + 1] = 0;			// 僗僥乕僞僗僇僂儞僞傪0偵偟偰儊僯儏乕偵栠傞
			statc[player * 10 + 3] = 0;
		}
	} else if( statc[player * 10 + 1] == 2 ){		// RISE
		// 僇乕僜儖昞帵
		bx1 = (bx[player] + 15 + 24 * player - 12 * maxPlay) * 8;
		by1 = (by[player] + 4) * 8;
		
		ExBltFastRect(3,  bx1 - 1, by1 - 1, 0, 34, 10, 10);
		ExBltFastRect(getBlockPlaneNo(player, blk[player]), bx1, by1, blk[player] * 8 - (blk[player] >= 10) * 80, 0, 8, 8);
		
		// 仾
		if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
		if( getPressState(player, 0) ) {
			PlayWave(5);
			by[player]--;
			if(by[player] < 1) by[player] = fldsizeh[player];
		}
		
		// 伀
		if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
		if( getPressState(player, 1) ) {
			PlayWave(5);
			by[player]++;
			if(by[player] > fldsizeh[player]) by[player] = 1;
		}
		
		// 仼
		if( (mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) )
		if( getPressState(player, 2) ) {
			PlayWave(5);
			
			// 僽儘僢僋慖戰
			if( getPressState(player, 6) ) {
				blk[player]--;
				if(blk[player] < 0) blk[player] = 16;
			}
			// 僇乕僜儖堏摦
			else {
				bx[player]--;
				if(bx[player] < 0) bx[player] = fldsizew[player] - 1;
			}
		}
		
		// 仺
		if( (mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) )
		if( getPressState(player, 3) ) {
			PlayWave(5);
			
			// 僽儘僢僋慖戰
			if( getPressState(player, 6) ) {
				blk[player]++;
				if(blk[player] > 16) blk[player] = 0;
			}
			// 僇乕僜儖堏摦
			else {
				bx[player]++;
				if(bx[player] > fldsizew[player] - 1) bx[player] = 0;
			}
		}
		
		// A儃僞儞偱攝抲
		if( getPressState(player, 4) && !statc[player * 10 + 3] ) {
			if(tomoyo_rise_fld[bx[player] + (by[player]-1) * fldsizew[player] + player * 200] != blk[player] + 1) {
				PlayWave(3);
			}
			tomoyo_rise_fld[bx[player] + (by[player]-1) * fldsizew[player] + player * 200] = blk[player] + 1;
//			fldt[bx[player] + by[player] * fldsizew[player] + player * 210] = -1;
		}
		if( !getPressState(player, 4) ) {
			statc[player * 10 + 3] = 0;
		}
		
		// HOLD儃僞儞偱僽儘僢僋徚嫀
		if( getPressState(player, 7) ) {
			if(tomoyo_rise_fld[bx[player] + (by[player]-1) * fldsizew[player] + player * 200] != 0) {
				PlayWave(3);
			}
			tomoyo_rise_fld[bx[player] + (by[player]-1) * fldsizew[player] + player * 200] = 0;
//			fldt[bx[player] + by[player] * fldsizew[player] + player * 210] = 0;
		}
		
		// B儃僞儞偱栠傞
		if( getPushState(player, 5) ) {
			statc[player * 10 + 1] = 0;			// 僗僥乕僞僗僇僂儞僞傪0偵偟偰儊僯儏乕偵栠傞
			statc[player * 10 + 3] = 0;
		}
	}
}

//仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱
//  僗僥乕僞僗No.19 - TOMOYO儌乕僪 僙儗僋僩夋柺
//仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯
// statc[player * 10]     : 僇乕僜儖埵抲
// statc[player * 10 + 1] : 僾儗僀乛僩儗乕僯儞僌A乛僩儗乕僯儞僌B乛僄僨傿僢僩
void statTomoyoSelect(int player) {
	int i;
	
	padRepeat(player);
	padRepeat2(player);
	
	printFont(15 + 24 * player - 12 * maxPlay, 6, "SELECT", 4);
	
	// 僗僥乕僕斣崋
	printFont(15 + 24 * player - 12 * maxPlay, 8, "STAGE", 3);
	
	// 21柺埲崀偼EX仜偲昞帵 #1.60c7m4
	if( (start_stage[player] >= 20) && (start_stage[player] <= 26) ) {
		sprintf(string[0],"EX%d",start_stage[player] - 19);
	} else if( (start_stage[player] >= 27) && (start_stage[player] <= 44) ){
		sprintf(string[0],"E-HEART%d",start_stage[player] - 26);
	} else if( (start_stage[player] >= 45) && (start_stage[player] <= 71) ){
		sprintf(string[0],"ACE-TGT%d",start_stage[player] - 44);
	} else if( start_stage[player] >= 100 ){
		sprintf(string[0],"F-POINT %d",start_stage[player] - 99);
	} else {
		sprintf(string[0],"%2d",start_stage[player] + 1);
	}
	
	printFont(15 + 24 * player - 12 * maxPlay, 9, string[0],  (statc[player * 10] == 0) * count % 9 );
	
	// NEXTC #1.60c7l7
	printFont(15 + 24 * player - 12 * maxPlay, 11, "NEXTC", 3);
	sprintf(string[0],"%d",start_nextc[player]);
	printFont(15 + 24 * player - 12 * maxPlay, 12, string[0],  (statc[player * 10] == 1) * count % 9 );

	// 僎乕儉儌乕僪
	printFont(15 + 24 * player - 12 * maxPlay, 14, "MODE", 3);
	if(statc[player * 10 + 1] == 0)
		printFont(15 + 24 * player - 12 * maxPlay, 15, "PLAY", (statc[player * 10] == 2) * count % 9);
	if(statc[player * 10 + 1] == 1)
		printFont(15 + 24 * player - 12 * maxPlay, 15, "TRAINING-A", (statc[player * 10] == 2) * count % 9);
	if(statc[player * 10 + 1] == 2)
		printFont(15 + 24 * player - 12 * maxPlay, 15, "TRAINING-B", (statc[player * 10] == 2) * count % 9);
	if(statc[player * 10 + 1] == 3)
		printFont(15 + 24 * player - 12 * maxPlay, 15, "EDIT", (statc[player * 10] == 2) * count % 9);

	// 儔儞僟儉儌乕僪 #1.60c7l9
	// DUAL懳墳 #1.60c7m1
	printFont(15 + 24 * player - 12 * maxPlay, 17, "RANDOM", 3);
	if(randommode[player])
		printFont(15 + 24 * player - 12 * maxPlay, 18, "ON", (statc[player * 10] == 3) * count % 9);
	else
		printFont(15 + 24 * player - 12 * maxPlay, 18, "OFF", (statc[player * 10] == 3) * count % 9);
	
	// 懌愗傝ON/OFF #1.60c7m5
	printFont(15 + 24 * player - 12 * maxPlay, 20, "BORDER", 3);
	if(t_noborder[player])
		printFont(15 + 24 * player - 12 * maxPlay, 21, "OFF", (statc[player * 10] == 4) * count % 9);
	else
		printFont(15 + 24 * player - 12 * maxPlay, 21, "ON", (statc[player * 10] == 4) * count % 9);
	
	// 仾
	if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
	if( getPressState(player, 0) ) {
		PlayWave(5);
		statc[player * 10]--;
		if(statc[player * 10] < 0) statc[player * 10] = 4;
	}
	
	// 伀
	if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
	if( getPressState(player, 1) ) {
		PlayWave(5);
		statc[player * 10]++;
		if(statc[player * 10] > 4) statc[player * 10] = 0;
	}
	
	// 仼
	if((mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) || (getPressState(player, 6)))
	if( getPressState(player, 2) ) {
		PlayWave(3);
		
		// 夞揮朄懃
		/*
		if(statc[player * 10] == 0) {
			rots[player]--;
			if(rots[player] < 0) rots[player] = 3;
		}
		*/
		// 僗僥乕僕斣崋
		if(statc[player * 10] == 0) {
			start_stage[player]--;
			if(start_stage[player] < 0) start_stage[player] = 199;
			// 僗僥乕僕僨乕僞撉傒崬傒 #1.60c7l9
			loadTomoyoStage(player, start_stage[player]);
		}
		// NEXTC #1.60c7l7
		if(statc[player * 10] == 1) {
			start_nextc[player]--;
			if(start_nextc[player] < 0) start_nextc[player] = 1399;
		}
		// 儌乕僪
		if(statc[player * 10] == 2) {
			statc[player * 10 + 1]--;
			if(statc[player * 10 + 1] < 0) statc[player * 10 + 1] = 3;
		}
		// 儔儞僟儉儌乕僪 #1.60c7l9
		if(statc[player * 10] == 3) {
			randommode[player] = !randommode[player];
			versusInit(player);
		}
		// 懌愗傝ON/OFF #1.60c7m5
		if(statc[player * 10] == 4) {
			t_noborder[player] = !t_noborder[player];
		}
	}
	
	// 仺
	if((mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) || (getPressState(player, 6)))
	if( getPressState(player, 3) ) {
		PlayWave(3);
		
		// 夞揮朄懃
		/*
		if(statc[player * 10] == 0) {
			rots[player]++;
			if(rots[player] > 3) rots[player] = 0;
		}
		*/
		// 僗僥乕僕斣崋
		if(statc[player * 10] == 0) {
			start_stage[player]++;
			if(start_stage[player] > 199) start_stage[player] = 0;
			// 僗僥乕僕僨乕僞撉傒崬傒 #1.60c7l9
			loadTomoyoStage(player, start_stage[player]);
		}
		// NEXTC #1.60c7l7
		if(statc[player * 10] == 1) {
			start_nextc[player]++;
			if(start_nextc[player] > 1399) start_nextc[player] = 0;
		}
		// 儌乕僪
		if(statc[player * 10] == 2) {
			statc[player * 10 + 1]++;
			if(statc[player * 10 + 1] > 3) statc[player * 10 + 1] = 0;
		}
		// 儔儞僟儉儌乕僪 #1.60c7l9
		if(statc[player * 10] == 3) {
			randommode[player] = !randommode[player];
			versusInit(player);
		}
		// 懌愗傝ON/OFF #1.60c7m5
		if(statc[player * 10] == 4) {
			t_noborder[player] = !t_noborder[player];
		}
	}
	
	// B儃僞儞
	if( getPushState(player, 5) ) {
		for(i=0;i<220;i++) {
			// 僼傿乕儖僪慡徚嫀 #1.60c7m2
			fld[i + 220 * player] = 0;
			fldt[i + 220 * player] = 0;
		}
		stat[player] = 2;					// SOLO MODE儌乕僪僙儗僋僩
		statc[player * 10] = 0;				// 僗僥乕僞僗僇僂儞僞傪0偵
		statc[player * 10 + 1] = 0;			// 
	}
	
	// HOLD儃僞儞偱nextc傪0偵栠偡
	if( getPushState(player, 7) ) {
		PlayWave(3);
		start_nextc[player] = 0;
	}
	
	// A儃僞儞
	if( getPushState(player, 4) ) {
		PlayWave(10);
		stage[player] = start_stage[player];
		if((start_stage[player] >= 27) && (start_stage[player] <= 44) )
			ltime[player] = 600 * 60;
		else if(start_stage[player] < 100)
			ltime[player] = 180 * 60;
		else
			ltime[player] = 1080 * 60;
		stage_nextc[player] = start_nextc[player];	// 僗僥乕僕僗僞乕僩帪偺NEXTC #1.60c7l9
		
		bgmlv = setstartBGM(gameMode[player], player);		// BGM愝掕 #1.60c7o8
		
		if( statc[player * 10 + 1] == 3 ) {
			// 僄僨傿僢僩
			stat[player] = 18;					// 僗僥乕僕僄僨傿僞
			statc[player * 10] = 1;				// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 1] = 0;			// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 2] = 19;		// 栠傝愭愝掕
		} else if( statc[player * 10 + 1] == 2 ) {
			// 僩儗乕僯儞僌B
			t_training[player] = 2;				// 僩儗乕僯儞僌ON
			stat[player] = 1;					// 僽儘僢僋僔儍僢僞乕
			statc[player * 10] = 0;				// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 1] = 3;			// Ready
		} else if( statc[player * 10 + 1] == 1 ) {
			// 僩儗乕僯儞僌A
			t_training[player] = 1;				// 僩儗乕僯儞僌ON
			stat[player] = 1;					// 僽儘僢僋僔儍僢僞乕
			statc[player * 10] = 0;				// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 1] = 3;			// Ready
		} else {
			// 僾儗僀
			t_training[player] = 0;				// 僩儗乕僯儞僌OFF
			stat[player] = 1;					// 僽儘僢僋僔儍僢僞乕
			statc[player * 10] = 0;				// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 1] = 3;			// Ready
		}
	}
	// NEXT傪傑偲傔偰僙僢僩 #1.60c7l9
	nextc[player] = start_nextc[player];
	next[player] = nextb[nextc[player] + player * 1400];
	setNextBlockColors(player, 1);		// NEXT僽儘僢僋偺怓傪愝掕 #1.60c7m9
}

//仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱
//  僗僥乕僞僗No.20 - TOMOYO儌乕僪 寢壥昞帵
//仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯
// statc[player * 10]     : 僐儞僥傿僯儏乕偡傞偐
// statc[player * 10 + 1] : 僐儞僥傿僯儏乕巆傝帪娫
// statc[player * 10 + 2] : 2恖摨帪偱僾儗僀偟偰偄傞偐
// statc[player * 10 + 3] : 儕僾儗僀僙乕僽昞帵
void statTomoyoResult(int player) {
	int tmp;
	
	statc[player * 10 + 1]++;
	
	// 壒妝傪棳偡
	// 2恖摨帪偱廳側傜側偄傛偆偵廋惓 #1.60c7m1
	if( (stat[1 - player] == 0) && (!IsPlayWave(63)) && (wavebgm >= 1) ) PlayWave(63);
	
	// 寈崘壒偑柭偭偰偄偨傜巭傔傞
	StopSE(40);
	
	// 儕僾儗僀曐懚
	if((textguide) && (!playback) && (!demo)){
		if(!player) printFont(13+24 * player - 12 * maxPlay, 26, "0-9 KEY:REPLAY", 0);
		else printFont(13+24 * player - 12 * maxPlay, 26, "Q-P KEY:REPLAY", 0);
	}
	
	// 儕僾儗僀僙乕僽 #1.60c7n8
	ReplaySaveCheck(player, 3);
	if(statc[player * 10 + 3]) {
		sprintf(string[0], "SAVED : %02d", statc[player * 10 + 3]);
		printFont(15 + 24 * player - 12 * maxPlay, 24, string[0], 5);
	}
	
	printFont(15 + 24 * player - 12 * maxPlay, 6, "PLAY DATA", 4);
	
	// STAGE
	ExBltRect(3, 120 + 192 * player - 96 * maxPlay, 64, 228, 112, 26, 7);
		
	if((stage[player] >= 26) && (ending[player])) {
		// ALL僋儕傾
		printSMALLFont(182 + 192 * player - 96 * maxPlay, 64, "ALL", 0);
	} else if ((stage[player] > 19) && (stage[player] <= 26)) {
		// EX
		printSMALLFont(182 + 192 * player - 96 * maxPlay, 64, "EX", 0);
		sprintf(string[0], "%d", stage[player] - 19);
		printSMALLFont(194 + 192 * player - 96 * maxPlay, 64, string[0], 0);
	} else if ((stage[player] > 26) && (stage[player] <= 44)) {
		// E-Heart
		printSMALLFont(182-(6*(stage[player] - 26 >= 10)) + 192 * player - 96 * maxPlay, 64, "EH", 0);
		sprintf(string[0], "%d", stage[player] - 26);
		printSMALLFont(194-(6*(stage[player] - 26 >= 10)) + 192 * player - 96 * maxPlay, 64, string[0], 0);
	} else if ((stage[player] > 44) && (stage[player] <= 71)) {
		// ACE-Target
		printSMALLFont(176-(6*(stage[player] - 44 >= 10)) + 192 * player - 96 * maxPlay, 64, "TGT", 0);
		sprintf(string[0], "%d", stage[player] - 44);
		printSMALLFont(194-(6*(stage[player] - 44 >= 10)) + 192 * player - 96 * maxPlay, 64, string[0], 0);
	} else if (stage[player] >= 100) {
		// F-Point
		printSMALLFont(182-(6*(stage[player] - 99 >= 10))-(6*(stage[player] - 99 >= 100)) + 192 * player - 96 * maxPlay, 64, "FP", 0);
		sprintf(string[0], "%d", stage[player] - 99);
		printSMALLFont(194-(6*(stage[player] - 99 >= 10))-(6*(stage[player] - 99 >= 100)) + 192 * player - 96 * maxPlay, 64, string[0], 0);
	} else {
		// 捠忢
		sprintf(string[0], "%2d", stage[player] + 1);
		printSMALLFont(188 + 192 * player - 96 * maxPlay, 64, string[0], 0);
	}
	
	// TIME
	ExBltRect(3, 120 + 192 * player - 96 * maxPlay, 75, 180, 119, 19, 7);
	getTime(time[player]);
	printSMALLFont(152 + 192 * player - 96 * maxPlay, 75, string[0], 0);
	
	// CLEAR #1.60c7m5
	if((!t_training[player]) && (tomoyo_opt[player] == 0) && (stage[player] <= 26)) {
		ExBltRect(3, 120 + 192 * player - 96 * maxPlay, 86, 254, 112, 26, 7);
		sprintf(string[0], "%3d>", clearp[player] );
		printSMALLFont(176 + 192 * player - 96 * maxPlay, 86, string[0], 0);
	}
	// SCORE(F-Point)
	if(stage[player] >= 100){
		ExBltRect(3, 120 + 192 * player - 96 * maxPlay, 86, 154, 112, 26, 7);
		sprintf(string[0], "%7d", sc[player]);
		printSMALLFont(158 + 192 * player - 96 * maxPlay, 86, string[0], 0);
	}
	// 僐儞僥傿僯儏乕慖戰
	if( (!playback) && (!ending[player]) ) {
		printSMALLFont(120 + 192 * player - 96 * maxPlay, 144, "CONTINUE", (statc[player * 10] == 0) * fontc[rots[player]]);
		printSMALLFont(120 + 192 * player - 96 * maxPlay, 154, "END", (statc[player * 10] == 1) * fontc[rots[player]]);
		
		sprintf(string[0], "%2d", 10 - (statc[player * 10 + 1] / 60));
		printFont(17 + 24 * player - 12 * maxPlay, 22, "TIME", 6);
		printFont(21 + 24 * player - 12 * maxPlay, 22, string[0], 0);
	}
	
	// 仾伀
	if(getPushState(player, 0) || getPushState(player, 1)) {
		if(!ending[player]) {
			PlayWave(5);
			statc[player * 10] = !statc[player * 10];
		}
	}
	
	// A儃僞儞
	if( (getPushState(player, 4)) || (statc[player * 10 + 1] >= 10 * 60) ) {
		StopAllBGM();
		
		if( playback ) {
			// 儕僾儗僀 #1.60c7n8
			stat[player] = 0;	// 嶲壛懸偪乮僞僀僩儖傊乯
		} else if( (!statc[player * 10]) && (statc[player * 10 + 1] < 10 * 60) && (!ending[player]) ) {
			// YES
			PlayWave(10);
			
			if((stage[player] >= 27) && (stage[player] <= 44) )
				ltime[player] = 600 * 60;
			else
				ltime[player] = 180 * 60;

			nextc[player] = stage_nextc[player];
			next[player] = nextb[nextc[player] + player * 1400];

			clearnum[player] = 0;
			clearp[player] = 0;

			// 弶婜壔
			tomoyoInitial(player);
			
			// 僗僞乕僩帪偺僗僥乕僕傪愝掕 #1.60c7n8
			start_stage[player] = stage[player];
			start_nextc[player] = stage_nextc[player];
			
			time2[player] = 0;					// TOMOYO梡僾儗僀僞僀儉傪儕僙僢僩
			replay_save[player] = 1;			// 儕僾儗僀僙乕僽傪壜擻偵偡傞
			
			stat[player] = 1;					// 僽儘僢僋僔儍僢僞乕
			statc[player * 10] = 0;				// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 1] = 3;			// Ready
		} else {
			// NO
			stat[player] = 11;				// 僱乕儉僄儞僩儕昞帵 #1.60c7p1
			statc[player * 10] = 0;			// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 1] = 0;
			statc[player * 10 + 2] = 0;
			statc[player * 10 + 3] = 0;
			statc[player * 10 + 4] = 0;
			statc[player * 10 + 5] = 0;
		}
	}
}

//仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱
//  僗僥乕僞僗No.36 - TOMOYO儌乕僪 F-Point梡丂僗僥乕僕僙儗僋僩
//仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯
// statc[player * 10]     : 儌乕僪乮0=嵟弶 1=搑拞乯
// statc[player * 10 + 1] : 僞僀儅乕
// statc[player * 10 + 2] : 僇乕僜儖埵抲
// statc[player * 10 + 3] : 尰嵼偺僗僥乕僕
void statTomoyoSelect_FP(int player) {
	int i;
	
	if(statc[player * 10 + 1] == 0){
		loadTomoyoStage(player, stage[player]);
		FP_bonus[player] = 1000 * (((stage[player]-100) / 4) + 1);
		if(repversw <= 46) FP_bonus[player] = 10800;
		statc[player * 10 + 3] = stage[player] - 99;
		if(stage[player] == 190){	//僗僥乕僕90撍攋偱棳傟惎
			StopAllBGM();
			PlayWave(43);
			objectCreate2(player, 8, Rand(20) + 180 + 192 * player - 96 * maxPlay, 20 + Rand(10), 0, 0, 0, 0);
		}
	}
	
	statc[player * 10 + 1]++;
	
	padRepeat(player);
	padRepeat2(player);
	
	printFont(15 + 24 * player - 12 * maxPlay, 6, "SELECT", 4);
	
	// 僗僥乕僕斣崋
	printFont(15 + 24 * player - 12 * maxPlay, 8, "    STAGE", 4);
	
	if(statc[player * 10] == 0){	//嵟弶
		printFont(15 + 24 * player - 12 * maxPlay, 7, "  FIRST", 4);
	
		sprintf(string[0],"F-POINT%3d",start_stage[player] - 99);
		printFont(15 + 24 * player - 12 * maxPlay, 14, string[0], 0);
		printFont(14 + 24 * player - 12 * maxPlay, 14, "<          >", count % 9);

		// 仼
		if((mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) || (getPressState(player, 6)))
		if( getPressState(player, 2) ) {
			PlayWave(3);
			
			// 僗僥乕僕斣崋
			start_stage[player]--;
			if(start_stage[player] < 100) start_stage[player] = 189;
			if(repversw >= 47) FP_bonus[player] = 1000 * (((start_stage[player]-100) / 4) + 1);
			// 僗僥乕僕僨乕僞撉傒崬傒 #1.60c7l9
			loadTomoyoStage(player, start_stage[player]);
		}
	
		// 仺
		if((mpc[player] == 1) || ((mpc[player] > tame1) && (mpc[player] % tame2 == 0)) || (getPressState(player, 6)))
		if( getPressState(player, 3) ) {
			PlayWave(3);
			
			// 僗僥乕僕斣崋
			start_stage[player]++;
			if(start_stage[player] > 189) start_stage[player] = 100;
			if(repversw >= 47) FP_bonus[player] = 1000 * (((start_stage[player]-100) / 4) + 1);
			// 僗僥乕僕僨乕僞撉傒崬傒 #1.60c7l9
			loadTomoyoStage(player, start_stage[player]);
		}
	} else {
		printFont(15 + 24 * player - 12 * maxPlay, 7, "   NEXT", 4);
		
		sprintf(string[0], "%2d", 10 - (statc[player * 10 + 1] / 60));
		printFont(17 + 24 * player - 12 * maxPlay, 23, "TIME", 6);
		printFont(21 + 24 * player - 12 * maxPlay, 23, string[0], 0);
		
		for(i=0;i<=3;i++){
			if(statc[player * 10 + 3] < 90){
				if(statc[player * 10 + 3] + FP_next[i] <= 90)
				sprintf(string[0], "%2d", statc[player * 10 + 3] + FP_next[i]);
				else sprintf(string[0], "90", 0);
			}else{
				if(statc[player * 10 + 3] + FP_next[i] <= 100)
					sprintf(string[0], "%2d", statc[player * 10 + 3] + FP_next[i]);
				else sprintf(string[0], "100", 0);
			}
			printFont(18 + 24 * player - 12 * maxPlay, 10 + (i * 2), string[0], 0);
		}
		
		printFont(15 + 24 * player - 12 * maxPlay, 10 + ( statc[player * 10 + 2] * 2), "b", fontc[rots[player]]);
		
		// 仾
		if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
		if( getPressState(player, 0) ) {
			PlayWave(5);
			statc[player * 10 + 2]--;
			if(statc[player * 10 + 2] < 0) statc[player * 10 + 2] = 3;
			if(statc[player * 10 + 3] < 90){
				if(statc[player * 10 + 3] + FP_next[statc[player * 10 + 2]] <= 90)
				stage[player] = statc[player * 10 + 3] + FP_next[statc[player * 10 + 2]] + 99;
				else stage[player] = 189;
				if(repversw >= 47) FP_bonus[player] = 1000 * (((stage[player]-100) / 4) + 1);
				loadTomoyoStage(player, stage[player]);
			}else{
				if(statc[player * 10 + 3] + FP_next[statc[player * 10 + 2]] <= 100)
					stage[player] = statc[player * 10 + 3] + FP_next[statc[player * 10 + 2]] + 99;
				else stage[player] = 199;
				if(repversw >= 47) FP_bonus[player] = 1000 * (((stage[player]-100) / 4) + 1);
				loadTomoyoStage(player, stage[player]);
			}
		}
		
		// 伀
		if( (mpc2[player] == 1) || ((mpc2[player] > tame3) && (mpc2[player] % tame4 == 0)) )
		if( getPressState(player, 1) ) {
			PlayWave(5);
			statc[player * 10 + 2]++;
			if(statc[player * 10 + 2] > 3) statc[player * 10 + 2] = 0;
			if(statc[player * 10 + 3] < 90){
				if(statc[player * 10 + 3] + FP_next[statc[player * 10 + 2]] <= 90)
				stage[player] = statc[player * 10 + 3] + FP_next[statc[player * 10 + 2]] + 99;
				else stage[player] = 189;
				if(repversw >= 47) FP_bonus[player] = 1000 * (((stage[player]-100) / 4) + 1);
				loadTomoyoStage(player, stage[player]);
			}else{
				if(statc[player * 10 + 3] + FP_next[statc[player * 10 + 2]] <= 100)
					stage[player] = statc[player * 10 + 3] + FP_next[statc[player * 10 + 2]] + 99;
				else stage[player] = 199;
				if(repversw >= 47) FP_bonus[player] = 1000 * (((stage[player]-100) / 4) + 1);
				loadTomoyoStage(player, stage[player]);
			}
		}
	}

	// A儃僞儞
	if( (getPushState(player, 4)) || ((statc[player * 10] != 0) && (statc[player * 10 + 1] > 600)) ) {
		PlayWave(10);
		if( statc[player * 10] == 0 ) {
			// 嵟弶
			stage[player] = start_stage[player];
			bgmlv = setstartBGM(gameMode[player], player);	//BGM僙僢僩
			if(repversw >= 47) FP_bonus[player] = 1000 * (((stage[player]-100) / 4) + 1);
			stat[player] = 1;					// 僽儘僢僋僔儍僢僞乕
			statc[player * 10] = 0;				// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 1] = 3;			// Ready
			statc[player * 10 + 2] = 0;
			statc[player * 10 + 3] = 0;
		}else{
			//搑拞
			//BGM愗傝懼偊敾掕
			if(stage[player] <= 129) i = 8;
			else if(stage[player] <= 159) i = 14;
			else if(stage[player] <= 189) i = 9;
			else i = 19;
			
			if(bgmlv != i){
				bgmlv = i;
				changeBGM(0);
			}
			if(repversw >= 47) FP_bonus[player] = 1000 * (((stage[player]-100) / 4) + 1);
			stat[player] = 3;					// Ready
			statc[player * 10] = 0;				// 僗僥乕僞僗僇僂儞僞傪0偵
			statc[player * 10 + 1] = 0;			// 
			statc[player * 10 + 2] = 0;
			statc[player * 10 + 3] = 0;
		}
	}
	if(( statc[player * 10] == 0 ) && (getPushState(player, 5))) {		// B儃僞儞偱儌乕僪慖戰夋柺偵栠傞
		sp[player] = 1;
		PlayWave(5);
		randommode[player] = 1;
		versusInit(player);				// NEXT傪惗惉偟捈偡
		randommode[player] = 0;
		stat[player] = 1;				// 僽儘僢僋僔儍僢僞乕幚峴
		statc[player * 10] = 0;			// 僗僥乕僞僗僇僂儞僞傪0偵
		statc[player * 10 + 1] = 2;		// 僔儍僢僞乕屻偼僗僥乕僞僗No.2
		relaymode[player] = 0;
	}
}
//仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱
//  僗僥乕僕忋偺僾儔僠僫僽儘僢僋攝抲傪儔儞僟儉偵偡傞
//仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯
void randPlatinum(int player, int tgtnum){
	int empty, i, j, put_flag[22], end_flag, put_num;
	
	if((tomoyo_rise[player]) || (tgtnum == 0)) return;
	for(i = 0; i < 22; i++) put_flag[i] = 0;
	put_num = 0;
	empty = 0;
	end_flag = 0;

	// 僾儔僠僫僽儘僢僋傪晛捠偺僽儘僢僋偵偡傞
	for(i = 0; i < 220; i++) {
		if(fld[i + player * 220] >= 11) {
			fld[i + player * 220] = fld[i + player * 220] - 9;
		}
	}

	while(!end_flag){
		for(i = 0; i <= fldsizeh[player]; i++) {
			empty = 1;
			if((!put_flag[i]) || (tgtnum == 99)){
				for(j = 0; j < fldsizew[player]; j++) {
					if((fld[j + i * fldsizew[player] + player * 220] >= 2) && (fld[j + i * fldsizew[player] + player * 220] <= 8)) {
						empty = 0;
						if((tgtnum == 99) || (rand(10, player) == 0)) {
							fld[j + i * fldsizew[player] + player * 220] = fld[j + i * fldsizew[player] + player * 220] + 9;
							put_num++;
							put_flag[i] = 1;
							if((put_num >= tgtnum) && (tgtnum != 99)) return;
							if(tgtnum != 99) break;
						}
					}
				}
			}
			if(empty) put_flag[i] = 1;
		}
		end_flag = 1;
		for(i = 0; i < 22; i++){
			if(!put_flag[i]){
				end_flag = 0;
				break;
			}
		}
	}
}


//仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱
//  TOMOYO儌乕僪 僗僥乕僕撉傒崬傒乛曐懚
//仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯
// 僼傽僀儖僼僅乕儅僢僩 (4byte扨埵)
//   0乣  209 僼傿乕儖僪僨乕僞乮墶10 * 廲21儅僗乯
// 210        MIRROR
// 211        ROLL ROLL
// 212        DEATH BLOCK
// 213        X-RAY
// 214        COLOR
// 215乣249   枹巊梡乮帺桼偵巊梡壜擻乯
// 250乣449   偣傝忋偑傝僼傿乕儖僪

/* 僗僥乕僕僨乕僞傪儘乕僪 */
void loadTomoyoStage(int player, int number) {
	int i;
	
	FillMemory(&saveBuf, 50000 * 4, 0);
	
	sprintf(string[0], "stage/stage%02d.sav", number);
	LoadFile(string[0], &saveBuf, 450 * 4);
	
	// 僼傿乕儖僪撉傒崬傒
	for(i=0;i<210;i++) {
		fld[(i+10) + 220 * player] = saveBuf[i];
		// 弶婜攝抲傪尒偊傞傛偆偵偡傞
		fldt[(i+10) + 220 * player] = (fld[(i+10) + 220 * player] != 0) * -1;
	}
	
	for(i=0;i<200;i++)
		tomoyo_rise_fld[i + 200 * player] = saveBuf[i+250];
	
	if(gameMode[player] == 6) {
		// MIRROR
		isfmirror[player] = saveBuf[210]; // #1.60c7l7
		
		// ROLL ROLL
		rollroll_flag[player] = saveBuf[211]; // #1.60c7l7
		
		// DEATH BLOCK #1.60c7l8
		IsBig[player] = saveBuf[212];

		// X-RAY #1.60c7p9ex
		xray_flag[player] = saveBuf[213];

		// COLOR #1.60c7p9ex
		color_flag[player] = saveBuf[214];
		
		// BLIND C7T6.5
		blind_flag[player] = saveBuf[215];
		
		// 嵟掅棊壓懍搙
		min_speed[player] = saveBuf[216];
		
		// 僒儞僟乕
		isthunder[player] = saveBuf[217];
		
		
		// NEXT塀偟
		hnext_flag[player] = saveBuf[219];
		
		tomoyo_waits[player] = saveBuf[220];
	}
	// 偣傝忋偑傝 乮儈僢僔儑儞偱傕巊梡乯
	tomoyo_rise[player] = saveBuf[218];
}

/* 僗僥乕僕僨乕僞傪僙乕僽 */
void saveTomoyoStage(int player, int number) {
	int i;
	
	FillMemory(&saveBuf, 50000 * 4, 0);
	
	// 僼傿乕儖僪傪僙乕僽僶僢僼傽偵僐僺乕
	for(i=0;i<210;i++) {
		saveBuf[i] = fld[(i+10) + 220 * player];
	}
	
	for(i=0;i<200;i++)
		saveBuf[i+250] = tomoyo_rise_fld[i + 200 * player];
	
	// MIRROR
	//saveBuf[210] = fmirror;
	saveBuf[210] = isfmirror[player]; // #1.60c7l7
	
	// ROLL ROLL
	//saveBuf[211] = rollroll];
	saveBuf[211] = rollroll_flag[player]; // #1.60c7l7
	
	// DEATH BLOCK #1.60c7l8
	saveBuf[212] = IsBig[player];
	
	// X-RAY #1.60c7p9ex
	saveBuf[213] = xray_flag[player];
	
	// COLOR #1.60c7p9ex
	saveBuf[214] = color_flag[player];
	
	// BLIND C7T6.5
	saveBuf[215] = blind_flag[player];
	
	// 嵟掅棊壓懍搙
	saveBuf[216] = min_speed[player];
	
	// 僒儞僟乕
	saveBuf[217] = isthunder[player];
	
	// 偣傝忋偑傝
	saveBuf[218] = tomoyo_rise[player];
	
	// NEXT塀偟
	saveBuf[219] = hnext_flag[player];
	
	saveBuf[220] = tomoyo_waits[player];
	
	// 曐懚偡傞
	sprintf(string[0], "stage/stage%02d.sav", number);
	SaveFile(string[0], &saveBuf, 450 * 4);
}
