1/* 2 * globals.h 3 * Copyright (C) 1998 Brainchild Design - http://brainchilddesign.com/ 4 * 5 * Copyright (C) 2001 Chuck Mason <cemason@users.sourceforge.net> 6 * 7 * Copyright (C) 2002 Florian Schulze <crow@icculus.org> 8 * 9 * Copyright (C) 2015 Côme Chilliet <come@chilliet.eu> 10 * 11 * This file is part of Jump 'n Bump. 12 * 13 * Jump 'n Bump is free software; you can redistribute it and/or modify 14 * it under the terms of the GNU General Public License as published by 15 * the Free Software Foundation; either version 2 of the License, or 16 * (at your option) any later version. 17 * 18 * Jump 'n Bump is distributed in the hope that it will be useful, 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 * GNU General Public License for more details. 22 * 23 * You should have received a copy of the GNU General Public License 24 * along with this program; if not, write to the Free Software 25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 26 */ 27 28#ifndef __GLOBALS_H 29#define __GLOBALS_H 30 31#ifdef __cplusplus 32extern "C" { 33#endif 34 35#include "config.h" 36 37#include <assert.h> 38#include <stdio.h> 39#include <stdlib.h> 40#include <string.h> 41#ifndef _WIN32 42#include <strings.h> 43#endif 44#include <time.h> 45#include <math.h> 46#include <dj.h> 47 48#ifdef DOS 49# include <conio.h> 50# include <dpmi.h> 51# include <sys/nearptr.h> 52# include <pc.h> 53#endif 54 55#ifdef _WIN32 56# define WIN32_LEAN_AND_MEAN 57# include <windows.h> 58# include <sys/stat.h> 59# include <io.h> 60# include "SDL.h" 61# if USE_SDL_MIXER 62# include "SDL_mixer.h" 63# endif 64#else 65# ifdef USE_SDL 66# include <sys/stat.h> 67# include "SDL.h" 68# if USE_SDL_MIXER 69# include "SDL_mixer.h" 70# endif 71# endif 72#endif 73 74#define JNB_MAX_PLAYERS 4 75 76#define JNB_END_SCORE 100 77 78#define JNB_INETPORT 11111 79 80extern int client_player_num; 81void tellServerPlayerMoved(int playerid, int movement_type, int newval); 82#define MOVEMENT_LEFT 1 83#define MOVEMENT_RIGHT 2 84#define MOVEMENT_UP 3 85 86#define JNB_VERSION "1.61" 87 88#define JNB_WIDTH 400 89#define JNB_HEIGHT 256 90 91extern int screen_width; 92extern int screen_height; 93extern int screen_pitch; 94extern int scale_up; 95 96extern int ai[JNB_MAX_PLAYERS]; 97 98#ifndef USE_SDL 99#define KEY_PL1_LEFT 0xcb 100#define KEY_PL1_RIGHT 0xcd 101#define KEY_PL1_JUMP 0xc8 102#define KEY_PL2_LEFT 0x1e 103#define KEY_PL2_RIGHT 0x20 104#define KEY_PL2_JUMP 0x11 105#else 106#define KEY_PL1_LEFT SDL_SCANCODE_LEFT 107#define KEY_PL1_RIGHT SDL_SCANCODE_RIGHT 108#define KEY_PL1_JUMP SDL_SCANCODE_UP 109#define KEY_PL2_LEFT SDL_SCANCODE_A 110#define KEY_PL2_RIGHT SDL_SCANCODE_D 111#define KEY_PL2_JUMP SDL_SCANCODE_W 112#define KEY_PL3_LEFT SDL_SCANCODE_J 113#define KEY_PL3_RIGHT SDL_SCANCODE_L 114#define KEY_PL3_JUMP SDL_SCANCODE_I 115#define KEY_PL4_LEFT SDL_SCANCODE_KP_4 116#define KEY_PL4_RIGHT SDL_SCANCODE_KP_6 117#define KEY_PL4_JUMP SDL_SCANCODE_KP_8 118#endif 119 120#define NUM_POBS 200 121#define NUM_OBJECTS 200 122#define NUM_FLIES 20 123#define NUM_LEFTOVERS 50 124 125#define OBJ_SPRING 0 126#define OBJ_SPLASH 1 127#define OBJ_SMOKE 2 128#define OBJ_YEL_BUTFLY 3 129#define OBJ_PINK_BUTFLY 4 130#define OBJ_FUR 5 131#define OBJ_FLESH 6 132#define OBJ_FLESH_TRACE 7 133 134#define OBJ_ANIM_SPRING 0 135#define OBJ_ANIM_SPLASH 1 136#define OBJ_ANIM_SMOKE 2 137#define OBJ_ANIM_YEL_BUTFLY_RIGHT 3 138#define OBJ_ANIM_YEL_BUTFLY_LEFT 4 139#define OBJ_ANIM_PINK_BUTFLY_RIGHT 5 140#define OBJ_ANIM_PINK_BUTFLY_LEFT 6 141#define OBJ_ANIM_FLESH_TRACE 7 142 143#define MOD_MENU 0 144#define MOD_GAME 1 145#define MOD_SCORES 2 146 147#define SFX_JUMP 0 148#define SFX_LAND 1 149#define SFX_DEATH 2 150#define SFX_SPRING 3 151#define SFX_SPLASH 4 152#define SFX_FLY 5 153 154#define NUM_SFX 6 155 156#define SFX_JUMP_FREQ 15000 157#define SFX_LAND_FREQ 15000 158#define SFX_DEATH_FREQ 20000 159#define SFX_SPRING_FREQ 15000 160#define SFX_SPLASH_FREQ 12000 161#define SFX_FLY_FREQ 12000 162 163#define BAN_VOID 0 164#define BAN_SOLID 1 165#define BAN_WATER 2 166#define BAN_ICE 3 167#define BAN_SPRING 4 168 169#ifndef DATA_PATH 170#ifdef __APPLE__ 171#define DATA_PATH "data/jumpbump.dat" 172#elif _WIN32 173#define DATA_PATH "data/jumpbump.dat" 174#else 175#define DATA_PATH "%%DATADIR%%/jumpnbump/jumpbump.dat" 176#endif 177#endif 178 179typedef struct { 180 int num_images; 181 int *width; 182 int *height; 183 int *hs_x; 184 int *hs_y; 185 void **data; 186 void **orig_data; 187} gob_t; 188 189typedef struct { 190 int joy_enabled, mouse_enabled; 191 int no_sound, music_no_sound, no_gore; 192 char error_str[256]; 193 int draw_page, view_page; 194 struct { 195 int num_pobs; 196 struct { 197 int x, y; 198 int image; 199 gob_t *pob_data; 200 int back_buf_ofs; 201 } pobs[NUM_POBS]; 202 } page_info[2]; 203 void *pob_backbuf[2]; 204} main_info_t; 205 206typedef struct { 207 int action_left,action_up,action_right; 208 int enabled, dead_flag; 209 int bumps; 210 int bumped[JNB_MAX_PLAYERS]; 211 int x, y; 212 int x_add, y_add; 213 int direction, jump_ready, jump_abort, in_water; 214 int anim, frame, frame_tick, image; 215} player_t; 216 217typedef struct { 218 int num_frames; 219 int restart_frame; 220 struct { 221 int image; 222 int ticks; 223 } frame[4]; 224} player_anim_t; 225 226typedef struct { 227 int used, type; 228 int x, y; 229 int x_add, y_add; 230 int x_acc, y_acc; 231 int anim; 232 int frame, ticks; 233 int image; 234} object_t; 235 236typedef struct { 237 int x, y; 238 int raw_x, raw_y; 239 int but1, but2; 240 struct { 241 int x1, x2, x3; 242 int y1, y2, y3; 243 } calib_data; 244} joy_t; 245 246typedef struct { 247 int but1, but2, but3; 248} mouse_t; 249 250extern main_info_t main_info; 251extern player_t player[JNB_MAX_PLAYERS]; 252extern player_anim_t player_anims[7]; 253extern object_t objects[NUM_OBJECTS]; 254extern joy_t joy; 255extern mouse_t mouse; 256 257extern char datfile_name[2048]; 258 259extern unsigned char *background_pic; 260extern unsigned char *mask_pic; 261 262extern gob_t rabbit_gobs; 263extern gob_t font_gobs; 264extern gob_t object_gobs; 265extern gob_t number_gobs; 266 267 268/* main.c */ 269 270extern int endscore_reached; 271 272void steer_players(void); 273void position_player(int player_num); 274void add_object(int type, int x, int y, int x_add, int y_add, int anim, int frame); 275void update_objects(void); 276int add_pob(int page, int x, int y, int image, gob_t *pob_data); 277void draw_flies(int page); 278void draw_pobs(int page); 279void redraw_flies_background(int page); 280void redraw_pob_backgrounds(int page); 281int add_leftovers(int page, int x, int y, int image, gob_t *pob_data); 282void draw_leftovers(int page); 283int init_level(int level, char *pal); 284void deinit_level(void); 285int init_program(int argc, char *argv[], char *pal); 286void deinit_program(void); 287unsigned short rnd(unsigned short max); 288int read_level(void); 289unsigned char *dat_open(char *file_name); 290int dat_filelen(char *file_name); 291void write_calib_data(void); 292 293 294/* input.c */ 295 296void update_player_actions(void); 297void init_inputs(void); 298int calib_joy(int type); 299 300/* menu.c */ 301 302int menu(void); 303int menu_init(void); 304void menu_deinit(void); 305 306 307/* gfx.c */ 308 309void set_scaling(int scale); 310void open_screen(void); 311void wait_vrt(int mix); 312void draw_begin(void); 313void draw_end(void); 314void flippage(int page); 315void draw_begin(void); 316void draw_end(void); 317void clear_lines(int page, int y, int count, int color); 318int get_color(int color, char pal[768]); 319int get_pixel(int page, int x, int y); 320void set_pixel(int page, int x, int y, int color); 321void setpalette(int index, int count, char *palette); 322void fillpalette(int red, int green, int blue); 323#ifdef DOS 324void get_block(char page, short x, short y, short width, short height, char *buffer); 325void put_block(char page, short x, short y, short width, short height, char *buffer); 326#else 327void get_block(int page, int x, int y, int width, int height, void *buffer); 328void put_block(int page, int x, int y, int width, int height, void *buffer); 329#endif 330void put_text(int page, int x, int y, char *text, int align); 331void put_pob(int page, int x, int y, int image, gob_t *gob, int mask, void *mask_pic); 332int pob_width(int image, gob_t *gob); 333int pob_height(int image, gob_t *gob); 334int pob_hs_x(int image, gob_t *gob); 335int pob_hs_y(int image, gob_t *gob); 336int read_pcx(unsigned char * handle, void *buffer, int buf_len, char *pal); 337void register_background(unsigned char *pixels, char pal[768]); 338int register_gob(unsigned char *handle, gob_t *gob, int len); 339void recalculate_gob(gob_t *gob, char pal[768]); 340void register_mask(void *pixels); 341 342/* gfx.c */ 343 344#ifdef USE_SDL 345/* long filelength(int handle); */ 346void fs_toggle(); 347int intr_sysupdate(); 348#endif 349 350/* interrpt.c */ 351 352extern char last_keys[50]; 353 354int hook_keyb_handler(void); 355void remove_keyb_handler(void); 356int key_pressed(int key); 357int addkey(unsigned int key); 358 359/* sound-linux.c */ 360#ifdef LINUX 361 362 363#endif 364 365#ifdef __cplusplus 366} 367#endif 368 369#endif 370