void wait(int i, int timer, char *keyflag) { int j; if (i > 0) { /* wait for some time */ api_settimer(timer, i); i = 128; } else { i = 0x0a; /* Enter */ } for (;;) { j = api_getkey(1); if (i == j) { break; } if (j == '4') { keyflag[0 /* left */] = 1; } if (j == '6') { keyflag[1 /* right */] = 1; } if (j == ' ') { keyflag[2 /* space */] = 1; } } return; }
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; }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
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(); }
void HariMain(void) { int i, timer; timer = api_alloctimer(); api_inittimer(timer, 128); for (i = 20000000; i >= 20000; i -= i / 100) { api_beep(i); api_settimer(timer, 1); if (api_getkey(1) != 128) { break; } } api_beep(0); api_end(); }
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(); }
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(); }
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(); }
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; }
void HariMain(void) { int i, timer; timer = api_alloctimer(); api_inittimer(timer, 128); for (i = 20000000; i >= 20000; i -= i / 100) { /* 20KHz~20Hz ,即人类可以听到的声音范围 */ /* i以1%的速度递减 */ api_beep(i); api_settimer(timer, 1); /* 0.01秒 */ if (api_getkey(1) != 128) { break; } } api_beep(0); api_end(); }
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(); }
void HariMain(void) { int i, timer; timer = api_alloctimer(); api_inittimer(timer, 128); for (i = 20000000; i >= 20000; i -= i / 100) { /* 20KHz〜20Hz : 人間に聞こえる音の範囲 */ /* iは1%ずつ減らされていく */ api_beep(i); api_settimer(timer, 1); /* 0.01秒 */ if (api_getkey(1) != 128) { break; } } api_beep(0); api_end(); }
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(); }
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(); }
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(); }
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(); }
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(); }
void wait(int i, int timer, char *keyflag, char *last_direction, struct snakeNode *snakeHead) { int j; if (i > 0) { api_settimer(timer, i); i = 128; } else { i = 0x0a; /* Enter */ } for (;;) { j = api_getkey(1); if (i == j) { break; } if (j == '4') { keyflag[0 /* left */] = 1; *last_direction = '4'; changeDirection(snakeHead, 4); } if (j == '6') { keyflag[1 /* right */] = 1; *last_direction = '6'; changeDirection(snakeHead, 6); } if (j == '8') { keyflag[2 /* up */] = 1; *last_direction = '8'; changeDirection(snakeHead, 8); } if (j == '2') { keyflag[3 /* down */] = 1; *last_direction = '2'; changeDirection(snakeHead, 2); } } return; }
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(); }
void HariMain() { char buf[WND_X * WND_Y * osak_getbuflen()]; char cmdline[30], *p = 0; struct CSV_INFO csvinfo; int sig, cx, cy, basex, basey, i, mode; int *p_com1, *p_com2; char c; /* CSVデータの初期化 */ p_com2 = &csvinfo.comma[MAX_COMMA_Y - 1][MAX_COMMA_X - 1]; for (p_com1 = &csvinfo.comma[0][0]; p_com1 <= p_com2; p_com1++) *p_com1 = -1; csvinfo.max_x = csvinfo.max_y = csvinfo.filesize = 0; /* コマンドライン取得 */ api_cmdline(cmdline, 30); for (p = cmdline; *p > ' '; p++); /* スペースが来るまで読み飛ばす */ for (; *p == ' '; p++); /* スペースを読み飛ばす */ i = api_fopen(p); if (i == 0) { api_putstr0("File not found.\n"); api_end(); } csvinfo.filesize = api_fsize(i, 0); if (csvinfo.filesize >= MAX_FILESIZ - 1) { /* 読めない */ api_putstr0("Filesize is too big.\n"); api_end(); } api_fread(csvinfo.buf, csvinfo.filesize, i); api_fclose(i); p = csvinfo.buf; i = cx = cy = mode = 0; if (*p != ',') csvinfo.comma[0][0] = 0; while (i < csvinfo.filesize) { c = csvinfo.buf[i++]; if (c == 0x22) { if (i == 1 || mode == 0) { mode++; continue; } if (mode && (csvinfo.buf[i] == ',' || csvinfo.buf[i] == 0x0a || csvinfo.buf[i] == 0x0d)) mode--; } if (mode == 0 && c == ',') { cx++; // 「,,」「,\n」のように、セルに何もない状態ではない if (csvinfo.buf[i] != ',' && csvinfo.buf[i] != 0x0a && csvinfo.buf[i] != 0x0d) csvinfo.comma[cy][cx] = i; // コンマの次の文字の場所が記録される } /* 改行コード */ if ((c == 0x0d /* CR */ && csvinfo.buf[i] == 0x0a /* LF */) || (c == 0x0a /* LF */ && csvinfo.buf[i] == 0x0d /* CR */)) { if (i < csvinfo.filesize) { if (csvinfo.max_x < cx) csvinfo.max_x = cx; cy++; cx = 0; i++; if (i >= csvinfo.filesize) break; csvinfo.max_y++; if (csvinfo.buf[i] != ',' && csvinfo.buf[i] != 0x0a && csvinfo.buf[i] != 0x0d) csvinfo.comma[cy][cx] = i; // コンマの次の文字の場所が記録される if (csvinfo.buf[i] == 0x22) mode++; } } } csvinfo.max_x++; csvinfo.max_y++; win = api_openwin(buf, WND_X, WND_Y, -1, "CSV-Viewer"); api_boxfilwin(win, 6, 26+16, GBOX_X+6, GBOX_Y+26+16, 7); /* ワークシート作成 */ for (i = 0; i <= GBOX_X; i += CELLSIZ_X) api_linewin(win, i + 6, 42, i + 6, GBOX_Y + 42, 15); for (i = 0; i <= GBOX_Y; i += CELLSIZ_Y) api_linewin(win, 6, i + 42, GBOX_X + 6, i + 42, 15); /* CSVデータ表示 */ cx = cy = basex = basey = 1; PutCell(1, 1, &csvinfo); my_drawboxId(4, cx, cy); Putcellinfo(basex+cx-2, basey+cy-2, &csvinfo); /* メインループ */ for (;;) { sig = api_getkey(1); if (sig == 0xb4) { /* left */ if (1 < cx) { my_drawboxId(15, cx, cy); cx--; sig = 0; } else if (1 < basex) { basex--; PutCell(basex, basey, &csvinfo); sig = 0; } } if (sig == 0xb6) { /* rigth */ if (cx < maxell_x-1) { my_drawboxId(15, cx, cy); cx++; sig = 0; } else if (basex+cx < MAX_COMMA_X) { basex++; PutCell(basex, basey, &csvinfo); sig = 0; } } if (sig == 0xb8) { /* up */ if (cy > 1) { my_drawboxId(15, cx, cy); cy--; sig = 0; } else if (1 < basey) { basey--; PutCell(basex, basey, &csvinfo); sig = 0; } } if (sig == 0xb2) { /* down */ if (cy < maxell_y-1) { my_drawboxId(15, cx, cy); cy++; sig = 0; } else if (basey+cy < MAX_COMMA_Y) { basey++; PutCell(basex, basey, &csvinfo); sig = 0; } } if (sig == 0xb9) { /* Page Up */ if (basey > 1) { basey -= maxell_y - 1; if (basey < 1) { my_drawboxId(15, cx, cy); basey = cy = 1; } PutCell(basex, basey, &csvinfo); sig = 0; } } if (sig == 0xb3) { /* Page Down */ if (basey <= MAX_COMMA_Y - maxell_y) { basey += maxell_y - 1; if (basey > MAX_COMMA_Y - maxell_y) { my_drawboxId(15, cx, cy); basey = MAX_COMMA_Y - maxell_y + 1; cy = maxell_y - 1; } PutCell(basex, basey, &csvinfo); sig = 0; } } if (sig == 0) { my_drawboxId(4, cx, cy); Putcellinfo(basex+cx-2, basey+cy-2, &csvinfo); } } }
void wait(int time) { api_settimer(timer, time); while (api_getkey(1) != 128); return; }