#include <stdio.h>
#include "apilib.h"

void HariMain(void)
{
	int *buf, s[12];
	int win, timer, sec = 0, min = 0, hou = 0;
	api_initmalloc();
	buf = api_malloc(150 * 50 * 4);
	win = api_openwin(buf, 150, 50, -1, "ヌードル(3分)");
	timer = api_alloctimer();
	api_inittimer(timer, 128);
	for (;;) {
		sprintf(s, "%5d:%02d:%02d", hou, min, sec);
		api_boxfilwin(win, 28, 27, 115, 41, api_getint(7) /* 白 */);
		api_putstrwin(win, 28, 27, api_getint(0) /* 黒 */, 11, s);
		api_settimer(timer, 100);	/* 1秒間 */
		if(api_getkey(1) != 128)
		{
			break;
		}
		sec++;
		if (sec == 60) {
			sec = 0;
			min++;
			if (min == 60) {
				min = 0;
				hou++;
			}
		}
		if( min == 3 && sec == 0 )
		{
			api_beep(440000);
		}
		if( min == 3 && sec == 3 )
		{
			api_beep(0);
		}
	}
	api_end();
}
