Index: bdisp.c
===================================================================
RCS file: /cvs/src/games/gomoku/bdisp.c,v
retrieving revision 1.9
diff -u -p -r1.9 bdisp.c
--- bdisp.c     14 Dec 2006 10:15:09 -0000      1.9
+++ bdisp.c     4 Jun 2009 00:17:36 -0000
@@ -54,12 +54,12 @@ static      char    pcolor[] = "*O.?";
  * Initialize screen display.
  */
 void
-cursinit()
+cursinit(void)
 {
        initscr();
        if ((LINES < SCRNH) || (COLS < SCRNW)) {
                endwin();
-               errx(1,"Screen too small (need %dx%d)",SCRNW,SCRNH);
+               errx(1, "Screen too small (need %dx%d)", SCRNW,SCRNH);
        }
 #ifdef KEY_MIN
        keypad(stdscr, TRUE);
@@ -77,7 +77,7 @@ cursinit()
  * Restore screen display.
  */
 void
-cursfini()
+cursfini(void)
 {
        move(BSZ4, 0);
        clrtoeol();
@@ -90,7 +90,7 @@ cursfini()
  * Initialize board display.
  */
 void
-bdisp_init()
+bdisp_init(void)
 {
        int i, j;

@@ -99,6 +99,7 @@ bdisp_init()
                move(0, 2 * i + 1);
                addch(letters[i]);
        }
+
        /* left and right edges */
        for (j = BSZ1; --j > 0; ) {
                move(20 - j, 0);
@@ -106,6 +107,7 @@ bdisp_init()
                move(20 - j, 2 * BSZ1 + 1);
                printw("%d ", j);
        }
+
        /* bottom border */
        for (i = 1; i < BSZ1; i++) {
                move(20, 2 * i + 1);
@@ -122,8 +124,7 @@ bdisp_init()
  * Update who is playing whom.
  */
 void
-bdwho(update)
-       int update;
+bdwho(int update)
 {
        int i, j;
        extern char *plyr[];
@@ -133,7 +134,7 @@ bdwho(update)
        i = strlen(plyr[BLACK]);
        j = strlen(plyr[WHITE]);
        if (i + j <= 20) {
-               move(21, 10 - (i + j)/2);
+               move(21, 10 - (i + j) / 2);
                printw("BLACK/%s (*) vs. WHITE/%s (O)",
                    plyr[BLACK], plyr[WHITE]);
        } else {
@@ -155,7 +156,7 @@ bdwho(update)
  * Update the board display after a move.
  */
 void
-bdisp()
+bdisp(void)
 {
        int i, j, c;
        struct spotstr *sp;
@@ -183,8 +184,7 @@ bdisp()
 /*
  * Dump board display to a file.
  */
-void bdump(fp)
-       FILE *fp;
+void bdump(FILE *fp)
 {
        int i, j, c;
        struct spotstr *sp;
@@ -222,10 +222,8 @@ void bdump(fp)
  * Display a transcript entry
  */
 void
-dislog(str)
-       char *str;
+dislog(char *str)
 {
-
        if (++lastline >= SCRNH - 1) {
                /* move 'em up */
                lastline = 1;
@@ -243,8 +241,7 @@ dislog(str)
  * Display a question.
  */
 void
-ask(str)
-       char *str;
+ask(char *str)
 {
        int len = strlen(str);

@@ -256,9 +253,7 @@ ask(str)
 }

 int
-getline(buf, size)
-       char *buf;
-       int size;
+getline(char *buf, int size)
 {
        char *cp, *end;
        int c = EOF;
@@ -299,11 +294,11 @@ getline(buf, size)
                }
        }
        *cp = '\0';
-       return(c != EOF);
+       return (c != EOF);
 }

-
-/* Decent (n)curses interface for the game, based on Eric S. Raymond's
+/*
+ * Decent (n)curses interface for the game, based on Eric S. Raymond's
  * modifications to the battleship (bs) user interface.
  */
 int getcoord(void)
@@ -312,89 +307,115 @@ int getcoord(void)
        static int cury = BSZ / 2;
        int ny, nx, c;

-       BGOTO(cury,curx);
+       BGOTO(cury, curx);
        refresh();
-       nx = curx; ny = cury;
+       nx = curx;
+       ny = cury;
        for (;;) {
-               mvprintw(BSZ3, (BSZ -6)/2, "(%c %d)",
-                               'A'+ ((curx > 7) ? (curx+1) : curx), cury + 1);
+               mvprintw(BSZ3, (BSZ - 6) / 2, "(%c %d)",
+                   'A' + ((curx > 7) ? (curx + 1) : curx), cury + 1);
                BGOTO(cury, curx);

                switch(c = getch()) {
-               case 'k': case '8':
+               case 'k':
+               case '8':
 #ifdef KEY_MIN
                case KEY_UP:
 #endif /* KEY_MIN */
-                       ny = cury + 1;       nx = curx;
+                       ny = cury + 1;
+                       nx = curx;
                        break;
-               case 'j': case '2':
+               case 'j':
+               case '2':
 #ifdef KEY_MIN
                case KEY_DOWN:
 #endif /* KEY_MIN */
-                       ny = BSZ + cury - 1; nx = curx;
+                       ny = BSZ + cury - 1;
+                       nx = curx;
                        break;
-               case 'h': case '4':
+               case 'h':
+               case '4':
 #ifdef KEY_MIN
                case KEY_LEFT:
 #endif /* KEY_MIN */
-                       ny = cury;          nx = BSZ + curx - 1;
+                       ny = cury;
+                       nx = BSZ + curx - 1;
                        break;
-               case 'l': case '6':
+               case 'l':
+               case '6':
 #ifdef KEY_MIN
                case KEY_RIGHT:
 #endif /* KEY_MIN */
-                       ny = cury;          nx = curx + 1;
+                       ny = cury;
+                       nx = curx + 1;
                        break;
-               case 'y': case '7':
+               case 'y':
+               case '7':
 #ifdef KEY_MIN
                case KEY_A1:
 #endif /* KEY_MIN */
-                       ny = cury + 1;        nx = BSZ + curx - 1;
+                       ny = cury + 1;
+                       nx = BSZ + curx - 1;
                        break;
-               case 'b': case '1':
+               case 'b':
+               case '1':
 #ifdef KEY_MIN
                case KEY_C1:
 #endif /* KEY_MIN */
-                       ny = BSZ + cury - 1; nx = BSZ + curx - 1;
+                       ny = BSZ + cury - 1;
+                       nx = BSZ + curx - 1;
                        break;
-               case 'u': case '9':
+               case 'u':
+               case '9':
 #ifdef KEY_MIN
                case KEY_A3:
 #endif /* KEY_MIN */
-                       ny = cury + 1;        nx = curx + 1;
+                       ny = cury + 1;
+                       nx = curx + 1;
                        break;
-               case 'n': case '3':
+               case 'n':
+               case '3':
 #ifdef KEY_MIN
                case KEY_C3:
 #endif /* KEY_MIN */
-                       ny = BSZ + cury - 1; nx = curx + 1;
+                       ny = BSZ + cury - 1;
+                       nx = curx + 1;
                        break;
                case 'K':
-                       ny = cury + 5;       nx = curx;
+                       ny = cury + 5;
+                       nx = curx;
                        break;
                case 'J':
-                       ny = BSZ + cury - 5; nx = curx;
+                       ny = BSZ + cury - 5;
+                       nx = curx;
                        break;
                case 'H':
-                       ny = cury;          nx = BSZ + curx - 5;
+                       ny = cury;
+                       nx = BSZ + curx - 5;
                        break;
                case 'L':
-                       ny = cury;          nx = curx + 5;
+                       ny = cury;
+                       nx = curx + 5;
                        break;
                case 'Y':
-                       ny = cury + 5;        nx = BSZ + curx - 5;
+                       ny = cury + 5;
+                       nx = BSZ + curx - 5;
                        break;
                case 'B':
-                       ny = BSZ + cury - 5; nx = BSZ + curx - 5;
+                       ny = BSZ + cury - 5;
+                       nx = BSZ + curx - 5;
                        break;
                case 'U':
-                       ny = cury + 5;        nx = curx + 5;
+                       ny = cury + 5;
+                       nx = curx + 5;
                        break;
                case 'N':
-                       ny = BSZ + cury - 5; nx = curx + 5;
+                       ny = BSZ + cury - 5;
+                       nx = curx + 5;
                        break;
                case FF:
-                       nx = curx; ny = cury;
+                       nx = curx;
+                       ny = cury;
                        (void)clearok(stdscr, TRUE);
                        (void)refresh();
                        break;
@@ -405,27 +426,25 @@ int getcoord(void)

                        getmouse(&myevent);
                        if (myevent.y >= 1 && myevent.y <= BSZ1
-                               && myevent.x >= 3 && myevent.x <= (2 * BSZ + 1))
-                       {
+                           && myevent.x >= 3 && myevent.x <= (2 * BSZ + 1)) {
                                curx = (myevent.x - 3) / 2;
                                cury = BSZ - myevent.y;
-                               return(PT(curx,cury));
-                       }
-                       else
+                               return (PT(curx, cury));
+                       } else
                                beep();
                }
-               break;
+                       break;
 #endif /* NCURSES_MOUSE_VERSION */
                case 'Q':
-                       return(RESIGN);
+                       return (RESIGN);
                        break;
                case 'S':
-                       return(SAVE);
+                       return (SAVE);
                        break;
                case ' ':
                case '\015':  /* return */
-                       (void) mvaddstr(BSZ3, (BSZ -6)/2, "      ");
-                       return(PT(curx+1,cury+1));
+                       (void)mvaddstr(BSZ3, (BSZ - 6) / 2, "      ");
+                       return (PT(curx + 1, cury + 1));
                        break;
        }

Reply via email to