20 # include <sys/nearptr.h>
25 # include <sys/stat.h>
28 # include <SDL_mixer.h>
31 # include <sys/stat.h>
33 # include <SDL/SDL_mixer.h>
38 #define JNB_HEIGHT 256
44 #if (defined(SCALE_UP) || defined(SCALE_UP2))
47 #define JNB_SURFACE_WIDTH (JNB_WIDTH*2)
48 #define JNB_SURFACE_HEIGHT (JNB_HEIGHT*2)
49 typedef unsigned short pixel_t;
53 #define JNB_SURFACE_WIDTH JNB_WIDTH
54 #define JNB_SURFACE_HEIGHT JNB_HEIGHT
55 typedef unsigned char pixel_t;
59 #define KEY_PL1_LEFT 0xcb
60 #define KEY_PL1_RIGHT 0xcd
61 #define KEY_PL1_JUMP 0xc8
62 #define KEY_PL2_LEFT 0x1e
63 #define KEY_PL2_RIGHT 0x20
64 #define KEY_PL2_JUMP 0x11
66 #define KEY_PL1_LEFT SDLK_LEFT
67 #define KEY_PL1_RIGHT SDLK_RIGHT
68 #define KEY_PL1_JUMP SDLK_UP
69 #define KEY_PL2_LEFT SDLK_a
70 #define KEY_PL2_RIGHT SDLK_d
71 #define KEY_PL2_JUMP SDLK_w
72 #define KEY_PL3_LEFT SDLK_j
73 #define KEY_PL3_RIGHT SDLK_l
74 #define KEY_PL3_JUMP SDLK_i
75 #define KEY_PL4_LEFT SDLK_KP4
76 #define KEY_PL4_RIGHT SDLK_KP6
77 #define KEY_PL4_JUMP SDLK_KP8
81 #define NUM_OBJECTS 200
83 #define NUM_LEFTOVERS 50
88 #define OBJ_YEL_BUTFLY 3
89 #define OBJ_PINK_BUTFLY 4
92 #define OBJ_FLESH_TRACE 7
94 #define OBJ_ANIM_SPRING 0
95 #define OBJ_ANIM_SPLASH 1
96 #define OBJ_ANIM_SMOKE 2
97 #define OBJ_ANIM_YEL_BUTFLY_RIGHT 3
98 #define OBJ_ANIM_YEL_BUTFLY_LEFT 4
99 #define OBJ_ANIM_PINK_BUTFLY_RIGHT 5
100 #define OBJ_ANIM_PINK_BUTFLY_LEFT 6
101 #define OBJ_ANIM_FLESH_TRACE 7
116 #define SFX_JUMP_FREQ 15000
117 #define SFX_LAND_FREQ 15000
118 #define SFX_DEATH_FREQ 20000
119 #define SFX_SPRING_FREQ 15000
120 #define SFX_SPLASH_FREQ 12000
121 #define SFX_FLY_FREQ 12000
136 unsigned char **orig_data;
140 int joy_enabled, mouse_enabled;
141 int no_sound, no_gore, fireworks;
143 int draw_page, view_page;
153 pixel_t pob_backbuf[2][JNB_SURFACE_WIDTH*JNB_SURFACE_HEIGHT];
157 int action_left,action_up,action_right;
158 int enabled, dead_flag;
163 int direction, jump_ready, jump_abort, in_water;
164 int anim, frame, frame_tick, image;
184 } objects[NUM_OBJECTS];
197 int but1, but2, but3;
200 char datfile_name[2048];
202 char *background_pic;
205 extern gob_t rabbit_gobs;
206 extern gob_t font_gobs;
207 extern gob_t object_gobs;
208 extern gob_t number_gobs;
213 void fireworks(void);
218 void steer_players(void);
219 void position_player(int player_num);
220 void fireworks(void);
221 void add_object(int type, int x, int y, int x_add, int y_add, int anim, int frame);
222 void update_objects(void);
223 int add_pob(int page, int x, int y, int image, gob_t *pob_data);
224 void draw_flies(int page);
225 void draw_pobs(int page);
226 void redraw_flies_background(int page);
227 void redraw_pob_backgrounds(int page);
228 int add_leftovers(int page, int x, int y, int image, gob_t *pob_data);
229 void draw_leftovers(int page);
230 int init_level(int level, char *pal);
231 void deinit_level(void);
232 int init_program(int argc, char *argv[], char *pal);
233 void deinit_program(void);
234 unsigned short rnd(unsigned short max);
235 int read_level(void);
236 FILE *dat_open(char *file_name, char *dat_name, char *mode);
237 int dat_filelen(char *file_name, char *dat_name);
238 void write_calib_data(void);
243 void update_player_actions(void);
244 void init_inputs(void);
245 int calib_joy(int type);
251 void menu_deinit(void);
256 void open_screen(void);
257 void wait_vrt(int mix);
258 void draw_begin(void);
260 void flippage(int page);
261 void draw_begin(void);
263 void clear_lines(int page, int y, int count, pixel_t color);
264 pixel_t get_color(int color, char pal[768]);
265 pixel_t get_pixel(int page, int x, int y);
266 void set_pixel(int page, int x, int y, pixel_t color);
267 void setpalette(int index, int count, char *palette);
268 void fillpalette(int red, int green, int blue);
270 void get_block(char page, short x, short y, short width, short height, char *buffer);
271 void put_block(char page, short x, short y, short width, short height, char *buffer);
273 void get_block(int page, int x, int y, int width, int height, pixel_t *buffer);
274 void put_block(int page, int x, int y, int width, int height, pixel_t *buffer);
276 void put_text(int page, int x, int y, char *text, int align);
277 void put_pob(int page, int x, int y, int image, gob_t *gob, int mask, unsigned char *mask_pic);
278 int pob_width(int image, gob_t *gob);
279 int pob_height(int image, gob_t *gob);
280 int pob_hs_x(int image, gob_t *gob);
281 int pob_hs_y(int image, gob_t *gob);
282 int read_pcx(FILE * handle, char *buffer, int buf_len, char *pal);
283 void register_background(char *pixels, char pal[768]);
284 int register_gob(FILE *handle, gob_t *gob, int len);
285 void recalculate_gob(gob_t *gob, char pal[768]);
286 void register_mask(char *pixels);
292 long filelength(int handle);
295 int intr_sysupdate();
300 extern char last_keys[50];
302 int hook_keyb_handler(void);
303 void remove_keyb_handler(void);
304 int key_pressed(int key);