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