/************************************************************************/
/*	FILE : sample.c							*/
/*									*/
/************************************************************************/
#include			<stdio.h>
#include			<locale.h>
#include			"xwins.h"
#include			"app_glob.c"
#include			"dir_glob.c"

#define				MAINXPOS		0
#define				MAINYPOS		0
#define				MAINWIDTH		1000
#define				MAINHEIGHT		600

#define				LABEL_XPOS		516
#define				LABEL_YPOS		16
#define				LABEL1_XPOS		32
#define				LABEL1_YPOS		32
#define				LABEL2_XPOS		32
#define				LABEL2_YPOS		260
#define				LABEL3_XPOS		30
#define				LABEL3_YPOS		500
#define				LABEL4_XPOS		50
#define				LABEL4_YPOS		400

#define				unchar			unsigned char

FILE				*fpw0;

char				enemy_label[]		= "ＥＮＥＭＹ　ＮＡＭＥ";
char				init_label[]		= "Ｉｎｉｔｉａｌ";
char				move_label[]		= "Ｍｏｖｅ";
char				fail_label[]		= "Ｆａｉｌ";
char				nose_label[]		= "Ｒｉｄｅ　ｏｎ";

char				objsize_label[]		= "ＯＢＪ衝突サイズ．．．（０〜１Ｆ）";
char				throw_label[]		= "投げた敵に当たるか？";
char				eat_label[]		= "食べれない？";
char				enen_label[]		= "敵どうし衝突するか？";
char				plen_label[]		= "プレイヤー衝突チェックのみ？";
char				enen0_label[]		= "敵ｖｓ敵衝突チェックされるか？";
char				enen1_label[]		= "敵ｖｓ敵衝突チェックするか？";
char				plen0_label[]		= "踏んだら．．．";
char				plen1_label[]		= "横から当たると．．．";

char				bgsize_label[]		= "ＢＧチェックサイズ．．．";
char				yclear_label[]		= "Ｙスピードクリアなし？";
char				yoko_label[]		= "ＢＧに横から当たると．．．";
char				tate_label[]		= "下のＢＧが無いと．．．";
char				xrev_label[]		= "反転するときＸ　ＳＰＥＥＤは？";
char				eat2_label[]		= "食べたとき．．．";

char				oamset_label[]		= "ＯＡＭセットタイプ．．．";
char				clrsize_label[]		= "範囲クリアサイズ．．．";
char				tama_label[]		= "シャボン玉になる？";
char				enmy_label[]		= "敵か？";
char				item_label[]		= "アイテム？";
char				point_label[]		= "点数";
char				objsum_label[]		= "ＯＢＪ使用数";

char				attr_label[]		= "ＯＢＪどうしの優先順位は．．．";
char				flip_label[]		= "フリップは．．．";
char				attr2_label[]		= "ＢＧとの優先順位は．．．";
char				color_label[]		= "カラーは．．．";

char				gpow_label[]		= "ＧＰＯＷは．．．";
char				gmax_label[]		= "ＧＭＡＸは．．．";

char				mode7_label[]		= "Ｍｏｄｅ７　ｃｈｒ．　ａｄｄｒ．";


char				dummy[2]		="";

char				init_sw_label[8]	="";
char				move_sw_label[8]	="";
char				fail_sw_label[8]	="";
char				nose_sw_label[8]	="";

char				objsize_sw0_label[4];
char				objsize_sw1_label[4];
char				throw_sw_label[8];
char				eat_sw_label[8];
char				enen_sw_label[8];
char				plen_sw_label[8];
char				enen0_sw_label[8];
char				enen1_sw_label[8];
char				plen0_sw_label[20];
char				plen1_sw_label[20];

char				bgsize_sw0_label[4];
char				bgsize_sw1_label[4];
char				yclear_sw_label[8];
char				yoko_sw_label[12];
char				tate_sw_label[8];
char				xrev_sw_label[8];
char				eat2_sw_label[16];

char				oamset_sw_label[10];
char				clrsize_sw_label[4];
char				tama_sw_label[4];
char				enmy_sw_label[12];
char				item_sw_label[8];
char				point_sw_label[4];
char				objsum_sw0_label[4];
char				objsum_sw1_label[4];

char				attr_sw_label[22];
char				flip_sw_label[16];
char				attr2_sw_label[4];
char				color_sw_label[4];

char				gpow_sw0_label[4];
char				gpow_sw1_label[4];
char				gmax_sw0_label[4];
char				gmax_sw1_label[4];
char				gmax_sw2_label[4];
char				gmax_sw3_label[4];

char				mode7_sw0_label[4];
char				mode7_sw1_label[4];
char				mode7_sw2_label[4];
char				mode7_sw3_label[4];

char				a_moji[]		= "Ａ";
char				b_moji[]		= "Ｂ";
char				c_moji[]		= "Ｃ";
char				d_moji[]		= "Ｄ";
char				e_moji[]		= "Ｅ";
char				f_moji[]		= "Ｆ";
char				g_moji[]		= "Ｇ";
char				h_moji[]		= "Ｈ";
char				i_moji[]		= "Ｉ";
char				j_moji[]		= "Ｊ";
char				k_moji[]		= "Ｋ";
char				l_moji[]		= "Ｌ";
char				m_moji[]		= "Ｍ";
char				n_moji[]		= "Ｎ";
char				o_moji[]		= "Ｏ";
char				p_moji[]		= "Ｐ";
char				q_moji[]		= "Ｑ";
char				r_moji[]		= "Ｒ";
char				s_moji[]		= "Ｓ";
char				t_moji[]		= "Ｔ";
char				u_moji[]		= "Ｕ";
char				v_moji[]		= "Ｖ";
char				w_moji[]		= "Ｗ";
char				x_moji[]		= "Ｘ";
char				y_moji[]		= "Ｙ";
char				z_moji[]		= "Ｚ";

char				s0_moji[]		= "０";
char				s1_moji[]		= "１";
char				s2_moji[]		= "２";
char				s3_moji[]		= "３";
char				s4_moji[]		= "４";
char				s5_moji[]		= "５";
char				s6_moji[]		= "６";
char				s7_moji[]		= "７";
char				s8_moji[]		= "８";
char				s9_moji[]		= "９";

char				bs_moji[]		= "ＢＳ";
char				clr_moji[]		= "ＣＬＲ";

char				num_label[]		= "Ｎｏ．";
char				num_sw0_label[6];
char				num_sw1_label[6];
char				add_label[]		= "Ａｄｄ";
char				del_label[]		= "Ｄｅｌ";
char				prev_label[]		= "Ｐｒｅｖ";
char				next_label[]		= "Ｎｅｘｔ";
char				make_label[]		= "Ｍａｋｅ";
char				quit_label[]		= "Ｑｕｉｔ";

static	char			*suuji_s[]		= {"0","1","2","3","4","5","6","7","8","9"};

static	char			*suuji[]		= {"０","１","２","３","４","５","６","７","８","９",
								"Ａ","Ｂ","Ｃ","Ｄ","Ｅ","Ｆ"};

static	char			*alpha_ss[]		= {"a","b","c","d","e","f","g","h","i","j","k","l","m",
								"n","o","p","q","r","s","t","u","v","w","x","y","z"};

static	char			*alpha_sl[]		= {"A","B","C","D","E","F","G","H","I","J","K","L","M",
								"N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};

static	char			*alpha_ls[]		= {"ａ","ｂ","ｃ","ｄ","ｅ","ｆ","ｇ","ｈ","ｉ","ｊ","ｋ",
								"ｌ","ｍ","ｎ","ｏ","ｐ","ｑ","ｒ","ｓ","ｔ","ｕ",
								"ｖ","ｗ","ｘ","ｙ","ｚ"};

static	char			*alpha_ll[]		= {"Ａ","Ｂ","Ｃ","Ｄ","Ｅ","Ｆ","Ｇ","Ｈ","Ｉ","Ｊ","Ｋ",
								"Ｌ","Ｍ","Ｎ","Ｏ","Ｐ","Ｑ","Ｒ","Ｓ","Ｔ","Ｕ",
								"Ｖ","Ｗ","Ｘ","Ｙ","Ｚ"};

static	char			*yesno[]		= {"ＮＯ","ＹＥＳ"};

static	char			*onoff[]		= {"ＯＦＦ","ＯＮ"};

static	char			*plen0_ans[]		= {"タマゴ０になる","タマゴ１になる","タマゴ２になる","ナシ",
								"ナシ","プレイヤーダメージ","乗れる","死ぬ"};

static	char			*plen1_ans[]		= {"はね返す","プレイヤーダメージ","当たらない","はね返る"};

static	char			*yoko_ans[]		= {"何もしない","反転する","止まる"};

static	char			*tate_ans[]		= {"落ちる","反転する","止まる"};

static	char			*xrev_ans[]		= {"反転","クリア"};

static	char			*eat2_ans[]		= {"口に入れるだけ","食べる","変身その１","変身その２",
								"変身その３","変身その４","変身その５","変身その６"};

static	char			*oamset_ans[]		= {"１キャラ","ＥＭＵ","その他","ナシ"};

static	char			*enmy_ans[]		= {"敵だよん","敵じゃない"};

static	char			*attr_ans[]		= {"表\示なし","プレイヤーの前　０","プレイヤーの前　１",
								"プレイヤーの前　２","プレイヤーの前　３",
								"プレイヤーと同じ　４","プレイヤーの後　５",
								"プレイヤーの後　６","プレイヤーの後　７"};

static	char			*flip_ans[]		= {"なし","Ｈフリップ","Ｖフリップ","Ｈ、Ｖフリップ"};

int				data_sum;
char				sel_lock;
char				dummy_name[12];
char				enemy_disp[12]		="";
int				num;

struct	values{
	char				enemy_name[12];
	char				enemy_name0[7];

	char				init_value,move_value,fail_value,nose_value;

	char				objsize_value;
	char				throw_value;
	char				eat_value;
	char				enen_value;
	char				plen_value;
	char				enen0_value;
	char				enen1_value;
	char				plen0_value;
	char				plen1_value;

	char				bgsize_value;
	char				yclear_value;
	char				yoko_value;
	char				tate_value;
	char				xrev_value;
	char				eat2_value;

	char				oamset_value;
	char				clrsize_value;
	char				tama_value;
	char				enmy_value;
	char				item_value;
	char				point_value;
	char				objsum_value;

	char				attr_value;
	char				flip_value;
	char				attr2_value;
	char				color_value;

	char				gpow_value;
	int				gmax_value;

	int				mode7_value;

	struct	values			*next_ptr;
	struct	values			*previous_ptr;
};

	struct	values	*first_ptr;
	struct	values	*now_ptr;
	struct	values	*before_ptr = NULL;
	struct	values	*after_ptr = NULL;
	struct	values	*new_ptr;
	struct	values	*save_ptr;

	int	new_area();
	int	win_data();

	XWIN	*which_xwin, *QuitButton, *Num, *AddButton, *DelButton, *PrevButton, *NextButton;
	XWIN	*MakeButton;

	XWIN	*Enemy, *Init, *Move, *Fail, *Nose;

	XWIN	*Objsize, *Throw, *Eat, *Enen, *Plen, *Enen0, *Enen1, *Plen0, *Plen1;
	XWIN	*Bgsize, *Yclear, *Yoko, *Tate, *Xrev, *Eat2;
	XWIN	*Oamset, *Clrsize, *Tama, *Enmy, *Item, *Point, *Objsum;
	XWIN	*Attr, *Flip, *Attr2, *Color;
	XWIN	*Gpow, *Gmax;
	XWIN	*Mode7;


	XWIN	*Num_sw, *Num_sw0, *Num_sw1;

	XWIN	*Enemy_name, *Init_sw0, *Move_sw0, *Fail_sw0, *Nose_sw0;

	XWIN	*Objsize_sw, *Objsize_sw0, *Objsize_sw1, *Throw_sw0, *Eat_sw0, *Enen_sw0, *Plen_sw0;
	XWIN	*Enen0_sw0, *Enen1_sw0, *Plen0_sw0, *Plen1_sw0;
	XWIN	*Bgsize_sw, *Bgsize_sw0, *Bgsize_sw1, *Yclear_sw0, *Yoko_sw0, *Tate_sw0, *Xrev_sw0, *Eat2_sw0;
	XWIN	*Oamset_sw0, *Clrsize_sw0, *Tama_sw0, *Enmy_sw0, *Item_sw0, *Point_sw0, *Objsum_sw, *Objsum_sw0, *Objsum_sw1;
	XWIN	*Attr_sw0, *Flip_sw0, *Attr2_sw0, *Color_sw0;
	XWIN	*Gpow_sw, *Gpow_sw0, *Gpow_sw1, *Gmax_sw, *Gmax_sw0, *Gmax_sw1, *Gmax_sw2, *Gmax_sw3;
	XWIN	*Mode7_sw, *Mode7_sw0, *Mode7_sw1, *Mode7_sw2, *Mode7_sw3;

	XWIN	*Board;
	XWIN	*A_sw0, *B_sw0, *C_sw0, *D_sw0, *E_sw0, *F_sw0, *G_sw0, *H_sw0, *I_sw0, *J_sw0, *K_sw0, *L_sw0;
	XWIN	*M_sw0, *N_sw0, *O_sw0, *P_sw0, *Q_sw0, *R_sw0, *S_sw0, *T_sw0, *U_sw0, *V_sw0, *W_sw0, *X_sw0;
	XWIN	*Y_sw0, *Z_sw0;

	XWIN	*S0_sw0, *S1_sw0, *S2_sw0, *S3_sw0, *S4_sw0, *S5_sw0, *S6_sw0, *S7_sw0, *S8_sw0, *S9_sw0;

	XWIN	*Bs_sw0, *Clr_sw0;



/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _init_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->init_value	= (now_ptr->init_value == 0) ? 1: 0;
			if(now_ptr->init_value == 0)	XSetWindowBackground(display, Init_sw0->xid,BG);
			else				XSetWindowBackground(display, Init_sw0->xid,FG);
			strcpy(init_sw_label, onoff[now_ptr->init_value]);
			XClearArea(display, Init_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _move_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->move_value	= (now_ptr->move_value == 0) ? 1: 0;
			if(now_ptr->move_value == 0)	XSetWindowBackground(display, Move_sw0->xid,BG);
			else				XSetWindowBackground(display, Move_sw0->xid,FG);
			strcpy(move_sw_label, onoff[now_ptr->move_value]);
			XClearArea(display, Move_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _fail_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->fail_value	= (now_ptr->fail_value == 0) ? 1: 0;
			if(now_ptr->fail_value == 0)	XSetWindowBackground(display, Fail_sw0->xid,BG);
			else				XSetWindowBackground(display, Fail_sw0->xid,FG);
			strcpy(fail_sw_label, onoff[now_ptr->fail_value]);
			XClearArea(display, Fail_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _nose_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->nose_value	= (now_ptr->nose_value == 0) ? 1: 0;
			if(now_ptr->nose_value == 0)	XSetWindowBackground(display, Nose_sw0->xid,BG);
			else				XSetWindowBackground(display, Nose_sw0->xid,FG);
			strcpy(nose_sw_label, onoff[now_ptr->nose_value]);
			XClearArea(display, Nose_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Objsize Switch		(5-7bit)		*/
/********************************************************/
int _objsize_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->objsize_value	= (now_ptr->objsize_value > 15) ? now_ptr->objsize_value - 16: now_ptr->objsize_value + 16;
			objsize_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Objsize Switch		(0-4bit)		*/
/********************************************************/
int _objsize_sw1(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->objsize_value = (now_ptr->objsize_value + 1 > 31) ? 0: now_ptr->objsize_value + 1;
			objsize_disp();
			break;
		case 2:
			now_ptr->objsize_value = (now_ptr->objsize_value - 1 < 0) ? 31: now_ptr->objsize_value - 1;
			objsize_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Objsize Switch					*/
/********************************************************/
objsize_disp()
{
			strcpy(objsize_sw0_label, suuji[now_ptr->objsize_value / 16]);
			XClearArea(display, Objsize_sw0->xid, 0, 0, 0, 0, True);
			strcpy(objsize_sw1_label, suuji[now_ptr->objsize_value % 16]);
			XClearArea(display, Objsize_sw1->xid, 0, 0, 0, 0, True);
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _throw_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->throw_value	= (now_ptr->throw_value == 0) ? 1: 0;
			if(now_ptr->throw_value == 0)	XSetWindowBackground(display,Throw_sw0->xid,BG);
			else				XSetWindowBackground(display,Throw_sw0->xid,FG);
			strcpy(throw_sw_label, yesno[now_ptr->throw_value]);
			XClearArea(display, Throw_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _eat_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->eat_value	= (now_ptr->eat_value == 0) ? 1: 0;
			if(now_ptr->eat_value == 0)	XSetWindowBackground(display,Eat_sw0->xid,BG);
			else				XSetWindowBackground(display,Eat_sw0->xid,FG);
			strcpy(eat_sw_label, yesno[now_ptr->eat_value]);
			XClearArea(display, Eat_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _enen_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->enen_value	= (now_ptr->enen_value == 0) ? 1: 0;
			if(now_ptr->enen_value == 0)	XSetWindowBackground(display,Enen_sw0->xid,BG);
			else				XSetWindowBackground(display,Enen_sw0->xid,FG);
			strcpy(enen_sw_label, yesno[now_ptr->enen_value]);
			XClearArea(display, Enen_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}


/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _plen_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->plen_value	= (now_ptr->plen_value == 0) ? 1: 0;
			if(now_ptr->plen_value == 0)	XSetWindowBackground(display,Plen_sw0->xid,BG);
			else				XSetWindowBackground(display,Plen_sw0->xid,FG);
			strcpy(plen_sw_label, yesno[now_ptr->plen_value]);
			XClearArea(display, Plen_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}


/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _enen0_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->enen0_value	= (now_ptr->enen0_value == 0) ? 1: 0;
			if(now_ptr->enen0_value == 0)	XSetWindowBackground(display,Enen0_sw0->xid,BG);
			else				XSetWindowBackground(display,Enen0_sw0->xid,FG);
			strcpy(enen0_sw_label, yesno[now_ptr->enen0_value]);
			XClearArea(display, Enen0_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}


/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _enen1_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->enen1_value	= (now_ptr->enen1_value == 0) ? 1: 0;
			if(now_ptr->enen1_value == 0)	XSetWindowBackground(display,Enen1_sw0->xid,BG);
			else				XSetWindowBackground(display,Enen1_sw0->xid,FG);
			strcpy(enen1_sw_label, yesno[now_ptr->enen1_value]);
			XClearArea(display, Enen1_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}


/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _plen0_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->plen0_value++)>6)	now_ptr->plen0_value=7;
			strcpy(plen0_sw_label, plen0_ans[now_ptr->plen0_value]);
			XClearArea(display, Plen0_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->plen0_value--)<1)	now_ptr->plen0_value=0;
			strcpy(plen0_sw_label, plen0_ans[now_ptr->plen0_value]);
			XClearArea(display, Plen0_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}


/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _plen1_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->plen1_value++)>2)	now_ptr->plen1_value=3;
			strcpy(plen1_sw_label, plen1_ans[now_ptr->plen1_value]);
			XClearArea(display, Plen1_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->plen1_value--)<1)	now_ptr->plen1_value=0;
			strcpy(plen1_sw_label, plen1_ans[now_ptr->plen1_value]);
			XClearArea(display, Plen1_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Bgsize Switch		(5-7bit)		*/
/********************************************************/
int _bgsize_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->bgsize_value	= (now_ptr->bgsize_value > 15) ? now_ptr->bgsize_value - 16: now_ptr->bgsize_value + 16;
			bgsize_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Bgsize Switch		(0-4bit)		*/
/********************************************************/
int _bgsize_sw1(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->bgsize_value = (now_ptr->bgsize_value + 1 > 31) ? 0: now_ptr->bgsize_value + 1;
			bgsize_disp();
			break;
		case 2:
			now_ptr->bgsize_value = (now_ptr->bgsize_value - 1 < 0) ? 31: now_ptr->bgsize_value - 1;
			bgsize_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Bgsize Switch					*/
/********************************************************/
bgsize_disp()
{
			strcpy(bgsize_sw0_label, suuji[now_ptr->bgsize_value / 16]);
			XClearArea(display, Bgsize_sw0->xid, 0, 0, 0, 0, True);
			strcpy(bgsize_sw1_label, suuji[now_ptr->bgsize_value % 16]);
			XClearArea(display, Bgsize_sw1->xid, 0, 0, 0, 0, True);
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _yclear_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->yclear_value	= (now_ptr->yclear_value == 0) ? 1: 0;
			if(now_ptr->yclear_value == 0)	XSetWindowBackground(display,Yclear_sw0->xid,BG);
			else				XSetWindowBackground(display,Yclear_sw0->xid,FG);
			strcpy(yclear_sw_label, yesno[now_ptr->yclear_value]);
			XClearArea(display, Yclear_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _yoko_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->yoko_value++)>1)		now_ptr->yoko_value=2;
			strcpy(yoko_sw_label, yoko_ans[now_ptr->yoko_value]);
			XClearArea(display, Yoko_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->yoko_value--)<1)		now_ptr->yoko_value=0;
			strcpy(yoko_sw_label, yoko_ans[now_ptr->yoko_value]);
			XClearArea(display, Yoko_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _tate_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->tate_value++)>1)		now_ptr->tate_value=2;
			strcpy(tate_sw_label, tate_ans[now_ptr->tate_value]);
			XClearArea(display, Tate_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->tate_value--)<1)		now_ptr->tate_value=0;
			strcpy(tate_sw_label, tate_ans[now_ptr->tate_value]);
			XClearArea(display, Tate_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _xrev_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->xrev_value	= (now_ptr->xrev_value == 0) ? 1: 0;
			strcpy(xrev_sw_label, xrev_ans[now_ptr->xrev_value]);
			XClearArea(display, Xrev_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _eat2_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->eat2_value++)>6)		now_ptr->eat2_value=7;
			strcpy(eat2_sw_label, eat2_ans[now_ptr->eat2_value]);
			XClearArea(display, Eat2_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->eat2_value--)<1)		now_ptr->eat2_value=0;
			strcpy(eat2_sw_label, eat2_ans[now_ptr->eat2_value]);
			XClearArea(display, Eat2_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _oamset_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->oamset_value++)>2)		now_ptr->oamset_value=3;
			strcpy(oamset_sw_label, oamset_ans[now_ptr->oamset_value]);
			XClearArea(display, Oamset_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->oamset_value--)<1)		now_ptr->oamset_value=0;
			strcpy(oamset_sw_label, oamset_ans[now_ptr->oamset_value]);
			XClearArea(display, Oamset_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _clrsize_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->clrsize_value++)>2)		now_ptr->clrsize_value=3;
			strcpy(clrsize_sw_label, suuji[now_ptr->clrsize_value]);
			XClearArea(display, Clrsize_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->clrsize_value--)<1)		now_ptr->clrsize_value=0;
			strcpy(clrsize_sw_label, suuji[now_ptr->clrsize_value]);
			XClearArea(display, Clrsize_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _tama_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->tama_value++)>6)		now_ptr->tama_value=7;
			strcpy(tama_sw_label, suuji[now_ptr->tama_value]);
			XClearArea(display, Tama_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->tama_value--)<1)		now_ptr->tama_value=0;
			strcpy(tama_sw_label, suuji[now_ptr->tama_value]);
			XClearArea(display, Tama_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _enmy_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->enmy_value	= (now_ptr->enmy_value == 0) ? 1: 0;
			strcpy(enmy_sw_label, enmy_ans[now_ptr->enmy_value]);
			XClearArea(display, Enmy_sw0->xid, 0, 0, 0, 0, True);

		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _item_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->item_value	= (now_ptr->item_value == 0) ? 1: 0;
			if(now_ptr->item_value == 0)	XSetWindowBackground(display,Item_sw0->xid,BG);
			else				XSetWindowBackground(display,Item_sw0->xid,FG);
			strcpy(item_sw_label, yesno[now_ptr->item_value]);
			XClearArea(display, Item_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _point_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->point_value++)>6)		now_ptr->point_value=7;
			strcpy(point_sw_label, suuji[now_ptr->point_value]);
			XClearArea(display, Point_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->point_value--)<1)		now_ptr->point_value=0;
			strcpy(point_sw_label, suuji[now_ptr->point_value]);
			XClearArea(display, Point_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Objsum Switch		(5-7bit)		*/
/********************************************************/
int _objsum_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			now_ptr->objsum_value	= (now_ptr->objsum_value > 15) ? now_ptr->objsum_value - 16: now_ptr->objsum_value + 16;
			objsum_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Objsum Switch		(0-4bit)		*/
/********************************************************/
int _objsum_sw1(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->objsum_value = (now_ptr->objsum_value + 1 > 31) ? 0: now_ptr->objsum_value + 1;
			objsum_disp();
			break;
		case 2:
			now_ptr->objsum_value = (now_ptr->objsum_value - 1 < 0) ? 31: now_ptr->objsum_value - 1;
			objsum_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Objsum Switch					*/
/********************************************************/
objsum_disp()
{
			strcpy(objsum_sw0_label, suuji[now_ptr->objsum_value / 16]);
			XClearArea(display, Objsum_sw0->xid, 0, 0, 0, 0, True);
			strcpy(objsum_sw1_label, suuji[now_ptr->objsum_value % 16]);
			XClearArea(display, Objsum_sw1->xid, 0, 0, 0, 0, True);
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _attr_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->attr_value++)>6)		now_ptr->attr_value=7;
			strcpy(attr_sw_label, attr_ans[now_ptr->attr_value+1]);
			XClearArea(display, Attr_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->attr_value--)<0)		now_ptr->attr_value=-1;
			strcpy(attr_sw_label, attr_ans[now_ptr->attr_value+1]);
			XClearArea(display, Attr_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _flip_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->flip_value++)>2)		now_ptr->flip_value=3;
			strcpy(flip_sw_label, flip_ans[now_ptr->flip_value]);
			XClearArea(display, Flip_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->flip_value--)<1)		now_ptr->flip_value=0;
			strcpy(flip_sw_label, flip_ans[now_ptr->flip_value]);
			XClearArea(display, Flip_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _attr2_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->attr2_value++)>2)		now_ptr->attr2_value=3;
			strcpy(attr2_sw_label, suuji[now_ptr->attr2_value]);
			XClearArea(display, Attr2_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->attr2_value--)<1)		now_ptr->attr2_value=0;
			strcpy(attr2_sw_label, suuji[now_ptr->attr2_value]);
			XClearArea(display, Attr2_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _color_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			if((now_ptr->color_value++)>6)		now_ptr->color_value=7;
			strcpy(color_sw_label, suuji[now_ptr->color_value]);
			XClearArea(display, Color_sw0->xid, 0, 0, 0, 0, True);
			break;
		case 2:
			if((now_ptr->color_value--)<1)		now_ptr->color_value=0;
			strcpy(color_sw_label, suuji[now_ptr->color_value]);
			XClearArea(display, Color_sw0->xid, 0, 0, 0, 0, True);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Gpow Switch		(1bit)			*/
/********************************************************/
int _gpow_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->gpow_value = (now_ptr->gpow_value + 16 > 127) ? now_ptr->gpow_value % 16: now_ptr->gpow_value + 16;
			gpow_disp();
			break;
		case 2:
			now_ptr->gpow_value = (now_ptr->gpow_value - 16 < 0) ? 112 + now_ptr->gpow_value % 16: now_ptr->gpow_value - 16;
			gpow_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Gpow Switch		(0bit)			*/
/********************************************************/
int _gpow_sw1(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->gpow_value = (now_ptr->gpow_value + 1 > 127) ? 0: now_ptr->gpow_value + 1;
			gpow_disp();
			break;
		case 2:
			now_ptr->gpow_value = (now_ptr->gpow_value - 1 < 0) ? 127: now_ptr->gpow_value - 1;
			gpow_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Gpow Switch					*/
/********************************************************/
gpow_disp()
{
			strcpy(gpow_sw0_label, suuji[now_ptr->gpow_value / 16]);
			XClearArea(display, Gpow_sw0->xid, 0, 0, 0, 0, True);
			strcpy(gpow_sw1_label, suuji[now_ptr->gpow_value % 16]);
			XClearArea(display, Gpow_sw1->xid, 0, 0, 0, 0, True);
}

/********************************************************/
/*	Gmax Switch		(3bit)			*/
/********************************************************/
int _gmax_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->gmax_value = (now_ptr->gmax_value + 4096 > 65535) ? now_ptr->gmax_value % 4096: now_ptr->gmax_value + 4096;
			gmax_disp();
			break;
		case 2:
			now_ptr->gmax_value = (now_ptr->gmax_value - 4096 < 0) ? 61440 + now_ptr->gmax_value % 4096: now_ptr->gmax_value - 4096;
			gmax_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Gmax Switch		(2bit)			*/
/********************************************************/
int _gmax_sw1(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->gmax_value = (now_ptr->gmax_value + 256 > 65535) ? now_ptr->gmax_value % 256: now_ptr->gmax_value + 256;
			gmax_disp();
			break;
		case 2:
			now_ptr->gmax_value = (now_ptr->gmax_value - 256 < 0) ? 65280 + now_ptr->gmax_value % 256: now_ptr->gmax_value - 256;
			gmax_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Gmax Switch		(1bit)			*/
/********************************************************/
int _gmax_sw2(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->gmax_value = (now_ptr->gmax_value + 16 > 65535) ? now_ptr->gmax_value % 16: now_ptr->gmax_value + 16;
			gmax_disp();
			break;
		case 2:
			now_ptr->gmax_value = (now_ptr->gmax_value - 16 < 0) ? 65520 + now_ptr->gmax_value % 16: now_ptr->gmax_value - 16;
			gmax_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Gpow Switch		(0bit)			*/
/********************************************************/
int _gmax_sw3(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->gmax_value = (now_ptr->gmax_value + 1 > 65535) ? 0: now_ptr->gmax_value + 1;
			gmax_disp();
			break;
		case 2:
			now_ptr->gmax_value = (now_ptr->gmax_value - 1 < 0) ? 65535: now_ptr->gmax_value - 1;
			gmax_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Gpow Switch					*/
/********************************************************/
gmax_disp()
{
			strcpy(gmax_sw0_label, suuji[now_ptr->gmax_value / 4096]);
			XClearArea(display, Gmax_sw0->xid, 0, 0, 0, 0, True);
			strcpy(gmax_sw1_label, suuji[(now_ptr->gmax_value % 4096) / 256]);
			XClearArea(display, Gmax_sw1->xid, 0, 0, 0, 0, True);
			strcpy(gmax_sw2_label, suuji[(now_ptr->gmax_value % 256) / 16]);
			XClearArea(display, Gmax_sw2->xid, 0, 0, 0, 0, True);
			strcpy(gmax_sw3_label, suuji[now_ptr->gmax_value % 16]);
			XClearArea(display, Gmax_sw3->xid, 0, 0, 0, 0, True);
}

/********************************************************/
/*	Mode7 Switch		(3bit)			*/
/********************************************************/
int _mode7_sw0(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->mode7_value = (now_ptr->mode7_value + 4096 > 65535) ? now_ptr->mode7_value % 4096: now_ptr->mode7_value + 4096;
			mode7_disp();
			break;
		case 2:
			now_ptr->mode7_value = (now_ptr->mode7_value - 4096 < 0) ? 61440 + now_ptr->mode7_value % 4096: now_ptr->mode7_value - 4096;
			mode7_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Mode7 Switch		(2bit)			*/
/********************************************************/
int _mode7_sw1(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->mode7_value = (now_ptr->mode7_value + 256 > 65535) ? now_ptr->mode7_value % 256: now_ptr->mode7_value + 256;
			mode7_disp();
			break;
		case 2:
			now_ptr->mode7_value = (now_ptr->mode7_value - 256 < 0) ? 65280 + now_ptr->mode7_value % 256: now_ptr->mode7_value - 256;
			mode7_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Mode7 Switch		(1bit)			*/
/********************************************************/
int _mode7_sw2(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->mode7_value = (now_ptr->mode7_value + 16 > 65535) ? now_ptr->mode7_value % 16: now_ptr->mode7_value + 16;
			mode7_disp();
			break;
		case 2:
			now_ptr->mode7_value = (now_ptr->mode7_value - 16 < 0) ? 65520 + now_ptr->mode7_value % 16: now_ptr->mode7_value - 16;
			mode7_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Mode7 Switch		(0bit)			*/
/********************************************************/
int _mode7_sw3(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
			now_ptr->mode7_value = (now_ptr->mode7_value + 1 > 65535) ? 0: now_ptr->mode7_value + 1;
			mode7_disp();
			break;
		case 2:
			now_ptr->mode7_value = (now_ptr->mode7_value - 1 < 0) ? 65535: now_ptr->mode7_value - 1;
			mode7_disp();
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Mode7 Switch					*/
/********************************************************/
mode7_disp()
{
			strcpy(mode7_sw0_label, suuji[now_ptr->mode7_value / 4096]);
			XClearArea(display, Mode7_sw0->xid, 0, 0, 0, 0, True);
			strcpy(mode7_sw1_label, suuji[(now_ptr->mode7_value % 4096) / 256]);
			XClearArea(display, Mode7_sw1->xid, 0, 0, 0, 0, True);
			strcpy(mode7_sw2_label, suuji[(now_ptr->mode7_value % 256) / 16]);
			XClearArea(display, Mode7_sw2->xid, 0, 0, 0, 0, True);
			strcpy(mode7_sw3_label, suuji[now_ptr->mode7_value % 16]);
			XClearArea(display, Mode7_sw3->xid, 0, 0, 0, 0, True);
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _a_sw0(caddr_t data)
{
	chain_name(0);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _b_sw0(caddr_t data)
{
	chain_name(1);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _c_sw0(caddr_t data)
{
	chain_name(2);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _d_sw0(caddr_t data)
{
	chain_name(3);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _e_sw0(caddr_t data)
{
	chain_name(4);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _f_sw0(caddr_t data)
{
	chain_name(5);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _g_sw0(caddr_t data)
{
	chain_name(6);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _h_sw0(caddr_t data)
{
	chain_name(7);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _i_sw0(caddr_t data)
{
	chain_name(8);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _j_sw0(caddr_t data)
{
	chain_name(9);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _k_sw0(caddr_t data)
{
	chain_name(10);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _l_sw0(caddr_t data)
{
	chain_name(11);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _m_sw0(caddr_t data)
{
	chain_name(12);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _n_sw0(caddr_t data)
{
	chain_name(13);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _o_sw0(caddr_t data)
{
	chain_name(14);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _p_sw0(caddr_t data)
{
	chain_name(15);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _q_sw0(caddr_t data)
{
	chain_name(16);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _r_sw0(caddr_t data)
{
	chain_name(17);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s_sw0(caddr_t data)
{
	chain_name(18);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _t_sw0(caddr_t data)
{
	chain_name(19);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _u_sw0(caddr_t data)
{
	chain_name(20);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _v_sw0(caddr_t data)
{
	chain_name(21);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _w_sw0(caddr_t data)
{
	chain_name(22);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _x_sw0(caddr_t data)
{
	chain_name(23);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _y_sw0(caddr_t data)
{
	chain_name(24);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _z_sw0(caddr_t data)
{
	chain_name(25);
	return 1;
}


/********************************************************/
/*	On Off Switch					*/
/********************************************************/
chain_name(int key_num)
{
	if(strlen(now_ptr->enemy_name)!=10){
		switch(event.xbutton.button){
			case 1:
				strcat(now_ptr->enemy_name0, alpha_sl[key_num]);
				strcat(now_ptr->enemy_name,  alpha_ll[key_num]);
				strcat(enemy_disp,  alpha_ll[key_num]);
					XClearArea(display, Enemy_name->xid, 0, 0, 0, 0, True);
				break;
			case 2:
				strcat(now_ptr->enemy_name0, alpha_ss[key_num]);
				strcat(now_ptr->enemy_name,  alpha_ls[key_num]);
				strcat(enemy_disp,  alpha_ls[key_num]);
				XClearArea(display, Enemy_name->xid, 0, 0, 0, 0, True);
			case 3:
				break;
		}
	}

}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s0_sw0(caddr_t data)
{
	chain_name2(0);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s1_sw0(caddr_t data)
{
	chain_name2(1);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s2_sw0(caddr_t data)
{
	chain_name2(2);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s3_sw0(caddr_t data)
{
	chain_name2(3);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s4_sw0(caddr_t data)
{
	chain_name2(4);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s5_sw0(caddr_t data)
{
	chain_name2(5);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s6_sw0(caddr_t data)
{
	chain_name2(6);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s7_sw0(caddr_t data)
{
	chain_name2(7);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s8_sw0(caddr_t data)
{
	chain_name2(8);
	return 1;
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _s9_sw0(caddr_t data)
{
	chain_name2(9);
	return 1;
}


/********************************************************/
/*	On Off Switch					*/
/********************************************************/
chain_name2(int key_num)
{
	if(strlen(now_ptr->enemy_name)!=10){
		switch(event.xbutton.button){
			case 1:
			case 2:
				strcat(now_ptr->enemy_name0, suuji_s[key_num]);
				strcat(now_ptr->enemy_name,  suuji[key_num]);
					strcat(enemy_disp,  suuji[key_num]);
				XClearArea(display, Enemy_name->xid, 0, 0, 0, 0, True);
				break;
			case 3:
				break;
		}
	}
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _bs_sw0(caddr_t data)
{
	char	i;

	if((i = strlen(now_ptr->enemy_name))!=0){
	i-=2;
		switch(event.xbutton.button){
			case 1:
			case 2:
				now_ptr->enemy_name0[i/2] = '\0';
				now_ptr->enemy_name[i] = '\0';
				enemy_disp[i] = '\0';
				XClearArea(display, Enemy_name->xid, 0, 0, 0, 0, True);
				break;
			case 3:
				break;
		}
	}
}

/********************************************************/
/*	On Off Switch					*/
/********************************************************/
int _clr_sw0(caddr_t data)
{
	if(strlen(now_ptr->enemy_name)!=0){
		switch(event.xbutton.button){
			case 1:
			case 2:
				now_ptr->enemy_name0[0] = '\0';
				now_ptr->enemy_name[0] = '\0';
				enemy_disp[0] = '\0';
				XClearArea(display, Enemy_name->xid, 0, 0, 0, 0, True);
				break;
			case 3:
				break;
		}
	}

}

/********************************************************/
/*	Number Select	(High)				*/
/********************************************************/
int _num_sw0(caddr_t data)
{
	int num_work;
	if(sel_lock == 0){
		switch(event.xbutton.button){
			case 1:
				num	= ((num+16) > data_sum) ? num % 16: num+16;
				break;
			case 2:
				num	= ((num-16) < 0) ? data_sum / 16 *16 + num % 16: num-16;
			case 3:
				break;
		}
		num_work = num;
		_num_sel(num_work);
	}

	return 1;
}

/********************************************************/
/*	Number Select	(Low)				*/
/********************************************************/
int _num_sw1(caddr_t data)
{
	int num_work;
	if(sel_lock == 0){
		num_work = num;
		switch(event.xbutton.button){
			case 1:
				num	= ((num+1) > data_sum) ? 0: num+1;
				break;
			case 2:
				num	= ((num-1) < 0) ? data_sum: num-1;
			case 3:
				break;
		}
		num_work = num;
		_num_sel(num_work);
	}

	return 1;
}

/********************************************************/
/*	Number Select					*/
/********************************************************/
_num_sel(int i)
{
	now_ptr = first_ptr;
	for(; i !=0; i--){
		now_ptr = now_ptr->next_ptr;
	}

	before_ptr = now_ptr->previous_ptr;
	after_ptr = now_ptr->next_ptr;
	win_data(now_ptr);
}

/********************************************************/
/*	Addition					*/
/********************************************************/
int _add(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			data_sum++;
			sel_lock = 1;
			new_area();
			num++;
			if(after_ptr != NULL){
				(now_ptr->next_ptr)->previous_ptr = new_ptr;
				new_ptr->next_ptr = now_ptr->next_ptr;
				now_ptr->next_ptr = new_ptr;
				new_ptr->previous_ptr = now_ptr;
				before_ptr = now_ptr;
				now_ptr = new_ptr;
				after_ptr = now_ptr->next_ptr;
			}
			else{
				now_ptr->next_ptr = new_ptr;
				new_ptr->previous_ptr = now_ptr;
				new_ptr->next_ptr = NULL;
				before_ptr = now_ptr;
				now_ptr = new_ptr;
				after_ptr = NULL;
			}
			win_data(now_ptr);
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Delete						*/
/********************************************************/
int _del(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			data_sum--;
			if(after_ptr != NULL){
				if(before_ptr == NULL)		first_ptr = after_ptr;
				else				before_ptr->next_ptr = now_ptr;
				free(now_ptr);
				now_ptr = after_ptr;
				after_ptr->previous_ptr = before_ptr;
				after_ptr = after_ptr->next_ptr;
			}
			else{
				before_ptr->next_ptr = NULL;
				now_ptr = before_ptr;
				before_ptr = before_ptr->previous_ptr;
				after_ptr = NULL;
				num--;
			}
			win_data(now_ptr);
		case 3:
			break;
	}

	return 1;
}


/********************************************************/
/*	Prev						*/
/********************************************************/
int _prev(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			sel_lock = 0;
			if(before_ptr != NULL){
				num--;
				after_ptr = now_ptr;
				now_ptr = before_ptr;
				before_ptr = now_ptr->previous_ptr;
				win_data(now_ptr);
			}
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Next						*/
/********************************************************/
int _next(caddr_t data)
{
	switch(event.xbutton.button){
		case 1:
		case 2:
			sel_lock = 0;
			if(after_ptr != NULL){
				num++;
				before_ptr = now_ptr;
				now_ptr = after_ptr;
				after_ptr = now_ptr->next_ptr;
				win_data(now_ptr);
			}
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Make						*/
/********************************************************/
int _make(caddr_t data)
{
	int	i;
	switch(event.xbutton.button){
		case 1:
			_make_data();
			break;
		case 2:
		case 3:
			break;
	}

	return 1;
}

/********************************************************/
/*	Quit						*/
/********************************************************/
int _quit(caddr_t data)
{
	int	i;
	switch(event.xbutton.button){
		case 1:
			/****** read file open ******/
			if((fpw0=fopen("sample.dat","wb")) != 0){
				fwrite(&data_sum, 1, sizeof(data_sum), fpw0);
				now_ptr = first_ptr;
				for(i=data_sum;i>=0;i--){
					fwrite(now_ptr, 1, sizeof(struct values), fpw0);
					now_ptr = now_ptr->next_ptr;
				}
				/****** write file close ******/
				fclose(fpw0);
			}
			ExitFlag = 1;
			break;
		case 2:
			strcpy(quit_label,"Ｅｎｄ");
			XClearArea(display, QuitButton->xid, 0, 0, 0, 0, True);

		case 3:
			break;
	}

	return 1;
}


/********************************************************/
/*	Main												*/
/********************************************************/
main(int argc, char **argv)
{
	int	i;

	setlocale(LC_CTYPE, "");

	xwin_init();

	app_init(argc,argv, MAINXPOS, MAINYPOS, MAINWIDTH, MAINHEIGHT);

#ifdef DEBUG
	XSynchronize( display,True );	/** TEST !! **/
#endif

/************************************************/
/*						*/
/*		メニュー類			*/
/*						*/
/************************************************/
	Enemy	= MakeXButton(LABEL1_XPOS, LABEL1_YPOS, 400, 16, 0, FG, BG,
			TopWind, enemy_label, NULL, NULL, LABEL16MODE);

	Init	= MakeXButton(LABEL1_XPOS+50, LABEL1_YPOS+50, 400, 20, 0, FG, BG,
			TopWind, init_label, NULL, NULL, LABEL16MODE);

	Move	= MakeXButton(LABEL1_XPOS+50, LABEL1_YPOS+82, 400, 20, 0, FG, BG,
			TopWind, move_label, NULL, NULL, LABEL16MODE);

	Fail	= MakeXButton(LABEL1_XPOS+50, LABEL1_YPOS+114, 400, 20, 0, FG, BG,
			TopWind, fail_label, NULL, NULL, LABEL16MODE);

	Nose	= MakeXButton(LABEL1_XPOS+50, LABEL1_YPOS+146, 400, 20, 0, FG, BG,
			TopWind, nose_label, NULL, NULL, LABEL16MODE);

/*		メニュー		*/
	Objsize = MakeXButton(LABEL_XPOS, LABEL_YPOS, 400, 16, 0, FG, BG,
			TopWind, objsize_label, NULL, NULL, LABEL16MODE);

	Throw	= MakeXButton(LABEL_XPOS, LABEL_YPOS+20, 400, 16, 0, FG, BG,
			TopWind, throw_label, NULL, NULL, LABEL16MODE);

	Eat	= MakeXButton(LABEL_XPOS, LABEL_YPOS+40, 400, 16, 0, FG, BG,
			TopWind, eat_label, NULL, NULL, LABEL16MODE);

	Enen	= MakeXButton(LABEL_XPOS, LABEL_YPOS+60, 400, 16, 0, FG, BG,
			TopWind, enen_label, NULL, NULL, LABEL16MODE);

	Plen	= MakeXButton(LABEL_XPOS, LABEL_YPOS+80, 400, 16, 0, FG, BG,
			TopWind, plen_label, NULL, NULL, LABEL16MODE);

	Enen0	= MakeXButton(LABEL_XPOS, LABEL_YPOS+100, 400, 16, 0, FG, BG,
			TopWind, enen0_label, NULL, NULL, LABEL16MODE);

	Enen1	= MakeXButton(LABEL_XPOS, LABEL_YPOS+120, 400, 16, 0, FG, BG,
			TopWind, enen1_label, NULL, NULL, LABEL16MODE);

	Plen0	= MakeXButton(LABEL_XPOS, LABEL_YPOS+140, 400, 16, 0, FG, BG,
			TopWind, plen0_label, NULL, NULL, LABEL16MODE);

	Plen1	= MakeXButton(LABEL_XPOS, LABEL_YPOS+160, 400, 16, 0, FG, BG,
			TopWind, plen1_label, NULL, NULL, LABEL16MODE);

	Bgsize	= MakeXButton(LABEL_XPOS, LABEL_YPOS+180, 400, 16, 0, FG, BG,
			TopWind, bgsize_label, NULL, NULL, LABEL16MODE);

	Yclear	= MakeXButton(LABEL_XPOS, LABEL_YPOS+200, 400, 16, 0, FG, BG,
			TopWind, yclear_label, NULL, NULL, LABEL16MODE);

	Yoko	= MakeXButton(LABEL_XPOS, LABEL_YPOS+220, 400, 16, 0, FG, BG,
			TopWind, yoko_label, NULL, NULL, LABEL16MODE);

	Tate	= MakeXButton(LABEL_XPOS, LABEL_YPOS+240, 400, 16, 0, FG, BG,
			TopWind, tate_label, NULL, NULL, LABEL16MODE);

	Xrev	= MakeXButton(LABEL_XPOS, LABEL_YPOS+260, 400, 16, 0, FG, BG,
			TopWind, xrev_label, NULL, NULL, LABEL16MODE);

	Eat2	= MakeXButton(LABEL_XPOS, LABEL_YPOS+280, 400, 16, 0, FG, BG,
			TopWind, eat2_label, NULL, NULL, LABEL16MODE);

	Oamset	= MakeXButton(LABEL_XPOS, LABEL_YPOS+300, 400, 16, 0, FG, BG,
			TopWind, oamset_label, NULL, NULL, LABEL16MODE);

	Clrsize = MakeXButton(LABEL_XPOS, LABEL_YPOS+320, 400, 16, 0, FG, BG,
			TopWind, clrsize_label, NULL, NULL, LABEL16MODE);

	Tama	= MakeXButton(LABEL_XPOS, LABEL_YPOS+340, 400, 16, 0, FG, BG,
			TopWind, tama_label, NULL, NULL, LABEL16MODE);

	Enmy	= MakeXButton(LABEL_XPOS, LABEL_YPOS+360, 400, 16, 0, FG, BG,
			TopWind, enmy_label, NULL, NULL, LABEL16MODE);

	Item	= MakeXButton(LABEL_XPOS, LABEL_YPOS+380, 400, 16, 0, FG, BG,
			TopWind, item_label, NULL, NULL, LABEL16MODE);

	Point	= MakeXButton(LABEL_XPOS, LABEL_YPOS+400, 400, 16, 0, FG, BG,
			TopWind, point_label, NULL, NULL, LABEL16MODE);

	Objsum	= MakeXButton(LABEL_XPOS, LABEL_YPOS+420, 400, 16, 0, FG, BG,
			TopWind, objsum_label, NULL, NULL, LABEL16MODE);

	Attr	= MakeXButton(LABEL_XPOS, LABEL_YPOS+440, 400, 16, 0, FG, BG,
			TopWind, attr_label, NULL, NULL, LABEL16MODE);

	Flip	= MakeXButton(LABEL_XPOS, LABEL_YPOS+460, 400, 16, 0, FG, BG,
			TopWind, flip_label, NULL, NULL, LABEL16MODE);

	Attr2	= MakeXButton(LABEL_XPOS, LABEL_YPOS+480, 400, 16, 0, FG, BG,
			TopWind, attr2_label, NULL, NULL, LABEL16MODE);

	Color	= MakeXButton(LABEL_XPOS, LABEL_YPOS+500, 400, 16, 0, FG, BG,
			TopWind, color_label, NULL, NULL, LABEL16MODE);

	Gpow	= MakeXButton(LABEL_XPOS, LABEL_YPOS+520, 400, 16, 0, FG, BG,
			TopWind, gpow_label, NULL, NULL, LABEL16MODE);

	Gmax	= MakeXButton(LABEL_XPOS, LABEL_YPOS+540, 400, 16, 0, FG, BG,
			TopWind, gmax_label, NULL, NULL, LABEL16MODE);

	Mode7	= MakeXButton(LABEL_XPOS, LABEL_YPOS+560, 400, 16, 0, FG, BG,
			TopWind, mode7_label, NULL, NULL, LABEL16MODE);


/************************************************/
/*						*/
/*		スイッチ類			*/
/*						*/
/************************************************/
	Enemy_name	= MakeXButton(LABEL1_XPOS+280, LABEL1_YPOS, 88, 20, 2, FG, BG,
				TopWind, enemy_disp, NULL, NULL, LABEL16MODE);

	Init_sw0	= MakeXButton(LABEL1_XPOS+280, LABEL1_YPOS+50, 50, 20, 2, FG, BG,
				TopWind, init_sw_label, _init_sw0, NULL, LABEL216MODE);

	Move_sw0	= MakeXButton(LABEL1_XPOS+280, LABEL1_YPOS+82, 50, 20, 2, FG, BG,
				TopWind, move_sw_label, _move_sw0, NULL, LABEL216MODE);

	Fail_sw0	= MakeXButton(LABEL1_XPOS+280, LABEL1_YPOS+114, 50, 20, 2, FG, BG,
				TopWind, fail_sw_label, _fail_sw0, NULL, LABEL216MODE);

	Nose_sw0	= MakeXButton(LABEL1_XPOS+280, LABEL1_YPOS+146, 50, 20, 2, FG, BG,
				TopWind, nose_sw_label, _nose_sw0, NULL, LABEL216MODE);

/*		メニュースイッチ		*/
	Objsize_sw	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS-3, 46, 19, 2, FG, BG,
				TopWind, dummy, NULL, NULL, LABEL16MODE);
	Objsize_sw0	= MakeXButton(LABEL_XPOS+312, LABEL_YPOS+1, 20, 16, 0, FG, BG,
				TopWind, objsize_sw0_label, _objsize_sw0, NULL, BUTTON16MODE);
	Objsize_sw1	= MakeXButton(LABEL_XPOS+337, LABEL_YPOS+1, 20, 16, 0, FG, BG,
				TopWind, objsize_sw1_label, _objsize_sw1, NULL, BUTTON16MODE);

	Throw_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+19, 50, 16, 2, FG, BG,
				TopWind, throw_sw_label, _throw_sw0, NULL, LABEL216MODE);

	Eat_sw0		= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+39, 50, 16, 2, FG, BG,
				TopWind, eat_sw_label, _eat_sw0, NULL, LABEL216MODE);

	Enen_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+59, 50, 16, 2, FG, BG,
				TopWind, enen_sw_label, _enen_sw0, NULL, LABEL216MODE);

	Plen_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+79, 50, 16, 2, FG, BG,
				TopWind, plen_sw_label, _plen_sw0, NULL, LABEL216MODE);

	Enen0_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+99, 50, 16, 2, FG, BG,
				TopWind, enen0_sw_label, _enen0_sw0, NULL, LABEL216MODE);

	Enen1_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+119, 50, 16, 2, FG, BG,
				TopWind, enen1_sw_label, _enen1_sw0, NULL, LABEL216MODE);

	Plen0_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+139, 160, 16, 2, FG, BG,
				TopWind, plen0_sw_label, _plen0_sw0, NULL, BUTTON16MODE);

	Plen1_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+159, 160, 16, 2, FG, BG,
				TopWind, plen1_sw_label, _plen1_sw0, NULL, BUTTON16MODE);

	Bgsize_sw	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+177, 46, 19, 2, FG, BG,
				TopWind, dummy, NULL, NULL, LABEL16MODE);
	Bgsize_sw0	= MakeXButton(LABEL_XPOS+312, LABEL_YPOS+181, 20, 16, 0, FG, BG,
				TopWind, bgsize_sw0_label, _bgsize_sw0, NULL, BUTTON16MODE);
	Bgsize_sw1	= MakeXButton(LABEL_XPOS+337, LABEL_YPOS+181, 20, 16, 0, FG, BG,
				TopWind, bgsize_sw1_label, _bgsize_sw1, NULL, BUTTON16MODE);

	Yclear_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+199, 50, 16, 2, FG, BG,
				TopWind, yclear_sw_label, _yclear_sw0, NULL, LABEL216MODE);

	Yoko_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+219, 160, 16, 2, FG, BG,
				TopWind, yoko_sw_label, _yoko_sw0, NULL, BUTTON16MODE);

	Tate_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+239, 160, 16, 2, FG, BG,
				TopWind, tate_sw_label, _tate_sw0, NULL, BUTTON16MODE);

	Xrev_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+259, 160, 16, 2, FG, BG,
				TopWind, xrev_sw_label, _xrev_sw0, NULL, BUTTON16MODE);

	Eat2_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+279, 160, 16, 2, FG, BG,
				TopWind, eat2_sw_label, _eat2_sw0, NULL, BUTTON16MODE);

	Oamset_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+299, 160, 16, 2, FG, BG,
				TopWind, oamset_sw_label, _oamset_sw0, NULL, BUTTON16MODE);

	Clrsize_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+319, 50, 16, 2, FG, BG,
				TopWind, clrsize_sw_label, _clrsize_sw0, NULL, BUTTON16MODE);

	Tama_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+339, 50, 16, 2, FG, BG,
				TopWind, tama_sw_label, _tama_sw0, NULL, BUTTON16MODE);

	Enmy_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+359, 160, 16, 2, FG, BG,
				TopWind, enmy_sw_label, _enmy_sw0, NULL, BUTTON16MODE);

	Item_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+379, 50, 16, 2, FG, BG,
				TopWind, item_sw_label, _item_sw0, NULL, LABEL216MODE);

	Point_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+399, 50, 16, 2, FG, BG,
				TopWind, point_sw_label, _point_sw0, NULL, BUTTON16MODE);

	Objsum_sw	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+417, 46, 19, 2, FG, BG,
				TopWind, dummy, NULL, NULL, LABEL16MODE);
	Objsum_sw0	= MakeXButton(LABEL_XPOS+312, LABEL_YPOS+421, 20, 16, 0, FG, BG,
				TopWind, objsum_sw0_label, _objsum_sw0, NULL, BUTTON16MODE);
	Objsum_sw1	= MakeXButton(LABEL_XPOS+337, LABEL_YPOS+421, 20, 16, 0, FG, BG,
				TopWind, objsum_sw1_label, _objsum_sw1, NULL, BUTTON16MODE);

	Attr_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+439, 160, 16, 2, FG, BG,
				TopWind, attr_sw_label, _attr_sw0, NULL, BUTTON16MODE);

	Flip_sw0	= MakeXButton(LABEL_XPOS+260, LABEL_YPOS+459, 160, 16, 2, FG, BG,
				TopWind, flip_sw_label, _flip_sw0, NULL, BUTTON16MODE);

	Attr2_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+479, 50, 16, 2, FG, BG,
				TopWind, attr2_sw_label, _attr2_sw0, NULL, BUTTON16MODE);

	Color_sw0	= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+499, 50, 16, 2, FG, BG,
				TopWind, color_sw_label, _color_sw0, NULL, BUTTON16MODE);

	Gpow_sw		= MakeXButton(LABEL_XPOS+310, LABEL_YPOS+517, 46, 19, 2, FG, BG,
				TopWind, dummy, NULL, NULL, LABEL16MODE);
	Gpow_sw0	= MakeXButton(LABEL_XPOS+312, LABEL_YPOS+521, 20, 16, 0, FG, BG,
				TopWind, gpow_sw0_label, _gpow_sw0, NULL, BUTTON16MODE);
	Gpow_sw1	= MakeXButton(LABEL_XPOS+337, LABEL_YPOS+521, 20, 16, 0, FG, BG,
				TopWind, gpow_sw1_label, _gpow_sw1, NULL, BUTTON16MODE);

	Gmax_sw		= MakeXButton(LABEL_XPOS+285, LABEL_YPOS+537, 96, 19, 2, FG, BG,
				TopWind, dummy, NULL, NULL, LABEL16MODE);
	Gmax_sw0	= MakeXButton(LABEL_XPOS+287, LABEL_YPOS+541, 20, 16, 0, FG, BG,
				TopWind, gmax_sw0_label, _gmax_sw0, NULL, BUTTON16MODE);
	Gmax_sw1	= MakeXButton(LABEL_XPOS+312, LABEL_YPOS+541, 20, 16, 0, FG, BG,
				TopWind, gmax_sw1_label, _gmax_sw1, NULL, BUTTON16MODE);
	Gmax_sw2	= MakeXButton(LABEL_XPOS+337, LABEL_YPOS+541, 20, 16, 0, FG, BG,
				TopWind, gmax_sw2_label, _gmax_sw2, NULL, BUTTON16MODE);
	Gmax_sw3	= MakeXButton(LABEL_XPOS+362, LABEL_YPOS+541, 20, 16, 0, FG, BG,
				TopWind, gmax_sw3_label, _gmax_sw3, NULL, BUTTON16MODE);

	Mode7_sw	= MakeXButton(LABEL_XPOS+285, LABEL_YPOS+557, 96, 19, 2, FG, BG,
				TopWind, dummy, NULL, NULL, LABEL16MODE);
	Mode7_sw0	= MakeXButton(LABEL_XPOS+287, LABEL_YPOS+561, 20, 16, 0, FG, BG,
				TopWind, mode7_sw0_label, _mode7_sw0, NULL, BUTTON16MODE);
	Mode7_sw1	= MakeXButton(LABEL_XPOS+312, LABEL_YPOS+561, 20, 16, 0, FG, BG,
				TopWind, mode7_sw1_label, _mode7_sw1, NULL, BUTTON16MODE);
	Mode7_sw2	= MakeXButton(LABEL_XPOS+337, LABEL_YPOS+561, 20, 16, 0, FG, BG,
				TopWind, mode7_sw2_label, _mode7_sw2, NULL, BUTTON16MODE);
	Mode7_sw3	= MakeXButton(LABEL_XPOS+362, LABEL_YPOS+561, 20, 16, 0, FG, BG,
				TopWind, mode7_sw3_label, _mode7_sw3, NULL, BUTTON16MODE);

/*		キーボード		*/
	Board		= MakeXButton(LABEL2_XPOS-10, LABEL2_YPOS-10, 434, 104, 2, FG, BG,
				TopWind, dummy, NULL, NULL, LABEL216MODE);

	A_sw0		= MakeXButton(LABEL2_XPOS, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, a_moji, _a_sw0, NULL, BUTTON16MODE);

	B_sw0		= MakeXButton(LABEL2_XPOS+28, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, b_moji, _b_sw0, NULL, BUTTON16MODE);

	C_sw0		= MakeXButton(LABEL2_XPOS+56, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, c_moji, _c_sw0, NULL, BUTTON16MODE);

	D_sw0		= MakeXButton(LABEL2_XPOS+84, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, d_moji, _d_sw0, NULL, BUTTON16MODE);

	E_sw0		= MakeXButton(LABEL2_XPOS+112, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, e_moji, _e_sw0, NULL, BUTTON16MODE);

	F_sw0		= MakeXButton(LABEL2_XPOS+140, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, f_moji, _f_sw0, NULL, BUTTON16MODE);

	G_sw0		= MakeXButton(LABEL2_XPOS+168, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, g_moji, _g_sw0, NULL, BUTTON16MODE);

	H_sw0		= MakeXButton(LABEL2_XPOS+196, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, h_moji, _h_sw0, NULL, BUTTON16MODE);

	I_sw0		= MakeXButton(LABEL2_XPOS+224, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, i_moji, _i_sw0, NULL, BUTTON16MODE);

	J_sw0		= MakeXButton(LABEL2_XPOS+252, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, j_moji, _j_sw0, NULL, BUTTON16MODE);

	K_sw0		= MakeXButton(LABEL2_XPOS+280, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, k_moji, _k_sw0, NULL, BUTTON16MODE);

	L_sw0		= MakeXButton(LABEL2_XPOS+308, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, l_moji, _l_sw0, NULL, BUTTON16MODE);

	M_sw0		= MakeXButton(LABEL2_XPOS+336, LABEL2_YPOS, 20, 20, 2, FG, BG,
				TopWind, m_moji, _m_sw0, NULL, BUTTON16MODE);


	N_sw0		= MakeXButton(LABEL2_XPOS, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, n_moji, _n_sw0, NULL, BUTTON16MODE);

	O_sw0		= MakeXButton(LABEL2_XPOS+28, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, o_moji, _o_sw0, NULL, BUTTON16MODE);

	P_sw0		= MakeXButton(LABEL2_XPOS+56, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, p_moji, _p_sw0, NULL, BUTTON16MODE);

	Q_sw0		= MakeXButton(LABEL2_XPOS+84, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, q_moji, _q_sw0, NULL, BUTTON16MODE);

	R_sw0		= MakeXButton(LABEL2_XPOS+112, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, r_moji, _r_sw0, NULL, BUTTON16MODE);

	S_sw0		= MakeXButton(LABEL2_XPOS+140, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, s_moji, _s_sw0, NULL, BUTTON16MODE);

	T_sw0		= MakeXButton(LABEL2_XPOS+168, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, t_moji, _t_sw0, NULL, BUTTON16MODE);

	U_sw0		= MakeXButton(LABEL2_XPOS+196, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, u_moji, _u_sw0, NULL, BUTTON16MODE);

	V_sw0		= MakeXButton(LABEL2_XPOS+224, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, v_moji, _v_sw0, NULL, BUTTON16MODE);

	W_sw0		= MakeXButton(LABEL2_XPOS+252, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, w_moji, _w_sw0, NULL, BUTTON16MODE);

	X_sw0		= MakeXButton(LABEL2_XPOS+280, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, x_moji, _x_sw0, NULL, BUTTON16MODE);

	Y_sw0		= MakeXButton(LABEL2_XPOS+308, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, y_moji, _y_sw0, NULL, BUTTON16MODE);

	Z_sw0		= MakeXButton(LABEL2_XPOS+336, LABEL2_YPOS+30, 20, 20, 2, FG, BG,
				TopWind, z_moji, _z_sw0, NULL, BUTTON16MODE);

	S0_sw0		= MakeXButton(LABEL2_XPOS, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s0_moji, _s0_sw0, NULL, BUTTON16MODE);

	S1_sw0		= MakeXButton(LABEL2_XPOS+28, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s1_moji, _s1_sw0, NULL, BUTTON16MODE);

	S2_sw0		= MakeXButton(LABEL2_XPOS+56, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s2_moji, _s2_sw0, NULL, BUTTON16MODE);

	S3_sw0		= MakeXButton(LABEL2_XPOS+84, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s3_moji, _s3_sw0, NULL, BUTTON16MODE);

	S4_sw0		= MakeXButton(LABEL2_XPOS+112, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s4_moji, _s4_sw0, NULL, BUTTON16MODE);

	S5_sw0		= MakeXButton(LABEL2_XPOS+140, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s5_moji, _s5_sw0, NULL, BUTTON16MODE);

	S6_sw0		= MakeXButton(LABEL2_XPOS+168, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s6_moji, _s6_sw0, NULL, BUTTON16MODE);

	S7_sw0		= MakeXButton(LABEL2_XPOS+196, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s7_moji, _s7_sw0, NULL, BUTTON16MODE);

	S8_sw0		= MakeXButton(LABEL2_XPOS+224, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s8_moji, _s8_sw0, NULL, BUTTON16MODE);

	S9_sw0		= MakeXButton(LABEL2_XPOS+252, LABEL2_YPOS+60, 20, 20, 2, FG, BG,
				TopWind, s9_moji, _s9_sw0, NULL, BUTTON16MODE);

	Bs_sw0		= MakeXButton(LABEL2_XPOS+300, LABEL2_YPOS+60, 40, 20, 2, FG, BG,
				TopWind, bs_moji, _bs_sw0, NULL, BUTTON16MODE);

	Clr_sw0		= MakeXButton(LABEL2_XPOS+350, LABEL2_YPOS+60, 60, 20, 2, FG, BG,
				TopWind, clr_moji, _clr_sw0, NULL, BUTTON16MODE);

	Num		= MakeXButton(LABEL4_XPOS, LABEL4_YPOS, 70, 20, 0, FG, BG,
				TopWind, num_label, NULL, NULL, LABEL16MODE);
	Num_sw		= MakeXButton(LABEL4_XPOS+60, LABEL4_YPOS, 46, 20, 2, FG, BG,
				TopWind, dummy, NULL, NULL, LABEL16MODE);
	Num_sw0		= MakeXButton(LABEL4_XPOS+62, LABEL4_YPOS+2, 20, 16, 0, FG, BG,
				TopWind, num_sw0_label, _num_sw0, NULL, LABEL216MODE);
	Num_sw1		= MakeXButton(LABEL4_XPOS+87, LABEL4_YPOS+2, 20, 16, 0, FG, BG,
				TopWind, num_sw1_label, _num_sw1, NULL, LABEL216MODE);

	PrevButton	= MakeXButton(LABEL4_XPOS+170, LABEL4_YPOS-5, 70, 30, 2, FG, BG,
				TopWind, prev_label, _prev, NULL, BUTTON16MODE);

	NextButton	= MakeXButton(LABEL4_XPOS+270, LABEL4_YPOS-5, 70, 30, 2, FG, BG,
				TopWind, next_label, _next, NULL, BUTTON16MODE);


	AddButton	= MakeXButton(LABEL3_XPOS, LABEL3_YPOS, 70, 70, 2, FG, BG,
				TopWind, add_label, _add, NULL, BUTTON16MODE);

	DelButton	= MakeXButton(LABEL3_XPOS+100, LABEL3_YPOS, 70, 70, 2, FG, BG,
				TopWind, del_label, _del, NULL, BUTTON16MODE);

	MakeButton	= MakeXButton(LABEL3_XPOS+200, LABEL3_YPOS, 70, 70, 2, FG, BG,
				TopWind, make_label, _make, NULL, BUTTON16MODE);

	QuitButton	= MakeXButton(LABEL3_XPOS+300, LABEL3_YPOS, 70, 70, 2, FG, BG,
				TopWind, quit_label, _quit, NULL, BUTTON16MODE);

	/****** read file open ******/
	if((fpw0=fopen("sample.dat","rb")) == 0){
		data_sum = 0;
		new_area();

		first_ptr = new_ptr;
		now_ptr = new_ptr;
		now_ptr->previous_ptr = NULL;
		now_ptr->next_ptr = NULL;
	}
	else{
		fread(&data_sum, 1, sizeof(data_sum), fpw0);

		new_ptr = (struct values *) malloc( sizeof(struct values));
		fread(new_ptr, 1, sizeof(struct values), fpw0);
		first_ptr = new_ptr;
		now_ptr = new_ptr;

		for(i=data_sum-1;i>=0;i--){
			new_ptr = (struct values *) malloc( sizeof(struct values));
			fread(new_ptr, 1, sizeof(struct values), fpw0);
			new_ptr->previous_ptr = now_ptr;
			now_ptr->next_ptr = new_ptr;
			now_ptr = new_ptr;
		}
		now_ptr->next_ptr = NULL;
		now_ptr = first_ptr;
		before_ptr = NULL;
		after_ptr = now_ptr->next_ptr;

	 /****** write file close ******/
		 fclose(fpw0);
	}

	num = 0;
	win_data(now_ptr);
	sel_lock = 0;


	while(!ExitFlag){
		XNextEvent(display, &event);
		if(XFindContext(display, event.xany.window, xwin_context, (caddr_t *)&which_xwin) == 0){
			if(*(which_xwin->event_handler) != NULL)	(*(which_xwin->event_handler))(which_xwin);
		}


	}

	XCloseDisplay(display);
	exit(0);
}

new_area()
{
	new_ptr = (struct values *) malloc( sizeof(struct values));

	new_ptr->init_value		= 0;
	new_ptr->move_value		= 0;
	new_ptr->fail_value		= 0;
	new_ptr->nose_value		= 0;

	new_ptr->objsize_value		= 0;
	new_ptr->throw_value		= 0;
	new_ptr->eat_value		= 0;
	new_ptr->enen_value		= 0;
	new_ptr->plen_value		= 0;
	new_ptr->enen0_value		= 0;
	new_ptr->enen1_value		= 0;
	new_ptr->plen0_value		= 0;
	new_ptr->plen1_value		= 0;

	new_ptr->bgsize_value		= 0;
	new_ptr->yclear_value		= 0;
	new_ptr->yoko_value		= 0;
	new_ptr->tate_value		= 0;
	new_ptr->xrev_value		= 0;
	new_ptr->eat2_value		= 0;

	new_ptr->oamset_value		= 0;
	new_ptr->clrsize_value		= 0;
	new_ptr->tama_value		= 0;
	new_ptr->enmy_value		= 0;
	new_ptr->item_value		= 0;
	new_ptr->point_value		= 0;
	new_ptr->objsum_value		= 0;

	new_ptr->flip_value		= 0;
	new_ptr->attr2_value		= 0;
	new_ptr->color_value		= 0;

	new_ptr->gpow_value		= 0;
	new_ptr->gmax_value		= 0;

	new_ptr->mode7_value		= 0;

	new_ptr->enemy_name[0]		= '\0';
	new_ptr->enemy_name0[0]		= '\0';


}

int	win_data(struct	 values	 *work_ptr)
{

	strcpy(enemy_disp, work_ptr->enemy_name);

	strcpy(init_sw_label, onoff[work_ptr->init_value]);
	strcpy(move_sw_label, onoff[work_ptr->move_value]);
	strcpy(fail_sw_label, onoff[work_ptr->fail_value]);
	strcpy(nose_sw_label, onoff[work_ptr->nose_value]);

	strcpy(objsize_sw0_label, suuji[work_ptr->objsize_value / 16]);
	strcpy(objsize_sw1_label, suuji[work_ptr->objsize_value % 16]);
	strcpy(throw_sw_label, yesno[work_ptr->throw_value]);
	strcpy(eat_sw_label, yesno[work_ptr->eat_value]);
	strcpy(enen_sw_label, yesno[work_ptr->enen_value]);
	strcpy(plen_sw_label, yesno[work_ptr->plen_value]);
	strcpy(enen0_sw_label, yesno[work_ptr->enen0_value]);
	strcpy(enen1_sw_label, yesno[work_ptr->enen1_value]);
	strcpy(plen0_sw_label, plen0_ans[work_ptr->enen0_value]);
	strcpy(plen1_sw_label, plen1_ans[work_ptr->enen1_value]);

	strcpy(bgsize_sw0_label, suuji[work_ptr->bgsize_value / 16]);
	strcpy(bgsize_sw1_label, suuji[work_ptr->bgsize_value % 16]);
	strcpy(yclear_sw_label, yesno[work_ptr->yclear_value]);
	strcpy(yoko_sw_label, yoko_ans[work_ptr->yoko_value]);
	strcpy(tate_sw_label, tate_ans[work_ptr->tate_value]);
	strcpy(xrev_sw_label, xrev_ans[work_ptr->xrev_value]);
	strcpy(eat2_sw_label, eat2_ans[work_ptr->eat2_value]);

	strcpy(oamset_sw_label, oamset_ans[work_ptr->oamset_value]);
	strcpy(clrsize_sw_label, suuji[work_ptr->clrsize_value]);
	strcpy(tama_sw_label, suuji[work_ptr->tama_value]);
	strcpy(enmy_sw_label, enmy_ans[work_ptr->enmy_value]);
	strcpy(item_sw_label, yesno[work_ptr->item_value]);
	strcpy(point_sw_label, suuji[work_ptr->point_value]);
	strcpy(objsum_sw0_label, suuji[work_ptr->objsum_value / 16]);
	strcpy(objsum_sw1_label, suuji[work_ptr->objsum_value % 16]);

	strcpy(attr_sw_label, attr_ans[work_ptr->attr_value+1]);
	strcpy(flip_sw_label, flip_ans[work_ptr->flip_value]);
	strcpy(attr2_sw_label, suuji[work_ptr->attr2_value]);
	strcpy(color_sw_label, suuji[work_ptr->color_value]);

	strcpy(gpow_sw0_label, suuji[work_ptr->gpow_value / 16]);
	strcpy(gpow_sw1_label, suuji[work_ptr->gpow_value % 16]);
	strcpy(gmax_sw0_label, suuji[work_ptr->gmax_value / 4096]);
	strcpy(gmax_sw1_label, suuji[(work_ptr->gmax_value % 4096) / 256]);
	strcpy(gmax_sw2_label, suuji[(work_ptr->gmax_value % 256) / 16]);
	strcpy(gmax_sw3_label, suuji[work_ptr->gmax_value % 16]);

	strcpy(mode7_sw0_label, suuji[work_ptr->mode7_value / 4096]);
	strcpy(mode7_sw1_label, suuji[(work_ptr->mode7_value % 4096) / 256]);
	strcpy(mode7_sw2_label, suuji[(work_ptr->mode7_value % 256) / 16]);
	strcpy(mode7_sw3_label, suuji[work_ptr->mode7_value % 16]);

	strcpy(num_sw0_label, suuji[num / 16]);
	strcpy(num_sw1_label, suuji[num % 16]);

	XSetWindowBackground(display,Enemy_name->xid,BG);
	if(work_ptr->init_value == 0)	XSetWindowBackground(display,Init_sw0->xid,BG);
	else				XSetWindowBackground(display,Init_sw0->xid,FG);
	if(work_ptr->move_value == 0)	XSetWindowBackground(display,Move_sw0->xid,BG);
	else				XSetWindowBackground(display,Move_sw0->xid,FG);
	if(work_ptr->fail_value == 0)	XSetWindowBackground(display,Fail_sw0->xid,BG);
	else				XSetWindowBackground(display,Fail_sw0->xid,FG);
	if(work_ptr->nose_value == 0)	XSetWindowBackground(display,Nose_sw0->xid,BG);
	else				XSetWindowBackground(display,Nose_sw0->xid,FG);
	if(work_ptr->throw_value == 0)	XSetWindowBackground(display,Throw_sw0->xid,BG);
	else				XSetWindowBackground(display,Throw_sw0->xid,FG);
	if(work_ptr->eat_value == 0)	XSetWindowBackground(display,Eat_sw0->xid,BG);
	else				XSetWindowBackground(display,Eat_sw0->xid,FG);
	if(work_ptr->enen_value == 0)	XSetWindowBackground(display,Enen_sw0->xid,BG);
	else				XSetWindowBackground(display,Enen_sw0->xid,FG);
	if(work_ptr->plen_value == 0)	XSetWindowBackground(display,Plen_sw0->xid,BG);
	else				XSetWindowBackground(display,Plen_sw0->xid,FG);
	if(work_ptr->enen0_value == 0)	XSetWindowBackground(display,Enen0_sw0->xid,BG);
	else				XSetWindowBackground(display,Enen0_sw0->xid,FG);
	if(work_ptr->enen1_value == 0)	XSetWindowBackground(display,Enen1_sw0->xid,BG);
	else				XSetWindowBackground(display,Enen1_sw0->xid,FG);
	if(work_ptr->yclear_value == 0) XSetWindowBackground(display,Yclear_sw0->xid,BG);
	else				XSetWindowBackground(display,Yclear_sw0->xid,FG);
	if(work_ptr->item_value == 0)	XSetWindowBackground(display,Item_sw0->xid,BG);
	else				XSetWindowBackground(display,Item_sw0->xid,FG);

	XClearArea(display, Enemy_name->xid, 0, 0, 0, 0, True);
	XClearArea(display, Init_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Move_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Fail_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Nose_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Objsize_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Objsize_sw1->xid, 0, 0, 0, 0, True);
	XClearArea(display, Throw_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Eat_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Enen_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Plen_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Enen0_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Enen1_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Plen0_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Plen1_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Bgsize_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Bgsize_sw1->xid, 0, 0, 0, 0, True);
	XClearArea(display, Yclear_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Yoko_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Tate_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Xrev_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Eat2_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Oamset_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Clrsize_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Tama_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Item_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Point_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Objsum_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Objsum_sw1->xid, 0, 0, 0, 0, True);
	XClearArea(display, Attr_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Color_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Gpow_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Gpow_sw1->xid, 0, 0, 0, 0, True);
	XClearArea(display, Gmax_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Gmax_sw1->xid, 0, 0, 0, 0, True);
	XClearArea(display, Gmax_sw2->xid, 0, 0, 0, 0, True);
	XClearArea(display, Gmax_sw3->xid, 0, 0, 0, 0, True);
	XClearArea(display, Mode7_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Mode7_sw1->xid, 0, 0, 0, 0, True);
	XClearArea(display, Mode7_sw2->xid, 0, 0, 0, 0, True);
	XClearArea(display, Mode7_sw3->xid, 0, 0, 0, 0, True);
	XClearArea(display, Num_sw0->xid, 0, 0, 0, 0, True);
	XClearArea(display, Num_sw1->xid, 0, 0, 0, 0, True);

}
/************************************************/
/*	make format data			*/
/************************************************/
_make_data(){
	int	i,j;
	/****** read file open ******/
	if((fpw0=fopen("enemy.dat","w")) != 0){

		save_ptr = first_ptr;
		for(i=data_sum,j=0;i>=0;i--){
			if((j&0x07)==0)				fprintf(fpw0,"\t\tGLB\t");
			else					fprintf(fpw0,",");
			fprintf(fpw0,"%s",save_ptr->enemy_name0);
			if(((j&0x07)==7)||(i==0))		fprintf(fpw0,"\n");
			j++;
			save_ptr = save_ptr->next_ptr;
		}

		fprintf(fpw0,";\n");

		save_ptr = first_ptr;
		for(i=data_sum,j=0;i>=0;i--){
			if(save_ptr->init_value!=0){
				if(j==0)			fprintf(fpw0,"\t\tEXT\t");
				else				fprintf(fpw0,",");
				fprintf(fpw0,"%sIN",save_ptr->enemy_name0);
				j++;
			}
			if((j==6)||(i==0)){
							fprintf(fpw0,"\n");
							j=0;
			}
			save_ptr = save_ptr->next_ptr;
		}

		fprintf(fpw0,";\n");

		save_ptr = first_ptr;
		for(i=data_sum,j=0;i>=0;i--){
			if(save_ptr->move_value!=0){
				if(j==0)		fprintf(fpw0,"\t\tEXT\t");
				else				fprintf(fpw0,",");
				fprintf(fpw0,"%sMV",save_ptr->enemy_name0);
				j++;
			}
			if((j==6)||(i==0)){
							fprintf(fpw0,"\n");
							j=0;
			}
			save_ptr = save_ptr->next_ptr;
		}

		fprintf(fpw0,";\n");

		save_ptr = first_ptr;
		for(i=data_sum,j=0;i>=0;i--){
			if(save_ptr->fail_value!=0){
				if(j==0)		fprintf(fpw0,"\t\tEXT\t");
				else				fprintf(fpw0,",");
				fprintf(fpw0,"%sFL",save_ptr->enemy_name0);
				j++;
			}
			if((j==6)||(i==0)){
							fprintf(fpw0,"\n");
							j=0;
			}
			save_ptr = save_ptr->next_ptr;
		}

		fprintf(fpw0,";\n");

		save_ptr = first_ptr;
		for(i=data_sum,j=0;i>=0;i--){
			if(save_ptr->nose_value!=0){
				if(j==0)		fprintf(fpw0,"\t\tEXT\t");
				else				fprintf(fpw0,",");
				fprintf(fpw0,"%sNS",save_ptr->enemy_name0);
				j++;
			}
			if((j==6)||(i==0)){
							fprintf(fpw0,"\n");
							j=0;
			}
			save_ptr = save_ptr->next_ptr;
		}

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,";*\t\tenemy initial name\t\t\t\t*\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,"EINADR\t\tEQU\t$\n");
		for(i=data_sum;i>=0;i--){
			if(save_ptr->init_value!=0){
				fprintf(fpw0,"%sN\t\tLWORD\t%sIN\t\t;[%s]\n",save_ptr->enemy_name0,save_ptr->enemy_name0,save_ptr->enemy_name0);
			}
			else{
				fprintf(fpw0,"%sN\t\tLWORD\tRTLSUB\t\t;[%s]\n",save_ptr->enemy_name0,save_ptr->enemy_name0);
			}
			save_ptr = save_ptr->next_ptr;
		}
		fprintf(fpw0,";\n");
		fprintf(fpw0,"ENENDN\t\tEQU\t$\n");

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,";*\t\tenemy name\t\t\t\t\t*\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,"ENMY_NAME\tEQU\t$\n");
		for(i=data_sum;i>=0;i--){
			fprintf(fpw0,"%s\t\tEQU\t(%sN-EINADR)/3\n",save_ptr->enemy_name0,save_ptr->enemy_name0);
			save_ptr = save_ptr->next_ptr;
		}
		fprintf(fpw0,";\n");
		fprintf(fpw0,";-------------- enemy end pointer -------------------------------\n");
		fprintf(fpw0,"ENEND\t\tEQU\t(ENENDN-EINADR)/3\n");
		fprintf(fpw0,";\n");

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,";*\t\tenemy move name\t\t\t\t\t*\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,"EMVADR\t\tEQU\t$\n");
		for(i=data_sum;i>=0;i--){
			if(save_ptr->move_value!=0){
				fprintf(fpw0,"\t\tLWORD\t%sMV\t\t;[%s]\n",save_ptr->enemy_name0,save_ptr->enemy_name0);
			}
			else{
				fprintf(fpw0,"\t\tLWORD\tRTLSUB\t\t;[%s]\n",save_ptr->enemy_name0);
			}
			save_ptr = save_ptr->next_ptr;
		}

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,";*\t\tenemy fail name\t\t\t\t\t*\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,"EFLADR\t\tEQU\t$\n");
		for(i=data_sum;i>=0;i--){
			if(save_ptr->fail_value!=0){
				fprintf(fpw0,"\t\tLWORD\t%sFL\t\t;[%s]\n",save_ptr->enemy_name0,save_ptr->enemy_name0);
			}
			else{
				fprintf(fpw0,"\t\tLWORD\tRTLSUB\t\t;[%s]\n",save_ptr->enemy_name0);
			}
			save_ptr = save_ptr->next_ptr;
		}

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,";*\t\tenemy nose name\t\t\t\t\t*\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,"ENSADR\t\tEQU\t$\n");
		for(i=data_sum;i>=0;i--){
			if(save_ptr->nose_value!=0){
				fprintf(fpw0,"\t\tLWORD\t%sNS\t\t;[%s]\n",save_ptr->enemy_name0,save_ptr->enemy_name0);
			}
			else{
				fprintf(fpw0,"\t\tLWORD\tRTLSUB\t\t;[%s]\n",save_ptr->enemy_name0);
			}
			save_ptr = save_ptr->next_ptr;
		}

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,";*\t\tenemy status data\t\t\t\t*\n");
		fprintf(fpw0,";****************************************************************\n");
		fprintf(fpw0,"ENMODE0\t\tEQU\t$\n");
		fprintf(fpw0,";\t\t\t    [ENMODE0]\n");
		for(i=data_sum;i>=0;i--){
			fprintf(fpw0,"\t\tWORD\t");
			for(j=1;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->plen1_value>>j)&0x01);
			}
			for(j=2;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->plen0_value>>j)&0x01);
			}
			fprintf(fpw0,"%01d",save_ptr->enen1_value&0x01);
			fprintf(fpw0,"%01d",save_ptr->enen0_value&0x01);
			fprintf(fpw0,"%01d",save_ptr->plen_value&0x01);
			fprintf(fpw0,"%01d",save_ptr->enen_value&0x01);
			fprintf(fpw0,"%01d",save_ptr->eat_value&0x01);
			fprintf(fpw0,"%01d",save_ptr->throw_value&0x01);
			for(j=4;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->objsize_value>>j)&0x01);
			}
			fprintf(fpw0,"B\t;[%s]\n",save_ptr->enemy_name0);
			save_ptr = save_ptr->next_ptr;
		}

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,"ENMODE1\t\tEQU\t$\n");
		fprintf(fpw0,";\t\t\t    [ENMODE1]\n");
		for(i=data_sum;i>=0;i--){
			fprintf(fpw0,"\t\tWORD\t");
			for(j=3;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->eat2_value>>j)&0x01);
			}
			fprintf(fpw0,"0");
			fprintf(fpw0,"%01d",save_ptr->xrev_value&0x01);
			for(j=1;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->tate_value>>j)&0x01);
			}
			for(j=1;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->yoko_value>>j)&0x01);
			}
			fprintf(fpw0,"%01d",save_ptr->yclear_value&0x01);
			for(j=4;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->bgsize_value>>j)&0x01);
			}
			fprintf(fpw0,"B\t;[%s]\n",save_ptr->enemy_name0);
			save_ptr = save_ptr->next_ptr;
		}

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,"ENMODE2\t\tEQU\t$\n");
		fprintf(fpw0,";\t\t\t    [ENMODE2]\n");
		for(i=data_sum;i>=0;i--){
			fprintf(fpw0,"\t\tWORD\t");
			for(j=4;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->objsum_value>>j)&0x01);
			}
			for(j=2;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->point_value>>j)&0x01);
			}
			fprintf(fpw0,"%01d",save_ptr->item_value&0x01);
			fprintf(fpw0,"%01d",save_ptr->enmy_value&0x01);
			for(j=1;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->tama_value>>j)&0x01);
			}
			for(j=1;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->clrsize_value>>j)&0x01);
			}
			for(j=1;j>=0;j--){
				fprintf(fpw0,"%01d",(save_ptr->oamset_value>>j)&0x01);
			}
			fprintf(fpw0,"B\t;[%s]\n",save_ptr->enemy_name0);
			save_ptr = save_ptr->next_ptr;
		}

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,"ENDATA0\t\tEQU\t$\n");
		fprintf(fpw0,";\t\t\t[ENYUSN]  [ENCLOR]\n");
		for(i=data_sum;i>=0;i--){
			fprintf(fpw0,"\t\tBYTE\t     0%02XH,",(unchar)save_ptr->attr_value);

			for(j=1;j>=0;j--){
				fprintf(fpw0,"%1d",(save_ptr->flip_value>>j)&0x01);
			}
			for(j=1;j>=0;j--){
				fprintf(fpw0,"%1d",(save_ptr->attr2_value>>j)&0x01);
			}
			for(j=2;j>=0;j--){
				fprintf(fpw0,"%1d",(save_ptr->color_value>>j)&0x01);
			}
			fprintf(fpw0,"0B\t;[%s]\n",save_ptr->enemy_name0);
			save_ptr = save_ptr->next_ptr;
		}

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,"ENDATA1\t\tEQU\t$\n");
		fprintf(fpw0,";\t\t\t[ENGPOW]  [ENGMAX]\n");
		for(i=data_sum;i>=0;i--){
			fprintf(fpw0,"\t\tBYTE\t     0%02XH,0%04XH/10H\t;[%s]\n",(unchar)save_ptr->gpow_value,save_ptr->gmax_value,save_ptr->enemy_name0);
			save_ptr = save_ptr->next_ptr;
		}

		save_ptr = first_ptr;
		fprintf(fpw0,";\n");
		fprintf(fpw0,"ETCADR\t\tEQU\t$\n");
		fprintf(fpw0,";\t\t\t[OBJ mode7 chara data address]\n");
		for(i=data_sum;i>=0;i--){
			if(save_ptr->mode7_value!=0){
				fprintf(fpw0,"\t\tWORD\tCIPCHD+%04XH\t\t;[%s]\n",save_ptr->mode7_value,save_ptr->enemy_name0);
			}
			else{
				fprintf(fpw0,"\t\tWORD\t00\t\t\t;[%s]\n",save_ptr->enemy_name0);
			}
			save_ptr = save_ptr->next_ptr;
		}

		/****** write file close ******/
		fclose(fpw0);
	}
}
