Annotation of 43BSDReno/games/backgammon/teachgammon/teach.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.
        !             4:  *
        !             5:  * Redistribution and use in source and binary forms are permitted
        !             6:  * provided that: (1) source distributions retain this entire copyright
        !             7:  * notice and comment, and (2) distributions including binaries display
        !             8:  * the following acknowledgement:  ``This product includes software
        !             9:  * developed by the University of California, Berkeley and its contributors''
        !            10:  * in the documentation or other materials provided with the distribution
        !            11:  * and in all advertising materials mentioning features or use of this
        !            12:  * software. Neither the name of the University nor the names of its
        !            13:  * contributors may be used to endorse or promote products derived
        !            14:  * from this software without specific prior written permission.
        !            15:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
        !            16:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
        !            17:  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
        !            18:  */
        !            19: 
        !            20: #ifndef lint
        !            21: char copyright[] =
        !            22: "@(#) Copyright (c) 1980 Regents of the University of California.\n\
        !            23:  All rights reserved.\n";
        !            24: #endif /* not lint */
        !            25: 
        !            26: #ifndef lint
        !            27: static char sccsid[] = "@(#)teach.c    5.6 (Berkeley) 6/1/90";
        !            28: #endif /* not lint */
        !            29: 
        !            30: #include "back.h"
        !            31: 
        !            32: char   *hello[];
        !            33: char   *list[];
        !            34: char   *intro1[];
        !            35: char   *intro2[];
        !            36: char   *moves[];
        !            37: char   *remove[];
        !            38: char   *hits[];
        !            39: char   *endgame[];
        !            40: char   *doubl[];
        !            41: char   *stragy[];
        !            42: char   *prog[];
        !            43: char   *lastch[];
        !            44: 
        !            45: extern char    ospeed;                 /* tty output speed for termlib */
        !            46: 
        !            47: char *helpm[] = {
        !            48:        "\nEnter a space or newline to roll, or",
        !            49:        "     b   to display the board",
        !            50:        "     d   to double",
        !            51:        "     q   to quit\n",
        !            52:        0
        !            53: };
        !            54: 
        !            55: char *contin[] = {
        !            56:        "",
        !            57:        0
        !            58: };
        !            59: 
        !            60: main (argc,argv)
        !            61: int    argc;
        !            62: char   **argv;
        !            63: 
        !            64: {
        !            65:        register int    i;
        !            66: 
        !            67:        signal (2,getout);
        !            68:        if (gtty (0,&tty) == -1)                        /* get old tty mode */
        !            69:                errexit ("teachgammon(gtty)");
        !            70:        old = tty.sg_flags;
        !            71: #ifdef V7
        !            72:        raw = ((noech = old & ~ECHO) | CBREAK);         /* set up modes */
        !            73: #else
        !            74:        raw = ((noech = old & ~ECHO) | RAW);            /* set up modes */
        !            75: #endif
        !            76:        ospeed = tty.sg_ospeed;                         /* for termlib */
        !            77:        tflag = getcaps (getenv ("TERM"));
        !            78: #ifdef V7
        !            79:        while (*++argv != 0)
        !            80: #else
        !            81:        while (*++argv != -1)
        !            82: #endif
        !            83:                getarg (&argv);
        !            84:        if (tflag)  {
        !            85:                noech &= ~(CRMOD|XTABS);
        !            86:                raw &= ~(CRMOD|XTABS);
        !            87:                clear();
        !            88:        }
        !            89:        text (hello);
        !            90:        text (list);
        !            91:        i = text (contin);
        !            92:        if (i == 0)
        !            93:                i = 2;
        !            94:        init();
        !            95:        while (i)
        !            96:                switch (i)  {
        !            97:                
        !            98:                case 1:
        !            99:                        leave();
        !           100:                
        !           101:                case 2:
        !           102:                        if (i = text(intro1))
        !           103:                                break;
        !           104:                        wrboard();
        !           105:                        if (i = text(intro2))
        !           106:                                break;
        !           107:                
        !           108:                case 3:
        !           109:                        if (i = text(moves))
        !           110:                                break;
        !           111:                
        !           112:                case 4:
        !           113:                        if (i = text(remove))
        !           114:                                break;
        !           115:                
        !           116:                case 5:
        !           117:                        if (i = text(hits))
        !           118:                                break;
        !           119:                
        !           120:                case 6:
        !           121:                        if (i = text(endgame))
        !           122:                                break;
        !           123:                
        !           124:                case 7:
        !           125:                        if (i = text(doubl))
        !           126:                                break;
        !           127:                
        !           128:                case 8:
        !           129:                        if (i = text(stragy))
        !           130:                                break;
        !           131:                
        !           132:                case 9:
        !           133:                        if (i = text(prog))
        !           134:                                break;
        !           135:                
        !           136:                case 10:
        !           137:                        if (i = text(lastch))
        !           138:                                break;
        !           139:                }
        !           140:        tutor();
        !           141: }
        !           142: 
        !           143: leave()  {
        !           144:        if (tflag)
        !           145:                clear();
        !           146:        else
        !           147:                writec ('\n');
        !           148:        fixtty(old);
        !           149:        execl (EXEC,"backgammon",args,"n",0);
        !           150:        writel ("Help! Backgammon program is missing\007!!\n");
        !           151:        exit (-1);
        !           152: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.