/*****************************
	帪娫應掕僞僀儅乕傾僾儕
*****************************/
#include "apilib.h"
#include <stdio.h>

void HariMain(void)
{
	HWND hWin;
	HTIME hTimer;
	int win_x = 200, win_y = 80;
	int sec = 0, min = 0, hou = 0;
	char *buf, s[30], cap[] = "仧Easy count timer仧";
	
	api_initmalloc();
	buf = api_malloc(win_x * win_y);
	hWin = api_openwin(buf, win_x, win_y, -1, "timer");
	hTimer = api_alloctimer();
	api_inittimer(hTimer, 128);

	for (;;) {
		sprintf(s, "%5d:%02d:%02d", hou, min, sec);
		api_boxfilwin(hWin, 10, 30, win_x - 10, win_y - 10, COL_BLUE);
		api_putstrwin(hWin, 35, 51, COL_WHITE, 30, s);
		api_putstrwin(hWin, 20, 31, COL_WHITE, 24, cap);
		api_settimer(hTimer, 100);
		if (api_getkey(1) != 128) break;
		sec++;
		if (sec == 60) {
			sec = 0;
			min++;
			if (min == 60) {
				min = 0;
				hou++;
			}
		}
	}
	api_end();
}

