]> icculus.org git repositories - crow/jumpnbump.git/blob - globals.h
Some documentation updates by Tarzeau.
[crow/jumpnbump.git] / globals.h
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 #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 # include <SDL_mixer.h>
60 #else
61 # ifdef USE_SDL
62 #  include <sys/stat.h>
63 #  include <SDL/SDL.h>
64 #  include <SDL/SDL_mixer.h>
65 # endif
66 #endif
67
68 #define JNB_VERSION "1.34"
69
70 #define JNB_WIDTH 400
71 #define JNB_HEIGHT 256
72 extern int screen_width;
73 extern int screen_height;
74 extern int screen_pitch;
75 extern int scale_up;
76 extern int bytes_per_pixel;
77
78 #ifndef USE_SDL
79 #define KEY_PL1_LEFT 0xcb
80 #define KEY_PL1_RIGHT   0xcd
81 #define KEY_PL1_JUMP 0xc8
82 #define KEY_PL2_LEFT 0x1e
83 #define KEY_PL2_RIGHT   0x20
84 #define KEY_PL2_JUMP 0x11
85 #else
86 #define KEY_PL1_LEFT SDLK_LEFT
87 #define KEY_PL1_RIGHT   SDLK_RIGHT
88 #define KEY_PL1_JUMP SDLK_UP
89 #define KEY_PL2_LEFT SDLK_a
90 #define KEY_PL2_RIGHT   SDLK_d
91 #define KEY_PL2_JUMP SDLK_w
92 #define KEY_PL3_LEFT SDLK_j
93 #define KEY_PL3_RIGHT   SDLK_l
94 #define KEY_PL3_JUMP SDLK_i
95 #define KEY_PL4_LEFT SDLK_KP4
96 #define KEY_PL4_RIGHT   SDLK_KP6
97 #define KEY_PL4_JUMP SDLK_KP8
98 #endif
99
100 #define NUM_POBS 200
101 #define NUM_OBJECTS 200
102 #define NUM_FLIES 20
103 #define NUM_LEFTOVERS 50
104
105 #define OBJ_SPRING 0
106 #define OBJ_SPLASH 1
107 #define OBJ_SMOKE 2
108 #define OBJ_YEL_BUTFLY 3
109 #define OBJ_PINK_BUTFLY 4
110 #define OBJ_FUR 5
111 #define OBJ_FLESH 6
112 #define OBJ_FLESH_TRACE 7
113
114 #define OBJ_ANIM_SPRING 0
115 #define OBJ_ANIM_SPLASH 1
116 #define OBJ_ANIM_SMOKE 2
117 #define OBJ_ANIM_YEL_BUTFLY_RIGHT 3
118 #define OBJ_ANIM_YEL_BUTFLY_LEFT 4
119 #define OBJ_ANIM_PINK_BUTFLY_RIGHT 5
120 #define OBJ_ANIM_PINK_BUTFLY_LEFT 6
121 #define OBJ_ANIM_FLESH_TRACE 7
122
123 #define MOD_MENU 0
124 #define MOD_GAME 1
125 #define MOD_SCORES 2
126
127 #define SFX_JUMP 0
128 #define SFX_LAND 1
129 #define SFX_DEATH 2
130 #define SFX_SPRING 3
131 #define SFX_SPLASH 4
132 #define SFX_FLY 5
133
134 #define NUM_SFX 6
135
136 #define SFX_JUMP_FREQ 15000
137 #define SFX_LAND_FREQ 15000
138 #define SFX_DEATH_FREQ 20000
139 #define SFX_SPRING_FREQ 15000
140 #define SFX_SPLASH_FREQ 12000
141 #define SFX_FLY_FREQ 12000
142
143 #define BAN_VOID        0
144 #define BAN_SOLID       1
145 #define BAN_WATER       2
146 #define BAN_ICE         3
147 #define BAN_SPRING      4
148
149 #ifndef DATA_PATH
150 #ifdef __APPLE__
151 #define DATA_PATH "data/jumpbump.dat"
152 #elif _WIN32
153 #define DATA_PATH "data/jumpbump.dat"
154 #else
155 #define DATA_PATH "/usr/share/jumpnbump/jumpbump.dat"
156 #endif
157 #endif
158
159 typedef struct {
160         int num_images;
161         int *width;
162         int *height;
163         int *hs_x;
164         int *hs_y;
165         void **data;
166         void **orig_data;
167 } gob_t;
168
169 typedef struct {
170         int joy_enabled, mouse_enabled;
171         int no_sound, music_no_sound, no_gore, fireworks;
172         char error_str[256];
173         int draw_page, view_page;
174         struct {
175                 int num_pobs;
176                 struct {
177                         int x, y;
178                         int image;
179                         gob_t *pob_data;
180                         int back_buf_ofs;
181                 } pobs[NUM_POBS];
182         } page_info[2];
183         void *pob_backbuf[2];
184 } main_info_t;
185
186 typedef struct {
187         int action_left,action_up,action_right;
188         int enabled, dead_flag;
189         int bumps;
190         int bumped[4];
191         int x, y;
192         int x_add, y_add;
193         int direction, jump_ready, jump_abort, in_water;
194         int anim, frame, frame_tick, image;
195 } player_t;
196
197 typedef struct {
198         int num_frames;
199         int restart_frame;
200         struct {
201                 int image;
202                 int ticks;
203         } frame[4];
204 } player_anim_t;
205
206 typedef struct {
207         int used, type;
208         int x, y;
209         int x_add, y_add;
210         int x_acc, y_acc;
211         int anim;
212         int frame, ticks;
213         int image;
214 } object_t;
215
216 typedef struct {
217         int x, y;
218         int raw_x, raw_y;
219         int but1, but2;
220         struct {
221                 int x1, x2, x3;
222                 int y1, y2, y3;
223         } calib_data;
224 } joy_t;
225
226 typedef struct {
227         int but1, but2, but3;
228 } mouse_t;
229
230 extern main_info_t main_info;
231 extern player_t player[4];
232 extern player_anim_t player_anims[7];
233 extern object_t objects[NUM_OBJECTS];
234 extern joy_t joy;
235 extern mouse_t mouse;
236
237 extern char datfile_name[2048];
238
239 extern char *background_pic;
240 extern char *mask_pic;
241
242 extern gob_t rabbit_gobs;
243 extern gob_t font_gobs;
244 extern gob_t object_gobs;
245 extern gob_t number_gobs;
246
247
248 /* fireworks.c */
249
250 void fireworks(void);
251
252
253 /* main.c */
254
255 void steer_players(void);
256 void position_player(int player_num);
257 void fireworks(void);
258 void add_object(int type, int x, int y, int x_add, int y_add, int anim, int frame);
259 void update_objects(void);
260 int add_pob(int page, int x, int y, int image, gob_t *pob_data);
261 void draw_flies(int page);
262 void draw_pobs(int page);
263 void redraw_flies_background(int page);
264 void redraw_pob_backgrounds(int page);
265 int add_leftovers(int page, int x, int y, int image, gob_t *pob_data);
266 void draw_leftovers(int page);
267 int init_level(int level, char *pal);
268 void deinit_level(void);
269 int init_program(int argc, char *argv[], char *pal);
270 void deinit_program(void);
271 unsigned short rnd(unsigned short max);
272 int read_level(void);
273 FILE *dat_open(char *file_name, char *dat_name, char *mode);
274 int dat_filelen(char *file_name, char *dat_name);
275 void write_calib_data(void);
276
277
278 /* input.c */
279
280 void update_player_actions(void);
281 void init_inputs(void);
282 int calib_joy(int type);
283
284 /* menu.c */
285
286 int menu(void);
287 int menu_init(void);
288 void menu_deinit(void);
289
290
291 /* gfx.c */
292
293 void set_scaling(int scale);
294 void open_screen(void);
295 void wait_vrt(int mix);
296 void draw_begin(void);
297 void draw_end(void);
298 void flippage(int page);
299 void draw_begin(void);
300 void draw_end(void);
301 void clear_lines(int page, int y, int count, int color);
302 int get_color(int color, char pal[768]);
303 int get_pixel(int page, int x, int y);
304 void set_pixel(int page, int x, int y, int color);
305 void setpalette(int index, int count, char *palette);
306 void fillpalette(int red, int green, int blue);
307 #ifdef DOS
308 void get_block(char page, short x, short y, short width, short height, char *buffer);
309 void put_block(char page, short x, short y, short width, short height, char *buffer);
310 #else
311 void get_block(int page, int x, int y, int width, int height, void *buffer);
312 void put_block(int page, int x, int y, int width, int height, void *buffer);
313 #endif
314 void put_text(int page, int x, int y, char *text, int align);
315 void put_pob(int page, int x, int y, int image, gob_t *gob, int mask, void *mask_pic);
316 int pob_width(int image, gob_t *gob);
317 int pob_height(int image, gob_t *gob);
318 int pob_hs_x(int image, gob_t *gob);
319 int pob_hs_y(int image, gob_t *gob);
320 int read_pcx(FILE * handle, void *buffer, int buf_len, char *pal);
321 void register_background(char *pixels, char pal[768]);
322 int register_gob(FILE *handle, gob_t *gob, int len);
323 void recalculate_gob(gob_t *gob, char pal[768]);
324 void register_mask(void *pixels);
325
326 /* gfx.c */
327
328 #ifdef USE_SDL
329 //long filelength(int handle);
330 void fs_toggle();
331 int intr_sysupdate();
332 #endif
333
334 /* interrpt.c */
335
336 extern char last_keys[50];
337
338 int hook_keyb_handler(void);
339 void remove_keyb_handler(void);
340 int key_pressed(int key);
341
342 /* sound-linux.c */
343 #ifdef LINUX
344
345
346 #endif
347
348 #endif