[comp.sources.games] v05i079: xwanderer - wanderer2 for X-windows X11R2

games@tekred.TEK.COM (10/29/88)

Submitted by: Mike Cuddy <cuddy@convex.uucp>
Comp.sources.games: Volume 5, Issue 79
Archive-name: xwanderer/Part01

	[This is the wanderer2 game (v5i73, v5i74) with support for
	 X11R2 X-windows.  We only have X10.4, so I can't really test
	 this out.	-br]

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 5)."
# Contents:  README MANIFEST fall.c game.c icon.c icons screens
# Wrapped by billr@saab on Fri Oct 28 16:31:10 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(4571 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
X                        * W A N D E R E R *
X                ----------------------------------
X
X    This program requires the header files string.h and curses.h, and
Xthe curses and termcap libraries libcurses.a and libtermcap.a. If your
Xsystem doesnt have them then you might as well give up now.
X
X    Still here? Good - then everythings OK.
X
X    First thing to do is edit the wand_head.h file. Most of the filenames
Xare self-explanatory - the lock file is usually in /tmp , you probably
Xdont need to change it. SCREENPATH is the directory in which the screen
Xfiles, screen.* , are kept. HISCOREPATH is the name of the hiscore table
Xfile - this will be created when you run the program, but must have group
Xand other read and write permission.
X    The masterpassword is the password that you can give when you try to
Xjump screen with ~ (see file wand.info) that will allow you to go to any
Xscreen at will. This is for wanderer 'wizards' only. Separate passwords
Xfor each screen are drawn from the file /usr/dict/words - if you dont have
Xit on your system then you'll have to change the file jump.c . These passwords
Xare given to the player upon completing each screen.
X
X    You can create new screens easily - just use the same format as the
Xscreens supplied. Each line of data MUST be the correct length , or nasty
Xthings happen because I didnt bother to put in an intelligent datafile reader
Xfunction. You can test out new screens using the development program included
Xin the package, which allows you to play a screen held in the file ./screen
Xwhich must be in standard Wanderer format. Obviously, no hiscores are saved
Xby this program. All screens must be readable by everyone.
X
X    The hiscore table holds only one score per name - this is to prevent
Xone person from taking over the entire table. If you object to this, then its
Xeasy to stop - just remove a few bits of scores.c. Unfortunately, this bit
Xcontains a *BUG* - if you score enouh to place yourself in the table directly
Xbelow your current hiscore, then both are retained until you next play. It
Xshould be easy to fix this, but I've never got around to it yet. The hiscore
Xsystem is absolutesly *full* of bad, obfuscated programming, and the lack of
Xany real commenting does not help, I'm afraid.
X    There is also a program called 'erase' included, which will allow you to
Xremove entries from the hiscore table. This table must, of course, have group
Xand other read/write permission. 'erase' has a nasty bug in it - to finish an
Xedit, type 0. If you use anything else, its liable to wipe the entire
Xtable...
X
X    Not much more to say, really. Info on playing the game can be found in
Xthe wand.info file. Once you have edited the header file, just type 'make'
Xto run the makefile. You may need to edit the makefile so that it conforms
Xwith your system. If you dont know how to do this, there's bound to be
Xsomeone around who does.
X
X    All that remains is for me to say that the source was written by me,
XSteven Shipway,  on a sun/3-160 called poppy at Warwick University. The
Xlatter are completely unaware of this major breakthrough in software
Xdesign (:-), and this is probably a good idea, since they may well disapprove
Xof this use of computing time and facilities! (Only kidding)
X
X                                -Steven Shipway
X
X------------------------------------------------------------------------------
X
XNotes for wanderer 2.0 (X11R2 version)
X
XThe 'X' version takes an optional command line argument '-d' or '-display'
Xto specify the display to use.  The bitmaps are in the 'icons' directory and
Xare easily changed with the 'X' bitmap utility.  
X
XThere is a new feature of help screens in the program.  Press '?' to get help.
XThe helpscreens are built from the help file (wanderer.help) which should be
Xinstalled with the screens (see SCREENDIR above).  I never got around to fixing 
XSteven's bug in the scores routine; oh, well.
X
XThe two programs, wanderer and xwanderer are made from the same source files
Xwith a few exceptions.  xwanderer is compiled with the -DXWANDER flag and
Xwanderer is compiled with -UXWANDER.  dev has been merged into the
Xwanderer program and is made by compiling with -DGAMEDEV.  The new makefile
Xknows about this and makes .o files with an appropriate letter tacked onto
Xthe end (e.g.:  m.c --> mX.c, mD.c, and mC.c.) questions about xwanderer should
Xbe directed to me, Mike Cuddy, ( {ihnp4,uiucdcs,allegra,sun}!convex!cuddy ).
X
XHave fun, and thanx to Steven for a great (albeit addicting) game.
X
X			-- Mike Cuddy
X			   {ihnp4, uiucdcs, allegra, sun}!convex!cuddy
END_OF_FILE
if test 4571 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(2532 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X FILES                      4	
X MANIFEST                   1	This shipping list
X Makefile                   2	
X README                     1	
X devread.c                  5	
X display.c                  2	
X erase.c                    3	
X fall.c                     1	
X game.c                     1	
X gamedev.c                  2	
X helpscr.c                  2	
X icon.c                     1	
X icons                      1	
X icons/backslide_bm         3	
X icons/backslide_tbm        5	
X icons/brick_bm             3	
X icons/brick_tbm            5	
X icons/cage_bm              4	
X icons/cage_tbm             5	
X icons/diamond_bm           3	
X icons/diamond_tbm          5	
X icons/dirt_bm              4	
X icons/dirt_tbm             5	
X icons/fwdslide_bm          3	
X icons/fwdslide_tbm         5	
X icons/landmine_bm          4	
X icons/landmine_tbm         5	
X icons/larrow_bm            3	
X icons/larrow_tbm           5	
X icons/monster_bm           3	
X icons/monster_tbm          5	
X icons/player_bm            4	
X icons/player_tbm           5	
X icons/playerl_bm           3	
X icons/playerr_bm           4	
X icons/rarrow_bm            3	
X icons/rarrow_tbm           5	
X icons/rock_bm              4	
X icons/rock_tbm             5	
X icons/space_bm             3	
X icons/space_tbm            5	
X icons/sprite_bm            3	
X icons/sprite_tbm           5	
X icons/teleport_bm          4	
X icons/teleport_tbm         5	
X icons/timecapsule_bm       3	
X icons/timecapsule_tbm      4	
X icons/wall_bm              4	
X icons/wall_tbm             5	
X icons/wanderer_bm          3	
X icons/wayout_bm            3	
X icons/wayout_tbm           5	
X icons/whoops_bm            3	
X icons/whoops_tbm           5	
X jump.c                     2	
X m.c                        2	
X make.out                   4	
X pixmapdecl.h               4	
X read.c                     5	
X scores.c                   2	
X screens                    1	
X screens/screen.1           4	
X screens/screen.10          4	
X screens/screen.11          4	
X screens/screen.12          4	
X screens/screen.13          4	
X screens/screen.2           4	
X screens/screen.3           4	
X screens/screen.4           4	
X screens/screen.5           4	
X screens/screen.6           4	
X screens/screen.7           4	
X screens/screen.8           4	
X screens/screen.9           4	
X wand.intro                 4	
X wand_head.h                4	
X wanderer.6                 4	
X wanderer.help              2	
END_OF_FILE
if test 2532 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'fall.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'fall.c'\"
else
echo shar: Extracting \"'fall.c'\" \(5949 characters\)
sed "s/^X//" >'fall.c' <<'END_OF_FILE'
X#include "wand_head.h"
X
Xextern void draw_symbol();
X#ifdef XWANDER
Xextern int tinymode;
X#endif
X
Xint fall(mx,my,x,y,sx,sy,screen,howdead)
Xint  x,y,sx,sy, *mx, *my;
Xchar screen[NOOFROWS][ROWLEN+1],
X     howdead[25];
X{
Xint nx = x,nyl = y,nyr = y,retval = 0;
Xif (y>(NOOFROWS-1))
X    return(0);
Xif((screen[y][x]!='O')&&(screen[y][x]!=' ')&&(screen[y][x]!='M')&&(screen[y][x]!='\\')&&(screen[y][x]!='/')&&(screen[y][x]!='@'))
X    return(0);
Xif(screen[y][x] == 'O')
X    {
X    if((screen[y][x-1] == ' ') && (screen[y-1][x-1] == ' '))
X        nx--;
X    else
X	{
X        if((screen[y][x+1] == ' ') && (screen[y-1][x+1] == ' '))
X            nx++;
X	else
X	    nx = -1;
X	}
X    if((screen[y-1][x] == ' ') && (screen[y-1][x+1] == ' '))
X        nyr--;
X    else
X	{
X        if((screen[y+1][x] == ' ') && (screen[y+1][x+1] == ' '))
X            nyr++;
X	else
X	    nyr = -1;
X	}
X    if((screen[y-1][x] == ' ') && (screen[y-1][x-1] == ' '))
X        nyl--;
X    else
X	{
X        if((screen[y+1][x] == ' ') && (screen[y+1][x-1] == ' '))
X            nyl++;
X	else
X	    nyl = -1;
X	}
X    }
Xif(screen[y][x] == '\\')
X    {
X    if(screen[y-1][++nx] != ' ')
X	nx = -1;
X    if(screen[--nyr][x+1] != ' ')
X        nyr = -1;
X    if(screen[++nyl][x-1] != ' ')
X        nyl = -1;
X    }
Xif(screen[y][x] == '/')
X    {
X    if(screen[y-1][--nx] != ' ')
X	nx = -1;
X    if(screen[++nyr][x+1] != ' ')
X	nyr = -1;
X    if(screen[--nyl][x-1] != ' ')
X	nyl = -1;
X    }
Xif((screen[y][nx] != ' ')&&(screen[y][nx] != ' '))
X    nx = -1;
Xif((screen[y-1][x] == 'O') && (nx>=0) && (y>0))       /* boulder falls ? */
X    {
X    screen[y-1][x] = ' ';
X    if(screen[y][nx] == '@')
X        {
X    	strcpy(howdead,"a falling boulder"); dobeep();
X    	retval=1;
X    	}
X    if(screen[y][nx] == 'M')
X        {
X    	dobeep();
X    	*mx = *my = -2;
X	screen[y][nx] = ' ';
X    	}
X    screen[y][nx] = 'O';
X#ifndef XWANDER
X    if((y<(sy+5)) && (y>(sy-3)) && (x>(sx-6)) && (x<(sx+6)))
X        draw_symbol((x-sx+5)*3,(y-sy+2)*2,' ');
X#else
X    if((y<(sy+5)) && (y>(sy-3)) && (x>(sx-6)) && (x<(sx+6)) || tinymode)
X        draw_symbol((x-sx+5),(y-sy+2),' ');
X#endif
X#ifndef XWANDER
X    if((y<(sy+4)) && (y>(sy-4)) && (nx>(sx-6)) && (nx<(sx+6)))
X        draw_symbol((nx-sx+5)*3,(y-sy+3)*2,'O');
X    refresh();
X#else
X    if((y<(sy+4)) && (y>(sy-4)) && (nx>(sx-6)) && (nx<(sx+6)) || tinymode)
X        draw_symbol((nx-sx+5),(y-sy+3),'O');
X#endif
X    retval+=fall(mx,my,nx ,y+1,sx,sy,screen,howdead);
X    retval+=fall(mx,my,nx ,y+1,sx,sy,screen,howdead);
X    retval+=fall(mx,my,nx ,y+1,sx,sy,screen,howdead);
X    retval+=fall(mx,my,x+1,y-1,sx,sy,screen,howdead);
X    retval+=fall(mx,my,x-1,y-1,sx,sy,screen,howdead);
X    retval+=fall(mx,my,x  ,y-1,sx,sy,screen,howdead);
X    if(screen[y+1][nx] == '@')
X        {
X    	strcpy(howdead,"a falling boulder");  dobeep();
X    	return(1);
X    	}
X    if(screen[y+1][nx] == 'M')
X        {
X    	dobeep();
X    	*mx = *my = -2;
X	screen[y+1][nx] = ' ';
X    	}
X    }
Xif((screen[nyr][x] != ' ')&&(screen[nyr][x] != 'M'))
X    nyr = -1;
Xif((screen[y][x+1] == '<')&&(nyr>=0)) /* arrow moves ( < ) ? */
X    {
X    screen[y][x+1] = ' ';
X    if(screen[nyr][x] == '@')
X        {
X    	strcpy(howdead,"a speeding arrow");  dobeep();
X    	retval = 1;
X    	}
X    if(screen[nyr][x] == 'M')
X        {
X    	dobeep();
X    	*mx = *my = -2;
X	screen[nyr][x] = ' ';
X    	}
X    screen[nyr][x] = '<';
X#ifndef XWANDER
X    if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+6)) && (x>(sx-6)))
X        draw_symbol((x-sx+6)*3,(y-sy+3)*2,' ');
X#else
X    if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+6)) && (x>(sx-6)) || tinymode)
X        draw_symbol((x-sx+6),(y-sy+3),' ');
X#endif
X#ifndef XWANDER
X    if((nyr<(sy+4)) && (nyr>(sy-4)) && (x<(sx+7)) && (x>(sx-5)))
X        draw_symbol((x-sx+5)*3,(nyr-sy+3)*2,'<');
X    refresh();
X#else
X    if((nyr<(sy+4)) && (nyr>(sy-4)) && (x<(sx+7)) && (x>(sx-5))||tinymode)
X        draw_symbol((x-sx+5),(nyr-sy+3),'<');
X#endif
X    retval+=fall(mx,my,x-1,nyr,sx,sy,screen,howdead);
X    retval+=fall(mx,my,x+1,y-1,sx,sy,screen,howdead);
X    retval+=fall(mx,my,x+1,y+1,sx,sy,screen,howdead);
X    retval+=fall(mx,my,x-1,y-1,sx,sy,screen,howdead);
X    retval+=fall(mx,my,x-1,y+1,sx,sy,screen,howdead);
X    retval+=fall(mx,my,x+1,y  ,sx,sy,screen,howdead);
X    if(screen[nyr][x-1] == '@')
X        {
X    	strcpy(howdead,"a speeding arrow");  dobeep();
X    	return(1);
X    	}
X    if(screen[nyr][x-1] == 'M')
X        {
X    	dobeep();
X    	*mx = *my = -2;
X	screen[nyr][x-1] = ' ';
X    	}
X    }
Xif((screen[nyl][x] != ' ')&&(screen[nyl][x] != 'M'))
X    nyl = -1;
Xif((screen[y][x-1] == '>')&&(nyl>=0))       /* arrow moves ( > ) ? */
X    {
X    screen[y][x-1] = ' ';
X    if(screen[nyl][x] == '@')
X        {
X    	strcpy(howdead,"a speeding arrow");  dobeep();
X    	retval = 1;
X    	}
X    if(screen[nyl][x] == 'M')
X        {
X    	dobeep();
X    	*mx = *my = -2;
X	screen[nyl][x] = ' ';
X    	}
X    screen[nyl][x] = '>';
X#ifndef XWANDER
X    if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+6)) && (x>(sx-6)))
X        draw_symbol((x-sx+4)*3,(y-sy+3)*2,' ');
X#else
X    if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+6)) && (x>(sx-6)) || tinymode)
X        draw_symbol((x-sx+4),(y-sy+3),' ');
X#endif
X#ifndef XWANDER
X    if((nyl<(sy+4)) && (nyl>(sy-4)) && (x<(sx+5)) && (x>(sx-7)))
X        draw_symbol((x-sx+5)*3,(nyl-sy+3)*2,'>');
X    refresh();
X#else
X    if((nyl<(sy+4)) && (nyl>(sy-4)) && (x<(sx+5)) && (x>(sx-7))||tinymode)
X        draw_symbol((x-sx+5),(nyl-sy+3),'>');
X#endif
X    retval+=fall(mx,my,x+1,nyl,sx,sy,screen,howdead);
X	retval+=fall(mx,my,x+1,y-1,sx,sy,screen,howdead);
X	retval+=fall(mx,my,x+1,y+1,sx,sy,screen,howdead);
X	retval+=fall(mx,my,x-1,y-1,sx,sy,screen,howdead);
X	retval+=fall(mx,my,x-1,y+1,sx,sy,screen,howdead);
X    retval += fall(mx,my,x-1,y,sx,sy,screen,howdead);
X    if(screen[nyl][x+1] == '@')
X        {
X    	strcpy(howdead,"a speeding arrow");  dobeep();
X    	return(1);
X    	}
X    if(screen[nyl][x+1] == 'M')
X        {
X    	dobeep();
X    	*mx = *my = -2;
X	screen[nyl][x+1] = ' ';
X    	}
X    }
Xif(retval>0)
X    return(1);
Xreturn(0);
X}
END_OF_FILE
if test 5949 -ne `wc -c <'fall.c'`; then
    echo shar: \"'fall.c'\" unpacked with wrong size!
fi
# end of 'fall.c'
fi
if test -f 'game.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'game.c'\"
else
echo shar: Extracting \"'game.c'\" \(19070 characters\)
sed "s/^X//" >'game.c' <<'END_OF_FILE'
X#include "wand_head.h"
X
X#define viable(x,y) ((screen[y][x] == ' ') || (screen[y][x] == ':') ||\
X    (screen[y][x] == '@') || (screen[y][x] == '+')) && (y >= 0) &&\
X    (x >= 0) && (y < NOOFROWS) && (x < ROWLEN)
X
Xtypedef struct mon_rec
X{
Xint x,y,mx,my;
Xchar under;
Xstruct mon_rec *next;
X};
X
Xtypedef struct { int d[2] } direction;
X#ifdef XWANDER
Xint playerfacing = 0;
Xint tinymode = 0;
Xextern int do_repaint;
X#endif
X
X#ifndef GAMEDEV
Xextern int jumpscreen();
X
Xextern void showpass();
X#endif
X
Xextern void draw_symbol();
X
Xextern void display();
X
Xextern int fall();
X
Xextern void map();
X
X/* Add a spirit to the chain */
X
Xstruct mon_rec *make_monster(x,y)
Xint x,y;
X{
Xstruct mon_rec *malloc(),
X	   *monster;
Xif((monster = malloc(sizeof(struct mon_rec))) == NULL)
Xreturn NULL;
Xmonster->x = x;
Xmonster->y = y;
Xmonster->mx = 1;      /* always start moving RIGHT. (fix later)  */
Xmonster->my = 0;
Xmonster->under = ' ';
Xmonster->next = NULL;
Xreturn monster;
X}
X
X/* 'follow lefthand wall' algorithm for sprites */
X
Xdirection new_direction(screen,x,y,bx,by)
Xint x,y,bx,by;
Xchar screen[NOOFROWS][ROWLEN+1];
X{
Xdirection out;
Xif(viable((x+by),(y-bx)))
X{
Xout.d[0] = by;
Xout.d[1] = -bx;
Xreturn out;
X}
Xif(viable((x+bx),(y+by)))
X{
Xout.d[0] = bx;
Xout.d[1] = by;
Xreturn out;
X}
Xif(viable((x-by),(y+bx)))
X{
Xout.d[0] = -by;
Xout.d[1] = bx;
Xreturn out;
X}
Xif(viable((x-bx),(y-by)))
X{
Xout.d[0] = -bx;
Xout.d[1] = -by;
Xreturn out;
X}
Xout.d[0] = -bx;
Xout.d[1] = -by;
Xreturn out;
X}
X
X/* Actual game function - Calls fall() to move
X   boulders and arrows recursively */
X
X#ifndef GAMEDEV
Xchar *playscreen(num,screen,score,bell,maxmoves,keys)
Xint  num;
X#else
Xchar *playscreen(num,screen,score,bell,maxmoves,keys)
X#endif
Xint  maxmoves,
X *bell,
X *score;
Xchar screen[NOOFROWS][ROWLEN+1],
X keys[10];
X{
Xint  x,y,nx,ny,deadyet =0,
X sx = -1,sy = -1,tx = -1,ty = -1,lx = 0,ly = 0,mx = -1,my = -1,
X bx, by, nbx, nby,
X newnum,
X diamonds = 0, nf = 0,hd ,vd ,xdirection,ydirection;
Xchar (*frow)[ROWLEN+1] = screen,
X ch,
X buffer[25],
X howdead[25];
Xdirection new_disp;
Xstruct mon_rec *monster,*mon_ptr, *current;
X
Xmon_ptr = NULL;
X
Xfor(x=0;x<=ROWLEN;x++)
Xfor(y=0;y<NOOFROWS;y++)
X    {
X    if((screen[y][x] == '*')||(screen[y][x] == '+'))
X	diamonds++;
X    if(screen[y][x] == 'A')     /* note teleport arrival point &  */
X	{                       /* replace with space */
X	tx = x;
X	ty = y;
X	screen[y][x] = ' ';
X	}
X    if(screen[y][x] == '@')
X	{
X	sx = x;
X	sy = y;
X	}
X    if(screen[y][x] == 'M')     /* Put megamonster in */
X	{
X	mx = x;
X	my = y;
X	}
X    if(screen[y][x] == 'S')     /* link small monster to pointer chain */
X	{
X	if((monster = make_monster(x,y)) == NULL)
X	    {
X	    strcpy(howdead,"running out of memory");
X	    return howdead;
X	    }
X	if(mon_ptr == NULL)
X	    current = mon_ptr = monster;
X	else
X	    current = current->next = monster;
X	}
X    if(screen[y][x] == '-')
X	    screen[y][x] = ' ';
X    };
Xx=sx;
Xy=sy;
Xif((x == -1)&&(y == -1))              /* no start position in file ? */
X{
X#ifdef GAMEDEV
Xstrcpy(howdead,"no start position!");
X#else
Xstrcpy(howdead,"a screen design error");
X#endif
Xreturn(howdead);
X}
X#ifndef XWANDER
Xmove(0,48);
X(void) addstr("Score\t   Diamonds");
Xmove(1,48);
X(void) addstr("\tFound\tTotal");
Xmove(3,48);
X(void) sprintf(buffer,"%d\t %d\t %d  ",*score,nf,diamonds);
X(void) addstr(buffer);
Xmove(6,48);
X(void) sprintf(buffer,"Current screen %d",num);
X(void) addstr(buffer);
Xif(maxmoves != 0)
X(void) sprintf(buffer,"Moves remaining = %d   ",maxmoves);
Xelse
X{
X(void) strcpy(buffer,"     Unlimited moves     ");
Xmaxmoves = -1;
X};
Xmove(15,48);
X(void) addstr(buffer);
Xif(mx != -1)                            /* tell player if monster exists */
Xdraw_symbol(48,10,'M');
Xelse
Xdraw_symbol(48,10,' ');
X#else
Xrepaint_score(*score, nf, diamonds, num, maxmoves, mx);
X#endif
X   
X
X
Xdisplay(sx,sy,frow,*score);
X
X/* ACTUAL GAME FUNCTION - Returns method of death in string  */
X
Xwhile(deadyet == 0)
X{
X#ifndef XWANDER
Xch = getchar();
X#else
Xch = getchar(sx, sy, frow, score, nf, diamonds, num, maxmoves, mx);
X#endif
X
Xnx=x;
Xny=y;
X#ifdef XWANDER
Xif(ch == keys[3])  {
X    playerfacing = 0;
X    nx++;
X}
Xif(ch == keys[2]) {
X    playerfacing = 1;
X    nx--;
X}
X#else
Xif(ch == keys[3]) 
X	nx++;
Xif(ch == keys[2])
X	nx--;
X#endif
Xif((ch == keys[1]) && (y<(NOOFROWS-1)))
X	ny++;
Xif(ch == keys[0])
X        ny--;
Xif(ch == '1')
X	{
X#ifndef XWANDER
X        move(10,45);
X        *bell = 1;
X        (void) addstr("Bell ON ");
X        dobeep();
X	move(16,0);
X        refresh();
X#else
X	*bell = 1;
X 	score_message(12,"Bell ON    ");
X#endif
X	}
Xif(ch == '0')
X	{
X#ifndef XWANDER
X        *bell = 0;
X        move(10,45);
X        (void) addstr("Bell OFF");
X	move(16,0);
X        refresh();
X#else
X	*bell = 1;
X 	score_message(12,"Bell OFF");
X#endif
X	}
Xif(ch == '~')                             /* level jump */
X#ifdef GAMEDEV
X	{
X	strcpy(howdead,"~~");
X	return(howdead);
X	}
X#else
X	{
X	if((newnum = jumpscreen(num)) == 0)
X	    {
X	    strcpy(howdead,"a jump error.");
X	    return howdead;
X	    }
X	if(newnum > num)
X	    {
X	    sprintf(howdead,"~%c",newnum);
X	    return howdead;
X	    }
X        dobeep();
X	}
X#endif
Xif(ch == '!')
X	{
X#ifdef XWANDER
X	if (tinymode) dobeep(); else {
X#endif
X	map(frow);
X        display(sx,sy,frow,*score);
X#ifdef XWANDER
X	}
X#endif
X	}
X#ifdef XWANDER
Xif (ch == 't')
X	{
X	    if (tinymode) {
X		tinymode = 0;
X		sx = x - 5;
X		if (sx < 0) sx = 0;
X		sy = y - 3;
X		if (sy < 0) sy = 0;
X		XClearArea(dpy, win, 5,5,ICON_WIDE*11, ICON_HIGH*7,0);
X		display(sx,sy,frow,*score);
X	    } else {
X		sx = 5; sy = 3;
X		tinymode = 1;
X		drawmap(frow,1);
X	    }
X	}
X#endif
Xif (ch == '?')
X	{
X	    do_help(keys);
X#ifdef XWANDER
X	    do_repaint = 1;
X	    if (tinymode) 
X		drawmap(frow,1);
X	    else
X#endif
X		display(sx,sy,frow,*score);
X	}
Xif(ch == 'q')
X        {
X        strcpy(howdead,"quitting the game");
X	return howdead;
X	}
X
Xif(screen[ny][nx] == 'C')
X    {
X    screen[ny][nx] = ':';
X    *score+=4;
X    if (*bell)
X	dobeep();
X    if(maxmoves != -1)
X        maxmoves+=250;
X    }
Xswitch(screen[ny][nx])
X    {
X    case '@': break;
X    case '*': *score+=9;
X        if (*bell)
X	    dobeep();
X        nf++;
X    case ':': *score+=1;
X#ifndef XWANDER
X        move(3,48);
X        sprintf(buffer,"%d\t %d",*score,nf);
X        (void) addstr(buffer);
X#else
X	score_message(2,"%7d   %3d     %3d", *score, nf, diamonds);
X#endif
X	
X    case ' ':
X	screen[y][x] = ' ';
X   	screen[ny][nx] = '@';
X#ifndef XWANDER
X    	draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
X    	draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'@');
X#else
X    	draw_symbol((x-sx+5),(y-sy+3),' ');
X    	draw_symbol((nx-sx+5),(ny-sy+3),'@');
X#endif
X        if(deadyet ==0)
X	    deadyet = fall(&mx,&my,x,y,sx,sy,screen,howdead);
X        if((deadyet ==0) && (nx != (x+1)))
X	    deadyet = fall(&mx,&my,x+1,y,sx,sy,screen,howdead);
X        if((deadyet ==0) && (nx != (x-1)))
X	    deadyet = fall(&mx,&my,x-1,y,sx,sy,screen,howdead);
X        if(deadyet ==0)
X	    deadyet = fall(&mx,&my,x+1,y+1,sx,sy,screen,howdead);
X        if(deadyet ==0)
X	    deadyet = fall(&mx,&my,x-1,y+1,sx,sy,screen,howdead);
X        if(deadyet ==0)
X	    deadyet = fall(&mx,&my,x-1,y-1,sx,sy,screen,howdead);
X        if((deadyet ==0) && (ny != (y+1)))
X	    deadyet = fall(&mx,&my,x,y+1,sx,sy,screen,howdead);
X        if((deadyet ==0) && (ny != (y-1)))
X	    deadyet = fall(&mx,&my,x,y-1,sx,sy,screen,howdead);
X        if(deadyet ==0)
X	    deadyet = fall(&mx,&my,x+1,y-1,sx,sy,screen,howdead);
X#ifndef XWANDER
X    	move(16,0);
X    	refresh();
X#endif
X	y = ny;
X	x = nx;
X        break;
X    case 'O':
X	if(screen[y][nx*2-x] == 'M')
X	    {
X	    screen[y][nx*2-x] = ' ';
X	    mx = my = -1;
X	    if(*bell)
X		dobeep();
X	    *score+=100;
X#ifndef XWANDER
X            move(3,48);
X            sprintf(buffer,"%d\t %d\t %d ",*score,nf,diamonds);
X            (void) addstr(buffer);
X	    draw_symbol(48,10,' ');
X	    move(16,0);
X            refresh();
X#else
X	    score_message(2,"%7d   %3d     %3d", *score, nf, diamonds);
X	    display_monster(mx);
X#endif
X	    }
X	if(screen[y][nx*2-x] == ' ')
X	    {
X	    screen[y][nx*2-x] = 'O';
X	    screen[y][x] = ' ';
X            screen[ny][nx] = '@';
X#ifndef XWANDER
X            draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
X            draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'@');
X            draw_symbol((nx*2-x-sx+5)*3,(y-sy+3)*2,'O');
X#else
X            draw_symbol((x-sx+5),(y-sy+3),' ');
X            draw_symbol((nx-sx+5),(ny-sy+3),'@');
X            draw_symbol((nx*2-x-sx+5),(y-sy+3),'O');
X#endif
X            if(deadyet==0)
X                deadyet = fall(&mx,&my,nx*2-x,y+1,sx,sy,screen,howdead);
X            if(deadyet==0)
X                deadyet = fall(&mx,&my,x*2-nx,y,sx,sy,screen,howdead);
X            if(deadyet==0)
X                deadyet = fall(&mx,&my,x,y,sx,sy,screen,howdead);
X            if(deadyet==0)
X                deadyet = fall(&mx,&my,x,y-1,sx,sy,screen,howdead);
X            if(deadyet==0)
X                deadyet = fall(&mx,&my,x,y+1,sx,sy,screen,howdead);
X#ifndef XWANDER
X            move(16,0);
X            refresh();
X#endif
X	    y = ny;
X	    x = nx;
X	    }
X	break;
X    case '<':
X    case '>':
X	if(screen[ny*2-y][x] == 'M')
X	    {
X	    screen[ny*2-y][x] = ' ';
X	    mx = my = -1;
X	    if(*bell)
X		dobeep();
X	    *score+=100;
X#ifndef XWANDER
X            move(3,48);
X            sprintf(buffer,"%d\t %d\t %d ",*score,nf,diamonds);
X            (void) addstr(buffer);
X	    draw_symbol(48,10,' ');
X	    move(16,0);
X            refresh();
X#else
X	    score_message(2,"%7d   %3d     %3d", *score, nf, diamonds);
X	    display_monster(mx);
X#endif
X	    }
X	if(screen[ny*2-y][x] == ' ')
X	    {
X	    screen[ny*2-y][x] = screen[ny][nx];
X	    screen[y][x] = ' ';
X            screen[ny][nx] = '@';
X#ifndef XWANDER
X            draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
X            draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'@');
X            draw_symbol((x-sx+5)*3,(ny*2-y-sy+3)*2,screen[ny*2-y][x]);
X#else
X            draw_symbol((x-sx+5),(y-sy+3),' ');
X            draw_symbol((nx-sx+5),(ny-sy+3),'@');
X            draw_symbol((x-sx+5),(ny*2-y-sy+3),screen[ny*2-y][x]);
X#endif
X            if(deadyet == 0)
X	        deadyet = fall(&mx,&my,x,y,sx,sy,screen,howdead);
X            if(deadyet == 0)
X	        deadyet = fall(&mx,&my,x-1,(ny>y)?y:(y-1),sx,sy,screen,howdead);
X            if(deadyet == 0)
X	        deadyet = fall(&mx,&my,x+1,(ny>y)?y:(y-1),sx,sy,screen,howdead);
X            if(deadyet == 0)
X	        deadyet = fall(&mx,&my,x-1,ny*2-y,sx,sy,screen,howdead);
X            if(deadyet == 0)
X	        deadyet = fall(&mx,&my,x+1,ny*2-y,sx,sy,screen,howdead);
X#ifndef XWANDER
X            move(16,0);
X            refresh();
X#endif
X	    y = ny;
X	    x = nx;
X	    }
X	break;
X    case '!':
X        strcpy(howdead,"an exploding landmine");
X	deadyet = 1;
X#ifndef XWANDER
X    	draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
X    	draw_symbol((nx-sx+5)*3,(ny-sy+3)*2,'@');
X        move(16,0);
X	refresh();
X#else
X    	draw_symbol((x-sx+5),(y-sy+3),' ');
X    	draw_symbol((nx-sx+5),(ny-sy+3),'@');
X#endif
X        break;
X    case 'X':
X	if(nf == diamonds)
X	    {
X	    *score+=250;
X	    if(*bell)
X		dobeep();
X#ifndef GAMEDEV
X	    showpass(num);
X	    return NULL;
X#else
X	    strcpy(howdead,"finishing the screen.");
X	    return howdead;
X#endif
X	    }
X	break;
X    case 'T':
X	if(tx > -1)
X	    {
X	    screen[ny][nx] = ' ';
X	    screen[y][x] = ' ';
X#ifdef XWANDER
X	    if (tinymode) {
X		draw_symbol(nx,ny,' ');
X		draw_symbol(x,y,' ');
X		draw_symbol(tx,ty,'@');
X	    }
X#endif
X	    lx = x;
X	    ly = y;
X	    y = ty;
X	    x = tx;
X	    screen[y][x] = '@';
X#ifdef XWANDER
X	    if (!tinymode) {
X#endif
X	    sx = x;
X	    sy = y;
X	    *score += 20;
X#ifdef XWANDER
X	    }
X#endif
X#ifndef XWANDER
X	    display(sx,sy,frow,*score);
X#else
X	    if (!tinymode)
X		display(sx,sy,frow,*score);
X#endif
X	    deadyet = fall(&mx,&my,nx,ny,sx,sy,screen,howdead);
X	    if(deadyet == 0)
X		deadyet = fall(&mx,&my,lx,ly,sx,sy,screen,howdead);
X	    if(deadyet == 0)
X		deadyet = fall(&mx,&my,lx+1,ly-1,sx,sy,screen,howdead);
X	    if(deadyet == 0)
X		deadyet = fall(&mx,&my,lx+1,ly+1,sx,sy,screen,howdead);
X	    if(deadyet == 0)
X		deadyet = fall(&mx,&my,lx-1,ly+1,sx,sy,screen,howdead);
X	    if(deadyet == 0)
X		deadyet = fall(&mx,&my,lx-1,ly-1,sx,sy,screen,howdead);
X#ifndef XWANDER
X	    move(16,0);
X	    refresh();
X#endif
X	    }
X	else
X	    {
X	    screen[ny][nx] = ' ';
X#ifndef XWANDER
X	    printf("Teleport out of order");
X#else
X	    erase_message(0);
X	    message(0,"Teleport out of order");
X	    if (*bell) dobeep();
X#endif
X	    }
X	break;
X    case 'M':
X	strcpy(howdead,"a hungry monster");
X	deadyet = 1;
X#ifndef XWANDER
X    	draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
X        move(16,0);
X	refresh();
X#else
X    	draw_symbol((x-sx+5),(y-sy+3),' ');
X#endif
X        break;
X    case 'S':
X	strcpy(howdead,"walking into a monster");
X	deadyet = 1;
X#ifndef XWANDER
X    	draw_symbol((x-sx+5)*3,(y-sy+3)*2,' ');
X        move(16,0);
X	refresh();
X#else
X    	draw_symbol((x-sx+5),(y-sy+3),' ');
X#endif
X        break;
X    default:
X        break;
X    }
Xif((y == ny) && (x == nx) && (maxmoves>0))
X    {
X#ifndef XWANDER
X    (void) sprintf(buffer,"Moves remaining = %d ",--maxmoves);
X    move(15,48);
X    (void) addstr(buffer);
X#else
X    score_message(15,"Moves Remaining = %d   ", --maxmoves);
X#endif
X    }
Xif(maxmoves == 0)
X    {
X#ifdef GAMEDEV
X#ifdef XWANDER
X    message(0,"You ran out of time!");
X    dobeep();
X#else
X    addstr("You ran out of time! \007\007");
X    refresh();
X#endif
X#else
X    strcpy(howdead,"running out of time");
X    return(howdead);
X#endif
X    }
X#ifdef XWANDER
X    if (!tinymode) {
X#endif
Xif ((x<(sx-3))&& (deadyet ==0))         /* screen scrolling if necessary */
X    {
X    sx-=6;
X    if(sx < 4)
X	sx = 4;
X    display(sx,sy,frow,*score);
X    }
Xif ((y<(sy-2))&& (deadyet == 0))
X    {
X    sy-=5;
X    if(sy < 2)
X	sy = 2;
X    display(sx,sy,frow,*score);
X    }
Xif ((x>(sx+3)) && (deadyet == 0))
X    {
X    sx+=6;
X    if(sx>(ROWLEN -5))
X	sx = ROWLEN -5;
X    display(sx,sy,frow,*score);
X    }
Xif ((y>(sy+2))&& (deadyet ==0))
X    {
X    sy+=5;
X    if(sy > (NOOFROWS-3))
X	sy = NOOFROWS -3;
X    display(sx,sy,frow,*score);
X    }
X#ifdef XWANDER
X    }
X#endif
X
X	/* MONSTER SECTION - Put all these in a separate function later */
X
Xif(mx == -2)                              /* has the monster been killed ? */
X    {
X    *score+=100;
X    mx = my = -1;
X#ifndef XWANDER
X    move(3,48);
X    sprintf(buffer,"%d\t %d\t",*score,nf);
X    (void) addstr(buffer);
X    draw_symbol(48,10,' ');
X    move(16,0);
X    refresh();
X#else
X    score_message(2,"%7d   %3d     %3d", *score, nf, diamonds);
X    display_monster(mx);
X#endif
X    }
Xif(mx != -1)                              /* no? then move that monster ! */
X    {
X    screen[my][mx] = ' ';
X    if(mx>x)
X        xdirection = -1;
X    else
X        xdirection = 1;
X#ifndef XWANDER
X    if((my<(sy+4))&&(my>(sy-4))&&(mx<(sx+6))&&(mx>(sx-6)))
X        draw_symbol((mx-sx+5)*3,(my-sy+3)*2,' ');
X#else
X    if((my<(sy+4))&&(my>(sy-4))&&(mx<(sx+6))&&(mx>(sx-6)) || tinymode)
X        draw_symbol((mx-sx+5),(my-sy+3),' ');
X#endif
X    if((hd = (mx-x))<0)
X	hd = -hd;
X    if((vd = (my-y))<0)
X	vd = -vd;
X    if((hd>vd)&&((screen[my][mx+xdirection] == ' ')||(screen[my][mx+xdirection] == '@')))
X	mx+=xdirection;
X    else
X        {
X        if(my>y)
X            ydirection = -1;
X	else
X    	    ydirection = 1;
X        if((screen[my+ydirection][mx] == ' ')||(screen[my+ydirection][mx] == '@'))
X	    my+=ydirection;
X	else
X            if((screen[my][mx+xdirection] == ' ')||(screen[my][mx+xdirection] == '@'))
X	mx+=xdirection;
X	}
X#ifndef XWANDER
X    if((my<(sy+4))&&(my>(sy-4))&&(mx<(sx+6))&&(mx>(sx-6)))
X        draw_symbol((mx-sx+5)*3,(my-sy+3)*2,'M');
X#else
X    if((my<(sy+4))&&(my>(sy-4))&&(mx<(sx+6))&&(mx>(sx-6)) || tinymode)
X        draw_symbol((mx-sx+5),(my-sy+3),'M');
X#endif
X    if(screen[my][mx] == '@')                     /* ha! gottim! */
X	{
X	strcpy(howdead,"a hungry monster");
X#ifndef XWANDER
X        move(16,0);
X	refresh();
X#endif
X        return(howdead);
X	}
X    screen[my][mx] = 'M';
X#ifndef XWANDER
X    move(16,0);
X    refresh();
X#endif
X    }
X
Xcurrent = monster = mon_ptr;
Xwhile((monster != NULL)&&(!deadyet))/* deal with those little monsters */
X    {
X    new_disp = new_direction(screen, monster->x, monster->y, monster->mx, monster->my );
X    screen[monster->y][monster->x] = monster->under;
X#ifndef XWANDER
X    if((monster->y < (sy+4)) && (monster->y > (sy-4)) && (monster->x < (sx+6)) && (monster->x > (sx-6)))
X        draw_symbol((monster->x-sx+5)*3,(monster->y-sy+3)*2,monster->under);
X#else
X    if((monster->y < (sy+4)) && (monster->y > (sy-4)) && (monster->x < (sx+6)) && (monster->x > (sx-6)) || tinymode)
X        draw_symbol((monster->x-sx+5),(monster->y-sy+3),monster->under);
X#endif
X    if(monster->under == ' ')
X		deadyet = deadyet | fall(&mx,&my,monster->x,monster->y,sx,sy,screen,howdead);
X    monster->mx = new_disp.d[0];
X    monster->my = new_disp.d[1];
X    monster->x += monster->mx;
X    monster->y += monster->my;
X    monster->under = screen[monster->y][monster->x];
X    screen[monster->y][monster->x] = 'S';        /* move into new space */
X#ifndef XWANDER
X    if((monster->y < (sy+4)) && (monster->y > (sy-4)) && (monster->x < (sx+6)) && (monster->x > (sx-6)))
X        draw_symbol((monster->x-sx+5)*3,(monster->y-sy+3)*2,'S');
X#else
X    if((monster->y < (sy+4)) && (monster->y > (sy-4)) && (monster->x < (sx+6)) && (monster->x > (sx-6)) || tinymode)
X        draw_symbol((monster->x-sx+5),(monster->y-sy+3),'S');
X#endif
X    if(monster->under == '@')                     /* monster hit you? */
X        {
X	strcpy(howdead,"the little monsters");
X#ifndef XWANDER
X	move(16,0);
X	refresh();
X#endif
X        return(howdead);
X        }
X    if(monster->under == '+')                    /* monster hit cage? */
X        {
X	*score +=20;
X	if(*bell)
X	    dobeep();
X        if(monster == mon_ptr)                  /* remove from chain */
X            mon_ptr = mon_ptr->next;
X  	else current->next = monster-> next;
X	screen[monster->y][monster->x] = '*';
X#ifndef XWANDER
X        if((monster->y < (sy+4)) && (monster->y > (sy-4)) && (monster->x < (sx+6)) && (monster->x > (sx-6)))
X                draw_symbol((monster->x-sx+5)*3,(monster->y-sy+3)*2,'*');
X#else
X        if((monster->y < (sy+4)) && (monster->y > (sy-4)) && (monster->x < (sx+6)) && (monster->x > (sx-6)) || tinymode)
X                draw_symbol((monster->x-sx+5),(monster->y-sy+3),'*');
X#endif
X        }
X    if(monster->under == 'S')
X	monster->under = ' ';
X    if(monster != mon_ptr)
X        current = current->next;
X    monster = monster->next;
X#ifdef GAMEDEV
Xif(deadyet != 0)
X    {
X#ifndef XWANDER
X    move(16,0);
X    addstr("You are dead, killed by ");
X    addstr(howdead);
X    addstr("\nPress any key to come back to life.");
X    refresh();
X    ch = getchar();
X    move(16,0);
X    addstr("                                                 \n");
X    addstr("                                                 ");
X    move(16,0);
X    refresh();
X    deadyet = 0;
X#else
X    erase_message(0);
X    erase_message(1);
X    message(0,"You are dead.  killed by %s.",howdead);
X    message(1,"Press any key to come back to life.");
X    (void)getchar(-1);
X    erase_message(0);
X    erase_message(1);
X    deadyet = 0;
X#endif
X    }
X
X#endif
X#ifndef XWANDER
X    move(16,0);
X    refresh();
X#endif
X    }
X
X}
Xreturn(howdead);
X}
END_OF_FILE
if test 19070 -ne `wc -c <'game.c'`; then
    echo shar: \"'game.c'\" unpacked with wrong size!
fi
# end of 'game.c'
fi
if test -f 'icon.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'icon.c'\"
else
echo shar: Extracting \"'icon.c'\" \(16377 characters\)
sed "s/^X//" >'icon.c' <<'END_OF_FILE'
X#include "wand_head.h"
X/* declare all of the pixmaps */
X
X#ifdef XWANDER
X
Xvoid paint_small_square();
Xextern playerfacing;
Xextern tinymode;
X/* first the 'large' pixmaps (64x64) */
XPixmap space_pm, wall_pm, larrow_pm, rarrow_pm, rock_pm, dirt_pm, fwdslide_pm, 
Xbackslide_pm, diamond_pm, brick_pm, playerl_pm, playerr_pm, wayout_pm, 
Xlandmine_pm, monster_pm, sprite_pm, timecapsule_pm, cage_pm, teleport_pm, 
Xwhoops_pm;
X
X/* the 'tiny' pixmaps (16x16) */
XPixmap space_tpm, wall_tpm, larrow_tpm, rarrow_tpm, rock_tpm, dirt_tpm, 
Xfwdslide_tpm, backslide_tpm, diamond_tpm, brick_tpm, player_tpm, wayout_tpm, 
Xlandmine_tpm, monster_tpm, sprite_tpm, timecapsule_tpm, cage_tpm, teleport_tpm, 
Xwhoops_tpm; 
X
Xint scorefonthigh, scorefonta, msgfonthigh, msgfonta, tablefonthigh, tablefonta;
Xint tablefontwide;
XXFontStruct *scorefont, *msgfont, *tablefont;
XGC scorefontgc, msgfontgc, linegc, tablegc;
X
X#endif
X
Xint do_repaint = 1;
X
X#ifndef XWANDER
Xvoid draw_symbol(x,y,ch)
Xint  x,y;
Xchar ch;
X{
X    char icon[2][4],
X         (*iconrow)[4] = icon;
X	
X    switch(ch)
X    {
X    case ' ':
X        strcpy((*iconrow++),"   ");
X        strcpy((*iconrow),"   ");
X        break;
X    case '#':
X        strcpy(*iconrow++,"###");
X        strcpy(*iconrow,"###");
X        break;
X    case '<':
X        strcpy(*iconrow++,"<--");
X        strcpy(*iconrow,"<--");
X        break;
X    case '>':
X        strcpy(*iconrow++,"-->");
X        strcpy(*iconrow,"-->");
X        break;
X    case 'O':
X        strcpy(*iconrow++,"/^\\");
X        strcpy(*iconrow,"\\_/");
X        break;
X    case ':':
X        strcpy(*iconrow++,". .");
X        strcpy(*iconrow," . ");
X        break;
X    case '/':
X        strcpy(*iconrow++," _/");
X        strcpy(*iconrow,"/  ");
X        break;
X    case '\\':
X        strcpy(*iconrow++,"\\_ ");
X        strcpy(*iconrow,"  \\");
X        break;
X    case '*':
X        strcpy(*iconrow++,"/$\\");
X        strcpy(*iconrow, "\\$/");
X        break;
X    case '=':
X        strcpy(*iconrow++,"=-=");
X        strcpy(*iconrow,  "-=-");
X        break;
X    case '@':
X        strcpy(*iconrow++," o ");
X        strcpy(*iconrow,  "<|>");
X        break;
X    case 'T':
X        strcpy(*iconrow++,"(*)");
X        strcpy(*iconrow,  "(*)");
X        break;
X    case 'X':
X        strcpy(*iconrow++,"Way");
X        strcpy(*iconrow,  "Out");
X        break;
X    case '!':
X        strcpy(*iconrow++," I ");
X        strcpy(*iconrow,  " o ");
X        break;
X    case 'M':
X        strcpy(*iconrow++,"}o{");
X        strcpy(*iconrow,  "/^\\");
X        break;
X    case 'S':
X        strcpy(*iconrow++,"-o-");
X        strcpy(*iconrow,  "/*\\");
X        break;
X    case 'C':
X        strcpy(*iconrow++,"   ");
X        strcpy(*iconrow,  "<O>");
X        break;
X    case '+':
X        strcpy(*iconrow++,"TTT");
X        strcpy(*iconrow,  "III");
X        break;
X    default:
X        strcpy(*iconrow++,"OOO");
X        strcpy(*iconrow,  "OOO");
X        break;
X    };
X    move(y+1,x+1);
X    iconrow--;
X    addstr(*iconrow++);
X    move(y+2,x+1);
X    addstr(*iconrow);
X}
X#else
X
XPixmap tiny_symbol_pixmap(), symbol_pixmap();
XGC symbol_gc();
X
Xvoid draw_symbol(x,y,ch)
Xint  x,y;
Xchar ch;
X{
X    Pixmap p = symbol_pixmap(ch);
X    GC g = symbol_gc(ch);
X    static int drawn[ROWLEN+1][NOOFROWS+1];
X
X    if (tinymode) { paint_small_square(x,y,ch); return; }
X    if (do_repaint) {
X	int i, j;
X	for (i = 0; i < ROWLEN; i++)
X	    for (j = 0; j < NOOFROWS+1; j++) 
X		drawn[i][j] = -1;
X	do_repaint = 0;
X    }
X
X    /* only paint area if we have to */
X    if (drawn[x][y] != ch) {
X	XCopyArea(dpy, p, win, g, 0, 0, ICON_WIDE, ICON_HIGH, 
X	    x * ICON_WIDE + 5, y * ICON_HIGH + 5);
X	drawn[x][y] = ch;
X    }
X}
X
XPixmap symbol_pixmap(ch)
Xint ch;
X{
X    Pixmap picture;
X
X    switch(ch) {
X    case ' ':
X	picture = space_pm;
X        break;
X    case '#':
X	picture = wall_pm;
X        break;
X    case '<':
X	picture = larrow_pm;
X        break;
X    case '>':
X	picture = rarrow_pm;
X        break;
X    case 'O':
X	picture = rock_pm;
X        break;
X    case ':':
X	picture = dirt_pm;
X        break;
X    case '/':
X	picture = fwdslide_pm;
X        break;
X    case '\\':
X	picture = backslide_pm;
X        break;
X    case '*':
X	picture = diamond_pm;
X        break;
X    case '=':
X	picture = brick_pm;
X        break;
X    case '@':
X	if (playerfacing == 1)
X	    picture = playerl_pm;
X	else
X	    picture = playerr_pm;
X        break;
X    case 'T':
X	picture = teleport_pm;
X        break;
X    case 'X':
X	picture = wayout_pm;
X        break;
X    case '!':
X	picture = landmine_pm;
X        break;
X    case 'M':
X	picture = monster_pm;
X        break;
X    case 'S':
X	picture = sprite_pm;
X        break;
X    case 'C':
X	picture = timecapsule_pm;
X        break;
X    case '+':
X	picture = cage_pm;
X        break;
X    default:
X	picture = brick_pm;
X        break;
X    }
X    return(picture);
X}
X
Xvoid paint_small_square(x,y,ch)
Xint  x,y;
Xchar ch;
X{
X    Pixmap p = tiny_symbol_pixmap(ch);
X    GC g = symbol_gc(ch);
X
X    x++;
X    y++;
X    if (ch == ' ' && !tinymode) return;
X    XCopyArea(dpy, p, win, g, 0, 0, SMALL_WIDE, SMALL_HIGH,
X	x * SMALL_WIDE + 13, y * SMALL_HIGH + 83);
X}
X
XPixmap tiny_symbol_pixmap(ch)
Xint ch;
X{
X    Pixmap picture;
X
X    switch(ch) {
X    case ' ':
X	picture = space_tpm;
X        break;
X    case '#':
X	picture = wall_tpm;
X        break;
X    case '<':
X	picture = larrow_tpm;
X        break;
X    case '>':
X	picture = rarrow_tpm;
X        break;
X    case 'O':
X	picture = rock_tpm;
X        break;
X    case ':':
X	picture = dirt_tpm;
X        break;
X    case '/':
X	picture = fwdslide_tpm;
X        break;
X    case '\\':
X	picture = backslide_tpm;
X        break;
X    case '*':
X	picture = diamond_tpm;
X        break;
X    case '=':
X	picture = brick_tpm;
X        break;
X    case '@':
X	picture = player_tpm;
X        break;
X    case 'T':
X	picture = teleport_tpm;
X        break;
X    case 'X':
X	picture = wayout_tpm;
X        break;
X    case '!':
X	picture = landmine_tpm;
X        break;
X    case 'M':
X	picture = monster_tpm;
X        break;
X    case 'S':
X	picture = sprite_tpm;
X        break;
X    case 'C':
X	picture = timecapsule_tpm;
X        break;
X    case '+':
X	picture = cage_tpm;
X        break;
X    default:
X	picture = brick_pm;
X        break;
X    }
X    return(picture);
X}
X
XGC symbol_gc(ch)
Xint ch;
X{
X    /* this should return an appropriate GC when color is added */
X    return(globgc);
X}
X
XPixmap MakePixmap(dpy, root, data ,width, height)
XDisplay *dpy;
XDrawable root;
Xshort *data;
Xunsigned int width, height;
X{
X
X    XImage ximage;
X    GC pgc;
X    XGCValues gcv;
X    Pixmap pid;
X
X    pid = XCreatePixmap(dpy,root,width,height,
X		DefaultDepth(dpy,DefaultScreen(dpy)));
X    
X    gcv.foreground = BlackPixel(dpy,DefaultScreen(dpy));
X    gcv.background = WhitePixel(dpy,DefaultScreen(dpy));
X
X    pgc = XCreateGC(dpy, pid, GCForeground | GCBackground, &gcv);
X    ximage.height = height;
X    ximage.width = width;
X    ximage.xoffset = 0;
X    ximage.format = XYBitmap;
X    ximage.data = (char *) data;
X    ximage.byte_order = LSBFirst;
X    ximage.bitmap_unit = 16;
X    ximage.bitmap_bit_order = LSBFirst;
X    ximage.bitmap_pad = 16;
X    ximage.bytes_per_line = (width + 15) / 16 * 2;
X    ximage.depth = 1;
X
X    XPutImage(dpy,pid,pgc,&ximage,0,0,0,0,width,height);
X
X    XFreeGC(dpy,pgc);
X    return(pid);
X}
X
X/* the big pixmaps */
X#include "icons/space_bm"
X#include "icons/wall_bm"
X#include "icons/larrow_bm"
X#include "icons/rarrow_bm"
X#include "icons/rock_bm"
X#include "icons/dirt_bm"
X#include "icons/fwdslide_bm"
X#include "icons/backslide_bm"
X#include "icons/diamond_bm"
X#include "icons/brick_bm"
X#include "icons/playerr_bm"
X#include "icons/playerl_bm"
X#include "icons/wayout_bm"
X#include "icons/landmine_bm"
X#include "icons/monster_bm"
X#include "icons/sprite_bm"
X#include "icons/timecapsule_bm"
X#include "icons/cage_bm"
X#include "icons/teleport_bm"
X#include "icons/whoops_bm"
X
X/* the tiny pixmaps */
X#include "icons/space_tbm"
X#include "icons/wall_tbm"
X#include "icons/larrow_tbm"
X#include "icons/rarrow_tbm"
X#include "icons/rock_tbm"
X#include "icons/dirt_tbm"
X#include "icons/fwdslide_tbm"
X#include "icons/backslide_tbm"
X#include "icons/diamond_tbm"
X#include "icons/brick_tbm"
X#include "icons/player_tbm"
X#include "icons/wayout_tbm"
X#include "icons/landmine_tbm"
X#include "icons/monster_tbm"
X#include "icons/sprite_tbm"
X#include "icons/timecapsule_tbm"
X#include "icons/cage_tbm"
X#include "icons/teleport_tbm"
X#include "icons/whoops_tbm"
X
Xbuild_pixmaps() 
X{
X    char *cp;
X
X    space_pm = MakePixmap(dpy, win, space_bm_bits, 64, 64);
X    wall_pm = MakePixmap(dpy, win, wall_bm_bits, 64, 64);
X    larrow_pm = MakePixmap(dpy, win, larrow_bm_bits, 64, 64);
X    rarrow_pm = MakePixmap(dpy, win, rarrow_bm_bits, 64, 64);
X    rock_pm = MakePixmap(dpy, win, rock_bm_bits, 64, 64);
X    dirt_pm = MakePixmap(dpy, win, dirt_bm_bits, 64, 64);
X    fwdslide_pm = MakePixmap(dpy, win, fwdslide_bm_bits, 64, 64);
X    backslide_pm = MakePixmap(dpy, win, backslide_bm_bits, 64, 64);
X    diamond_pm = MakePixmap(dpy, win, diamond_bm_bits, 64, 64);
X    brick_pm = MakePixmap(dpy, win, brick_bm_bits, 64, 64);
X    playerl_pm = MakePixmap(dpy, win, playerl_bm_bits, 64, 64);
X    playerr_pm = MakePixmap(dpy, win, playerr_bm_bits, 64, 64);
X    wayout_pm = MakePixmap(dpy, win, wayout_bm_bits, 64, 64);
X    landmine_pm = MakePixmap(dpy, win, landmine_bm_bits, 64, 64);
X    monster_pm = MakePixmap(dpy, win, monster_bm_bits, 64, 64);
X    sprite_pm = MakePixmap(dpy, win, sprite_bm_bits, 64, 64);
X    timecapsule_pm = MakePixmap(dpy, win, timecapsule_bm_bits, 64, 64);
X    cage_pm = MakePixmap(dpy, win, cage_bm_bits, 64, 64);
X    teleport_pm = MakePixmap(dpy, win, teleport_bm_bits, 64, 64);
X    whoops_pm = MakePixmap(dpy, win, whoops_bm_bits, 64, 64);
X
X    space_tpm = MakePixmap(dpy, win, space_tbm_bits, 16, 16);
X    wall_tpm = MakePixmap(dpy, win, wall_tbm_bits, 16, 16);
X    larrow_tpm = MakePixmap(dpy, win, larrow_tbm_bits, 16, 16);
X    rarrow_tpm = MakePixmap(dpy, win, rarrow_tbm_bits, 16, 16);
X    rock_tpm = MakePixmap(dpy, win, rock_tbm_bits, 16, 16);
X    dirt_tpm = MakePixmap(dpy, win, dirt_tbm_bits, 16, 16);
X    fwdslide_tpm = MakePixmap(dpy, win, fwdslide_tbm_bits, 16, 16);
X    backslide_tpm = MakePixmap(dpy, win, backslide_tbm_bits, 16, 16);
X    diamond_tpm = MakePixmap(dpy, win, diamond_tbm_bits, 16, 16);
X    brick_tpm = MakePixmap(dpy, win, brick_tbm_bits, 16, 16);
X    player_tpm = MakePixmap(dpy, win, player_tbm_bits, 16, 16);
X    wayout_tpm = MakePixmap(dpy, win, wayout_tbm_bits, 16, 16);
X    landmine_tpm = MakePixmap(dpy, win, landmine_tbm_bits, 16, 16);
X    monster_tpm = MakePixmap(dpy, win, monster_tbm_bits, 16, 16);
X    sprite_tpm = MakePixmap(dpy, win, sprite_tbm_bits, 16, 16);
X    timecapsule_tpm = MakePixmap(dpy, win, timecapsule_tbm_bits, 16, 16);
X    cage_tpm = MakePixmap(dpy, win, cage_tbm_bits, 16, 16);
X    teleport_tpm = MakePixmap(dpy, win, teleport_tbm_bits, 16, 16);
X    whoops_tpm = MakePixmap(dpy, win, whoops_tbm_bits, 16, 16);
X    /* build all of the GC's here too! */
X    globgc = XCreateGC(dpy, win, 0, 0);
X    XSetFunction(dpy, globgc, GXcopyInverted); 
X
X	/* create the message font gc and load the message font */
X    msgfontgc = XCreateGC(dpy, win, 0, 0);
X    XSetFunction(dpy, msgfontgc, GXcopyInverted);
X    linegc = XCreateGC(dpy, win, 0, 0);
X    XSetFunction(dpy, linegc, GXcopy);
X    XSetLineAttributes(dpy,linegc, 2, LineSolid, CapButt, JoinMiter);
X    cp = (char *)getenv("MSGFONT");
X    if (!cp) cp = "vr-20";
X    msgfont = XLoadQueryFont(dpy, cp);
X    if (msgfont == 0) {
X	fprintf(stderr,"Can't load (msgfont) %s.  Bye!\n",cp);
X	exit(1);
X    }
X    msgfonthigh = msgfont->max_bounds.ascent+msgfont->max_bounds.descent;
X    msgfonta = msgfont->max_bounds.ascent;
X    XSetFont(dpy, msgfontgc, msgfont->fid);
X
X    	/* create the highscore table gc and load the font */
X    tablegc = XCreateGC(dpy, win, 0, 0);
X    cp =(char *) getenv("TABLEFONT");
X    if (!cp) cp = "8x13bold";
X    tablefont = XLoadQueryFont(dpy, cp);
X    if (tablefont == 0) {
X	fprintf(stderr,"Can't load (tablefont) %s.  Bye!\n",cp);
X	exit(1);
X    }
X    tablefonthigh = tablefont->max_bounds.ascent+tablefont->max_bounds.descent;
X    tablefontwide = tablefont->max_bounds.width;
X    tablefonta = tablefont->max_bounds.ascent;
X    XSetFont(dpy, tablegc, tablefont->fid);
X
X	/* create the score font gc and load the score font */
X    scorefontgc = XCreateGC(dpy, win, 0, 0);
X    XSetFunction(dpy, scorefontgc, GXcopyInverted);
X    cp = (char*)getenv("SCOREFONT");
X    if (!cp) cp = "fcor-20";
X    scorefont = XLoadQueryFont(dpy,cp);
X    if (scorefont == 0) {
X	fprintf(stderr,"Can't load (scorefont).  Bye!\n");
X	exit(1);
X    }
X    scorefonthigh = scorefont->max_bounds.ascent+msgfont->max_bounds.descent;
X    scorefonta = msgfont->max_bounds.ascent;
X    XSetFont(dpy,scorefontgc, scorefont->fid);
X}
X
Xdisplay_monster(mx)
X{
X    Pixmap m = symbol_pixmap((mx != (-1) ? 'M' : ' ')); 
X    GC mgc = symbol_gc((mx != (-1) ? 'M' : ' ')); 
X    int x1 = ICON_WIDE * 12 + 54;
X    int x2 = x1 + (ICON_WIDE) + 6;
X    int y1 = scorefonthigh * 10 + 10;
X    int y2 = y1 + (ICON_HIGH) + 6;
X
X    XDrawLine(dpy, win, linegc, x1, y1, x2, y1);
X    XDrawLine(dpy, win, linegc, x2, y1, x2, y2);
X    XDrawLine(dpy, win, linegc, x2, y2, x1, y2);
X    XDrawLine(dpy, win, linegc, x1, y2, x1, y1);
X
X    XCopyArea(dpy, m, win, mgc, 0, 0, ICON_WIDE, ICON_HIGH,
X	x1 + 3, y1 + 3);
X    /* score_message(9,"   Monster Detector"); */
X}
X
X
Xtable_message(y,fmt,s1,s2,s3,s4,s5,s6,s7,s8)
Xchar *fmt,*s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8;
X{
X    char buf[256];
X
X    sprintf(buf,fmt,s1,s2,s3,s4,s5,s6,s7,s8);
X
X    XDrawImageString(dpy, win, tablegc,30,
X	(tablefonthigh*y)+10+tablefonta, buf, strlen(buf));
X}
X
Xmessage(y,fmt,s1,s2,s3,s4,s5,s6,s7,s8)
Xchar *fmt,*s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8;
X{
X    char buf[256];
X
X    sprintf(buf,fmt,s1,s2,s3,s4,s5,s6,s7,s8);
X
X    XDrawImageString(dpy, win, msgfontgc,5,
X	(msgfonthigh*y)+(ICON_HIGH*7)+20+msgfonta, buf, strlen(buf));
X}
X
Xerase_message(n)
X{
X    /* fprintf(stderr,"XClearArea: %d %d %d %d\n", 
X	5, (msgfonthigh*n)+(ICON_HIGH*7)+20,ICON_WIDE*11+10,msgfonthigh); */
X    XClearArea(dpy, win, 5, (msgfonthigh*n)+(ICON_HIGH*7)+20, 
X	ICON_WIDE * 11 + 10, msgfonthigh, 0);
X}
X
Xscore_message(y,fmt,s1,s2,s3,s4,s5,s6,s7,s8)
Xchar *fmt,*s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8;
X{
X    char buf[256];
X
X    sprintf(buf,fmt,s1,s2,s3,s4,s5,s6,s7,s8);
X
X    XDrawImageString(dpy, win, scorefontgc, ICON_WIDE*11+20,
X    scorefonthigh*y+10+scorefonta,
X	buf, strlen(buf));
X}
X
XXBeep()	/* There has to be a better way to do this.. */
X{
X     XFlush(dpy);  printf("\07");   fflush(stdout);  
X}
X
X/* takes over the standard getchar */
Xgetchar(sx, sy, frow, score, nf, diamonds, num, maxmoves, mx)
Xchar (*frow)[ROWLEN+1];
Xint *score;
X{
X    XEvent event, ev;
X    int i;
X    char buf[3];
X
X     /* printf("In getchar\n"); */
X
X    while (1) {
X    XNextEvent(dpy, &(event));
X	switch(event.type) {
X	case Expose:		
X	    if (event.xexpose.count != 0) {
X		/* fprintf(stderr,"xwanderer: %d expose events to follow\n",
X		    event.xexpose.count); */
X		/* XXX - anyone want to optimize this? */
X		/* what we do here is look at the number of expose
X		 * events that are supposed to follow this one 
X		 * and throw them away then we do a big redraw 
X		 */
X		for (i = 0; i < event.xexpose.count != 0; i++) {
X		    XPeekEvent(dpy, &(ev));	/* peek */
X		    if (ev.type != Expose)	/* is the event expose? */
X			break;			/* yep, we'll proc. later */
X		    XNextEvent(dpy,&ev);	/* nope, toss event */
X		}
X	    }
X	    if (sx != (-1)) { 
X		do_repaint = 1;
X	        if (!tinymode) 
X		    display(sx,sy,frow,*score);
X		else drawmap(frow,1);
X		
X	        repaint_score(*score, nf, diamonds, num, maxmoves, mx);
X	    }
X	    break;	
X	case KeyPress:
X	    buf[0] = 0;
X	    XLookupString(&(event), buf, 1, NULL, NULL);
X	    buf[1] = 0;
X	    /* printf("buf[0] = %c %d\n", buf[0], buf[0]); */
X	    if (buf[0] == 13) buf[0] = 10;
X	    if (buf[0] == 12) {
X		do_repaint = 1;
X		if (sx != (-1)) 
X		    if (tinymode) drawmap(frow,1); 
X		else 
X		    display(sx,sy,frow,*score); 
X	    } else if (buf[0] != 0) return(buf[0]);
X	    break;
X	}
X    }
X}
X
Xrepaint_score(score, nf, diamonds, num, maxmoves, mx)
X{
X    score_message(0,"Score       Diamonds");
X    score_message(1,"         Found   Total");
X    score_message(2,"%7d   %3d     %3d   ", score, nf, diamonds);
X    score_message(6,"Current Screen %d    ",num);
X    if (maxmoves != -1)
X	score_message(15,"Moves Remaining = %d     ", maxmoves);
X    else
X	score_message(15,"     Unlimited moves       ");
X    display_monster(mx);
X}
X#endif
END_OF_FILE
if test 16377 -ne `wc -c <'icon.c'`; then
    echo shar: \"'icon.c'\" unpacked with wrong size!
fi
# end of 'icon.c'
fi
if test ! -d 'icons' ; then
    echo shar: Creating directory \"'icons'\"
    mkdir 'icons'
fi
if test ! -d 'screens' ; then
    echo shar: Creating directory \"'screens'\"
    mkdir 'screens'
fi
echo shar: End of archive 1 \(of 5\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0