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