]> icculus.org git repositories - crow/jumpnbump.git/blob - globals.h
Fixes for SDL and VisualC.
[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         char joy_enabled, mouse_enabled, num_mouse_buttons;
102         char 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         char enabled, dead_flag;
119         int bumps;
120         int bumped[4];
121         int x, y;
122         int x_add, y_add;
123         char direction, jump_ready, jump_abort, in_water;
124         int anim, frame, frame_tick, image;
125 } player[4];
126
127 struct {
128         int num_frames;
129         int restart_frame;
130         struct {
131                 int image;
132                 int ticks;
133         } frame[4];
134 } player_anims[7];
135
136 struct {
137         char used, type;
138         int x, y;
139         int x_add, y_add;
140         int x_acc, y_acc;
141         int anim;
142         int frame, ticks;
143         int image;
144 } objects[300];
145
146 struct {
147         int x, y;
148         int raw_x, raw_y;
149         char but1, but2;
150         struct {
151                 int x1, x2, x3;
152                 int y1, y2, y3;
153         } calib_data;
154 } joy;
155
156 struct {
157         char but1, but2, but3;
158 } mouse;
159
160 char datfile_name[256];
161
162 char *background_pic;
163 char *mask_pic;
164
165 char *rabbit_gobs;
166 char *font_gobs;
167
168
169 /* main.c */
170
171 void steer_players(void);
172 void position_player(short player_num);
173 void fireworks(void);
174 void add_object(char type, short x, short y, long x_add, long y_add, short anim, short frame);
175 void update_objects(void);
176 char add_pob(int page, short x, short y, short image, char *pob_data);
177 void draw_pobs(int page);
178 void redraw_pob_backgrounds(int page);
179 char add_leftovers(int page, short x, short y, short image, char *pob_data);
180 void draw_leftovers(int page);
181 char init_level(short level);
182 void deinit_level(void);
183 char init_program(int argc, char *argv[]);
184 void deinit_program(void);
185 void read_joy(void);
186 char calib_joy(char type);
187 void read_mouse(void);
188 unsigned short rnd(unsigned short max);
189 char read_level(void);
190 FILE *dat_open(char *file_name, char *dat_name, char *mode);
191 int dat_filelen(char *file_name, char *dat_name);
192 void write_calib_data(void);
193
194
195 /* menu.c */
196
197 char menu(void);
198 char menu_init(void);
199 void menu_deinit(void);
200
201
202 /* gfx.c */
203
204 void open_screen(void);
205 void wait_vrt(void);
206 #if 0
207 void get_block(char page, short x, short y, short width, short height, char *buffer);
208 void put_block(char page, short x, short y, short width, short height, char *buffer);
209 #endif
210 void put_text(char page, int x, int y, char *text, char align);
211 void put_pob(char page, short x, short y, short image, char *pob_data, char mask, char *mask_pic);
212 char pob_col(short x1, short y1, short image1, char *pob_data1, short x2, short y2, short image2, char *pob_data2);
213 short pob_width(short image, char *pob_data);
214 short pob_height(short image, char *pob_data);
215 short pob_hs_x(short image, char *pob_data);
216 short pob_hs_y(short image, char *pob_data);
217 char read_pcx(FILE * handle, char *buffer, long buf_len, char *pal);
218
219 /* gfx.c */
220
221 void get_block(char page, long x, long y, long width, long height, char *buffer);
222 void put_block(char page, long x, long y, long width, long height, char *buffer);
223
224 #ifdef USE_SDL
225 #ifndef _MSC_VER
226 long filelength(int handle);
227 #endif
228 void setpalette(int index, int count, char *palette);
229 void fillpalette(int red, int green, int blue);
230 void flippage(long page);
231 void fs_toggle();
232 char *get_vgaptr(long, long, long);
233 char intr_sysupdate();
234 #endif
235
236 /* interrpt.c */
237
238 extern char last_keys[50];
239
240 char hook_keyb_handler(void);
241 void remove_keyb_handler(void);
242 char key_pressed(unsigned char key);
243
244 /* sound-linux.c */
245 #ifdef LINUX
246
247
248 #endif
249
250 #endif