diff options
Diffstat (limited to 'backgammon/teachgammon/teach.c')
-rw-r--r-- | backgammon/teachgammon/teach.c | 127 |
1 files changed, 59 insertions, 68 deletions
diff --git a/backgammon/teachgammon/teach.c b/backgammon/teachgammon/teach.c index 3eaf2739..f473d044 100644 --- a/backgammon/teachgammon/teach.c +++ b/backgammon/teachgammon/teach.c @@ -1,4 +1,4 @@ -/* $NetBSD: teach.c,v 1.4 1995/04/29 00:44:18 mycroft Exp $ */ +/* $NetBSD: teach.c,v 1.5 1997/10/10 08:59:52 lukem Exp $ */ /* * Copyright (c) 1980, 1993 @@ -33,38 +33,26 @@ * SUCH DAMAGE. */ +#include <sys/cdefs.h> #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1980, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ +__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); +#endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)teach.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: teach.c,v 1.4 1995/04/29 00:44:18 mycroft Exp $"; +__RCSID("$NetBSD: teach.c,v 1.5 1997/10/10 08:59:52 lukem Exp $"); #endif -#endif /* not lint */ +#endif /* not lint */ #include "back.h" +#include "tutor.h" -char *hello[]; -char *list[]; -char *intro1[]; -char *intro2[]; -char *moves[]; -char *remove[]; -char *hits[]; -char *endgame[]; -char *doubl[]; -char *stragy[]; -char *prog[]; -char *lastch[]; - -extern speed_t ospeed; /* tty output speed for termlib */ - -char *helpm[] = { +extern speed_t ospeed; /* tty output speed for termlib */ + +char *helpm[] = { "\nEnter a space or newline to roll, or", " b to display the board", " d to double", @@ -72,99 +60,102 @@ char *helpm[] = { 0 }; -char *contin[] = { +char *contin[] = { "", 0 }; -main (argc,argv) -int argc; -char **argv; - +int +main(argc, argv) + int argc; + char *argv[]; { - register int i; + int i; - signal (2,getout); - if (tcgetattr (0, &old) == -1) /* get old tty mode */ - errexit ("teachgammon(gtty)"); + signal(2, getout); + if (tcgetattr(0, &old) == -1) /* get old tty mode */ + errexit("teachgammon(gtty)"); noech = old; noech.c_lflag &= ~ECHO; raw = noech; - raw.c_lflag &= ~ICANON; /* set up modes */ - ospeed = cfgetospeed (&old); /* for termlib */ - tflag = getcaps (getenv ("TERM")); + raw.c_lflag &= ~ICANON; /* set up modes */ + ospeed = cfgetospeed(&old); /* for termlib */ + tflag = getcaps(getenv("TERM")); #ifdef V7 while (*++argv != 0) #else while (*++argv != -1) #endif - getarg (&argv); - if (tflag) { - noech.c_oflag &= ~(ONLCR|OXTABS); - raw.c_oflag &= ~(ONLCR|OXTABS); + getarg(&argv); + if (tflag) { + noech.c_oflag &= ~(ONLCR | OXTABS); + raw.c_oflag &= ~(ONLCR | OXTABS); clear(); } - text (hello); - text (list); - i = text (contin); + text(hello); + text(list); + i = text(contin); if (i == 0) i = 2; init(); while (i) - switch (i) { - + switch (i) { case 1: leave(); - + case 2: - if (i = text(intro1)) + if ((i = text(intro1)) != 0) break; wrboard(); - if (i = text(intro2)) + if ((i = text(intro2)) != 0) break; - + case 3: - if (i = text(moves)) + if ((i = text(moves)) != 0) break; - + case 4: - if (i = text(remove)) + if ((i = text(removepiece)) != 0) break; - + case 5: - if (i = text(hits)) + if ((i = text(hits)) != 0) break; - + case 6: - if (i = text(endgame)) + if ((i = text(endgame)) != 0) break; - + case 7: - if (i = text(doubl)) + if ((i = text(doubl)) != 0) break; - + case 8: - if (i = text(stragy)) + if ((i = text(stragy)) != 0) break; - + case 9: - if (i = text(prog)) + if ((i = text(prog)) != 0) break; - + case 10: - if (i = text(lastch)) + if ((i = text(lastch)) != 0) break; } tutor(); + /* NOTREACHED */ + return (0); } -leave() { +void +leave() +{ if (tflag) clear(); else - writec ('\n'); + writec('\n'); fixtty(&old); - execl (EXEC,"backgammon",args,"n",0); - writel ("Help! Backgammon program is missing\007!!\n"); - exit (-1); + execl(EXEC, "backgammon", args, "n", 0); + writel("Help! Backgammon program is missing\007!!\n"); + exit(-1); } |