1*2010f3c8Smestre /* $OpenBSD: init_field.c,v 1.8 2016/01/04 17:33:24 mestre Exp $ */
2df930be7Sderaadt /* $NetBSD: init_field.c,v 1.3 1995/04/22 10:08:52 cgd Exp $ */
3df930be7Sderaadt
4df930be7Sderaadt /*
5df930be7Sderaadt * Copyright (c) 1980, 1993
6df930be7Sderaadt * The Regents of the University of California. All rights reserved.
7df930be7Sderaadt *
8df930be7Sderaadt * Redistribution and use in source and binary forms, with or without
9df930be7Sderaadt * modification, are permitted provided that the following conditions
10df930be7Sderaadt * are met:
11df930be7Sderaadt * 1. Redistributions of source code must retain the above copyright
12df930be7Sderaadt * notice, this list of conditions and the following disclaimer.
13df930be7Sderaadt * 2. Redistributions in binary form must reproduce the above copyright
14df930be7Sderaadt * notice, this list of conditions and the following disclaimer in the
15df930be7Sderaadt * documentation and/or other materials provided with the distribution.
167a09557bSmillert * 3. Neither the name of the University nor the names of its contributors
17df930be7Sderaadt * may be used to endorse or promote products derived from this software
18df930be7Sderaadt * without specific prior written permission.
19df930be7Sderaadt *
20df930be7Sderaadt * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21df930be7Sderaadt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22df930be7Sderaadt * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23df930be7Sderaadt * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24df930be7Sderaadt * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25df930be7Sderaadt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26df930be7Sderaadt * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27df930be7Sderaadt * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28df930be7Sderaadt * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29df930be7Sderaadt * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30df930be7Sderaadt * SUCH DAMAGE.
31df930be7Sderaadt */
32df930be7Sderaadt
33df930be7Sderaadt #include "robots.h"
34df930be7Sderaadt
35df930be7Sderaadt /*
36df930be7Sderaadt * init_field:
37d648d61bSpjanzen * Lay down the initial pattern which is constant across all levels,
38df930be7Sderaadt * and initialize all the global variables.
39df930be7Sderaadt */
40d648d61bSpjanzen void
init_field(void)413eb8c9edSjsg init_field(void)
42df930be7Sderaadt {
4397419aa0Spjanzen int i;
44df930be7Sderaadt static bool first = TRUE;
45df930be7Sderaadt static char *desc[] = {
46df930be7Sderaadt "Directions:",
47df930be7Sderaadt "",
48df930be7Sderaadt "y k u",
49df930be7Sderaadt " \\|/",
50df930be7Sderaadt "h- -l",
51df930be7Sderaadt " /|\\",
52df930be7Sderaadt "b j n",
53df930be7Sderaadt "",
54df930be7Sderaadt "Commands:",
55df930be7Sderaadt "",
56df930be7Sderaadt "w: wait for end",
57df930be7Sderaadt "t: teleport",
58df930be7Sderaadt "q: quit",
59df930be7Sderaadt "^L: redraw screen",
60df930be7Sderaadt "",
61df930be7Sderaadt "Legend:",
62df930be7Sderaadt "",
63df930be7Sderaadt "+: robot",
64df930be7Sderaadt "*: junk heap",
65df930be7Sderaadt "@: you",
66df930be7Sderaadt "",
67df930be7Sderaadt "Score: 0",
68df930be7Sderaadt NULL
69df930be7Sderaadt };
70df930be7Sderaadt
71df930be7Sderaadt Dead = FALSE;
72df930be7Sderaadt Waiting = FALSE;
7315eabdf8Stholo #ifndef NCURSES_VERSION
74df930be7Sderaadt flushok(stdscr, TRUE);
7515eabdf8Stholo #endif
76df930be7Sderaadt Score = 0;
77df930be7Sderaadt
78df930be7Sderaadt erase();
79df930be7Sderaadt move(0, 0);
80df930be7Sderaadt addch('+');
81df930be7Sderaadt for (i = 1; i < Y_FIELDSIZE; i++) {
82df930be7Sderaadt move(i, 0);
83df930be7Sderaadt addch('|');
84df930be7Sderaadt }
85df930be7Sderaadt move(Y_FIELDSIZE, 0);
86df930be7Sderaadt addch('+');
87df930be7Sderaadt for (i = 1; i < X_FIELDSIZE; i++)
88df930be7Sderaadt addch('-');
89df930be7Sderaadt addch('+');
90df930be7Sderaadt if (first)
91df930be7Sderaadt refresh();
92df930be7Sderaadt move(0, 1);
93df930be7Sderaadt for (i = 1; i < X_FIELDSIZE; i++)
94df930be7Sderaadt addch('-');
95df930be7Sderaadt addch('+');
96df930be7Sderaadt for (i = 1; i < Y_FIELDSIZE; i++) {
97df930be7Sderaadt move(i, X_FIELDSIZE);
98df930be7Sderaadt addch('|');
99df930be7Sderaadt }
100df930be7Sderaadt if (first)
101df930be7Sderaadt refresh();
102df930be7Sderaadt for (i = 0; desc[i] != NULL; i++) {
103df930be7Sderaadt move(i, X_FIELDSIZE + 2);
104df930be7Sderaadt addstr(desc[i]);
105df930be7Sderaadt }
106df930be7Sderaadt if (first)
107df930be7Sderaadt refresh();
108df930be7Sderaadt first = FALSE;
109df930be7Sderaadt #ifdef FANCY
110df930be7Sderaadt if (Pattern_roll)
111df930be7Sderaadt Next_move = &Move_list[-1];
112df930be7Sderaadt #endif
113df930be7Sderaadt }
114