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