robots.h revision 1.11 1 1.11 jsm /* $NetBSD: robots.h,v 1.11 1999/09/08 21:17:57 jsm Exp $ */
2 1.4 cgd
3 1.1 cgd /*
4 1.4 cgd * Copyright (c) 1980, 1993
5 1.4 cgd * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * Redistribution and use in source and binary forms, with or without
8 1.1 cgd * modification, are permitted provided that the following conditions
9 1.1 cgd * are met:
10 1.1 cgd * 1. Redistributions of source code must retain the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer.
12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer in the
14 1.1 cgd * documentation and/or other materials provided with the distribution.
15 1.1 cgd * 3. All advertising materials mentioning features or use of this software
16 1.1 cgd * must display the following acknowledgement:
17 1.1 cgd * This product includes software developed by the University of
18 1.1 cgd * California, Berkeley and its contributors.
19 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
20 1.1 cgd * may be used to endorse or promote products derived from this software
21 1.1 cgd * without specific prior written permission.
22 1.1 cgd *
23 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 cgd * SUCH DAMAGE.
34 1.1 cgd *
35 1.4 cgd * @(#)robots.h 8.1 (Berkeley) 5/31/93
36 1.1 cgd */
37 1.1 cgd
38 1.6 lukem # include <sys/ttydefaults.h>
39 1.6 lukem # include <ctype.h>
40 1.1 cgd # include <curses.h>
41 1.7 lukem # include <err.h>
42 1.6 lukem # include <fcntl.h>
43 1.6 lukem # include <pwd.h>
44 1.1 cgd # include <setjmp.h>
45 1.6 lukem # include <signal.h>
46 1.6 lukem # include <stdlib.h>
47 1.5 cgd # include <string.h>
48 1.6 lukem # include <termios.h>
49 1.6 lukem # include <unistd.h>
50 1.1 cgd
51 1.1 cgd /*
52 1.1 cgd * miscellaneous constants
53 1.1 cgd */
54 1.1 cgd
55 1.1 cgd # define Y_FIELDSIZE 23
56 1.1 cgd # define X_FIELDSIZE 60
57 1.1 cgd # define Y_SIZE 24
58 1.1 cgd # define X_SIZE 80
59 1.1 cgd # define MAXLEVELS 4
60 1.1 cgd # define MAXROBOTS (MAXLEVELS * 10)
61 1.1 cgd # define ROB_SCORE 10
62 1.1 cgd # define S_BONUS (60 * ROB_SCORE)
63 1.1 cgd # define Y_SCORE 21
64 1.1 cgd # define X_SCORE (X_FIELDSIZE + 9)
65 1.1 cgd # define Y_PROMPT (Y_FIELDSIZE - 1)
66 1.1 cgd # define X_PROMPT (X_FIELDSIZE + 2)
67 1.1 cgd # define MAXSCORES (Y_SIZE - 2)
68 1.1 cgd # define MAXNAME 16
69 1.1 cgd # define MS_NAME "Ten"
70 1.1 cgd
71 1.1 cgd /*
72 1.1 cgd * characters on screen
73 1.1 cgd */
74 1.1 cgd
75 1.1 cgd # define ROBOT '+'
76 1.1 cgd # define HEAP '*'
77 1.1 cgd # define PLAYER '@'
78 1.1 cgd
79 1.1 cgd /*
80 1.1 cgd * type definitions
81 1.1 cgd */
82 1.1 cgd
83 1.1 cgd typedef struct {
84 1.1 cgd int y, x;
85 1.1 cgd } COORD;
86 1.1 cgd
87 1.6 lukem typedef struct {
88 1.9 christos u_int32_t s_uid;
89 1.9 christos u_int32_t s_score;
90 1.9 christos u_int32_t s_auto;
91 1.9 christos u_int32_t s_level;
92 1.9 christos char s_name[MAXNAME];
93 1.6 lukem } SCORE;
94 1.6 lukem
95 1.6 lukem typedef struct passwd PASSWD;
96 1.6 lukem
97 1.1 cgd /*
98 1.1 cgd * global variables
99 1.1 cgd */
100 1.1 cgd
101 1.1 cgd extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running,
102 1.9 christos Teleport, Waiting, Was_bonus, Auto_bot;
103 1.1 cgd
104 1.1 cgd #ifdef FANCY
105 1.1 cgd extern bool Pattern_roll, Stand_still;
106 1.1 cgd #endif
107 1.1 cgd
108 1.11 jsm extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], Run_ch;
109 1.11 jsm extern const char *Next_move, *Move_list;
110 1.1 cgd
111 1.9 christos extern int Count, Level, Num_robots, Num_scrap, Num_scores, Score,
112 1.9 christos Start_level, Wait_bonus, Num_games;
113 1.1 cgd
114 1.9 christos extern COORD Max, Min, My_pos, Robots[], Scrap[];
115 1.1 cgd
116 1.1 cgd extern jmp_buf End_move;
117 1.1 cgd
118 1.1 cgd /*
119 1.1 cgd * functions types
120 1.1 cgd */
121 1.1 cgd
122 1.6 lukem void add_score __P((int));
123 1.6 lukem bool another __P((void));
124 1.6 lukem int cmp_sc __P((const void *, const void *));
125 1.6 lukem bool do_move __P((int, int));
126 1.11 jsm bool eaten __P((const COORD *));
127 1.6 lukem void flush_in __P((void));
128 1.6 lukem void get_move __P((void));
129 1.6 lukem void init_field __P((void));
130 1.6 lukem bool jumping __P((void));
131 1.6 lukem void make_level __P((void));
132 1.6 lukem void move_robots __P((int));
133 1.6 lukem bool must_telep __P((void));
134 1.6 lukem void play_level __P((void));
135 1.11 jsm int query __P((const char *));
136 1.8 hubertf void quit __P((int)) __attribute__((__noreturn__));
137 1.6 lukem void reset_count __P((void));
138 1.6 lukem int rnd __P((int));
139 1.6 lukem COORD *rnd_pos __P((void));
140 1.6 lukem void score __P((void));
141 1.6 lukem void set_name __P((SCORE *));
142 1.6 lukem void show_score __P((void));
143 1.6 lukem int sign __P((int));
144 1.10 christos char automove __P((void));
145