// 僔儞僌儖戜懳墳 & 僄儞僨傿儞僌帪偵伀偐仾傪墴偟偰傕揰傪憹壛偝偣側偄#1.60c6.1a
// 愙拝99, Big懳墳丂#1.60c7
/*
world夞揮朄懃儊儌

仺:塃夞揮  仼嵍夞揮
L:  侽      侾      俀      俁        J:  侽      侾      俀      俁
仩仩仧仺仩仭仩仺仩仩仩仺仧仭仩仺      仧仩仩仺仩仭仧仺仩仩仩仺仩仭仩仺
仭仭仭  仩仭仩  仭仭仭  仩仭仩        仭仭仭  仩仭仩  仭仭仭  仩仭仩
仩仩仩仼仩仭仧仼仧仩仩仼仩仭仩仼      仩仩仩仼仩仭仩仼仩仩仧仼仧仭仩仼

S:  侽      侾      俀      俁        Z:  侽      侾      俀      俁
仩仭仧仺仩仭仩仺仩仩仩仺仧仩仩仺      仧仭仩仺仩仩仧仺仩仩仩仺仩仭仩仺
仭仭仩  仩仭仭  仩仭仭  仭仭仩        仩仭仭  仩仭仭  仭仭仩  仭仭仩
仩仩仩仼仩仩仧仼仧仭仩仼仩仭仩仼      仩仩仩仼仩仭仩仼仩仭仧仼仧仩仩仼

T:  侽      侾      俀      俁        仩:TTC悇彠偼偙傫側傫偩偭偨偭偗?
仩仧仩仺仩仭仩仺仩仩仩仺仩仭仩仺      仧仭仩仺仩仭仧仺仩仩仩仺仩仩仩仺
仭仭仭  仩仭仧  仭仭仭  仧仭仩        仭仭仩  仩仭仭  仩仭仭  仭仭仩
仩仩仩仼仩仭仩仼仩仧仩仼仩仭仩仼      仩仩仩仼仩仩仩仼仩仭仧仼仧仭仩仼

I:    侽        侾        俀        俁
仩仩仩仩  仩仩仧仩  仩仩仩仩  仩仭仩仩
仧仭仭仭仺仩仩仭仩仺仩仩仩仩仺仩仭仩仩仺
仩仩仩仩仼仩仩仭仩仼仭仭仭仧仼仩仭仩仩仼
仩仩仩仩  仩仩仭仩  仩仩仩仩  仩仧仩仩

夞揮曗惓(I埲奜嫟捠)
0>>1:(-1, 0)>(-1, -1)>(0, +2)>(-1, +2)  0>>3:(+1, 0)>(+1, -1)>(0, +2)>(+1, +2)
1>>2:(+1, 0)>(+1, +1)>(0, -2)>(+1, -2)  3>>2:(-1, 0)>(-1, +1)>(0, -2)>(-1, -2)
2>>3:(+1, 0)>(+1, -1)>(0, +2)>(+1, +2)  2>>1:(-1, 0)>(-1, -1)>(0, +2)>(-1, +2)
3>>0:(-1, 0)>(-1, +1)>(0, -2)>(-1, -2)  1>>0:(+1, 0)>(+1, +1)>(0, -2)>(+1, -2)
a>>b偲偡傞偲
a==1: (+1, 0)>(+1, +1)>(0, -2)>(+1, -2)
a==3: (-1, 0)>(-1, +1)>(0, -2)>(-1, -2)
b==1: (-1, 0)>(-1, -1)>(0, +2)>(-1, +2)
b==3: (+1, 0)>(+1, -1)>(0, +2)>(+1, +2)

I偺傒
0>>1:(-2, 0)>(+1, 0)>(+1, -2)            0>>3:(+2, 0)>(-1, 0)>(-1, -2)		5/14廋惓
1>>2:(-1, 0)>(+2, 0)>(-1, -2)>(+2, +1)   3>>2:(+1, 0)>(-2, 0)>(+1, -2)>(-2, +1)
2>>3:(-1, 0)>(+2, 0)>(+2, -1)            2>>1:(+1, 0)>(-2, 0)>(-2, -1)
3>>0:(+1, 0)>(-2, 0)>(-2, -1)>(+1, +2)   1>>0:(-1, 0)>(+2, 0)>(+2, -1)>(-1, +2)

0>>1:(+1, 0)>(-2, 0)>(+1, -2)
0>>3:(-1, 0)>(+2, 0)>(-1, -2)
偺曽偑暘偐傝傗偡偄偟僾儗僀偟傗偡偄偑乧
*/

int	blkWDataX[7 * 4 * 4] =	// world僞僀僾儈僲 憡懳X埵抲
{
	0, 1, 2, 3, 		2, 2, 2, 2, 		3, 2, 1, 0, 		1, 1, 1, 1, // I
	2, 2, 1, 0, 		2, 1, 1, 1, 		0, 0, 1, 2, 		0, 1, 1, 1, // L
	1, 2, 2, 1, 		2, 2, 1, 1, 		2, 1, 1, 2, 		1, 1, 2, 2, // 仩
	0, 1, 1, 2, 		2, 2, 1, 1, 		2, 1, 1, 0, 		0, 0, 1, 1, // Z
	1, 0, 1, 2, 		2, 1, 1, 1, 		1, 2, 1, 0, 		0, 1, 1, 1, // T
	0, 0, 1, 2, 		2, 1, 1, 1, 		2, 2, 1, 0, 		0, 1, 1, 1, // J
	2, 1, 1, 0, 		2, 2, 1, 1, 		0, 1, 1, 2, 		0, 0, 1, 1, // S
};

int	blkWDataY[7 * 4 * 4] =	// world僞僀僾儈僲 憡懳Y埵抲
{
	1, 1, 1, 1, 		0, 1, 2, 3, 		2, 2, 2, 2, 		3, 2, 1, 0, // I
	0, 1, 1, 1, 		2, 2, 1, 0, 		2, 1, 1, 1, 		0, 0, 1, 2, // L
	0, 0, 1, 1, 		0, 1, 1, 0, 		1, 1, 0, 0, 		1, 0, 0, 1, // 仩
	0, 0, 1, 1, 		0, 1, 1, 2, 		2, 2, 1, 1, 		2, 1, 1, 0, // Z
	0, 1, 1, 1, 		1, 0, 1, 2, 		2, 1, 1, 1, 		1, 2, 1, 0, // T
	0, 1, 1, 1, 		0, 0, 1, 2, 		2, 1, 1, 1, 		2, 2, 1, 0, // J
	0, 0, 1, 1, 		2, 1, 1, 0, 		2, 2, 1, 1, 		0, 1, 1, 2, // S
};

// 9怓偩偲丄wcol[9]偑晄惓側抣偵側偭偰偄傞偺偱10怓偵廋惓#1.60c7k6
// 偙傟偑[]偑愒偵壔偗傞尨場偩偭偨傢偗偩偑
//int	wcol[20] = {0, 5, 2, 3, 1, 7, 6, 4, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
int	wcol[7] = {5,2,3,1,7,6,4};

/*
0>>3:(-1, 0)>(+2, 0)>(-1, -2)>(+2, +1)  0>>1:(-2, 0)>(+1, 0)>(+1, -2)>(-2, +1)
3>>2:(-2, 0)>(+1, 0)>(+1, -2)>(-2, +1)  1>>2:(+2, 0)>(-1, 0)>(-1, -2)>(+2, +1)
2>>1:(-2, 0)>(+1, 0)>(-2, -1)>(+1, +1)  2>>3:(+2, 0)>(-1, 0)>(+2, -1)>(-1, +1)
1>>0:(+2, 0)>(-1, 0)>(+2, -1)>(-1, +2)  3>>0:(-2, 0)>(+1, 0)>(-2, -1)>(+1, +2)
*/

// I宆僽儘僢僋暻廟傝僥乕僽儖乮4岓曗亊4曽岦亊2夞揮亊2曗惓嵗昗乯
/*
int iBlockKickTable[4 * 4 * 2 * 2] = {
	// 嵍夞揮
	-1, 0,		 2, 0,		-1, -2,		 2, 1,		// 0>>3
	 2, 0,		-1, 0,		 2, -1,		-1, 2,		// 1>>0
	-2, 0,		 1, 0,		-2, -1,		 1, 1,		// 2>>1
	-2, 0,		 1, 0,		 1, -2,		-2, 1,		// 3>>2

	// 塃夞揮
	-2, 0,		 1, 0,		 1, -2,		-2, 1,		// 0>>1
	 2, 0,		-1, 0,		-1, -2,		 2, 1,		// 1>>2
	 2, 0,		-1, 0,		 2, -1,		-1, 1,		// 2>>3
	-2, 0,		 1, 0,		-2, -1,		 1, 2		// 3>>0
};
*/

// 嵍夞揮偺応崌偼丄朹偑忋傊偡偭傐敳偗傞傎偆偑桪愭
// 塃夞揮偺応崌偼丄朹偑壓偵廂傑傞傎偆偑桪愭
int iBlockKickTable[4 * 4 * 2 * 2] = {
	// 嵍夞揮
	-1, 0,		 2, 0,		-1, -2,		 2, 1,		// 0>>3
	 2, 0,		-1, 0,		 2, -1,		-1, 2,		// 1>>0
	-2, 0,		 1, 0,		-2, -1,		 1, 1,		// 2>>1
	-2, 0,		 1, 0,		 1, -2,		-2, 1,		// 3>>2

	// 塃夞揮
	-2, 0,		 1, 0,		-2, 1,		 1, -2,		// 0>>1
	 2, 0,		-1, 0,		 2, 1,		-1, -2,		// 1>>2
	 2, 0,		-1, 0,		-1, 1,		 2, -1,		// 2>>3
	-2, 0,		 1, 0,		 1, 2,		-2, -1		// 3>>0
};
// SRS-X愱梡丂180搙夞揮暻廟傝僥乕僽儖乮I埲奜乯
// 嬼悢斣崋偼2夞180亱夞揮偡傟偽尦偺埵抲偵栠傞乮偐傕偟傟側偄乯偑丄
// 婏悢斣崋偼壓傊偺曗惓偑桪愭偝傟傞乮偐傕偟傟側偄乯
int otherBlock180KickTable[11 * 2 * 4] ={
	 1, 0,   2, 0,   1, 1,   2, 1,  -1, 0,  -2, 0,  -1, 1,  -2, 1,   0,-1,   3, 0,  -3, 0,		// 0>>2劅劉
	 0, 1,   0, 2,  -1, 1,  -1, 2,   0,-1,   0,-2,  -1,-1,  -1,-2,   1, 0,   0, 3,   0,-3,		// 1>>3劅劑劉
	-1, 0,  -2, 0,  -1,-1,  -2,-1,   1, 0,   2, 0,   1,-1,   2,-1,   0, 1,  -3, 0,   3, 0,		// 2>>0劅劊劆
	 0, 1,   0, 2,   1, 1,   1, 2,   0,-1,   0,-2,   1,-1,   1,-2,  -1, 0,   0, 3,   0,-3		// 3>>1劅劅劊
};

// SRS-X愱梡丂180搙夞揮暻廟傝僥乕僽儖乮I乯
// 傗傝曽師戞偱偼嬃堎偺暻旘偽偟丄暻敳偗偑壜擻ww
int iBlock180KickTable[11 * 2 * 4] ={
	 -1, 0,  -2, 0,   1, 0,   2, 0,   0, 1,    0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
	  0, 1,   0, 2,   0,-1,   0,-2,  -1, 0,    0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
	  1, 0,   2, 0,  -1, 0,  -2, 0,   0,-1,    0,0, 0,0, 0,0, 0,0, 0,0, 0,0,
	  0, 1,   0, 2,   0,-1,   0,-2,   1, 0,    0,0, 0,0, 0,0, 0,0, 0,0, 0,0
};
// player: 僾儗僀儎乕斣崋
// kickm : 愙抧忬懺偱堏摦偱偒傞夞悢
// kickr : 愙抧忬懺偱夞揮偱偒傞夞悢
void statWMove(int player, int kickm, int kickr) {
	int		bak, bottom, move, don, flash, kosa, rolling ,synchro,landing, fsmooth;
	int		mx, my, sx[11], sy[11], i, k, l;
	int		j,lockT;

	fsmooth = 0;
	don = 0;
	synchro = 0;
	landing = 0;
	if((repversw >= 35) && (kickm != -1)) kickm++;
	hiddenProc (player);

	if(!statc[player * 10 + 2]) {
		padRepeat (player);
		
		// Hold
		if((repversw >= 64) && (!statc[player * 10 + 6])){
			doHold(player, 0);
			// HOLD偟偰僎乕儉僆乕僶乕偵側偭偨応崌偼偙偙偱巭傔傞 #1.60c7m2
			if(stat[player] == 7) return;
		}

		bs[player] = bs[player] + sp[player];
		
		lockT = wait3[player];
		if(isboost[player]){
			bs[player] = 1200;
			if((sp[player] >= 1200) && (gameMode[player] != 6))
				lockT = wait3[player] / 2;
		}

		// spawn_y_type偑1偺応崌偺20G #1.60c7s2
		if( (spawn_y_type) && (sp[player] >= 1200) ) bs[player] = 1320;
		
		// Hold
		if(repversw < 35){
			doHold(player, 0);
			// HOLD偟偰僎乕儉僆乕僶乕偵側偭偨応崌偼偙偙偱巭傔傞 #1.60c7m2
			if(stat[player] == 7) return;
		}
		
		// 儘乕儖儘乕儖張棟 #1.60c7j5
		rolling = 0;
		if(isrollroll[player]) {
			// 夞傞僞僀儈儞僌傪乽僗僥乕僕僞僀儉偑30僼儗乕儉偱妱傝愗傟傞乿帪偵曄峏 #1.60c7m5
			if((ending[player] == 2) && (repversw >= 44)){
				/* 僄儞僨傿儞僌丒儘乕儖 */
				if( edrec[player] % p_rollroll_timer == 0 )
					rolling = 1;
			} else if( gameMode[player] == 6 ) {
				/* TOMOYO */
				//僗僥乕僕20埲崀乮僗僥乕僕僞僀儉柍偟乯
				if((repversw >= 44) && (stage[player] > 19) && (ltime[player] % p_rollroll_timer == 0))
					rolling = 1;
				//僗僥乕僕19傑偱
				else if( stime[player] % p_rollroll_timer == 0 )
					rolling = 1;
			} else if( (gameMode[player] >= 4) || (item_mode[player]) ) {
				/* VERSUS / PRACTICE / MISSION */
				if( time[player] % p_rollroll_timer  == 0 )
					rolling = 1;
			}
		}

		// 夞揮
		// 夞揮曽岦媡揮愝掕懳墳#1.60c7f8
		if((statc[player * 10 + 6] != 0) && (repversw >= 59))
			move = 0;
		else if(w_reverse)
			move = (getPushState(player , 4) || getPushState(player , 6) || rolling) - (getPushState(player , 5));
		else
			move = (getPushState(player , 5) || rolling) - (getPushState(player , 4) || getPushState(player , 6));
		if((rots[player] == 7) && (getPushState(player , 6) != 0) && (repversw >= 23) && (statc[player * 10 + 6] == 0)) move = 2;
		if((move != 0 ) && (isrotatelock[player] == 0)) {
				bak = (rt[player] + move);
				if(istrance[player]){
					do{
						k = rand(7,player);
						setNextBlockColors(player, 1);
					}while(k == blk[player]);
				}else{
					k = blk[player];
				}
				mx = 0; my = 0;
			if(move < 2){
				if(bak < 0) bak = 3;
				if(bak > 3) bak = 0;
			}else{
				if(bak > 3) bak = bak - 4;
				if(bak < 0) bak = bak + 4;
			}
			if((repversw >= 35) && (judgeBlock (player, bx[player], by[player] + 1, blk[player], rt[player]) != 0)) landing = 1;
			if(judgeBlock (player, bx[player], by[player], k, bak) == 0) {
				if(rotate_snd) PlaySE(4);	// 夞揮壒愝掕#1.60c7f7
				rt[player] = bak;
				blk[player] = k;
				synchro = 1;
				if(istrance[player])
					c_cblk_r[player] = wcol[k];
				
				// 夞揮偝偣偨夞悢+1 #1.60c7s6
				statc[player * 10 + 5]++;
			} else if((!disable_wallkick) && (heboGB[player]==0)) {	// 夞傜側偐偭偨傜
				if(move == 2){	// SRS-X 180亱夞揮偺帪
//					j = (move > 0) * 88;
					if(blk[player] != 0){
						for(i = 0; i < 11; i++) {
							sx[i] = otherBlock180KickTable[ (i * 2) + (rt[player] * 22) ];
							sy[i] = otherBlock180KickTable[ (i * 2) + (rt[player] * 22) + 1 ];
						}
					}else {
						for(i = 0; i < 11; i++) {
							sx[i] = iBlock180KickTable[ (i * 2) + (rt[player] * 22) ];
							sy[i] = iBlock180KickTable[ (i * 2) + (rt[player] * 22) + 1 ];
						}
					}
				}else if(blk[player] != 0) {	//	I埲奜偺帪
					/*
					1>>0, 2: (+1, 0)>(+1, +1)>(0, -2)>(+1, -2)
					3>>0, 2: (-1, 0)>(-1, +1)>(0, -2)>(-1, -2)
					0, 2>>1: (-1, 0)>(-1, -1)>(0, +2)>(-1, +2)
					0, 2>>3: (+1, 0)>(+1, -1)>(0, +2)>(+1, +2)
					*/
					sx[0] = co(((rt[player]==1)||(bak==3)), 1, -1);
					sy[0] = 0;
					sx[1] = sx[0];
					sy[1] = co(rt[player]%2, 1, -1);
					sx[2] = 0;
					sy[2] = sy[1]*(-2);
					sx[3] = sx[0];
					sy[3] = sy[2];
				} else {		//	I偺帪
					if(world_i_rot) {
						/*
						旕嵍塃懳徧僶乕僕儑儞 #1.60c7r7
						
						嵍夞揮                                  塃夞揮
						0>>3:(-1, 0)>(+2, 0)>(-1, -2)>(+2, +1)  0>>1:(-2, 0)>(+1, 0)>(+1, -2)>(-2, +1)
						3>>2:(-2, 0)>(+1, 0)>(+1, -2)>(-2, +1)  1>>2:(+2, 0)>(-1, 0)>(-1, -2)>(+2, +1)
						2>>1:(-2, 0)>(+1, 0)>(-2, -1)>(+1, +1)  2>>3:(+2, 0)>(-1, 0)>(+2, -1)>(-1, +1)
						1>>0:(+2, 0)>(-1, 0)>(+2, -1)>(-1, +2)  3>>0:(-2, 0)>(+1, 0)>(-2, -1)>(+1, +2)
						*/
						
						j = (move > 0) * 32;
						
						for(i = 0; i < 4; i++) {
							sx[i] = iBlockKickTable[ (i * 2) + (rt[player] * 8) + j ];
							sy[i] = iBlockKickTable[ (i * 2) + (rt[player] * 8) + j + 1 ];
							
							//sprintf(string[0], "move:%d no:%d rt:%d sx:%d sy:%d", move, i, rt[player], sx[i], sy[i]);
							//InnerLogMes(string[0]);
						}
					} else {
						/*
						0>>1:(-2, 0)>(+1, 0)>(+1, -2)>(,)         2>>3:(-1, 0)>(+2, 0)>(+2, -1)>(,)
						2>>1:(+1, 0)>(-2, 0)>(-2, -1)>(,)         0>>3:(+2, 0)>(-1, 0)>(-1, -2)>(,)
						1>>2:(-1, 0)>(+2, 0)>(-1, -2)>(+2, +1)    3>>2:(+1, 0)>(-2, 0)>(+1, -2)>(-2, +1)
						1>>0:(-1, 0)>(+2, 0)>(+2, -1)>(-1, +2)    3>>0:(+1, 0)>(-2, 0)>(-2, -1)>(+1, +2)
						*/
						sx[0] = co(((rt[player]==3)||(bak == 1)), 1, -1);
						sy[0] = 0;
						sx[1] = sx[0]*(-2);
						sy[1] = 0;
						sx[2] = co((rt[player]+bak==3), co(sx[0]==1, -2, -1), co(sx[0]==1, 1, 2));
						sy[2] = co(sx[2]%2, -2, -1);
						sx[3] = (rt[player]%2)*co(bak, sx[0], sx[1]);
						sy[3] = (rt[player]%2)*co(bak, 1, 2);
						if(rt[player] == 0) {		// 忬懺0偐傜偺夞揮帪偩偗廋惓
							i = sx[0]; sx[0] = sx[1]; sx[1] = i;
						}
					}
				}
				
				// BIG偱偼曗惓検傪2攞偡傞 #1.60c7m6
				if(IsBig[player]) {
					for(i = 0; i < 4+(7*((move == 2) && (repversw >= 48))); i++) {
						sx[i] = sx[i] * 2;
						sy[i] = sy[i] * 2;
					}
				}
				
				for(i = 0; i < 4+(7*(move == 2)); i++) {
					if(judgeBlock (player, bx[player]+sx[i], by[player]+sy[i], k, bak) == 0) {
						mx = sx[i];
						my = sy[i];
						break;
					}
				}
			}

			if(mx || my) {
				if(rotate_snd) {
					PlaySE(4);	// 夞揮壒愝掕#1.60c7f7
				}
				if(move == 2) PlaySE(0);
				bx[player] = bx[player] + mx;
				by[player] = by[player] + my;
				rt[player] = bak;
				blk[player] = k;
				synchro = 1;
				if(istrance[player])
					c_cblk_r[player] = wcol[k];
				
				// 夞揮偝偣偨夞悢+1 #1.60c7s6
				statc[player * 10 + 5]++;
			}
			l = judgeBlock (player, bx[player], by[player] + 1, blk[player], rt[player]);
			if((rt[player] == bak) && ((l != 0) || ((landing) && (repversw >= 35))) && (heboGB[player]==0)) {
				if(repversw < 40) kickc[player]++;	// 愙抧偟偨忬懺偱偺夞揮夞悢傪僇僂儞僩
				else kickc3[player]++;
				if((world_drop_snd != 0) && (world_drop_snd != 3) && (l != 0))
					PlaySE(1);
				if((((kickc[player] < kickm) || (kickm == -1)) && (repversw < 40)) || (kickc3[player] < kickr) || (kickr == -1)) {
					bk[player] = 0;		// 屌掕帪娫儕僙僢僩
				}
				// T-SPIN尃棙妉摼 #1.60c7n6
				if((blk[player] == 4 )&&(tspin_type >0)) tspin_flag[player] = 1;
			}
		}

		//	嵍塃偵堏摦
				move = getPressState(player , 3) - getPressState(player , 2);
		if(isLRreverse[player]) move = 0 - move;
		if( move && (statc[player * 10 + 4] != 0) ) {
			/* 僗儉乕僘帪偺昞帵堎忢傪廋惓 via C++ Port */
			if ( smooth && (sp[player] < 60) )
			{
				// drawCBlock (player, blk[player] + 1, 5, bs[player] * 8 / 60, 0, 1);
			}
			else
			{
				drawCBlock (player, blk[player] + 1, 5, 0, 0, 1);
			}
			// BIG帪丄2儅僗扨埵儌乕僪偺応崌偼堏摦検傪2攞偡傞 #1.60c7m6
			if(IsBig[player] && BigMove[player]) move = move * 2;
			if((repversw >= 35) && (judgeBlock (player, bx[player], by[player] + 1, blk[player], rt[player]) != 0)) landing = 1;
			if((mpc[player] == 1) || (mpc[player] >= waitt[player]) || ( (rots[player] == 6) && (mpc[player] >= 10 - (repversw >= 64)) && (repversw >= 19) ) || ((isremote[player])&&(gameMode[player] != 4)))
				if(judgeBlock (player, bx[player] + move, by[player], blk[player], rt[player]) == 0) {
					bx[player] = bx[player] + move;
					if(movesound) PlaySE(5);	// 堏摦壒愝掕偑斀塮偝傟側偄偺傪廋惓#1.60c7f7
					l = judgeBlock (player, bx[player], by[player] + 1, blk[player], rt[player]);
					if(((l != 0) || ((landing) && (repversw >= 35))) && (heboGB[player]==0)) {	// 墶堏摦偱傕屌掕帪娫儕僙僢僩
						if((!synchro) || (repversw < 35)) kickc[player]++;
						if((world_drop_snd != 0) && (world_drop_snd != 3) && (l != 0))
							PlaySE(1);
						if((kickc[player] < kickm) || (kickm == -1)) {
							bk[player] = 0;
						}
					}
					if(!synchro) tspin_flag[player] = 0;	// 僔儞僋儘偱側偄側傜T-SPIN尃棙攳扗 #1.60c7n6
				}
		}
		synchro = 0;

//		statc[player * 10 + 4] = 1; 				 // 嵟弶偺1僼儗乕儉偼堏摦偝偣側偄僝

		if(!nanameallow) move = 0;

		//	伀傪棧偟偰偄傞丄傑偨偼downtype偑0偺応崌丄壓擖傟惂尷夝彍#1.60c7f9
		if((!getPressState(player, 1-(1*(isUDreverse[player])))) || (!downtype)) down_flag[player] = 0;
		if((!getPressState(player, 0+(1*(isUDreverse[player])))) || (!downtype) || (repversw < 12)) up_flag[player] = 0;
		
		//	崅懍棊壓!! 壓擖傟夵憿#1.60c7f9
		if((!move) && getPressState(player , 1-(1*(isUDreverse[player]))) && ((sp[player] < 60) || ((rots[player] == 7) && (repversw >= 44))) && (!down_flag[player]) && ((statc[player * 10 + 4]) || (repversw < 27))) {
			if((heboGB[player])&& (repversw >= 52)){
				bs[player] = bs[player] + 20;//1/3G
			}else if(((rots[player] == 3) || (rots[player] == 6)) && (repversw >= 20)){
				bs[player] = bs[player] + 30;		//ACE-SRS偲DS-WORLD偺崅懍棊壓傪抶偔
			}else{
				if((rots[player] == 7) && (repversw >= 44)) bs[player] = bs[player] + 90;
				else bs[player] = 61;
			}
			if((gameMode[player]>=9)||((gameMode[player]==6)&&(anothermode[player]==4))||((gameMode[player]==7)&&(anothermode[player]==3))){
					sc[player]++;//捈擖傟
			}else{
				qdrop[player]++;	//抶偄暘偺僪儘僢僾儃乕僫僗敿尭偼丄僗僐傾寁嶼帪偵
			}
		}
		
		if((ismagnetblock[player]) && (repversw >= 41)) bs[player] = bs[player] + 30;

		for(bottom = by[player]; judgeBlock (player, bx[player], bottom, blk[player], rt[player]) == 0; bottom++);

		//	抧柺偵偔偭偮偄偨
		if((judgeBlock (player, bx[player], by[player] + 1, blk[player], rt[player]) != 0)) {

			if((ismagnetblock[player] == 1) || ((kickc[player] >= kickm) && (kickm != -1) && (rots[player] != 6) && (repversw >= 30)) ||
			((kickc3[player] >= kickr) && (kickr != -1) && (rots[player] != 6)))
				bk[player] = 100;
				
			bs[player] = 0;
			if((bk[player] == 0) && (smooth)) don = 1;

			if(lockT != 99) // 愙拝99張棟丂#1.60c7
				bk[player]++;
			else
				bk[player] = 98;

			// 壓擖傟夵憿#1.60c7f9
			if((getPressState(player , 1-(1*(isUDreverse[player])))) && (!down_flag[player]) 
						&& (statc[player * 10 + 4] || (repversw < 27)) && (!move || nanamedown))
				if((rots[player] == 7) || (heboGB[player]!=0))	// SRS-X懄愙拝
					bk[player] = 100;
				else
					bk[player] = bk[player] + 1 + ((rots[player] == 2) && (repversw >= 30) && (!nanamedown));
			
			// 忋擖傟懄愙拝
			if( ( (getPressState(player , 0+(1*(isUDreverse[player]))) && (repversw >= 43)) ||
				  (getPushState(player , 0+(1*(isUDreverse[player]))) && (repversw < 43)) )
				 && (rots[player] != 7) && ( (repversw <= 13) || !up_flag[player] ) && (heboGB[player]==0) 
				 && (statc[player * 10 + 4] || (repversw < 27)) && (!move || nanamedown)) {
				bk[player] = bk[player] + lockT;
				if((rots[player] == 3) || (rots[player] == 6))	//ACE-SRS偼愱梡偺SE傪柭傜偡
					PlaySE(44);
				
				// 忋擖傟惂尷捛壛 #1.60c7q8
				if( downtype && (repversw >= 14) && (repversw < 54)) up_flag[player] = 1;
			}
			
			if((bk[player] > lockT) || ((kickc[player] > kickm) && (kickm != -1)) || ((kickc3[player] > kickr) && (kickr != -1))) {
				if(heboGB[player]==0)
					PlaySE(3);
				else if(heboGB[player] == 1)
					PlaySE(1);
				kickc[player] = 0;
				kickc3[player] = 0;
				statc[player * 10 + 2] ++;
				drawCBlock (player, 0, 0, 0, 10, 0);
				// 壓擖傟惂尷#1.60c7f9
				if((getPressState(player , 1-(1*(isUDreverse[player])))) && (downtype) && (!move || nanamedown)) down_flag[player] = 1;
				if((repversw >= 57) && (rots[player] != 6)) goto lockflash;	// SUPER側SKIP
				return;
			}
		} else {
			// T.L.S. (Temporary Landing System)  (c)1998 AR仠KA(^^;
			// 暿娭悢偵撈棫 #1.60c7k4
			drawTLSBlock(player, bottom);
			
			// 忋僉乕偱堦弖偱棊壓&屌掕
			// 忋擖傟惂尷捛壛 #1.60c7p1
			if(getPressState(player , 0+(1*(isUDreverse[player]))) && (!move) && (!sonicdrop) && (!up_flag[player]) && (heboGB[player]==0) && ((statc[player * 10 + 4]) || (repversw < 27))) {
				if(rots[player] != 7){
					if(gameMode[player]==10){//15%
						sc[player] = sc[player] + ( bottom - by[player] - 1 ) * 23 / 20;
					}else if((gameMode[player]>=9)||((gameMode[player]==6)&&(anothermode[player]==4))||((gameMode[player]==7)&&(anothermode[player]==3))){
						sc[player] = sc[player]+(bottom -by[player] -1) *2;//捈擖傟
					}else{
						sdrop[player] = (bottom -by[player] -1) *2;//堦扷sdrop傊擖傟傞
					}
					if(!block_spectrum){
						by[player] = bottom - 1;
					}else{	//巆憸傪昤夋
						/* 巆憸奐巒埵抲傪僗儉乕僘抧揰偵偡傞 via C++ Port */
						fsmooth = 0;
						if ( smooth && (sp[player] < 60) )
						{
							/* 1僼儗乕儉偩偗 */
							fsmooth = bs[player] * 8 / 60;
						}

						while(by[player] != bottom - 1){
							drawCBlock (player, blk[player] + 1, 4, fsmooth, 0, 1);
							by[player]++;
							fsmooth = 0;
						}
					}
					if((world_drop_snd == 1) || ((world_drop_snd == 3) && (rots[player] != 2)) || (rots[player] == 3) || (rots[player] == 6)) PlaySE(1);
					PlaySE(3);
					if((rots[player] == 3) || (rots[player] == 6))	//ACE-SRS偼愱梡偺SE傪柭傜偡
						PlaySE(44);
					kickc[player] = 0;
					kickc3[player] = 0;
					statc[player * 10 + 2] ++;
					drawCBlock (player, 0, 0, 0, 10, 0);
					if((downtype) && (repversw < 54)) up_flag[player] = 1;
					statc[player * 10 + 5] = 0;	// 夞揮偝偣偨悢儕僙僢僩 #1.60c7s6
					if((repversw >= 57) && (rots[player] != 6)) goto lockflash;	// SUPER側SKIP
					return;
				}
				else {	//SRS-X
					if((sp[player] <= 240) && (!ending[player])) {
						if((gameMode[player]>=9)||((gameMode[player]==6)&&(anothermode[player]==4))||((gameMode[player]==7)&&(anothermode[player]==3))){
							sc[player] = sc[player]+(bottom -by[player] -1) *2;//捈擖傟
						}else{
							sdrop[player] = (bottom -by[player] -1) *2;//堦扷sdrop傊擖傟傞
						}
					}
//					PlaySE(44);
					if(!block_spectrum){
						by[player] = bottom - 1;
					}else{	//巆憸傪昤夋
						while(by[player] != bottom - 1){
							drawCBlock (player, blk[player] + 1, 4, 0 , 0, 1);
							by[player]++;
						}
					}
					bs[player] = 0;
					bk[player] = 0;
					if(!smooth) don = 1;
					if((downtype) && (repversw < 54)) up_flag[player] = 1;
					statc[player * 10 + 5] = 0;	// 夞揮偝偣偨悢儕僙僢僩 #1.60c7s6
				}
			}

			while(bs[player] > 60) {
				bk[player] = 0;
				tspin_flag[player] = 0;	// T-SPIN尃棙攳扗 #1.60c7o9
				
				bs[player] = bs[player] - 60;
				
				// BIG帪丄2儅僗扨埵儌乕僪偺応崌偼棊偪傞検傪2攞偡傞 #1.60c7m6
				// 3儅僗棧傟偰偄偰傕愙抧偟偰偟傑偆偺傪廋惓 #1.60c7o9
				if( (judgeBlock(player, bx[player], by[player] + 1, blk[player], rt[player]) == 0)
				 || (judgeBlock(player, bx[player], by[player] + 1 + (IsBig[player] && BigMove[player] && !ybigtype), blk[player], rt[player]) == 0) )
				{
					if((block_spectrum) && ((!smooth) || (bs[player] >= 60)) && (heboGB[player]==0))	//巆憸傪昤夋
						drawCBlock (player, blk[player] + 1, 5, 0 , 0, 1);
					by[player] = by[player] + 1 + (IsBig[player] && BigMove[player] && !ybigtype);
				}
				
				// 抧柺偵偔偭偮偄偨
				if(judgeBlock(player, bx[player], by[player] + 1, blk[player], rt[player])) {
					by[player] = bottom - 1;
					bs[player] = 0;
					if(!smooth) don = 1;
					
					if((ismagnetblock[player] == 1) || ((kickc[player] >= kickm) && (kickm != -1) && (rots[player] != 6) && (repversw >= 30)) ||
					((kickc3[player] >= kickr) && (kickr != -1) && (rots[player] != 6)))
						bk[player] = 100;
					
					// 壓僉乕偱屌掕懍搙傾僢僾 #1.60c7r3
					if( getPressState(player, 1-(1*(isUDreverse[player]))) && (!down_flag[player]) && (repversw >= 15) 
							&& (statc[player * 10 + 4] || (repversw < 27)) && (!move || nanamedown)) {
						if((rots[player] != 7) && (heboGB[player]==0)) bk[player] = bk[player] + 1 + ((rots[player] == 2) && (repversw >= 30) && (!nanamedown));
						else {	// SRS-X懄屌掕
							PlaySE(1);
							if(heboGB[player]==0)
								PlaySE(3);
							kickc[player] = 0;
							kickc3[player] = 0;
							statc[player * 10 + 2]++;
							drawCBlock (player, 0, 0, 0, 10, 0);
							if(downtype) down_flag[player] = 1;
							if((repversw >= 57) && (rots[player] != 6)) goto lockflash;	// SUPER側SKIP
							return;
						}
					}
					
					// 忋擖傟懄愙拝 #1.60c7r3
					if( ( (getPressState(player , 0+(1*(isUDreverse[player]))) && (repversw >= 43)) ||
						  (getPushState(player , 0+(1*(isUDreverse[player]))) && (repversw < 43)) )
						&& (rots[player] != 7) &&(!up_flag[player]) && (repversw >= 15) && (heboGB[player]==0) 
						&& (statc[player * 10 + 4] || (repversw < 27)) && (!move || nanamedown)) {
						PlaySE(3);
						if((rots[player] == 3) || (rots[player] == 6))	//ACE-SRS偼愱梡偺SE傪柭傜偡
							PlaySE(44);
						kickc[player] = 0;
						kickc3[player] = 0;
						statc[player * 10 + 2]++;
						drawCBlock (player, 0, 0, 0, 10, 0);
						if(downtype) up_flag[player] = 1;
						if((repversw >= 57) && (rots[player] != 6)) goto lockflash;	// SUPER側SKIP
						if(repversw >= 57) return;
					}
				} else {
					// 夞揮偝偣偨悢儕僙僢僩 #1.60c7s6
					statc[player * 10 + 5] = 0;
				}
			}
		}

		statc[player * 10 + 4] = 1; 				 // 嵟弶偺1僼儗乕儉偼堏摦偝偣側偄僝
				
		// 愙抧壒傪柭傜偡
		// world_drop_snd偑1偺応崌偺傒 #1.60c7m9
		if( (don) && (world_drop_snd >= 1) && (heboGB[player]!=1) ) PlaySE(1);
			
		// 僽儘僢僋傪昤偔
		flash = (count % 2) * (blockflash == 0) + (blockflash == 1);
		kosa = bk[player] * 7 / (lockT + (lockT == 0));
		if(kosa > 6) kosa = 6;
		if(smooth && (sp[player] < 60))
			drawCBlock (player, blk[player] + 1, kosa, bs[player] * 8 / 60 , flash, 0);
		else
			drawCBlock (player, blk[player] + 1, kosa, 0 , flash, 0);
			
		if((repversw >= 35) && (repversw < 64) && (!statc[player * 10 + 2]) && (!statc[player * 10 + 6])){
			 doHold(player, 0);
			// HOLD偟偰僎乕儉僆乕僶乕偵側偭偨応崌偼偙偙偱巭傔傞 #1.60c7m2
			if(stat[player] == 7) return;
		}
		
		statc[player * 10 + 6] = 0;
		if((repversw >= 57) && (statc[player * 10 + 2] != 0)) goto lockflash;	// SUPER側SKIP
	} else {
		lockflash:
		statc[player * 10 + 2] ++;
		if((c_nblk[0 + player * 6] != 8) && (c_nblk[0 + player * 6] >= 0))drawCBlock (player, 0, 0, 0, 10, 0);
		
		// 伀傪棧偟偰偄傞応崌丄壓擖傟惂尷夝彍#1.60c7n6
		if((!getPressState(player, 1-(1*(isUDreverse[player])))) && (repversw >= 10)) down_flag[player] = 0;
		else if((downtype) && (repversw >= 54)) down_flag[player] = 1;
		if(!getPressState(player, 0+(1*(isUDreverse[player])))) up_flag[player] = 0;
		else if((downtype) && (repversw >= 54)) up_flag[player] = 1;
		
		if(statc[player * 10 + 2] > 2 - (repversw >= 9)) {	// 愙拝帪偺奃怓壔傪1僼儗抁弅 #1.60c7k8
			setBlock (player, bx[player], by[player], blk[player], rt[player]);
			if(stat[player] == 7) return;
			
			ndelay[player] = 1;
			
			lc[player]++;
			
			// T-SPIN妉摼 #1.60c7s6
			//3-僐乕僫乕僠僃僢僋(僗儔僀僪偺傗偮偼偡偱偵僠僃僢僋偝傟偰傞)
			if((tspin_flag[player]) && (blk[player] == 4) && ((tspin_type>=2) || (gameMode[player] == 8)) && (statc[player * 10 + 5] > 0) && (isTSpin(player) >= 3) ) {
				PlaySE(34);
				tspin_c[player] = 120;
				tspin_flag[player] = 2;
				last_tspin[player] = 0;
			} else if((tspin_type==2) || (gameMode[player] == 8)){
				tspin_flag[player] = 0;
			}
			
			lc[player]++;
			
			// TGMLV忋徃偼statBlock偵堏揮偟傑偟偨#1.60c7i7
			if(ending[player] == 0) {
				// 僽儘僢僋傪拝彴偝偣偨夞悢 #1.60c7i2
				bdowncnt[player]++;
				st_bdowncnt[player]++;
				if((gameMode[player] == 3) && (devil_nextrise[player] >= 0) && (devil_randrise)) {
					devil_nextrise[player]--;
				}
			}
			
			// 僄儞僨傿儞僌拞偺壴壩敪惗 #1.60c7s8
			if( (ending[player] == 2) && (gameMode[player] == 0) && (repversw <= 37)) {
				hanabi_total[player]++;
				hanabi_waiting[player]++;
			}
			// ACE僇僗僞儉幃IRS
			if((ace_irs == 2) && (repversw >= 35)) doIRS2plus(player);
			// 僽儘僢僋徚嫀敾抐偵傛傝1僼儗抁弅 #1.60c7k8
			if ((blockEraseJudge(player)) || (repversw < 9)) {
				stat[player] = 8;
				statc[player * 10] = 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;
				statc[player * 10 + 6] = 0;
				//僗僥乕僞僗曄峏偲摨帪偵師偺僗僥乕僞僗娭悢傪幚峴偡傞帠偱1僼儗抁弅丂C7V2.1
				if(repversw >= 54) statEraseBlock(player);
			} else {
				stat[player] = 6;
				statc[player * 10] = wait1[player];
				statc[player * 10 + 1] = 15;
				statc[player * 10 + 2] = 0;
				statc[player * 10 + 3] = 2 * (rots[player] != 6);
				statc[player * 10 + 4] = 0;
				statc[player * 10 + 5] = 0;
				statc[player * 10 + 6] = 0;

				cmbpts[player] = 0;
				combo[player] = 0;
				combo2[player] = 0;
				hanabi_combo[player] = 0;
				hebocombo[player] = 0;
				scrate[player] = 100;//ori儌乕僪梡偺僗僐傾儗乕僩
				pinchCheck(player);
				//僗僥乕僞僗曄峏偲摨帪偵師偺僗僥乕僞僗娭悢傪幚峴偡傞帠偱1僼儗抁弅丂C7V2.1
				if(repversw >= 54) statErase(player);
			}

			return;
		}
	}
	effect (player);
}


int	co(int a, int b, int c) {	// conditional op
	if(a) return b;
	else return c;
}
