|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T c
Length: 27905 (0x6d01)
Types: TextFile
Names: »cent-sys5.patch«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Cent/cent-sys5.patch«
------------------------< Makefile >------------------------
Index: Makefile
*** cent.orig/Makefile Tue Jul 7 11:55:34 1987
--- cent/Makefile Tue Jul 7 14:34:19 1987
***************
*** 1,7
# makefile for centipede
# edit sys_dep.c to adjust pathnames for your system
#
! CFLAGS = -O
OBJECTS = cent.o stuff.o input.o interrupts.o score.o move.o rand.o \
save.o shoot.o la.o extern.o options.o sys_dep.o
--- 1,7 -----
# makefile for centipede
# edit sys_dep.c to adjust pathnames for your system
#
! CFLAGS = -O -DSYSV -Dindex=strchr
OBJECTS = cent.o stuff.o input.o interrupts.o score.o move.o rand.o \
save.o shoot.o la.o extern.o options.o sys_dep.o
***************
*** 7,13
save.o shoot.o la.o extern.o options.o sys_dep.o
cent: $(OBJECTS)
! cc -s -x -o cent $(OBJECTS) -lcurses -ltermcap -lm
cent.o stuff.o input.o move.o shoot.o save.o extern.o options.o: cent.h
input.o options.o: sys_dep.h
--- 7,13 -----
save.o shoot.o la.o extern.o options.o sys_dep.o
cent: $(OBJECTS)
! cc -o cent $(OBJECTS) -lcurses -lm
cent.o stuff.o input.o move.o shoot.o save.o extern.o options.o: cent.h
input.o options.o: sys_dep.h
------------------------< cent.c >------------------------
Index: cent.c
*** cent.orig/cent.c Tue Jul 7 11:55:35 1987
--- cent/cent.c Tue Jul 7 11:57:13 1987
***************
*** 18,23
printf("Usage: cent [-s] [savefile]\n");
exit(0);
}
signal(SIGTSTP,SIG_IGN);
signal(SIGQUIT,quit);
signal(SIGINT,SIG_IGN);
--- 18,24 -----
printf("Usage: cent [-s] [savefile]\n");
exit(0);
}
+ #ifndef SYSV
signal(SIGTSTP,SIG_IGN);
#endif
signal(SIGQUIT,catchint);
***************
*** 19,25
exit(0);
}
signal(SIGTSTP,SIG_IGN);
! signal(SIGQUIT,quit);
signal(SIGINT,SIG_IGN);
if (argc == 2 && !strcmp(argv[1],"-s"))
showscores();
--- 20,27 -----
}
#ifndef SYSV
signal(SIGTSTP,SIG_IGN);
! #endif
! signal(SIGQUIT,catchint);
signal(SIGINT,SIG_IGN);
if (argc == 2 && !strcmp(argv[1],"-s"))
showscores();
***************
*** 26,32
dooptions();
strcpy(name,getlogin());
#ifdef WIZARD
! author = !strcmp(name,"nathan");
if (author && getenv("CENTNAME") != NULL)
strcpy(name,getenv("CENTNAME"));
#endif
--- 28,34 -----
dooptions();
strcpy(name,getlogin());
#ifdef WIZARD
! author = !strcmp(name,"keith");
if (author && getenv("CENTNAME") != NULL)
strcpy(name,getenv("CENTNAME"));
#endif
***************
*** 52,57
else
instructions();
signal(SIGINT,catchint);
signal(SIGTSTP,catchstop);
signal(SIGALRM,catchalarm);
noecho();
--- 54,60 -----
else
instructions();
signal(SIGINT,catchint);
+ #ifndef SYSV
signal(SIGTSTP,catchstop);
#endif
signal(SIGALRM,catchalarm);
***************
*** 53,58
instructions();
signal(SIGINT,catchint);
signal(SIGTSTP,catchstop);
signal(SIGALRM,catchalarm);
noecho();
crmode();
--- 56,62 -----
signal(SIGINT,catchint);
#ifndef SYSV
signal(SIGTSTP,catchstop);
+ #endif
signal(SIGALRM,catchalarm);
noecho();
crmode();
------------------------< cent.h >------------------------
Index: cent.h
*** cent.orig/cent.h Tue Jul 7 11:55:38 1987
--- cent/cent.h Thu Jul 2 15:14:18 1987
***************
*** 4,9
#include <sys/types.h>
#include <sys/stat.h>
/* stdio.h and sgtty.h are included by curses.h */
#define FREEMAN 12000
#define CENTLENGTH 20
--- 4,13 -----
#include <sys/types.h>
#include <sys/stat.h>
/* stdio.h and sgtty.h are included by curses.h */
+ #ifdef SYSV
+ # include <fcntl.h>
+ # include <sgtty.h>
+ #endif
#define FREEMAN 12000
#define CENTLENGTH 20
------------------------< input.c >------------------------
Index: input.c
*** cent.orig/input.c Tue Jul 7 11:55:40 1987
--- cent/input.c Sat Jul 4 14:45:28 1987
***************
*** 1,6
#include "cent.h"
#include "sys_dep.h"
move_guy()
{
register int y, x, changed = 0;
--- 1,11 -----
#include "cent.h"
#include "sys_dep.h"
+ #ifdef SYSV
+ # undef getchar
+ # define getchar cget
+ #endif
+
move_guy()
{
register int y, x, changed = 0;
***************
*** 7,12
int count,repeat = 0;
char ch;
ioctl(0,FIONREAD,&count);
while (repeat || count--)
{
--- 12,18 -----
int count,repeat = 0;
char ch;
+ #ifndef SYSV
ioctl(0,FIONREAD,&count);
#else
if (cready()) count = 1;
***************
*** 8,13
char ch;
ioctl(0,FIONREAD,&count);
while (repeat || count--)
{
if (repeat)
--- 14,23 -----
#ifndef SYSV
ioctl(0,FIONREAD,&count);
+ #else
+ if (cready()) count = 1;
+ else count = 0;
+ #endif
while (repeat || count--)
{
if (repeat)
***************
*** 20,25
x = guy.x;
switch(ch)
{
case LEFT:
x--;
break;
--- 30,38 -----
x = guy.x;
switch(ch)
{
+ case '\014': /* KDW */
+ redrawscr(); refresh();
+ break;
case LEFT:
x--;
break;
***************
*** 113,116
}
if (changed)
refresh();
}
--- 126,193 -----
}
if (changed)
refresh();
+ }
+
+ /*
+ * KDW: setblock, cready and cget from Rochkind.
+ */
+
+ #define EMPTY '\0'
+
+ static char cbuf = EMPTY;
+
+ #define BOOLEAN int
+ #define FALSE 0
+ #define TRUE 1
+
+ setblock (fd, on)
+ int fd;
+ BOOLEAN on;
+ {
+ static int blockf, nonblockf;
+ static BOOLEAN first = TRUE;
+ int flags;
+
+ if (first)
+ {
+ first = FALSE;
+ if ((flags = fcntl(fd, F_GETFL, 0)) == -1)
+ perror("fcntl");
+ blockf = flags & ~O_NDELAY;
+ nonblockf = flags | O_NDELAY;
+ }
+ if (fcntl(fd, F_SETFL, on ? blockf : nonblockf) == -1)
+ perror("fcntl2");
+ }
+
+ BOOLEAN cready ()
+ {
+ if (cbuf != EMPTY)
+ return TRUE;
+ setblock(0, FALSE);
+ switch (read(0, &cbuf, 1))
+ {
+ case -1: perror("read"); break;
+ case 0: return FALSE;
+ default: return TRUE;
+ }
+ }
+
+ int cget ()
+ {
+ char c;
+
+ if (cbuf != EMPTY)
+ {
+ c = cbuf;
+ cbuf = EMPTY;
+ return c & 0377;
+ }
+ setblock(0, TRUE);
+ switch (read(0, &c, 1))
+ {
+ case -1: perror("read"); break;
+ case 0: return -1;
+ default: return c & 0377;
+ }
}
------------------------< interrupts.c >------------------------
Index: interrupts.c
*** cent.orig/interrupts.c Tue Jul 7 11:55:42 1987
--- cent/interrupts.c Tue Jul 7 14:37:05 1987
***************
*** 19,24
catchint()
{
signal(SIGINT,SIG_IGN);
signal(SIGTSTP,SIG_IGN);
inter = 1;
}
--- 19,25 -----
catchint()
{
signal(SIGINT,SIG_IGN);
+ #ifndef SYSV
signal(SIGTSTP,SIG_IGN);
#endif
inter = 1;
***************
*** 20,25
{
signal(SIGINT,SIG_IGN);
signal(SIGTSTP,SIG_IGN);
inter = 1;
}
--- 21,27 -----
signal(SIGINT,SIG_IGN);
#ifndef SYSV
signal(SIGTSTP,SIG_IGN);
+ #endif
inter = 1;
}
***************
*** 25,30
catchstop()
{
signal(SIGTSTP,SIG_IGN);
signal(SIGINT,SIG_IGN);
stopped = 1;
--- 27,33 -----
catchstop()
{
+ #ifndef SYSV
signal(SIGTSTP,SIG_IGN);
#endif
signal(SIGINT,SIG_IGN);
***************
*** 26,31
catchstop()
{
signal(SIGTSTP,SIG_IGN);
signal(SIGINT,SIG_IGN);
stopped = 1;
}
--- 29,35 -----
{
#ifndef SYSV
signal(SIGTSTP,SIG_IGN);
+ #endif
signal(SIGINT,SIG_IGN);
stopped = 1;
}
***************
*** 40,45
fflush(stdout);
ioctl(0,TIOCGETP,&curseterm);
ioctl(0,TIOCSETP,&origterm);
signal(SIGTSTP,SIG_DFL);
kill(getpid(),SIGTSTP);
signal(SIGTSTP,SIG_IGN);
--- 44,50 -----
fflush(stdout);
ioctl(0,TIOCGETP,&curseterm);
ioctl(0,TIOCSETP,&origterm);
+ #ifndef SYSV
signal(SIGTSTP,SIG_DFL);
kill(getpid(),SIGTSTP);
signal(SIGTSTP,SIG_IGN);
***************
*** 43,48
signal(SIGTSTP,SIG_DFL);
kill(getpid(),SIGTSTP);
signal(SIGTSTP,SIG_IGN);
stopped = 0;
ioctl(0,TIOCSETP,&curseterm);
redrawscr();
--- 48,54 -----
signal(SIGTSTP,SIG_DFL);
kill(getpid(),SIGTSTP);
signal(SIGTSTP,SIG_IGN);
+ #endif
stopped = 0;
ioctl(0,TIOCSETP,&curseterm);
redrawscr();
***************
*** 48,53
redrawscr();
ioctl(0,TIOCSETP,&curseterm); /* Just to make sure... */
waitboard();
signal(SIGTSTP,catchstop);
signal(SIGINT,catchint);
}
--- 54,60 -----
redrawscr();
ioctl(0,TIOCSETP,&curseterm); /* Just to make sure... */
waitboard();
+ #ifndef SYSV
signal(SIGTSTP,catchstop);
#endif
signal(SIGINT,catchint);
***************
*** 49,54
ioctl(0,TIOCSETP,&curseterm); /* Just to make sure... */
waitboard();
signal(SIGTSTP,catchstop);
signal(SIGINT,catchint);
}
--- 56,62 -----
waitboard();
#ifndef SYSV
signal(SIGTSTP,catchstop);
+ #endif
signal(SIGINT,catchint);
}
***************
*** 59,64
signal(SIGQUIT,SIG_IGN);
mvaddstr(12,60,"Really quit?");
refresh();
ch = getchar();
move(12,60);
clrtoeol();
--- 67,73 -----
signal(SIGQUIT,SIG_IGN);
mvaddstr(12,60,"Really quit?");
refresh();
+ #ifndef SYSV
ch = getchar();
#else
setblock(0, TRUE);
***************
*** 60,65
mvaddstr(12,60,"Really quit?");
refresh();
ch = getchar();
move(12,60);
clrtoeol();
refresh();
--- 69,79 -----
refresh();
#ifndef SYSV
ch = getchar();
+ #else
+ setblock(0, TRUE);
+ ch = getchar();
+ setblock(0, FALSE);
+ #endif
move(12,60);
clrtoeol();
refresh();
***************
*** 67,72
endgame();
inter = 0;
signal(SIGINT,catchint);
signal(SIGTSTP,catchstop);
signal(SIGQUIT,quit);
}
--- 81,87 -----
endgame();
inter = 0;
signal(SIGINT,catchint);
+ #ifndef SYSV
signal(SIGTSTP,catchstop);
#endif
signal(SIGQUIT,catchint);
***************
*** 68,74
inter = 0;
signal(SIGINT,catchint);
signal(SIGTSTP,catchstop);
! signal(SIGQUIT,quit);
}
waitboard()
--- 83,90 -----
signal(SIGINT,catchint);
#ifndef SYSV
signal(SIGTSTP,catchstop);
! #endif
! signal(SIGQUIT,catchint);
}
waitboard()
***************
*** 75,80
{
char ch;
signal(SIGTSTP,SIG_IGN);
signal(SIGINT,SIG_IGN);
mvaddstr(12,60,"Press return");
--- 91,97 -----
{
char ch;
+ #ifndef SYSV
signal(SIGTSTP,SIG_IGN);
#endif
signal(SIGINT,SIG_IGN);
***************
*** 76,81
char ch;
signal(SIGTSTP,SIG_IGN);
signal(SIGINT,SIG_IGN);
mvaddstr(12,60,"Press return");
mvaddstr(13,60,"when ready");
--- 93,99 -----
#ifndef SYSV
signal(SIGTSTP,SIG_IGN);
+ #endif
signal(SIGINT,SIG_IGN);
mvaddstr(12,60,"Press return");
mvaddstr(13,60,"when ready");
***************
*** 80,85
mvaddstr(12,60,"Press return");
mvaddstr(13,60,"when ready");
refresh();
while ((ch = getchar()) != '\r')
{
#ifdef WIZARD
--- 98,104 -----
mvaddstr(12,60,"Press return");
mvaddstr(13,60,"when ready");
refresh();
+ setblock(0, TRUE);
while ((ch = getchar()) != '\r')
{
#ifdef WIZARD
***************
*** 85,91
#ifdef WIZARD
if (ch == '\020')
setname();
! else if (ch == '\014')
#else
if (ch == '\014')
#endif
--- 104,110 -----
#ifdef WIZARD
if (ch == '\020')
setname();
! else if (ch == '\014' || ch == 'r')
#else
if (ch == '\014' || ch == 'r')
#endif
***************
*** 87,93
setname();
else if (ch == '\014')
#else
! if (ch == '\014')
#endif
redrawscr();
else if (ch == 's' || ch == 'S')
--- 106,112 -----
setname();
else if (ch == '\014' || ch == 'r')
#else
! if (ch == '\014' || ch == 'r')
#endif
redrawscr();
else if (ch == 's' || ch == 'S')
***************
*** 93,98
else if (ch == 's' || ch == 'S')
savegame();
}
move(12,60);
clrtoeol();
move(13,60);
--- 112,118 -----
else if (ch == 's' || ch == 'S')
savegame();
}
+ setblock(0, FALSE);
move(12,60);
clrtoeol();
move(13,60);
***************
*** 100,105
move(15,60);
clrtoeol();
signal(SIGINT,catchint);
signal(SIGTSTP,catchstop);
}
--- 120,126 -----
move(15,60);
clrtoeol();
signal(SIGINT,catchint);
+ #ifndef SYSV
signal(SIGTSTP,catchstop);
#endif
}
***************
*** 101,106
clrtoeol();
signal(SIGINT,catchint);
signal(SIGTSTP,catchstop);
}
catchalarm()
--- 122,128 -----
signal(SIGINT,catchint);
#ifndef SYSV
signal(SIGTSTP,catchstop);
+ #endif
}
catchalarm()
***************
*** 121,123
touchwin(stdscr);
refresh();
}
--- 143,146 -----
touchwin(stdscr);
refresh();
}
+
------------------------< la.c >------------------------
Index: la.c
*** cent.orig/la.c Tue Jul 7 11:55:42 1987
--- cent/la.c Thu Jul 2 16:28:20 1987
***************
*** 1,4
#include <nlist.h>
loadav(avenrun) /* Function storing 1,5,15 minute load averages in */
double *avenrun; /* avenrun; should be declared double avenrun[3]; */
--- 1,5 -----
#include <nlist.h>
+ #include <stdio.h>
loadav(avenrun) /* Function storing 1,5,15 minute load averages in */
double *avenrun; /* avenrun; should be declared double avenrun[3]; */
***************
*** 12,17
if (kmem < 0) /* Open necessary files. */
{
if ((kmem = open("/dev/kmem",0)) == -1)
return(-1); /* Cannot open. */
nlist("/vmunix", nl);
}
--- 13,20 -----
if (kmem < 0) /* Open necessary files. */
{
if ((kmem = open("/dev/kmem",0)) == -1)
+ {
+ syserror("Can't open /dev/kmem.");
return(-1); /* Cannot open. */
}
if (nlist("/vmunix", nl) == -1)
***************
*** 13,19
{
if ((kmem = open("/dev/kmem",0)) == -1)
return(-1); /* Cannot open. */
! nlist("/vmunix", nl);
}
if (lseek(kmem,(long)nl[0].n_value, 0) == -1 ||
read(kmem,avenrun,3 * sizeof(double)) == -1)
--- 16,28 -----
{
syserror("Can't open /dev/kmem.");
return(-1); /* Cannot open. */
! }
! if (nlist("/vmunix", nl) == -1)
! if (nlist("/unix", nl) == -1)
! {
! error("Can't get avenrun from nlist in kernel.");
! return -1;
! }
}
if (lseek(kmem,(long)nl[0].n_value, 0) == -1)
{
***************
*** 15,22
return(-1); /* Cannot open. */
nlist("/vmunix", nl);
}
! if (lseek(kmem,(long)nl[0].n_value, 0) == -1 ||
! read(kmem,avenrun,3 * sizeof(double)) == -1)
return(-1); /* sizeof avenrun is 24. */
return(0);
}
--- 24,32 -----
return -1;
}
}
! if (lseek(kmem,(long)nl[0].n_value, 0) == -1)
! {
! syserror("Can't seek in /dev/kmem.");
return(-1); /* sizeof avenrun is 24. */
}
if (read(kmem,avenrun,3 * sizeof(double)) == -1)
***************
*** 18,22
if (lseek(kmem,(long)nl[0].n_value, 0) == -1 ||
read(kmem,avenrun,3 * sizeof(double)) == -1)
return(-1); /* sizeof avenrun is 24. */
return(0);
}
--- 28,39 -----
{
syserror("Can't seek in /dev/kmem.");
return(-1); /* sizeof avenrun is 24. */
+ }
+ if (read(kmem,avenrun,3 * sizeof(double)) == -1)
+ {
+ syserror("Can't read from /dev/kmem.");
+ return(-1); /* sizeof avenrun is 24. */
+ }
return(0);
}
***************
*** 19,22
read(kmem,avenrun,3 * sizeof(double)) == -1)
return(-1); /* sizeof avenrun is 24. */
return(0);
}
--- 35,52 -----
return(-1); /* sizeof avenrun is 24. */
}
return(0);
+ }
+
+ syserror (str)
+ char *str;
+ {
+ extern int errno;
+ extern char *sys_errlist[];
+ fprintf(stderr, "%s (%s)\n", str, sys_errlist[errno]);
+ }
+
+ error (str)
+ char *str;
+ {
+ fprintf(stderr, "%s\n", str);
}
------------------------< move.c >------------------------
Index: move.c
*** cent.orig/move.c Tue Jul 7 11:55:44 1987
--- cent/move.c Thu Jul 2 14:55:37 1987
***************
*** 54,59
refresh();
fflush(stdout);
do
ioctl(1,TIOCOUTQ,&count);
while (count > spiderhere * 40);
move_guy();
--- 54,60 -----
refresh();
fflush(stdout);
do
+ #ifndef SYSV
ioctl(1,TIOCOUTQ,&count);
#else
count = 0;
***************
*** 55,60
fflush(stdout);
do
ioctl(1,TIOCOUTQ,&count);
while (count > spiderhere * 40);
move_guy();
}
--- 56,64 -----
do
#ifndef SYSV
ioctl(1,TIOCOUTQ,&count);
+ #else
+ count = 0;
+ #endif
while (count > spiderhere * 40);
move_guy();
}
------------------------< rand.c >------------------------
Index: rand.c
*** cent.orig/rand.c Tue Jul 7 11:55:46 1987
--- cent/rand.c Tue Jul 7 14:30:47 1987
***************
*** 4,9
#include <ctype.h>
#include <math.h>
#include <sys/types.h>
#include <sys/timeb.h>
double RandSeed,floor(),pow();
--- 4,10 -----
#include <ctype.h>
#include <math.h>
#include <sys/types.h>
+ #ifndef SYSV
#include <sys/timeb.h>
#endif
***************
*** 5,10
#include <math.h>
#include <sys/types.h>
#include <sys/timeb.h>
double RandSeed,floor(),pow();
--- 6,12 -----
#include <sys/types.h>
#ifndef SYSV
#include <sys/timeb.h>
+ #endif
double RandSeed,floor(),pow();
***************
*** 14,19
return (d-floor(d));
}
rninit() /* seed is of form .mmmsss (m = millisecs, s = secs) */
{
struct timeb tbuf;
--- 16,28 -----
return (d-floor(d));
}
+ #ifdef SYSV
+ rninit()
+ {
+ RandSeed = (double) time((long *) 0);
+ }
+
+ #else
rninit() /* seed is of form .mmmsss (m = millisecs, s = secs) */
{
struct timeb tbuf;
***************
*** 20,26
ftime(&tbuf);
RandSeed = tbuf.millitm/1000.0 + frac(tbuf.time/1000.0) / 1000.0;
! }
double rn() /* remainder of hairy exponential */
{
--- 29,36 -----
ftime(&tbuf);
RandSeed = tbuf.millitm/1000.0 + frac(tbuf.time/1000.0) / 1000.0;
! }
! #endif
double rn() /* remainder of hairy exponential */
{
***************
*** 26,28
{
return (RandSeed = frac(pow(RandSeed*4.32 + 3.52, 3.64)));
}
--- 36,39 -----
{
return (RandSeed = frac(pow(RandSeed*4.32 + 3.52, 3.64)));
}
+
------------------------< save.c >------------------------
Index: save.c
*** cent.orig/save.c Tue Jul 7 11:55:47 1987
--- cent/save.c Sat Jul 4 14:47:59 1987
***************
*** 9,14
savegame()
{
char fil[100];
if (!gamestarted)
{
--- 9,15 -----
savegame()
{
char fil[100];
+ struct sgttyb curseterm;
strcpy(fil, "cent.save");
if (!gamestarted)
***************
*** 10,15
{
char fil[100];
if (!gamestarted)
{
mvaddstr(15,60,"Too early to save");
--- 11,17 -----
char fil[100];
struct sgttyb curseterm;
+ strcpy(fil, "cent.save");
if (!gamestarted)
{
mvaddstr(15,60,"Too early to save");
***************
*** 16,21
refresh();
return;
}
printf("%s",CL);
nocrmode();
echo();
--- 18,27 -----
refresh();
return;
}
+ #ifdef SYSV
+ clear();
+ refresh();
+ #else
printf("%s",CL);
#endif
setblock(0, TRUE);
***************
*** 17,22
return;
}
printf("%s",CL);
nocrmode();
echo();
nl();
--- 23,30 -----
refresh();
#else
printf("%s",CL);
+ #endif
+ setblock(0, TRUE);
nocrmode();
echo();
nl();
***************
*** 21,26
echo();
nl();
printf("File name: ");
scanf("%s",fil);
noecho();
crmode();
--- 29,36 -----
echo();
nl();
printf("File name: ");
+ ioctl(0,TIOCGETP,&curseterm);
+ ioctl(0,TIOCSETP,&origterm);
scanf("%s",fil);
ioctl(0,TIOCSETP,&curseterm);
noecho();
***************
*** 22,27
nl();
printf("File name: ");
scanf("%s",fil);
noecho();
crmode();
printf("Saving... ");
--- 32,38 -----
ioctl(0,TIOCGETP,&curseterm);
ioctl(0,TIOCSETP,&origterm);
scanf("%s",fil);
+ ioctl(0,TIOCSETP,&curseterm);
noecho();
crmode();
printf("Saving... ");
***************
*** 106,112
dorest(fil)
{
int fd,n,count,tim;
! register char ch;
register int y,x;
char buf[512];
PEDE **piece = ¢ipede, *prev = NULL;
--- 117,123 -----
dorest(fil)
{
int fd,n,count,tim;
! char ch; /* KDW: was register; blasted for portability */
register int y,x;
char buf[512];
PEDE **piece = ¢ipede, *prev = NULL;
------------------------< score.c >------------------------
Index: score.c
*** cent.orig/score.c Tue Jul 7 11:55:48 1987
--- cent/score.c Tue Jul 7 15:07:33 1987
***************
*** 1,5
#include "cent.h"
struct score {
char name[10];
long score;
--- 1,9 -----
#include "cent.h"
+ extern char *def_pager, *def_pager_opts;
+
+ FILE *getpager ();
+
struct score {
char name[10];
long score;
***************
*** 40,46
if (wr = needtowrite(scores,numscores,&myscore))
if ((fd = creat(scorefile,0600)) == -1)
err();
! if ((morefp = popen("/usr/ucb/more","w")) == NULL)
{
perror("Error popen'ing more");
exit(1);
--- 44,50 -----
if (wr = needtowrite(scores,numscores,&myscore))
if ((fd = creat(scorefile,0600)) == -1)
err();
! if ((morefp = getpager()) == NULL)
{
perror("Error popen'ing cat");
exit(1);
***************
*** 42,48
err();
if ((morefp = popen("/usr/ucb/more","w")) == NULL)
{
! perror("Error popen'ing more");
exit(1);
}
printf("Centipede Hall of Fame\n");
--- 46,52 -----
err();
if ((morefp = getpager()) == NULL)
{
! perror("Error popen'ing cat");
exit(1);
}
printf("Centipede Hall of Fame\n");
***************
*** 100,106
lockscore();
if ((fd = open(scorefile,0)) == -1)
err();
! if ((morefp = popen("/usr/ucb/more","w")) == NULL)
{
perror("Error popen'ing more");
exit(1);
--- 104,110 -----
lockscore();
if ((fd = open(scorefile,0)) == -1)
err();
! if ((morefp = getpager()) == NULL)
{
perror("Error popen'ing cat");
exit(1);
***************
*** 102,108
err();
if ((morefp = popen("/usr/ucb/more","w")) == NULL)
{
! perror("Error popen'ing more");
exit(1);
}
printf("Centipede Hall of Fame\n");
--- 106,112 -----
err();
if ((morefp = getpager()) == NULL)
{
! perror("Error popen'ing cat");
exit(1);
}
printf("Centipede Hall of Fame\n");
***************
*** 147,150
perror("Error removing lockfile");
exit(-1);
}
}
--- 151,177 -----
perror("Error removing lockfile");
exit(-1);
}
+ }
+
+ /*
+ * KDW: getpager: figure out what pager to use to display the score file,
+ * and open a pipe to it.
+ */
+
+ FILE *getpager ()
+ {
+ FILE *morefp;
+ char *PAGER;
+
+ if ((PAGER = getenv("PAGER")) != NULL)
+ {
+ if ((morefp = popen(PAGER, "w")) != NULL)
+ return morefp;
+ }
+ if ((morefp = popen(def_pager, "w")) != NULL)
+ return morefp;
+ if ((morefp = popen("cat", "w")) != NULL)
+ return morefp;
+ else
+ return NULL;
}
------------------------< stuff.c >------------------------
Index: stuff.c
*** cent.orig/stuff.c Tue Jul 7 11:55:50 1987
--- cent/stuff.c Tue Jul 7 15:11:40 1987
***************
*** 1,5
#include "cent.h"
rnd(n)
register int n;
{
--- 1,7 -----
#include "cent.h"
+ extern char *def_pager, *def_pager_opts;
+
rnd(n)
register int n;
{
***************
*** 221,227
crmode();
if ((ch = getchar()) != 'y' && ch != 'Y')
return;
! sprintf(cmd,"/usr/ucb/more %s",helpfile);
system(cmd);
printf("[Hit return to start the game]");
while (getchar() != '\n');
--- 223,232 -----
crmode();
if ((ch = getchar()) != 'y' && ch != 'Y')
return;
! if (getenv("PAGER") == NULL)
! sprintf(cmd,"%s %s %s", def_pager, def_pager_opts, helpfile);
! else
! sprintf(cmd,"%s %s", getenv("PAGER"), helpfile);
system(cmd);
printf("[Hit return to start the game]");
while (getchar() != '\n');
------------------------< sys_dep.c >------------------------
Index: sys_dep.c
*** cent.orig/sys_dep.c Tue Jul 7 11:55:51 1987
--- cent/sys_dep.c Tue Jul 7 14:46:43 1987
***************
*** 3,9
/* Scorefile: Where the scorefile should live */
! char scorefile[] = "/usr/games/centipede/scores";
/* Lockfile: Where to create and look for a lockfile controlling access
--- 3,9 -----
/* Scorefile: Where the scorefile should live */
! char scorefile[] = "/usr/games/lib/cent/scorefile";
/* Lockfile: Where to create and look for a lockfile controlling access
***************
*** 8,14
/* Lockfile: Where to create and look for a lockfile controlling access
to the scorefile */
! char lockfile[] = "/usr/games/centipede/lockfile";
/* Helpfile: Where the help file is located */
--- 8,14 -----
/* Lockfile: Where to create and look for a lockfile controlling access
to the scorefile */
! char lockfile[] = "/usr/games/lib/cent/lockfile";
/* Helpfile: Where the help file is located */
***************
*** 12,18
/* Helpfile: Where the help file is located */
! char helpfile[] = "/usr/games/centipede/cent.doc";
/* Maxload: The maximum allowed load average for playing */
--- 12,18 -----
/* Helpfile: Where the help file is located */
! char helpfile[] = "/usr/games/lib/cent/cent.doc";
/* Maxload: The maximum allowed load average for playing */
***************
*** 21,23
/* Niceness: The amount to nice the game by (lower its priority) */
int niceness = 4;
--- 21,29 -----
/* Niceness: The amount to nice the game by (lower its priority) */
int niceness = 4;
+
+ /* def_pager: default pager if we can't otherwise choose one */
+ char *def_pager = "less";
+
+ /* def_pager_opts: options for default pager; include - if you need it */
+ char *def_pager_opts = "-qew";
------------------------< sys_dep.h >------------------------
Index: sys_dep.h
*** cent.orig/sys_dep.h Tue Jul 7 11:55:52 1987
--- cent/sys_dep.h Thu Jul 2 13:55:28 1987
***************
*** 1,8
/* User commands */
! #define LEFT '1'
! #define RIGHT '3'
! #define UPWARD '5'
! #define DOWN '.'
#define FIRE ' '
#define UPRIGHT '6'
#define UPLEFT '4'
--- 1,8 -----
/* User commands */
! #define LEFT 'h'
! #define RIGHT 'l'
! #define UPWARD 'k'
! #define DOWN 'j'
#define FIRE ' '
#define UPRIGHT 'u'
#define UPLEFT 'y'
***************
*** 4,13
#define UPWARD '5'
#define DOWN '.'
#define FIRE ' '
! #define UPRIGHT '6'
! #define UPLEFT '4'
! #define DOWNRIGHT '\r'
! #define DOWNLEFT '0'
! #define FASTLEFT '7'
! #define FASTRIGHT '9'
#define PAUSEKEY '\t'
--- 4,13 -----
#define UPWARD 'k'
#define DOWN 'j'
#define FIRE ' '
! #define UPRIGHT 'u'
! #define UPLEFT 'y'
! #define DOWNRIGHT 'n'
! #define DOWNLEFT 'b'
! #define FASTLEFT 'H'
! #define FASTRIGHT 'L'
#define PAUSEKEY '\t'