Exemplo n.º 1
0
void HariMain(void) {
  api_initmalloc();

  char cmdline[256];
  api_cmdline(cmdline, sizeof(cmdline));  // TODO: Check command line argument length.

  int argc = 0;
  char* argv[16];

  char* p = cmdline;
  // TODO: Check argument count not to overflow.
  for (;;) {
    if (*p == '\0')
      break;
    argv[argc++] = p;
    p = p + strlen(p) + 1;
  }
  argv[argc] = NULL;

  for (void (**pp)() = __preinit_array_start; pp < __preinit_array_end; ++pp)
    (**pp)();
  // TODO: Init.
  for (void (**pp)() = __init_array_start; pp < __init_array_end; ++pp)
    (**pp)();

  int result = main(argc, argv);
  exit(result);
}
Exemplo n.º 2
0
void HariMain(void)
{
	char *buffer;
	int window, i;
	api_initmalloc();
	buffer = api_malloc(160 * 100);
	window = api_create_window(buffer, 160, 100, -1, "Lines");
	for(i = 0;i < 8; i++)
	{
		api_drawline(window + 1, 8, 26, 77, i * 9 + 26, i);
		api_drawline(window + 1, 88, 26, i * 9 + 88, 89, i);
	}
	api_refreshwindow(window, 6, 26, 154, 90);
	/*
	for(;;)
	{
		if(0x0a == api_getkey(1))
		{
			break;
		}
	}
	*/
	api_closewindow(window);
	api_end();
}
Exemplo n.º 3
0
Arquivo: noodle.c Projeto: 1m69/OSASK
void HariMain(void)
{
	char *buf, s[12];
	int win, timer, sec = 0, min = 0, hou = 0;
	api_initmalloc();
	buf = api_malloc(150 * 50);
	win = api_openwin(buf, 150, 50, -1, "noodle");
	timer = api_alloctimer();
	api_inittimer(timer, 128);
	for (;;) {
		sprintf(s, "%5d:%02d:%02d", hou, min, sec);
		api_boxfilwin(win, 28, 27, 115, 41, 7 /* �� */);
		api_putstrwin(win, 28, 27, 0 /* �� */, 11, s);
		api_settimer(timer, 100);	/* 1�b�� */
		if (api_getkey(1) != 128) {
			break;
		}
		sec++;
		if (sec == 60) {
			sec = 0;
			min++;
			if (min == 60) {
				min = 0;
				hou++;
			}
		}
	}
	api_end();
}
Exemplo n.º 4
0
void HariMain(){
    char *buf;
    int win;
    api_initmalloc();
    buf = api_malloc(150 * 100);
	win = api_openwin(buf, 150, 100, -1, "timer");
    api_end();
}
Exemplo n.º 5
0
void HariMain(void)
{
    char *buf;
    int win;
    api_initmalloc();
    buf = api_malloc(150 * 100);
    win = api_openwin(buf, 150, 100, -1, "star1");
    api_boxfilwin(win,  6, 26, 143, 93, 0 /* 黒 */);
    api_point(win, 75, 59, 3 /* 黄 */);
    api_end();
}
Exemplo n.º 6
0
void HariMain(void)
{
	char *buf;
	int win;

	api_initmalloc();
	buf = api_malloc(150 * 50);
	win = api_openwin(buf, 150, 50, -1, "hello");
	api_boxfilwin(win,  8, 36, 141, 43, 6 /* ���F */);
	api_putstrwin(win, 28, 28, 0 /* �� */, 12, "hello, world");
	api_end();
}
Exemplo n.º 7
0
void HariMain (void)
{
  api_initmalloc ();
  char *buf = api_malloc (144 * 164);
  int win = api_openwin (buf, 144, 164, -1, "color");
  for (int y = 0; y < 128; y++) {
	for (int x = 0; x < 128; x++) {
	  buf [(x + 8) + (y + 28) * 144] = rgb2pal(x * 2, y * 2, 0, x, y);
	}
  }
  api_refreshwin (win, 8,28, 136, 156);
  api_getkey (1);
  api_end();
}
Exemplo n.º 8
0
void HariMain()
{
	int win, xsize = 400, ysize = 200;
	char win_buf[xsize * ysize];
	api_initmalloc();
	
	struct MOUSE_INFO *minfo;
	minfo = api_malloc(sizeof(struct MOUSE_INFO));
	minfo->flag = -589;
	int counter = 0;
	int index = 0;
	char cbuf[20];
	
	win = api_openwin((char *)win_buf, xsize, ysize, -1 /*ºÚÉ«*/, "minesweeper");
    api_refreshwin(win, 0, 0, xsize-1, ysize-1);

	char s[20];
	for(;;)
	{
		sprintf(cbuf, "%10d", counter);
		api_boxfilwin(win, 30, 30, 30 + strlen(cbuf) * 8, 30 + 16, 8/*ÁÁ»Ò*/);
		api_putstrwin(win, 30, 30, 0 /*ºÚÉ«*/, strlen(cbuf),  cbuf);
		
		api_getmouse(1, minfo);
			
		if(minfo->flag == 1)
		{	
			sprintf(s,"%5d %5d, [l m r] %d", minfo->x, minfo->y, minfo->btn);
			//sprintf(s,"%d", (int)minfo);
			if( (minfo->btn & 0x01) != 0 ){
				s[14] = 'L';
			}
			if( (minfo->btn & 0x02) != 0 ){
				s[18] = 'R';
			}
			if( (minfo->btn & 0x04) != 0 ){
				s[16] = 'M';
			}
			api_boxfilwin(win, 30, 50, 30 + 40 * 8, 50 + 16, 8/*ÁÁ»Ò*/);
			api_putstrwin(win, 30, 50, 0, strlen(s),  s);
			minfo->flag = -1;
		}
		counter++;
	}
	
	api_free(minfo, sizeof(struct MOUSE_INFO));
	api_closewin(win);
	api_end();
}
Exemplo n.º 9
0
void CHNMain(void)
{
	uchar *buf;
	uint winID;

	api_initmalloc();
	buf = api_malloc(150 * 100);
	winID = api_openwin(buf, 150, 100, -1, "star1");
	api_boxfilwin(winID, 6, 26, 143, 93, black);
	api_point(winID, 75, 59, yellow);
	for(;;){
		if(api_getkey(true) == 0x0a) break;
	}
	api_end();
}
Exemplo n.º 10
0
void HariMain(void)
{
	char *buf;
	int win, i, x, y;
	api_initmalloc();
	buf = api_malloc(150 * 100);
	win = api_openwin(buf, 150, 100, -1, "stars");
	api_boxfilwin(win,  6, 26, 143, 93, 0 /* 黒 */);
	for (i = 0; i < 50; i++) {
		x = (rand() % 137) +  6;
		y = (rand() %  67) + 26;
		api_point(win, x, y, 3 /* 黄 */);
	}
	api_end();
}
Exemplo n.º 11
0
Arquivo: star1.c Projeto: OSPROJ/LOS
void HariMain(void)
{
	char *buf;
	int win;
	api_initmalloc();
	buf = api_malloc(150 * 100);
	win = api_openwin(buf, 150, 100, -1, "star1");
	api_boxfilwin(win,  6, 26, 143, 93, 0 /* �� */);
	api_point(win, 75, 59, 3 /* �� */);
	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break; /* Enter�Ȃ�break; */
		}
	}
	api_end();
}
Exemplo n.º 12
0
void UcanMain(void)
{
	char *buf;
	int win, x, y;
	api_initmalloc();
	buf = api_malloc(144 * 164);
	win = api_openwin(buf, 144, 164, -1, "color2");
	for (y = 0; y < 128; y++) {
		for (x = 0; x < 128; x++) {
			buf[(x + 8) + (y + 28) * 144] = rgb2pal(x * 2, y * 2, 0, x, y);
		}
	}
	api_refreshwin(win, 8, 28, 136, 156);
	api_getkey(1); /* 等待任意键按下 */
	api_end();
}
Exemplo n.º 13
0
void HariMain(void)
{
	char *buf;
	int win;

	api_initmalloc();
	buf = api_malloc(150 * 50);
	win = api_openwin(buf, 150, 50, -1, "hello");
	api_boxfilwin(win,  8, 36, 141, 43, 6); /*浅蓝色*/
	api_putstrwin(win, 28, 28, 0 , 12, "hello, world");/*黑色*/
	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break; /*按下回车键则break; */
		}
	}
	api_end();
}
Exemplo n.º 14
0
void HariMain(void)
{
	char *buf;
	int win;

	api_initmalloc();
	buf = api_malloc(150 * 50);
	win = api_openwin(buf, 150, 50, -1, "hello");
	api_boxfilwin(win,  8, 36, 141, 43, 6 /* 물색 */);
	api_putstrwin(win, 28, 28, 0 /* 검정 */, 12, "hello, world");
	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break; /* Enter라면 break; */
		}
	}
	api_end();
}
Exemplo n.º 15
0
void HariMain(void)
{
	char *buffer;
	int window, i, x, y;
	api_initmalloc();
	buffer = api_malloc(150 * 100);
	window = api_create_window(buffer, 150, 100, -1, "Stars");
	api_drawrectangle_onwindow(window + 1, 6, 26, 138, 68, 0);
	for(i = 0;i < 50; i++)
	{
		x = (rand() % 138) + 6;
		y = (rand() % 68) + 26;
		api_drawpoint(window + 1, x, y, 3);
	}
	api_refreshwindow(window, 6, 26, 150, 100);
	api_end();
}
Exemplo n.º 16
0
void HariMain(void)
{
	char *buf;
	int win;

	api_initmalloc();
	buf = api_malloc(150 * 150);
	win = api_openwin(buf, 150, 150, -1, "hello");
	api_boxfilwin(win,  8, 36, 141, 43, 6);
	api_putstrwin(win, 0, 0, 0, 12, "hello my world");
	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break;
		}
	}
	api_end();
}
Exemplo n.º 17
0
void HariMain(void)
{
    char* buf;
    int win, x, y, r, g, b;
    api_initmalloc();
    buf = api_malloc(144 * 164);
    win = api_openwin(buf, 144, 164, -1, "color");
    for (y = 0; y < 128; y++) {
        for (x = 0; x < 128; x++) {
            r = x * 2;
            g = y * 2;
            b = 0;
            buf[(x + 8) + (y + 28) * 144] = 16 + (r / 43) + (g / 43) * 6 + (b / 43) * 36;
        }
    }
    api_refreshwin(win, 8, 28, 136, 156);
    api_getkey(1); /* 按下任意键 */
    api_end();
}
Exemplo n.º 18
0
void HariMain(void)
{
	char *buf;
	int win, i;
	api_initmalloc();
	buf = api_malloc(160 * 100);
	win = api_openwin(buf, 160, 100, -1, "lines");
	for (i = 0; i < 8; i++) {
		api_linewin(win + 1, 8, 26, 77, i * 9 + 26, i);
		api_linewin(win + 1, 88, 26, i * 9 + 88, 89, i);
	}
	api_refreshwin(win, 6, 26, 154, 90);
	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break; //enter
		}
	}
	api_closewin(win);
	api_end();
}
Exemplo n.º 19
0
Arquivo: stars.c Projeto: barmi/bxos
void HariMain(void)
{
	char *buf;
	int win, i, x, y;
	api_initmalloc();
	buf = api_malloc(150 * 100);
	win = api_openwin(buf, 150, 100, -1, "stars");
	api_boxfilwin(win,  6, 26, 143, 93, 0 /* 검정 */);
	for (i = 0; i < 50; i++) {
		x = (rand() % 137) +  6;
		y = (rand() %  67) + 26;
		api_point(win, x, y, 3 /* 노랑 */);
	}
	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break; /* Enter라면 break; */
		}
	}
	api_end();
}
Exemplo n.º 20
0
void HariMain(void)
{
	char *buffer;
	int window, i, x, y;
	api_initmalloc();
	buffer = api_malloc(160 * 100);
	window = api_create_window(buffer, 160, 100, -1, "game");
	api_drawrectangle_onwindow(window, 4, 24, 152, 72, 0);
	x = 76;
	y = 56;
	api_putstring_onwindow(window, x, y, 3, 1, "*");
	for(;;)
	{
		i = api_getkey(1);
		api_putstring_onwindow(window, x, y, 0, 1, "*");
		if('4' == i && x > 4)
		{
			x -= 8;
		}
		if('6' == i && x < 148)
		{
			x += 8;
		}
		if('8' == i && y > 24)
		{
			y -= 8;
		}
		if('2' == i && y < 80)
		{
			y += 8;
		}
		if(0x0a == i)			//按下回车键就结束
		{
			break;
		}
		api_putstring_onwindow(window, x, y, 3, 1, "*");
	}
	api_closewindow(window);
	api_end();
}
Exemplo n.º 21
0
void HariMain(void)
{
	char *buf;
	int win, i, x, y;
	api_initmalloc();
	buf = api_malloc(160 * 100);
	win = api_openwin(buf, 160, 100, -1, "walk");
	api_boxfilwin(win, 4, 24, 155, 95, 0);/*黑色*/
	x = 76;
	y = 56;
	api_putstrwin(win, x, y, 3, 1, "*");/*黄色*/
	for (;;) {
		i = api_getkey(1);
		api_putstrwin(win, x, y, 0 , 1, "*"); /*用黑色擦除*/
		if (i == '4' && x >   4) { x -= 8; }
		if (i == '6' && x < 148) { x += 8; }
		if (i == '8' && y >  24) { y -= 8; }
		if (i == '2' && y <  80) { y += 8; }
		if (i == 0x0a) { break; } /*按回车键结束*/
		api_putstrwin(win, x, y, 3 , 1, "*");/*黄色*/
	}	
	api_closewin(win);
	api_end();
}
Exemplo n.º 22
0
void HariMain(void)
{


	char *buf;
	int win, i, x, y, timer;
	api_initmalloc();
	buf = api_malloc(200 * 200);
	char* title;
	char keyflag[4];
	char *last_direction;
	*last_direction = '4';


	//snake
	struct snakeNode *head = api_malloc(sizeof(struct snakeNode));
	head->preNode = NULL;
	head->posX = 75;
	head->posY = 55;
	head->moveDirection = 4;

	struct snakeNode *tail = head;
	//snake

	//food
	struct Food food;
	food.posX = 69;
	food.posY = 61;
	food.isEaten = 1;// not eaten;
	//food



	sprintf(title, "posX: %d, posY: %d, mp: %d", tail->posX, tail->posY, tail->moveDirection);
	//sprintf(title, "Hungry Snake");
	win = api_openwin(buf, 200, 200, -1, title);
	timer = api_alloctimer();

	api_inittimer(timer, 128);

	api_boxfilwin(win, 5, 25, 195, 195, 0);
	x = 75;
	y = 55;
	tail->posX = 75;
	tail->posY = 55;
	api_putstrwin(win, tail->posX, tail->posY, 3, 1, "*");
	//scrnRefresher(win, tail, 3, "*");





	for (;;) {

		i = *last_direction;
		scrnRefresher(win, tail, 0, "*");
		// updateSnake(head);
		updateSnake(tail);
		scrnRefresher(win, tail, 3, "*");

		//add food here
		foodInit(&food, win, 4, "+");
		//add food here


		/*detecting*/
		detecting(head, &tail, &food);



		delay();
		//if (snakeLength < 10) {tail = addSegment(tail, &snakeLength);}

		wait(1, timer, keyflag, last_direction, head);
	}




	api_closewin(win);
	api_end();
}