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
49 # include <sys/nearptr.h>
54 # define WIN32_LEAN_AND_MEAN
56 # include <sys/stat.h>
59 # include <SDL_mixer.h>
62 # include <sys/stat.h>
64 # include <SDL/SDL_mixer.h>
69 #define JNB_HEIGHT 256
70 extern int screen_width;
71 extern int screen_height;
72 extern int screen_pitch;
74 extern int bytes_per_pixel;
77 #define KEY_PL1_LEFT 0xcb
78 #define KEY_PL1_RIGHT 0xcd
79 #define KEY_PL1_JUMP 0xc8
80 #define KEY_PL2_LEFT 0x1e
81 #define KEY_PL2_RIGHT 0x20
82 #define KEY_PL2_JUMP 0x11
84 #define KEY_PL1_LEFT SDLK_LEFT
85 #define KEY_PL1_RIGHT SDLK_RIGHT
86 #define KEY_PL1_JUMP SDLK_UP
87 #define KEY_PL2_LEFT SDLK_a
88 #define KEY_PL2_RIGHT SDLK_d
89 #define KEY_PL2_JUMP SDLK_w
90 #define KEY_PL3_LEFT SDLK_j
91 #define KEY_PL3_RIGHT SDLK_l
92 #define KEY_PL3_JUMP SDLK_i
93 #define KEY_PL4_LEFT SDLK_KP4
94 #define KEY_PL4_RIGHT SDLK_KP6
95 #define KEY_PL4_JUMP SDLK_KP8
99 #define NUM_OBJECTS 200
101 #define NUM_LEFTOVERS 50
106 #define OBJ_YEL_BUTFLY 3
107 #define OBJ_PINK_BUTFLY 4
110 #define OBJ_FLESH_TRACE 7
112 #define OBJ_ANIM_SPRING 0
113 #define OBJ_ANIM_SPLASH 1
114 #define OBJ_ANIM_SMOKE 2
115 #define OBJ_ANIM_YEL_BUTFLY_RIGHT 3
116 #define OBJ_ANIM_YEL_BUTFLY_LEFT 4
117 #define OBJ_ANIM_PINK_BUTFLY_RIGHT 5
118 #define OBJ_ANIM_PINK_BUTFLY_LEFT 6
119 #define OBJ_ANIM_FLESH_TRACE 7
134 #define SFX_JUMP_FREQ 15000
135 #define SFX_LAND_FREQ 15000
136 #define SFX_DEATH_FREQ 20000
137 #define SFX_SPRING_FREQ 15000
138 #define SFX_SPLASH_FREQ 12000
139 #define SFX_FLY_FREQ 12000
149 #define DATA_PATH "data/jumpbump.dat"
151 #define DATA_PATH "data/jumpbump.dat"
153 #define DATA_PATH "/usr/share/jumpnbump/jumpbump.dat"
168 int joy_enabled, mouse_enabled;
169 int no_sound, no_gore, fireworks;
171 int draw_page, view_page;
181 void *pob_backbuf[2];
185 int action_left,action_up,action_right;
186 int enabled, dead_flag;
191 int direction, jump_ready, jump_abort, in_water;
192 int anim, frame, frame_tick, image;
225 int but1, but2, but3;
228 extern main_info_t main_info;
229 extern player_t player[4];
230 extern player_anim_t player_anims[7];
231 extern object_t objects[NUM_OBJECTS];
233 extern mouse_t mouse;
235 extern char datfile_name[2048];
237 extern char *background_pic;
238 extern char *mask_pic;
240 extern gob_t rabbit_gobs;
241 extern gob_t font_gobs;
242 extern gob_t object_gobs;
243 extern gob_t number_gobs;
248 void fireworks(void);
253 void steer_players(void);
254 void position_player(int player_num);
255 void fireworks(void);
256 void add_object(int type, int x, int y, int x_add, int y_add, int anim, int frame);
257 void update_objects(void);
258 int add_pob(int page, int x, int y, int image, gob_t *pob_data);
259 void draw_flies(int page);
260 void draw_pobs(int page);
261 void redraw_flies_background(int page);
262 void redraw_pob_backgrounds(int page);
263 int add_leftovers(int page, int x, int y, int image, gob_t *pob_data);
264 void draw_leftovers(int page);
265 int init_level(int level, char *pal);
266 void deinit_level(void);
267 int init_program(int argc, char *argv[], char *pal);
268 void deinit_program(void);
269 unsigned short rnd(unsigned short max);
270 int read_level(void);
271 FILE *dat_open(char *file_name, char *dat_name, char *mode);
272 int dat_filelen(char *file_name, char *dat_name);
273 void write_calib_data(void);
278 void update_player_actions(void);
279 void init_inputs(void);
280 int calib_joy(int type);
286 void menu_deinit(void);
291 void set_scaling(int scale);
292 void open_screen(void);
293 void wait_vrt(int mix);
294 void draw_begin(void);
296 void flippage(int page);
297 void draw_begin(void);
299 void clear_lines(int page, int y, int count, int color);
300 int get_color(int color, char pal[768]);
301 int get_pixel(int page, int x, int y);
302 void set_pixel(int page, int x, int y, int color);
303 void setpalette(int index, int count, char *palette);
304 void fillpalette(int red, int green, int blue);
306 void get_block(char page, short x, short y, short width, short height, char *buffer);
307 void put_block(char page, short x, short y, short width, short height, char *buffer);
309 void get_block(int page, int x, int y, int width, int height, void *buffer);
310 void put_block(int page, int x, int y, int width, int height, void *buffer);
312 void put_text(int page, int x, int y, char *text, int align);
313 void put_pob(int page, int x, int y, int image, gob_t *gob, int mask, void *mask_pic);
314 int pob_width(int image, gob_t *gob);
315 int pob_height(int image, gob_t *gob);
316 int pob_hs_x(int image, gob_t *gob);
317 int pob_hs_y(int image, gob_t *gob);
318 int read_pcx(FILE * handle, void *buffer, int buf_len, char *pal);
319 void register_background(char *pixels, char pal[768]);
320 int register_gob(FILE *handle, gob_t *gob, int len);
321 void recalculate_gob(gob_t *gob, char pal[768]);
322 void register_mask(void *pixels);
327 //long filelength(int handle);
329 int intr_sysupdate();
334 extern char last_keys[50];
336 int hook_keyb_handler(void);
337 void remove_keyb_handler(void);
338 int key_pressed(int key);