121219Sdist /* 221219Sdist * Copyright (c) 1980 Regents of the University of California. 3*33487Sbostic * All rights reserved. 4*33487Sbostic * 5*33487Sbostic * Redistribution and use in source and binary forms are permitted 6*33487Sbostic * provided that this notice is preserved and that due credit is given 7*33487Sbostic * to the University of California at Berkeley. The name of the University 8*33487Sbostic * may not be used to endorse or promote products derived from this 9*33487Sbostic * software without specific prior written permission. This software 10*33487Sbostic * is provided ``as is'' without express or implied warranty. 1121219Sdist */ 126768Srrh 1321219Sdist #ifndef lint 14*33487Sbostic char copyright[] = 15*33487Sbostic "@(#) Copyright (c) 1980 Regents of the University of California.\n\ 16*33487Sbostic All rights reserved.\n"; 17*33487Sbostic #endif /* not lint */ 1821219Sdist 19*33487Sbostic #ifndef lint 20*33487Sbostic static char sccsid[] = "@(#)teach.c 5.4 (Berkeley) 02/16/88"; 21*33487Sbostic #endif /* not lint */ 22*33487Sbostic 236768Srrh #include "back.h" 246768Srrh 256768Srrh char *hello[]; 266768Srrh char *list[]; 276768Srrh char *intro1[]; 286768Srrh char *intro2[]; 296768Srrh char *moves[]; 306768Srrh char *remove[]; 316768Srrh char *hits[]; 326768Srrh char *endgame[]; 336768Srrh char *doubl[]; 346768Srrh char *stragy[]; 356768Srrh char *prog[]; 366768Srrh char *lastch[]; 376768Srrh 386768Srrh extern char ospeed; /* tty output speed for termlib */ 396768Srrh 406768Srrh char *helpm[] = { 416768Srrh "\nEnter a space or newline to roll, or", 426768Srrh " b to display the board", 436768Srrh " d to double", 446768Srrh " q to quit\n", 456768Srrh 0 466768Srrh }; 476768Srrh 486768Srrh char *contin[] = { 496768Srrh "", 506768Srrh 0 516768Srrh }; 526768Srrh 536768Srrh main (argc,argv) 546768Srrh int argc; 556768Srrh char **argv; 566768Srrh 576768Srrh { 586768Srrh register int i; 596768Srrh 606768Srrh signal (2,getout); 616768Srrh if (gtty (0,&tty) == -1) /* get old tty mode */ 626768Srrh errexit ("teachgammon(gtty)"); 636768Srrh old = tty.sg_flags; 646768Srrh #ifdef V7 656768Srrh raw = ((noech = old & ~ECHO) | CBREAK); /* set up modes */ 666768Srrh #else 676768Srrh raw = ((noech = old & ~ECHO) | RAW); /* set up modes */ 686768Srrh #endif 6933148Sbostic ospeed = tty.sg_ospeed; /* for termlib */ 706768Srrh tflag = getcaps (getenv ("TERM")); 716768Srrh #ifdef V7 726768Srrh while (*++argv != 0) 736768Srrh #else 746768Srrh while (*++argv != -1) 756768Srrh #endif 766768Srrh getarg (&argv); 776768Srrh if (tflag) { 786768Srrh noech &= ~(CRMOD|XTABS); 796768Srrh raw &= ~(CRMOD|XTABS); 806768Srrh clear(); 816768Srrh } 826768Srrh text (hello); 836768Srrh text (list); 846768Srrh i = text (contin); 856768Srrh if (i == 0) 866768Srrh i = 2; 876768Srrh init(); 886768Srrh while (i) 896768Srrh switch (i) { 906768Srrh 916768Srrh case 1: 926768Srrh leave(); 936768Srrh 946768Srrh case 2: 956768Srrh if (i = text(intro1)) 966768Srrh break; 976768Srrh wrboard(); 986768Srrh if (i = text(intro2)) 996768Srrh break; 1006768Srrh 1016768Srrh case 3: 1026768Srrh if (i = text(moves)) 1036768Srrh break; 1046768Srrh 1056768Srrh case 4: 1066768Srrh if (i = text(remove)) 1076768Srrh break; 1086768Srrh 1096768Srrh case 5: 1106768Srrh if (i = text(hits)) 1116768Srrh break; 1126768Srrh 1136768Srrh case 6: 1146768Srrh if (i = text(endgame)) 1156768Srrh break; 1166768Srrh 1176768Srrh case 7: 1186768Srrh if (i = text(doubl)) 1196768Srrh break; 1206768Srrh 1216768Srrh case 8: 1226768Srrh if (i = text(stragy)) 1236768Srrh break; 1246768Srrh 1256768Srrh case 9: 1266768Srrh if (i = text(prog)) 1276768Srrh break; 1286768Srrh 1296768Srrh case 10: 1306768Srrh if (i = text(lastch)) 1316768Srrh break; 1326768Srrh } 1336768Srrh tutor(); 1346768Srrh } 1356768Srrh 1366768Srrh leave() { 1376768Srrh if (tflag) 1386768Srrh clear(); 1396768Srrh else 1406768Srrh writec ('\n'); 1416768Srrh fixtty(old); 1426768Srrh execl (EXEC,"backgammon",args,"n",0); 1436768Srrh writel ("Help! Backgammon program is missing\007!!\n"); 1446768Srrh exit (-1); 1456768Srrh } 146