xref: /openbsd/games/robots/robots.h (revision 2010f3c8)
1 /*	$OpenBSD: robots.h,v 1.14 2016/01/04 17:33:24 mestre Exp $	*/
2 /*	$NetBSD: robots.h,v 1.5 1995/04/24 12:24:54 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. Neither the name of the University nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  *	@(#)robots.h	8.1 (Berkeley) 5/31/93
33  */
34 
35 #include <curses.h>
36 #include <limits.h>
37 
38 /*
39  * miscellaneous constants
40  */
41 
42 #define	Y_FIELDSIZE	23
43 #define	X_FIELDSIZE	60
44 #define	Y_SIZE		24
45 #define	X_SIZE		80
46 #define	MAXLEVELS	4
47 #define	MAXROBOTS	(MAXLEVELS * 10)
48 #define	ROB_SCORE	10
49 #define	S_BONUS		(60 * ROB_SCORE)
50 #define	Y_SCORE		21
51 #define	X_SCORE		(X_FIELDSIZE + 9)
52 #define	Y_PROMPT	(Y_FIELDSIZE - 1)
53 #define	X_PROMPT	(X_FIELDSIZE + 2)
54 #define	MAXSCORES	(Y_SIZE - 2)
55 
56 /*
57  * characters on screen
58  */
59 
60 #define	ROBOT	'+'
61 #define	HEAP	'*'
62 #define	PLAYER	'@'
63 
64 /*
65  * type definitions
66  */
67 
68 typedef struct {
69 	int	y, x;
70 } COORD;
71 
72 typedef struct {
73 	uid_t	s_uid;
74 	int	s_score;
75 	char	s_name[LOGIN_NAME_MAX];
76 } SCORE;
77 
78 /*
79  * global variables
80  */
81 
82 extern bool	Dead, Full_clear, Jump, Newscore, Real_time, Running,
83 		Teleport, Waiting, Was_bonus;
84 
85 #ifdef	FANCY
86 extern bool	Pattern_roll, Stand_still;
87 #endif
88 
89 extern char	Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], *Next_move,
90 		*Move_list, Run_ch;
91 
92 extern int	Count, Level, Num_robots, Num_scores, Score,
93 		Start_level, Wait_bonus;
94 
95 extern struct timespec	tv;
96 
97 extern COORD	Max, Min, My_pos, Robots[];
98 
99 
100 /*
101  * functions types
102  */
103 
104 void	add_score(int);
105 bool	another(void);
106 int	cmp_sc(const void *, const void *);
107 bool	do_move(int, int);
108 bool	eaten(COORD *);
109 void	get_move(void);
110 void	init_field(void);
111 bool	jumping(void);
112 void	make_level(void);
113 void	move_robots(void);
114 bool	must_telep(void);
115 void	play_level(void);
116 int	query(char *);
117 __dead void	quit(int);
118 void	reset_count(void);
119 int	rnd(int);
120 COORD	*rnd_pos(void);
121 void	score(int);
122 void	set_name(SCORE *);
123 void	show_score(void);
124 int	sign(int);
125 __dead void	usage(void);
126