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