Home | History | Annotate | Line # | Download | only in robots
robots.h revision 1.18
      1 /*	$NetBSD: robots.h,v 1.18 2004/01/27 20:30:30 jsm 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	<sys/endian.h>
     36 # include	<ctype.h>
     37 # include	<curses.h>
     38 # include	<err.h>
     39 # include	<errno.h>
     40 # include	<fcntl.h>
     41 # include	<pwd.h>
     42 # include	<setjmp.h>
     43 # include	<signal.h>
     44 # include	<stdlib.h>
     45 # include	<string.h>
     46 # include	<termios.h>
     47 # include	<unistd.h>
     48 
     49 /*
     50  * miscellaneous constants
     51  */
     52 
     53 # define	Y_FIELDSIZE	23
     54 # define	X_FIELDSIZE	60
     55 # define	Y_SIZE		24
     56 # define	X_SIZE		80
     57 # define	MAXLEVELS	4
     58 # define	MAXROBOTS	(MAXLEVELS * 10)
     59 # define	ROB_SCORE	10
     60 # undef		S_BONUS
     61 # define	S_BONUS		(60 * ROB_SCORE)
     62 # define	Y_SCORE		21
     63 # define	X_SCORE		(X_FIELDSIZE + 9)
     64 # define	Y_PROMPT	(Y_FIELDSIZE - 1)
     65 # define	X_PROMPT	(X_FIELDSIZE + 2)
     66 # define	MAXSCORES	(Y_SIZE - 2)
     67 # define	MAXNAME		16
     68 # define	MS_NAME		"Ten"
     69 
     70 /*
     71  * characters on screen
     72  */
     73 
     74 # define	ROBOT	'+'
     75 # define	HEAP	'*'
     76 # define	PLAYER	'@'
     77 
     78 /*
     79  * type definitions
     80  */
     81 
     82 typedef struct {
     83 	int	y, x;
     84 } COORD;
     85 
     86 typedef struct {
     87 	u_int32_t	s_uid;
     88 	u_int32_t	s_score;
     89 	u_int32_t	s_auto;
     90 	u_int32_t	s_level;
     91 	char		s_name[MAXNAME];
     92 } SCORE;
     93 
     94 typedef struct passwd	PASSWD;
     95 
     96 /*
     97  * global variables
     98  */
     99 
    100 extern bool	Dead, Full_clear, Jump, Newscore, Real_time, Running,
    101 		Teleport, Waiting, Was_bonus, Auto_bot;
    102 
    103 #ifdef	FANCY
    104 extern bool	Pattern_roll, Stand_still;
    105 #endif
    106 
    107 extern char	Cnt_move, Field[Y_FIELDSIZE][X_FIELDSIZE], Run_ch;
    108 extern const char *Next_move, *Move_list;
    109 
    110 extern int	Count, Level, Num_robots, Num_scrap, Num_scores,
    111 		Start_level, Wait_bonus, Num_games;
    112 
    113 extern u_int32_t	Score;
    114 
    115 extern COORD	Max, Min, My_pos, Robots[], Scrap[];
    116 
    117 extern jmp_buf	End_move;
    118 
    119 /*
    120  * functions types
    121  */
    122 
    123 void	add_score(int);
    124 bool	another(void);
    125 char	automove(void);
    126 int	cmp_sc(const void *, const void *);
    127 bool	do_move(int, int);
    128 bool	eaten(const COORD *);
    129 void	flush_in(void);
    130 void	get_move(void);
    131 void	init_field(void);
    132 bool	jumping(void);
    133 void	make_level(void);
    134 void	move_robots(int);
    135 bool	must_telep(void);
    136 void	play_level(void);
    137 int	query(const char *);
    138 void	quit(int) __attribute__((__noreturn__));
    139 void	reset_count(void);
    140 int	rnd(int);
    141 COORD  *rnd_pos(void);
    142 void	score(int);
    143 void	set_name(SCORE *);
    144 void	show_score(void);
    145 int	sign(int);
    146 void	telmsg(int);
    147