xref: /netbsd-src/games/robots/robots.h (revision e5aeb4ea46bbe6a0522c39af347be4ddcd733a80)
1 /*	$NetBSD: robots.h,v 1.16 2003/08/07 09:37:37 agc Exp $	*/
2 
3 /*
4  * Copyright (c) 1980, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
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.
18  *
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
29  * SUCH DAMAGE.
30  *
31  *	@(#)robots.h	8.1 (Berkeley) 5/31/93
32  */
33 
34 # include	<sys/ttydefaults.h>
35 # include	<ctype.h>
36 # include	<curses.h>
37 # include	<err.h>
38 # include	<errno.h>
39 # include	<fcntl.h>
40 # include	<pwd.h>
41 # include	<setjmp.h>
42 # include	<signal.h>
43 # include	<stdlib.h>
44 # include	<string.h>
45 # include	<termios.h>
46 # include	<unistd.h>
47 
48 /*
49  * miscellaneous constants
50  */
51 
52 # define	Y_FIELDSIZE	23
53 # define	X_FIELDSIZE	60
54 # define	Y_SIZE		24
55 # define	X_SIZE		80
56 # define	MAXLEVELS	4
57 # define	MAXROBOTS	(MAXLEVELS * 10)
58 # define	ROB_SCORE	10
59 # undef		S_BONUS
60 # define	S_BONUS		(60 * ROB_SCORE)
61 # define	Y_SCORE		21
62 # define	X_SCORE		(X_FIELDSIZE + 9)
63 # define	Y_PROMPT	(Y_FIELDSIZE - 1)
64 # define	X_PROMPT	(X_FIELDSIZE + 2)
65 # define	MAXSCORES	(Y_SIZE - 2)
66 # define	MAXNAME		16
67 # define	MS_NAME		"Ten"
68 
69 /*
70  * characters on screen
71  */
72 
73 # define	ROBOT	'+'
74 # define	HEAP	'*'
75 # define	PLAYER	'@'
76 
77 /*
78  * type definitions
79  */
80 
81 typedef struct {
82 	int	y, x;
83 } COORD;
84 
85 typedef struct {
86 	u_int32_t	s_uid;
87 	u_int32_t	s_score;
88 	u_int32_t	s_auto;
89 	u_int32_t	s_level;
90 	char		s_name[MAXNAME];
91 } SCORE;
92 
93 typedef struct passwd	PASSWD;
94 
95 /*
96  * global variables
97  */
98 
99 extern bool	Dead, Full_clear, Jump, Newscore, Real_time, Running,
100 		Teleport, Waiting, Was_bonus, Auto_bot;
101 
102 #ifdef	FANCY
103 extern bool	Pattern_roll, Stand_still;
104 #endif
105 
106 extern char	Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], Run_ch;
107 extern const char *Next_move, *Move_list;
108 
109 extern int	Count, Level, Num_robots, Num_scrap, Num_scores,
110 		Start_level, Wait_bonus, Num_games;
111 
112 extern u_int32_t	Score;
113 
114 extern COORD	Max, Min, My_pos, Robots[], Scrap[];
115 
116 extern jmp_buf	End_move;
117 
118 /*
119  * functions types
120  */
121 
122 void	add_score __P((int));
123 bool	another __P((void));
124 char	automove __P((void));
125 int	cmp_sc __P((const void *, const void *));
126 bool	do_move __P((int, int));
127 bool	eaten __P((const COORD *));
128 void	flush_in __P((void));
129 void	get_move __P((void));
130 void	init_field __P((void));
131 bool	jumping __P((void));
132 void	make_level __P((void));
133 void	move_robots __P((int));
134 bool	must_telep __P((void));
135 void	play_level __P((void));
136 int	query __P((const char *));
137 void	quit __P((int)) __attribute__((__noreturn__));
138 void	reset_count __P((void));
139 int	rnd __P((int));
140 COORD  *rnd_pos __P((void));
141 void	score __P((int));
142 void	set_name __P((SCORE *));
143 void	show_score __P((void));
144 int	sign __P((int));
145 void	telmsg __P((int));
146