]> icculus.org git repositories - crow/jumpnbump.git/blob - globals.pre
Added AI by Ricardo Cruz. This also adds mouse controls.
[crow/jumpnbump.git] / globals.pre
1 /*
2  * globals.h
3  * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
4  *
5  * Copyright (C) 2001 Chuck Mason <cemason@users.sourceforge.net>
6  *
7  * Copyright (C) 2002 Florian Schulze <crow@icculus.org>
8  *
9  * This file is part of Jump'n'Bump.
10  *
11  * Jump'n'Bump is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * Jump'n'Bump is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25
26 #ifndef __GLOBALS_H
27 #define __GLOBALS_H
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #include "config.h"
34
35 #include <assert.h>
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <string.h>
39 #ifndef _MSC_VER
40 #include <strings.h>
41 #endif
42 #include <time.h>
43 #include <math.h>
44 #include <dj.h>
45
46 #ifdef DOS
47 # include <conio.h>
48 # include <dpmi.h>
49 # include <sys/nearptr.h>
50 # include <pc.h>
51 #endif
52
53 #ifdef _MSC_VER
54 # define WIN32_LEAN_AND_MEAN
55 # include <windows.h>
56 # include <sys/stat.h>
57 # include <io.h>
58 # include "SDL.h"
59 # if USE_SDL_MIXER
60 #  include "SDL_mixer.h"
61 # endif
62 #else
63 # ifdef USE_SDL
64 #  include <sys/stat.h>
65 #  include "SDL.h"
66 #  if USE_SDL_MIXER
67 #   include "SDL_mixer.h"
68 #  endif
69 # endif
70 #endif
71
72 #define JNB_MAX_PLAYERS 4
73
74 #define JNB_INETPORT 11111
75
76 extern int client_player_num;
77 void tellServerPlayerMoved(int playerid, int movement_type, int newval);
78 #define MOVEMENT_LEFT  1
79 #define MOVEMENT_RIGHT 2
80 #define MOVEMENT_UP    3
81
82 #define JNB_VERSION "1.51"
83
84 #define JNB_WIDTH 400
85 #define JNB_HEIGHT 256
86
87 extern int screen_width;
88 extern int screen_height;
89 extern int screen_pitch;
90 extern int scale_up;
91
92 extern int ai[JNB_MAX_PLAYERS];
93
94 #ifndef USE_SDL
95 #define KEY_PL1_LEFT 0xcb
96 #define KEY_PL1_RIGHT   0xcd
97 #define KEY_PL1_JUMP 0xc8
98 #define KEY_PL2_LEFT 0x1e
99 #define KEY_PL2_RIGHT   0x20
100 #define KEY_PL2_JUMP 0x11
101 #else
102 #define KEY_PL1_LEFT SDLK_LEFT
103 #define KEY_PL1_RIGHT   SDLK_RIGHT
104 #define KEY_PL1_JUMP SDLK_UP
105 #define KEY_PL2_LEFT SDLK_a
106 #define KEY_PL2_RIGHT   SDLK_d
107 #define KEY_PL2_JUMP SDLK_w
108 #define KEY_PL3_LEFT SDLK_j
109 #define KEY_PL3_RIGHT   SDLK_l
110 #define KEY_PL3_JUMP SDLK_i
111 #define KEY_PL4_LEFT SDLK_KP4
112 #define KEY_PL4_RIGHT   SDLK_KP6
113 #define KEY_PL4_JUMP SDLK_KP8
114 #endif
115
116 #define NUM_POBS 200
117 #define NUM_OBJECTS 200
118 #define NUM_FLIES 20
119 #define NUM_LEFTOVERS 50
120
121 #define OBJ_SPRING 0
122 #define OBJ_SPLASH 1
123 #define OBJ_SMOKE 2
124 #define OBJ_YEL_BUTFLY 3
125 #define OBJ_PINK_BUTFLY 4
126 #define OBJ_FUR 5
127 #define OBJ_FLESH 6
128 #define OBJ_FLESH_TRACE 7
129
130 #define OBJ_ANIM_SPRING 0
131 #define OBJ_ANIM_SPLASH 1
132 #define OBJ_ANIM_SMOKE 2
133 #define OBJ_ANIM_YEL_BUTFLY_RIGHT 3
134 #define OBJ_ANIM_YEL_BUTFLY_LEFT 4
135 #define OBJ_ANIM_PINK_BUTFLY_RIGHT 5
136 #define OBJ_ANIM_PINK_BUTFLY_LEFT 6
137 #define OBJ_ANIM_FLESH_TRACE 7
138
139 #define MOD_MENU 0
140 #define MOD_GAME 1
141 #define MOD_SCORES 2
142
143 #define SFX_JUMP 0
144 #define SFX_LAND 1
145 #define SFX_DEATH 2
146 #define SFX_SPRING 3
147 #define SFX_SPLASH 4
148 #define SFX_FLY 5
149
150 #define NUM_SFX 6
151
152 #define SFX_JUMP_FREQ 15000
153 #define SFX_LAND_FREQ 15000
154 #define SFX_DEATH_FREQ 20000
155 #define SFX_SPRING_FREQ 15000
156 #define SFX_SPLASH_FREQ 12000
157 #define SFX_FLY_FREQ 12000
158
159 #define BAN_VOID        0
160 #define BAN_SOLID       1
161 #define BAN_WATER       2
162 #define BAN_ICE         3
163 #define BAN_SPRING      4
164
165 #ifndef DATA_PATH
166 #ifdef __APPLE__
167 #define DATA_PATH "data/jumpbump.dat"
168 #elif _WIN32
169 #define DATA_PATH "data/jumpbump.dat"
170 #else
171 #define DATA_PATH "%%PREFIX%%/share/jumpnbump/jumpbump.dat"
172 #endif
173 #endif
174
175 typedef struct {
176         int num_images;
177         int *width;
178         int *height;
179         int *hs_x;
180         int *hs_y;
181         void **data;
182         void **orig_data;
183 } gob_t;
184
185 typedef struct {
186         int joy_enabled, mouse_enabled;
187         int no_sound, music_no_sound, no_gore, fireworks;
188         char error_str[256];
189         int draw_page, view_page;
190         struct {
191                 int num_pobs;
192                 struct {
193                         int x, y;
194                         int image;
195                         gob_t *pob_data;
196                         int back_buf_ofs;
197                 } pobs[NUM_POBS];
198         } page_info[2];
199         void *pob_backbuf[2];
200 } main_info_t;
201
202 typedef struct {
203         int action_left,action_up,action_right;
204         int enabled, dead_flag;
205         int bumps;
206         int bumped[JNB_MAX_PLAYERS];
207         int x, y;
208         int x_add, y_add;
209         int direction, jump_ready, jump_abort, in_water;
210         int anim, frame, frame_tick, image;
211 } player_t;
212
213 typedef struct {
214         int num_frames;
215         int restart_frame;
216         struct {
217                 int image;
218                 int ticks;
219         } frame[4];
220 } player_anim_t;
221
222 typedef struct {
223         int used, type;
224         int x, y;
225         int x_add, y_add;
226         int x_acc, y_acc;
227         int anim;
228         int frame, ticks;
229         int image;
230 } object_t;
231
232 typedef struct {
233         int x, y;
234         int raw_x, raw_y;
235         int but1, but2;
236         struct {
237                 int x1, x2, x3;
238                 int y1, y2, y3;
239         } calib_data;
240 } joy_t;
241
242 typedef struct {
243         int but1, but2, but3;
244 } mouse_t;
245
246 extern main_info_t main_info;
247 extern player_t player[JNB_MAX_PLAYERS];
248 extern player_anim_t player_anims[7];
249 extern object_t objects[NUM_OBJECTS];
250 extern joy_t joy;
251 extern mouse_t mouse;
252
253 extern char datfile_name[2048];
254
255 extern char *background_pic;
256 extern char *mask_pic;
257
258 extern gob_t rabbit_gobs;
259 extern gob_t font_gobs;
260 extern gob_t object_gobs;
261 extern gob_t number_gobs;
262
263
264 /* fireworks.c */
265
266 void fireworks(void);
267
268
269 /* main.c */
270
271 void steer_players(void);
272 void position_player(int player_num);
273 void fireworks(void);
274 void add_object(int type, int x, int y, int x_add, int y_add, int anim, int frame);
275 void update_objects(void);
276 int add_pob(int page, int x, int y, int image, gob_t *pob_data);
277 void draw_flies(int page);
278 void draw_pobs(int page);
279 void redraw_flies_background(int page);
280 void redraw_pob_backgrounds(int page);
281 int add_leftovers(int page, int x, int y, int image, gob_t *pob_data);
282 void draw_leftovers(int page);
283 int init_level(int level, char *pal);
284 void deinit_level(void);
285 int init_program(int argc, char *argv[], char *pal);
286 void deinit_program(void);
287 unsigned short rnd(unsigned short max);
288 int read_level(void);
289 unsigned char *dat_open(char *file_name);
290 int dat_filelen(char *file_name);
291 void write_calib_data(void);
292
293
294 /* input.c */
295
296 void update_player_actions(void);
297 void init_inputs(void);
298 int calib_joy(int type);
299
300 /* menu.c */
301
302 int menu(void);
303 int menu_init(void);
304 void menu_deinit(void);
305
306
307 /* gfx.c */
308
309 void set_scaling(int scale);
310 void open_screen(void);
311 void wait_vrt(int mix);
312 void draw_begin(void);
313 void draw_end(void);
314 void flippage(int page);
315 void draw_begin(void);
316 void draw_end(void);
317 void clear_lines(int page, int y, int count, int color);
318 int get_color(int color, char pal[768]);
319 int get_pixel(int page, int x, int y);
320 void set_pixel(int page, int x, int y, int color);
321 void setpalette(int index, int count, char *palette);
322 void fillpalette(int red, int green, int blue);
323 #ifdef DOS
324 void get_block(char page, short x, short y, short width, short height, char *buffer);
325 void put_block(char page, short x, short y, short width, short height, char *buffer);
326 #else
327 void get_block(int page, int x, int y, int width, int height, void *buffer);
328 void put_block(int page, int x, int y, int width, int height, void *buffer);
329 #endif
330 void put_text(int page, int x, int y, char *text, int align);
331 void put_pob(int page, int x, int y, int image, gob_t *gob, int mask, void *mask_pic);
332 int pob_width(int image, gob_t *gob);
333 int pob_height(int image, gob_t *gob);
334 int pob_hs_x(int image, gob_t *gob);
335 int pob_hs_y(int image, gob_t *gob);
336 int read_pcx(unsigned char * handle, void *buffer, int buf_len, char *pal);
337 void register_background(char *pixels, char pal[768]);
338 int register_gob(unsigned char *handle, gob_t *gob, int len);
339 void recalculate_gob(gob_t *gob, char pal[768]);
340 void register_mask(void *pixels);
341
342 /* gfx.c */
343
344 #ifdef USE_SDL
345 /* long filelength(int handle); */
346 void fs_toggle();
347 int intr_sysupdate();
348 #endif
349
350 /* interrpt.c */
351
352 extern char last_keys[50];
353
354 int hook_keyb_handler(void);
355 void remove_keyb_handler(void);
356 int key_pressed(int key);
357 int addkey(unsigned int key);
358
359 /* sound-linux.c */
360 #ifdef LINUX
361
362
363 #endif
364
365 #ifdef __cplusplus
366 }
367 #endif
368
369 #endif