BSD 4_3 release
[unix-history] / usr / src / games / worm.c
index ed69fcf..789ab9a 100644 (file)
@@ -1,3 +1,19 @@
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1980 Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif not lint
+
+#ifndef lint
+static char sccsid[] = "@(#)worm.c     5.2 (Berkeley) 6/25/85";
+#endif not lint
+
 /*
  * Worm.  Written by Michael Toy
  * UCSC
 /*
  * Worm.  Written by Michael Toy
  * UCSC
@@ -15,6 +31,9 @@
 #define when break;case
 #define otherwise break;default
 #define CNTRL(p) ('p'-'A'+1)
 #define when break;case
 #define otherwise break;default
 #define CNTRL(p) ('p'-'A'+1)
+#ifndef baudrate
+# define       baudrate()      _tty.sg_ospeed
+#endif
 
 WINDOW *tv;
 WINDOW *stw;
 
 WINDOW *tv;
 WINDOW *stw;
@@ -26,6 +45,7 @@ struct body {
 } *head, *tail, goody;
 int growing = 0;
 int running = 0;
 } *head, *tail, goody;
 int growing = 0;
 int running = 0;
+int slow = 0;
 int score = 0;
 int start_len = LENGTH;
 char lastch;
 int score = 0;
 int start_len = LENGTH;
 char lastch;
@@ -52,6 +72,7 @@ char **argv;
        initscr();
        crmode();
        noecho();
        initscr();
        crmode();
        noecho();
+       slow = (baudrate() <= B1200);
        clear();
        stw = newwin(1, COLS-1, 0, 0);
        tv = newwin(LINES-1, COLS-1, 1, 0);
        clear();
        stw = newwin(1, COLS-1, 0, 0);
        tv = newwin(LINES-1, COLS-1, 1, 0);
@@ -101,7 +122,6 @@ life()
        }
        tail = np;
        tail->prev = NULL;
        }
        tail = np;
        tail->prev = NULL;
-       wrefresh(tv);
 }
 
 display(pos, chr)
 }
 
 display(pos, chr)
@@ -207,8 +227,10 @@ char ch;
        nh->x = x;
        display(nh, HEAD);
        head = nh;
        nh->x = x;
        display(nh, HEAD);
        head = nh;
-       wrefresh(tv);
-       if (! running) alarm(1);
+       if (!(slow && running))
+               wrefresh(tv);
+       if (!running)
+               alarm(1);
 }
 
 crash()
 }
 
 crash()