robots.h revision 1.16 1 1.16 agc /* $NetBSD: robots.h,v 1.16 2003/08/07 09:37:37 agc 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.16 agc * 3. Neither the name of the University nor the names of its contributors
16 1.1 cgd * may be used to endorse or promote products derived from this software
17 1.1 cgd * without specific prior written permission.
18 1.1 cgd *
19 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 1.1 cgd * SUCH DAMAGE.
30 1.1 cgd *
31 1.4 cgd * @(#)robots.h 8.1 (Berkeley) 5/31/93
32 1.1 cgd */
33 1.1 cgd
34 1.6 lukem # include <sys/ttydefaults.h>
35 1.6 lukem # include <ctype.h>
36 1.1 cgd # include <curses.h>
37 1.7 lukem # include <err.h>
38 1.12 jsm # include <errno.h>
39 1.6 lukem # include <fcntl.h>
40 1.6 lukem # include <pwd.h>
41 1.1 cgd # include <setjmp.h>
42 1.6 lukem # include <signal.h>
43 1.6 lukem # include <stdlib.h>
44 1.5 cgd # include <string.h>
45 1.6 lukem # include <termios.h>
46 1.6 lukem # include <unistd.h>
47 1.1 cgd
48 1.1 cgd /*
49 1.1 cgd * miscellaneous constants
50 1.1 cgd */
51 1.1 cgd
52 1.1 cgd # define Y_FIELDSIZE 23
53 1.1 cgd # define X_FIELDSIZE 60
54 1.1 cgd # define Y_SIZE 24
55 1.1 cgd # define X_SIZE 80
56 1.1 cgd # define MAXLEVELS 4
57 1.1 cgd # define MAXROBOTS (MAXLEVELS * 10)
58 1.1 cgd # define ROB_SCORE 10
59 1.14 jsm # undef S_BONUS
60 1.1 cgd # define S_BONUS (60 * ROB_SCORE)
61 1.1 cgd # define Y_SCORE 21
62 1.1 cgd # define X_SCORE (X_FIELDSIZE + 9)
63 1.1 cgd # define Y_PROMPT (Y_FIELDSIZE - 1)
64 1.1 cgd # define X_PROMPT (X_FIELDSIZE + 2)
65 1.1 cgd # define MAXSCORES (Y_SIZE - 2)
66 1.1 cgd # define MAXNAME 16
67 1.1 cgd # define MS_NAME "Ten"
68 1.1 cgd
69 1.1 cgd /*
70 1.1 cgd * characters on screen
71 1.1 cgd */
72 1.1 cgd
73 1.1 cgd # define ROBOT '+'
74 1.1 cgd # define HEAP '*'
75 1.1 cgd # define PLAYER '@'
76 1.1 cgd
77 1.1 cgd /*
78 1.1 cgd * type definitions
79 1.1 cgd */
80 1.1 cgd
81 1.1 cgd typedef struct {
82 1.1 cgd int y, x;
83 1.1 cgd } COORD;
84 1.1 cgd
85 1.6 lukem typedef struct {
86 1.9 christos u_int32_t s_uid;
87 1.9 christos u_int32_t s_score;
88 1.9 christos u_int32_t s_auto;
89 1.9 christos u_int32_t s_level;
90 1.9 christos char s_name[MAXNAME];
91 1.6 lukem } SCORE;
92 1.6 lukem
93 1.6 lukem typedef struct passwd PASSWD;
94 1.6 lukem
95 1.1 cgd /*
96 1.1 cgd * global variables
97 1.1 cgd */
98 1.1 cgd
99 1.1 cgd extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running,
100 1.9 christos Teleport, Waiting, Was_bonus, Auto_bot;
101 1.1 cgd
102 1.1 cgd #ifdef FANCY
103 1.1 cgd extern bool Pattern_roll, Stand_still;
104 1.1 cgd #endif
105 1.1 cgd
106 1.11 jsm extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], Run_ch;
107 1.11 jsm extern const char *Next_move, *Move_list;
108 1.1 cgd
109 1.13 jsm extern int Count, Level, Num_robots, Num_scrap, Num_scores,
110 1.9 christos Start_level, Wait_bonus, Num_games;
111 1.13 jsm
112 1.13 jsm extern u_int32_t Score;
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.15 christos char automove __P((void));
125 1.6 lukem int cmp_sc __P((const void *, const void *));
126 1.6 lukem bool do_move __P((int, int));
127 1.11 jsm bool eaten __P((const COORD *));
128 1.6 lukem void flush_in __P((void));
129 1.6 lukem void get_move __P((void));
130 1.6 lukem void init_field __P((void));
131 1.6 lukem bool jumping __P((void));
132 1.6 lukem void make_level __P((void));
133 1.6 lukem void move_robots __P((int));
134 1.6 lukem bool must_telep __P((void));
135 1.6 lukem void play_level __P((void));
136 1.11 jsm int query __P((const char *));
137 1.8 hubertf void quit __P((int)) __attribute__((__noreturn__));
138 1.6 lukem void reset_count __P((void));
139 1.6 lukem int rnd __P((int));
140 1.6 lukem COORD *rnd_pos __P((void));
141 1.12 jsm void score __P((int));
142 1.6 lukem void set_name __P((SCORE *));
143 1.6 lukem void show_score __P((void));
144 1.6 lukem int sign __P((int));
145 1.15 christos void telmsg __P((int));
146