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