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