Exemple #1
0
void HariMain(void)
{
	FileDescriptor *fd;
	char* path = "/TESFILE";
	char src[16];
	char *result;
	if(0 != api_crate(path)) {
		api_putstr0("create error");
		api_end();
	}
	if((fd =(FileDescriptor*)api_open(path,FD_MODE_READ_WRITE))== NULL){
		api_putstr0("open error");
		api_end();
	}
	strcpy(src,"writing");
	if(0 != api_write(fd,16,src)){
		api_putstr0("write error");
		api_end();
	}
	if(0 != api_read(fd,16,result)){
		 api_putstr0("read error");
		 api_end();
 	}
	api_putstr0(result);
	if(0 != api_close(fd))
		api_putstr0("create error");
	api_end();
}
Exemple #2
0
void HariMain(void)
{
	char buf[214 * 82 * osak_getbuflen()], s[2];
	int win, col;

	win = api_openwin(buf, 25 * 8 + 14, 3 * 16 + 34, -1, "LuckyNum");
	api_boxfilwin(win, BPX, BPY, 25 * 8 + BPX, 3 * 16 + BPY, 0);

	api_putstrwin(win, BPX,      BPY, 6, 12, "LuckyNumber=");
	api_putstrwin(win, BPX, 16 + BPY, 6, 12, "LuckyColor =");
	api_putstrwin(win, BPX, 32 + BPY, 3, 17, "Good Luck!(^o^)/~");

	srand(tomo_gettick()); /* seedを与える */

	s[0] = '0' + rand() % 10;
	s[1] = '\0';
	api_putstrwin(win, 13 * 8 + BPX, BPY, 6, 1, s);

	col = rand() % 9;	/* Hariboteは明るい色が前に集まっているので変なループはいらない */

	api_boxfilwin(win, 13 * 8 + BPX, 16 + BPY, 14 * 8 + BPX - 1, 32 + BPY - 1, col);

	while (api_getkey(1) != 0x0a);

	api_closewin(win);
	api_end();
}
Exemple #3
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();
}
Exemple #4
0
void HariMain(void)
{
  *((char*)0x00102600) = 0;
  api_end();

  return;
}
Exemple #5
0
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, "%d:%d:%d", hou, min, sec);
	api_boxfilwin (win, 28, 27, 115, 41, 7 /* White */);
	api_putstrwin (win, 28, 27, 0 /* Black */, 11, s);
	api_settimer (timer, 100); /* 1 second */
	if (api_getkey(1) != 128) {
	  break;
	}
	sec++;
	if (sec == 60) {
	  sec = 0;
	  min++;
	  if (min == 60) {
		min = 0;
		hou++;
	  }
	}
  }
  api_end();
}
Exemple #6
0
void 
HariMain(void)
{
  api_putstr0("Hello, world!\n");

  api_end();
}
Exemple #7
0
void HariMain(void)
{
	char *buffer, string[12];
	int window, timer, second = 0, minute = 0, hour = 0;
	api_initmalloc();
	buffer = api_malloc(150 * 100);
	window = api_create_window(buffer, 150, 100, -1, "clock");
	timer = api_alloctimer();
	api_inittimer(timer, 128);
	for(;;)
	{
		sprintf(string, "%5d:%02d:%02d", hour, minute, second);
		api_drawrectangle_onwindow(window, 28, 27, 115, 41, 7);
		api_putstring_onwindow(window, 28, 27, 0, 11, string);
		api_settimer(timer, 100);
		if(128 != api_get_fifodata(1))
		{
			break;
		}
		second++;
		if(second == 60)
		{
			second = 0;
			if(minute == 60)
			{
				minute = 0;
				hour++;
			}
		}
	}
	api_end();
}
Exemple #8
0
void HariMain(void)
{
	static char s[9] = { 0xb2, 0xdb, 0xca, 0xc6, 0xce, 0xcd, 0xc4, 0x0a, 0x00 };
	/*半角片假名イロハニホヘト的字符编码+换行+0 */
	api_putstr0(s);
	api_end();
}
Exemple #9
0
void HariMain(void)
{
	char buf[152 * 100], col;
	int win, timer;
	int bpx = 8, bpy = 26;

	win = api_openwin(buf, 152, 100, -1, "Mt.orz");
	timer = api_alloctimer();
	api_inittimer(timer, 128);

	for (;;) {
		for (col = 8; col < 16; col++) {
			if (col == 8) { col = 0; }	/* OSASKのパレットとは微妙に違うため */
			api_putstrwin(win, 7 * 8 + bpx, 0      + bpy, col,  3, "orz");
			api_putstrwin(win, 5 * 8 + bpx,     16 + bpy, col,  7, "orz orz");
			api_putstrwin(win, 3 * 8 + bpx, 2 * 16 + bpy, col, 11, "orz orz orz");
			api_putstrwin(win,     8 + bpx, 3 * 16 + bpy, col, 15, "orz orz orz orz");
			if (col == 0) { col = 8; }	/* 上と同じ */
			api_settimer(timer, 50);	/* 0.5秒 */
			if (api_getkey(1) != 128) {
				goto end;
			}
		}
	}

end:
	api_closewin(win);
	api_end();
}
Exemple #10
0
void HariMain(void)
{
    int fh;
    char c, cmdline[80], *p;

    api_cmdline(cmdline, 80);
    for (p = cmdline; *p != ' '; p++)
        ; /* 跳过第一个参数 */
    for (; *p == ' '; p++)
        ; /* 跳过空格 */
    fh = api_fopen(p);
    if (fh != 0) {
        for (;;) {
            if (api_fread(&c, 1, fh) == 0) {
                break;
            }
            api_putchar(c);
        }
    } else {
    	char s[40];
    	p[16] = 0;
    	sprintf(s, "File '%s' not found.\n", p);
        api_putstr0(s);
    }
    api_end();
}
Exemple #11
0
void HariMain(void)
{
	int win, i, j, dis;
	char buf[216 * 237];
	struct POINT {
		int x, y;
	};
	static struct POINT table[16] = {
		{ 204, 129 }, { 195,  90 }, { 172,  58 }, { 137,  38 }, {  98,  34 },
		{  61,  46 }, {  31,  73 }, {  15, 110 }, {  15, 148 }, {  31, 185 },
		{  61, 212 }, {  98, 224 }, { 137, 220 }, { 172, 200 }, { 195, 168 },
		{ 204, 129 }
	};

	win = api_openwin(buf, 216, 237, -1, "bball");
	api_boxfilwin(win, 8, 29, 207, 228, 0);
	for (i = 0; i <= 14; i++) {
		for (j = i + 1; j <= 15; j++) {
			dis = j - i; /*两点间的距离*/
			if (dis >= 8) {
				dis = 15 - dis; /*逆向计数*/
			}
			if (dis != 0) {
				api_linewin(win, table[i].x, table[i].y, table[j].x, table[j].y, 8 - dis);
			}
		}
	}

	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break; /*按下回车键则break; */
		}
	}
	api_end();
}
Exemple #12
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);
	for(;;)
	{
		if(0x0a == api_getkey(1))
		{
			break;
		}
	}
	api_closewindow(window);
	api_end();
}
Exemple #13
0
void HariMain(){
    char *buf;
    int win;
    api_initmalloc();
    buf = api_malloc(150 * 100);
	win = api_openwin(buf, 150, 100, -1, "timer");
    api_end();
}
Exemple #14
0
void 
HariMain(void)
{
  int win;
  win = win_open(buf, 150, 50, -1, "Hello-Win");

  api_end();
}
Exemple #15
0
void HariMain(void)
{
    int win;
    win = api_openwin(buf, 150, 50, -1, "hello");
	api_boxfilwin(win,  8, 36, 141, 43, 3);
	api_putstrwin(win, 28, 28, 0, 12, "hello, world");
    api_end();
}
Exemple #16
0
void HariMain(void)
{
  api_putchar('h');
  api_putchar('e');
  api_putchar('l');
  api_putchar('l');
  api_putchar('o');
  api_end();
}
Exemple #17
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();
}
Exemple #18
0
void HariMain(void)
{
	api_putchar('H');
	api_putchar('e');
	api_putchar('l');
	api_putchar('l');
	api_putchar('o');
	api_putchar('!');
	api_end();
	return ;
}
Exemple #19
0
void CHNMain(void)
{
	char a[100];
	a[10] = 'A';
	api_putchar(a[10]);
	a[10] = 'B';
	api_putchar(a[102]);
	a[10] = 'C';
	api_putchar(a[123]);
	api_end();
}
Exemple #20
0
void HariMain(void)
{
	int file = api_fopen("license.txt");
	int size = api_fsize(file /* handle */, 0 /* mode */);
	char* buff = (char *) api_malloc(size + 1);
	api_fread(buff, size, file);
	buff[size] = '\0';
	api_putstr0(buff);
	api_fclose(file);
	api_free(buff);
	api_end();
}
Exemple #21
0
void exit(int status) {
  for (int i = 0; i < _atexit.count; ++i) {
    ExitFunction f = _atexit.functions[i];
    (*f)();
  }

  __cxa_finalize(NULL);

  // TODO: Handle exit status.
  (void)status;
  api_end();
}
Exemple #22
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();
}
Exemple #23
0
void HariMain(void)
{
	int win;
	char buf[150 * 50];

	win = api_openwin(buf, 150, 50, -1, "hello");
	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break; /*按下回车键则break; */
		}
	}
	api_end();
}
Exemple #24
0
void HariMain(void)
{
	int win;
	win = api_openwin(buf, 150, 50, -1, "hello");
	api_boxfilwin(win,  8, 36, 141, 43, 3 /* �� */);
	api_putstrwin(win, 28, 28, 0 /* �� */, 12, "hello, world");
	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break; /* Enter�Ȃ�break; */
		}
	}
	api_end();
}
Exemple #25
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();
}
Exemple #26
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();
}
Exemple #27
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();
}
Exemple #28
0
void HariMain(void)
{
	int fh;
	char c;
	fh = api_fopen("ipl10.nas");
	if (fh != 0) {
		for (;;) {
			if (api_fread(&c, 1, fh) == 0) {
				break;
			}
			api_putchar(c);
		}
	}
	api_end();
}
Exemple #29
0
void HariMain(void)
{
    int win;
    char buf[150 * 70];
    win = api_openwin(buf, 150, 70, 255, "notrec");
    api_boxfilwin(win,   0, 50,  34, 69, 255);
    api_boxfilwin(win, 115, 50, 149, 69, 255);
    api_boxfilwin(win,  50, 30,  99, 49, 255);
    for (;;) {
	if (api_getkey(1) == 0x0a) {
		break;
	}
    }
    api_end();
}
Exemple #30
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();
}