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, 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(); }
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 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; }
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) { 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 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) { 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 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 wait(int time) { api_settimer(timer, time); while (api_getkey(1) != 128); return; }