コード例 #1
0
void Putcellinfo(int x, int y, struct CSV_INFO *csvinfo)
/* セル番地の表示 */
{
	int i;
	char s[TBOX_X + 1];

	for (i = 0; i < TBOX_X; i++) {s[i] = ' ';}
	s[0] = '(';
	s[9] = ')';
	s[TBOX_X] = '\0';

	i = setdec(y + 1, s, 7);	// これは行番号
	s[i--] = 0x41 + (x % 26);	// ここから列番号
	if (x > 25)
		s[i] = 0x40 + (x / 26);
	api_boxfilwin(win, 6, 26, 6 + TBOX_X * 8, 41, 8);
	api_putstrwin(win, 6, 26, 0, TBOX_X, s);	// 表示1

	i = GetCellData(s, csvinfo, csvinfo->comma[y][x], TBOX_X-12);
	if (i >= 0) {
		s[i] = 0;
		api_putstrwin(win, 86, 26, 0, i, s);	// 表示2
	}
	return;
}
コード例 #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();
}
コード例 #3
0
ファイル: mtorz.c プロジェクト: tangfuhao/30System
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();
}
コード例 #4
0
ファイル: minesweeper.c プロジェクト: jjhlzn/haribote
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();
}
コード例 #5
0
ファイル: noodle.c プロジェクト: msyksphinz/sicp_exercise
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();
}
コード例 #6
0
ファイル: clock.c プロジェクト: tyfkda/haribote
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;
}
コード例 #7
0
ファイル: snake.c プロジェクト: haha370104/OSCourse
void scrnRefresher(int win, struct snakeNode *tail, int color, char *c) {
	//api_putstrwin(win, tail->posX, tail->posY, 0, 1, "*");
	while(tail != NULL) {
		api_putstrwin(win, tail->posX, tail->posY, color, 1, c);
		tail = tail->preNode;
	}

}
コード例 #8
0
ファイル: winhelo2.c プロジェクト: LinuxKernelDevelopment/30
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();
}
コード例 #9
0
ファイル: snake.c プロジェクト: haha370104/OSCourse
void foodInit(struct Food *food, int win, int color, char *c) {
	/*
	position should be start at (75, 55) 
	and with(moveScale * n, moveScale * n) distance
	and 
	9 <= x <= 183, 9 + 6 * 29 = 183 => n(0~29)
	25 <= y <= 175, 25 + 6 * 25 = 175 => m(0~25)
	*/
	if (food->isEaten == 0) {
		/*not eaten*/
	} else {
		api_putstrwin(win, food->posX, food->posY, 0, 1, c);
		food->posX = 9 + 6 * range(0, 29);
		food->posY = 25 + 6 * range(0, 25);
		api_putstrwin(win, food->posX, food->posY, color, 1, c);
		food->isEaten = 0;
	}
}
コード例 #10
0
void putstr(int px, int py, int c, int bc, int l, char *s)
{
	if (bc != 7) {
		api_boxfilwin(win, px + 6, py + 42, px + 6 + l * 8, py + 58, bc);
	} else {
		api_boxfilwin(win, px + 6, py + 42, px + 5 + l * 8, py + 57, bc);
	}
	api_putstrwin(win, px + 6, py + 42, c, l, s);
	return;
}
コード例 #11
0
ファイル: winhelo3.c プロジェクト: FuDesign2008/mess
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();
}
コード例 #12
0
ファイル: winhelo2.c プロジェクト: bigpussy/harib_os_src
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();
}
コード例 #13
0
ファイル: walk.c プロジェクト: AlayshChen/30dayMakeOS
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();
}
コード例 #14
0
ファイル: winhelo3.c プロジェクト: barmi/bxos
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();
}
コード例 #15
0
ファイル: winhelo3.c プロジェクト: AlayshChen/30dayMakeOS
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();
}
コード例 #16
0
ファイル: winhello.c プロジェクト: haha370104/OSCourse
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();
}
コード例 #17
0
void HariMain(void)
{
	char buf[416 * 52 * osak_getbuflen()], s[2];
	int win, timer, i, curc = 0, curx = 8;
	win = api_openwin(buf, 416, 50, -1, "1Line");
	timer = api_alloctimer();
	api_inittimer(timer, 128);
	make_textbox(win, 8, 28, 400, 16);
	s[1] = '\0';
	api_settimer(timer, 50);	/* 0.5•b */
	for (;;) {
		i = api_getkey(1);
		if (i == 128) {
			if (curc == 0) {
				/* On */
				curc = 7;
			} else {
				/* Off */
				curc = 0;
			}
			api_boxfilwin(win, curx, 43, 7 + curx, 43, curc);
			api_settimer(timer, 50);	/* 0.5•b */
		}
		if (i == 0x08) {
			/* BackSpace */
			if (8 < curx) {
				api_boxfilwin(win, curx - 8, 28, curx + 7, 43, 7);
				curx -= 8;
				api_boxfilwin(win, curx, 43, 7 + curx, 43, curc);
			}
		}
		if (0x20 <= i && i <= 'z') {
			if (curx < 400) {
				api_boxfilwin(win, curx, 28 + 15, 7 + curx, 28 + 15,  7);
				s[0] = i;
				api_putstrwin(win, curx, 28, 0, 1, s);
				curx += 8;
				api_boxfilwin(win, curx, 28 + 15, 7 + curx, 28 + 15,  curc);
			}
		}
	}
	api_closewin(win);
	api_end();
}
コード例 #18
0
ファイル: invader.c プロジェクト: hupeng2006/flyBits
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;
}
コード例 #19
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;
}
コード例 #20
0
ファイル: snake.c プロジェクト: haha370104/OSCourse
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();
}
コード例 #21
0
ファイル: mmlplay.c プロジェクト: AlayshChen/30dayMakeOS
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;
			}
コード例 #22
0
ファイル: tview.c プロジェクト: barmi/bxos
char *lineview(int win, int w, int y, int xskip, unsigned char *p, int tab, int lang)
{
	int x = - xskip;
	char s[130];
	for (;;) {
		if (*p == 0) {
			break;
		}
		if (*p == 0x0a) {
			p++;
			break;
		}
		if (lang == 0) {	/* ASCII */
			if (*p == 0x09) {
				x = puttab(x, w, xskip, s, tab);
			} else {
				if (0 <= x && x < w) {
					s[x] = *p;
				}
				x++;
			}
			p++;
		}
		if (lang == 1) {	/* SJIS */
			if (*p == 0x09) {
				x = puttab(x, w, xskip, s, tab);
				p++;
			} else if ((0x81 <= *p && *p <= 0x9f) || (0xe0 <= *p && *p <= 0xfc)) {
				/* 전각 문자 */
				if (x == -1) {
					s[0] = ' ';
				}
				if (0 <= x && x < w - 1) {
					s[x]     = *p;
					s[x + 1] = p[1];
				}
				if (x == w - 1) {
					s[x] = ' ';
				} 
				x += 2;
				p += 2;
			} else {
				if (0 <= x && x < w) {
					s[x] = *p;
				}
				x++;
				p++;
			}
		}
		if (lang == 2) {	/* EUC */
			if (*p == 0x09) {
				x = puttab(x, w, xskip, s, tab);
				p++;
			} else if (0xa1 <= *p && *p <= 0xfe) {
				/* 전각 문자 */
				if (x == -1) {
					s[0] = ' ';
				}
				if (0 <= x && x < w - 1) {
					s[x]     = *p;
					s[x + 1] = p[1];
				}
				if (x == w - 1) {
					s[x] = ' ';
				} 
				x += 2;
				p += 2;
			} else {
				if (0 <= x && x < w) {
					s[x] = *p;
				}
				x++;
				p++;
			}
		}
	}
	if (x > w) {
		x = w;
	}
	if (x > 0) {
		s[x] = 0;
		api_putstrwin(win + 1, 8, y, 0, x, s);
	}
	return p;
}
コード例 #23
0
ファイル: mmlplay.c プロジェクト: 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;
			}
コード例 #24
0
ファイル: kuha.c プロジェクト: tangfuhao/30System
void putstr(char *s, int x, int y, int l)
{
	api_boxfilwin(win + 1, x * 8 + 6, y * 16 + 26, (x + l) * 8 + 6, (y + 1) * 16 + 26, 0);
	api_putstrwin(win, x * 8 + 6, y * 16 + 26, 7, l, s);
	return;
}