-
Notifications
You must be signed in to change notification settings - Fork 6
/
globals.h
296 lines (248 loc) · 6.67 KB
/
globals.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/*
* globals.h
* Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/
*
* Copyright (C) 2001 Chuck Mason <[email protected]>
*
* Copyright (C) 2002 Florian Schulze <[email protected]>
*
* Copyright (C) 2015 Côme Chilliet <[email protected]>
*
* This file is part of Jump 'n Bump.
*
* Jump 'n Bump is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Jump 'n Bump is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __GLOBALS_H
#define __GLOBALS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "config.h"
#include <assert.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include "dj.h"
#define JNB_MAX_PLAYERS 4
#define JNB_END_SCORE 100
#define JNB_INETPORT 11111
extern int client_player_num;
void tellServerPlayerMoved(int playerid, int movement_type, int newval);
#define MOVEMENT_LEFT 1
#define MOVEMENT_RIGHT 2
#define MOVEMENT_UP 3
#define JNB_VERSION "1.60"
#define JNB_WIDTH 400
#define JNB_HEIGHT 256
extern int ai[JNB_MAX_PLAYERS];
extern unsigned char *datafile_buffer;
#define KEY_PL1_LEFT 0xa0
#define KEY_PL1_RIGHT 0xa1
#define KEY_PL1_JUMP 0xa2
#define KEY_PL2_LEFT 0xb0
#define KEY_PL2_RIGHT 0xb1
#define KEY_PL2_JUMP 0xb2
#define KEY_PL3_LEFT 0xc0
#define KEY_PL3_RIGHT 0xc1
#define KEY_PL3_JUMP 0xc2
#define KEY_PL4_LEFT 0xd0
#define KEY_PL4_RIGHT 0xd1
#define KEY_PL4_JUMP 0xd2
#define NUM_POBS 200
#define NUM_OBJECTS 200
#define NUM_FLIES 20
#define NUM_LEFTOVERS 50
#define OBJ_SPRING 0
#define OBJ_SPLASH 1
#define OBJ_SMOKE 2
#define OBJ_YEL_BUTFLY 3
#define OBJ_PINK_BUTFLY 4
#define OBJ_FUR 5
#define OBJ_FLESH 6
#define OBJ_FLESH_TRACE 7
#define OBJ_ANIM_SPRING 0
#define OBJ_ANIM_SPLASH 1
#define OBJ_ANIM_SMOKE 2
#define OBJ_ANIM_YEL_BUTFLY_RIGHT 3
#define OBJ_ANIM_YEL_BUTFLY_LEFT 4
#define OBJ_ANIM_PINK_BUTFLY_RIGHT 5
#define OBJ_ANIM_PINK_BUTFLY_LEFT 6
#define OBJ_ANIM_FLESH_TRACE 7
#define MOD_MENU 0
#define MOD_GAME 1
#define MOD_SCORES 2
#define SFX_JUMP 0
#define SFX_LAND 1
#define SFX_DEATH 2
#define SFX_SPRING 3
#define SFX_SPLASH 4
#define SFX_FLY 5
#define NUM_SFX 6
#define SFX_JUMP_FREQ 15000
#define SFX_LAND_FREQ 15000
#define SFX_DEATH_FREQ 20000
#define SFX_SPRING_FREQ 15000
#define SFX_SPLASH_FREQ 12000
#define SFX_FLY_FREQ 12000
#define BAN_VOID 0
#define BAN_SOLID 1
#define BAN_WATER 2
#define BAN_ICE 3
#define BAN_SPRING 4
typedef struct {
int num_images;
int *width;
int *height;
int *hs_x;
int *hs_y;
void **data;
void **orig_data;
} gob_t;
typedef struct {
int joy_enabled;
int no_sound, music_no_sound, no_gore;
char error_str[256];
int draw_page, view_page;
struct {
int num_pobs;
struct {
int x, y;
int image;
gob_t *pob_data;
int back_buf_ofs;
} pobs[NUM_POBS];
} page_info[2];
uint8_t pob_backbuf[2][JNB_WIDTH*JNB_HEIGHT];
} main_info_t;
typedef struct {
int action_left,action_up,action_right;
int enabled, dead_flag;
int bumps;
int bumped[JNB_MAX_PLAYERS];
int x, y;
int x_add, y_add;
int direction, jump_ready, jump_abort, in_water;
int anim, frame, frame_tick, image;
} player_t;
typedef struct {
int num_frames;
int restart_frame;
struct {
int image;
int ticks;
} frame[4];
} player_anim_t;
typedef struct {
int used, type;
int x, y;
int x_add, y_add;
int x_acc, y_acc;
int anim;
int frame, ticks;
int image;
} object_t;
typedef struct {
int x, y;
int raw_x, raw_y;
int but1, but2;
struct {
int x1, x2, x3;
int y1, y2, y3;
} calib_data;
} joy_t;
typedef struct {
int but1, but2, but3;
} mouse_t;
extern main_info_t main_info;
extern player_t player[];
extern player_anim_t player_anims[];
extern object_t objects[];
extern joy_t joy;
extern mouse_t mouse;
extern unsigned char background_pic[];
extern unsigned char mask_pic[];
extern gob_t rabbit_gobs;
extern gob_t font_gobs;
extern gob_t object_gobs;
extern gob_t number_gobs;
extern int endscore_reached;
/* main.c */
void steer_players(void);
void position_player(int player_num);
void add_object(int type, int x, int y, int x_add, int y_add, int anim, int frame);
void update_objects(void);
int add_pob(int page, int x, int y, int image, gob_t *pob_data);
void draw_flies(int page);
void draw_pobs(int page);
void redraw_flies_background(int page);
void redraw_pob_backgrounds(int page);
int add_leftovers(int page, int x, int y, int image, gob_t *pob_data);
void draw_leftovers(int page);
int init_level(void);
void deinit_level(void);
void end_game(void);
int end_loop(void);
int init_program(void);
void deinit_program(void);
unsigned short rnd(unsigned short max);
int read_level(void);
unsigned char *dat_open(char *file_name);
int dat_filelen(char *file_name);
void game_init(void);
int game_loop(void);
/* input.c */
void update_player_actions(void);
/* menu.c */
int menu_frame(void);
int menu_init(void);
void menu_deinit(void);
/* gfx.c */
void open_screen(void);
void draw_begin(void);
void draw_end(void);
void flippage(int page);
void draw_begin(void);
void draw_end(void);
void clear_lines(int page, int y, int count, int color);
int get_color(int color, char pal[768]);
int get_pixel(int page, int x, int y);
void set_pixel(int page, int x, int y, int color);
void setpalette(int index, int count, char *palette);
void fillpalette(int red, int green, int blue);
void get_block(int page, int x, int y, int width, int height, void *buffer);
void put_block(int page, int x, int y, int width, int height, void *buffer);
void put_text(int page, int x, int y, char *text, int align);
void put_pob(int page, int x, int y, int image, gob_t *gob, int mask, void *mask_pic);
int pob_width(int image, gob_t *gob);
int pob_height(int image, gob_t *gob);
int pob_hs_x(int image, gob_t *gob);
int pob_hs_y(int image, gob_t *gob);
int read_pcx(unsigned char * handle, void *buffer, int buf_len, char *pal);
void register_background(unsigned char *pixels, char pal[768]);
int register_gob(unsigned char *handle, gob_t *gob, int len);
void free_gob(gob_t *gob);
void register_mask(void *pixels);
/* interrpt.c */
extern char last_keys[50];
int key_pressed(int key);
int addkey(unsigned int key);
void mix_sound(signed short *stream, int len);
#ifdef __cplusplus
}
#endif
#endif