1.1 --- a/src/main.c Wed Mar 19 10:08:25 2014 +0100 1.2 +++ b/src/main.c Wed Mar 19 15:36:54 2014 +0100 1.3 @@ -28,9 +28,11 @@ 1.4 */ 1.5 1.6 #include "terminal-chess.h" 1.7 +#include "game.h" 1.8 +#include "input.h" 1.9 #include <string.h> 1.10 #include <time.h> 1.11 -#include <ncurses.h> 1.12 +#include <getopt.h> 1.13 1.14 int get_settings(int argc, char **argv, Settings *settings) { 1.15 char *valid; 1.16 @@ -44,7 +46,7 @@ 1.17 settings->gameinfo.servercolor = BLACK; 1.18 break; 1.19 case 'r': 1.20 - settings->gameinfo.servercolor = (rand()>>5) & 1 ? WHITE : BLACK; 1.21 + settings->gameinfo.servercolor = rand() & 1 ? WHITE : BLACK; 1.22 break; 1.23 case 't': 1.24 case 'a': 1.25 @@ -125,11 +127,7 @@ 1.26 refresh(); 1.27 } 1.28 1.29 -static WINDOW* window; 1.30 - 1.31 void leavescr() { 1.32 - mvprintw(getmaxy(window)-1, 0, "Leaving terminal-chess. Press any key..."); 1.33 - getch(); 1.34 endwin(); 1.35 } 1.36 1.37 @@ -162,9 +160,17 @@ 1.38 ); 1.39 return EXIT_SUCCESS; 1.40 } 1.41 - 1.42 - window = initscr(); 1.43 + tchess_window = initscr(); 1.44 cbreak(); 1.45 + if (has_colors()) { 1.46 + start_color(); 1.47 + init_colorpairs(); 1.48 + bkgd(COLOR_PAIR(COL_YB)); 1.49 + } else { 1.50 + fprintf(stderr, "Non-colored terminals are not supported yet."); 1.51 + endwin(); 1.52 + return EXIT_FAILURE; 1.53 + } 1.54 atexit(leavescr); 1.55 1.56 return is_server(&settings) ? server_run(&settings) : client_run(&settings);