/* テストプログラム*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <msdos.cf>
#include <egb.h>
#include <mos.h>
#include <snd.h>

#include <ysuty2.h>
#include <s_button.h>


/* グローバル変数の初期化 */
char	gwork[1536];				/* EGB用ワークエリア */
char	mwork[4096];				/* マウス用ワークエリア */
char	mosPat_work[258];			/* マウスカーソル形状用 */
FILE	*fp;


/* 関数のプロトタイプ宣言 */

int		init();
ITEM	*addItems();
int		execItems();
int		term();

int		main(int argc,char *argv[])
{
	init();									/* 各種初期化 */
	addItems();								/* ボタンの描画 */

	execItems();							/* アイテムの実行 */
	term();									/* 終了 */

	return(0);
}


/* 画面への描画等の初期化 */
int		init()
{
	YGB_init(gwork,17,10);
	YGB_writePage(gwork,0);
	YGB_writeMode(gwork,PSET);

	
	MOS_start(mwork,4096);
	MOS_resolution(0,17);
	MOS_writePage(0);
	MOS_color(0,_C(31,31,31));
	MOS_typeRom(81,0,0,mosPat_work);
	MOS_setpos(128,120);


	YGB_use12dotFont();				/* 拡張ライブラリＩの無い人はカット*/

	YGB_fontSize(gwork,6,12);
	YGB_color(gwork,15);
	YGB_print(gwork,32,32,"EVTPLAY?");

	return(0);
}


/* ボタンの描画＆設定*/
ITEM *addItems()
{
	ITEM	*top;
	YGB_color(gwork,100);
	SGB_holButton(gwork,160,50,179,60,_C(24,24,24));
	YGB_color(gwork,_C(6,6,24));
	YGB_box(gwork,159,49,180,61);
	top=YGU_addButton(NULL,160,50,20,11);
	
	SGB_proButton(gwork,120,40,135,47,_C(12,26,17));
	SGB_colButton(gwork,136,40,151,47,_C(31,31,31),_C(0,0,31),_C(0,31,0));
	SGB_gradProButton(gwork,130,80,145,95,_C(31,15,15),_C(0,0,0),1);
	SGB_gradProButton(gwork,146,80,161,95,_C(28,24,24),_C(18,18,0),0);
	SGB_gradHolButton(gwork,162,80,177,95,_C(2,2,1),_C(24,24,12),0);
	SGB_gradProButton(gwork,115,80,129,94,_C(0,0,0),_C(31,31,31),1);

	char	bunsho[60];		/*[60]っていうように数を指定しないと強制終了。*/
	char	bun2[]="[例えばこのように]";
	sprintf(bunsho," sprintfを使いましょう...%s\n",bun2);

	SGB_gradStrProButton(gwork,130,102,_C(20,20,20),
						14,1," BUTTON ",6,12,1,_C(0,0,0));
	SGB_strProButton(gwork,130,165,_C(20,20,20)," 文字列 だ",6,12,1,_C(0,0,0));
	SGB_strHolButton(gwork,130,118,_C(20,20,20),"EXIT?",6,12,1,_C(0,0,0));
	SGB_strProButton(gwork,30,133,_C(20,20,20),bunsho,6,12,1,_C(0,0,0));
	SGB_gradStrHolButton(gwork,130,149,_C(20,20,20),
						_C(31,15,31),0,"EXIT?",6,12,1,_C(0,0,0));
	SGB_gradProButton(gwork,0,0,500,20,_C(31,31,31),0,1);	/* 書くのが見える*/


	SGB_proPlate(gwork,120,280,135,287,_C(12,26,17));
	SGB_colPlate(gwork,136,280,151,287,_C(31,31,31),_C(0,0,31),_C(0,31,0));
	SGB_gradProPlate(gwork,130,320,145,335,_C(31,15,15),_C(15,31,31),1);
	SGB_gradProPlate(gwork,146,320,161,335,_C(28,24,24),_C(20,20,28),0);
	SGB_gradHolPlate(gwork,162,320,177,335,_C(2,2,1),_C(24,24,12),0);
	SGB_gradProPlate(gwork,115,320,129,334,_C(31,0,0),_C(0,31,31),1);

	SGB_gradStrProPlate(gwork,130,342,_C(20,20,20),
						_C(14,14,14),1," PLATE ",6,12,1,_C(0,0,0));
	SGB_strProPlate(gwork,130,405,_C(20,20,20)," 文字列 ",6,12,1,_C(0,0,0));
	SGB_strHolPlate(gwork,130,358,_C(20,20,20),"EXIT?",6,12,1,_C(0,0,0));
	SGB_strProPlate(gwork,30,373,_C(20,20,20),bunsho,6,12,1,_C(0,0,0));
	SGB_gradStrHolPlate(gwork,130,389,_C(20,20,20),
						_C(31,31,31),0,
						"カットとペーストがばればれ",6,12,1,_C(0,0,0));
	SGB_gradProPlate(gwork,0,240,500,260,_C(31,31,31),_C(15,15,31),1);

	return top;
}


/* アイテムの実行 */
int		execItems()
{
	ITEM	*act,*one;
	int		stat=0xff;

	one=addItems();
	MOS_disp(1);

	act=NULL;
	
	while( (act!=one)&&(stat==0xff) )
	{
		act=YGU_allItemsAction(gwork,one);
		SND_joy_in_2(0,&stat);
	}
	YGU_deleteAll(one);
	return(0);
}


/* 終了 */
int		term()
{
	MOS_disp(0);
	MOS_end();
	return(0);
}


