/*
 * $Id: m_msg_main_cursol.c,v 1.1 2003/06/06 00:15:12 tong Exp $
 *
 *	メッセージ表示のライブラリーのインクルードソースファイル
 *
 * $Log: m_msg_main_cursol.c,v $
 * Revision 1.1  2003/06/06 00:15:12  tong
 * source files for localization from Nintendo.
 *
 * Revision 1.89  2001-01-29 12:44:07+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.88  2001-01-27 20:02:06+09  sakakibara
 * アイテム受け渡し 開始、終了 命令追加。
 *
 * Revision 1.87  2001-01-18 20:40:36+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.86  2001-01-18 00:17:54+09  sakakibara
 * ボタン待ち処理 お試し
 *
 * Revision 1.85  2001-01-05 14:10:06+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.84  2001-01-05 14:09:37+09  sakakibara
 * pf5 も色指定。
 *
 * Revision 1.83  2000-12-16 22:08:09+09  sakakibara
 * Ｂ
 *
 * Revision 1.82  2000-12-16 15:56:42+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.81  2000-12-15 22:42:00+09  sakakibara
 * SNB
 *
 * Revision 1.80  2000-12-14 16:00:14+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.79  2000-12-12 23:58:01+09  sakakibara
 * 自由文字列色指定
 *
 * Revision 1.78  2000-12-08 23:48:01+09  sakakibara
 * 音声制御
 *
 * Revision 1.77  2000-12-07 13:29:32+09  sakakibara
 * ページ送り音無し
 *
 * Revision 1.76  2000-12-01 11:40:58+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.75  2000-11-30 23:23:14+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.74  2000-11-30 22:50:04+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.73  2000-11-14 14:56:41+09  sakakibara
 * 選択ウィンドウ 隠れ後のタイマ
 *
 * Revision 1.72  2000-11-13 17:42:57+09  sakakibara
 * 選択ウィンドウ出現したのフラグ
 *
 * Revision 1.71  2000-11-08 23:42:27+09  sakakibara
 * 行スケール設定処理
 *
 * Revision 1.70  2000-10-16 16:43:53+09  sakakibara
 * プレイヤ名 色変え
 *
 * Revision 1.69  2000-10-02 11:40:01+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.68  2000-09-28 21:54:43+09  sakakibara
 * コントロール命令追加に伴う修正
 *
 * Revision 1.67  2000-08-14 21:45:51+09  sakakibara
 * 会話カーソル処理の終了を１frame遅くした。
 *
 * Revision 1.66  2000-07-14 13:25:59+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.65  2000-07-05 17:50:03+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.64  2000-07-04 18:11:12+09  sakakibara
 * コントロール命令追加に伴う修正
 *
 * Revision 1.63  2000-06-29 21:02:17+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.62  2000-06-19 14:47:57+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.61  2000-06-16 20:09:18+09  sakakibara
 * コントロール命令追加に伴う修正
 *
 * Revision 1.60  2000-06-13 12:55:29+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.59  2000-06-12 19:53:03+09  sakakibara
 * *** empty log message ***
 *
 * Revision 1.58  2000-05-25 16:18:48+09  sakakibara
 * コントロール命令追加に伴う修正
 *
 * Revision 1.57  2000-05-17 19:55:08+09  sakakibara
 * コントロール命令追加に伴う修正
 *
 * Revision 1.56  2000-05-17 18:48:11+09  sakakibara
 * 発声ＯＮ／ＯＦＦ 処理作成
 *
 * Revision 1.55  2000-05-10 16:05:08+09  sakakibara
 * コントロール命令追加に伴う修正
 *
 */
/*************メッセージウインドウの"カーソル"メインの処理******************/

/*
 ******************************************************************************
 *	メッセージウインドウの"カーソル"メインの処理
 ******************************************************************************
 */
/*
 ************************************************************************
 *	カーソル処理キャンセル命令が來ているかチェック
 ************************************************************************
 */
static int mMsg_Check_CancelOrder(M_MSG_WIN *win_p)
{
    if ((win_p->flag_cancel_able != FALSE) && (win_p->flag_cancel == FALSE)) {
	if (chkTrigger(A_BTN) || chkTrigger(B_BTN)) {
	    return TRUE;
	}
    }
    return FALSE;
}

/*
 ************************************************************************
 *	index番目のコードがコントロール命令かを調べる
 ************************************************************************
 */
static int mMsg_Main_Cursol_Check_ControlCursol(M_MSG_WIN *win_p, int index)
{
    unchar *data_p = win_p->msg_p->code.data;
    unchar code = data_p[index];
    
    if(code == MOJI_CONT) {
#if DEBUG
	int type = (int)(data_p[index+1]);

	if(!((0 <= type) && (type < TOTAL_CONT))) {
	    PRINTF(ESC_ERROR
		   "mMsg_Main_Cursol_Check_ControlCursol:範囲外変なコントロールコードが來た\n"
		   ESC_NORMAL);
	    assert(0);
	}
#endif
	return(TRUE);
    }
    else {
	return(FALSE);
    }
}

/*
 ************************************************************************
 *	"終了コード"の場合のカーソルコントロール処理
 ************************************************************************
 */
static int mMsg_Main_Cursol_Last_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    win_p->now_end_font_code_cursol_index = *index_p;	/* インデックスはそのまま */
    
    if (bitcheck(win_p->status, M_MSG_STATUS_LAST_WAIT)) {
	bitclr(win_p->status, M_MSG_STATUS_LAST_WAIT);
	return M_MSG_RETURN_TYPE_FALSE;
    } else {
	bitset(win_p->status, M_MSG_STATUS_LAST_WAIT);	/* 1 frame 遅らせる flag */
	return M_MSG_RETURN_TYPE_TRUE;
    }
}

/*
 ************************************************************************
 *	"継続コード"の場合のカーソルコントロール処理
 ************************************************************************
 */
static int mMsg_Main_Cursol_Continue_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    win_p->now_end_font_code_cursol_index = *index_p;	/* インデックスはそのまま */
    
    if (bitcheck(win_p->status, M_MSG_STATUS_LAST_WAIT)) {
	bitclr(win_p->status, M_MSG_STATUS_LAST_WAIT);
	return M_MSG_RETURN_TYPE_FALSE;
    } else {
	bitset(win_p->status, M_MSG_STATUS_LAST_WAIT);	/* 1 frame 遅らせる flag */
	return M_MSG_RETURN_TYPE_TRUE;
    }
}

/*
 ************************************************************************
 *	"文字表示クリヤーコード"の場合のカーソルコントロール処理
 ************************************************************************
 */
static int mMsg_Main_Cursol_Clear_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    /* 表示範囲のクリヤー */
    win_p->now_end_font_code_cursol_index = *index_p;
    mMsg_Clear_CursolIndex(win_p);
    /* 間を空ける為のタイマーを入れる */
    mMsg_SetTimer(win_p, M_MSG_TIME_NEXT_PAGE);	    
//    /* 会話時のページ送り音を出す */
//    mMsg_sound_PAGE_OKURI();
    
    return(M_MSG_RETURN_TYPE_TRUE);	/* タイマーをセットするのでTRUE */
//    return(M_MSG_RETURN_TYPE_NONE);
}

/*
 ************************************************************************
 *	"タイマーセットコード"の場合のカーソルコントロール処理
 ************************************************************************
 */
static int mMsg_Main_Cursol_CursolSetTime_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    float set_time = mMsg_Get_CursolSetTimeCode(win_p, *index_p);

    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    win_p->now_end_font_code_cursol_index = *index_p;
    
    if (win_p->flag_cancel != FALSE) {
	return M_MSG_RETURN_TYPE_NONE;
    }
    
    if (set_time > 0.0F) {
	win_p->cursol_timer = set_time;
	if (bitcheck(win_p->status, M_MSG_STATUS_QUICK)) {
	    mMsg_sound_MessageSpeedForce(1.0f);
	} else {
	    mMsg_sound_MessageSpeedForce(set_time);
	}
	return M_MSG_RETURN_TYPE_TRUE;
    } else {
#if DEBUG
	PRINTF(ESC_WARNING"ゼロ以下はタイマーにセット出来ない(%s %d)\n"
	       ESC_NORMAL, __FILE__, __LINE__);
#endif
	return M_MSG_RETURN_TYPE_NONE;
    }
}

/* "ボタン待ち"の場合のカーソルコントロール処理 */
static int mMsg_Main_Cursol_Button_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    if (bitcheck(win_p->status, M_MSG_STATUS_LAST_WAIT)) {
	bitclr(win_p->status, M_MSG_STATUS_LAST_WAIT);
	*index_p += mMsg_Set_SizeCode(win_p, *index_p);
	win_p->now_end_font_code_cursol_index = *index_p;
	
	return M_MSG_RETURN_TYPE_FALSE;
    } else {
	bitset(win_p->status, M_MSG_STATUS_LAST_WAIT);	/* 1 frame 遅らせる flag */
	win_p->now_end_font_code_cursol_index = *index_p;	/* インデックスはそのまま */
	
	return M_MSG_RETURN_TYPE_TRUE;
    }
}

/* "カラーコード"の場合のカーソルコントロール処理 */
static int mMsg_Main_Cursol_Color_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    int now_display_line = win_p->now_display_line;
    rgba_t *font_color_p;

    if((0 <= now_display_line) && (now_display_line < M_MSG_TOTAL_LINE_DRAW_FONT_AREA)) {
	font_color_p = &(win_p->font_color[now_display_line]);
    }
    else {
	font_color_p = &(win_p->font_color[0]);
#if DEBUG
	PRINTF(ESC_WARNING
	       "mMsg_Main_Cursol_Color_ControlCursol:%d そんなラインの色は変えられない!!!!!!!!!!!!!!\n"
	       ESC_NORMAL,
	       now_display_line);
#endif	
    }
    
    mMsg_Get_ColorCode(win_p,
		       *index_p,
		       &(font_color_p->r),
		       &(font_color_p->g),
		       &(font_color_p->b));
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "カーソル処理キャンセル可能"の場合のカーソルコントロール処理 */
static int mMsg_Main_Cursol_AbleCancel_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    /* カーソル処理キャンセル可能のセット */
    win_p->flag_cancel_able = TRUE;
    
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "カーソル処理キャンセル不可能"の場合のカーソルコントロール処理 */
static int mMsg_Main_Cursol_UnableCancel_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    /* カーソル処理キャンセル可能のクリヤー */
    win_p->flag_cancel = FALSE;
    win_p->flag_cancel_able = FALSE;
    
    return(M_MSG_RETURN_TYPE_NONE);
}

/* デモ命令セット(汎用) */
static int mMsg_Main_Cursol_SetDemoOrder_ControlCursol(M_MSG_WIN *win_p, int *index_p, int kind)
{
    int num;
    unshort value;
    
    /* デモ指令変数のゲット */
    mMsg_Get_OrderCode(win_p,
		       *index_p,
		       &num,
		       &value);

    /* デモ指令変数のセット */
    mDemo_Set_OrderValue(kind, num, value);
	
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* CONT_SET_DEMO_ORDER_PLAYER,		デモ命令セット(プレイヤー) */
static int mMsg_Main_Cursol_SetDemoOrderPlayer_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetDemoOrder_ControlCursol(win_p, index_p, M_DEMO_ORDER_PLAYER));
}

/* CONT_SET_DEMO_ORDER_NPC0,		デモ命令セット(ＮＰＣ０) */
static int mMsg_Main_Cursol_SetDemoOrderNpc0_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetDemoOrder_ControlCursol(win_p, index_p, M_DEMO_ORDER_NPC0));
}

/* CONT_SET_DEMO_ORDER_NPC1,		デモ命令セット(ＮＰＣ１) */
static int mMsg_Main_Cursol_SetDemoOrderNpc1_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetDemoOrder_ControlCursol(win_p, index_p, M_DEMO_ORDER_NPC1));
}

/* CONT_SET_DEMO_ORDER_NPC2,		デモ命令セット(ＮＰＣ２) */
static int mMsg_Main_Cursol_SetDemoOrderNpc2_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetDemoOrder_ControlCursol(win_p, index_p, M_DEMO_ORDER_NPC2));
}

/* CONT_SET_DEMO_ORDER_QUEST,		デモ命令セット(クエスト) */
static int mMsg_Main_Cursol_SetDemoOrderQuest_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetDemoOrder_ControlCursol(win_p, index_p, M_DEMO_ORDER_QUEST));
}


/* CONT_SET_SELECT_WINDOW,	選択ウインドウセット */
static int mMsg_Main_Cursol_SetSelectWindow_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    win_p->now_end_font_code_cursol_index = *index_p;
    mChoice_Change_request_main_index(&(win_p->choice_win), M_CHOICE_MAIN_APPEAR);
    return(M_MSG_RETURN_TYPE_TRUE);
}

/* 継続メッセージセット（汎用） */
static int mMsg_Main_Cursol_SetNextMessage_ControlCursol(M_MSG_WIN *win_p, int *index_p, int select_num)
{
    unshort msg_num;
    unchar *data_p = win_p->msg_p->code.data;
    int choice_num = mChoice_Get_ChoseNum(mChoice_Get_base_window_p());

//    if(choice_num != -1) {
	msg_num = (unshort)(((int)(data_p[*index_p+2])) << 8);
	msg_num = (unshort)(msg_num | (0x00ff & ((int)(data_p[*index_p+3]))));
	
	if((select_num == 255) || (select_num == choice_num)) {
	    if(msg_num != LIMIT_UNSHORT_ABS) {
		/* 継続メッセージの番号セット */
		mMsg_Set_continue_msg_num(win_p, (int)msg_num);
	    }
	    else {
		mMsg_Set_CancelNormalContinue(win_p);
	    }
	}

//    }
//#if DEBUG
//    else {
//	PRINTF(ESC_ERROR
//	       "選択が行われている最中！！！！！！！！！\n"
//	       ESC_ERROR);
//	assert(0);
//    }
//#endif    
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* CONT_SET_NEXT_MESSAGE_F,	継続メッセージセット（強制） */
static int mMsg_Main_Cursol_SetNextMessageF_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetNextMessage_ControlCursol(win_p, index_p, 255));
}

/* CONT_SET_NEXT_MESSAGE_0,	継続メッセージセット（選択肢が０なら） */
static int mMsg_Main_Cursol_SetNextMessage0_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetNextMessage_ControlCursol(win_p, index_p, 0));
}

/* CONT_SET_NEXT_MESSAGE_1,	継続メッセージセット（選択肢が１なら） */
static int mMsg_Main_Cursol_SetNextMessage1_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetNextMessage_ControlCursol(win_p, index_p, 1));
}

/* CONT_SET_NEXT_MESSAGE_2,	継続メッセージセット（選択肢が２なら） */
static int mMsg_Main_Cursol_SetNextMessage2_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetNextMessage_ControlCursol(win_p, index_p, 2));
}

/* CONT_SET_NEXT_MESSAGE_3,	継続メッセージセット（選択肢が３なら） */
static int mMsg_Main_Cursol_SetNextMessage3_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetNextMessage_ControlCursol(win_p, index_p, 3));
}


#define TOTAL_M_MSG_RANDOM_ELEMENT	4

/* 継続メッセージをランダムにセット(汎用) */
static int mMsg_Main_Cursol_SetNextMessageRamdomCommon_ControlCursol(M_MSG_WIN *win_p, int *index_p, int total_element)
{
    unshort msg_num_table[TOTAL_M_MSG_RANDOM_ELEMENT];
    unchar *data_p = win_p->msg_p->code.data;
    int continue_table_index = (int)get_random_timer(0, (short)total_element);	/* たぶんー１すると都合が悪いかも */
    int i;

#if DEBUG    
    if(!((2 <= total_element) && (total_element <= TOTAL_M_MSG_RANDOM_ELEMENT))) {
	PRINTF(ESC_ERROR
	       "mMsg_Main_Cursol_SetNextMessageRamdomCommon_ControlCursol:ランダム要素が変 = %d!!!!!!!!!!!!!!\n"
	       ESC_NORMAL,
	       total_element);
	assert(0);
    }
#endif

    /* 分岐するメッセージ番号のロード */
    for(i = 0; i < total_element; i++) {
	msg_num_table[i] = (unshort)(((int)(data_p[*index_p+2+2*i])) << 8);
	msg_num_table[i] = (unshort)(msg_num_table[i] | (0x00ff & ((int)(data_p[*index_p+3+2*i]))));
    }

    if(!((0 <= continue_table_index) && (continue_table_index < total_element))) {
#if DEBUG
	PRINTF(ESC_WARNING
	       "mMsg_Main_Cursol_SetNextMessageRamdomCommon_ControlCursol:ランダムのアルゴリズムが変 = %d!!!!!!!!!!!!!!\n"
	       ESC_NORMAL,
	       continue_table_index);
#endif
	continue_table_index = 0;
    }

    /* 継続メッセージの番号セット */
    mMsg_Set_continue_msg_num(win_p, (int)(msg_num_table[continue_table_index]));
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    return(M_MSG_RETURN_TYPE_NONE);
}

#undef TOTAL_M_MSG_RANDOM_ELEMENT


/* CONT_SET_NEXT_MESSAGE_RAMDOM_2	継続メッセージセット(２個からランダムに) */
static int mMsg_Main_Cursol_SetNextMessageRamdom2_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetNextMessageRamdomCommon_ControlCursol(win_p, index_p, 2));
}

/* CONT_SET_NEXT_MESSAGE_RAMDOM_3	継続メッセージセット(３個からランダムに) */
static int mMsg_Main_Cursol_SetNextMessageRamdom3_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetNextMessageRamdomCommon_ControlCursol(win_p, index_p, 3));
}

/* CONT_SET_NEXT_MESSAGE_RAMDOM_4	継続メッセージセット(４個からランダムに) */
static int mMsg_Main_Cursol_SetNextMessageRamdom4_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetNextMessageRamdomCommon_ControlCursol(win_p, index_p, 4));
}

/* 選択文字列セット(汎用) */
static int mMsg_Main_Cursol_SetSelectString_ControlCursol(M_MSG_WIN *win_p, int *index_p, int total_setect)
{
    unchar *data_p = win_p->msg_p->code.data;
    int str_num[M_CHOICE_TOTAL_CHOICE_MAX];

    {
	unshort temp;
	
	temp = (unshort)(((int)(data_p[*index_p+2])) << 8);
	temp = (unshort)(temp | (0x00ff & ((int)(data_p[*index_p+3]))));
	str_num[0] = (int)temp;
	
	temp = (unshort)(((int)(data_p[*index_p+4])) << 8);
	temp = (unshort)(temp | (0x00ff & ((int)(data_p[*index_p+5]))));
	str_num[1] = (int)temp;

	if(total_setect > M_CHOICE_TOTAL_CHOICE_MIN) {
	    temp = (unshort)(((int)(data_p[*index_p+6])) << 8);
	    temp = (unshort)(temp | (0x00ff & ((int)(data_p[*index_p+7]))));
	    str_num[2] = (int)temp;
	}
	
	if(total_setect > (M_CHOICE_TOTAL_CHOICE_MIN + 1)) {
	    temp = (unshort)(((int)(data_p[*index_p+8])) << 8);
	    temp = (unshort)(temp | (0x00ff & ((int)(data_p[*index_p+9]))));
	    str_num[3] = (int)temp;
	}
    }

    if((M_CHOICE_TOTAL_CHOICE_MIN <= total_setect) && (total_setect <= M_CHOICE_TOTAL_CHOICE_MAX)) {
	static unchar str[M_CHOICE_TOTAL_CHOICE_MAX][M_CHOICE_STRING_MAX_LENGTH];
	{
	    int i;
	    ACTOR *client_actor_p = win_p->client_actor_p;
	    for(i = 0; i < total_setect; i++) {
		mChoice_Load_ChoseStringFromRom(mChoice_Get_base_window_p(), str[i], str_num[i], client_actor_p);
	    }
	}
	{
	    unchar *str0_p = str[0];
	    unchar *str1_p = str[1];
	    unchar *str2_p = (total_setect > M_CHOICE_TOTAL_CHOICE_MIN) ? str[2] :  NULL;
	    unchar *str3_p = (total_setect > (M_CHOICE_TOTAL_CHOICE_MIN + 1)) ? str[3] :  NULL;
	    
	    mChoice_Set_choice_data(mChoice_Get_base_window_p(),
				    str0_p, M_CHOICE_STRING_MAX_LENGTH,
				    str1_p, M_CHOICE_STRING_MAX_LENGTH,
				    str2_p, M_CHOICE_STRING_MAX_LENGTH,
				    str3_p, M_CHOICE_STRING_MAX_LENGTH);
	}
    }
#if DEBUG
    else {
	PRINTF(ESC_ERROR
	       "mMsg_Main_Cursol_SetSelectString_ControlCursol:選択肢の数がおかしい!!!!!!!!!!\n"
	       ESC_NORMAL);
	assert(0);
    }
#endif
    
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* CONT_SET_SELECT_STRING2,	選択文字列セット(２個セット) */
static int mMsg_Main_Cursol_SetSelectString2_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetSelectString_ControlCursol(win_p, index_p, 2));
}

/* CONT_SET_SELECT_STRING3,	選択文字列セット(３個セット) */
static int mMsg_Main_Cursol_SetSelectString3_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetSelectString_ControlCursol(win_p, index_p, 3));
}

/* CONT_SET_SELECT_STRING3,	選択文字列セット(４個セット) */
static int mMsg_Main_Cursol_SetSelectString4_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetSelectString_ControlCursol(win_p, index_p, 4));
}

/* CONT_SET_FORCE_NEXT,		強制的にプッシュボタン待ち解除フラグセット */
static int mMsg_Main_Cursol_SetForceNext_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    /* ボタン押しを待たずに次へ行くフラグセット */
    mMsg_Set_ForceNext(win_p);
    
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "プレイヤー名の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_PlayerName_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    M_MSG_DATA *msg_p = win_p->msg_p;
    unchar *data_p = msg_p->code.data;
    
    /* 色変え命令追加 */
    msg_p->total_code = mMsg_Set_PlayerNameColor(data_p, index_p,
						 msg_p->total_code);
    
    /* プレイヤー名のコピー */
    msg_p->total_code = mMsg_CopyPlayerName(data_p, *index_p,
					    msg_p->total_code);
    
    return M_MSG_RETURN_TYPE_NONE;
}

/* "話し手名の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_TalkName_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 話し手名のコピー */
    win_p->msg_p->total_code = mMsg_CopyTalkName(win_p->client_actor_p,
						 data_p,
						 *index_p,
						 total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "語尾の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Tail_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 語尾のコピー */
    win_p->msg_p->total_code = mMsg_CopyTail(win_p->client_actor_p,
						 data_p,
						 *index_p,
						 total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "年の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Year_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 年のコピー */
    win_p->msg_p->total_code = mMsg_CopyYear(data_p,
					     *index_p,
					     total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "月の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Month_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 月のコピー */
    win_p->msg_p->total_code = mMsg_CopyMonth(data_p,
					      *index_p,
					      total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "曜日の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Week_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 曜日のコピー */
    win_p->msg_p->total_code = mMsg_CopyWeek(data_p,
					     *index_p,
					     total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "日の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Day_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 日のコピー */
    win_p->msg_p->total_code = mMsg_CopyDay(data_p,
					    *index_p,
					    total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "時の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Hour_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 時のコピー */
    win_p->msg_p->total_code = mMsg_CopyHour(data_p,
					     *index_p,
					     total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "分の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Min_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 分のコピー */
    win_p->msg_p->total_code = mMsg_CopyMin(data_p,
					    *index_p,
					    total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "秒の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Sec_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 秒のコピー */
    win_p->msg_p->total_code = mMsg_CopySec(data_p,
					    *index_p,
					    total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "自由文字列の置き換え"処理(汎用) */
static int mMsg_Main_Cursol_PutString_Free(M_MSG_WIN *win_p, int start_index, int num)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 自由文字列のコピー */
    win_p->msg_p->total_code = mMsg_CopyFree(win_p,
					     num,
					     data_p,
					     start_index,
					     total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "自由文字列の置き換え"処理(汎用)(色指定) */
static int mMsg_Main_Cursol_PutString_Free_cl(M_MSG_WIN *win_p, int *start_index_p, int num,
					      mMSG_Pf_Cl_Id color_id)
{
    if (color_id != mMSG_Pf_CL_ID_NONE) {
	M_MSG_DATA *msg_p = win_p->msg_p;
	
	/* 色変え命令追加 */
	msg_p->total_code = mMsg_Set_PfColor(msg_p->code.data, start_index_p,
					     msg_p->total_code,
					     win_p->free_str[num],
					     color_id);
    }
    mMsg_Main_Cursol_PutString_Free(win_p, *start_index_p, num);
    
    return M_MSG_RETURN_TYPE_NONE;
}

/* "自由文字列０の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free0_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 0));
}

/* "自由文字列１の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free1_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    /* color 付で */
    return mMsg_Main_Cursol_PutString_Free_cl(
	win_p, index_p, 1,
	(mMSG_Pf_Cl_Id)(win_p->free_str_cl_id[mMSG_PF_CL_TBL_1]));
}

/* "自由文字列２の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free2_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    /* color 付で */
    return mMsg_Main_Cursol_PutString_Free_cl(
	win_p, index_p, 2,
	(mMSG_Pf_Cl_Id)(win_p->free_str_cl_id[mMSG_PF_CL_TBL_2]));
}

/* "自由文字列３の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free3_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 3));
}

/* "自由文字列４の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free4_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 4));
}

/* "自由文字列５の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free5_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    /* color 付で */
    return mMsg_Main_Cursol_PutString_Free_cl(
	win_p, index_p, 5,
	(mMSG_Pf_Cl_Id)(win_p->free_str_cl_id[mMSG_PF_CL_TBL_5]));
}

/* "自由文字列６の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free6_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 6));
}

/* "自由文字列７の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free7_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 7));
}

/* "自由文字列８の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free8_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 8));
}

/* "自由文字列９の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free9_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 9));
}

/* "自由文字列１０の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free10_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 10));
}

/* "自由文字列１１の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free11_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 11));
}

/* "自由文字列１２の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free12_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 12));
}

/* "自由文字列１３の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free13_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 13));
}

/* "自由文字列１４の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free14_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 14));
}

/* "自由文字列１５の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free15_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 15));
}

/* "自由文字列１６の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free16_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 16));
}

/* "自由文字列１７の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free17_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 17));
}

/* "自由文字列１８の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free18_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 18));
}

/* "自由文字列１９の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Free19_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Free(win_p, *index_p, 19));
}

/* "決定文字列の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Determination_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 決定文字列のコピー */
    win_p->msg_p->total_code = mMsg_CopyDetermination(win_p,
						      data_p,
						      *index_p,
						      total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "国名・置き換え" */
static int mMsg_Main_Cursol_PutString_CountryName_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 国名のコピー */
    win_p->msg_p->total_code = mMsg_CopyCountryName(data_p,
						    *index_p,
						    total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "０から９９の乱数・置き換え" */
static int mMsg_Main_Cursol_PutString_RamdomNumber2_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 乱数のコピー */
    win_p->msg_p->total_code = mMsg_CopyRamdomNumber2(data_p,
						      *index_p,
						      total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "アイテム文字列の置き換え"処理(汎用) */
static int mMsg_Main_Cursol_PutString_Item(M_MSG_WIN *win_p, int start_index, int num)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* アイテム文字列のコピー */
    win_p->msg_p->total_code = mMsg_CopyItem(win_p,
					     num,
					     data_p,
					     start_index,
					     total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "アイテム文字列０の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Item0_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Item(win_p, *index_p, 0));
}

/* "アイテム文字列１の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Item1_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Item(win_p, *index_p, 1));
}

/* "アイテム文字列２の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Item2_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Item(win_p, *index_p, 2));
}

/* "アイテム文字列３の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Item3_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Item(win_p, *index_p, 3));
}

/* "アイテム文字列４の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Item4_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Item(win_p, *index_p, 4));
}

/* "手紙文字列の置き換え"処理(汎用) */
static int mMsg_Main_Cursol_PutString_Mail(M_MSG_WIN *win_p, int start_index, int num)
{
    unchar *data_p = win_p->msg_p->code.data;
    int total_code = win_p->msg_p->total_code;

    /* 手紙文字列のコピー */
    win_p->msg_p->total_code = mMsg_CopyMail(win_p,
					     num,
					     data_p,
					     start_index,
					     total_code);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "手紙文字列０の置き換え"処理 */
static int mMsg_Main_Cursol_PutString_Mail0_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_PutString_Mail(win_p, *index_p, 0));
}

/* "プレイヤーの状態を変更要求する"処理(汎用) */
static int mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(M_MSG_WIN *win_p, int *index_p, signed char  value)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    mDemo_Set_change_player_destiny(value);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "プレイヤーの状態を０に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny0_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 0));
}

/* "プレイヤーの状態を１に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny1_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 1));
}

/* "プレイヤーの状態を２に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny2_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 2));
}

/* "プレイヤーの状態を３に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny3_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 3));
}

/* "プレイヤーの状態を４に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny4_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 4));
}

/* "プレイヤーの状態を５に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny5_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 5));
}

/* "プレイヤーの状態を６に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny6_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 6));
}

/* "プレイヤーの状態を７に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny7_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 7));
}

/* "プレイヤーの状態を８に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny8_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 8));
}

/* "プレイヤーの状態を９に変更要求する"処理 */
static int mMsg_Main_Cursol_SetPlayerDestiny9_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetPlayerDestiny_ControlCursol(win_p, index_p, 9));
}

/* "会話の内容を変更要求する"処理(汎用) */
static int mMsg_Main_Cursol_SetMessageContents_ControlCursol(M_MSG_WIN *win_p, int *index_p, u8 value)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    mMsg_sound_MessageStatus(value);
    return(M_MSG_RETURN_TYPE_NONE);
}

/* "会話の内容を"通常"に変更要求する"処理 */
static int mMsg_Main_Cursol_SetMessageContentsNormal_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetMessageContents_ControlCursol(win_p, index_p, VOICE_STATUS_NORMAL));
}

/* "会話の内容を"怒った"に変更要求する"処理 */
static int mMsg_Main_Cursol_SetMessageContentsAngry_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetMessageContents_ControlCursol(win_p, index_p, VOICE_STATUS_ANGRY));
}

/* "会話の内容を"哀しい"に変更要求する"処理 */
static int mMsg_Main_Cursol_SetMessageContentsSad_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetMessageContents_ControlCursol(win_p, index_p, VOICE_STATUS_SAD));
}

/* "会話の内容を"楽しい"に変更要求する"処理 */
static int mMsg_Main_Cursol_SetMessageContentsFun_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetMessageContents_ControlCursol(win_p, index_p, VOICE_STATUS_FUN));
}

/* "会話の内容を"眠い"に変更要求する"処理 */
static int mMsg_Main_Cursol_SetMessageContentsSleepy_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    return(mMsg_Main_Cursol_SetMessageContents_ControlCursol(win_p, index_p, VOICE_STATUS_SLEEPY));
}

/* "文字単位のメッセージ表示色変更"処理 */
static int mMsg_Main_Cursol_SetColorChar_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);

    /* (表示処理で色設定する) */
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
}

/* "文字表示音声の ＯＮ／ＯＦＦ"処理 */
static int mMsg_Main_Cursol_SoundCut_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    /* 命令をチェックし 発声無しフラグ を設定する */
    if (mMsg_Get_SoundCutCode(win_p, *index_p)) {
	bitclr(win_p->status, M_MSG_STATUS_SOUND_CUT);
    } else {
	bitset(win_p->status, M_MSG_STATUS_SOUND_CUT);
    }
    
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    win_p->now_end_font_code_cursol_index = *index_p;
    
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
}

/* "行オフセット設定命令"処理 */
static int mMsg_Main_Cursol_SetLineOffset_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ)(表示で処理) */
}

/* "行タイプ設定命令"処理 */
static  int mMsg_Main_Cursol_SetLineType_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ)(表示で処理) */
}

/* "文字単位のスケール設定命令"処理 */
static int mMsg_Main_Cursol_SetCharScale_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ)(表示で処理) */
}

/* "ボタン待ち(ページ送り音無し)"の場合のカーソルコントロール処理 */
static int mMsg_Main_Cursol_Button2_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    if (bitcheck(win_p->status, M_MSG_STATUS_LAST_WAIT)) {
	bitclr(win_p->status, M_MSG_STATUS_LAST_WAIT);
	*index_p += mMsg_Set_SizeCode(win_p, *index_p);
	win_p->now_end_font_code_cursol_index = *index_p;
	
	bitset(win_p->status, M_MSG_STATUS_NON_SE_OKURI);
	
	return M_MSG_RETURN_TYPE_FALSE;
    } else {
	bitset(win_p->status, M_MSG_STATUS_LAST_WAIT);	/* 1 frame 遅らせる flag */
	win_p->now_end_font_code_cursol_index = *index_p;	/* インデックスはそのまま */
	
	return M_MSG_RETURN_TYPE_TRUE;
    }
}

/* "BGM 生成"処理 */
static int mMsg_Main_Cursol_BgmMake_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    FONT_BgmNum bgm_num;
    FONT_BgmStop bgm_stop_ex;
    
    /* 命令をチェックし, ＢＧＭ Make！ */
    mMsg_Get_bgm_make(win_p, *index_p, &bgm_num, &bgm_stop_ex);
    mMsg_sound_bgm_make(bgm_num, bgm_stop_ex);
    
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    win_p->now_end_font_code_cursol_index = *index_p;
    
    return M_MSG_RETURN_TYPE_NONE;
}

/* "BGM ストップ"処理 */
static int mMsg_Main_Cursol_BgmDelete_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    FONT_BgmNum bgm_num;
    FONT_BgmStop bgm_stop_my;
    
    /* 命令をチェックし, ＢＧＭ Delete！ */
    mMsg_Get_bgm_delete(win_p, *index_p, &bgm_num, &bgm_stop_my);
    mMsg_sound_bgm_delete(bgm_num, bgm_stop_my);
    
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    win_p->now_end_font_code_cursol_index = *index_p;
    
    return M_MSG_RETURN_TYPE_NONE;
}

/* "データの最後(時間で閉じる)"処理 */
static int mMsg_Main_Cursol_MsgTimeEnd_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    win_p->now_end_font_code_cursol_index = *index_p;	/* インデックスはそのまま */
    
    if (bitcheck(win_p->status, M_MSG_STATUS_LAST_WAIT)) {
	int t;
	
        /* メッセージデータから待ち時間取得 (t : (0 〜 255)) */
	t = mMsg_Get_MsgTimeEnd_time(win_p, *index_p);
	if (t > 0) {
	    t--;	/* つじつま合せ */
	}
	
	/* タイマセット (１単位 ２フレーム) */
	win_p->end_timer = (unshort)((t << 1) + 1);
	
	bitclr(win_p->status, M_MSG_STATUS_LAST_WAIT);
	return M_MSG_RETURN_TYPE_FALSE;
    } else {
	bitset(win_p->status, M_MSG_STATUS_LAST_WAIT);	/* 1 frame 遅らせる flag */
	return M_MSG_RETURN_TYPE_TRUE;
    }
}

/* システム用トリガーＳＥ 処理 */
static int mMsg_Main_Cursol_SoundTrgSys_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    FONT_TrgSys se_num;
    
    /*  */
    mMsg_Get_sound_trg_sys(win_p, *index_p, &se_num);
    mMsg_sound_sound_trg_sys(se_num);
    
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    win_p->now_end_font_code_cursol_index = *index_p;
    
    return M_MSG_RETURN_TYPE_NONE;
}

/* 行単位のスケール設定命令 処理 */
static int mMsg_Main_Cursol_SetLineScale_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ)(表示で処理) */
}

/* ページ送り音無しセット命令 処理 */
static int mMsg_Main_Cursol_SoundNoPage_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    bitset(win_p->status, M_MSG_STATUS_NON_SE_OKURI);
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
}

/* 基準となる音声を使う セット命令 処理 */
static int mMsg_Main_Cursol_VoiceTrue_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
#if DEBUG && defined(U_sakakibara_U) && 1
    PRINTF("％ＶＴ％<%s %d>\n", __FILE__, __LINE__);
#endif
    
    mMsg_sound_spec_change_true(win_p);
    
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
}

/* 逆の音声を使う セット命令 処理 */
static int mMsg_Main_Cursol_VoiceFalse_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
#if DEBUG && defined(U_sakakibara_U) && 1
    PRINTF("％ＶＦ％<%s %d>\n", __FILE__, __LINE__);
#endif
    
    mMsg_sound_spec_change_false(win_p);
    
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
}

/* 選択肢 Ｂで一番下に セット命令 処理 */
static int mMsg_Main_Cursol_SelectNoB_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    *index_p += mMsg_Set_SizeCode(win_p, *index_p);
    
    /* Ｂボタンキャンセル連絡 */
    mChoice_no_b_set(mChoice_Get_base_window_p());
    
    return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
}

/* アイテム受け渡し開始 セット */
static int mMsg_Main_Cursol_GiveOpen_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
#ifdef MSG_TOOL	/* フリーズ回避 */
    if (chkTrigger(A_BTN)) {
	*index_p += mMsg_Set_SizeCode(win_p, *index_p);
	win_p->now_end_font_code_cursol_index = *index_p;
	
	return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
    }
#endif
    
    /* アイテム受け渡し状態になるまで次へ行かない */
    if (mMsg_Check_give_item()) {
	*index_p += mMsg_Set_SizeCode(win_p, *index_p);
	win_p->now_end_font_code_cursol_index = *index_p;
	
	return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
    } else {
	win_p->now_end_font_code_cursol_index = *index_p;
	
	return M_MSG_RETURN_TYPE_TRUE;	/* (一時停止) */
    }
}

/* アイテム受け渡し終了 セット */
static int mMsg_Main_Cursol_GiveClose_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
#ifdef MSG_TOOL	/* フリーズ回避 */
    if (chkTrigger(A_BTN)) {
	*index_p += mMsg_Set_SizeCode(win_p, *index_p);
	win_p->now_end_font_code_cursol_index = *index_p;
	
	return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
    }
#endif
    
    /* アイテム受け渡し終了まで次へ行かない */
    if (mMsg_Check_give_item() == FALSE) {
	*index_p += mMsg_Set_SizeCode(win_p, *index_p);
	win_p->now_end_font_code_cursol_index = *index_p;
	
	return M_MSG_RETURN_TYPE_NONE;	/* (次の文字へ) */
    } else {
	win_p->now_end_font_code_cursol_index = *index_p;
	
	return M_MSG_RETURN_TYPE_TRUE;	/* (一時停止) */
    }
}


/* index番目のコントロール命令に対応した処理を行う */
/* 返り値によって受け手の"return"処理が変わる */
static int mMsg_Main_Cursol_Proc_ControlCursol(M_MSG_WIN *win_p, int *index_p)
{
    unchar *data_p = win_p->msg_p->code.data;
    unchar code = data_p[*index_p];
    
    if(code == MOJI_CONT) {
	int type = (int)(data_p[(*index_p)+1]);
	static M_MSG_PROC2 proc[TOTAL_CONT] = {
	    mMsg_Main_Cursol_Last_ControlCursol,		/* CONT_LAST,			データの最後を表す */
	    mMsg_Main_Cursol_Continue_ControlCursol,		/* CONT_CONTINUE,		データの継続を表す */
	    mMsg_Main_Cursol_Clear_ControlCursol,		/* CONT_CLEAR,			文字表示クリヤー */
	    mMsg_Main_Cursol_CursolSetTime_ControlCursol,	/* CONT_CURSOL_SET_TIME,	カーソル表示タイマーセット */
	    mMsg_Main_Cursol_Button_ControlCursol,		/* CONT_BUTTON,			ボタン待ち */
	    mMsg_Main_Cursol_Color_ControlCursol,		/* CONT_COLOR,			メッセージ表示色変更 */
	    mMsg_Main_Cursol_AbleCancel_ControlCursol,		/* CONT_ABLE_CANSEL		カーソル処理キャンセル可能 */
	    mMsg_Main_Cursol_UnableCancel_ControlCursol,	/* CONT_UNABLE_CANSEL		カーソル処理キャンセル不可能 */
	    mMsg_Main_Cursol_SetDemoOrderPlayer_ControlCursol,	/* CONT_SET_DEMO_ORDER_PLAYER,	デモ命令セット(プレイヤー) */
	    mMsg_Main_Cursol_SetDemoOrderNpc0_ControlCursol,	/* CONT_SET_DEMO_ORDER_NPC0,	デモ命令セット(NPC0) */
	    mMsg_Main_Cursol_SetDemoOrderNpc1_ControlCursol,	/* CONT_SET_DEMO_ORDER_NPC1,	デモ命令セット(NPC1) */
	    mMsg_Main_Cursol_SetDemoOrderNpc2_ControlCursol,	/* CONT_SET_DEMO_ORDER_NPC2,	デモ命令セット(NPC2) */
	    mMsg_Main_Cursol_SetDemoOrderQuest_ControlCursol,	/* CONT_SET_DEMO_ORDER_QUEST,	デモ命令セット(クエスト) */
	    mMsg_Main_Cursol_SetSelectWindow_ControlCursol,	/* CONT_SET_SELECT_WINDOW,	選択ウインドウセット */
	    mMsg_Main_Cursol_SetNextMessageF_ControlCursol,	/* CONT_SET_NEXT_MESSAGE,	継続メッセージセット(強制) */
	    mMsg_Main_Cursol_SetNextMessage0_ControlCursol,	/* CONT_SET_NEXT_MESSAGE,	継続メッセージセット(選択肢が０なら) */
	    mMsg_Main_Cursol_SetNextMessage1_ControlCursol,	/* CONT_SET_NEXT_MESSAGE,	継続メッセージセット(選択肢が１なら) */
	    mMsg_Main_Cursol_SetNextMessage2_ControlCursol,	/* CONT_SET_NEXT_MESSAGE,	継続メッセージセット(選択肢が２なら) */
	    mMsg_Main_Cursol_SetNextMessage3_ControlCursol,	/* CONT_SET_NEXT_MESSAGE,	継続メッセージセット(選択肢が３なら) */
	    mMsg_Main_Cursol_SetNextMessageRamdom2_ControlCursol,/* CONT_SET_NEXT_MESSAGE_RAMDOM_2	継続メッセージセット(２個からランダムに) */
	    mMsg_Main_Cursol_SetNextMessageRamdom3_ControlCursol,/* CONT_SET_NEXT_MESSAGE_RAMDOM_3	継続メッセージセット(３個からランダムに) */
	    mMsg_Main_Cursol_SetNextMessageRamdom4_ControlCursol,/* CONT_SET_NEXT_MESSAGE_RAMDOM_4	継続メッセージセット(４個からランダムに) */
	    mMsg_Main_Cursol_SetSelectString2_ControlCursol,	/* CONT_SET_SELECT_STRING2,	選択文字列セット(２個セット) */
	    mMsg_Main_Cursol_SetSelectString3_ControlCursol,	/* CONT_SET_SELECT_STRING3,	選択文字列セット(３個セット) */
	    mMsg_Main_Cursol_SetSelectString4_ControlCursol,	/* CONT_SET_SELECT_STRING4,	選択文字列セット(４個セット) */
	    mMsg_Main_Cursol_SetForceNext_ControlCursol,	/* CONT_SET_FORCE_NEXT,		強制的にプッシュボタン待ち解除フラグセット */
	    
	    mMsg_Main_Cursol_PutString_PlayerName_ControlCursol,/* CONT_PUT_PLAYER_NAME,	"プレイヤー名の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_TalkName_ControlCursol,	/* CONT_PUT_TALK_NAME,		"話し手名の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Tail_ControlCursol,	/* CONT_PUT_TAIL,		"語尾の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Year_ControlCursol,	/* CONT_PUT_YEAR,		"年の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Month_ControlCursol,	/* CONT_PUT_MONTH,		"月の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Week_ControlCursol,	/* CONT_PUT_WEEK,		"曜日の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Day_ControlCursol,	/* CONT_PUT_DAY,		"日の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Hour_ControlCursol,	/* CONT_PUT_HOUR,		"時の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Min_ControlCursol,	/* CONT_PUT_MIN,		"分の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Sec_ControlCursol,	/* CONT_PUT_SEC,		"秒の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free0_ControlCursol,	/* CONT_PUT_FREE0,		"自由文字列０の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free1_ControlCursol,	/* CONT_PUT_FREE1,		"自由文字列１の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free2_ControlCursol,	/* CONT_PUT_FREE2,		"自由文字列２の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free3_ControlCursol,	/* CONT_PUT_FREE3,		"自由文字列３の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free4_ControlCursol,	/* CONT_PUT_FREE4,		"自由文字列４の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free5_ControlCursol,	/* CONT_PUT_FREE5,		"自由文字列５の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free6_ControlCursol,	/* CONT_PUT_FREE6,		"自由文字列６の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free7_ControlCursol,	/* CONT_PUT_FREE7,		"自由文字列７の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free8_ControlCursol,	/* CONT_PUT_FREE8,		"自由文字列８の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free9_ControlCursol,	/* CONT_PUT_FREE9,		"自由文字列９の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Determination_ControlCursol,	/* CONT_PUT_DETERMINATION,	"決定文字列の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_CountryName_ControlCursol,	/* CONT_PUT_COUNTRY_NAME,	"国名・置き換え" */
	    mMsg_Main_Cursol_PutString_RamdomNumber2_ControlCursol,	/* CONT_PUT_RAMDOM_NUMBER2,	"０から９９の乱数・置き換え" */
	    mMsg_Main_Cursol_PutString_Item0_ControlCursol,	/* CONT_PUT_ITEM0,		"アイテム文字列０の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Item1_ControlCursol,	/* CONT_PUT_ITEM1,		"アイテム文字列１の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Item2_ControlCursol,	/* CONT_PUT_ITEM2,		"アイテム文字列２の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Item3_ControlCursol,	/* CONT_PUT_ITEM3,		"アイテム文字列３の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Item4_ControlCursol,	/* CONT_PUT_ITEM4,		"アイテム文字列４の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free10_ControlCursol,	/* CONT_PUT_FREE10,		"自由文字列１０の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free11_ControlCursol,	/* CONT_PUT_FREE11,		"自由文字列１１の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free12_ControlCursol,	/* CONT_PUT_FREE12,		"自由文字列１２の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free13_ControlCursol,	/* CONT_PUT_FREE13,		"自由文字列１３の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free14_ControlCursol,	/* CONT_PUT_FREE14,		"自由文字列１４の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free15_ControlCursol,	/* CONT_PUT_FREE15,		"自由文字列１５の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free16_ControlCursol,	/* CONT_PUT_FREE16,		"自由文字列１６の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free17_ControlCursol,	/* CONT_PUT_FREE17,		"自由文字列１７の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free18_ControlCursol,	/* CONT_PUT_FREE18,		"自由文字列１８の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Free19_ControlCursol,	/* CONT_PUT_FREE19,		"自由文字列１９の置き換え"処理 */
	    mMsg_Main_Cursol_PutString_Mail0_ControlCursol,	/* CONT_PUT_MAIL0		"手紙文字列０の置き換え"処理 */
	    mMsg_Main_Cursol_SetPlayerDestiny0_ControlCursol,	/* CONT_SET_PLAYER_DESTINY0	プレイヤーの状態を０に変更 */
	    mMsg_Main_Cursol_SetPlayerDestiny1_ControlCursol,	/* CONT_SET_PLAYER_DESTINY1	プレイヤーの状態を１に変更 */
	    mMsg_Main_Cursol_SetPlayerDestiny2_ControlCursol,	/* CONT_SET_PLAYER_DESTINY2	プレイヤーの状態を２に変更 */
	    mMsg_Main_Cursol_SetPlayerDestiny3_ControlCursol,	/* CONT_SET_PLAYER_DESTINY3	プレイヤーの状態を３に変更 */
	    mMsg_Main_Cursol_SetPlayerDestiny4_ControlCursol,	/* CONT_SET_PLAYER_DESTINY4	プレイヤーの状態を４に変更 */
	    mMsg_Main_Cursol_SetPlayerDestiny5_ControlCursol,	/* CONT_SET_PLAYER_DESTINY5	プレイヤーの状態を５に変更 */
	    mMsg_Main_Cursol_SetPlayerDestiny6_ControlCursol,	/* CONT_SET_PLAYER_DESTINY6	プレイヤーの状態を６に変更 */
	    mMsg_Main_Cursol_SetPlayerDestiny7_ControlCursol,	/* CONT_SET_PLAYER_DESTINY7	プレイヤーの状態を７に変更 */
	    mMsg_Main_Cursol_SetPlayerDestiny8_ControlCursol,	/* CONT_SET_PLAYER_DESTINY8	プレイヤーの状態を８に変更 */
	    mMsg_Main_Cursol_SetPlayerDestiny9_ControlCursol,	/* CONT_SET_PLAYER_DESTINY9	プレイヤーの状態を９に変更 */
	    mMsg_Main_Cursol_SetMessageContentsNormal_ControlCursol,	/* CONT_SET_MESSAGE_CONTENTS_NORMAL	会話の内容を"通常"に変更 */
	    mMsg_Main_Cursol_SetMessageContentsAngry_ControlCursol,	/* CONT_SET_MESSAGE_CONTENTS_ANGRY	会話の内容を"怒った"に変更 */
	    mMsg_Main_Cursol_SetMessageContentsSad_ControlCursol,	/* CONT_SET_MESSAGE_CONTENTS_SAD	会話の内容を"哀しい"に変更 */
	    mMsg_Main_Cursol_SetMessageContentsFun_ControlCursol,	/* CONT_SET_MESSAGE_CONTENTS_FUN	会話の内容を"楽しい"に変更 */
	    mMsg_Main_Cursol_SetMessageContentsSleepy_ControlCursol,	/* CONT_SET_MESSAGE_CONTENTS_SLEEPY	会話の内容を"眠い"に変更 */
	    mMsg_Main_Cursol_SetColorChar_ControlCursol,		/* CONT_SET_COLOR_CHAR	文字単位のメッセージ表示色変更 */
	    mMsg_Main_Cursol_SoundCut_ControlCursol,			/* CONT_SOUND_CUT	文字表示音声の ＯＮ／ＯＦＦ */
	    mMsg_Main_Cursol_SetLineOffset_ControlCursol,		/* CONT_SET_LINE_OFFSET	行オフセット設定命令 */
	    mMsg_Main_Cursol_SetLineType_ControlCursol,			/* CONT_SET_LINE_TYPE	行タイプ設定命令 */
	    mMsg_Main_Cursol_SetCharScale_ControlCursol,		/* CONT_SET_CHAR_SCALE	文字単位のスケール設定命令 */
	    mMsg_Main_Cursol_Button2_ControlCursol,		/* CONT_BUTTON2		ボタン待ち (ページ送り音無し) */
	    mMsg_Main_Cursol_BgmMake_ControlCursol,		/* CONT_BGM_MAKE 	BGM 生成 */
	    mMsg_Main_Cursol_BgmDelete_ControlCursol,		/* CONT_BGM_DELETE	BGM 削除 */
	    mMsg_Main_Cursol_MsgTimeEnd_ControlCursol,		/* CONT_MSG_TIME_END	データの最後(時間で閉じる) */
	    mMsg_Main_Cursol_SoundTrgSys_ControlCursol,		/* CONT_SOUND_TRG_SYS	システム用トリガーＳＥ */
	    mMsg_Main_Cursol_SetLineScale_ControlCursol,	/* CONT_SET_CHAR_SCALE	行単位のスケール設定命令 */
	    mMsg_Main_Cursol_SoundNoPage_ControlCursol,		/* CONT_SOUND_NO_PAGE	ページ送り音無しセット */
	    mMsg_Main_Cursol_VoiceTrue_ControlCursol,		/* CONT_VOICE_TRUE	基準となる音声を使う */
	    mMsg_Main_Cursol_VoiceFalse_ControlCursol,		/* CONT_VOICE_FALSE	逆の音声を使う */
	    mMsg_Main_Cursol_SelectNoB_ControlCursol,		/* CONT_SELECT_NO_B	選択肢 Ｂで一番下を選択 */
	    mMsg_Main_Cursol_GiveOpen_ControlCursol,		/* CONT_GIVE_OPEN	アイテム受け渡し開始 */
	    mMsg_Main_Cursol_GiveClose_ControlCursol,		/* CONT_GIVE_CLOSE	アイテム受け渡し終了 */
	};
	
	if(!((0 <= type) && (type < TOTAL_CONT) && (proc[type] != NULL))) {
#if DEBUG
	    PRINTF(ESC_ERROR
		   "mMsg_Main_Cursol_Proc_ControlCursol:変なコントロールコードが來た!!!!!!!!!!!!!!!\n"
		   ESC_NORMAL);
	    assert(0);
#endif
	    return(M_MSG_RETURN_TYPE_NONE);
	}
	else {
	    return ((proc[type])(win_p, index_p));
	}
    }
    else {
#if DEBUG
	PRINTF(ESC_WARNING
	       "mMsg_Main_Cursol_Proc_ControlCursol:コントロールコードでない!!!!!!!!!!!!!!!\n"
	       ESC_NORMAL);
#endif
	return(M_MSG_RETURN_TYPE_NONE);
    }
}

/* カーソルの移動（移動終了なら"FALSE"） */
static int mMsg_Main_Cursol_ControlCursol(M_MSG_WIN *win_p)
{
    int now_end_font_code_cursol_index = win_p->now_end_font_code_cursol_index;
    int code_index = now_end_font_code_cursol_index;
    float *cursol_timer_p = &(win_p->cursol_timer);
    int choice_hide_flag = (mChoice_check_main_index(&(win_p->choice_win)) == M_CHOICE_MAIN_HIDE);
    int ret_flag = TRUE;	/* default */
    
    /* Ｂボタンクイックチェック */
    if (chkTrigger(B_BTN)) {
	bitset(win_p->status, M_MSG_STATUS_QUICK);
    }

    /*  */
    if (mMsg_Check_CancelOrder(win_p)) {
	win_p->flag_cancel = TRUE;
    }
    
    if (win_p->flag_cancel) {	/* カーソルキャンセル */
	*cursol_timer_p = 0.0f;
    } else  if (bitcheck(win_p->status, M_MSG_STATUS_QUICK)) {	/* Ｂボタンクイック */
	/* カーソルタイマ処理が１フレームで終わるように */
	*cursol_timer_p = 0.0f;
    } else {
//    *cursol_timer_p -= (1.0F * M_SPD_SPEED_MUL_F);
	*cursol_timer_p -= 1.0f;
	
	if (*cursol_timer_p <= 0.0f) {
	    *cursol_timer_p = 0.0f;
	}
    }
    
    /* 選択ウィンドウ 隠れ後のタイマ設定 */
    if (choice_hide_flag) {
	if (win_p->choice_hide_timer > 0) {
	    (win_p->choice_hide_timer)--;
	}
    } else {
	win_p->choice_hide_timer = 3;
    }
    
    /* "現在,発声しているか"のフラグを解除 */
    mMsg_Unset_NowUtter(win_p);
    
    if ((*cursol_timer_p <= 0.0F) && choice_hide_flag) {
	unchar code;
	
	while (1) {
	    code = win_p->msg_p->code.data[code_index];
	    
	    if (mMsg_Check_CancelOrder(win_p)) {
		win_p->flag_cancel = TRUE;
	    } else if (code == MOJI_RETURN) {
		code_index += mMsg_Set_SizeCode(win_p, code_index);
		(win_p->now_display_line)++;
	    } else if (code == MOJI_SHIFT) {
		code_index += mMsg_Set_SizeCode(win_p, code_index);
#if DEBUG
		PRINTF(ESC_ERROR"MOJI_SHIFT が入っている!!(%s %d)\n"
		       ESC_NORMAL, __FILE__, __LINE__);
#endif
	    } else if (mMsg_Main_Cursol_Check_ControlCursol(win_p, code_index)) {
		int value = mMsg_Main_Cursol_Proc_ControlCursol(win_p, &code_index);
		
		if (value == M_MSG_RETURN_TYPE_FALSE) {
		    /* 直前に選択ウィンドウが開いていたときは通達しない */
		    if (win_p->choice_hide_timer == 0) {
			mMsg_sound_voice_endcode_set(win_p);	/* end 通達 */
		    }
		    ret_flag =  FALSE;	/***** カーソル処理終了！ ****/
		    break;	/* 〓〓〓〓 ブレーク 〓〓〓〓 */
		} else if (value == M_MSG_RETURN_TYPE_TRUE) {
		    break;	/* 〓〓〓〓 ブレーク 〓〓〓〓 */
		}
	    } else {
		int now_code_index = code_index;
		
		code_index += mMsg_Set_SizeCode(win_p, code_index);
		win_p->now_end_font_code_cursol_index = code_index;
		
		/* 表示速度をサウンド側へ伝える */
		mMsg_sound_MessageSpeedClear();
		if (win_p->flag_cancel == FALSE) {
		    if (mMsg_sound_CodeVoice(win_p, now_code_index)) {	/* 声を出しているなら */
			/* "現在,発声しているか"のフラグをセット */
			mMsg_Set_NowUtter(win_p);
		    }
		    break;	/* 〓〓〓〓 ブレーク 〓〓〓〓 */
		}
	    }
	}
    }
    
    return ret_flag;
}

/* "カーソル"から切り替えを要請 */
static void mMsg_request_main_index_fromCursol(M_MSG_WIN *win_p, int cursolling)
{
    if(cursolling == FALSE) {
	/* メッセージのメイン処理変更を要求 */
	mMsg_request_main_normal(win_p,
				 M_MSG_INIT_ELEMENT_NONE_INSETUP,
				 M_MSG_REQUEST_PRIORITY_NORMAL);
    }
#if 0
    /* メッセージスクロールキャンセル */
    else if(chkTrigger(B_BTN)) {
	if(0) {
	    /* スクロールコードのキャンセル処理 */
	}
    }
#endif
}

/*
 ******************************************************************************
 *	メッセージウインドウの"カーソル"メインの処理（おおもと）
 ******************************************************************************
 */
static void mMsg_Main_Cursol(M_MSG_WIN *win_p, GAME *game_p)
{
    int cursolling;
    
    /* カーソルの移動 */
    cursolling = mMsg_Main_Cursol_ControlCursol(win_p);
    /* "カーソル"から切り替えを要請 */
    mMsg_request_main_index_fromCursol(win_p, cursolling);
    /* セットアップ */
    mMsg_MainSetup_Window(win_p, game_p);
    
    if (win_p->main_index != M_MSG_MAIN_CURSOL) {
	bitclr(win_p->status, M_MSG_STATUS_QUICK);
    }
}

/*
 ******************************************************************************
 *	"カーソル"メインへのセットアップ
 ******************************************************************************
 */
static void mMsg_MainSetup_Cursol(M_MSG_WIN *win_p, GAME *game_p)
{
    M_MSG_REQUEST_MAIN_CURSOL_DATA	*request_main_cursol_data_p = &(win_p->request_main_data.cursol);
    s32	flag = request_main_cursol_data_p->flag;

    (void)game_p;
    
    /* メイン処理のインデックスを変更 */
    win_p->main_index = M_MSG_MAIN_CURSOL;
    /* 描画処理を通す */
    win_p->flag_draw = TRUE;

    /* リクエストされたメイン処理のインデックス */
    win_p->request_main_index = -1;
    /* リクエスト優先順位 */
    win_p->request_priority = M_MSG_REQUEST_PRIORITY_NORMAL_LOWER1;

    /* clear */
    win_p->end_timer = 0;
    bitclr(win_p->status, M_MSG_STATUS_LAST_WAIT);
    
    if(flag !=  M_MSG_INIT_CURSOL_FROM_WAIT) {
	/* メッセージウインドウのボタン待ち点滅時間 */
	win_p->display_button_turn = FALSE;
    }
    
    /* 選択ウィンドウ 隠れ後のタイマクリア */
    win_p->choice_hide_timer =0;
}
