//ind_player

let indexPlayer;
let CutinDifficulty = "Extra";

task TPracticeScene{
	let bEndScene = false;
	let pathTitle = dir ~ "./Image/menu.png";
	let pathPlayerI = dir ~ "./Image/player_menu.png";
	let SelectDifficulty = "Extra ->";
	CutinDifficulty = "Extra";

	let objTitleImage = ObjPrim_Create(OBJ_SPRITE_2D); 
	Obj_SetRenderPriorityI(objTitleImage, 20);
	ObjPrim_SetTexture(objTitleImage, pathTitle);
	ObjSprite2D_SetSourceRect(objTitleImage, 0, 0, 800, 600);
	ObjSprite2D_SetDestRect(objTitleImage, 0, 0, 640, 480);
	ObjRender_SetAlpha(objTitleImage,120);
	
	let objReimu = ObjPrim_Create(OBJ_SPRITE_2D); 
	Obj_SetRenderPriorityI(objReimu, 21);
	ObjPrim_SetTexture(objReimu, pathPlayerI);
	ObjSprite2D_SetSourceRect(objReimu, 0, 0, 190, 240);
	ObjSprite2D_SetDestCenter(objReimu);
	ObjRender_SetPosition(objReimu,160,365,0);
	ObjRender_SetAlpha(objReimu,0);
	
	let objMarisa = ObjPrim_Create(OBJ_SPRITE_2D); 
	Obj_SetRenderPriorityI(objMarisa, 21);
	ObjPrim_SetTexture(objMarisa, pathPlayerI);
	ObjSprite2D_SetSourceRect(objMarisa, 190, 0, 380, 240);
	ObjSprite2D_SetDestCenter(objMarisa);
	ObjRender_SetPosition(objMarisa,160,365,0);
	ObjRender_SetAlpha(objMarisa,0);
	
	let objTitleText = ObjText_Create();
	ObjText_SetFontType(objTitleText,"Blogger Sans");
	ObjText_SetText(objTitleText, "Spellcard Practice");
	ObjText_SetFontSize(objTitleText, 50);
	ObjText_SetFontColorTop(objTitleText, 255, 255, 255);
	ObjText_SetFontColorBottom(objTitleText, 255, 255, 255);
	Obj_SetRenderPriorityI(objTitleText, 30);
	ObjRender_SetX(objTitleText, 20);
	ObjRender_SetY(objTitleText, 20);
	
	let objTextD = ObjText_Create();
	ObjText_SetFontType(objTextD,"Blogger Sans");
	ObjText_SetText(objTextD, SelectDifficulty);
	ObjText_SetFontSize(objTextD, 30);
	ObjText_SetFontColorTop(objTextD, 255, 255, 255);
	ObjText_SetFontColorBottom(objTextD, 255, 255, 255);
	Obj_SetRenderPriorityI(objTextD, 30);
	ObjRender_SetAlpha(objTextD,120);
	ObjRender_SetX(objTextD, 220);
	ObjRender_SetY(objTextD, 200);
	
	let objTextD2 = ObjText_Create();
	ObjText_SetFontType(objTextD2,"Blogger Sans");
	ObjText_SetText(objTextD2, "Difficulty:");
	ObjText_SetFontSize(objTextD2, 30);
	ObjText_SetFontColorTop(objTextD2, 255, 220, 220);
	ObjText_SetFontColorBottom(objTextD2, 255, 150, 150);
	Obj_SetRenderPriorityI(objTextD2, 30);
	ObjRender_SetX(objTextD2, 110);
	ObjRender_SetY(objTextD2, 200);

	let INDEX_REIMU_A = 0;
	let INDEX_REIMU_B = 1;
	let INDEX_REIMU_C = 2;
	let INDEX_MARISA_A = 3;
	let INDEX_MARISA_B = 4;
	let INDEX_MARISA_C = 5;
	let selectIndexPlayer = 0;

	task TMenuItem(let index, let mx, let my, let text){
		function CreateTextObject(let mx, let my, let text){
			let obj = ObjText_Create();
			ObjText_SetText(obj, text);
			ObjText_SetFontSize(obj, 30);
			ObjText_SetFontType(obj,"Blogger Sans");
			ObjText_SetFontColorTop(obj, 255, 255, 255);
			ObjText_SetFontColorBottom(obj, 255, 255, 255);
			Obj_SetRenderPriorityI(obj, 30);
			ObjRender_SetX(obj, mx);
			ObjRender_SetY(obj, my);
			return obj;}

		let scaleSS = 0;
		let objText = CreateTextObject(mx, my, text);
			loop(20){
				ObjRender_SetScaleX(objText,scaleSS);
				ObjRender_SetScaleX(objTextD,scaleSS);
				ObjRender_SetScaleX(objTextD2,scaleSS);
				ObjRender_SetScaleX(objTitleText,scaleSS);
			scaleSS+=0.05;yield;}

	let move1 = 0;
	let move2 = 0;
	let moveA = 0;
	let moveB = 0;

	let alphaR = 0;
	let alphaM = 0;
	let alphaD = 0;
	let alphaDmove = 0;
	
	while(!bEndScene){
		alphaD = 120+120*sin(alphaDmove);
		alphaDmove+=6;
		
		ObjRender_SetAlpha(objReimu,alphaR);
		ObjRender_SetAlpha(objMarisa,alphaM);
		ObjRender_SetAlpha(objTextD,alphaD);
		ObjText_SetText(objTextD, SelectDifficulty);
		
			alternative(selectIndexPlayer)
				case(INDEX_REIMU_A){alphaR+=6;alphaM-=8;}
				case(INDEX_REIMU_B){alphaR+=6;alphaM-=8;}
				case(INDEX_REIMU_C){alphaR+=6;alphaM-=8;}
			
				case(INDEX_MARISA_A){alphaR-=6;alphaM+=8;}
				case(INDEX_MARISA_B){alphaR-=6;alphaM+=8;}
				case(INDEX_MARISA_C){alphaR-=6;alphaM+=8;}
			if(alphaR <= 0){alphaR = 0;}
			if(alphaR >= 255){alphaR = 255;}
			if(alphaM <= 0){alphaM = 0;}
			if(alphaM >= 255){alphaM = 255;}
		
		if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH){
			SelectDifficulty = "Extra ->";}
		
		if(GetAreaCommonData("ULTRA","PATH",0)==1){
			if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH){
				SelectDifficulty = "<- Ultra Extra";}}
		
		if(index == selectIndexPlayer){
			ObjRender_SetAlpha(objText,255);
			ObjRender_SetPosition(objText,mx-move1,my,0);
			move2=0;moveB=0;
			move1=15*sin(moveA);
			if(move1<4){moveA+=10;}}
		else{
			ObjRender_SetAlpha(objText,155);
			ObjRender_SetPosition(objText,mx-move1+move2,my,0);
			move1=0;moveA=0;
			move2=4*sin(moveB);
			if(move2<4){moveB+=10;}}
		
		if(GetVirtualKeyState(VK_OK) == KEY_PUSH){
			SE(se_ok);
			loop(20){
				ObjRender_SetAlpha(objReimu,alphaR);
				ObjRender_SetAlpha(objMarisa,alphaM);
				ObjRender_SetScaleX(objText,scaleSS);
				ObjRender_SetScaleX(objTextD,scaleSS);
				ObjRender_SetScaleX(objTextD2,scaleSS);
				ObjRender_SetScaleX(objTitleText,scaleSS);
				alphaR-=13;alphaM-=13;
				scaleSS-=0.05;yield;}}
			
		if(GetVirtualKeyState(VK_CANCEL) == KEY_PUSH){
			SE(se_cancel);
			loop(20){
				ObjRender_SetAlpha(objReimu,alphaR);
				ObjRender_SetAlpha(objMarisa,alphaM);
				ObjRender_SetScaleX(objText,scaleSS);
				ObjRender_SetScaleX(objTextD,scaleSS);
				ObjRender_SetScaleX(objTextD2,scaleSS);
				ObjRender_SetScaleX(objTitleText,scaleSS);
				alphaR-=13;alphaM-=13;
				scaleSS-=0.05;yield;}}
		yield;}
		
	Obj_Delete(objReimu);
	Obj_Delete(objMarisa);
	Obj_Delete(objTextD2);
	Obj_Delete(objTextD);
	Obj_Delete(objText);}

	let mx = 220;
	let my = 290;
	let texts = ["Reimu Hakurei A","Reimu Hakurei B","Reimu Hakurei C","Marisa Kirisame A","Marisa Kirisame B","Marisa Kirisame C"];
	var countMenu = length(texts);
	ascent(var iText in 0 .. countMenu){
		TMenuItem(iText, mx, my, texts[iText]);
		my+=30;}

	while(GetVirtualKeyState(VK_OK) != KEY_FREE){yield;}

	let frameKeyHold = 0;
	loop{
		if(GetVirtualKeyState(VK_CANCEL) == KEY_PUSH){
			SE(se_cancel);
			let alpha = 120;
			loop(20){
				ObjRender_SetAlpha(objTitleImage,alpha);
				alpha+=255/20;yield;}
			Obj_Delete(objTitleImage);
			Obj_Delete(objTitleText);
			TTitleScene;
			bEndScene = true;
			return;}

		if(GetVirtualKeyState(VK_OK) == KEY_PUSH){
		let dirModule = GetModuleDirectory();
			if(selectIndexPlayer == INDEX_REIMU_A){
				indexPlayer = "Reimu Hakurei A";
				pathPlayer = dir ~ "Player/Reimu by plasmaflame22/Reimu_A.txt";
				wait(20); TSpellScene;}
				
			else if(selectIndexPlayer == INDEX_REIMU_B){
				indexPlayer = "Reimu Hakurei B";
				pathPlayer = dir ~ "Player/Reimu by plasmaflame22/Reimu_B.txt";
				wait(20); TSpellScene;}
				
			else if(selectIndexPlayer == INDEX_REIMU_C){
				indexPlayer = "Reimu Hakurei C";
				pathPlayer = dir ~ "Player/Reimu by plasmaflame22/Reimu_C.txt";
				wait(20); TSpellScene;}

			else if(selectIndexPlayer == INDEX_MARISA_A){
				indexPlayer = "Marisa Kirisame A";
				pathPlayer = dir ~ "Player/Marisa by plasmaflame22/Marisa_A.txt";
				wait(20); TSpellScene;}
				
			else if(selectIndexPlayer == INDEX_MARISA_B){
				indexPlayer = "Marisa Kirisame B";
				pathPlayer = dir ~ "Player/Marisa by plasmaflame22/Marisa_B.txt";
				wait(20); TSpellScene;}
				
			else if(selectIndexPlayer == INDEX_MARISA_C){
				indexPlayer = "Marisa Kirisame C";
				pathPlayer = dir ~ "Player/Marisa by plasmaflame22/Marisa_C.txt";
				wait(20); TSpellScene;}
			break;}

		if(GetVirtualKeyState(VK_UP) == KEY_PUSH){
			selectIndexPlayer--;
			SE(se_select);}
		else if(GetVirtualKeyState(VK_DOWN) == KEY_PUSH){
			selectIndexPlayer++;
			SE(se_select);}
		else if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH){
			CutinDifficulty = "Extra";
			SE(se_select);}
		else if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH){
			if(GetAreaCommonData("ULTRA","PATH",0)==0){
				SE(se_invalid);}
			else{SE(se_select);}}
		if(GetAreaCommonData("ULTRA","PATH",0)==1){
			if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH){
				CutinDifficulty = "Ultra";
				SE(se_select);}}

		else if(GetVirtualKeyState(VK_UP) == KEY_HOLD){
			frameKeyHold++;
			if(frameKeyHold == 30 || (frameKeyHold > 30 && (frameKeyHold % 10 == 0))){
				SE(se_select);
				selectIndexPlayer--;}}

		else if(GetVirtualKeyState(VK_DOWN) == KEY_HOLD){
			frameKeyHold++;
			if(frameKeyHold == 30 || (frameKeyHold > 30 && (frameKeyHold % 10 == 0))){
				SE(se_select);
				selectIndexPlayer++;}}

		else{frameKeyHold = -1;}
		if(selectIndexPlayer < 0) {selectIndexPlayer = countMenu-1;}
		else{selectIndexPlayer %= countMenu;}
		yield;}
	bEndScene = true;
	Obj_Delete(objTitleImage);
	Obj_Delete(objTitleText);
	Obj_Delete(objMarisa);
	Obj_Delete(objReimu);
	Obj_Delete(objTextD);}



task TSpellScene{
	let alpha = 0;
	let bEndTitleScene = false;

	let pathTitle = dir ~ "./Image/menu.png";
	let pathFire = dir ~ "./Image/firesheet.png";

	let objTitleImage = ObjPrim_Create(OBJ_SPRITE_2D); 
	Obj_SetRenderPriorityI(objTitleImage, 20);
	ObjPrim_SetTexture(objTitleImage, pathTitle);
	ObjSprite2D_SetSourceRect(objTitleImage, 0, 0, 800, 600);
	ObjSprite2D_SetDestRect(objTitleImage, 0, 0, 640, 480);
	ObjRender_SetAlpha(objTitleImage,120);

	let objTitleText = ObjText_Create();
	ObjText_SetFontType(objTitleText,"Blogger Sans");
	ObjText_SetText(objTitleText, "Spellcard Selection");
	ObjText_SetFontSize(objTitleText, 40);
	ObjText_SetFontColorTop(objTitleText, 255, 255, 255);
	ObjText_SetFontColorBottom(objTitleText, 255, 255, 255);
	Obj_SetRenderPriorityI(objTitleText, 30);
	ObjRender_SetX(objTitleText, 20);
	ObjRender_SetY(objTitleText, 20);

	let INDEX_START_SPELL0M = 0;
	let INDEX_START_SPELL1M = 1;
	let INDEX_START_SPELL2M = 2;
	let INDEX_START_SPELL0B = 3;
	let INDEX_START_SPELL1B = 4;
	let INDEX_START_SPELL2B = 5;
	let INDEX_START_SPELL3B = 6;
	let INDEX_START_SPELL4B = 7;
	let INDEX_START_SPELL5B = 8;
	let INDEX_START_SPELL6B = 9;
	let INDEX_START_SPELL7B = 10;
	let INDEX_START_SPELL8B = 11;
	let INDEX_START_SPELL9B = 12;

	let selectIndex = 0;

	task TMenuItem(let index, let mx, let my, let text){
		function CreateTextObject(let mx, let my, let text){
			let obj = ObjText_Create();
			ObjText_SetText(obj, text);
			ObjText_SetFontSize(obj, 25);
			ObjText_SetFontType(obj,"Blogger Sans");
			ObjText_SetFontColorTop(obj, 255, 255, 255);
			ObjText_SetFontColorBottom(obj, 255, 255, 255);
			Obj_SetRenderPriorityI(obj, 26);
			ObjRender_SetX(obj, mx);
			ObjRender_SetY(obj, my);
			return obj;}
			
		function CreateArrow(let mx, let my){
			let obja = ObjPrim_Create(OBJ_SPRITE_2D);
			ObjPrim_SetTexture(obja, pathFire);
			Obj_SetRenderPriorityI(obja, 25);
			ObjRender_SetScaleXYZ(obja,0.8,0.8,0);
			ObjRender_SetPosition(obja, mx, my, 0);
			ObjRender_SetAlpha(obja,0);
			task tManage{
				let animFrame = 0;let w = 3;
				while(!Obj_IsDeleted(obja)){
				ObjSprite2D_SetDestRect(obja,-38,-70,38,70);
					if(animFrame < w){ObjSprite2D_SetSourceRect(obja,0,8,76,148);}
					if(animFrame >= w && animFrame < w*3){ObjSprite2D_SetSourceRect(obja,82,8,158,148);}
					if(animFrame >= w*3 && animFrame < w*5){ObjSprite2D_SetSourceRect(obja,160,8,236,148);}
					if(animFrame >= w*5 && animFrame < w*7){ObjSprite2D_SetSourceRect(obja,230,8,306,148);}
					if(animFrame >= w*7 && animFrame < w*9){ObjSprite2D_SetSourceRect(obja,310,8,386,148);}
					if(animFrame >= w*9 && animFrame < w*11){ObjSprite2D_SetSourceRect(obja,388,10,464,150);}
					if(animFrame >= w*11 && animFrame < w*13){ObjSprite2D_SetSourceRect(obja,462,7,538,147);}
					if(animFrame >= w*13 && animFrame < w*15){ObjSprite2D_SetSourceRect(obja,544,8,620,148);}
					if(animFrame >= w*15){ObjSprite2D_SetSourceRect(obja,622,8,698,148);}
					if(animFrame>=w*17){animFrame=0;}
				animFrame++;yield;}}
			tManage;
			return obja;}

		let objText = CreateTextObject(mx, my, text);
		let objArrow = CreateArrow(mx-10,my-10);
		
		let scaleSS = 0;
		let alphaAR = 0;
		loop(20){
			if(index == selectIndex){
				ObjRender_SetAlpha(objArrow,alphaAR);}
			ObjRender_SetScaleX(objText,scaleSS);
			ObjRender_SetScaleX(objTitleText,scaleSS);
			scaleSS+=0.05;alphaAR+=255/20;yield;}

	let move1 = 0;
	let moveA = 0;
	let move2 = 0;
	let moveB = 0;
	let scale = 1;
		
	while(!bEndTitleScene){
		if(index == selectIndex){
			ObjRender_SetAlpha(objText,255);
			ObjRender_SetAlpha(objArrow,255);
			Obj_SetRenderPriorityI(objText,26);
			ObjRender_SetPosition(objText,mx-move1,my,0);
			move2=0;
			moveB=0;
			move1=15*sin(moveA);
			if(move1<4){moveA+=10;}}
		else{
			ObjRender_SetAlpha(objArrow,0);
			ObjRender_SetAlpha(objText,155);
			ObjRender_SetPosition(objText,mx-move1+move2,my,0);
			move1=0;
			moveA=0;
			move2=4*sin(moveB);
			if(move2<4){moveB+=10;}}

		if(GetVirtualKeyState(VK_OK) == KEY_PUSH){
			let alphaT = 120;
			loop(20){
				if(index == selectIndex){
					ObjRender_SetAlpha(objArrow,alphaAR);}
				ObjRender_SetAlpha(objTitleImage,alphaT);
				ObjRender_SetScaleX(objText,scale);
				ObjRender_SetScaleX(objTitleText,scale);
			scale-=0.0527;alphaAR-=255/10;alphaT-=120/20;yield;}
			Obj_Delete(objTitleImage);
			Obj_Delete(objArrow);
			Obj_Delete(objTitleText);
			Obj_Delete(objText);}
		if(GetVirtualKeyState(VK_CANCEL) == KEY_PUSH){
			loop(20){
				if(index == selectIndex){
					ObjRender_SetAlpha(objArrow,alphaAR);}
				ObjRender_SetScaleX(objText,scale);
				ObjRender_SetScaleX(objTitleText,scale);
				scale-=0.05;alphaAR-=255/20;yield;}}
		yield;}
	Obj_Delete(objTitleText);
	Obj_Delete(objText);
	Obj_Delete(objTitleImage);
	Obj_Delete(objArrow);}

	let mx = 80;
	let my = 75;
	
	let TextSpaceMS00 = "";
	let TextSpaceMS01 = "";
	let TextSpaceMS02 = "";
	let TextSpaceMS03 = "";
	let TextSpaceMS04 = "";
	let TextSpaceMS05 = "";
	let TextSpaceMS06 = "";
	let TextSpaceMS07 = "";
	let TextSpaceMS08 = "";
	let TextSpaceMS09 = "";
	let TextSpaceMS10 = "";
	let TextSpaceMS11 = "";
	let TextSpaceMS12 = "";
	let SpellNameMS00 = "Musical Present \"White Gold\"";
	let SpellNameMS01 = "Banquet Sign \"Perfect Festival\"";
	let SpellNameMS02 = "Red Thread \"The Flax Yarn Flashes Forward\"";
	let SpellNameMS03 = "Luminescence \"Great Lantern Explosion\"";
	let SpellNameMS04 = "Soul Sign \"House of Shining Lanterns\"";
	let SpellNameMS05 = "Chroma \"Treasure Lamp Histogram\"";
	let SpellNameMS06 = "Incense Lamp \"Impurity-Hating Sparkler\"";
	let SpellNameMS07 = "Lamp Sign \"Colour-Controlling Light\"";
	let SpellNameMS08 = "\South Sea \"Souvenier for Colour Lovers\"";
	let SpellNameMS09 = "Coloring \"Dance of the Rare Man\"";
	let SpellNameMS10 = "Samsara \"Twilight Matrix\"";
	let SpellNameMS11 = "Magic Lantern \"Jewel of Life Among the People\"";
	let SpellNameMS12 = "\"Gift to the Courageous Oath\"";
	
		let SpellDataAttemptMS00 = SpellNameMS00~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS00 = SpellNameMS00~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS00 = GetAreaCommonData("cutin_History", SpellDataAttemptMS00, 0);
		let SpellValueGetMS00 = GetAreaCommonData("cutin_History", SpellDataGetMS00, 0);
	let MS00 = IntToString(SpellValueGetMS00)~"/"~IntToString(SpellValueAttemptMS00);
	if(SpellValueGetMS00 < 10 && SpellValueAttemptMS00 < 10){TextSpaceMS00 = "........."}
	if(SpellValueGetMS00 >= 10 && SpellValueAttemptMS00 < 10){TextSpaceMS00 = "......."}
	if(SpellValueGetMS00 < 10 && SpellValueAttemptMS00 >= 10){TextSpaceMS00 = "......."}
	if(SpellValueGetMS00 >= 10 && SpellValueAttemptMS00 >= 10){TextSpaceMS00 = "....."}
		let SpellDataAttemptMS01 = SpellNameMS01~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS01 = SpellNameMS01~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS01 = GetAreaCommonData("cutin_History", SpellDataAttemptMS01, 0);
		let SpellValueGetMS01 = GetAreaCommonData("cutin_History", SpellDataGetMS01, 0);
	let MS01 = IntToString(SpellValueGetMS01)~"/"~IntToString(SpellValueAttemptMS01);
	if(SpellValueGetMS01 < 10 && SpellValueAttemptMS01 < 10){TextSpaceMS01 = "........."}
	if(SpellValueGetMS01 >= 10 && SpellValueAttemptMS01 < 10){TextSpaceMS01 = "......."}
	if(SpellValueGetMS01 < 10 && SpellValueAttemptMS01 >= 10){TextSpaceMS01 = "......."}
	if(SpellValueGetMS01 >= 10 && SpellValueAttemptMS01 >= 10){TextSpaceMS01 = "....."}
		let SpellDataAttemptMS02 = SpellNameMS02~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS02 = SpellNameMS02~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS02 = GetAreaCommonData("cutin_History", SpellDataAttemptMS02, 0);
		let SpellValueGetMS02 = GetAreaCommonData("cutin_History", SpellDataGetMS02, 0);
	let MS02 = IntToString(SpellValueGetMS02)~"/"~IntToString(SpellValueAttemptMS02);
	if(SpellValueGetMS02 < 10 && SpellValueAttemptMS02 < 10){TextSpaceMS02 = "........."}
	if(SpellValueGetMS02 >= 10 && SpellValueAttemptMS02 < 10){TextSpaceMS02 = "......."}
	if(SpellValueGetMS02 < 10 && SpellValueAttemptMS02 >= 10){TextSpaceMS02 = "......."}
	if(SpellValueGetMS02 >= 10 && SpellValueAttemptMS02 >= 10){TextSpaceMS02 = "....."}
		let SpellDataAttemptMS03 = SpellNameMS03~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS03 = SpellNameMS03~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS03 = GetAreaCommonData("cutin_History", SpellDataAttemptMS03, 0);
		let SpellValueGetMS03 = GetAreaCommonData("cutin_History", SpellDataGetMS03, 0);
	let MS03 = IntToString(SpellValueGetMS03)~"/"~IntToString(SpellValueAttemptMS03);
	if(SpellValueGetMS03 < 10 && SpellValueAttemptMS03 < 10){TextSpaceMS03 = "........."}
	if(SpellValueGetMS03 >= 10 && SpellValueAttemptMS03 < 10){TextSpaceMS03 = "......."}
	if(SpellValueGetMS03 < 10 && SpellValueAttemptMS03 >= 10){TextSpaceMS03 = "......."}
	if(SpellValueGetMS03 >= 10 && SpellValueAttemptMS03 >= 10){TextSpaceMS03 = "....."}
		let SpellDataAttemptMS04 = SpellNameMS04~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS04 = SpellNameMS04~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS04 = GetAreaCommonData("cutin_History", SpellDataAttemptMS04, 0);
		let SpellValueGetMS04 = GetAreaCommonData("cutin_History", SpellDataGetMS04, 0);
	let MS04 = IntToString(SpellValueGetMS04)~"/"~IntToString(SpellValueAttemptMS04);
	if(SpellValueGetMS04 < 10 && SpellValueAttemptMS04 < 10){TextSpaceMS04 = "........."}
	if(SpellValueGetMS04 >= 10 && SpellValueAttemptMS04 < 10){TextSpaceMS04 = "......."}
	if(SpellValueGetMS04 < 10 && SpellValueAttemptMS04 >= 10){TextSpaceMS04 = "......."}
	if(SpellValueGetMS04 >= 10 && SpellValueAttemptMS04 >= 10){TextSpaceMS04 = "....."}
		let SpellDataAttemptMS05 = SpellNameMS05~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS05 = SpellNameMS05~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS05 = GetAreaCommonData("cutin_History", SpellDataAttemptMS05, 0);
		let SpellValueGetMS05 = GetAreaCommonData("cutin_History", SpellDataGetMS05, 0);
	let MS05 = IntToString(SpellValueGetMS05)~"/"~IntToString(SpellValueAttemptMS05);
	if(SpellValueGetMS05 < 10 && SpellValueAttemptMS05 < 10){TextSpaceMS05 = "........."}
	if(SpellValueGetMS05 >= 10 && SpellValueAttemptMS05 < 10){TextSpaceMS05 = "......."}
	if(SpellValueGetMS05 < 10 && SpellValueAttemptMS05 >= 10){TextSpaceMS05 = "......."}
	if(SpellValueGetMS05 >= 10 && SpellValueAttemptMS05 >= 10){TextSpaceMS05 = "....."}
		let SpellDataAttemptMS06 = SpellNameMS06~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS06 = SpellNameMS06~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS06 = GetAreaCommonData("cutin_History", SpellDataAttemptMS06, 0);
		let SpellValueGetMS06 = GetAreaCommonData("cutin_History", SpellDataGetMS06, 0);
	let MS06 = IntToString(SpellValueGetMS06)~"/"~IntToString(SpellValueAttemptMS06);
	if(SpellValueGetMS06 < 10 && SpellValueAttemptMS06 < 10){TextSpaceMS06 = "........."}
	if(SpellValueGetMS06 >= 10 && SpellValueAttemptMS06 < 10){TextSpaceMS06 = "......."}
	if(SpellValueGetMS06 < 10 && SpellValueAttemptMS06 >= 10){TextSpaceMS06 = "......."}
	if(SpellValueGetMS06 >= 10 && SpellValueAttemptMS06 >= 10){TextSpaceMS06 = "....."}
		let SpellDataAttemptMS07 = SpellNameMS07~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS07 = SpellNameMS07~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS07 = GetAreaCommonData("cutin_History", SpellDataAttemptMS07, 0);
		let SpellValueGetMS07 = GetAreaCommonData("cutin_History", SpellDataGetMS07, 0);
	let MS07 = IntToString(SpellValueGetMS07)~"/"~IntToString(SpellValueAttemptMS07);
	if(SpellValueGetMS07 < 10 && SpellValueAttemptMS07 < 10){TextSpaceMS07 = "........."}
	if(SpellValueGetMS07 >= 10 && SpellValueAttemptMS07 < 10){TextSpaceMS07 = "......."}
	if(SpellValueGetMS07 < 10 && SpellValueAttemptMS07 >= 10){TextSpaceMS07 = "......."}
	if(SpellValueGetMS07 >= 10 && SpellValueAttemptMS07 >= 10){TextSpaceMS07 = "....."}
		let SpellDataAttemptMS08 = SpellNameMS08~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS08 = SpellNameMS08~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS08 = GetAreaCommonData("cutin_History", SpellDataAttemptMS08, 0);
		let SpellValueGetMS08 = GetAreaCommonData("cutin_History", SpellDataGetMS08, 0);
	let MS08 = IntToString(SpellValueGetMS08)~"/"~IntToString(SpellValueAttemptMS08);
	if(SpellValueGetMS08 < 10 && SpellValueAttemptMS08 < 10){TextSpaceMS08 = "........."}
	if(SpellValueGetMS08 >= 10 && SpellValueAttemptMS08 < 10){TextSpaceMS08 = "......."}
	if(SpellValueGetMS08 < 10 && SpellValueAttemptMS08 >= 10){TextSpaceMS08 = "......."}
	if(SpellValueGetMS08 >= 10 && SpellValueAttemptMS08 >= 10){TextSpaceMS08 = "....."}
		let SpellDataAttemptMS09 = SpellNameMS09~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS09 = SpellNameMS09~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS09 = GetAreaCommonData("cutin_History", SpellDataAttemptMS09, 0);
		let SpellValueGetMS09 = GetAreaCommonData("cutin_History", SpellDataGetMS09, 0);
	let MS09 = IntToString(SpellValueGetMS09)~"/"~IntToString(SpellValueAttemptMS09);
	if(SpellValueGetMS09 < 10 && SpellValueAttemptMS09 < 10){TextSpaceMS09 = "........."}
	if(SpellValueGetMS09 >= 10 && SpellValueAttemptMS09 < 10){TextSpaceMS09 = "......."}
	if(SpellValueGetMS09 < 10 && SpellValueAttemptMS09 >= 10){TextSpaceMS09 = "......."}
	if(SpellValueGetMS09 >= 10 && SpellValueAttemptMS09 >= 10){TextSpaceMS09 = "....."}
		let SpellDataAttemptMS10 = SpellNameMS10~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS10 = SpellNameMS10~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS10 = GetAreaCommonData("cutin_History", SpellDataAttemptMS10, 0);
		let SpellValueGetMS10 = GetAreaCommonData("cutin_History", SpellDataGetMS10, 0);
	let MS10 = IntToString(SpellValueGetMS10)~"/"~IntToString(SpellValueAttemptMS10);
	if(SpellValueGetMS10 < 10 && SpellValueAttemptMS10 < 10){TextSpaceMS10 = "........."}
	if(SpellValueGetMS10 >= 10 && SpellValueAttemptMS10 < 10){TextSpaceMS10 = "......."}
	if(SpellValueGetMS10 < 10 && SpellValueAttemptMS10 >= 10){TextSpaceMS10 = "......."}
	if(SpellValueGetMS10 >= 10 && SpellValueAttemptMS10 >= 10){TextSpaceMS10 = "....."}
		let SpellDataAttemptMS11 = SpellNameMS11~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS11 = SpellNameMS11~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS11 = GetAreaCommonData("cutin_History", SpellDataAttemptMS11, 0);
		let SpellValueGetMS11 = GetAreaCommonData("cutin_History", SpellDataGetMS11, 0);
	let MS11 = IntToString(SpellValueGetMS11)~"/"~IntToString(SpellValueAttemptMS11);
	if(SpellValueGetMS11 < 10 && SpellValueAttemptMS11 < 10){TextSpaceMS11 = "........."}
	if(SpellValueGetMS11 >= 10 && SpellValueAttemptMS11 < 10){TextSpaceMS11 = "......."}
	if(SpellValueGetMS11 < 10 && SpellValueAttemptMS11 >= 10){TextSpaceMS11 = "......."}
	if(SpellValueGetMS11 >= 10 && SpellValueAttemptMS11 >= 10){TextSpaceMS11 = "....."}
		let SpellDataAttemptMS12 = SpellNameMS12~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Attempt";
		let SpellDataGetMS12 = SpellNameMS12~"|"~CutinDifficulty~"|"~indexPlayer~"|"~"Get";
		let SpellValueAttemptMS12 = GetAreaCommonData("cutin_History", SpellDataAttemptMS12, 0);
		let SpellValueGetMS12 = GetAreaCommonData("cutin_History", SpellDataGetMS12, 0);
	let MS12 = IntToString(SpellValueGetMS12)~"/"~IntToString(SpellValueAttemptMS12);
	if(SpellValueGetMS12 < 10 && SpellValueAttemptMS12 < 10){TextSpaceMS12 = "........."}
	if(SpellValueGetMS12 >= 10 && SpellValueAttemptMS12 < 10){TextSpaceMS12 = "......."}
	if(SpellValueGetMS12 < 10 && SpellValueAttemptMS12 >= 10){TextSpaceMS12 = "......."}
	if(SpellValueGetMS12 >= 10 && SpellValueAttemptMS12 >= 10){TextSpaceMS12 = "....."}
	
	let texts = [MS00~TextSpaceMS00~SpellNameMS00,
			MS01~TextSpaceMS01~SpellNameMS01,
			MS02~TextSpaceMS02~SpellNameMS02,
			MS03~TextSpaceMS03~SpellNameMS03,
			MS04~TextSpaceMS04~SpellNameMS04,
			MS05~TextSpaceMS05~SpellNameMS05,
			MS06~TextSpaceMS06~SpellNameMS06,
			MS07~TextSpaceMS07~SpellNameMS07,
			MS08~TextSpaceMS08~SpellNameMS08,
			MS09~TextSpaceMS09~SpellNameMS09,
			MS10~TextSpaceMS10~SpellNameMS10,
			MS11~TextSpaceMS11~SpellNameMS11,
			MS12~TextSpaceMS12~SpellNameMS12,];
	var countMenu = length(texts);
	ascent(var iText in 0 .. countMenu){
		TMenuItem(iText, mx, my, texts[iText]);
		my += 30;}

	while(GetVirtualKeyState(VK_OK) != KEY_FREE){yield;}

	let startStage = false;
	let frameKeyHold = 0;
	loop{
		if(GetVirtualKeyState(VK_CANCEL) == KEY_PUSH){
			SE(se_cancel);
			loop(20){yield;}
			Obj_Delete(objTitleImage);
			Obj_Delete(objTitleText);
			bEndTitleScene = true;
			TPracticeScene;
			return;}

		if(GetVirtualKeyState(VK_OK) == KEY_PUSH){
			if(selectIndex == INDEX_START_SPELL0M){
			SE(se_ok); 
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",0);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",13);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL1M){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",1);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",14);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL2M){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",2);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",15);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL0B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",3);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",16);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL1B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",4);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",17);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL2B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",5);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",18);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL3B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",6);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",19);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL4B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",7);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",20);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL5B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",8);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",21);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL6B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",9);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",22);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL7B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",10);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",23);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL8B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",11);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",24);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			else if(selectIndex == INDEX_START_SPELL9B){
			SE(se_ok);
				if(CutinDifficulty == "Extra"){SetCommonData("Spell",12);SetCommonData("Word",0);}
				if(CutinDifficulty == "Ultra Extra"){SetCommonData("Spell",25);SetCommonData("Word",1);}
				wait(25); T3StageScene("");}
			break;}

		if(GetVirtualKeyState(VK_UP) == KEY_PUSH){
			selectIndex--;
			SE(se_select);}
		else if(GetVirtualKeyState(VK_DOWN) == KEY_PUSH){
			selectIndex++;
			SE(se_select);}

		else if(GetVirtualKeyState(VK_UP) == KEY_HOLD){
			frameKeyHold++;
			if(frameKeyHold == 30 || (frameKeyHold > 30 && (frameKeyHold % 10 == 0))){
				SE(se_select);
				selectIndex--;}}

		else if(GetVirtualKeyState(VK_DOWN) == KEY_HOLD){
			frameKeyHold++;
			if(frameKeyHold == 30 || (frameKeyHold > 30 && (frameKeyHold % 10 == 0))){
				SE(se_select);
				selectIndex++;}}

		else{frameKeyHold = 0;}
		if(selectIndex < 0) {selectIndex = countMenu - 1;}
		else{selectIndex %= countMenu;}
		yield;}

	bEndTitleScene = true;
	Obj_Delete(objTitleImage);
	Obj_Delete(objTitleText);}