
function MemoryReset
{
	if(replayflg){return;}
	memory_highscore=[];
	memory_highscore_stage=[];
	memory_spell_totalcount=[];
	memory_spell_getcount=[];
	memory_flg=[];
	memory_tuning=[];
	
	
	ascent(a in 0..40)
	{
		let scr=[0];
		memory_highscore=memory_highscore~scr;
		memory_highscore_stage=memory_highscore_stage~scr;
	}
	ascent(a in 0..200)
	{
		let count=[0];
		memory_spell_totalcount=memory_spell_totalcount~count;
		memory_spell_getcount=memory_spell_getcount~count;
	}
	ascent(a in 0..15)
	{
		let flg=[false];
		memory_flg=memory_flg~flg;
	}
	
	local
	{
		let data=[3,0,1,1,0,0,0,0,0,0];
		memory_tuning=data;
	}
	
	ascent(a in 0..20)
	{
		let data=[0];
		memory_others=memory_others~data;
	}
	ClearCommonData;
	
	SetCommonData("Memory_HighScore",memory_highscore);
	SetCommonData("Memory_HighScore_Stage",memory_highscore_stage);
	SetCommonData("Memory_SpellResult_TotalCount",memory_spell_totalcount);
	SetCommonData("Memory_SpellResult_GetCount",memory_spell_getcount);
	SetCommonData("Memory_FlagData",memory_flg);
	SetCommonData("Memory_ConfigData",memory_tuning);
	SetCommonData("Memory_Others",memory_others);
	
	SaveCommonData;
	
	RaiseError("Z[uf[^Zbg܂"\n"NAtOEXy擾󋵁EnCXRAERtBOݒ肪܂","PhantasmagoriaTrues_save.dat");
}


function MemorySave
{
	
	local
	{
		let defaultdata=[];
		ascent(a in 0..200)
		{
			let count=[0];
			defaultdata=defaultdata~count;
		}
		memory_spell_totalcount=GetCommonDataDefault("SpellResult_TotalCount",defaultdata);
		memory_spell_getcount=GetCommonDataDefault("SpellResult_GetCount",defaultdata);
	}
	local
	{
		memory_others[0]=timer_hours;
		memory_others[1]=timer_minutes;
		memory_others[2]=timer_seconds;
		
		memory_others[3]=play_count;
	}
	if(!replayflg)
	{
		ClearCommonData;
		SetCommonData("Memory_HighScore",memory_highscore);
		SetCommonData("Memory_HighScore_Stage",memory_highscore_stage);
		SetCommonData("Memory_SpellResult_TotalCount",memory_spell_totalcount);
		SetCommonData("Memory_SpellResult_GetCount",memory_spell_getcount);
		SetCommonData("Memory_FlagData",memory_flg);
		SetCommonData("Memory_ConfigData",memory_tuning);
		SetCommonData("Memory_Others",memory_others);
		SaveCommonData;
		
		SetCommonData("Memory_HighScore",replay_highscore);
		SetCommonData("Memory_HighScore_Stage",replay_highscore_stage);
		SetCommonData("Memory_SpellResult_TotalCount",replay_spell_totalcount);
		SetCommonData("Memory_SpellResult_GetCount",replay_spell_getcount);
		SetCommonData("Memory_FlagData",replay_flg);
		SetCommonData("Memory_ConfigData",replay_tuning);
		SetCommonData("Memory_Others",replay_others);
		SaveCommonDataInReplayFile;
	}
}

function MemoryLoad
{
	if(!IsReplay){LoadCommonData;}
	else{LoadCommonDataFromReplayFile;}
	
	//HighScore
	local
	{
		let defaultdata=[];
		ascent(a in 0..40)
		{
			let scr=[0];
			defaultdata=defaultdata~scr;
		}
		memory_highscore=GetCommonDataDefault("Memory_HighScore",defaultdata);
		memory_highscore_stage=GetCommonDataDefault("Memory_HighScore_Stage",defaultdata);
		
		replay_highscore=GetCommonDataDefault("Memory_HighScore",defaultdata);
		replay_highscore_stage=GetCommonDataDefault("Memory_HighScore_Stage",defaultdata);
	}
	
	//SpellResult
	local
	{
		let defaultdata=[];
		ascent(a in 0..200)
		{
			let count=[0];
			defaultdata=defaultdata~count;
		}
		SetCommonData("SpellResult_TotalCount",GetCommonDataDefault("Memory_SpellResult_TotalCount",defaultdata));
		SetCommonData("SpellResult_GetCount",GetCommonDataDefault("Memory_SpellResult_GetCount",defaultdata));
		memory_spell_totalcount=GetCommonDataDefault("Memory_SpellResult_TotalCount",defaultdata);
		memory_spell_getcount=GetCommonDataDefault("Memory_SpellResult_GetCount",defaultdata);
		
		replay_spell_totalcount=GetCommonDataDefault("Memory_SpellResult_TotalCount",defaultdata);
		replay_spell_getcount=GetCommonDataDefault("Memory_SpellResult_GetCount",defaultdata);
	}
	
	//FlagData
	local
	{
		let defaultdata=[];
		ascent(a in 0..15)
		{
			let flg=[false];
			defaultdata=defaultdata~flg;
		}
		memory_flg=GetCommonDataDefault("Memory_FlagData",defaultdata);
		replay_flg=GetCommonDataDefault("Memory_FlagData",defaultdata);
	}
	
	//Tuning
	local
	{
		let defaultdata=[3,0,1,1,0,0,0,0,0,0];
		memory_tuning=GetCommonDataDefault("Memory_ConfigData",defaultdata);
		replay_tuning=GetCommonDataDefault("Memory_ConfigData",defaultdata);
		
		tuning_difficulty=memory_tuning[0];
		tuning_lightmode=memory_tuning[1];
		tuning_playmusic=memory_tuning[2];
		tuning_continue=memory_tuning[3];
	}
	
	//Others
	local
	{
		let defaultdata=[];
		ascent(a in 0..20)
		{
			let data=[0];
			defaultdata=defaultdata~data;
		}
		memory_others=GetCommonDataDefault("Memory_Others",defaultdata);
		replay_others=GetCommonDataDefault("Memory_Others",defaultdata);
		
		timer_hours=memory_others[0];
		timer_minutes=memory_others[1];
		timer_seconds=memory_others[2];
		
		play_count=memory_others[3];
		
		play_count++;
	}
}

