diff -u beasts-orig/beast.c beasts/beast.c --- beasts-orig/beast.c Mon Jul 27 22:36:59 1998 +++ beasts/beast.c Sat Mar 11 09:48:32 2000 @@ -4,7 +4,7 @@ #include "beasts.h" #include "beast.h" -#include "console.h" /* FIXME: should be draw.h */ +/*#include "console.h"*/ /* FIXME: should be draw.h */ /* Structure of a beast */ typedef struct { @@ -130,8 +130,8 @@ move_beastie(i,turnnum, field, hero); /* } next beast */ - /* (*RefreshField)(); */ - ConsoleRefresh(); + (*field_refresh)(); + /*ConsoleRefresh();*/ } /* beastie_dance */ static void @@ -311,7 +311,8 @@ return; /* Nothing left to do if we didn't move. */ field->map[bpos]=EMPTY; - ConsoleDrawIcon(beast[bnum].x,beast[bnum].y,EMPTY); + /*ConsoleDrawIcon(beast[bnum].x,beast[bnum].y,EMPTY);*/ + (*draw_icon)(beast[bnum].x,beast[bnum].y,EMPTY); beast[bnum].x+=dx; beast[bnum].y+=dy; @@ -319,7 +320,8 @@ beast[bnum].phobic-=1; field->map[endpos]=BEAST0+bnum; - ConsoleDrawIcon(beast[bnum].x,beast[bnum].y,BEAST0+bnum); + /*ConsoleDrawIcon(beast[bnum].x,beast[bnum].y,BEAST0+bnum);*/ + (*draw_icon)(beast[bnum].x,beast[bnum].y,BEAST0+bnum); } static void @@ -342,7 +344,8 @@ case HERO: endlevel("Hero blown to pieces."); default: - ConsoleDrawIcon(xx,yy,EMPTY); + /*ConsoleDrawIcon(xx,yy,EMPTY);*/ + (*draw_icon)(xx,yy,EMPTY); field->map[yoff+xx]=EMPTY; } /* end switch */ } /* next xx */ diff -u beasts-orig/beasts.h beasts/beasts.h --- beasts-orig/beasts.h Mon Jul 27 22:07:47 1998 +++ beasts/beasts.h Sat Mar 11 09:48:32 2000 @@ -33,7 +33,12 @@ DOWN_RIGHT } Direction; +typedef void (*InitFunc) (); +typedef void (*FieldSizeFunc) (int *x, int *y); +typedef void (*LoopFunc) (Field *field, Hero *hero); typedef void (*DrawIconFunc) (int x, int y, Grounds thing); +typedef void (*RefreshFunc) (); +typedef void (*QuitFunc) (); /* in main.c */ gboolean place_thing(Grounds thing, @@ -51,6 +56,8 @@ Hero *GlobalHeroPtr; Field *GlobalFieldPtr; gboolean StopLoop; +extern DrawIconFunc draw_icon; +extern RefreshFunc field_refresh; #define float_rand() ((float)rand()/(float)RAND_MAX) #define int_rand(N,X) ((int)(((double)rand()/(double)RAND_MAX)*((X)-(N)+1)+(N))) diff -u beasts-orig/main.c beasts/main.c --- beasts-orig/main.c Mon Jul 27 22:38:20 1998 +++ beasts/main.c Sat Mar 11 09:48:32 2000 @@ -24,12 +24,14 @@ static void draw_field(Field *field); -/* extern DrawIconFunc ConsoleDrawIcon; */ - /***** Defines ********/ -static DrawIconFunc (*draw_icon); -static void (*field_refresh)(); +InitFunc screen_init; +FieldSizeFunc field_size; +LoopFunc screen_loop; +DrawIconFunc draw_icon; +RefreshFunc field_refresh; +QuitFunc screen_quit; /*************** Functions *********************/ @@ -47,15 +49,23 @@ /* Determine interface mode (slang, gnome). */ - ConsoleInit(); +#ifndef NO_CONSOLE_INTERFACE + /* Ncurses interface */ + screen_init=&ConsoleInit; + field_size=&ConsoleFieldSize; + screen_loop=&ConsoleLoop; draw_icon=&ConsoleDrawIcon; field_refresh=&ConsoleRefresh; + screen_quit=&ConsoleQuit; +#endif + + (*screen_init)(); /* Get screen size. */ /* Calculate playing field size. */ - ConsoleFieldSize(&x,&y); + (*field_size)(&x,&y); srand(time(NULL)); field.map=g_new(Grounds,x*y); @@ -79,7 +89,7 @@ /* Action! */ StopLoop=FALSE; start_timer(); - ConsoleLoop(&field, &hero); + (*screen_loop)(&field, &hero); /* Hopefully everything is event based and we sleep for a while. */ @@ -87,7 +97,7 @@ /* Something caused the level to end. Who won? */ - ConsoleQuit(); + (*screen_quit)(); exit(0); } @@ -181,8 +191,8 @@ yoff=yy*field->x; for(xx=0; xx < field->x; xx++) { if(field->map[yoff+xx] != EMPTY) { - /* (*draw_icon)(xx,yy,field->map[yoff+xx]); */ - ConsoleDrawIcon(xx,yy,field->map[yoff+xx]); + (*draw_icon)(xx,yy,field->map[yoff+xx]); + /*ConsoleDrawIcon(xx,yy,field->map[yoff+xx]);*/ } /* endif not empty */ } /* next xx */ } /* next yy */ @@ -234,8 +244,8 @@ end_y = (yoff + x + stepped) / field->x; end_x = (yoff + x + stepped) % field->x; - ConsoleDrawIcon(end_x, end_y, BLOCK); - /* (*draw_icon)(end_x,end_y,BLOCK); */ + /*ConsoleDrawIcon(end_x, end_y, BLOCK);*/ + (*draw_icon)(end_x,end_y,BLOCK); return TRUE; } @@ -257,8 +267,8 @@ } - /* (*draw_icon)(hero->x, hero->y, EMPTY); */ - ConsoleDrawIcon(hero->x, hero->y, EMPTY); + (*draw_icon)(hero->x, hero->y, EMPTY); + /*ConsoleDrawIcon(hero->x, hero->y, EMPTY);*/ switch (thatway) { case UP_LEFT: @@ -293,8 +303,8 @@ default: break; } - ConsoleDrawIcon(hero->x, hero->y, HERO); - /* (*draw_icon)(hero->x, hero->y, HERO); */ + /*ConsoleDrawIcon(hero->x, hero->y, HERO);*/ + (*draw_icon)(hero->x, hero->y, HERO); (*field_refresh)();