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