Annotation of 43BSDReno/games/backgammon/common_source/back.h, revision 1.1.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:  *     @(#)back.h      5.4 (Berkeley) 6/1/90
                     20:  */
                     21: 
                     22: #include <sgtty.h>
                     23: 
                     24: #define rnum(r)        (random()%r)
                     25: #define D0     dice[0]
                     26: #define D1     dice[1]
                     27: #define swap   {D0 ^= D1; D1 ^= D0; D0 ^= D1; d0 = 1-d0;}
                     28: 
                     29: /*
                     30:  *
                     31:  * Some numerical conventions:
                     32:  *
                     33:  *     Arrays have white's value in [0], red in [1].
                     34:  *     Numeric values which are one color or the other use
                     35:  *     -1 for white, 1 for red.
                     36:  *     Hence, white will be negative values, red positive one.
                     37:  *     This makes a lot of sense since white is going in decending
                     38:  *     order around the board, and red is ascending.
                     39:  *
                     40:  */
                     41: 
                     42: char   EXEC[];                 /* object for main program */
                     43: char   TEACH[];                /* object for tutorial program */
                     44: 
                     45: int    pnum;                   /* color of player:
                     46:                                        -1 = white
                     47:                                         1 = red
                     48:                                         0 = both
                     49:                                         2 = not yet init'ed */
                     50: char   args[100];              /* args passed to teachgammon and back */
                     51: int    acnt;                   /* length of args */
                     52: int    aflag;                  /* flag to ask for rules or instructions */
                     53: int    bflag;                  /* flag for automatic board printing */
                     54: int    cflag;                  /* case conversion flag */
                     55: int    hflag;                  /* flag for cleaning screen */
                     56: int    mflag;                  /* backgammon flag */
                     57: int    raflag;                 /* 'roll again' flag for recovered game */
                     58: int    rflag;                  /* recovered game flag */
                     59: int    tflag;                  /* cursor addressing flag */
                     60: int    rfl;                    /* saved value of rflag */
                     61: int    iroll;                  /* special flag for inputting rolls */
                     62: int    board[26];              /* board:  negative values are white,
                     63:                                   positive are red */
                     64: int    dice[2];                /* value of dice */
                     65: int    mvlim;                  /* 'move limit':  max. number of moves */
                     66: int    mvl;                    /* working copy of mvlim */
                     67: int    p[5];                   /* starting position of moves */
                     68: int    g[5];                   /* ending position of moves (goals) */
                     69: int    h[4];                   /* flag for each move if a man was hit */
                     70: int    cturn;                  /* whose turn it currently is:
                     71:                                        -1 = white
                     72:                                         1 = red
                     73:                                         0 = just quitted
                     74:                                        -2 = white just lost
                     75:                                         2 = red just lost */
                     76: int    d0;                     /* flag if dice have been reversed from
                     77:                                   original position */
                     78: int    table[6][6];            /* odds table for possible rolls */
                     79: int    rscore;                 /* red's score */
                     80: int    wscore;                 /* white's score */
                     81: int    gvalue;                 /* value of game (64 max.) */
                     82: int    dlast;                  /* who doubled last (0 = neither) */
                     83: int    bar;                    /* position of bar for current player */
                     84: int    home;                   /* position of home for current player */
                     85: int    off[2];                 /* number of men off board */
                     86: int    *offptr;                /* pointer to off for current player */
                     87: int    *offopp;                /* pointer to off for opponent */
                     88: int    in[2];                  /* number of men in inner table */
                     89: int    *inptr;                 /* pointer to in for current player */
                     90: int    *inopp;                 /* pointer to in for opponent */
                     91: 
                     92: int    ncin;                   /* number of characters in cin */
                     93: char   cin[100];               /* input line of current move
                     94:                                   (used for reconstructing input after
                     95:                                   a backspace) */
                     96: 
                     97: char   *color[];
                     98:                                /* colors as strings */
                     99: char   **colorptr;             /* color of current player */
                    100: char   **Colorptr;             /* color of current player, capitalized */
                    101: int    colen;                  /* length of color of current player */
                    102: 
                    103: struct sgttyb  tty;            /* tty information buffer */
                    104: int            old;            /* original tty status */
                    105: int            noech;          /* original tty status without echo */
                    106: int            raw;            /* raw tty status, no echo */
                    107: 
                    108: int    curr;                   /* row position of cursor */
                    109: int    curc;                   /* column position of cursor */
                    110: int    begscr;                 /* 'beginning' of screen
                    111:                                   (not including board) */
                    112: 
                    113: int    getout();               /* function to exit backgammon cleanly */

unix.superglobalmegacorp.com

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