games@tekred.CNA.TEK.COM (02/15/89)
Submitted by: Dave Bodenstab <att!iwsl8!imdave>
Comp.sources.games: Volume 6, Issue 12
Archive-name: ega-wanderer/Part04
#! /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 4 (of 5)."
# Contents: 16x16.c Makefile display.c fall.c icons/48x48/backslide_bm
# icons/48x48/landmine_bm icons/48x48/teleport_bm icons/bmtoBM.c
# jump.c m.c save.c wand_head.h
# Wrapped by billr@saab on Tue Feb 14 15:28:02 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f '16x16.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'16x16.c'\"
else
echo shar: Extracting \"'16x16.c'\" \(5506 characters\)
sed "s/^X//" >'16x16.c' <<'END_OF_FILE'
X#include "bitmap.h"
X
Xstatic BM(16,16) arrival ={ 16, 16,
X 0x00, 0x00, 0x0f, 0xf8, 0x10, 0x04, 0x27, 0xf2, 0x48, 0x0a, 0x53, 0xea,
X 0x54, 0x2a, 0x55, 0xca, 0x55, 0x92, 0x54, 0x24, 0x53, 0xc8, 0x48, 0x10,
X 0x27, 0xe2, 0x10, 0x04, 0x0f, 0xf8, 0x00, 0x00, };
X
Xstatic BM(16,16) backslide ={ 16, 16,
X 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10, 0x00, 0x08, 0x00, 0x04, 0x00,
X 0x02, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x40, 0x00, 0x20, 0x00, 0x10,
X 0x00, 0x08, 0x00, 0x04, 0x00, 0x02, 0x00, 0x00, };
X
Xstatic BM(16,16) balloon ={ 16, 16,
X 0x00, 0x00, 0x03, 0xc0, 0x0c, 0x30, 0x10, 0x08, 0x10, 0x08, 0x20, 0x04,
X 0x20, 0x04, 0x20, 0x04, 0x20, 0x04, 0x10, 0x08, 0x10, 0x08, 0x0c, 0x30,
X 0x03, 0xce, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x00, };
X
Xstatic BM(16,16) brick ={ 16, 16,
X 0x77, 0x77, 0x5d, 0xdd, 0x3b, 0xbb, 0x6e, 0xee, 0x77, 0x77, 0x00, 0x00,
X 0xbb, 0x3b, 0xee, 0x6e, 0x77, 0x77, 0xdd, 0x5d, 0xbb, 0x3b, 0xee, 0x6e,
X 0x77, 0x77, 0x00, 0x00, 0x3b, 0xbb, 0x6e, 0xee, };
X
Xstatic BM(16,16) cage ={ 16, 16,
X 0x00, 0x00, 0xff, 0xfe, 0x49, 0x24, 0x49, 0x24, 0x49, 0x24, 0x49, 0x24,
X 0x4b, 0x24, 0x4b, 0x24, 0x4b, 0x24, 0x49, 0x24, 0x49, 0x24, 0x49, 0x24,
X 0x49, 0x24, 0x49, 0x24, 0xff, 0xfe, 0x00, 0x00, };
X
Xstatic BM(16,16) diamond ={ 16, 16,
X 0x00, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0x0f, 0xe0, 0x07, 0xc0, 0x02, 0x80,
X 0x07, 0xc0, 0x0f, 0xf0, 0x0e, 0xf0, 0x1c, 0x70, 0x1b, 0xf8, 0x3c, 0x78,
X 0x3f, 0xb8, 0x3c, 0x78, 0x3e, 0xf0, 0x1f, 0xf0, };
X
Xstatic BM(16,16) dirt ={ 16, 16,
X 0x88, 0x88, 0x22, 0x22, 0x4c, 0x44, 0x11, 0x31, 0x88, 0x08, 0x22, 0x02,
X 0x58, 0x5c, 0x11, 0x11, 0x88, 0x88, 0x22, 0x32, 0x54, 0x44, 0x10, 0x11,
X 0x88, 0xa8, 0x02, 0x22, 0x44, 0x44, 0x11, 0x11, };
X
Xstatic BM(16,16) fwdslide ={ 16, 16,
X 0x00, 0x00, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00, 0x10, 0x00, 0x20,
X 0x00, 0x40, 0x00, 0x80, 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00,
X 0x10, 0x00, 0x20, 0x00, 0x40, 0x00, 0x00, 0x00, };
X
Xstatic BM(16,16) landmine ={ 16, 16,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x14, 0x00, 0x00, 0x00,
X 0x17, 0x00, 0x00, 0xf8, 0x09, 0xc4, 0x00, 0xaa, 0x00, 0x92, 0x00, 0xaa,
X 0x00, 0x44, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, };
X
Xstatic BM(16,16) larrow ={ 16, 16,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x08, 0x0a, 0x10, 0x14, 0x3f, 0xfc, 0x10, 0x14, 0x08, 0x0a, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
X
Xstatic BM(16,16) monster ={ 16, 16,
X 0x00, 0x00, 0x0e, 0x00, 0x0a, 0xe0, 0x04, 0xa2, 0x44, 0x42, 0x4f, 0xe2,
X 0x5f, 0xf2, 0x5f, 0xf2, 0x7c, 0xfe, 0x1b, 0x60, 0x18, 0x60, 0x1f, 0xe0,
X 0x02, 0x40, 0x06, 0x40, 0x04, 0x40, 0x3c, 0x78, };
X
Xstatic BM(16,16) player ={ 16, 16,
X 0x00, 0x00, 0x01, 0x80, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x00, 0x00,
X 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xe0, 0x07, 0xe0, 0x03, 0xc0,
X 0x01, 0x80, 0x01, 0x80, 0x07, 0xe0, 0x00, 0x00, };
X
Xstatic BM(16,16) rarrow ={ 16, 16,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x08,
X 0x28, 0x04, 0x3f, 0xfe, 0x28, 0x04, 0x50, 0x08, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
X
Xstatic BM(16,16) rock ={ 16, 16,
X 0x00, 0x00, 0x01, 0xc0, 0x07, 0xf0, 0x1f, 0xf8, 0x37, 0xf6, 0x7f, 0xfa,
X 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfc, 0x37, 0xfc, 0x2b, 0xf8,
X 0x18, 0xf8, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, };
X
Xstatic BM(16,16) space ={ 16, 16,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
X
Xstatic BM(16,16) sprite ={ 16, 16,
X 0x00, 0x00, 0x3c, 0x04, 0x22, 0x4a, 0x01, 0x10, 0x08, 0xa8, 0x02, 0x20,
X 0x05, 0x44, 0x11, 0x10, 0x08, 0x88, 0x02, 0x60, 0x04, 0x60, 0x19, 0x10,
X 0x20, 0x88, 0x40, 0x08, 0x00, 0x18, 0x00, 0x00, };
X
Xstatic BM(16,16) teleport ={ 16, 16,
X 0x00, 0x00, 0x01, 0x00, 0x0f, 0xe0, 0x3f, 0xf8, 0x10, 0x10, 0x16, 0xd0,
X 0x16, 0xd0, 0x10, 0x10, 0x14, 0xd0, 0x10, 0x10, 0x16, 0xd0, 0x10, 0x10,
X 0x16, 0xd0, 0x10, 0x10, 0x3f, 0xf8, 0x00, 0x00, };
X
Xstatic BM(16,16) timecapsule ={ 16, 16,
X 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x04, 0x40, 0x09, 0x20,
X 0x11, 0x10, 0x11, 0xd0, 0x10, 0x10, 0x08, 0x20, 0x04, 0x40, 0x03, 0x80,
X 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, };
X
Xstatic BM(16,16) wall ={ 16, 16,
X 0xaa, 0xaa, 0x54, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xae, 0xba, 0x15, 0x55,
X 0xaa, 0xaa, 0x75, 0x55, 0xa8, 0xea, 0x55, 0x55, 0x8a, 0xa2, 0x55, 0x55,
X 0xaa, 0xa2, 0x75, 0xd5, 0xaa, 0xaa, 0x55, 0x55, };
X
Xstatic BM(16,16) wayout ={ 16, 16,
X 0x00, 0x00, 0x7f, 0xfe, 0x7f, 0xfe, 0x6f, 0xf6, 0x77, 0xee, 0x7b, 0xde,
X 0x7d, 0xbe, 0x7e, 0x7e, 0x7e, 0x7e, 0x7d, 0xbe, 0x7b, 0xde, 0x77, 0xee,
X 0x6f, 0xf6, 0x7f, 0xfe, 0x7f, 0xfe, 0x00, 0x00, };
X
Xstatic BM(16,16) whoops ={ 16, 16,
X 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x81, 0x81, 0x82, 0x41, 0x80, 0x41,
X 0x81, 0x99, 0x80, 0x25, 0x99, 0x05, 0xa4, 0x19, 0x84, 0x01, 0x98, 0x11,
X 0x80, 0x01, 0x90, 0x01, 0x80, 0x01, 0xff, 0xff, };
X
Xbitmap *b16x16[] ={ (bitmap*) &backslide, (bitmap*) &balloon,
X (bitmap*) &brick, (bitmap*) &cage,
X (bitmap*) &diamond, (bitmap*) &dirt,
X (bitmap*) &fwdslide, (bitmap*) &landmine,
X (bitmap*) &larrow, (bitmap*) &monster,
X (bitmap*) &player, (bitmap*) &rarrow,
X (bitmap*) &rock, (bitmap*) &space,
X (bitmap*) &sprite, (bitmap*) &teleport,
X (bitmap*) &timecapsule, (bitmap*) &wall,
X (bitmap*) &wayout, (bitmap*) &whoops,
X (bitmap*) &arrival, };
END_OF_FILE
if test 5506 -ne `wc -c <'16x16.c'`; then
echo shar: \"'16x16.c'\" unpacked with wrong size!
fi
# end of '16x16.c'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(1430 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile for wanderer
X
XCURSESO = m.o save.o jump.o display.o icon.o game.o read.o help.o fall.o \
X scores.o edit.o
XEGAO = 159x174.o 16x16.o 48x48.o iAPX286.o
X
X# For the EGA version, use the following
XEGA = -DEGA
XOBJ = $(CURSESO) $(EGAO)
XMODEL = -Ml
XSTACK =
X
X# If you just want the curses version, then use
X#EGA =
X#OBJ = $(CURSESO)
X#MODEL =
X#STACK = -k 0x4000
X
X# You're on your own here...
XG = #-g
XO = -O
XS = -s
XCFLAGS = $(MODEL) $G $O $(EGA)
XLDFLAGS = $(MODEL) $G $S $(STACK)
XLIBS = -lcurses
X
XDEST = /usr/games
XSCORE = $(DEST)/lib/.wanderer
XSCREENS = $(DEST)/lib/wanderer
X
Xwanderer: $(OBJ)
X $(CC) $(LDFLAGS) -o wanderer $(OBJ) $(LIBS)
X
Xinstall: wanderer
X cpset wanderer $(DEST) 2755 # sgid
X touch $(SCORE) # score file
X chmod 660 $(SCORE)
X cp screens/screen.[1-9]* $(SCREENS) # screens
X
Xclean:
X rm -f *.o core tags
Xclobber: clean
X rm -f wanderer
X
Xdepend:
X mkdepend -mMakefile *.c
X
X# DO NOT DELETE THIS LINE - make depend DEPENDS ON IT
X# Dependencies generated at: Mon Jan 2 12:08:35 CST 1989
X
Xm.o: bitmap.h wand_head.h
Xsave.o: wand_head.h
Xjump.o: wand_head.h
Xdisplay.o: bitmap.h wand_head.h
Xicon.o: bitmap.h wand_head.h
Xgame.o: bitmap.h wand_head.h
Xread.o: wand_head.h
Xhelp.o: wand_head.h
Xfall.o: bitmap.h wand_head.h
Xscores.o: wand_head.h
Xedit.o: bitmap.h wand_head.h
X159x174.o: bitmap.h
X16x16.o: bitmap.h
X48x48.o: bitmap.h
XiAPX286.o: bitmap.h
X
X# DO NOT ADD ANYTHING HERE - WILL GO AWAY
END_OF_FILE
if test 1430 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'display.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'display.c'\"
else
echo shar: Extracting \"'display.c'\" \(5616 characters\)
sed "s/^X//" >'display.c' <<'END_OF_FILE'
X#include "wand_head.h"
X
X#ifdef EGA
X#include "bitmap.h"
X
Xextern bitmap *b48x48[];
Xextern bitmap *b16x16[];
Xextern char *EGAaddr;
Xint EGAmode;
X
Xvoid egamap();
X#endif
X
Xextern int debug_disp;
Xextern char (*screen)[ROWLEN+1+1];
X
X
X/*
X * Draw the complete map
X */
Xvoid map()
X{
Xint x,y;
Xchar ch;
Xchar (*row_ptr)[ROWLEN+1+1] = screen;
X
X#ifdef EGA
Xif(EGAaddr) {
X egamap();
X return;
X }
X#endif
X
Xmvaddch(0,0,'+');
Xfor(x = 0;x < ROWLEN; x++)
X addch('-');
Xaddch('+');
Xfor(y = 0;y < NOOFROWS; y++)
X {
X mvaddch(y+1,0,'|');
X for(x = 0; x < ROWLEN; x++)
X {
X ch = (*row_ptr)[x];
X if(!debug_disp)
X {
X if((ch == 'M')||(ch == 'S'))
X ch = ' ';
X addch(ch);
X }
X else
X if(ch==' '||ch=='#'||ch=='<'||ch=='>'||ch=='O'||ch==':'||
X ch=='/'||ch=='\\'||ch=='*'||ch=='='||ch=='@'||ch=='T'||
X ch=='X'||ch=='!'||ch=='M'||ch=='S'||ch=='C'||ch=='+'||
X ch=='A'||ch=='^')
X addch(ch);
X else
X addch('"');
X }
X addch('|');
X row_ptr++;
X }
Xmvaddch(y+1,0,'+');
Xfor(x = 0;x < ROWLEN; x++)
X addch('-');
Xaddch('+');
Xif(!debug_disp)
X {
X mvaddstr(18,0,"Press any key to return to the game.");
X refresh();
X (void) getch();
X mvaddstr(18,0," ");
X refresh();
X for(y=0;y<=(NOOFROWS+1);y++)
X {
X move(y,0);
X for(x=0;x<=(ROWLEN+2);x++)
X addch(' ');
X }
X }
Xelse
X refresh();
X}
X
X#ifdef EGA
Xstatic void egamap()
X{
Xint x,y;
Xbitmap *map;
Xchar ch;
Xchar (*row_ptr)[ROWLEN+1+1] = screen;
X
XClear();
XEGAmode = 16;
X
Xfor(y = 0;y < NOOFROWS; y++)
X {
X for(x = 0; x < ROWLEN; x++)
X {
X map = b16x16[ symbol( ch = (*row_ptr)[x] ) ];
X
X if(!debug_disp)
X {
X if((ch == 'M')||(ch == 'S'))
X map = b16x16[ SPACE ];
X }
X egapaint( x * map->width, y * map->height, map );
X }
X row_ptr++;
X }
X
Xegaline( 0, NOOFROWS * map->height, ROWLEN * map->width - 1, NOOFROWS * map->height );
X
Xif(!debug_disp)
X {
X egaputs(4,341,"Press any key to return to the game.");
X (void) Getch();
X egaclear(4,341,639,349);
X }
X}
X#endif
X
X
X/*
X * Draw the map centered on (cx,cy)
X */
Xvoid display(cx,cy)
Xint cx,cy;
X{
X int x,y = 0,x_coord,y_coord;
X char (*row_ptr)[ROWLEN+1+1] = screen;
X
X while(y<(cy-3))
X {
X y++;
X row_ptr++;
X }
X
X#ifdef EGA
X if(EGAaddr) {
X egabox( 0, 0, 4+11*48+3, 4+7*48+3 );
X egabox( 1, 1, 4+11*48+2, 4+7*48+2 );
X }
X else
X#endif
X {
X mvaddstr(0,0,"+---------------------------------+");
X mvaddstr(15,0,"+---------------------------------+");
X }
X
X for(y=(cy-3);y<=(cy+3);y++) {
X y_coord = (y+3-cy)*2;
X
X if ((y<0) || (y>=NOOFROWS)) {
X#ifdef EGA
X if(EGAaddr) {
X for( x = 0; x <= 10; ++x )
X draw_symbol( x * 3, y_coord, '#' );
X }
X else
X#endif
X {
X mvaddstr(y_coord+1,0,"|#################################|");
X mvaddstr(y_coord+2,0,"|#################################|");
X }
X }
X else {
X#ifdef EGA
X if(!EGAaddr)
X#endif
X {
X mvaddch(y_coord+1,0,'|');
X mvaddch(y_coord+1,34,'|');
X mvaddch(y_coord+2,0,'|');
X mvaddch(y_coord+2,34,'|');
X }
X
X for(x=(cx-5);x<=(cx+5);x++)
X {
X x_coord = (x+5-cx)*3;
X if ((x<0) || (x>ROWLEN-1))
X draw_symbol(x_coord,y_coord,'#');
X else
X draw_symbol(x_coord,y_coord,(*row_ptr)[x]);
X }
X row_ptr++;
X } /* end if */
X } /* end y loop */
X
X#ifdef EGA
X if(!EGAaddr)
X#endif
X {
X move(16,0);
X refresh();
X }
X}
X
Xvoid redraw_screen(maxmoves,num,score,nf,diamonds,mx,sx,sy)
Xint *maxmoves,num,nf,diamonds,mx,sx,sy;
Xlong score;
X{
X#ifdef EGA
Xif(EGAaddr) {
X EGAmode = 0;
X
X if(!debug_disp) {
X
X Clear();
X
X egaprintf( 540, 4, "Score %ld", score );
X
X egaputs( 540,24, "Diamonds" );
X egaprintf( 540,34, " found %3d", nf );
X egaprintf( 540,44, " total %3d", diamonds );
X
X egaprintf( 540,64, "Screen %d", num );
X
X if(*maxmoves > 0)
X egaprintf( 540,84, "Moves %6d", *maxmoves );
X else
X *maxmoves = -1;
X
X if(mx != -1) /* tell player if monster exists */
X egapaint( 566,130, b48x48[MONSTER] );
X
X display(sx,sy);
X }
X else
X {
X map();
X
X egaputs( 4,274, "Score" );
X egaprintf( 4,284, "%ld", score );
X
X egaprintf( 4+10*8,270, " Diamonds Current screen %d", num );
X egaputs( 4+10*8,279, "found total" );
X egaprintf( 4+10*8,288, " %3d %3d", nf, diamonds );
X
X if(*maxmoves > 0)
X egaprintf( 4+28*8,288, "Remaining moves %6d", *maxmoves );
X else
X *maxmoves = -1;
X
X if(mx != -1) /* tell player if monster exists */
X egapaint( 480,289, b48x48[MONSTER] );
X }
X }
Xelse
X#endif
X {
X clear();
X mvaddstr(0,48,"Score\t Diamonds");
X mvaddstr(1,48,"\tFound\tTotal");
X mvprintw(3,48,"%ld\t %d\t %d ",score,nf,diamonds);
X mvprintw(6,48,"Current screen %d",num);
X if(*maxmoves > 0)
X mvprintw(15,48,"Moves remaining = %d ",*maxmoves);
X else {
X mvaddstr(15,48," Unlimited moves ");
X *maxmoves = -1;
X }
X if(mx != -1) /* tell player if monster exists */
X draw_symbol(48,10,'M');
X else
X draw_symbol(48,10,' ');
X if(!debug_disp)
X display(sx,sy);
X else
X map();
X }
X}
X
X
X/*
X * Update score
X */
Xvoid
Xupdate_score(score,nf,diamonds)
Xlong score;
X{
X#ifdef EGA
Xif(EGAaddr) {
X if(debug_disp) {
X egaprintf( 4,284, "%-6ld", score );
X egaprintf( 4+10*8,288, " %3d %3d", nf, diamonds );
X }
X else {
X egaprintf( 540, 4, "Score %-6ld", score );
X egaprintf( 540,34, " found %3d", nf );
X egaprintf( 540,44, " total %3d", diamonds );
X }
X }
Xelse
X#endif
X mvprintw(3,48,"%ld\t %d\t %d ",score,nf,diamonds);
X}
END_OF_FILE
if test 5616 -ne `wc -c <'display.c'`; then
echo shar: \"'display.c'\" unpacked with wrong size!
fi
# end of 'display.c'
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'\" \(7429 characters\)
sed "s/^X//" >'fall.c' <<'END_OF_FILE'
X#include "wand_head.h"
X#ifdef EGA
X#include "bitmap.h"
X
Xextern bitmap *b16x16[];
Xextern char *EGAaddr;
X#endif
Xextern int debug_disp;
Xextern char (*screen)[ROWLEN+1+1];
Xextern void draw_symbol();
X
Xint check(mx,my,x,y,dx,dy,sx,sy,howdead)
X/* check for any falling caused by something moving out of x,y along
X vector dx,dy. All the others are constant and should really have
X been global... */
Xint x,y,sx,sy,dx,dy, *mx, *my;
Xchar howdead[25];
X{
Xint ret=0;
Xret+=fall(mx,my,x,y,sx,sy,howdead);
Xret+=fall(mx,my,x-dx,y-dy,sx,sy,howdead);
Xret+=fall(mx,my,x-dy,y-dx,sx,sy,howdead);
Xret+=fall(mx,my,x+dy,y+dx,sx,sy,howdead);
Xret+=fall(mx,my,x-dx-dy,y-dy-dx,sx,sy,howdead);
Xret+=fall(mx,my,x-dx+dy,y-dy+dx,sx,sy,howdead);
Xreturn ret;
X}
X
Xint fall(mx,my,x,y,sx,sy,howdead) /* recursive function for falling */
X /* boulders and arrows */
Xint x,y,sx,sy, *mx, *my;
Xchar howdead[25];
X{
Xint nx = x,nxu = x,nyl = y,nyr = y,retval = 0;
Xif ((y>(NOOFROWS-1))||(y<0)||(x<0)||(x>(ROWLEN-1)))
X return(0);
Xif((screen[y][x] != 'O') && (screen[y][x] != ' ') && (screen[y][x] != 'M') &&
X (screen[y][x] !='\\') && (screen[y][x] != '/') && (screen[y][x] != '@') &&
X (screen[y][x] != '^'))
X return(0);
Xif(screen[y][x] == 'O') {
X if((screen[y][x-1] == ' ') && (screen[y-1][x-1] == ' '))
X nx--;
X else {
X if((screen[y][x+1] == ' ') && (screen[y-1][x+1] == ' '))
X nx++;
X else
X nx = -1;
X }
X if((screen[y][x-1] == ' ') && (screen[y+1][x-1] == ' '))
X nxu--;
X else {
X if((screen[y][x+1] == ' ') && (screen[y+1][x+1] == ' '))
X nxu++;
X else
X nxu = -1;
X }
X if((screen[y-1][x] == ' ') && (screen[y-1][x+1] == ' '))
X nyr--;
X else {
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 if((screen[y+1][x] == ' ') && (screen[y+1][x-1] == ' '))
X nyl++;
X else
X nyl = -1;
X }
X }
Xif(screen[y][x] == '\\') {
X if(screen[y-1][++nx] != ' ')
X nx = -1;
X if(screen[y+1][--nxu] != ' ')
X nxu = -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 if(screen[y-1][--nx] != ' ')
X nx = -1;
X if(screen[y+1][++nxu] != ' ')
X nxu = -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] != 'M'))
X nx = -1;
Xif((screen[y-1][x] == 'O') && (nx >= 0) && (y > 0) &&
X (screen[y][nx] != '^')) /* boulder falls ? */
X {
X screen[y-1][x] = ' ';
X if(screen[y][nx] == '@') {
X strcpy(howdead,"a falling boulder");
X retval=1;
X }
X if(screen[y][nx] == 'M') {
X *mx = *my = -2;
X screen[y][nx] = ' ';
X }
X screen[y][nx] = 'O';
X if(!debug_disp) {
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 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 }
X else {
X#ifdef EGA
X if(EGAaddr) {
X bitmap *map;
X map = b16x16[SPACE];
X egapaint( x * map->width, (y-1) * map->height, map );
X map = b16x16[ROCK];
X egapaint( nx * map->width, y * map->height, map );
X }
X else
X#endif
X {
X move(y,x+1);
X addch(' ');;
X move(y+1,nx+1);
X addch('O');
X }
X }
X refresh();
X retval+=fall(mx,my,nx ,y+1,sx,sy,howdead);
X retval+=check(mx,my,x,y-1,0,1,sx,sy,howdead);
X if(screen[y+1][nx] == '@') {
X strcpy(howdead,"a falling boulder");
X return(1);
X }
X if(screen[y+1][nx] == 'M')
X {
X *mx = *my = -2;
X screen[y+1][nx] = ' ';
X }
X }
Xif((screen[nyr][x] != '^')&&(screen[nyr][x] != ' ')&&(screen[nyr][x] != 'M'))
X nyr = -1;
Xif((screen[y][x+1] == '<')&&(nyr>=0)&&(x+1<ROWLEN)) /* arrow moves ( < ) ? */
X {
X screen[y][x+1] = ' ';
X if(screen[nyr][x] == '@')
X {
X strcpy(howdead,"a speeding arrow");
X retval = 1;
X }
X if(screen[nyr][x] == 'M')
X {
X *mx = *my = -2;
X screen[nyr][x] = ' ';
X }
X screen[nyr][x] = '<';
X if(!debug_disp)
X {
X if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+5)) && (x>(sx-7)))
X draw_symbol((x-sx+6)*3,(y-sy+3)*2,' ');
X if((nyr<(sy+4)) && (nyr>(sy-4)) && (x<(sx+6)) && (x>(sx-6)))
X draw_symbol((x-sx+5)*3,(nyr-sy+3)*2,'<');
X }
X else
X {
X#ifdef EGA
X if(EGAaddr) {
X bitmap *map;
X map = b16x16[SPACE];
X egapaint( (x+1) * map->width, y * map->height, map );
X map = b16x16[LARROW];
X egapaint( x * map->width, nyr * map->height, map );
X }
X else
X#endif
X {
X move(y+1,x+2);
X addch(' ');
X move(nyr+1,x+1);
X addch('<');
X }
X }
X refresh();
X retval+=fall(mx,my,x-1,nyr,sx,sy,howdead);
X retval+=check(mx,my,x+1,y,-1,0,sx,sy,howdead);
X if(screen[nyr][x-1] == '@')
X {
X strcpy(howdead,"a speeding arrow");
X return(1);
X }
X if(screen[nyr][x-1] == 'M')
X {
X *mx = *my = -2;
X screen[nyr][x-1] = ' ';
X }
X }
Xif((screen[nyl][x] != ' ')&&(screen[nyl][x] != '^')&&(screen[nyl][x] != 'M'))
X nyl = -1;
Xif((screen[y][x-1] == '>')&&(nyl>=0)&&(x>0)) /* arrow moves ( > ) ? */
X {
X screen[y][x-1] = ' ';
X if(screen[nyl][x] == '@')
X {
X strcpy(howdead,"a speeding arrow");
X retval = 1;
X }
X if(screen[nyl][x] == 'M')
X {
X *mx = *my = -2;
X screen[nyl][x] = ' ';
X }
X screen[nyl][x] = '>';
X if(!debug_disp)
X {
X if((y<(sy+4)) && (y>(sy-4)) && (x<(sx+7)) && (x>(sx-5)))
X draw_symbol((x-sx+4)*3,(y-sy+3)*2,' ');
X if((nyl<(sy+4)) && (nyl>(sy-4)) && (x<(sx+6)) && (x>(sx-6)))
X draw_symbol((x-sx+5)*3,(nyl-sy+3)*2,'>');
X }
X else
X {
X#ifdef EGA
X if(EGAaddr) {
X bitmap *map;
X map = b16x16[SPACE];
X egapaint( (x-1) * map->width, y * map->height, map );
X map = b16x16[RARROW];
X egapaint( x * map->width, nyl * map->height, map );
X }
X else
X#endif
X {
X move(y+1,x);
X addch(' ');
X move(nyl+1,x+1);
X addch('>');
X }
X }
X refresh();
X retval+=fall(mx,my,x+1,nyl,sx,sy,howdead);
X retval+=check(mx,my,x-1,y,1,0,sx,sy,howdead);
X if(screen[nyl][x+1] == '@')
X {
X strcpy(howdead,"a speeding arrow");
X return(1);
X }
X if(screen[nyl][x+1] == 'M')
X {
X *mx = *my = -2;
X screen[nyl][x+1] = ' ';
X }
X }
Xif(screen[y][nxu] != ' ')
X nxu = -1;
Xif((screen[y+1][x] == '^') && (nxu >= 0) && (y < NOOFROWS) &&
X (screen[y][x] != '^')) /* balloon rises? */
X {
X screen[y+1][x] = ' ';
X screen[y][nxu] = '^';
X if(!debug_disp)
X {
X if((y<(sy+3)) && (y>(sy-5)) && (x>(sx-6)) && (x<(sx+6)))
X draw_symbol((x-sx+5)*3,(y-sy+4)*2,' ');
X if((y<(sy+4)) && (y>(sy-4)) && (nxu>(sx-6)) && (nxu<(sx+6)))
X draw_symbol((nxu-sx+5)*3,(y-sy+3)*2,'^');
X }
X else
X {
X#ifdef EGA
X if(EGAaddr) {
X bitmap *map;
X map = b16x16[SPACE];
X egapaint( x * map->width, (y+1) * map->height, map );
X map = b16x16[BALLOON];
X egapaint( nxu * map->width, y * map->height, map );
X }
X else
X#endif
X {
X move(y+2,x+1);
X addch(' ');
X move(y+1,nxu+1);
X addch('^');
X }
X }
X refresh();
X retval+=fall(mx,my,nxu ,y-1,sx,sy,howdead);
X retval+=check(mx,my,x,y+1,0,-1,sx,sy,howdead);
X }
Xif(retval>0)
X return(1);
Xreturn(0);
X}
END_OF_FILE
if test 7429 -ne `wc -c <'fall.c'`; then
echo shar: \"'fall.c'\" unpacked with wrong size!
fi
# end of 'fall.c'
fi
if test -f 'icons/48x48/backslide_bm' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'icons/48x48/backslide_bm'\"
else
echo shar: Extracting \"'icons/48x48/backslide_bm'\" \(1899 characters\)
sed "s/^X//" >'icons/48x48/backslide_bm' <<'END_OF_FILE'
X#define backslide_bm_width 48
X#define backslide_bm_height 48
Xstatic char backslide_bm_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00,
X 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00,
X 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00,
X 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
X 0x00, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03,
X 0x00, 0x00, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
END_OF_FILE
if test 1899 -ne `wc -c <'icons/48x48/backslide_bm'`; then
echo shar: \"'icons/48x48/backslide_bm'\" unpacked with wrong size!
fi
# end of 'icons/48x48/backslide_bm'
fi
if test -f 'icons/48x48/landmine_bm' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'icons/48x48/landmine_bm'\"
else
echo shar: Extracting \"'icons/48x48/landmine_bm'\" \(1896 characters\)
sed "s/^X//" >'icons/48x48/landmine_bm' <<'END_OF_FILE'
X#define landmine_bm_width 48
X#define landmine_bm_height 48
Xstatic char landmine_bm_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00,
X 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x20, 0x14, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x01, 0x00, 0x00, 0x00, 0x00,
X 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x91, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x01, 0x00, 0x00, 0x00,
X 0x00, 0x09, 0x01, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x01, 0x00, 0x00, 0x00,
X 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x10, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xe0, 0x01, 0xfc, 0x7f, 0x00,
X 0x00, 0x00, 0xf2, 0x1e, 0xf0, 0x00, 0x00, 0x00, 0x9c, 0x07, 0xc0, 0x03,
X 0x00, 0x00, 0x8c, 0x00, 0x00, 0x06, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x1c,
X 0x00, 0x00, 0x66, 0x00, 0x00, 0x38, 0x00, 0x00, 0x3c, 0xb6, 0x6d, 0x33,
X 0x00, 0x00, 0xb8, 0x14, 0x45, 0x31, 0x00, 0x00, 0x30, 0x08, 0x82, 0x30,
X 0x00, 0x00, 0xb0, 0x14, 0x45, 0x31, 0x00, 0x00, 0x30, 0xb6, 0x6d, 0x33,
X 0x00, 0x00, 0xb0, 0x00, 0x00, 0x30, 0x00, 0x00, 0x60, 0x01, 0x00, 0x30,
X 0x00, 0x00, 0xe0, 0x01, 0x00, 0x18, 0x00, 0x00, 0x80, 0x06, 0x00, 0x0e,
X 0x00, 0x00, 0x80, 0xb9, 0x1d, 0x07, 0x00, 0x00, 0x00, 0xf7, 0xf3, 0x03,
X 0x00, 0x00, 0x00, 0x1e, 0xf8, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x0f, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
END_OF_FILE
if test 1896 -ne `wc -c <'icons/48x48/landmine_bm'`; then
echo shar: \"'icons/48x48/landmine_bm'\" unpacked with wrong size!
fi
# end of 'icons/48x48/landmine_bm'
fi
if test -f 'icons/48x48/teleport_bm' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'icons/48x48/teleport_bm'\"
else
echo shar: Extracting \"'icons/48x48/teleport_bm'\" \(1896 characters\)
sed "s/^X//" >'icons/48x48/teleport_bm' <<'END_OF_FILE'
X#define teleport_bm_width 48
X#define teleport_bm_height 48
Xstatic char teleport_bm_bits[] = {
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00,
X 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x3f, 0x00,
X 0x00, 0x54, 0x55, 0x55, 0x55, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x03,
X 0x80, 0x55, 0x55, 0x55, 0x55, 0x03, 0x80, 0xff, 0xff, 0xff, 0xff, 0x03,
X 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x06, 0x00, 0x00, 0xc0, 0x00,
X 0x00, 0x72, 0x77, 0xdd, 0x9d, 0x00, 0x00, 0x76, 0x77, 0xdc, 0xdd, 0x00,
X 0x00, 0x02, 0x00, 0x01, 0x80, 0x00, 0x00, 0x76, 0x77, 0xdc, 0xdd, 0x00,
X 0x00, 0x72, 0x77, 0xdd, 0x9d, 0x00, 0x00, 0x06, 0x00, 0x00, 0xc0, 0x00,
X 0x00, 0xaa, 0xaa, 0xab, 0xaa, 0x00, 0x00, 0x56, 0x55, 0x55, 0xd5, 0x00,
X 0x00, 0xaa, 0xaa, 0x0b, 0xa0, 0x00, 0x00, 0x16, 0x50, 0xa5, 0xd2, 0x00,
X 0x00, 0x2a, 0xa0, 0x4b, 0xa5, 0x00, 0x00, 0x16, 0x50, 0xa5, 0xd2, 0x00,
X 0x00, 0x2a, 0xa0, 0x4b, 0xa5, 0x00, 0x00, 0x16, 0x50, 0xa5, 0xd2, 0x00,
X 0x00, 0x2a, 0xa0, 0x4b, 0xa5, 0x00, 0x00, 0x56, 0x55, 0x05, 0xd0, 0x00,
X 0x00, 0xaa, 0xaa, 0xab, 0xaa, 0x00, 0x00, 0x56, 0x55, 0x55, 0xd5, 0x00,
X 0x00, 0x0a, 0xa0, 0x0b, 0xa0, 0x00, 0x00, 0x46, 0x45, 0xa5, 0xd2, 0x00,
X 0x00, 0xaa, 0xaa, 0x4b, 0xa5, 0x00, 0x00, 0x46, 0x45, 0xa5, 0xd2, 0x00,
X 0x00, 0x0a, 0xa0, 0x0b, 0xa0, 0x00, 0x00, 0x56, 0x55, 0x55, 0xd5, 0x00,
X 0x00, 0xaa, 0xaa, 0xab, 0xaa, 0x00, 0x00, 0x06, 0x40, 0x05, 0xd0, 0x00,
X 0x00, 0xaa, 0xaa, 0x4b, 0xa5, 0x00, 0x00, 0x46, 0x45, 0xa5, 0xd2, 0x00,
X 0x00, 0xaa, 0xaa, 0x4b, 0xa5, 0x00, 0x00, 0x06, 0x40, 0x05, 0xd0, 0x00,
X 0x00, 0xaa, 0xaa, 0xab, 0xaa, 0x00, 0x80, 0xff, 0xff, 0xff, 0xff, 0x03,
X 0x80, 0xaa, 0xaa, 0xaa, 0xaa, 0x02, 0x80, 0xff, 0xff, 0xff, 0xff, 0x03,
X 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
END_OF_FILE
if test 1896 -ne `wc -c <'icons/48x48/teleport_bm'`; then
echo shar: \"'icons/48x48/teleport_bm'\" unpacked with wrong size!
fi
# end of 'icons/48x48/teleport_bm'
fi
if test -f 'icons/bmtoBM.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'icons/bmtoBM.c'\"
else
echo shar: Extracting \"'icons/bmtoBM.c'\" \(2231 characters\)
sed "s/^X//" >'icons/bmtoBM.c' <<'END_OF_FILE'
X/*
X * bmtoBM file...
X *
X * Converts X windows (I think) bitmaps to the bitmap format used by
X * the EGA version of the wanderer game.
X */
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X
X#define MAXBITS 200
X
Xtypedef unsigned char uchar;
X
Xtypedef struct {
X int width, height;
X uchar bits[MAXBITS*MAXBITS/8];
X } bitmap;
X
Xextern bitmap readmap();
X
Xvoid
Xusage( name )
Xchar *name;
X {
X fprintf( stderr, "Usage:\t%s files...\n", name );
X exit( 1 );
X }
X
Xmain( argc, argv )
Xchar **argv;
X {
X bitmap map;
X
X if ( argc <= 1 )
X usage( argv[0] );
X
X while( ++argv, --argc > 0 )
X writemap( *argv, &readmap(*argv) );
X }
X
X
X bitmap
Xreadmap( file )
Xchar *file;
X {
X FILE *fp;
X int i, j, width, height;
X bitmap map;
X
X fp = fopen( file, "r" );
X
X fscanf( fp, "#define %*s %d\n", &width );
X fscanf( fp, "#define %*s %d\n", &height );
X
X for( i = 0; i < height; ++i )
X for( j = 0; j < (width+7)/8; ++j )
X map.bits[i*((width+7)/8)+j] = byte( fp );
X fclose( fp );
X
X map.width = width;
X map.height = height;
X
X return( map );
X }
X
X int
Xbyte( fp )
XFILE *fp;
X {
X unsigned b, x, y;
X
X for( ; ; )
X if ( getc(fp) == '0' && getc(fp) == 'x' )
X {
X fscanf( fp, "%x", &x );
X
X for( b = 0x80, y = 0; b != 0; b >>= 1, y >>= 1 )
X if ( x & b )
X y |= 0x100;
X
X return( y );
X }
X }
X
X
Xwritemap( file, map )
Xchar *file;
Xbitmap *map;
X {
X FILE *fp;
X int width, height, i, j, c;
X char buffer[100];
X struct stat o, n;
X
X strcpy( buffer, file );
X
X /* change 'bm' to 'BM' if possible */
X if ( strcmp("bm",buffer+strlen(buffer)-2) == 0 )
X strcpy( buffer+strlen(buffer)-2, "BM" );
X else
X sprintf( buffer, "%s.BM", file );
X
X if ( stat(file,&o) != -1 && stat(buffer,&n) != -1 )
X if ( o.st_ino == n.st_ino )
X {
X fprintf( stderr, "Output file \"%s\" would overwrite input file \"%s\"\nFile \"%s\" not converted\n",
X buffer, file, file );
X return;
X }
X
X fp = fopen( buffer, "w" );
X
X fprintf( fp, "BM(%d,%d) %s ={ %d, %d,", map->height, map->width, file, map->height, map->width );
X
X for( c = i = 0; i < map->height; ++i )
X for( j = 0; j < (map->width+7)/8; ++j )
X {
X if ( (c++ % 12) == 0 )
X fprintf( fp, "\n " );
X
X fprintf( fp, "0x%02x, ", map->bits[i*((map->width+7)/8)+j] & 0xff );
X }
X
X fprintf( fp, "};\n" );
X
X fclose( fp );
X }
END_OF_FILE
if test 2231 -ne `wc -c <'icons/bmtoBM.c'`; then
echo shar: \"'icons/bmtoBM.c'\" unpacked with wrong size!
fi
# end of 'icons/bmtoBM.c'
fi
if test -f 'jump.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'jump.c'\"
else
echo shar: Extracting \"'jump.c'\" \(7485 characters\)
sed "s/^X//" >'jump.c' <<'END_OF_FILE'
X#include "wand_head.h"
X#include <sys/types.h>
X#include <sys/stat.h>
X
Xextern int debug_disp;
Xextern int no_passwords;
Xextern int maxscreens;
X#ifdef EGA
Xextern char *EGAaddr;
X#endif
X
Xint scrn_passwd(num, passwd) /* reads password num into passwd */
Xint num;
Xchar *passwd;
X{
X long position;
X struct stat statbuf;
X FILE *fp;
X
X if (stat(DICTIONARY,&statbuf) == -1)
X return 0;
X position = PASSWD;
X position %= statbuf.st_size;
X if((fp = fopen(DICTIONARY,"r")) == NULL)
X return 0;
X fseek(fp,position,0);
X while(fgetc(fp) != '\n')
X continue;
X /* read a word into passwd */
X fscanf(fp,"%s\n",passwd);
X passwd[12] = '\0';
X fclose(fp);
X return (1);
X}
X
Xvoid showpass(num)
Xint num;
X{
Xchar correct[20];
Xchar buffer[100];
Xint Y = debug_disp? 20 : 18;
X
Xif(no_passwords)
X return;
Xmove(Y,0);
Xif(!scrn_passwd(num,correct))
X return;
X(void) sprintf(buffer,"The password to jump to level %d ( using ~ ) is : %s ",(num+1),correct);
X#ifdef EGA
Xif(EGAaddr) {
X if(debug_disp) {
X egaputs(4,341,buffer);
X egaputs(4+79*8-11*8,341,"Hit any key");
X }
X else {
X egaprintf(540,200,"Level %d",num+1);
X egaputs(540,210,"password is");
X egaputs(540,220,correct);
X
X egaputs(540,341,"Hit any key");
X }
X (void) Getch();
X }
Xelse
X#endif
X {
X addstr(buffer);
X addch('\n');
X addstr("Press any key to erase it and continue \n");
X refresh();
X (void) getch();
X move(Y,0);
X addstr(" \n");
X addstr(" ");
X move(Y,0);
X refresh();
X }
X}
X
Xint jumpscreen(num)
Xint num;
X{
Xchar word[20],
X buffer[100],
X correct[20];
Xint index;
Xint Y = debug_disp? 18 : 16;
Xchar ch;
Xint scrn;
X
Xif(no_passwords == 1) {
X /*
X * No passwords are required. Just get the level number and return.
X */
X if(num == maxscreens) {
X#ifdef EGA
X if(EGAaddr) {
X if(debug_disp) {
X egaputs(4, 341,"This is the last screen!");
X egaputs(4+79*8-11*8,341,"Hit any key");
X }
X else {
X egaputs(540,200,"Last screen!");
X
X egaputs(540,341,"Hit any key");
X }
X (void) Getch();
X if(debug_disp)
X egaclear(4,341, 639,349);
X else
X egaclear(540,200, 639,349);
X }
X else
X#endif
X {
X move(Y,0);
X addstr("This is the last screen!");
X refresh();
X }
X return num;
X }
X
X#ifdef EGA
X if(EGAaddr) {
X if(debug_disp) {
X egaputs(4, 341,"Enter the number of the desired level: ");
X egagets(4+39*8,341,buffer);
X }
X else {
X egaputs(540, 200,"What level?");
X egagets(540+2*8,210,buffer);
X }
X sscanf(buffer,"%d",&scrn);
X }
X else
X#endif
X {
X move(Y,0);
X addstr("Enter number of desired level.\n");
X refresh();
X echo();
X scanw("%d",&scrn);
X noecho();
X }
X if(scrn > num && scrn <= maxscreens) {
X move(Y,0);
X#ifdef EGA
X if(!EGAaddr)
X#endif
X addstr(" ");
X return scrn;
X }
X
X#ifdef EGA
X if(EGAaddr) {
X if(scrn <= num)
X if(debug_disp) {
X egaputs(4, 341,"No way, Jose! Back-jumping is prohibited!");
X egaputs(4+79*8-11*8,341,"Hit any key");
X }
X else {
X egaputs(540,230,"Sorry! No");
X egaputs(540,240,"back-jumping");
X egaputs(540,250,"allowed!");
X
X egaputs(540,341,"Hit any key");
X }
X else
X if(debug_disp) {
X egaputs(4,341,"No way, Jose! There are not that many screens!");
X egaputs(4+79*8-11*8,341,"Hit any key");
X }
X else {
X egaputs(540,230,"Sorry! Not");
X egaputs(540,240,"that many");
X egaputs(540,250,"screens!");
X
X egaputs(540,341,"Hit any key");
X }
X (void) Getch();
X if(debug_disp)
X egaclear(4,341, 639,349);
X else
X egaclear(540,200, 639,349);
X }
X else
X#endif
X {
X move(Y,0);
X if(scrn <= num)
X addstr("No way, Jose! Back-jumping is prohibited!");
X else
X addstr("No way, Jose! There are not that many screens!");
X refresh();
X }
X return num;
X }
X
X/*
X * Passwords are required
X */
X#ifdef EGA
Xif(EGAaddr) {
X if(debug_disp)
X egaputs(4,341,"Enter the password of the screen to jump to:");
X else
X egaputs(540,200,"Password?");
X }
Xelse
X#endif
X {
X move(Y,0);
X addstr("Please enter password of screen to jump to:");
X refresh();
X }
Xfor( index = 0; index < 12; ++index ) {
X if((ch = getch()) == '\n')
X break;
X else {
X#ifdef EGA
X if(!EGAaddr)
X#endif
X {
X addch('*');
X refresh();
X }
X word[index] = ch;
X }
X }
Xword[index]='\0';
X#ifdef EGA
Xif(EGAaddr) {
X if(debug_disp)
X egaputs(4,341,"Validating... ");
X else
X egaputs(540,200,"Checking...");
X }
Xelse
X#endif
X {
X move(Y,0);
X addstr("Validating... \n");
X refresh();
X }
X
X/*
X * Check for Wizard Mode
X */
Xif(strcmp(word,MASTERPASSWORD) == 0)
X {
X#ifdef EGA
X if(EGAaddr) {
X if(debug_disp) {
X egaputs(4, 341,"Enter the number of the desired level: ");
X egagets(4+39*8,341,buffer);
X }
X else {
X egaputs(540, 200,"What level?");
X egagets(540+2*8,210,buffer);
X }
X sscanf(buffer,"%d",&num);
X }
X else
X#endif
X {
X move(Y,0);
X addstr("Enter number of desired level: ");
X refresh();
X echo();
X scanw("%d",&num);
X noecho();
X }
X (void) scrn_passwd(num-1,correct);
X sprintf(buffer,"Certainly master, but the correct word is %s.",correct);
X#ifdef EGA
X if(EGAaddr) {
X if(debug_disp) {
X egaputs(4, 341,buffer);
X egaputs(4+79*8-11*8,341,"Hit any key");
X }
X else {
X egaputs(540,230,"Certainly!");
X egaprintf(540,240,"Level %d",num);
X egaputs(540,250,"password is");
X egaputs(540,260,correct);
X
X egaputs(540,341,"Hit any key");
X }
X (void) Getch();
X if(debug_disp)
X egaclear(4,341, 639,349);
X else
X egaclear(540,200, 639,349);
X }
X else
X#endif
X {
X move(Y,0);
X addstr(buffer);
X addch('\n');
X addstr("Press any key to continue");
X refresh();
X (void) getch();
X move(Y,0);
X addstr(" ");
X move(Y+1,0);
X addstr(" ");
X refresh();
X }
X return num;
X }
Xelse
X if(num == maxscreens) {
X#ifdef EGA
X if(EGAaddr) {
X if(debug_disp) {
X egaputs(4, 341,"This is the last screen!");
X egaputs(4+79*8-11*8,341,"Hit any key");
X }
X else {
X egaputs(540,200,"Last screen!");
X
X egaputs(540,341,"Hit any key");
X }
X (void) Getch();
X if(debug_disp)
X egaclear(4,341, 639,349);
X else
X egaclear(540,200, 639,349);
X }
X else
X#endif
X {
X move(Y,0);
X addstr("This is the last screen!");
X refresh();
X }
X return num;
X }
X
X/*
X * Get level corresponding to the password
X */
Xfor(scrn = num;scrn < maxscreens;scrn++) {
X if(!scrn_passwd(scrn,correct))
X break;
X if(strcmp(correct,word) == 0)
X {
X move(Y,0);
X#ifdef EGA
X if(!EGAaddr)
X#endif
X addstr("Password Validated..... Jumping to desired screen. ");
X refresh();
X return ++scrn;
X }
X }
X
X#ifdef EGA
Xif(EGAaddr) {
X if(debug_disp) {
X egaputs(4, 341,"Password is incorrect!");
X egaputs(4+79*8-11*8,341,"Hit any key");
X }
X else {
X egaputs(540,220,"Password is");
X egaputs(540,230,"not correct!");
X
X egaputs(540,341,"Hit any key");
X }
X (void) Getch();
X if(debug_disp)
X egaclear(4,341, 639,349);
X else
X egaclear(540,200, 639,349);
X }
Xelse
X#endif
X {
X move(Y,0);
X addstr("Password is incorrect! ");
X refresh();
X move(Y,0);
X addstr(" ");
X }
X
Xreturn num;
X}
END_OF_FILE
if test 7485 -ne `wc -c <'jump.c'`; then
echo shar: \"'jump.c'\" unpacked with wrong size!
fi
# end of 'jump.c'
fi
if test -f 'm.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'m.c'\"
else
echo shar: Extracting \"'m.c'\" \(4477 characters\)
sed "s/^X//" >'m.c' <<'END_OF_FILE'
X#include "wand_head.h"
X#include <sys/types.h>
X#include <sys/stat.h>
X#ifdef EGA
X#include "bitmap.h"
X
Xstruct termio sav;
X#endif
X
Xint debug_disp = 0;
Xint no_passwords = 0;
Xint maxscreens;
Xint edit_mode = 0;
Xint saved_game = 0;
Xchar *edit_screen;
Xchar *screenpath;
X/* Screen[NOOFROWS][ROWLEN] is centered inside area[NOOFROWS+2][ROWLEN+2].
X * This prevents fall() from accessing some random characters outside of
X * screen[][] that happen to match a boulder, etc.
X */
Xchar area[1+NOOFROWS+1][1+ROWLEN+1];
Xchar (*screen)[ROWLEN+1+1] = &area[1][1];
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
Xstruct stat statbuf;
Xint num,bell = 0,maxmoves = 0,x,y;
Xlong score = 0;
Xchar howdead[25],buffer[100], *name,*keys,*dead;
Xchar *malloc();
Xchar *getenv();
X#ifdef EGA
Xextern char *EGAaddr;
Xextern bitmap wanderer;
X#endif
X
Xif((screenpath = getenv("SCREENPATH")) == NULL)
X screenpath = SCREENPATH;
X
Xif(argc == 2)
X {
X if(!strcmp(argv[1], "-e"))
X {
X edit_mode = 1;
X edit_screen = NULL;
X }
X else if(!strcmp(argv[1], "-m"))
X {
X erase_scores();
X return 0;
X }
X else if(!strcmp(argv[1], "-c"))
X {
X char ch;
X int fp;
X /* show credits */
X sprintf(buffer,"%s/credits",screenpath);
X if((fp = open(buffer,O_RDONLY)) == -1) {
X printf(" Sorry - credits unavailable!\n");
X exit(1);
X }
X while(read(fp,&ch,1) == 1)
X putchar(ch);
X putchar('\n');
X exit(0);
X }
X else if(!strcmp(argv[1], "-s"))
X {
X savescore("",0L,0,NULL);
X return 0;
X }
X else if(!strcmp(argv[1], "-f"))
X {
X debug_disp = 1;
X }
X else
X {
X fprintf(stderr,"Usage: %s [ -e [file] | -m | -c | -s | -f ]\n",argv[0]);
X exit(1);
X }
X }
Xif(argc > 2)
X {
X if(!strcmp(argv[1],"-e"))
X {
X edit_mode = 1;
X edit_screen = argv[2];
X }
X else
X {
X fprintf(stderr,"Usage: %s [ -e [file] | -m | -c | -s | -f ]\n",argv[0]);
X exit(1);
X }
X }
X
X/* use passwords? if file "no_pws" exists and is readable, then no pws! */
Xsprintf(buffer,"%s/no_pws",screenpath);
Xif(access(buffer,4) == 0)
X no_passwords = 1;
X
X/* count available screens */
Xfor(maxscreens = 0;;maxscreens++) {
X sprintf(buffer,"%s/screen.%d",screenpath,(maxscreens+1));
X if(stat(buffer,&statbuf) == -1)
X break;
X}
X
Xif((name = getenv("NEWNAME")) == NULL)
X if((name = getenv("NAME")) == NULL)
X if((name = getenv("FULLNAME")) == NULL)
X if((name = getenv("USER")) == NULL)
X if((name = getenv("LOGNAME")) == NULL)
X#ifdef ASKNAME /* M001 */
X {
X name = malloc(80);
X if (name == NULL) {
X printf("malloc error\n");
X exit(1);
X }
X printf("Name? "); fflush(stdout);
X gets(name);
X if (name[0] == '\0')
X name = "noname";
X }
X#else
X name = "noname";
X#endif
X
Xif((keys = getenv("NEWKEYS")) == NULL)
X keys = "kjhl";
X
X#ifdef EGA
Xif(egainit()) {
X struct termio cb;
X
X /*
X * set stdin to raw mode
X */
X ioctl(0, TCGETA, &sav);
X cb = sav;
X cb.c_cc[VMIN] = 1;
X cb.c_cc[VTIME] = 255;
X cb.c_lflag &= ~(ECHO | ICANON);
X ioctl(0, TCSETAW, &cb);
X
X egapaint( 233,95, &wanderer );
X sleep( 3 );
X }
X else
X#endif
X {
X initscr();
X keypad(stdscr, TRUE);
X CBON;
X noecho();
X }
X
X/* MAIN PROGRAM HERE */
X
Xplay_again:
X
Xif(!edit_mode) {
X howdead[0] = 0;
X for (num=1; num <= maxscreens; ++num) {
X if (rscreen(num,&maxmoves)) {
X strcpy(howdead,"a non-existant screen");
X break;
X }
X dead = playscreen(&num,&score,&bell,maxmoves,keys);
X if ((dead != NULL) && (*dead == '~')) {
X num = (int)(dead[1]) - 1;
X dead = NULL;
X }
X if (dead != NULL)
X {
X strcpy(howdead,dead);
X break;
X }
X }
X }
Xelse
X {
X if(rscreen(num,&maxmoves))
X {
X for(x=0;x<ROWLEN;x++)
X for(y=0;y<NOOFROWS;y++)
X screen[y][x] = ' ';
X }
X edit(num,&score,&bell,maxmoves,keys);
X }
X/* END OF MAIN PROGRAM */
X
X#ifdef EGA
Xif(!EGAaddr)
X#endif
X {
X echo();
X CBOFF;
X endwin();
X }
X
Xif(!edit_mode) {
X /* SAVE ROUTINES FOR SCORES */
X
X#ifdef NO_RESTORED_GAME_HISCORES
X if(saved_game) {
X#ifdef EGA
X if(!EGAaddr)
X#endif
X printf("No scores recorded for restored games.\n");
X }
X else
X#endif
X savescore(howdead,score,num,name);
X
X#ifdef EGA
X if(EGAaddr) {
X egaputs(4,341,"Play again? ");
X egagets(4+12*8,341,buffer);
X if(buffer[0] == 'y' || buffer[0] == 'Y') {
X score = 0;
X saved_game = 0;
X goto play_again;
X }
X }
X#endif
X }
X
X#ifdef EGA
Xif(EGAaddr) {
X egareset();
X ioctl(0, TCSETAW, &sav);
X }
X#endif
X
Xprintf("WANDERER (C) 1988 S. Shipway\n");
Xreturn 0;
X}
END_OF_FILE
if test 4477 -ne `wc -c <'m.c'`; then
echo shar: \"'m.c'\" unpacked with wrong size!
fi
# end of 'm.c'
fi
if test -f 'save.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'save.c'\"
else
echo shar: Extracting \"'save.c'\" \(6471 characters\)
sed "s/^X//" >'save.c' <<'END_OF_FILE'
X#include "wand_head.h"
X
X#ifdef EGA
Xextern char *EGAaddr;
X#endif
X
Xextern char area[1+NOOFROWS+1][1+ROWLEN+1];
Xextern int saved_game;
Xextern int debug_disp;
X
X#ifndef NO_ENCRYPTION
X
X/* this is the random number seed */
X#define BLURFL 32451 /* the word blurfl is used for historical reasons */
X /* but it can be any number */
X
Xstatic int fread(buffer,length,items,stream)
Xchar *buffer;
XFILE *stream;
X{
Xint loop, c, count;
X
Xfor(loop=0; loop<items; loop++)
X for(count = 0; count<length; ++count ) {
X if ( (c = getc(stream)) == EOF || ferror(stream) )
X return( loop );
X *buffer++ = c ^ rand();
X }
X
Xreturn( items );
X}
X
Xstatic int fwrite(buffer,length,items,stream)
Xchar *buffer;
XFILE *stream;
X{
Xint loop, count;
X
Xfor(loop=0; loop<items; loop++)
X for(count = 0; count<length; ++count ) {
X if ( putc(*buffer++ ^ rand(), stream) == EOF )
X return( loop );
X }
X
Xreturn( items );
X}
X#endif
X
Xstruct saved_game {
X short num;
X long score;
X short bell;
X short maxmoves;
X short num_monsters;
X};
X
Xstruct save_vars zz;
X
Xvoid
Xsave_game(num, score, bell, maxmoves, start_of_list, tail_of_list)
Xint num, *bell, maxmoves;
Xlong *score;
Xstruct mon_rec *start_of_list, *tail_of_list;
X{
X char fname[128], *fp;
X FILE *fo;
X struct saved_game s;
X extern char *getenv();
X struct mon_rec *mp;
X
X#ifndef NO_ENCRYPTION
X srand(BLURFL);
X#endif
X
X fp = getenv("SAVENAME");
X#ifdef EGA
X if(EGAaddr) {
X egaclear(0,350-4*9, 639,349);
X egaputs(4,350-3*9,"Saving game... Filename ? ");
X
X if (fp == NULL) {
X fp = fname;
X egagets(4+26*8,350-3*9,fp);
X }
X else
X egaputs(4+26*8,350-3*9,fp);
X }
X else
X#endif
X {
X move(LINES-3,0);
X clrtobot();
X addstr("Saving game... Filename ? ");
X
X if (fp == NULL) {
X refresh();
X fp = fname;
X echo(); CBOFF;
X getstr(fp);
X noecho(); CBON;
X }
X else {
X addstr(fp);
X addch('\n');
X refresh();
X }
X }
X if (NULL == (fo = fopen(fp, W_BIN))) {
X saveError("Error opening '%s'", fp);
X return;
X }
X
X s.num = num;
X s.score = *score;
X s.bell = *bell;
X s.maxmoves = maxmoves;
X s.num_monsters = 0;
X
X mp = start_of_list; /* first entry is dummy */
X while (mp != tail_of_list) {
X mp = mp->next;
X s.num_monsters++; /* count them monsters */
X }
X
X if ( (1 != fwrite("WANDERER", 8, 1, fo)) ||
X (1 != fwrite(&s, sizeof(s), 1, fo)) ||
X (1 != fwrite(&zz, sizeof(zz), 1, fo)) )
X {
X saveError("Error writing '%s'", fp);
X fclose(fo);
X unlink(fp);
X return;
X }
X
X mp = start_of_list;
X while (mp != tail_of_list) {
X /* save them monsters */
X mp = mp->next;
X if (1 != fwrite(mp, sizeof(*mp), 1, fo)) {
X saveError("Error writing '%s'", fp);
X fclose(fo);
X unlink(fp);
X return;
X }
X }
X
X if ( 1 != fwrite(area, sizeof(area), 1, fo) )
X {
X saveError("Error writing '%s'", fp);
X fclose(fo);
X unlink(fp);
X return;
X }
X
X fclose(fo);
X#ifdef EGA
X if(EGAaddr) {
X extern struct termio sav;
X egareset();
X ioctl(0, TCSETAW, &sav);
X }
X else
X#endif
X {
X refresh();
X endwin();
X }
X exit(0);
X}
X
XsaveError( msg, arg )
Xchar *msg, *arg;
X{
X#ifdef EGA
X if(EGAaddr)
X egaprintf(4,350-2*9,msg,arg);
X else
X#endif
X {
X mvprintw(LINES-2,0,msg,arg);
X refresh();
X }
X}
X
X
Xint
Xrestore_game(num, score, bell, maxmoves, start_of_list, tail_of_list)
Xint *num, *bell, *maxmoves;
Xlong *score;
Xstruct mon_rec *start_of_list, **tail_of_list;
X{
X FILE *fi;
X struct saved_game s;
X struct mon_rec *mp, *tmp, *rp;
X char fname[128], *fp;
X char name[10];
X extern char *getenv();
X extern char *malloc();
X
X#ifndef NO_ENCRYPTION
X srand(BLURFL);
X#endif
X
X fp = getenv("SAVENAME");
X#ifdef EGA
X if(EGAaddr) {
X egaclear(0,350-4*9, 639,349);
X egaputs(4,350-3*9,"Restore Filename ? ");
X
X if (fp == NULL) {
X fp = fname;
X egagets(4+19*8,350-3*9,fp);
X }
X else
X egaputs(4+19*8,350-3*9,fp);
X }
X else
X#endif
X {
X move(LINES-3,0);
X clrtobot();
X addstr("Restore Filename ? ");
X
X if (NULL == (fp = getenv("SAVENAME"))) {
X refresh();
X CBOFF; echo();
X fp = fname;
X getstr(fp);
X noecho(); CBON;
X }
X else {
X addstr(fp);
X addch('\n');
X refresh();
X }
X }
X if (NULL == (fi = fopen(fp, R_BIN))) {
X restoreError("Error opening '%s'; cannot restore game", fp);
X return 0;
X }
X
X if ( 1 != fread(name, 8, 1, fi) ) {
X restoreError("Error reading '%s'; cannot restore game", fp);
X fclose(fi);
X return 0;
X }
X
X if ( 0 != strncmp(name,"WANDERER",8) ) {
X restoreError("File '%s' is not a WANDERER save file; cannot restore game", fp);
X fclose(fi);
X return 0;
X }
X
X if ( (1 != fread((char *)&s, sizeof(s), 1, fi)) ||
X (1 != fread((char *)&zz, sizeof(zz), 1, fi)) ) {
X restoreError("Error reading '%s'; cannot restore game", fp);
X fclose(fi);
X return 0;
X }
X
X /* read monsters into core */
X if (NULL == (rp = (struct mon_rec*)malloc(s.num_monsters*sizeof(*rp)))) {
X restoreError("Monster alloc error on '%s'; cannot restore game", fp);
X fclose(fi);
X return 0;
X }
X if ((s.num_monsters != fread(rp,sizeof(struct mon_rec),s.num_monsters,fi)) ||
X (1 != fread(area, sizeof(area), 1, fi)) ) {
X restoreError("Error reading '%s'; cannot restore game", fp);
X free(rp);
X fclose(fi);
X return 0;
X }
X
X /* point of no return */
X *num = s.num;
X *score = s.score;
X *bell = s.bell;
X *maxmoves = s.maxmoves;
X
X /* free any monsters already on chain, to start clean */
X mp = start_of_list->next;
X while ((mp != NULL) && (mp != start_of_list)) {
X /* free them monsters */
X tmp = mp;
X mp = mp->next;
X free(tmp);
X }
X
X /* re-initialize the monster list */
X /* *start_of_list = {0,0,0,0,0,NULL,NULL}; */
X memset( start_of_list, 0, sizeof(*start_of_list) );
X
X *tail_of_list = start_of_list;
X
X for( tmp = rp; s.num_monsters--; ++tmp ) {
X /* use make_monster to allocate the monster structures */
X /* to get all the linking right without even trying */
X if (NULL == (mp = make_monster(0, 0))) {
X#ifdef EGA
X if(EGAaddr) {
X extern struct termio sav;
X egareset();
X ioctl(0, TCSETAW, &sav);
X printf("Monster alloc error on '%s'; cannot restore game\n", fp);
X }
X else
X#endif
X {
X mvprintw(LINES-2,0,"Monster alloc error on '%s'; cannot restore game", fp);
X refresh();
X endwin();
X }
X fclose(fi);
X exit(1); /* no recovery possible */
X }
X /* copy info without trashing links */
X mp->x = tmp->x;
X mp->y = tmp->y;
X mp->mx = tmp->mx;
X mp->my = tmp->my;
X mp->under = tmp->under;
X }
X
X fclose(fi);
X unlink(fp);
X free(rp);
X saved_game = 1;
X return 1;
X}
X
XrestoreError( msg, arg )
Xchar *msg, *arg;
X{
X#ifdef EGA
X if(EGAaddr)
X egaprintf(4,350-2*9,msg,arg);
X else
X#endif
X {
X mvprintw(LINES-2,0,msg,arg);
X refresh();
X }
X}
END_OF_FILE
if test 6471 -ne `wc -c <'save.c'`; then
echo shar: \"'save.c'\" unpacked with wrong size!
fi
# end of 'save.c'
fi
if test -f 'wand_head.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'wand_head.h'\"
else
echo shar: Extracting \"'wand_head.h'\" \(5088 characters\)
sed "s/^X//" >'wand_head.h' <<'END_OF_FILE'
X#include <stdio.h>
X#include <curses.h>
X#include <string.h>
X#include <fcntl.h>
X
X/* I wouldn't change these if I were you - it won't give you a bigger screen */
X#define ROWLEN 40
X#define NOOFROWS 16
X
X/* Change these to the necessary directories or files */
X#define SCREENPATH "/usr/games/lib/wanderer"
X#define HISCOREPATH "/usr/games/lib/.wanderer"
X#define LOCKPATH "/tmp/wanderer.lock" /* hiscore lock file */
X#define DICTIONARY "/usr/lib/dictionary"
X
X/* change this to anything (12 characters or less), but don't forget what */
X#define MASTERPASSWORD "slimy worms"
X
X/* change the numbers in this as well, but keep it in the same form */
X#define PASSWD (num * num * 4373L + num * 16927L + 39L)
X
X/* To disable the recording of hiscores from games restored from saves */
X/* #define NO_RESTORED_GAME_HISCORES */
X/* #define COMPARE_BY_NAME define this to compare by name, not uid */
X#define GUESTUID 0 /* guestuid always compared by name */
X/* #define NO_ENCRYPTION define this to disable the savefile encryptor */
X
X/* To compile for Microport System V/286 with EGA */
X#ifdef iAPX286
X#define EGA 1 /* enable EGA graphics mode */
X#endif
X
X/* cbreak switching via curses package. */
X/* on some Ultrix systems you may need to use crmode() and nocrmode() */
X/* if so, just change the #defs to the necessary. I also know that Xenix */
X/* systems have to use crmode, so.. */
X#ifdef XENIX
X#define CBON crmode()
X#define CBOFF nocrmode()
X#else
X#define CBON cbreak()
X#define CBOFF nocbreak()
X#endif
X
X
X/* MSDOS modifications (M001) by Gregory H. Margo */
X#ifdef MSDOS
X#define R_BIN "rb" /* binary mode for non-text files */
X#define W_BIN "wb"
X# ifdef VOIDPTR
X# define VOIDSTAR (void *)
X# else
X# define VOIDSTAR (char *)
X# endif
X#define ASKNAME /* ask user's name if not in environment */
X#define COMPARE_BY_NAME /* compare users with name, not uid */
X#undef getchar /* remove stdio's definition to use curses' */
X#define getchar() getch() /* use curse's definition instead */
X
X#else /* not MSDOS */
X#define R_BIN "r"
X#define W_BIN "w"
X#define VOIDSTAR (void *)
X#endif
X
X#ifdef EGA
X/*
X * Front-end various curses routines... this avoids a lot of #ifdef'ing
X */
X#undef clear
X#undef refresh
X#undef move
X#undef getch
X#define clear() Clear()
X#define refresh() Refresh()
X#define move(y,x) Move(y,x)
X#define getch() Getch()
X#define beep() Beep()
X#endif
X
X/* Save and Restore game additions (M002) by Gregory H. Margo */
X/* mon_rec structure needed by save.c */
Xstruct mon_rec
X {
X int x,y,mx,my;
X char under;
X struct mon_rec *next,*prev;
X };
X
X
Xstruct save_vars {
X int z_x, z_y,
X z_tx, z_ty,
X z_mx, z_my,
X z_max_score,
X z_diamonds,
X z_nf;
X};
X
X/* prototypes added by Gregory H. Margo */
X#ifdef LINT_ARGS /* M001 */
X/* DISPLAY.c */
Xextern void map(char (*)[ROWLEN+1]);
Xextern void display(int ,int ,char (*)[ROWLEN+1]);
Xextern void update_score(lonf, int, int );
X
X/* EDIT.C */
Xextern void instruct(void);
Xextern void noins(void);
Xextern void edit(int ,long *,int *,int ,char *);
X
X/* FALL.C */
Xextern int check(int *,int *,int ,int ,int ,int ,int ,int ,char *);
Xextern int fall(int *,int *,int ,int ,int ,int ,char *);
X
X/* GAME.C */
Xextern struct mon_rec *make_monster(int ,int );
Xextern char *playscreen(int *,long *,int *,int ,char *);
X
X/* ICON.C */
Xextern void draw_symbol(int ,int ,char );
Xextern int symbol(char);
X
X/* JUMP.C */
Xextern int scrn_passwd(int ,char *);
Xextern void showpass(int );
Xextern int jumpscreen(int );
Xextern int getnum(void);
X
X/* READ.C */
Xextern int rscreen(int ,int *);
Xextern int wscreen(int ,int );
X
X/* SAVE.C */
Xextern void save_game(int ,long *,int *,int ,struct mon_rec *,struct mon_rec *);
Xextern int restore_game(int *,long *,int *,int *,struct mon_rec *,struct mon_rec **);
X
X/* SCORES.C */
Xextern int savescore(char *,long ,int ,char *);
Xextern void delete_entry(int );
Xextern int erase_scores(void);
X
X#ifdef EGA
X/* iAPX286.c */
Xextern int egainit(void);
Xextern void egaclear(int,int, int,int);
Xextern void egareset(void);
Xextern void egaline( int, int, int, int );
Xextern void egaputs( int, int, char * );
Xextern void egapaint( int, int, void * );
Xextern void egamessage( int, char * );
X#endif
X
X#else
X
X/* DISPLAY.c */
Xextern void map();
Xextern void display();
Xextern void update_score();
X
X/* EDIT.C */
Xextern void instruct();
Xextern void noins();
Xextern void edit();
X
X/* FALL.C */
Xextern int check();
Xextern int fall();
X
X/* GAME.C */
Xextern struct mon_rec *make_monster();
Xextern char *playscreen();
X
X/* ICON.C */
Xextern void draw_symbol();
Xextern int symbol();
X
X/* JUMP.C */
Xextern int scrn_passwd();
Xextern void showpass();
Xextern int jumpscreen();
Xextern int getnum();
X
X/* READ.C */
Xextern int rscreen();
Xextern int wscreen();
X
X/* SAVE.C */
Xextern void save_game();
Xextern int restore_game();
X
X/* SCORES.C */
Xextern int savescore();
Xextern void delete_entry();
Xextern int erase_scores();
X
X#ifdef EGA
X/* iAPX286.c */
Xextern int egainit();
Xextern void egaclear();
Xextern void egareset();
Xextern void egaline();
Xextern void egaputs();
Xextern void egapaint();
Xextern void egamessage();
X#endif
X
X#endif
END_OF_FILE
if test 5088 -ne `wc -c <'wand_head.h'`; then
echo shar: \"'wand_head.h'\" unpacked with wrong size!
fi
# end of 'wand_head.h'
fi
echo shar: End of archive 4 \(of 5\).
cp /dev/null ark4isdone
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