/* as.txt */
/* ＡＳ */

#define _timeclear() FrameLayer_SendMessage(app, SAM_Time_Show, "", FALSE)

/* ----------------------------------------------------------------------- */
/* _change_game用 */
int _as_key[2];
int _bgm_key[2];
int _img_key[2];

#define DEFAULT_KEY "SIS"

#define _change_game(key) strcpy(_as_key, key); FrameLayer_SendMessage(malie, MSM_ChangeGame, 0, key)
#define _cg(name, wipe) _name = name; _wipe = wipe; _call(CG);
#define _cg_bg(name, wipe) strcpy(_img_key, _as_key); _name = name; _wipe = wipe; _call(CG_BG);
#define _sound(num) strcpy(_bgm_key, _as_key); _sound_num = num; _sound_play = TRUE; FrameLayer_SendMessage(malie, MSM_Sound      , num , 0   )

#include "as_h.txt"

#include "_malievalue.txt"

/* ----------------------------------------------------------------------- */
/* */
maliescenario:
{
#include "_maliescenario.txt"
	_end;
}

/* ----------------------------------------------------------------------- */
/* フォルダ定義 */

//#define BOKU
#define SULTAN

#define SULTAN_FOLDER ".\\"

/* ----------------------------------------------------------------------- */
/* 僕と、僕らの夏 */
#ifdef BOKU

#define DATA_FOLDER    BOKU_FOLDER "data\\"
#define PICTURE_FOLDER DATA_FOLDER "picture\\"
#define BG_FOLDER      PICTURE_FOLDER "bg\\"
#define EVENT_FOLDER   PICTURE_FOLDER "event\\"
#define CHARA_FOLDER   PICTURE_FOLDER "char\\"
#define BGM_FOLDER     DATA_FOLDER "bgm\\"
#define SE_FOLDER      DATA_FOLDER "se\\"
#define VOICE_FOLDER   DATA_FOLDER "voice\\"

#define MASK_FOLDER    SULTAN_FOLDER "data\\picture\\mask"

#endif /* BOKU */

/* ----------------------------------------------------------------------- */
/* スルタン */
#ifdef SULTAN

#define DATA_FOLDER    SULTAN_FOLDER "data\\"
#define PICTURE_FOLDER DATA_FOLDER "picture\\"
#define BG_FOLDER      PICTURE_FOLDER "bg\\"
#define EVENT_FOLDER   PICTURE_FOLDER "event\\"
#define CHARA_FOLDER   PICTURE_FOLDER "chara\\"
#define BGM_FOLDER     DATA_FOLDER "bgm\\"
#define SE_FOLDER      DATA_FOLDER "se\\"
#define VOICE_FOLDER   DATA_FOLDER "voice.lib|"

#define MASK_FOLDER    SULTAN_FOLDER "data\\picture\\mask"

#define TABLE_FOLDER ".\\sultan\\data\\table\\"

#endif /* SULTAN */

/* ----------------------------------------------------------------------- */
/* システム */
system:
{
@load: /* ロード時 */

	/* ＢＧＭ再生 */
	FrameLayer_SendMessage(malie, MSM_ChangeGame, 0, _bgm_key);
	_soundloop(TRUE);
	if (_sound_play)
	{
		_sound(_sound_num);
	}
	
	FrameLayer_SendMessage(malie, MSM_ChangeGame, 0, _as_key);
	
	WAIT(1);
	/* フェードイン */
	_changescreen(_screen_id);
	FrameLayer_SendMessage(malie, MSM_SystemFade, 0, 0);
	
	_end;

@save: /* セーブ時 */
	_end;

@run: /* 実行時 */
	
	/* レイヤー初期化 */
	app   = System_GetScreen(IDS_Sultan);
	adv   = System_GetScreen(IDS_Adv   );
	malie = System_GetScreen(IDS_Malie );
	
	/* フォルダ初期化 */
	FrameLayer_SendMessage(malie, MSM_SetFolder, MSFID_Bg   , BG_FOLDER   );
	FrameLayer_SendMessage(malie, MSM_SetFolder, MSFID_Event, EVENT_FOLDER);
	FrameLayer_SendMessage(malie, MSM_SetFolder, MSFID_Chara, CHARA_FOLDER);
	FrameLayer_SendMessage(malie, MSM_SetFolder, MSFID_Bgm  , BGM_FOLDER  );
	FrameLayer_SendMessage(malie, MSM_SetFolder, MSFID_Se   , SE_FOLDER   );
	FrameLayer_SendMessage(malie, MSM_SetFolder, MSFID_Voice, VOICE_FOLDER);
	FrameLayer_SendMessage(malie, MSM_SetFolder, MSFID_Mask , MASK_FOLDER);
	
	_soundloop(TRUE);
	
	_end;
	
@stop:
	out_debug("シナリオ処理が停止しました。\n");
	_end;

@create: /* 生成時 */
	_end;

@destroy: /* 開放時 */
	_end;
}

/*  */
obj_ALL_CLEAR:
{
	_obj(0); _obj_SHOW(FALSE);
	_obj(1); _obj_SHOW(FALSE);
	_obj(2); _obj_SHOW(FALSE);
	_obj(3); _obj_SHOW(FALSE);
	_obj(4); _obj_SHOW(FALSE);
	_obj(5); _obj_SHOW(FALSE);
	_obj(6); _obj_SHOW(FALSE);
	_obj(7); _obj_SHOW(FALSE);
	_obj(8); _obj_SHOW(FALSE);
	_obj(9); _obj_SHOW(FALSE);
	_end;
}

#define _obj_ALL_CLEAR() _call(obj_ALL_CLEAR)

int return_screen;

/* ----------------------------------------------------------------------- */
/* メイン処理 */
main:
{
//	return_screen = System_GetScreen();
	
	/* 初期化 */
	_call(system@run);
	_call(obj_ALL_CLEAR);
	
	/* キー設定 */
	strcpy(_as_key , DEFAULT_KEY);
	strcpy(_bgm_key, DEFAULT_KEY);
	strcpy(_img_key, DEFAULT_KEY);
	
	/* アドベンチャー画面へフェード */
	System_TakeScreen(0);
	_changescreen(IDS_Adv);
	_loadcg("black");
	System_TakeScreen(1);
	_soundstop(1000);
	_wipe_set(OL, 1000);
	&ol;
	System_TakeScreen(2);
	
	_title_goto("@exit");
	
	/* シナリオ部 */
	_call(maliescenario);
	
@exit:
	_change_game(DEFAULT_KEY);
	_title_goto(NULL);
	_soundstop(2000);
	_cg("black", OL);
	
	/*  */
	System_TakeScreen(0);
	_changescreen(IDS_Sultan_SceneSelect);
	System_TakeScreen(1);
	&ol;
	System_TakeScreen(2);
	
	FrameLayer_SendMessage(malie, MSM_Exit, 0, 0);
	System_Await();
}

/* eof */