//仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱仴仱
//  儔儞僉儞僌娭楢
//仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯仮仯

// 儔儞僉儞僌梡僌儘乕僶儖曄悢
// 5柤 亊 15儌乕僪 亊 2夞揮儖乕儖僞僀僾(堦屄梊旛)
//僇僥僑儕乕
//價僊丄儅僗*4(抜埵暿)丄20G*2丄僨價丄僨價-丄僩儌Ti丄僩儌EH丄僄僗*3丄僄儞僪儗僗
bool	allocked2 = false;
char*	rkname[5 * 15 * 2];			// 柤慜
int		rkdata[5 * 15 * 2];		// 壴壩乛抜埵乛僗僥乕僕乛儔僀儞
int		rktime2[5 * 15 * 2];		// 僞僀儉
int		rkclear[5 * 15 * 2];		// 0=搑拞偱拏懅 1=儘乕儖幐攕 2=儘乕儖僋儕傾
int		rkother[5 * 15 * 2];		// 偦偺懠乮儗儀儖傗僋儕傾棪側偳乯
int		rkrots[5 * 15 * 2];		// 夞揮儖乕儖

int		rkac[5 * 15 * 2];		// AC儊僟儖 #LITE30.2
int		rkst[5 * 15 * 2];		// ST儊僟儖 #LITE30.2
int		rksk[5 * 15 * 2];		// SK儊僟儖 #LITE30.2
int		rkco[5 * 15 * 2];		// CO儊僟儖 #LITE30.2
int		rkre[5 * 15 * 2];		// RE儊僟儖 #LITE30.2
int		modecolor[15] = {4,1,1,1,1,5,5,2,2,3,3,0,0,2,9};		// 儌乕僪柤昞帵怓

// 儔儞僉儞僌弶婜壔
void RankingInit2() {
	int i;
	
	for(i = 0; i < (5 * 15 * 2); i++) {
		StrCpy(rkname[i], "NOP");
		rkdata[i] = 0;
		rktime2[i] = 1200*60;
		rkclear[i] = 0;
		rkother[i] = 0;
		rkrots[i] = 0;
		rkac[i] = 0;
		rkst[i] = 0;
		rksk[i] = 0;
		rkco[i] = 0;
		rkre[i] = 0;
	}
}

// 壗埵偵擖傞偐僠僃僢僋乮儔儞僋奜側傜-1乯
int RankingCheck2(int rmode, int rrots, int rdata, int rtime, int rclear) {
	int i, j, rank;
	
	if(playback || demo) return -1;
//	if(rmode >= 8) return -1;
	
	rank = -1;
	
	ARSSRSch(rrots);//ARS偐SRS偐傪寛傔傞娭悢
	
	for(i = 0; i < 5; i++) {
		j = RankingGet(rmode, rankingrule);
		
		if(
			(rdata > rkdata[j + i]) ||  //抜埵壴壩摓払僗僥乕僕儔僀儞
			((rdata == rkdata[j + i]) && ((rclear > rkclear[j + i])//儘乕儖僋儕傾亜幐攕亜儘乕儖埲慜
			|| ((rclear == rkclear[j + i]) && (rtime < rktime2[j + i]))))
		  )
		{//if(rmode <= 3) return ((rmode * 60) + (rtype * 30) + (rrots * 3));
			rank = i;
			break;
		}
	}
	
	return rank;
}

// 儔儞僉儞僌偵搊榐
void RankingRegist2(int rmode, int rrots, int rdata, int rtime, int rclear, 
	int rother, char *rname, int rank, int rac, int rst, int rsk, int rco ,int rre) {
	
	int i, j, rcolor;
	
	if(playback || demo) return;
	if((rank < 0) || (rank > 4)) return;
	
	ARSSRSch(rrots);
	j = RankingGet(rmode, rankingrule);
	
	// 儔儞僉儞僌傪偢傜偡
	for(i = 4; i > rank ; i--) {
		StrCpy(rkname[j + i], rkname[j + i - 1]);
		rkdata[j + i] = rkdata[j + i - 1];
		rktime2[j + i] = rktime2[j + i - 1];
		rkclear[j + i] = rkclear[j + i - 1];
		rkother[j + i] = rkother[j + i - 1];
		rkrots[j + i] = rkrots[j + i - 1];
	}
	
	// 怴偟偄僨乕僞傪搊榐
	StrCpy(rkname[j + rank], rname);
	rkdata[j + rank] = rdata;
	rktime2[j + rank] = rtime;
	rkclear[j + rank] = rclear;
	rkother[j + rank] = rother;
	rkrots[j + rank] = rrots;
	
	// 儊僟儖傪搊榐 #LITE30.2
	rkac[j + rank] = rac;
	rkst[j + rank] = rst;
	rksk[j + rank] = rsk;
	rkco[j + rank] = rco;
	rkre[j + rank] = rre;
}

// 儔儞僉儞僌昞帵
void RankingProc_2(int cat) {
	count = 0;
	flag = 0;
//	category = cat;
		if(cat==0){	//價僊僫乕
		category = 0;
		}else if(cat==1){	//儅僗僞乕
			if(enable_grade[0]==1){	//1
			category = 1;
			}else if(enable_grade[0]==2){	//2
			category = 2;
			}else if(enable_grade[0]==3){	//2+
			category = 3;
			}else if(enable_grade[0]==4){	//3
			category = 4;
			}
		}else if(cat==2){
			if(enable_grade[0]<=3){
			category = 5;
			}else if(enable_grade[0]==4){	//3
			category = 6;
			}
		}else if(cat==3){
			if(devil_minus[0]==0){
			category = 7;
			}else if(devil_minus[0]==1){
			category = 8;
			}
		}else if(cat==6){	//偲傕傛
			if(tomoyo_opt[0]==0){	//Ti
			category = 9;
			}else if(tomoyo_opt[0]==1){	//EH
			category = 10;
			}
		}else if(cat==7){
			if(anothermode[0]==0){
			category = 11;
			}else if(anothermode[0]==1){
			category = 12;
			}else if(anothermode[0]==2){
			category = 13;
			}
		}

	
	while(!flag) {
		count++;
		
		KeyInput();			
		RankingView2();
		
		// A偐B偱栠傞
		if( (count > 448) || getPushState(0,4) || getPushState(0,5) || getPushState(1,4) || getPushState(1,5) ) {
			flag = 1;
		}
		
		spriteTime();
	}
}

void RankingProc2_2() {
	category = 0;

	while(1) {
		KeyInput();
		
		RankingView2();
		// 仼
		if( getPushState(0,2) ) {
			PlayWave( 5 );
			category--;//僎乕儉儌乕僪
			if(category < 0) category = 14;
		}
		
		// 仺
		if( getPushState(0,3) ) {
			PlayWave( 5 );
			category++;
			if(category > 14) category = 0;
		}
		
		// 仾
		if( getPushState(0,0) ) {
			PlayWave( 5 );
			rankingrule = !(rankingrule);//夞揮儖乕儖
		}
		
		// 伀
		if( getPushState(0,1) ) {
			PlayWave( 5 );
			rankingrule  = !(rankingrule);
		}
		
		// A偐B偱栠傞
		if( getPushState(0,4) || getPushState(0,5) || getPushState(1,4) || getPushState(1,5) ) {
			return;
		}
		
		spriteTime();
	}
}

void RankingView2() {//5埵傑偱
	int i, j, k, color;
	
	// 攚宨昤夋
	count++;
	if(background == 0) {
		for(i = 0; i <= 4; i++) {
			if(getDrawRate() == 1)
				BltFastRect(4, 96 * i - (count % 96) / 3, 0, 0, 0, 96, 240);
			else
				BltFastRect(4, 192 * i - (count % 32), 0, 0, 0, 192, 480);
		}
	} else if(background == 1) {
		for(i = 0; i <= 4; i++) {
			ExBltFastRect(4, 96 * i, 0, 0, 0, 96, 240);
		}
	} else {
		ExBltFast(30, 0, 0);
	}

	// 儖乕儖柤昞帵
	getRuleNameEx(rankingrule, 0);
	StrCat(string[0], " TYPE RULE - ");
	
	// 儌乕僪柤昞帵
	getModeNameEx(category, 1);
	StrCat(string[1], " MODE");
	
	StrCat(string[0], string[1]);
	printFont(1, 1, string[0], modecolor[category]);
	
	// 儔儞僉儞僌昞帵
	if(category == 0) {//beginner 
		printFont(1, 3, "HANABI RANKING", 1); 
	} else if(category == 9) {//偲傕傛TI 
		printFont(1, 3, "TI COURSE RANKING", 1);
	} else if(category == 10) {//偲傕傛EH
		printFont(1, 3, "E-HEART COURSE RANKING", 1);
	} else if(category == 14) {//僄儞僪儗僗
		printFont(1, 3, "ENDLESS RANKING", 1);
	} else if((category >= 1) && (category <= 6)) {//儅僗僞乕丒20G
		printFont(1, 3, "GRANDMASTER RANKING", 1);
	} else {
		printFont(1,  3, "TIME TRIAL RANKING", 1);
	}
	
	if(category == 0)//價僊
		printFont(1, 5  , "RANK  NAME  HANABI LEVEL  TIME", 2);
	else if(category == 9)//偲傕傛TI
		printFont(1, 5  , "RANK  NAME  STAGE  CLEAR  TIME", 2);
	else if(category == 10)//偲傕傛EH
		printFont(1, 5  , "RANK  NAME  STAGE         TIME", 2);
	else if((category == 11)||(category == 12)||(category == 13))//ace宯
		printFont(1, 5  , "RANK  NAME  LINES  LEVEL  TIME", 2);
	else if(category == 14)//僄儞僪儗僗
		printFont(1, 5  , "RANK  NAME  LEVEL  MODE   TIME", 2);
	else
		printFont(1, 5  , "RANK  NAME  CLASS  LEVEL  TIME", 2);
	if(rankingrule == 0){
		printFont(16, 27  , "HEBORIS TI-ARS", 0);//ARS
		printFont(16, 28  , "ACE-ARS ACE-ARS2 D.R.S", 0);
	}else{
		printFont(16, 27  , "TI-WORLD ACE-SRS", 0);//SRS
		printFont(16, 28  , "DS-WORLD SRS-X", 0);
	}	
		for(i = 0; i < 5; i++) {
			j = RankingGet(category, rankingrule);
			// 弴埵
			if(i == 0) {sprintf(string[0], "1ST");
			printFont(1, 6 + (i * 4)  , string[0], 2);
			}
			if(i == 1) {sprintf(string[0], "2ND");
			printFont(1, 6 + (i * 4)  , string[0], 9);
			}
			if(i == 2) {sprintf(string[0], "3RD");
			printFont(1, 6 + (i * 4)  , string[0], 4);
			}
			if(i == 3) sprintf(string[0], "4TH");
			if(i == 4) sprintf(string[0], "5TH");
			printFont(1, 6 + (i * 4)  , string[0], 0);
			
			// 柤慜
			printFont(7, 6 + (i * 4)  , rkname[j + i], digitc[rkrots[j + i]]);
			
			if(category == 0) {
				// 僗僐傾
				sprintf(string[0], "%d", rkdata[j + i]);
				printFont(13, 6 + (i * 4)  , string[0],digitc[rkrots[j + i]]);
				
				// 儗儀儖
				sprintf(string[0], "%d", rkother[j + i]);
        			printFont(20, 6 + (i * 4)  , string[0], digitc[rkrots[j + i]]); 
	         } else if( (category >= 1) && (category <= 8) ) { 
				// 抜埵 
               			sprintf(string[0], "%d", rkother[j + i]); 
				if((category == 7)||(category == 8)){//devil 
					printFont(13, 6 + (i * 4) , dgname[rkother[j + i]], digitc[rkrots[j + i]]); 
					sprintf(string[0], "%d", rkdata[j + i]); 
				} else if( ((category == 1)||(category == 3))&&(rkdata[j + i] == 18)) 
					printFont(13, 6 + (i * 4)  , "GM", digitc[rkrots[j + i]]); 
				else 
					printFont(13, 6 + (i * 4)  , gname2[rkdata[j + i]], digitc[rkrots[j + i]]); 

            // 儗儀儖 
            printFont(20, 6 + (i * 4)  , string[0], digitc[rkrots[j + i]]); 
         } else if((category == 9) || (category == 10)) { 
            // 僗僥乕僕 

				if(rkclear[j + i] == 2)
					sprintf(string[0], "ALL");
				else{
				if(rkdata[j + i] <= 19)
					sprintf(string[0], "%d", rkdata[j + i] + 1);
				else if((rkdata[j + i] <= 26)&&(rkdata[j + i] >= 20))
					sprintf(string[0], "EX%d", rkdata[j + i] - 19);
				else if(rkdata[j + i] >=27 )
					sprintf(string[0], "%d", rkdata[j + i] - 26);
				}
				printFont(13, 6 + (i * 4)  , string[0], digitc[rkrots[j + i]]);
				
				// 僋儕傾棪
				if(category == 9){
				sprintf(string[0], "%d%%", rkother[j + i]);
				printFont(20, 6 + (i * 4)  , string[0], digitc[rkrots[j + i]]);
				}
			} else if((category == 11)||(category == 12)||(category == 13)){//ace宯
				// 儔僀儞
				sprintf(string[0], "%d", rkdata[j + i]);
				printFont(13, 6 + (i * 4)  , string[0], digitc[rkrots[j + i]]);
				
				// 儗儀儖
				sprintf(string[0], "%d", rkother[j + i] + 1);
				printFont(20, 6 + (i * 4)  , string[0], digitc[rkrots[j + i]]);
			}else {
			// 儗儀儖
				sprintf(string[0], "%d", rkdata[j + i]);
				printFont(13, 6 + (i * 4)  , string[0], digitc[rkrots[j + i]]);
				
				if(rkother[j + i]==0)sprintf(string[0], "BEGINN");
				if(rkother[j + i]==1)sprintf(string[0], "MASTER");
				if(rkother[j + i]==2)sprintf(string[0], "20G");
				if(rkother[j + i]==3)sprintf(string[0], "DEVIL");
				printFont(20, 6 + (i * 4)  , string[0], digitc[rkrots[j + i]]);
			}
			
			// 僞僀儉
			getTime(rktime2[j + i]);
			printFont(27, 6 + (i * 4), string[0], digitc[rkrots[j + i]]);
			
			// 儔僀儞
			if(rkclear[j + i] == 1) {
			//printFont(20, 8+(i*4)  , "GREENLINE", 4);
			ExBltRect(77, 110, (7 + (i * 4)  ) *8,  0, 2, 170, 2);
			}else if(rkclear[j + i] == 2) {
			//printFont(20, 8+(i*4)  , "YELLOWLINE", 7);
			ExBltRect(77, 110, (7 + (i * 4)  ) *8,  0, 0, 170, 2);
			}
			
			// 夞揮
				if(rkrots[j + i]==0)sprintf(string[0], "HEBORIS");
				if(rkrots[j + i]==1)sprintf(string[0], "TI-ARS");
				if(rkrots[j + i]==2)sprintf(string[0], "TI-WORLD");
				if(rkrots[j + i]==3)sprintf(string[0], "ACE-SRS");
				if(rkrots[j + i]==4)sprintf(string[0], "ACE-ARS");
				if(rkrots[j + i]==5)sprintf(string[0], "ACE-ARS2");
				if(rkrots[j + i]==6)sprintf(string[0], "DS-WORLD");
				if(rkrots[j + i]==7)sprintf(string[0], "SRS-X");
				if(rkrots[j + i]==8)sprintf(string[0], "D.R.S");
				printFont(27, 8 + (i * 4)  , string[0], fontc[rkrots[j + i]]);
			
			// 儊僟儖
			if((category <= 8)||(category == 14)) {
				if(rkac[j + i]) ExBltRect(0, 20, (7 + (i * 4)  ) * 8,  0, 52 - rkac[j + i] * 13, 15, 12);
					else ExBltRect(0, 20, (7 + (i * 4)  ) * 8,  0, 52, 15, 12);
				if(rkst[j + i]) ExBltRect(0, 40, (7 + (i * 4)  ) * 8, 16, 52 - rkst[j + i] * 13, 15, 12);
					else ExBltRect(0, 40, (7 + (i * 4)  ) * 8, 16, 52 , 15, 12);
				if(rksk[j + i]) ExBltRect(0, 60, (7 + (i * 4)  ) * 8, 32, 52 - rksk[j + i] * 13, 15, 12);
					else ExBltRect(0, 60, (7 + (i * 4)  ) * 8, 32, 52, 15, 12);
				if(rkco[j + i]) ExBltRect(0, 80, (7 + (i * 4)  ) * 8, 80, 52 - rkco[j + i] * 13, 15, 12);
				 	else ExBltRect(0, 80, (7 + (i * 4)  ) * 8, 80, 52, 15, 12);
				if(rkre[j + i]) ExBltRect(0, 100,(7 + (i * 4)  ) * 8, 48, 52 - rkre[j + i] * 13, 15, 12);
					else ExBltRect(0, 100,(7 + (i * 4)  ) * 8, 48, 52, 15, 12);
			}
		}
		printFont(1, 27  , "k n ROT TYPE", 0);
		printFont(1, 28  , "< > GAME MODE", 0);
	
}
// 儔儞僉儞僌傪曐懚
void RankingSave2() {
	int i, temp2[3];
	
	FillMemory(&saveBuf, 5000 * 4, 0);
	
	// 僿僢僟
	saveBuf[0] = 0x4F424549;
	saveBuf[1] = 0x20534953;
	saveBuf[2] = 0x48474949;
	saveBuf[3] = 0x34764354;
	
	// 儔儞僉儞僌僨乕僞
	for(i = 0; i < (5 * 15 * 2); i++) {
		// 柤慜
		StrCpy(&temp2, rkname[i]);
		saveBuf[4 + i] = temp2[0];//1
		
		// 抜埵
		saveBuf[4 + i + (5 * 15 * 2) * 1] = rkdata[i];//2
		
		// 僞僀儉
		saveBuf[4 + i + (5 * 15 * 2) * 2] = rktime2[i];//3
		
		// 儘乕儖僋儕傾
		saveBuf[4 + i + (5 * 15 * 2) * 3] = rkclear[i];//4
		
		// 偦偺懠
		saveBuf[4 + i + (5 * 15 * 2) * 4] = rkother[i];//5
		
		// 儊僟儖 #LITE30.2
		saveBuf[4 + i + (5 * 15 * 2) * 5] = rkac[i];//6
		saveBuf[4 + i + (5 * 15 * 2) * 6] = rkst[i];//7
		saveBuf[4 + i + (5 * 15 * 2) * 7] = rksk[i];//8
		saveBuf[4 + i + (5 * 15 * 2) * 8] = rkco[i];//9
		saveBuf[4 + i + (5 * 15 * 2) * 9] = rkre[i];//10
		saveBuf[4 + i + (5 * 15 * 2) * 10] = rkrots[i];//11
	}
	
	SaveFile("RANKING2.SAV", &saveBuf, 1654 * 4);//1654=4+(5*15*2*11)
}

// 儔儞僉儞僌傪撉傒崬傒
int RankingLoad2() {
	int i, temp2[3];
	
	// 僿僢僟偩偗撉傒崬傒
	FillMemory(&saveBuf, 5000 * 4, 0);
	LoadFile("RANKING2.SAV", &saveBuf, 16);
	
	// 僶乕僕儑儞堘偄側傜弶婜壔
	if(saveBuf[0] != 0x4F424549) return 1;
	if(saveBuf[1] != 0x20534953) return 1;
	if(saveBuf[2] != 0x48474949) return 1;
	if(saveBuf[3] != 0x34764354) return 1;
	
	// 慡晹撉傒崬傒
	LoadFile("RANKING2.SAV", &saveBuf, 1654 * 4);
	
	for(i = 0; i < (5 * 15 * 2); i++) {
		// 柤慜
		temp2[0] = saveBuf[4 + i];
		StrCpy(rkname[i], &temp2);
		
		// 抜埵
		rkdata[i]  = saveBuf[4 + i + (5 * 15 * 2) * 1];
		
		// 僞僀儉
		rktime2[i]  = saveBuf[4 + i + (5 * 15 * 2) * 2];
		
		// 儘乕儖僋儕傾
		rkclear[i] = saveBuf[4 + i + (5 * 15 * 2) * 3];
		
		// 偦偺懠
		rkother[i] = saveBuf[4 + i + (5 * 15 * 2) * 4];
		
		// 儊僟儖 #LITE30.2
		rkac[i] = saveBuf[4 + i + (5 * 15 * 2) * 5];
		rkst[i] = saveBuf[4 + i + (5 * 15 * 2) * 6];
		rksk[i] = saveBuf[4 + i + (5 * 15 * 2) * 7];
		rkco[i] = saveBuf[4 + i + (5 * 15 * 2) * 8];
		rkre[i] = saveBuf[4 + i + (5 * 15 * 2) * 9];
		rkrots[i] = saveBuf[4 + i + (5 * 15 * 2) * 10];
	}
	
	return 0;
}

// 儔儞僉儞僌傪撉傒彂偒偡傞帪偵巊梡
int RankingGet(int rmode, int rrots) {
	// 晛捠偺儌乕僪
	return ((rmode * 10) + (rrots * 5));
}
// 奜晹偐傜儔儞僉儞僌偺僨乕僞傪巊偄偨偄帪偵巊梡
int RankingGet2(int rmode,int rtype, int rrots,int player) {
	int cat[2];
	if((rrots==0)||(rrots==1)||(rrots==4)||(rrots==5)){
		rankingrule = 0 ;//ARS
	}else{
		rankingrule = 1;//SRS
	}
	
	if((rmode<=3)&&(rtype)){
		cat[player] = 14;
		}else if(rmode==0){
		cat[player] = 0;
		}else if(rmode==1){
			if(enable_grade[player]==1){
			cat[player] = 1;
			}else if(enable_grade[player]==2){
			cat[player] = 2;
			}else if(enable_grade[player]==3){
			cat[player] = 3;
			}else if(enable_grade[player]==4){
			cat[player] = 4;
			}
		}else if(rmode==2){
			if(enable_grade[player]<=3){
			cat[player] = 5;
			}else if(enable_grade[player]==4){
			cat[player] = 6;
			}
		}else if(rmode==3){
			if(devil_minus[player]==0){
			cat[player] = 7;
			}else if(devil_minus[player]==1){
			cat[player] = 8;
			}
		}else if(rmode==6){
			if(tomoyo_opt[player]==0){
			cat[player] = 9;
			}else if(tomoyo_opt[player]==1){
			cat[player] = 10;
			}
		}else if(rmode==7){
			if(anothermode[player]==0){
			cat[player] = 11;
			}else if(anothermode[player]==1){
			cat[player] = 12;
			}else if(anothermode[player]==2){
			cat[player] = 13;
			}
	}
	return ((cat[player] * 10) + (rankingrule * 5));
}
// 5柤 亊 15儌乕僪 亊 2夞揮儖乕儖僞僀僾
// 柤慜傪奿擺偡傞曄悢(rkname)偺儊儌儕傪妋曐
void RankingAlloc() {
	int i;
	if ( !allocked2 )
	{
		for(i = 0; i < (5 * 15 * 2 ); i++) rkname[i] = new char[4];
		allocked2 = true;
	}
}


void getModeNameEx( int mode, int number ) {
	if(mode == 0)
		sprintf(string[number], "BEGINNER");
	else if(mode == 1)
		sprintf(string[number], "MASTER GRADE 1");
	else if(mode == 2)
		sprintf(string[number], "MASTER GRADE 2");
	else if(mode == 3)
		sprintf(string[number], "MASTER GRADE 3");
	else if(mode == 4)
		sprintf(string[number], "MASTER GRADE 4");
	else if(mode == 5)
		sprintf(string[number], "20G");
	else if(mode == 6)
		sprintf(string[number], "20G GRADE 4");
	else if(mode == 7)
		sprintf(string[number], "DEVIL");
	else if(mode == 8)
		sprintf(string[number], "DEVIL-");
	else if((mode == 9)||(mode == 10))
		sprintf(string[number], "TOMOYO");
	else if(mode == 11)
		sprintf(string[number], "ACE(NORMAL)");
	else if(mode == 12)
		sprintf(string[number], "ACE(ANOTHER)");
	else if(mode == 13)
		sprintf(string[number], "ACE(HELL)");
	else if(mode == 14)
		sprintf(string[number], "ENDLESS");
}

void getRuleNameEx( int rule, int number ) {

		if(rule == 0)
			sprintf(string[number], "ARS");
		else if(rule == 1)
			sprintf(string[number], "SRS");
}	
//besttime(ACE偺傒)
void viewbesttime(int player){
	int	tmp,color;
	
	if(Isbesttime==0)return;
	
	color = (count % 4 / 2) * (sp[player] >= 1200) * digitc[rots[player]];
	/* 儀僗僩僞僀儉 */
	if( (gameMode[player] == 7) && ((!maxPlay) || (stat[1 - player] == 0)) ) {
		printFont(26+2*((hnext[player] >= 4) && (!player)) + 7 * player - 12 * maxPlay, 10, "BEST TIME", fontc[rots[player]]);
		
		tmp = RankingGet2(gameMode[player], anothermode[player], rots[player],player);
		if( ((rkdata[tmp] >= 150)&&(anothermode[player] <= 1)) || ((rkdata[tmp] >= 200)&&(anothermode[player] == 2)) )
		getTime(rktime2[tmp]);
		else getTime(0);
		printFont(26+2*((hnext[player] >= 4) && (!player)) + 7 * player - 12 * maxPlay, 11, string[0], color);
	}
}
void viewbesttimes(int player){
	int	tmp,color;
	
	if(Isbesttime==0)return;
	color = (count % 4 / 2) * (sp[player] >= 1200) * digitc[rots[player]];
	/* 儀僗僩僞僀儉 */
	if( (gameMode[player] == 7) && ((!maxPlay) || (stat[1 - player] == 0)) ) {
			//best偺暥帤
			ExBltRect(3, 208+20*((hnext[player] >= 4) && (!player)) + 70 * player - 96 * maxPlay, 78, 251, 91, 21, 7);
			//time偺暥帤
			ExBltRect(3, 230+20*((hnext[player] >= 4) && (!player)) + 70 * player - 96 * maxPlay, 78, 180, 119, 19, 7);
			tmp = RankingGet2(gameMode[player], anothermode[player], rots[player],player);
			if( ((rkdata[tmp] >= 150)&&(anothermode[player] <= 1)) || ((rkdata[tmp] >= 200)&&(anothermode[player] == 2)) )
			getTime(rktime2[tmp]);
			else getTime(0);
			printSMALLFont((26 + 8 * player - 12 * maxPlay)*8+20*((hnext[player] >= 4) && (!player)), 86, string[0], color);
	}
}

int ARSSRSch(int rots){
	if((rots==0)||(rots==1)||(rots==4)||(rots==5)||(rots==8)){
	rankingrule = 0 ;//ARS
	}else{
	rankingrule = 1;//SRS
	}
	return rankingrule;
}