xref: /netbsd-src/games/robots/robots.h (revision 5305281b0c6d5ac1e32a81589acdabcb6df90102)
1*5305281bSdholland /*	$NetBSD: robots.h,v 1.22 2009/08/12 08:30:55 dholland Exp $	*/
26045e6e0Scgd 
361f28255Scgd /*
46045e6e0Scgd  * Copyright (c) 1980, 1993
56045e6e0Scgd  *	The Regents of the University of California.  All rights reserved.
661f28255Scgd  *
761f28255Scgd  * Redistribution and use in source and binary forms, with or without
861f28255Scgd  * modification, are permitted provided that the following conditions
961f28255Scgd  * are met:
1061f28255Scgd  * 1. Redistributions of source code must retain the above copyright
1161f28255Scgd  *    notice, this list of conditions and the following disclaimer.
1261f28255Scgd  * 2. Redistributions in binary form must reproduce the above copyright
1361f28255Scgd  *    notice, this list of conditions and the following disclaimer in the
1461f28255Scgd  *    documentation and/or other materials provided with the distribution.
15e5aeb4eaSagc  * 3. Neither the name of the University nor the names of its contributors
1661f28255Scgd  *    may be used to endorse or promote products derived from this software
1761f28255Scgd  *    without specific prior written permission.
1861f28255Scgd  *
1961f28255Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2061f28255Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2161f28255Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2261f28255Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2361f28255Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2461f28255Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2561f28255Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2661f28255Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2761f28255Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2861f28255Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2961f28255Scgd  * SUCH DAMAGE.
3061f28255Scgd  *
316045e6e0Scgd  *	@(#)robots.h	8.1 (Berkeley) 5/31/93
3261f28255Scgd  */
3361f28255Scgd 
34a4cc1f4fSdholland #include <sys/cdefs.h>
35a4cc1f4fSdholland 
3661f28255Scgd #include <setjmp.h>
37a4cc1f4fSdholland #include <stdbool.h>
38a4cc1f4fSdholland #include <stdint.h>
3961f28255Scgd 
4061f28255Scgd /*
4161f28255Scgd  * miscellaneous constants
4261f28255Scgd  */
4361f28255Scgd 
4461f28255Scgd #define Y_FIELDSIZE	23
4561f28255Scgd #define X_FIELDSIZE	60
4661f28255Scgd #define Y_SIZE		24
4761f28255Scgd #define X_SIZE		80
4861f28255Scgd #define MAXLEVELS	4
4961f28255Scgd #define MAXROBOTS	(MAXLEVELS * 10)
5061f28255Scgd #define ROB_SCORE	10
51ce5670f7Sjsm #undef  S_BONUS
5261f28255Scgd #define S_BONUS		(60 * ROB_SCORE)
5361f28255Scgd #define Y_SCORE		21
5461f28255Scgd #define X_SCORE		(X_FIELDSIZE + 9)
5561f28255Scgd #define Y_PROMPT	(Y_FIELDSIZE - 1)
5661f28255Scgd #define X_PROMPT	(X_FIELDSIZE + 2)
5761f28255Scgd #define MAXSCORES	(Y_SIZE - 2)
5861f28255Scgd #define MAXNAME		16
5961f28255Scgd #define MS_NAME		"Ten"
6061f28255Scgd 
6161f28255Scgd /*
6261f28255Scgd  * characters on screen
6361f28255Scgd  */
6461f28255Scgd 
6561f28255Scgd #define ROBOT	'+'
6661f28255Scgd #define HEAP	'*'
6761f28255Scgd #define PLAYER	'@'
6861f28255Scgd 
6961f28255Scgd /*
7061f28255Scgd  * type definitions
7161f28255Scgd  */
7261f28255Scgd 
7361f28255Scgd typedef struct {
7461f28255Scgd 	int y, x;
7561f28255Scgd } COORD;
7661f28255Scgd 
779007937fSlukem typedef struct {
78a4cc1f4fSdholland 	uint32_t s_uid;
79a4cc1f4fSdholland 	uint32_t s_score;
80a4cc1f4fSdholland 	uint32_t s_auto;
81a4cc1f4fSdholland 	uint32_t s_level;
829007937fSlukem 	char s_name[MAXNAME];
839007937fSlukem } SCORE;
849007937fSlukem 
8561f28255Scgd /*
8661f28255Scgd  * global variables
8761f28255Scgd  */
8861f28255Scgd 
8961f28255Scgd extern bool Dead, Full_clear, Jump, Newscore, Real_time, Running,
9018dfb39eSchristos 	Teleport, Waiting, Was_bonus, Auto_bot;
9161f28255Scgd 
9261f28255Scgd #ifdef FANCY
9361f28255Scgd extern bool Pattern_roll, Stand_still;
9461f28255Scgd #endif
9561f28255Scgd 
96092d3130Sjsm extern char Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], Run_ch;
97092d3130Sjsm extern const char *Next_move, *Move_list;
9861f28255Scgd 
9920e33050Sjsm extern int Count, Level, Num_robots, Num_scrap, Num_scores,
10018dfb39eSchristos 	Start_level, Wait_bonus, Num_games;
10161f28255Scgd 
102a4cc1f4fSdholland extern uint32_t Score;
10320e33050Sjsm 
10418dfb39eSchristos extern COORD Max, Min, My_pos, Robots[], Scrap[];
10561f28255Scgd 
10661f28255Scgd extern jmp_buf End_move;
10761f28255Scgd 
10861f28255Scgd /*
10930870bd5Sdholland  * functions
11061f28255Scgd  */
11161f28255Scgd 
112cb5fd834Sjsm void add_score(int);
113cb5fd834Sjsm char automove(void);
114cb5fd834Sjsm void flush_in(void);
115cb5fd834Sjsm void get_move(void);
116cb5fd834Sjsm void init_field(void);
117cb5fd834Sjsm bool jumping(void);
118cb5fd834Sjsm void make_level(void);
119cb5fd834Sjsm void move_robots(int);
120cb5fd834Sjsm void play_level(void);
121cb5fd834Sjsm int query(const char *);
12230870bd5Sdholland void quit(int) __dead;
123cb5fd834Sjsm void reset_count(void);
124cb5fd834Sjsm COORD *rnd_pos(void);
125cb5fd834Sjsm void score(int);
126cb5fd834Sjsm void show_score(void);
127cb5fd834Sjsm int sign(int);
128cb5fd834Sjsm void telmsg(int);
129