Ejemplo n.º 1
0
int main() {
  const int W = 160 + 8 * 2, H = 160 + 20 + 16 + 8 * 2;
  unsigned char* buf = api_malloc(W * H);
  int win = api_openwin(buf, W, H, -1, "clock");
  TIMER* timer = api_alloctimer();
  api_inittimer(timer, 128);
  for (;;) {
    unsigned char now[7];
    api_now(now);
    int year = (now[0] << 8) | now[1];
    int month = now[2];
    int day = now[3];
    int hour = now[4];
    int minute = now[5];
    int second = now[6];

    char s[24];
    snprintf(s, sizeof(s), "%d/%02d/%02d %02d:%02d:%02d", year, month, day, hour, minute, second);
    api_boxfilwin(win | 1, 8, 20 + 8, W - 8, H - 8, COL8_DARK_GRAY);
    draw_poly_circle(win | 1, 160 / 2 + 8, 160 / 2 + 8 + 20, 78, 12, COL8_BLACK);
    draw_clock_line(win | 1, second, 60, 70, COL8_DARK_BLUE);
    draw_clock_line(win | 1, minute * 60 + second, 60 * 60, 60, COL8_GREEN);
    draw_clock_line(win | 1, ((hour % 12) * 60 + minute) * 60 + second, 12 * 60 * 60, 40, COL8_RED);
    api_putstrwin(win | 1, (W - 19 * 8) / 2, H - 8 - 16, COL8_WHITE, 19, s);
    api_refreshwin(win, 8, 20 + 8, W - 8, H - 8);

    api_settimer(timer, 100);
    if (api_getkey(1) == 0x1b)
      break;
  }
  return 0;
}
Ejemplo n.º 2
0
Archivo: tview.c Proyecto: barmi/bxos
void textview(int win, int w, int h, int xskip, char *p, int tab, int lang)
{
	int i;
	api_boxfilwin(win + 1, 8, 29, w * 8 + 7, h * 16 + 28, 7);
	for (i = 0; i < h; i++) {
		p = lineview(win, w, i * 16 + 29, xskip, p, tab, lang);
	}
	api_refreshwin(win, 8, 29, w * 8 + 8, h * 16 + 29);
	return;
}
Ejemplo n.º 3
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();
}
Ejemplo n.º 4
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();
}
Ejemplo n.º 5
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, "stars2");
	api_boxfilwin(win + 1,  6, 26, 143, 93, 0 /* 崟 */);
	for (i = 0; i < 50; i++) {
		x = (rand() % 137) +  6;
		y = (rand() %  67) + 26;
		api_point(win + 1, x, y, 3 /* 墿 */);
	}
	api_refreshwin(win,  6, 26, 144, 94);
	api_end();
}
Ejemplo n.º 6
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();
}
Ejemplo n.º 7
0
void main()
{
	char buf[144 * 164];
	int win, x, y , r, g, b;
	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] = rgb2pal(r, g, b, x, y);
		}
	api_refreshwin(win, 8, 28, 136, 156);
	api_getkey(1);
	return;
}
Ejemplo n.º 8
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();
}
Ejemplo n.º 9
0
void putstr(int win, char *winbuf, int x, int y, int col, unsigned char *s)
{
	int c, x0, i;
	char *p, *q, t[2];
	x = x * 8 + 8;
	y = y * 16 + 29;
	x0 = x;
	i = strlen(s);	
	api_boxfilwin(win + 1, x, y, x + i * 8 - 1, y + 15, 0); //remove all with black color
	q = winbuf + y * 336;
	t[1] = 0;
	for (;;) {
		c = *s;
		if (c == 0) {
			break;
		}
		if (c != ' ') {
			if ('a' <= c && c <= 'h') {
				p = charset + 16 * (c - 'a');
				q += x;
				for (i = 0; i < 16; i++) {
					if ((p[i] & 0x80) != 0) { q[0] = col; }
					if ((p[i] & 0x40) != 0) { q[1] = col; }
					if ((p[i] & 0x20) != 0) { q[2] = col; }
					if ((p[i] & 0x10) != 0) { q[3] = col; }
					if ((p[i] & 0x08) != 0) { q[4] = col; }
					if ((p[i] & 0x04) != 0) { q[5] = col; }
					if ((p[i] & 0x02) != 0) { q[6] = col; }
					if ((p[i] & 0x01) != 0) { q[7] = col; }
					q += 336;
				}
				q -= 336 * 16 + x;
			} else {
				t[0] = *s;
				api_putstrwin(win + 1, x, y, col, 1, t);
			}
		}
		s++;
		x += 8;
	}
	api_refreshwin(win, x0, y, x, y + 16);
	return;
}
Ejemplo n.º 10
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();
}
Ejemplo n.º 11
0
Archivo: stars2.c Proyecto: 1m69/OSASK
void HariMain(void)
{
	char *buf;
	int win, i, x, y;
	api_initmalloc();
	buf = api_malloc(150 * 100);
	win = api_openwin(buf, 150, 100, -1, "stars2");
	api_boxfilwin(win + 1,  6, 26, 143, 93, 0 /* 黒 */);
	for (i = 0; i < 50; i++) {
		x = (rand() % 137) +  6;
		y = (rand() %  67) + 26;
		api_point(win + 1, x, y, 3 /* 黄 */);
	}
	api_refreshwin(win,  6, 26, 144, 94);
	for (;;) {
		if (api_getkey(1) == 0x0a) {
			break; /* Enterならbreak; */
		}
	}
	api_end();
}
Ejemplo n.º 12
0
Archivo: mmlplay.c Proyecto: 1m69/OSASK
void HariMain(void)
{
	char winbuf[256 * 112], txtbuf[100 * 1024];
	char s[32], *p, *r;
	int win, timer, i, j, t = 120, l = 192 / 4, o = 4, q = 7, note_old = 0;

	/* 音番号と周波数(mHz)の対応表 */
	/* たとえば、O4Aは440Hzなので、440000 */
	/* オクターブ16のAは1802240Hzなので、1802240000 */
	/* 以下はオクターブ16のリスト(C〜B) */
	static int tonetable[12] = {
		1071618315, 1135340056, 1202850889, 1274376125, 1350154473, 1430438836,
		1515497155, 1605613306, 1701088041, 1802240000, 1909406767, 2022946002
	};
	static int notetable[7] = { +9, +11, +0 /* C */, +2, +4, +5, +7 };

	/* コマンドライン解析 */
	api_cmdline(s, 30);
	for (p = s; *p > ' '; p++) { }	/* スペースが来るまで読み飛ばす */
	for (; *p == ' '; p++) { }	/* スペースを読み飛ばす */
	i = strlen(p);
	if (i > 12) {
file_error:
		end("file open error.\n");
	}
	if (i == 0) {
		end(0);
	}

	/* ウィンドウの準備 */
	win = api_openwin(winbuf, 256, 112, -1, "mmlplay");
	api_putstrwin(win, 128, 32, 0, i, p);
	api_boxfilwin(win, 8, 60, 247,  76, 7);
	api_boxfilwin(win, 6, 86, 249, 105, 7);

	/* ファイル読み込み */
	i = api_fopen(p);
	if (i == 0) {
		goto file_error;
	}
	j = api_fsize(i, 0);
	if (j >= 100 * 1024) {
		j = 100 * 1024 - 1;
	}
	api_fread(txtbuf, j, i);
	api_fclose(i);
	txtbuf[j] = 0;
	r = txtbuf;
	i = 0; /* 通常モード */
	for (p = txtbuf; *p != 0; p++) {	/* 処理を簡単にするためにコメントや空白を消す */
		if (i == 0 && *p > ' ') {	/* スペースや改行コードなどではない */
			if (*p == '/') {
				if (p[1] == '*') {
					i = 1;
				} else if (p[1] == '/') {
					i = 2;
				} else {
					*r = *p;
					if ('a' <= *p && *p <= 'z') {
						*r += 'A' - 'a';	/* 小文字は大文字に変換 */
					}
					r++;
				}
			} else if (*p == 0x22) {
				*r = *p;
				r++;
				i = 3;
			} else {
				*r = *p;
				r++;
			}
		} else if (i == 1 && *p == '*' && p[1] == '/') {	/* ブロックコメント */
			p++;
			i = 0;
		} else if (i == 2 && *p == 0x0a) {	/* 行コメント */
			i = 0;
		} else if (i == 3) {	/* 文字列 */
			*r = *p;
			r++;
			if (*p == 0x22) {
				i = 0;
			} else if (*p == '%') {
				p++;
				*r = *p;
				r++;
			}
		}
	}
	*r = 0;

	/* タイマの準備 */
	timer = api_alloctimer();
	api_inittimer(timer, 128);

	/* メイン */
	p = txtbuf;
	for (;;) {
		if (('A' <= *p && *p <= 'G') || *p == 'R') {	/* 音符・休符 */
			/* 周波数計算 */
			if (*p == 'R') {
				i = 0;
				s[0] = 0;
			} else {
				i = o * 12 + notetable[*p - 'A'] + 12;
				s[0] = 'O';
				s[1] = '0' + o;
				s[2] = *p;
				s[3] = ' ';
				s[4] = 0;
			}
			p++;
			if (*p == '+' || *p == '-' || *p == '#') {
				s[3] = *p;
				if (*p == '-') {
					i--;
				} else {
					i++;
				}
				p++;
			}
			if (i != note_old) {
				api_boxfilwin(win + 1, 32, 36, 63, 51, 8);
				if (s[0] != 0) {
					api_putstrwin(win + 1, 32, 36, 10, 4, s);
				}
				api_refreshwin(win, 32, 36, 64, 52);
				if (28 <= note_old && note_old <= 107) {
					api_boxfilwin(win, (note_old - 28) * 3 + 8, 60, (note_old - 28) * 3 + 10,  76, 7);
				}
				if (28 <= i && i <= 107) {
					api_boxfilwin(win, (i - 28) * 3 + 8, 60, (i - 28) * 3 + 10,  76, 4);
				}
				if (s[0] != 0) {
					api_beep(tonetable[i % 12] >> (17 - i / 12));
				} else {
					api_beep(0);
				}
				note_old = i;
			}
Ejemplo n.º 13
0
void HariMain(void)
{
	char winbuf[256 * 112], txtbuf[100 * 1024];
	char s[32], *p, *r;
	int win, timer, i, j, t = 120, l = 192 / 4, o = 4, q = 7, note_old = 0;

	/*音号与频率(mHz)的对照表*/
	/*例如,04A为440Hz,即440000 */
	/*第16八度的A为1802240Hz,即1802240000 */
	/*以下为第16八度的列表(C~B) */
	static int tonetable[12] = {
		1071618315, 1135340056, 1202850889, 1274376125, 1350154473, 1430438836,
		1515497155, 1605613306, 1701088041, 1802240000, 1909406767, 2022946002
	};
	static int notetable[7] = { +9, +11, +0 /* C */, +2, +4, +5, +7 };

	/*命令行解析*/
	api_cmdline(s, 30);
	for (p = s; *p > ' '; p++) { }	/*一直读到空格为止*/
	for (; *p == ' '; p++) { }	/*跳过空格*/
	i = strlen(p);
	if (i > 12) {
file_error:
		end("file open error.\n");
	}
	if (i == 0) {
		end(0);
	}

	/*准备窗口*/
	win = api_openwin(winbuf, 256, 112, -1, "mmlplay");
	api_putstrwin(win, 128, 32, 0, i, p);
	api_boxfilwin(win, 8, 60, 247,  76, 7);
	api_boxfilwin(win, 6, 86, 249, 105, 7);

	/*载入文件*/
	i = api_fopen(p);
	if (i == 0) {
		goto file_error;
	}
	j = api_fsize(i, 0);
	if (j >= 100 * 1024) {
		j = 100 * 1024 - 1;
	}
	api_fread(txtbuf, j, i);
	api_fclose(i);
	txtbuf[j] = 0;
	r = txtbuf;
	i = 0; /*通常模式*/
	for (p = txtbuf; *p != 0; p++) {	/*为了方便处理,将注释和空白删去*/
		if (i == 0 && *p > ' ') {	/*不是空格或换行符*/
			if (*p == '/') {
				if (p[1] == '*') {
					i = 1;
				} else if (p[1] == '/') {
					i = 2;
				} else {
					*r = *p;
					if ('a' <= *p && *p <= 'z') {
						*r += 'A' - 'a';	/*将小写字母转换为大写字母*/
					}
					r++;
				}
			} else if (*p == 0x22) {
				*r = *p;
				r++;
				i = 3;
			} else {
				*r = *p;
				r++;
			}
		} else if (i == 1 && *p == '*' && p[1] == '/') {	/*段注释*/
			p++;
			i = 0;
		} else if (i == 2 && *p == 0x0a) {	/*行注释*/
			i = 0;
		} else if (i == 3) {	/*字符串*/
			*r = *p;
			r++;
			if (*p == 0x22) {
				i = 0;
			} else if (*p == '%') {
				p++;
				*r = *p;
				r++;
			}
		}
	}
	*r = 0;

	/*定时器准备*/
	timer = api_alloctimer();
	api_inittimer(timer, 128);

	/*主体*/
	p = txtbuf;
	for (;;) {
		if (('A' <= *p && *p <= 'G') || *p == 'R') {	/*音符、休止符*/
			/*计算频率*/
			if (*p == 'R') {
				i = 0;
				s[0] = 0;
			} else {
				i = o * 12 + notetable[*p - 'A'] + 12;
				s[0] = 'O';
				s[1] = '0' + o;
				s[2] = *p;
				s[3] = ' ';
				s[4] = 0;
			}
			p++;
			if (*p == '+' || *p == '-' || *p == '#') {
				s[3] = *p;
				if (*p == '-') {
					i--;
				} else {
					i++;
				}
				p++;
			}
			if (i != note_old) {
				api_boxfilwin(win + 1, 32, 36, 63, 51, 8);
				if (s[0] != 0) {
					api_putstrwin(win + 1, 32, 36, 10, 4, s);
				}
				api_refreshwin(win, 32, 36, 64, 52);
				if (28 <= note_old && note_old <= 107) {
					api_boxfilwin(win, (note_old - 28) * 3 + 8, 60, (note_old - 28) * 3 + 10,  76, 7);
				}
				if (28 <= i && i <= 107) {
					api_boxfilwin(win, (i - 28) * 3 + 8, 60, (i - 28) * 3 + 10,  76, 4);
				}
				if (s[0] != 0) {
					api_beep(tonetable[i % 12] >> (17 - i / 12));
				} else {
					api_beep(0);
				}
				note_old = i;
			}
Ejemplo n.º 14
0
void putstr(int win, char *winbuf, int x, int y, int col, unsigned char *s)
{
	int c, x0, i, col2;
	char *p, t[2];
	struct SYS_INFO sysinfo;
	int bpp;
	char *q;
	unsigned short *sq;
	unsigned int   *iq;
	tomo_sysinfo(&sysinfo);
	bpp = sysinfo.vmode;
	col2 = osak_getcolor(1, col);
	x = x * 8 + 8;
	y = y * 16 + 29;
	x0 = x;
	i = strlen(s);	/* sの文字数を数える */
	api_boxfilwin(win + 1, x, y, x + i * 8 - 1, y + 15, 0);
	q = winbuf + y * 336;
	sq = (unsigned short *) winbuf + y * 336;
	iq = (unsigned int   *) winbuf + y * 336;
	t[1] = 0;
	for (;;) {
		c = *s;
		if (c == 0) {
			break;
		}
		if (c != ' ') {
			if ('a' <= c && c <= 'h') {
				p = charset + 16 * (c - 'a');
				if (bpp == 8) {
					q += x;
					for (i = 0; i < 16; i++) {
						if ((p[i] & 0x80) != 0) { q[0] = col; }
						if ((p[i] & 0x40) != 0) { q[1] = col; }
						if ((p[i] & 0x20) != 0) { q[2] = col; }
						if ((p[i] & 0x10) != 0) { q[3] = col; }
						if ((p[i] & 0x08) != 0) { q[4] = col; }
						if ((p[i] & 0x04) != 0) { q[5] = col; }
						if ((p[i] & 0x02) != 0) { q[6] = col; }
						if ((p[i] & 0x01) != 0) { q[7] = col; }
						q += 336;
					}
					q -= 336 * 16 + x;
				} else if (bpp == 16) {
					col = osak_getcolor(16, col2);
					sq += x;
					for (i = 0; i < 16; i++) {
						if ((p[i] & 0x80) != 0) { sq[0] = col; }
						if ((p[i] & 0x40) != 0) { sq[1] = col; }
						if ((p[i] & 0x20) != 0) { sq[2] = col; }
						if ((p[i] & 0x10) != 0) { sq[3] = col; }
						if ((p[i] & 0x08) != 0) { sq[4] = col; }
						if ((p[i] & 0x04) != 0) { sq[5] = col; }
						if ((p[i] & 0x02) != 0) { sq[6] = col; }
						if ((p[i] & 0x01) != 0) { sq[7] = col; }
						sq += 336;
					}
					sq -= 336 * 16 + x;
				} else if (bpp == 24) {
					iq += x;
					for (i = 0; i < 16; i++) {
						if ((p[i] & 0x80) != 0) { iq[0] = col2; }
						if ((p[i] & 0x40) != 0) { iq[1] = col2; }
						if ((p[i] & 0x20) != 0) { iq[2] = col2; }
						if ((p[i] & 0x10) != 0) { iq[3] = col2; }
						if ((p[i] & 0x08) != 0) { iq[4] = col2; }
						if ((p[i] & 0x04) != 0) { iq[5] = col2; }
						if ((p[i] & 0x02) != 0) { iq[6] = col2; }
						if ((p[i] & 0x01) != 0) { iq[7] = col2; }
						iq += 336;
					}
					iq -= 336 * 16 + x;
				}
			} else {
				t[0] = *s;
				api_putstrwin(win + 1, x, y, col, 1, t);
			}
		}
		s++;
		x += 8;
	}
	api_refreshwin(win, x0, y, x, y + 16);
	return;
}