diff --git a/configure.ac b/configure.ac index 38a404b..e1b364e 100644 --- a/configure.ac +++ b/configure.ac @@ -13,18 +13,26 @@ AM_CONFIG_HEADER(config.h) AM_PROG_CC_C_O AC_PROG_CPP +AC_ARG_ENABLE(slang, + [ --enable-slang slang graphics support (default enabled)]) AC_ARG_ENABLE(ncurses, - [ --enable-ncurses ncurses interface support (default is slang)]) + [ --enable-ncurses ncurses graphics support (default disabled)]) if test "${enable_ncurses}" = "yes" then AC_CHECK_HEADER(ncurses.h,:,AC_MSG_ERROR([cannot find ncurses headers])) AC_CHECK_LIB(ncurses,initscr,:,AC_MSG_ERROR([cannot find ncurses library])) else - AC_CHECK_HEADER(slang.h,:,AC_MSG_ERROR([cannot find slang headers])) - AC_CHECK_LIB(slang,SLkp_init,:,AC_MSG_ERROR([cannot find slang library])) + if test "${enable_slang}" != "no" + then + AC_CHECK_HEADER(slang.h,:,AC_MSG_ERROR([cannot find slang headers])) + AC_CHECK_LIB(slang,SLkp_init,:,AC_MSG_ERROR([cannot find slang library])) + else + : + fi fi +AM_CONDITIONAL(USE_SLANG, test "${enable_slang}" != "no") AM_CONDITIONAL(USE_NCURSES, test "${enable_ncurses}" = "yes") AC_OUTPUT([ diff --git a/src/Makefile.am b/src/Makefile.am index d056d0d..1913174 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,12 +7,13 @@ AM_CFLAGS = -g -O2 -fno-strength-reduce -fomit-frame-pointer # Code qui fait des warnings == code de porc == deux baffes dans ta gueule AM_CFLAGS += -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wstrict-prototypes -Wshadow -Waggregate-return -Wmissing-prototypes -Wnested-externs +if USE_SLANG +CPPFLAGS_slang = -DUSE_SLANG +LDFLAGS_slang = -lslang +endif if USE_NCURSES -CPPFLAGS_gfx = -DUSE_NCURSES -LDFLAGS_gfx = -lncurses -else -CPPFLAGS_gfx = -DUSE_SLANG -LDFLAGS_gfx = -lslang +CPPFLAGS_ncurses = -DUSE_NCURSES +LDFLAGS_ncurses = -lncurses endif bin_PROGRAMS = ttyvaders @@ -33,6 +34,6 @@ ttyvaders_SOURCES = \ tunnel.c \ $(NULL) -ttyvaders_CPPFLAGS = $(CPPFLAGS_gfx) -ttyvaders_LDADD = $(LDFLAGS_gfx) +ttyvaders_CPPFLAGS = $(CPPFLAGS_slang) $(CPPFLAGS_ncurses) +ttyvaders_LDADD = $(LDFLAGS_slang) $(LDFLAGS_ncurses) diff --git a/src/ceo.c b/src/ceo.c index e451d66..cf882ce 100644 --- a/src/ceo.c +++ b/src/ceo.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: ceo.c,v 1.4 2002/12/22 22:17:41 sam Exp $ + * $Id: ceo.c,v 1.5 2002/12/23 10:06:27 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "config.h" +#include #include #include "common.h" diff --git a/src/common.h b/src/common.h index cd0b5ed..70b2843 100644 --- a/src/common.h +++ b/src/common.h @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: common.h,v 1.10 2002/12/23 09:28:37 sam Exp $ + * $Id: common.h,v 1.11 2002/12/23 10:06:27 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,12 +32,17 @@ # define gfx_goto(x,y) SLsmg_gotorc(y,x) # define gfx_putchar(x) SLsmg_write_char(x) # define gfx_putstr(x) SLsmg_write_string(x) -#else +#elif USE_NCURSES # include # define gfx_color(x) attrset(COLOR_PAIR(x)) # define gfx_goto(x,y) move(y,x) # define gfx_putchar(x) addch(x) # define gfx_putstr(x) addstr(x) +#else +# define gfx_color(x) do{}while(0) +# define gfx_goto(x,y) do{}while(0) +# define gfx_putchar(x) do{}while(0) +# define gfx_putstr(x) do{}while(0) #endif #define gfx_putcharTO(x,y,c) do{ gfx_goto(x,y); gfx_putchar(c); }while(0) diff --git a/src/graphics.c b/src/graphics.c index 331519d..ee0f8ff 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: graphics.c,v 1.4 2002/12/22 18:44:12 sam Exp $ + * $Id: graphics.c,v 1.5 2002/12/23 10:06:27 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,7 +49,7 @@ int init_graphics( void ) SLsmg_cls(); SLsmg_refresh(); -#else +#elif USE_NCURSES /* Initialize ncurses library */ initscr(); keypad(stdscr, TRUE); @@ -57,6 +57,8 @@ int init_graphics( void ) cbreak(); noecho(); nodelay(stdscr, TRUE); +#else + /* Dummy driver */ #endif return 0; @@ -80,7 +82,7 @@ void init_game( game *g ) g->w = SLtt_Screen_Cols; g->h = SLtt_Screen_Rows; -#else +#elif USE_NCURSES start_color(); init_pair( BLACK, COLOR_BLACK, COLOR_BLACK ); @@ -96,6 +98,10 @@ void init_game( game *g ) g->w = COLS; g->h = LINES; +#else + /* Use dummy driver */ + g->w = 80; + g->h = 25; #endif } @@ -106,13 +112,15 @@ char get_key( void ) { return SLang_getkey(); } -#else +#elif USE_NCURSES char key; if( ( key = getch() ) != ERR ) { return key; } +#else + /* Use dummy driver */ #endif return 0; @@ -122,8 +130,10 @@ void clear_graphics( void ) { #ifdef USE_SLANG SLsmg_cls(); -#else +#elif USE_NCURSES clear(); +#else + /* Use dummy driver */ #endif } @@ -132,8 +142,10 @@ void refresh_graphics( void ) gfx_goto( 0, 0 ); #ifdef USE_SLANG SLsmg_refresh(); -#else +#elif USE_NCURSES refresh(); +#else + /* Use dummy driver */ #endif } @@ -142,9 +154,10 @@ void end_graphics( void ) #ifdef USE_SLANG SLang_reset_tty(); SLsmg_reset_smg(); -#else +#elif USE_NCURSES endwin(); +#else + /* Use dummy driver */ #endif } - diff --git a/src/main.c b/src/main.c index afc1b4c..e7954ca 100644 --- a/src/main.c +++ b/src/main.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: main.c,v 1.9 2002/12/23 09:28:37 sam Exp $ + * $Id: main.c,v 1.10 2002/12/23 10:06:27 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -69,6 +69,7 @@ static void start_game (game *g) g->p = create_player( g ); g->al = malloc(sizeof(aliens)); + init_bonus( g, g->bo ); init_weapons( g, g->wp ); init_explosions( g, g->ex ); init_aliens( g, g->al ); @@ -128,7 +129,7 @@ static void start_game (game *g) add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, 0, WEAPON_BEAM ); } break; - case 'd': + case 'f': if( g->p->nuke == 0 ) { g->p->nuke = 40; @@ -222,10 +223,7 @@ static void start_game (game *g) } free_starfield( g, g->sf ); - -#if 0 - free_player( p ); free_tunnel( g->t ); -#endif +// free_player( g->p ); } diff --git a/src/tunnel.c b/src/tunnel.c index 368b49f..57907be 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -3,7 +3,7 @@ * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * - * $Id: tunnel.c,v 1.5 2002/12/23 09:28:37 sam Exp $ + * $Id: tunnel.c,v 1.6 2002/12/23 10:06:27 sam Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,8 +39,6 @@ tunnel * create_tunnel( game *g, int w, int h ) if( t->w >= g->w ) { - t->left[0] = -10; - t->right[0] = g->w + 10; for( i = 0; i < g->h; i++ ) { t->left[i] = -10; @@ -81,7 +79,7 @@ void update_tunnel( game *g, tunnel *t ) int i,j,k; /* Slide tunnel one block vertically */ - for( i = t->h; i--; ) + for( i = t->h - 1; i--; ) { t->left[i+1] = t->left[i]; t->right[i+1] = t->right[i];