1*e5aeb4eaSagc /* $NetBSD: init.c,v 1.8 2003/08/07 09:36:57 agc Exp $ */ 2101657d1Scgd 361f28255Scgd /* 4101657d1Scgd * Copyright (c) 1980, 1993 5101657d1Scgd * The Regents of the University of California. All rights reserved. 661f28255Scgd * 761f28255Scgd * Redistribution and use in source and binary forms, with or without 861f28255Scgd * modification, are permitted provided that the following conditions 961f28255Scgd * are met: 1061f28255Scgd * 1. Redistributions of source code must retain the above copyright 1161f28255Scgd * notice, this list of conditions and the following disclaimer. 1261f28255Scgd * 2. Redistributions in binary form must reproduce the above copyright 1361f28255Scgd * notice, this list of conditions and the following disclaimer in the 1461f28255Scgd * documentation and/or other materials provided with the distribution. 15*e5aeb4eaSagc * 3. Neither the name of the University nor the names of its contributors 1661f28255Scgd * may be used to endorse or promote products derived from this software 1761f28255Scgd * without specific prior written permission. 1861f28255Scgd * 1961f28255Scgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2061f28255Scgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2161f28255Scgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2261f28255Scgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2361f28255Scgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2461f28255Scgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2561f28255Scgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2661f28255Scgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2761f28255Scgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2861f28255Scgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2961f28255Scgd * SUCH DAMAGE. 3061f28255Scgd */ 3161f28255Scgd 3216641b76Slukem #include <sys/cdefs.h> 3361f28255Scgd #ifndef lint 34101657d1Scgd #if 0 35101657d1Scgd static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 5/31/93"; 36101657d1Scgd #else 37*e5aeb4eaSagc __RCSID("$NetBSD: init.c,v 1.8 2003/08/07 09:36:57 agc Exp $"); 38101657d1Scgd #endif 3961f28255Scgd #endif /* not lint */ 4061f28255Scgd 41eab5a765Smycroft #include <termios.h> 4261f28255Scgd 4361f28255Scgd /* 4461f28255Scgd * variable initialization. 4561f28255Scgd */ 4661f28255Scgd 4761f28255Scgd /* name of executable object programs */ 4892932dfcShubertf const char EXEC[] = "/usr/games/backgammon"; 4992932dfcShubertf const char TEACH[] = "/usr/games/teachgammon"; 5061f28255Scgd 5116641b76Slukem int pnum = 2; /* color of player: -1 = white 1 = red 0 = 5216641b76Slukem * both 2 = not yet init'ed */ 5361f28255Scgd int acnt = 0; /* length of args */ 5461f28255Scgd int aflag = 1; /* flag to ask for rules or instructions */ 5561f28255Scgd int bflag = 0; /* flag for automatic board printing */ 5661f28255Scgd int cflag = 0; /* case conversion flag */ 5761f28255Scgd int hflag = 1; /* flag for cleaning screen */ 5861f28255Scgd int mflag = 0; /* backgammon flag */ 5961f28255Scgd int raflag = 0; /* 'roll again' flag for recovered game */ 6061f28255Scgd int rflag = 0; /* recovered game flag */ 6161f28255Scgd int tflag = 0; /* cursor addressing flag */ 6261f28255Scgd int iroll = 0; /* special flag for inputting rolls */ 6361f28255Scgd int rfl = 0; 6461f28255Scgd 6592932dfcShubertf const char *const color[] = {"White", "Red", "white", "red"}; 66fafe3609Slukem 67fafe3609Slukem 6892932dfcShubertf const char *const *Colorptr; 6992932dfcShubertf const char *const *colorptr; 70fafe3609Slukem int *inopp; 71fafe3609Slukem int *inptr; 72fafe3609Slukem int *offopp; 73fafe3609Slukem int *offptr; 74fafe3609Slukem char args[100]; 75fafe3609Slukem int bar; 76fafe3609Slukem int begscr; 77fafe3609Slukem int board[26]; 78fafe3609Slukem char cin[100]; 79fafe3609Slukem int colen; 80fafe3609Slukem int cturn; 81fafe3609Slukem int curc; 82fafe3609Slukem int curr; 83fafe3609Slukem int d0; 84fafe3609Slukem int dice[2]; 85fafe3609Slukem int dlast; 86fafe3609Slukem int g[5]; 87fafe3609Slukem int gvalue; 88fafe3609Slukem int h[4]; 89fafe3609Slukem int home; 90fafe3609Slukem int in[2]; 91fafe3609Slukem int mvl; 92fafe3609Slukem int mvlim; 93fafe3609Slukem int ncin; 94fafe3609Slukem int off[2]; 95fafe3609Slukem int p[5]; 96fafe3609Slukem int rscore; 97fafe3609Slukem int table[6][6]; 98fafe3609Slukem int wscore; 99fafe3609Slukem struct termios old, noech, raw; 100