]> icculus.org git repositories - crow/jumpnbump.git/blob - globals.h
More cleanups. Added get_pixel and set_pixel 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 #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 SFX_JUMP_FREQ 15000
96 #define SFX_LAND_FREQ 15000
97 #define SFX_DEATH_FREQ 20000
98 #define SFX_SPRING_FREQ 15000
99 #define SFX_SPLASH_FREQ 12000
100 #define SFX_FLY_FREQ 12000
101
102 #define BAN_VOID        0
103 #define BAN_SOLID       1
104 #define BAN_WATER       2
105 #define BAN_ICE         3
106 #define BAN_SPRING      4
107
108
109 struct {
110         int joy_enabled, mouse_enabled;
111         int no_sound, no_gore, fireworks;
112         char error_str[256];
113         int draw_page, view_page;
114         struct {
115                 int num_pobs;
116                 struct {
117                         int x, y;
118                         int image;
119                         char *pob_data;
120                         int back_buf_ofs;
121                 } pobs[NUM_POBS];
122         } page_info[2];
123         char *pob_backbuf[2];
124 } main_info;
125
126 struct {
127         int action_left,action_up,action_right;
128         int enabled, dead_flag;
129         int bumps;
130         int bumped[4];
131         int x, y;
132         int x_add, y_add;
133         char direction, jump_ready, jump_abort, in_water;
134         int anim, frame, frame_tick, image;
135 } player[4];
136
137 struct {
138         int num_frames;
139         int restart_frame;
140         struct {
141                 int image;
142                 int ticks;
143         } frame[4];
144 } player_anims[7];
145
146 struct {
147         int used, type;
148         int x, y;
149         int x_add, y_add;
150         int x_acc, y_acc;
151         int anim;
152         int frame, ticks;
153         int image;
154 } objects[NUM_OBJECTS];
155
156 struct {
157         int x, y;
158         int raw_x, raw_y;
159         int but1, but2;
160         struct {
161                 int x1, x2, x3;
162                 int y1, y2, y3;
163         } calib_data;
164 } joy;
165
166 struct {
167         int but1, but2, but3;
168 } mouse;
169
170 char datfile_name[2048];
171
172 char *background_pic;
173 char *mask_pic;
174
175 char *rabbit_gobs;
176 char *font_gobs;
177
178
179 /* fireworks.c */
180
181 void fireworks(void);
182
183
184 /* main.c */
185
186 void steer_players(void);
187 void position_player(int player_num);
188 void fireworks(void);
189 void add_object(int type, int x, int y, int x_add, int y_add, int anim, int frame);
190 void update_objects(void);
191 int add_pob(int page, int x, int y, int image, char *pob_data);
192 void draw_flies(int page);
193 void draw_pobs(int page);
194 void redraw_flies_background(int page);
195 void redraw_pob_backgrounds(int page);
196 int add_leftovers(int page, int x, int y, int image, char *pob_data);
197 void draw_leftovers(int page);
198 int init_level(int level, char *pal);
199 void deinit_level(void);
200 int init_program(int argc, char *argv[], char *pal);
201 void deinit_program(void);
202 unsigned short rnd(unsigned short max);
203 int read_level(void);
204 FILE *dat_open(char *file_name, char *dat_name, char *mode);
205 int dat_filelen(char *file_name, char *dat_name);
206 void write_calib_data(void);
207
208
209 /* input.c */
210
211 void update_player_actions(void);
212 void init_inputs(void);
213 int calib_joy(char type);
214
215 /* menu.c */
216
217 int menu(void);
218 int menu_init(void);
219 void menu_deinit(void);
220
221
222 /* gfx.c */
223
224 void open_screen(void);
225 void wait_vrt(int mix);
226 void flippage(int page);
227 void clear_page(int page, int color);
228 void clear_lines(int page, int y, int count, int color);
229 int get_pixel(int page, int x, int y);
230 void set_pixel(int page, int x, int y, int color);
231 void setpalette(int index, int count, char *palette);
232 void fillpalette(int red, int green, int blue);
233 #ifdef DOS
234 void get_block(char page, short x, short y, short width, short height, char *buffer);
235 void put_block(char page, short x, short y, short width, short height, char *buffer);
236 #else
237 void get_block(int page, int x, int y, int width, int height, char *buffer);
238 void put_block(int page, int x, int y, int width, int height, char *buffer);
239 #endif
240 void put_text(int page, int x, int y, char *text, int align);
241 void put_pob(int page, int x, int y, int image, char *pob_data, int mask, char *mask_pic);
242 int pob_col(int x1, int y1, int image1, char *pob_data1, int x2, int y2, int image2, char *pob_data2);
243 int pob_width(int image, char *pob_data);
244 int pob_height(int image, char *pob_data);
245 int pob_hs_x(int image, char *pob_data);
246 int pob_hs_y(int image, char *pob_data);
247 int read_pcx(FILE * handle, char *buffer, int buf_len, char *pal);
248
249 /* gfx.c */
250
251 #ifdef USE_SDL
252 #ifndef _MSC_VER
253 long filelength(int handle);
254 #endif
255 void fs_toggle();
256 int intr_sysupdate();
257 #endif
258
259 /* interrpt.c */
260
261 extern char last_keys[50];
262
263 int hook_keyb_handler(void);
264 void remove_keyb_handler(void);
265 int key_pressed(int key);
266
267 /* sound-linux.c */
268 #ifdef LINUX
269
270
271 #endif
272
273 #endif