3 * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
5 * Copyright (C) 2001 Chuck Mason <cemason@users.sourceforge.net>
7 * Copyright (C) 2002 Florian Schulze <crow@icculus.org>
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.
13 * This file is part of Jump'n'Bump.
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.
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.
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
53 # include <sys/nearptr.h>
58 # define WIN32_LEAN_AND_MEAN
60 # include <sys/stat.h>
64 # include <SDL_mixer.h>
68 # include <sys/stat.h>
71 # include <SDL/SDL_mixer.h>
76 #define JNB_MAX_PLAYERS 4
78 #define JNB_INETPORT 11111
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
86 #define JNB_VERSION "1.39"
89 #define JNB_HEIGHT 256
91 extern int screen_width;
92 extern int screen_height;
93 extern int screen_pitch;
95 extern int bytes_per_pixel;
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
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
120 #define NUM_OBJECTS 200
122 #define NUM_LEFTOVERS 50
127 #define OBJ_YEL_BUTFLY 3
128 #define OBJ_PINK_BUTFLY 4
131 #define OBJ_FLESH_TRACE 7
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
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
170 #define DATA_PATH "data/jumpbump.dat"
172 #define DATA_PATH "data/jumpbump.dat"
174 #define DATA_PATH "/usr/share/jumpnbump/jumpbump.dat"
189 int joy_enabled, mouse_enabled;
190 int no_sound, music_no_sound, no_gore, fireworks;
192 int draw_page, view_page;
202 void *pob_backbuf[2];
206 int action_left,action_up,action_right;
207 int enabled, dead_flag;
209 int bumped[JNB_MAX_PLAYERS];
212 int direction, jump_ready, jump_abort, in_water;
213 int anim, frame, frame_tick, image;
246 int but1, but2, but3;
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];
254 extern mouse_t mouse;
256 extern char datfile_name[2048];
258 extern char *background_pic;
259 extern char *mask_pic;
261 extern gob_t rabbit_gobs;
262 extern gob_t font_gobs;
263 extern gob_t object_gobs;
264 extern gob_t number_gobs;
269 void fireworks(void);
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);
299 void update_player_actions(void);
300 void init_inputs(void);
301 int calib_joy(int type);
307 void menu_deinit(void);
312 void set_scaling(int scale);
313 void open_screen(void);
314 void wait_vrt(int mix);
315 void draw_begin(void);
317 void flippage(int page);
318 void draw_begin(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);
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);
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);
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);
348 //long filelength(int handle);
350 int intr_sysupdate();
355 extern char last_keys[50];
357 int hook_keyb_handler(void);
358 void remove_keyb_handler(void);
359 int key_pressed(int key);