/* * quit.c: runs Quit train. * Copyright (C) 2002 FUKUCHI, Kentarou */ #include #include #include #include "quit.h" static int my_mvaddstr(int, int, unsigned char *); static int add_QUIT(int); static void add_punpun(int, int); static void add_baka(int, int); static void add_golua(int, int); static int phase = 0; int main(int argc, char *argv[]) { int x; initscr(); /* signal(SIGINT, SIG_IGN); */ noecho(); leaveok(stdscr, TRUE); scrollok(stdscr, FALSE); for (x = COLS - 2; ; --x) { if (add_QUIT(x) == ERR) break; phase++; refresh(); usleep(30000); } mvcur(0, COLS - 1, LINES - 1, 0); endwin(); return 0; } int add_QUIT(int x) { #ifdef JAPANESE static char *quit[QUITHEIGHT] = {QUITSTR01, QUITSTR02, QUITSTR03, QUITSTR04, QUITSTR05, QUITSTR06, QUITSTR07, QUITSTR08, QUITSTR09, QUITSTR10, QUITSTR11, QUITSTR12}; #else static char *quit[QUITHEIGHT] = {QUITSTR01, QUITSTR02, QUITSTR03, QUITSTR04, QUITSTR05, QUITSTR06, QUITSTR07, QUITSTR08, QUITSTR09, QUITSTR10, QUITSTR11, QUITSTR12, QUITSTR13, QUITSTR14, QUITSTR15, QUITSTR16, QUITSTR17}; #endif int y, i; if (x < -QUITLENGTH) return ERR; y = (LINES - QUITHEIGHT)/2; for (i = 0; i < QUITHEIGHT; ++i) { my_mvaddstr(y + i, x, quit[i]); } #ifdef JAPANESE add_punpun(y+8, x); add_baka(y+8, x+26); add_golua(y+8, x+37); #else add_punpun(y+6, x); add_baka(y+6, x+38); add_golua(y+6, x+56); #endif return OK; } #ifdef JAPANESE void add_punpun(int y, int x) { my_mvaddstr(y, x + ((unsigned int)x & 4), "プン"); } void add_baka(int y, int x) { if ((phase & 15) < 8) my_mvaddstr(y, x, "バカ"); } void add_golua(int y, int x) { if ((phase & 15) >= 8) my_mvaddstr(y, x, "ゴルァ"); } int my_mvaddstr(int y, int x, unsigned char *str) { int col; int flag; col = COLS; flag = 0; for ( ; x < 0; ++x, ++str) { if (*str == '\0') return ERR; if (*str > 0x7f) flag ^= 1; } if(flag && x == 0) { str++; x++; mvaddch(y, 0, ' '); } for ( ; *str != '\0'; ++str, ++x) { if (*str > 0x7f) { if(x >= COLS-1) { mvaddch(y, x, ' '); return ERR; } if(mvaddnstr(y, x, str, 2) == ERR) return ERR; str++; x++; } else { if(mvaddch(y, x, *str) == ERR) return ERR; } } return OK; } #else /* JAPANESE */ void add_punpun(int y, int x) { int i; static char *pun[PUNHEIGHT] = {PUNSTR01, PUNSTR02, PUNSTR03}; for(i = 0; i < PUNHEIGHT; i++) { my_mvaddstr(y + i, x + (((unsigned int)x & 4)<<1), pun[i]); } } void add_baka(int y, int x) { int i; static char *baka[BAKAHEIGHT] = {BAKASTR01, BAKASTR02, BAKASTR03}; if ((phase & 15) < 8) for(i = 0; i < BAKAHEIGHT; i++) { my_mvaddstr(y + i, x, baka[i]); } } void add_golua(int y, int x) { int i; static char *golua[GOLUAHEIGHT] = {GOLUASTR01, GOLUASTR02, GOLUASTR03}; if ((phase & 15) >= 8) for(i = 0; i < GOLUAHEIGHT; i++) { my_mvaddstr(y + i, x, golua[i]); } } int my_mvaddstr(int y, int x, unsigned char *str) { int col; col = COLS; for ( ; x < 0; ++x, ++str) if (*str == '\0') return ERR; for ( ; *str != '\0'; ++str, ++x) { if(mvaddch(y, x, *str) == ERR) return ERR; } return OK; } #endif /* JAPANESE */