BSD 4_4_Lite1 release
[unix-history] / usr / src / games / snake / snake / snake.c
index 41702fd..b99da10 100644 (file)
@@ -1,6 +1,45 @@
+/*
+ * Copyright (c) 1980, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)snake.c    4.2 (Berkeley) %G%";
-#endif
+static char copyright[] =
+"@(#) Copyright (c) 1980, 1993\n\
+       The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)snake.c    8.2 (Berkeley) 1/7/94";
+#endif /* not lint */
 
 /*
  * snake - crt hack game.
 
 /*
  * snake - crt hack game.
@@ -13,32 +52,15 @@ static char sccsid[] = "@(#)snake.c 4.2 (Berkeley) %G%";
  *     cc -O snake.c move.c -o snake -lm -ltermlib
  */
 
  *     cc -O snake.c move.c -o snake -lm -ltermlib
  */
 
-#include "snake.h"
-#include <pwd.h>
-
-       /*
-        * If CHECKBUSY is defined, the file BUSY must be executable
-        * and must return a value which is used to determine the priority
-        * a which snake runs.  A zero value means no nice.
-        * If BUSY does not exist, snake won't play.
-        */
-#ifndef BUSY
-#define BUSY   "/usr/games/lib/busy"
-#endif
+#include <sys/param.h>
 
 
-       /*
-        * This is the data file for scorekeeping.
-        */
-#ifndef SNAKERAWSCORES
-#define SNAKERAWSCORES "/usr/games/lib/snakerawscores"
-#endif
+#include <errno.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <time.h>
 
 
-       /*
-        * If it exists, a log is kept here.  Otherwise it isn't.
-        */
-#ifndef LOGFILE
-#define LOGFILE        "/usr/games/lib/snake.log"
-#endif
+#include "snake.h"
+#include "pathnames.h"
 
 #define PENALTY  10    /* % penalty for invoking spacewarp     */
 
 
 #define PENALTY  10    /* % penalty for invoking spacewarp     */
 
@@ -61,10 +83,7 @@ struct point snake[6];
 
 int loot, penalty;
 int long tl, tm=0L;
 
 int loot, penalty;
 int long tl, tm=0L;
-int argcount;
-char **argval;
 int moves;
 int moves;
-static char str[BSIZE];
 char stri[BSIZE];
 char *p;
 char ch, savec;
 char stri[BSIZE];
 char *p;
 char ch, savec;
@@ -78,46 +97,44 @@ main(argc,argv)
 int argc;
 char **argv;
 {
 int argc;
 char **argv;
 {
-       int i,k;
-       int j;
-       long time();
-       int stop();
-       extern char _sobuf[];
-
-       argcount = argc;
-       argval = argv;
-       penalty = loot = 0;
-       getcap();
-       ccnt -= 2; lcnt -= 2;   /* compensate for border */
-       busy();
-       time(&tv);
-
-       for (i=1; i<argc; i++) {
-               switch(argv[i][1]) {
+       extern char *optarg;
+       extern int optind;
+       int ch, i, j, k;
+       long atol();
+       void stop();
+
+       (void)time(&tv);
+       srandom((int)tv);
+
+       while ((ch = getopt(argc, argv, "l:w:")) != EOF)
+               switch((char)ch) {
+#ifdef notdef
                case 'd':
                case 'd':
-                       sscanf(argv[1], "-d%ld", &tv);
+                       tv = atol(optarg);
                        break;
                        break;
+#endif
                case 'w':       /* width */
                case 'w':       /* width */
-               case 'c':       /* columns */
-                       ccnt = atoi(argv[i]+2);
+                       ccnt = atoi(optarg);
                        break;
                case 'l':       /* length */
                        break;
                case 'l':       /* length */
-               case 'h':       /* height */
-               case 'r':       /* rows */
-                       lcnt = atoi(argv[i]+2);
+                       lcnt = atoi(optarg);
                        break;
                        break;
+               case '?':
                default:
                default:
-                       printf("bad option %s\n", argv[1]);
+                       fputs("usage: snake [-d seed] [-w width] [-l length]\n", stderr);
+                       exit(1);
                }
                }
-       }
 
 
-       srand((int)tv);
-       setbuf(stdout,_sobuf);
-       i = ((lcnt < ccnt) ? lcnt : ccnt);      /* min screen edge */
+       penalty = loot = 0;
+       getcap();
+
+       i = MIN(lcnt, ccnt);
        if (i < 4) {
        if (i < 4) {
-               printf("Screen too small for a fair game\n");
-               done();
+               cook();
+               pr("snake: screen too small for a fair game.\n");
+               exit(1);
        }
        }
+
        /*
         * chunk is the amount of money the user gets for each $.
         * The formula below tries to be fair for various screen sizes.
        /*
         * chunk is the amount of money the user gets for each $.
         * The formula below tries to be fair for various screen sizes.
@@ -145,10 +162,10 @@ char **argv;
        putpad(TI); /*  String to begin programs that use cm */
        putpad(KS); /*  Put terminal in keypad transmit mode */
 
        putpad(TI); /*  String to begin programs that use cm */
        putpad(KS); /*  Put terminal in keypad transmit mode */
 
-       random(&finish);
-       random(&you);
-       random(&money);
-       random(&snake[0]);
+       snrand(&finish);
+       snrand(&you);
+       snrand(&money);
+       snrand(&snake[0]);
 
        if ((orig.sg_ospeed < B9600) ||
            ((! CM) && (! TA))) fast=0;
 
        if ((orig.sg_ospeed < B9600) ||
            ((! CM) && (! TA))) fast=0;
@@ -222,8 +239,7 @@ mainloop()
                if (!fast) flushi();
                lastc = c;
                switch (c){
                if (!fast) flushi();
                lastc = c;
                switch (c){
-               case CTRL(z):
-               case CTRL(c):
+               case CTRL('z'):
                        suspend();
                        continue;
                case EOT:
                        suspend();
                        continue;
                case EOT:
@@ -233,27 +249,7 @@ mainloop()
                        length(moves);
                        logit("quit");
                        done();
                        length(moves);
                        logit("quit");
                        done();
-               case '!':
-                       cook();
-                       putchar('\n');
-                       putchar(c);
-                       fflush(stdout);
-                       j = read(0,stri,BSIZE);
-                       stri[j] = 0;
-                       if (fork() == 0) {
-                               setuid(getuid());
-                               system(stri);
-                       } else
-                               wait(0);
-                       printf("READY?\n");
-                       fflush(stdout);
-                       raw();
-                       c = getchar();
-                       ungetc(c,stdin);
-                       putpad(KS);
-                       putpad(TI);
-                       point(&cursor,0,lcnt-1);
-               case CTRL(l):
+               case CTRL('l'):
                        setup();
                        winnings(cashvalue);
                        continue;
                        setup();
                        winnings(cashvalue);
                        continue;
@@ -328,7 +324,7 @@ mainloop()
                                                pchar(&you,ME);
                                }
                                break;
                                                pchar(&you,ME);
                                }
                                break;
-                       case CTRL(p):
+                       case CTRL('p'):
                        case 'e':
                        case 'k':
                        case 'i':
                        case 'e':
                        case 'k':
                        case 'i':
@@ -341,7 +337,7 @@ mainloop()
                                                pchar(&you,ME);
                                }
                                break;
                                                pchar(&you,ME);
                                }
                                break;
-                       case CTRL(n):
+                       case CTRL('n'):
                        case 'c':
                        case 'j':
                        case LF:
                        case 'c':
                        case 'j':
                        case LF:
@@ -365,7 +361,7 @@ mainloop()
                                if(k < repeat)
                                        pchar(&you,' ');
                                do {
                                if(k < repeat)
                                        pchar(&you,' ');
                                do {
-                                       random(&money);
+                                       snrand(&money);
                                } while (money.col == finish.col && money.line == finish.line ||
                                         money.col < 5 && money.line == 0 ||
                                         money.col == you.col && money.line == you.line);
                                } while (money.col == finish.col && money.line == finish.line ||
                                         money.col < 5 && money.line == 0 ||
                                         money.col == you.col && money.line == you.line);
@@ -378,12 +374,12 @@ mainloop()
                                win(&finish);
                                ll();
                                cook();
                                win(&finish);
                                ll();
                                cook();
-                               printf("You have won with $%d.\n",cashvalue);
+                               pr("You have won with $%d.\n",cashvalue);
                                fflush(stdout);
                                logit("won");
                                fflush(stdout);
                                logit("won");
-                               post(cashvalue,0);
+                               post(cashvalue,1);
                                length(moves);
                                length(moves);
-                               done(0);
+                               done();
                        }
                        if (pushsnake())break;
                }
                        }
                        if (pushsnake())break;
                }
@@ -435,55 +431,35 @@ drawbox()
        }
 }
 
        }
 }
 
-
-random(sp)
+snrand(sp)
 struct point *sp;
 {
 struct point *sp;
 {
-       register int issame;
        struct point p;
        register int i;
 
        struct point p;
        register int i;
 
-       sp->col = sp->line = -1;        /* impossible */
-       do {
-               issame = 0;
-               p.col = ((rand()>>8) & 0377)% ccnt;
-               p.line = ((rand()>>8) & 0377)% lcnt;
+       for (;;) {
+               p.col = random() % ccnt;
+               p.line = random() % lcnt;
 
                /* make sure it's not on top of something else */
 
                /* make sure it's not on top of something else */
-               if (p.line == 0 && p.col <5) issame++;
-               if(same(&p, &you)) issame++;
-               if(same(&p, &money)) issame++;
-               if(same(&p, &finish)) issame++;
-               for (i=0; i<5; i++)
-                       if(same(&p, &snake[i])) issame++;
-
-       } while (issame);
+               if (p.line == 0 && p.col < 5)
+                       continue;
+               if (same(&p, &you))
+                       continue;
+               if (same(&p, &money))
+                       continue;
+               if (same(&p, &finish))
+                       continue;
+               for (i = 0; i < 5; i++)
+                       if (same(&p, &snake[i]))
+                               break;
+               if (i < 5)
+                       continue;
+               break;
+       }
        *sp = p;
 }
 
        *sp = p;
 }
 
-busy()
-{
-       FILE *pip, *popen();
-       char c;
-       int b,r;
-       float a;
-
-#ifdef CHECKBUSY
-       if (! strcmp (argval[0], "test")) return;
-       if ((access(BUSY,1) != 0) || (pip = popen(BUSY,"r")) == NULL){
-               printf("Sorry, no snake just now.\n");
-               done();
-       }
-       fscanf(pip,"%d",&b);
-       pclose(pip);
-       if (b > 20) {
-               printf("Sorry, the system is too heavily loaded right now.\n");
-               done();
-       }
-       nice(b);
-#endif
-}
-
 post(iscore, flag)
 int    iscore, flag;
 {
 post(iscore, flag)
 int    iscore, flag;
 {
@@ -492,43 +468,50 @@ int       iscore, flag;
        short   uid;
        short   oldbest=0;
        short   allbwho=0, allbscore=0;
        short   uid;
        short   oldbest=0;
        short   allbwho=0, allbscore=0;
-       struct  passwd *p, *getpwuid();
+       struct  passwd *p;
 
        /*
         * Neg uid, 0, and 1 cannot have scores recorded.
         */
 
        /*
         * Neg uid, 0, and 1 cannot have scores recorded.
         */
-       if ((uid=getuid()) > 1 && (rawscores=open(SNAKERAWSCORES,2))>=0) {
-               /* Figure out what happened in the past */
-               read(rawscores, &allbscore, sizeof(short));
-               read(rawscores, &allbwho, sizeof(short));
+       if ((uid = getuid()) <= 1) {
+               pr("No saved scores for uid %d.\n", uid);
+               return(1);
+       }
+       if ((rawscores = open(_PATH_RAWSCORES, O_RDWR|O_CREAT, 0644)) < 0) {
+               pr("No score file %s: %s.\n", _PATH_RAWSCORES,
+                   strerror(errno));
+               return(1);
+       }
+       /* Figure out what happened in the past */
+       read(rawscores, &allbscore, sizeof(short));
+       read(rawscores, &allbwho, sizeof(short));
+       lseek(rawscores, ((long)uid)*sizeof(short), 0);
+       read(rawscores, &oldbest, sizeof(short));
+       if (!flag)
+               return (score > oldbest ? 1 : 0);
+
+       /* Update this jokers best */
+       if (score > oldbest) {
                lseek(rawscores, ((long)uid)*sizeof(short), 0);
                lseek(rawscores, ((long)uid)*sizeof(short), 0);
-               read(rawscores, &oldbest, sizeof(short));
-               if (flag) return (score > oldbest ? 1 : 0);
-
-               /* Update this jokers best */
-               if (score > oldbest) {
-                       lseek(rawscores, ((long)uid)*sizeof(short), 0);
-                       write(rawscores, &score, sizeof(short));
-                       printf("You bettered your previous best of $%d\n", oldbest);
-               } else
-                       printf("Your best to date is $%d\n", oldbest);
-
-               /* See if we have a new champ */
-               p = getpwuid(allbwho);
-               if (p == NULL || score > allbscore) {
-                       lseek(rawscores, (long)0, 0);
-                       write(rawscores, &score, sizeof(short));
-                       write(rawscores, &uid, sizeof(short));
-                       if (p != NULL)
-                               printf("You beat %s's old record of $%d!\n", p->pw_name, allbscore);
-                       else
-                               printf("You set a new record!\n");
-               } else
-                       printf("The highest is %s with $%d\n", p->pw_name, allbscore);
-               close(rawscores);
+               write(rawscores, &score, sizeof(short));
+               pr("You bettered your previous best of $%d\n", oldbest);
+       } else
+               pr("Your best to date is $%d\n", oldbest);
+
+       /* See if we have a new champ */
+       p = getpwuid(allbwho);
+       if (p == NULL || score > allbscore) {
+               lseek(rawscores, (long)0, 0);
+               write(rawscores, &score, sizeof(short));
+               write(rawscores, &uid, sizeof(short));
+               if (allbwho)
+                       pr("You beat %s's old record of $%d!\n",
+                           p->pw_name, allbscore);
+               else
+                       pr("You set a new record!\n");
        } else
        } else
-               if (!flag)
-                       printf("Unable to post score.\n");
+               pr("The highest is %s with $%d\n", p->pw_name, allbscore);
+       close(rawscores);
        return (1);
 }
 
        return (1);
 }
 
@@ -556,7 +539,7 @@ struct point *sp, *np;
           snake would get too good */
        struct point d;
        int w, i, wt[8];
           snake would get too good */
        struct point d;
        int w, i, wt[8];
-       double sqrt(), v1, v2, vp, max;
+       double v1, v2, vp, max;
        point(&d,you.col-sp->col,you.line-sp->line);
        v1 = sqrt( (double) (d.col*d.col + d.line*d.line) );
        w=0; 
        point(&d,you.col-sp->col,you.line-sp->line);
        v1 = sqrt( (double) (d.col*d.col + d.line*d.line) );
        w=0; 
@@ -580,7 +563,13 @@ struct point *sp, *np;
                wt[i]=0;
                if (d.col<0 || d.col>=ccnt || d.line<0 || d.line>=lcnt)
                        continue;
                wt[i]=0;
                if (d.col<0 || d.col>=ccnt || d.line<0 || d.line>=lcnt)
                        continue;
-               if (d.line == 0 && d.col < 5) continue;
+               /*
+                * Change to allow snake to eat you if you're on the money,
+                * otherwise, you can just crouch there until the snake goes
+                * away.  Not positive it's right.
+                *
+                * if (d.line == 0 && d.col < 5) continue;
+                */
                if (same(&d,&money)) continue;
                if (same(&d,&finish)) continue;
                wt[i]= i==w ? loot/10 : 1;
                if (same(&d,&money)) continue;
                if (same(&d,&finish)) continue;
                wt[i]= i==w ? loot/10 : 1;
@@ -595,7 +584,7 @@ struct point *sp, *np;
                else
                        vp -= wt[i];
        if (i==8) {
                else
                        vp -= wt[i];
        if (i==8) {
-               printf("failure\n"); 
+               pr("failure\n"); 
                i=0;
                while (wt[i]==0) i++;
        }
                i=0;
                while (wt[i]==0) i++;
        }
@@ -607,25 +596,26 @@ spacewarp(w)
 int w;{
        struct point p;
        int j;
 int w;{
        struct point p;
        int j;
-       
-       random(&you);
+       char *str;
+
+       snrand(&you);
        point(&p,COLUMNS/2 - 8,LINES/2 - 1);
        if (p.col < 0)
                p.col = 0;
        if (p.line < 0)
                p.line = 0;
        if (w) {
        point(&p,COLUMNS/2 - 8,LINES/2 - 1);
        if (p.col < 0)
                p.col = 0;
        if (p.line < 0)
                p.line = 0;
        if (w) {
-               sprintf(str,"BONUS!!!");
+               str = "BONUS!!!";
                loot = loot - penalty;
                penalty = 0;
        } else {
                loot = loot - penalty;
                penalty = 0;
        } else {
-               sprintf(str,"SPACE WARP!!!");
+               str = "SPACE WARP!!!";
                penalty += loot/PENALTY;
        }
        for(j=0;j<3;j++){
                clear();
                delay(5);
                penalty += loot/PENALTY;
        }
        for(j=0;j<3;j++){
                clear();
                delay(5);
-               aprintf(&p,str);
+               apr(&p,str);
                delay(10);
        }
        setup();
                delay(10);
        }
        setup();
@@ -651,26 +641,26 @@ snap()
        if (! stretch(&money)) if (! stretch(&finish)) delay(10);
        if(you.line < 3){
                point(&p,you.col,0);
        if (! stretch(&money)) if (! stretch(&finish)) delay(10);
        if(you.line < 3){
                point(&p,you.col,0);
-               remove(&p);
+               chk(&p);
        }
        if(you.line > lcnt-4){
                point(&p,you.col,lcnt-1);
        }
        if(you.line > lcnt-4){
                point(&p,you.col,lcnt-1);
-               remove(&p);
+               chk(&p);
        }
        if(you.col < 10){
                point(&p,0,you.line);
        }
        if(you.col < 10){
                point(&p,0,you.line);
-               remove(&p);
+               chk(&p);
        }
        if(you.col > ccnt-10){
                point(&p,ccnt-1,you.line);
        }
        if(you.col > ccnt-10){
                point(&p,ccnt-1,you.line);
-               remove(&p);
+               chk(&p);
        }
        fflush(stdout);
 }
 stretch(ps)
 struct point *ps;{
        struct point p;
        }
        fflush(stdout);
 }
 stretch(ps)
 struct point *ps;{
        struct point p;
-       
+
        point(&p,you.col,you.line);
        if(abs(ps->col-you.col) < 6){
                if(you.line < ps->line){
        point(&p,you.col,you.line);
        if(abs(ps->col-you.col) < 6){
                if(you.line < ps->line){
@@ -678,13 +668,13 @@ struct point *ps;{
                                pchar(&p,'v');
                        delay(10);
                        for (;p.line > you.line;p.line--)
                                pchar(&p,'v');
                        delay(10);
                        for (;p.line > you.line;p.line--)
-                               remove(&p);
+                               chk(&p);
                } else {
                        for (p.line = you.line-1;p.line >= ps->line;p.line--)
                                pchar(&p,'^');
                        delay(10);
                        for (;p.line < you.line;p.line++)
                } else {
                        for (p.line = you.line-1;p.line >= ps->line;p.line--)
                                pchar(&p,'^');
                        delay(10);
                        for (;p.line < you.line;p.line++)
-                               remove(&p);
+                               chk(&p);
                }
                return(1);
        } else if(abs(ps->line-you.line) < 3){
                }
                return(1);
        } else if(abs(ps->line-you.line) < 3){
@@ -694,13 +684,13 @@ struct point *ps;{
                                pchar(&p,'>');
                        delay(10);
                        for (;p.col > you.col;p.col--)
                                pchar(&p,'>');
                        delay(10);
                        for (;p.col > you.col;p.col--)
-                               remove(&p);
+                               chk(&p);
                } else {
                        for (p.col = you.col-1;p.col >= ps->col;p.col--)
                                pchar(&p,'<');
                        delay(10);
                        for (;p.col < you.col;p.col++)
                } else {
                        for (p.col = you.col-1;p.col >= ps->col;p.col--)
                                pchar(&p,'<');
                        delay(10);
                        for (;p.col < you.col;p.col++)
-                               remove(&p);
+                               chk(&p);
                }
                return(1);
        }
                }
                return(1);
        }
@@ -716,20 +706,20 @@ struct point *ps;{
        if(ps->line == 0)ps->line++;
        if(ps->line == LINES -1)ps->line--;
        if(ps->col == COLUMNS -1)ps->col--;
        if(ps->line == 0)ps->line++;
        if(ps->line == LINES -1)ps->line--;
        if(ps->col == COLUMNS -1)ps->col--;
-       aprintf(point(&x,ps->col-1,ps->line-1),"/*\\\r* *\r\\*/");
+       apr(point(&x,ps->col-1,ps->line-1),"/*\\\r* *\r\\*/");
        for (j=0;j<20;j++){
                pchar(ps,'@');
                delay(1);
                pchar(ps,' ');
                delay(1);
        }
        for (j=0;j<20;j++){
                pchar(ps,'@');
                delay(1);
                pchar(ps,' ');
                delay(1);
        }
-       if (post(cashvalue,1)) {
-               aprintf(point(&x,ps->col-1,ps->line-1),"   \ro.o\r\\_/");
+       if (post(cashvalue,0)) {
+               apr(point(&x,ps->col-1,ps->line-1),"   \ro.o\r\\_/");
                delay(6);
                delay(6);
-               aprintf(point(&x,ps->col-1,ps->line-1),"   \ro.-\r\\_/");
+               apr(point(&x,ps->col-1,ps->line-1),"   \ro.-\r\\_/");
                delay(6);
        }
                delay(6);
        }
-       aprintf(point(&x,ps->col-1,ps->line-1),"   \ro.o\r\\_/");
+       apr(point(&x,ps->col-1,ps->line-1),"   \ro.o\r\\_/");
 }
 win(ps)
 struct point *ps;
 }
 win(ps)
 struct point *ps;
@@ -791,7 +781,7 @@ pushsnake()
                        i = (cashvalue) % 10;
                        bonus = ((rand()>>8) & 0377)% 10;
                        ll();
                        i = (cashvalue) % 10;
                        bonus = ((rand()>>8) & 0377)% 10;
                        ll();
-                       printf("%d\n", bonus);
+                       pr("%d\n", bonus);
                        delay(30);
                        if (bonus == i) {
                                spacewarp(1);
                        delay(30);
                        if (bonus == i) {
                                spacewarp(1);
@@ -800,9 +790,11 @@ pushsnake()
                                return(1);
                        }
                        if ( loot >= penalty ){
                                return(1);
                        }
                        if ( loot >= penalty ){
-                               printf("You and your $%d have been eaten\n",cashvalue);
+                               pr("You and your $%d have been eaten\n",
+                                   cashvalue);
                        } else {
                        } else {
-                               printf("The snake ate you.  You owe $%d.\n",-cashvalue);
+                               pr("The snake ate you.  You owe $%d.\n",
+                                   -cashvalue);
                        }
                        logit("eaten");
                        length(moves);
                        }
                        logit("eaten");
                        length(moves);
@@ -812,7 +804,7 @@ pushsnake()
        return(0);
 }
        
        return(0);
 }
        
-remove(sp)
+chk(sp)
 struct point *sp;
 {
        int j;
 struct point *sp;
 {
        int j;
@@ -855,12 +847,13 @@ int won;
        p.line = p.col = 1;
        if(won>0){
                move(&p);
        p.line = p.col = 1;
        if(won>0){
                move(&p);
-               printf("$%d",won);
+               pr("$%d",won);
        }
 }
 
        }
 }
 
+void
 stop(){
 stop(){
-       signal(SIGINT,1);
+       signal(SIGINT,SIG_IGN);
        ll();
        length(moves);
        done();
        ll();
        length(moves);
        done();
@@ -870,15 +863,9 @@ suspend()
 {
        char *sh;
 
 {
        char *sh;
 
+       ll();
        cook();
        cook();
-#ifdef SIGTSTP
        kill(getpid(), SIGTSTP);
        kill(getpid(), SIGTSTP);
-#else
-       sh = getenv("SHELL");
-       if (sh == NULL)
-               sh = "/bin/sh";
-       system(sh);
-#endif
        raw();
        setup();
        winnings(cashvalue);
        raw();
        setup();
        winnings(cashvalue);
@@ -887,7 +874,7 @@ suspend()
 length(num)
 int num;
 {
 length(num)
 int num;
 {
-       printf("You made %d moves.\n",num);
+       pr("You made %d moves.\n",num);
 }
 
 logit(msg)
 }
 
 logit(msg)
@@ -896,9 +883,10 @@ char *msg;
        FILE *logfile;
        long t;
 
        FILE *logfile;
        long t;
 
-       if ((logfile=fopen(LOGFILE, "a")) != NULL) {
+       if ((logfile=fopen(_PATH_LOGFILE, "a")) != NULL) {
                time(&t);
                time(&t);
-               fprintf(logfile, "%s $%d %dx%d %s %s", getlogin(), cashvalue, lcnt, ccnt, msg, ctime(&t));
+               fprintf(logfile, "%s $%d %dx%d %s %s",
+                   getlogin(), cashvalue, lcnt, ccnt, msg, ctime(&t));
                fclose(logfile);
        }
 }
                fclose(logfile);
        }
 }