]> icculus.org git repositories - crow/jumpnbump.git/blob - globals.h
Updated the sound engine. Much nicer mixing now.
[crow/jumpnbump.git] / globals.h
1 #ifndef __GLOBALS_H
2 #define __GLOBALS_H
3
4 #include "config.h"
5
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #ifndef _MSC_VER
10 #include <strings.h>
11 #endif
12 #include <time.h>
13 #include <math.h>
14 #include <dj.h>
15
16 #ifdef DOS
17 # include <conio.h>
18 # include <dpmi.h>
19 # include <sys/nearptr.h>
20 # include <pc.h>
21 #endif
22
23 #ifdef _MSC_VER
24 # include <sys/stat.h>
25 # include <io.h>
26 # include <SDL.h>
27 # include <SDL_mixer.h>
28 #else
29 # ifdef USE_SDL
30 #  include <sys/stat.h>
31 #  include <SDL/SDL.h>
32 #  include <SDL/SDL_mixer.h>
33 # endif
34 #endif
35
36 #define JNB_WIDTH 400
37 #define JNB_HEIGHT 256
38
39 #ifndef USE_SDL
40 #define KEY_PL1_LEFT 0xcb
41 #define KEY_PL1_RIGHT   0xcd
42 #define KEY_PL1_JUMP 0xc8
43 #define KEY_PL2_LEFT 0x1e
44 #define KEY_PL2_RIGHT   0x20
45 #define KEY_PL2_JUMP 0x11
46 #else
47 #define KEY_PL1_LEFT SDLK_LEFT
48 #define KEY_PL1_RIGHT   SDLK_RIGHT
49 #define KEY_PL1_JUMP SDLK_UP
50 #define KEY_PL2_LEFT SDLK_a
51 #define KEY_PL2_RIGHT   SDLK_d
52 #define KEY_PL2_JUMP SDLK_w
53 #define KEY_PL3_LEFT SDLK_j
54 #define KEY_PL3_RIGHT   SDLK_l
55 #define KEY_PL3_JUMP SDLK_i
56 #define KEY_PL4_LEFT SDLK_KP4
57 #define KEY_PL4_RIGHT   SDLK_KP6
58 #define KEY_PL4_JUMP SDLK_KP8
59 #endif
60
61 #define NUM_POBS 200
62 #define NUM_OBJECTS 200
63 #define NUM_FLIES 20
64 #define NUM_LEFTOVERS 50
65
66 #define OBJ_SPRING 0
67 #define OBJ_SPLASH 1
68 #define OBJ_SMOKE 2
69 #define OBJ_YEL_BUTFLY 3
70 #define OBJ_PINK_BUTFLY 4
71 #define OBJ_FUR 5
72 #define OBJ_FLESH 6
73 #define OBJ_FLESH_TRACE 7
74
75 #define OBJ_ANIM_SPRING 0
76 #define OBJ_ANIM_SPLASH 1
77 #define OBJ_ANIM_SMOKE 2
78 #define OBJ_ANIM_YEL_BUTFLY_RIGHT 3
79 #define OBJ_ANIM_YEL_BUTFLY_LEFT 4
80 #define OBJ_ANIM_PINK_BUTFLY_RIGHT 5
81 #define OBJ_ANIM_PINK_BUTFLY_LEFT 6
82 #define OBJ_ANIM_FLESH_TRACE 7
83
84 #define MOD_MENU 0
85 #define MOD_GAME 1
86 #define MOD_SCORES 2
87
88 #define SFX_JUMP 0
89 #define SFX_LAND 1
90 #define SFX_DEATH 2
91 #define SFX_SPRING 3
92 #define SFX_SPLASH 4
93 #define SFX_FLY 5
94
95 #define NUM_SFX 6
96
97 #define SFX_JUMP_FREQ 15000
98 #define SFX_LAND_FREQ 15000
99 #define SFX_DEATH_FREQ 20000
100 #define SFX_SPRING_FREQ 15000
101 #define SFX_SPLASH_FREQ 12000
102 #define SFX_FLY_FREQ 12000
103
104 #define BAN_VOID        0
105 #define BAN_SOLID       1
106 #define BAN_WATER       2
107 #define BAN_ICE         3
108 #define BAN_SPRING      4
109
110
111 struct {
112         int joy_enabled, mouse_enabled;
113         int no_sound, no_gore, fireworks;
114         char error_str[256];
115         int draw_page, view_page;
116         struct {
117                 int num_pobs;
118                 struct {
119                         int x, y;
120                         int image;
121                         char *pob_data;
122                         int back_buf_ofs;
123                 } pobs[NUM_POBS];
124         } page_info[2];
125         char *pob_backbuf[2];
126 } main_info;
127
128 struct {
129         int action_left,action_up,action_right;
130         int enabled, dead_flag;
131         int bumps;
132         int bumped[4];
133         int x, y;
134         int x_add, y_add;
135         char direction, jump_ready, jump_abort, in_water;
136         int anim, frame, frame_tick, image;
137 } player[4];
138
139 struct {
140         int num_frames;
141         int restart_frame;
142         struct {
143                 int image;
144                 int ticks;
145         } frame[4];
146 } player_anims[7];
147
148 struct {
149         int used, type;
150         int x, y;
151         int x_add, y_add;
152         int x_acc, y_acc;
153         int anim;
154         int frame, ticks;
155         int image;
156 } objects[NUM_OBJECTS];
157
158 struct {
159         int x, y;
160         int raw_x, raw_y;
161         int but1, but2;
162         struct {
163                 int x1, x2, x3;
164                 int y1, y2, y3;
165         } calib_data;
166 } joy;
167
168 struct {
169         int but1, but2, but3;
170 } mouse;
171
172 char datfile_name[2048];
173
174 char *background_pic;
175 char *mask_pic;
176
177 char *rabbit_gobs;
178 char *font_gobs;
179
180
181 /* fireworks.c */
182
183 void fireworks(void);
184
185
186 /* main.c */
187
188 void steer_players(void);
189 void position_player(int player_num);
190 void fireworks(void);
191 void add_object(int type, int x, int y, int x_add, int y_add, int anim, int frame);
192 void update_objects(void);
193 int add_pob(int page, int x, int y, int image, char *pob_data);
194 void draw_flies(int page);
195 void draw_pobs(int page);
196 void redraw_flies_background(int page);
197 void redraw_pob_backgrounds(int page);
198 int add_leftovers(int page, int x, int y, int image, char *pob_data);
199 void draw_leftovers(int page);
200 int init_level(int level, char *pal);
201 void deinit_level(void);
202 int init_program(int argc, char *argv[], char *pal);
203 void deinit_program(void);
204 unsigned short rnd(unsigned short max);
205 int read_level(void);
206 FILE *dat_open(char *file_name, char *dat_name, char *mode);
207 int dat_filelen(char *file_name, char *dat_name);
208 void write_calib_data(void);
209
210
211 /* input.c */
212
213 void update_player_actions(void);
214 void init_inputs(void);
215 int calib_joy(char type);
216
217 /* menu.c */
218
219 int menu(void);
220 int menu_init(void);
221 void menu_deinit(void);
222
223
224 /* gfx.c */
225
226 void open_screen(void);
227 void wait_vrt(int mix);
228 void flippage(int page);
229 void clear_page(int page, int color);
230 void clear_lines(int page, int y, int count, int color);
231 int get_pixel(int page, int x, int y);
232 void set_pixel(int page, int x, int y, int color);
233 void setpalette(int index, int count, char *palette);
234 void fillpalette(int red, int green, int blue);
235 #ifdef DOS
236 void get_block(char page, short x, short y, short width, short height, char *buffer);
237 void put_block(char page, short x, short y, short width, short height, char *buffer);
238 #else
239 void get_block(int page, int x, int y, int width, int height, char *buffer);
240 void put_block(int page, int x, int y, int width, int height, char *buffer);
241 #endif
242 void put_text(int page, int x, int y, char *text, int align);
243 void put_pob(int page, int x, int y, int image, char *pob_data, int mask, char *mask_pic);
244 int pob_col(int x1, int y1, int image1, char *pob_data1, int x2, int y2, int image2, char *pob_data2);
245 int pob_width(int image, char *pob_data);
246 int pob_height(int image, char *pob_data);
247 int pob_hs_x(int image, char *pob_data);
248 int pob_hs_y(int image, char *pob_data);
249 int read_pcx(FILE * handle, char *buffer, int buf_len, char *pal);
250
251 /* gfx.c */
252
253 #ifdef USE_SDL
254 #ifndef _MSC_VER
255 long filelength(int handle);
256 #endif
257 void fs_toggle();
258 int intr_sysupdate();
259 #endif
260
261 /* interrpt.c */
262
263 extern char last_keys[50];
264
265 int hook_keyb_handler(void);
266 void remove_keyb_handler(void);
267 int key_pressed(int key);
268
269 /* sound-linux.c */
270 #ifdef LINUX
271
272
273 #endif
274
275 #endif