Sweep-fix comparing pointers with 0 (and assigning 0 to pointers).
[games.git] / games / backgammon / backgammon / text.c
1 /*-
2  * Copyright (c) 1980, 1993
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * @(#)text.c   8.1 (Berkeley) 5/31/93
30  * $FreeBSD: src/games/backgammon/backgammon/text.c,v 1.5 1999/11/30 03:48:23 billf Exp $
31  */
32
33 #include "back.h"
34
35 const char *const instr[] = {
36     "    If you did not notice by now, this program reacts to things as",
37     "soon as you type them, without waiting for a newline.  This means that",
38     "the special characters RUBOUT, ESC, and CONTROL-D, will not perform",
39     "their special functions during most of this program.  The program",
40     "should usually stop when a RUBOUT is typed, but occasionally it will",
41     "ignore RUBOUTs until it is waiting for input.\n",
42     "    These instructions are presented in small chunks designed not to",
43     "roll off the top of your screen.  When the characters '-->' are print-",
44     "ed, no more data will be printed until a space or newline is typed.",
45     "In this way, you can finish one section before continuing to another.",
46     "Like this:",
47     "",
48     "    The two sides are colored 'red' and 'white.' The computer may play",
49     "one side, or if there are two players, the computer can merely act as",
50     "a gamekeeper, letting the players make the moves.  Once you tell the",
51     "computer what color(s) you want to play, the decision remains in ef-",
52     "fect until you quit the program, even if you play more than one game,",
53     "since the program keeps a running score.\n",
54     "    The program will prompt for a move in one of two ways.  If the",
55     "player has the opportunity to double, then merely his color will be",
56     "typed out.  The player can now do one of several things.  He can dou-",
57     "ble by typing a 'd', he can roll by typing a space (' ') or newline,",
58     "or if he is not sure, he can reprint the board by typing a 'r'.\n",
59     "    If the player cannot double, his roll will be thrust in front of",
60     "him, followed by the request 'Move:', asking for a move but not giving",
61     "him the chance to double.  He can still ask for the board by typing",
62     "'r'.  In either of these two states, the player can quit by typing 'q'",
63     "or save the game by typing 's'.  In either case, the player will be",
64     "asked to verify, in case there was some error.  The program then ends",
65     "immediately, after first saving the file if so requested.",
66     "",
67     "    A player can move one of his men using two forms of input.  The",
68     "first form is <s>-<f>, where <s> is the starting position, and <f> is",
69     "the finishing position of the player's man.  For example, if white",
70     "wanted to move a piece from position 13 to position 8, his move could",
71     "be entered as 13-8.  The second form is <s>/<r> where <s> is the",
72     "starting position, an <r> is the roll actually made.  Hence, white",
73     "could have entered as 13/5 instead of 13-8.\n",
74     "    A player must move each roll of the dice separately.  For example,",
75     "if a player rolled 4 3, and wanted to move from 13 to 6, he could",
76     "enter it as 13/4,9/3 or 13/3,10/4 or 13-10,10-6 or 13-9,9-6, but not",
77     "13-6.  The last two entries can be shortened to 13-10-6 and 13-9-6.",
78     "If you want to move more than one piece from the same position, such",
79     "as 13-10,13-9, you can abbreviate this using the <s>/<r> format as by",
80     "entering more than one <r>, or 13/34.  A player can use both forms for",
81     "the same roll, e.g. 13/3,13-9, and separates individual moves by ei-",
82     "ther a comma or a space.  The letter 'b' represents the bar, and the",
83     "letter 'h' represents a player's home.  You could also enter the",
84     "number that would be in the position of the bar, 25 or 0 as appropri-",
85     "ate.  Use a newline at the end of your moves for a turn.",
86     "",
87     "    As you type in your move, if a character does not make sense under",
88     "the above constrictions, a bell will sound instead of the character,",
89     "and it will be ignored.  You may kill lines and erase characters as",
90     "you would normally, but don't be surprised if they look different than",
91     "usual.  Also, if you have entered one or more of your rolls, and you",
92     "wish to see what the move looks like so far, type a 'r' to see what it",
93     "looks like.  This cannot be done in the middle of a move (e.g., after",
94     "a '-' or '/').  After the printing board, the program will go back to",
95     "inputting your move and you can backspace or kill just as if you had",
96     "just typed in your input.\n",
97     "    Now you should be ready to begin the game.  Good luck!",
98     "",
99     0};
100
101 void
102 text(const char *const *t)
103 {
104         int i;
105         const char *s, *a;
106
107         fixtty(noech);
108         while (*t != NULL) {
109                 s = a = *t;
110                 for (i = 0; *a != '\0'; i--)
111                         a++;
112                 if (i) {
113                         writel(s);
114                         writec('\n');
115                 } else {
116                         writel("-->");
117                         fixtty(raw);
118                         while ((i = readc()) != ' ' && i != '\n');
119                         fixtty(noech);
120                         clear();
121                 }
122                 t++;
123         }
124         fixtty(raw);
125 }