1 /*
2  * xrobots.h  --  xrobots
3  *
4  * Copyright 1989 Brian Warkentine
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the author's name not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  The author makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
17  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THE
18  * AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
19  * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
20  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
21  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * The author's current employer has no connection with this software, as it
24  * was written before being employed at Sun.  The following address is for
25  * contacting the author only and does not imply any responsibility on the
26  * behalf of Sun Microsystems.
27  *
28  * Contact the author at:
29  * 	Brian Warkentine  (brianw@Sun.COM)
30  * 	Sun Microsystems
31  * 	2550 Garcia Avenue
32  * 	Mountain View, Ca 94043-1100
33  *
34  */
35 
36 typedef struct {
37   Pixel		fg,
38   		bg;
39   Boolean	spiffy,		/* limited graphics 			*/
40 		autoteleport,	/* teleport when sonic used, and no moves */
41 		autoteleportalways,	/* teleport when no available moves */
42 		showjumps,	/* show no intermediate moves 		*/
43 		diewaiting;	/* die if you use wait unsafely 	*/
44   XtTranslations translations;
45   char		*score_filename;
46 } AppData;
47 
48 /*
49  * from main.c
50  */
51 extern AppData	app_data;
52 extern Display 	*display;
53 extern Window 	playfield;
54 extern Widget 	playfield_widget;
55 extern GC 	gc,
56 		cleargc;
57 extern unsigned int
58 		chasetime;
59 
60 extern void 	update_score();
61 
62 /*
63  * from graphics.c
64  */
65 extern XtEventHandler redisplay_level();
66 
67 extern void 	init_pixmaps(),
68 		auto_teleport(),
69 		display_possible_moves(),
70 		display_level(),
71 		update_pointer(),
72 		free_pixmaps(),
73 		do_death(),
74 		show_teleport(),
75 		show_sonic(),
76 		show_movement();
77 
78 #define CELLSIZE 21
79 
80 #define pos_to_coord( _pos_ ) (( _pos_ ) * CELLSIZE + 5)
81 
82 /*
83  * from actions.c
84  */
85 
86 extern void 		sonic_action(),
87 			reset_sonic_button();
88 
89 extern XtActionProc	do_nothing_action(),
90 			move_action(),
91 			jump_action(),
92 			go_here_action();
93 
94 extern XtEventHandler 	pointer_moved();
95 
96 extern int  		determine_direction();
97 
98 /*
99  * from score.c
100  */
101 
102 #ifndef SCORE_FILE
103 #  define SCORE_FILE "/usr/games/lib/xrobotscores"
104 #endif
105 
106 #ifndef MAXSCORES
107 #  define MAXSCORES 20
108 #endif
109 
110 extern void 	check_score(),
111 		create_high_score_popup();
112 
113 extern void	show_scores_callback();
114 
115 /*
116  * from game.c
117  */
118 
119 #ifndef MAXX
120 # 	define 	MAXX 35
121 #endif
122 #ifndef MAXY
123 #  	define 	MAXY 20
124 #endif
125 
126 #define EMPTY 	0
127 #define ROBOT 	1
128 #define HEAP  	2
129 #define REDRAW 	3
130 
131 #define LEFT    1
132 #define RIGHT   2
133 #define UP      4
134 #define DOWN    8
135 #define STILL   16
136 
137 #define for_each	for(x=0;x<MAXX;x++) \
138 			  for(y=0;y<MAXY;y++)
139 
140 /* I know, I KNOW... global variables! */
141 
142 extern int 	human_x, human_y,
143            	last_human_x, last_human_y;
144 
145 extern int	robot_array[MAXX][MAXY],
146 		robot_array_bak[MAXX][MAXY];
147 
148 extern int 	score,
149 		num_robots,
150 		game_active,
151 		sonic_used;
152 
153 #define INXRANGE( _x_ )  (((_x_) >=0) && ((_x_)<MAXX))
154 #define INYRANGE( _y_ )  (((_y_) >=0) && ((_y_)<MAXY))
155 
156 extern void 	new_game(),
157 		add_score(),
158 		new_level();
159 extern int  	chase();
160 extern void 	undo_chase(),
161 		teleport(),
162 		sonic_screwdriver(),
163 		wait_for_em();
164 extern int  	can_go();
165 
166 
167 
168 
169