]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - backgammon/common_source/table.c
1 /* $NetBSD: table.c,v 1.7 2003/08/07 09:36:57 agc Exp $ */
4 * Copyright (c) 1980, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #include <sys/cdefs.h>
35 static char sccsid
[] = "@(#)table.c 8.1 (Berkeley) 5/31/93";
37 __RCSID("$NetBSD: table.c,v 1.7 2003/08/07 09:36:57 agc Exp $");
43 const char *const help2
[] = {
44 " Enter moves as <s>-<f> or <s>/<r> where <s> is the starting",
45 "position, <f> is the finishing position, and <r> is the roll.",
46 "Remember, each die roll must be moved separately.",
56 static const struct state atmata
[] = {
58 {'R', 1, 0}, {'?', 7, 0}, {'Q', 0, -3}, {'B', 8, 25},
59 {'9', 2, 25}, {'8', 2, 25}, {'7', 2, 25}, {'6', 2, 25},
60 {'5', 2, 25}, {'4', 2, 25}, {'3', 2, 25}, {'2', 2, 19},
61 {'1', 2, 15}, {'0', 2, 25}, {'.', 0, 0}, {'9', 2, 25},
62 {'8', 2, 25}, {'7', 2, 25}, {'6', 2, 25}, {'5', 2, 25},
64 {'4', 2, 25}, {'3', 2, 25}, {'2', 2, 25}, {'1', 2, 25},
65 {'0', 2, 25}, {'/', 0, 32}, {'-', 0, 39}, {'.', 0, 0},
66 {'/', 5, 32}, {' ', 6, 3}, {',', 6, 3}, {'\n', 0, -1},
67 {'6', 3, 28}, {'5', 3, 28}, {'4', 3, 28}, {'3', 3, 28},
68 {'2', 3, 28}, {'1', 3, 28}, {'.', 0, 0}, {'H', 9, 61},
70 {'9', 4, 61}, {'8', 4, 61}, {'7', 4, 61}, {'6', 4, 61},
71 {'5', 4, 61}, {'4', 4, 61}, {'3', 4, 61}, {'2', 4, 53},
72 {'1', 4, 51}, {'0', 4, 61}, {'.', 0, 0}, {'9', 4, 61},
73 {'8', 4, 61}, {'7', 4, 61}, {'6', 4, 61}, {'5', 4, 61},
74 {'4', 4, 61}, {'3', 4, 61}, {'2', 4, 61}, {'1', 4, 61},
76 {'0', 4, 61}, {' ', 6, 3}, {',', 6, 3}, {'-', 5, 39},
77 {'\n', 0, -1}, {'.', 0, 0}
96 for (j
= 0; j
< 5; j
++)
106 curmove(cturn
== -1 ? 18 : 19, 39);
115 if (c
== old
.c_cc
[VERASE
] && ncin
> 0) {
117 curmove(curr
, curc
- 1);
119 if (old
.c_cc
[VERASE
] == '\010')
122 writec(cin
[ncin
- 1]);
135 if (c
== old
.c_cc
[VKILL
] && ncin
> 0) {
142 if (old
.c_cc
[VERASE
] == '\010') {
143 for (j
= 0; j
< ncin
; j
++)
159 if ((!tflag
) || c
!= '\n')
167 if (n
== -1 && mvl
>= mvlim
)
169 if (n
== -1 && mvl
< mvlim
- 1)
174 if (movokay(mvl
+ 1)) {
179 writel("\t\tMove: ");
180 for (j
= 0; j
< ncin
;)
183 if (movokay(mvl
+ 1)) {
187 curmove(cturn
== -1 ? 18 : 19, ncin
+ 39);
208 while ((a
= atmata
[i
].ch
) != '.') {
209 if (a
== c
|| (test
&& a
== '\n')) {
210 switch (atmata
[i
].fcode
) {
215 curmove(cturn
== -1 ? 18 : 19, 0);
226 p
[mvl
] = p
[mvl
] * 10 + c
- '0';
235 g
[mvl
] = p
[mvl
] + cturn
* (c
- '0');
246 g
[mvl
] = g
[mvl
] * 10 + c
- '0';
267 curmove(cturn
== -1 ? 18 : 19, 39);
271 writel("\t\tMove: ");
283 if (!test
|| a
!= '\n')
284 return (atmata
[i
].newst
);
301 for (i
= 0; i
< 4; i
++)
303 for (j
= 0; j
< ncin
; j
++)
304 n
= dotable(cin
[j
], n
);