1 /* 2 * Copyright (c) 1980 Regents of the University of California. 3 * All rights reserved. The Berkeley software License Agreement 4 * specifies the terms and conditions for redistribution. 5 */ 6 7 #ifndef lint 8 static char sccsid[] = "@(#)teach.c 5.1 (Berkeley) 05/29/85"; 9 #endif not lint 10 11 #include "back.h" 12 13 char *hello[]; 14 char *list[]; 15 char *intro1[]; 16 char *intro2[]; 17 char *moves[]; 18 char *remove[]; 19 char *hits[]; 20 char *endgame[]; 21 char *doubl[]; 22 char *stragy[]; 23 char *prog[]; 24 char *lastch[]; 25 26 extern char ospeed; /* tty output speed for termlib */ 27 28 char *helpm[] = { 29 "\nEnter a space or newline to roll, or", 30 " b to display the board", 31 " d to double", 32 " q to quit\n", 33 0 34 }; 35 36 char *contin[] = { 37 "", 38 0 39 }; 40 41 main (argc,argv) 42 int argc; 43 char **argv; 44 45 { 46 register char *s, *ts[]; 47 register int i; 48 49 signal (2,getout); 50 if (gtty (0,&tty) == -1) /* get old tty mode */ 51 errexit ("teachgammon(gtty)"); 52 old = tty.sg_flags; 53 #ifdef V7 54 raw = ((noech = old & ~ECHO) | CBREAK); /* set up modes */ 55 #else 56 raw = ((noech = old & ~ECHO) | RAW); /* set up modes */ 57 #endif 58 ospeed = old.sg_ospeed; /* for termlib */ 59 tflag = getcaps (getenv ("TERM")); 60 #ifdef V7 61 while (*++argv != 0) 62 #else 63 while (*++argv != -1) 64 #endif 65 getarg (&argv); 66 if (tflag) { 67 noech &= ~(CRMOD|XTABS); 68 raw &= ~(CRMOD|XTABS); 69 clear(); 70 } 71 text (hello); 72 text (list); 73 i = text (contin); 74 if (i == 0) 75 i = 2; 76 init(); 77 while (i) 78 switch (i) { 79 80 case 1: 81 leave(); 82 83 case 2: 84 if (i = text(intro1)) 85 break; 86 wrboard(); 87 if (i = text(intro2)) 88 break; 89 90 case 3: 91 if (i = text(moves)) 92 break; 93 94 case 4: 95 if (i = text(remove)) 96 break; 97 98 case 5: 99 if (i = text(hits)) 100 break; 101 102 case 6: 103 if (i = text(endgame)) 104 break; 105 106 case 7: 107 if (i = text(doubl)) 108 break; 109 110 case 8: 111 if (i = text(stragy)) 112 break; 113 114 case 9: 115 if (i = text(prog)) 116 break; 117 118 case 10: 119 if (i = text(lastch)) 120 break; 121 } 122 tutor(); 123 } 124 125 leave() { 126 if (tflag) 127 clear(); 128 else 129 writec ('\n'); 130 fixtty(old); 131 execl (EXEC,"backgammon",args,"n",0); 132 writel ("Help! Backgammon program is missing\007!!\n"); 133 exit (-1); 134 } 135