1 /* $Id: game.h,v 1.6 2003-12-08 22:32:56 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Constants & prototypes which pertain to the game only
20 * Revision 1.3 1995/09/14 13:44:34 allender
21 * fixed function prototypes to have void return value to satify
24 * Revision 1.2 1995/08/17 09:25:05 allender
25 * externed Scanline_double variable
27 * Revision 1.1 1995/05/16 15:56:46 allender
30 * Revision 2.1 1995/03/06 15:23:22 john
31 * New screen techniques.
33 * Revision 2.0 1995/02/27 11:28:21 john
34 * New version 2.0, which has no anonymous unions, builds with
35 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
37 * Revision 1.79 1995/02/13 10:37:17 john
38 * Saved Buggin' cheat mode to save file.
40 * Revision 1.78 1995/02/01 16:34:12 john
43 * Revision 1.77 1995/01/29 21:37:14 mike
44 * initialize variables on game load so you don't drain your energy when you fire.
46 * Revision 1.76 1995/01/26 22:11:36 mike
47 * Purple chromo-blaster (ie, fusion cannon) spruce up (chromification)
49 * Revision 1.75 1995/01/26 16:45:31 mike
50 * Add autofire fusion cannon stuff.
52 * Revision 1.74 1994/12/11 23:18:06 john
54 * Added RealFrameTime.
55 * Put in a pause when sound initialization error.
56 * Made controlcen countdown and framerate use RealFrameTime.
58 * Revision 1.73 1994/12/09 00:41:24 mike
59 * fix hang in automap print screen
61 * Revision 1.72 1994/12/04 13:47:00 mike
62 * enhance custom detail level support.
64 * Revision 1.71 1994/12/02 15:05:44 matt
65 * Added new "official" cheats
67 * Revision 1.70 1994/11/28 18:14:09 rob
68 * Added game_mode flag for team games.
70 * Revision 1.69 1994/11/15 16:51:13 matt
71 * Made rear view only switch to rear cockpit if cockpit on in front view
73 * Revision 1.68 1994/11/04 16:26:10 john
74 * Fixed bug with letterbox mode game after you finish a game.
76 * Revision 1.67 1994/11/02 11:59:48 john
77 * Moved menu out of game into inferno main loop.
79 * Revision 1.66 1994/10/26 23:02:19 matt
80 * Made palette flash saturate negative values
82 * Revision 1.65 1994/10/26 15:21:05 mike
83 * Detail level stuff. Make Render_depth public.
85 * Revision 1.64 1994/10/19 00:13:01 matt
88 * Revision 1.63 1994/10/09 14:54:39 matt
89 * Made player cockpit state & window size save/restore with saved games & automap
91 * Revision 1.62 1994/10/08 19:56:32 matt
94 * Revision 1.61 1994/10/07 22:19:32 mike
95 * Increase number of difficulty levels from 4 to 5.
97 * Revision 1.60 1994/10/06 14:14:11 matt
98 * Added new function to reset time (to prevent big FrameTime) at start of level
100 * Revision 1.59 1994/10/05 17:08:43 matt
101 * Changed order of cockpit bitmaps, since there's no longer a full-screen cockpit
103 * Revision 1.58 1994/10/03 23:44:13 matt
104 * Save & restore palette effect around menus & pause message
106 * Revision 1.57 1994/09/29 17:42:12 matt
107 * Cleaned up game_mode a little
109 * Revision 1.56 1994/09/28 23:12:01 matt
110 * Macroized palette flash system
112 * Revision 1.55 1994/09/24 16:56:13 rob
113 * Added new fields for the Game_mode bitvector for modem play.
115 * Revision 1.54 1994/09/24 14:16:20 mike
116 * Added new game mode constants.
118 * Revision 1.53 1994/09/22 19:00:57 mike
119 * Move NDL from robot.h to here.
121 * Revision 1.52 1994/09/22 10:46:51 mike
122 * Add difficulty levels.
124 * Revision 1.51 1994/09/17 01:39:52 matt
125 * Added status bar/sizable window mode, and in the process revamped the
126 * whole cockpit mode system.
128 * Revision 1.50 1994/09/15 21:23:10 matt
129 * Changed system to keep track of whether & what cockpit is up
131 * Revision 1.49 1994/09/15 16:11:33 john
132 * Added support for VFX1 head tracking. Fixed bug with memory over-
133 * write when using stereo mode.
135 * Revision 1.48 1994/09/13 16:40:10 mike
136 * Prototype Global_missile_firing_count.
138 * Revision 1.47 1994/09/13 11:19:05 mike
139 * Add Next_missile_fire_time.
141 * Revision 1.46 1994/09/12 09:52:50 john
142 * Made global flush function that flushes keyboard,mouse, and joystick.
144 * Revision 1.45 1994/09/03 15:24:14 mike
145 * Make global Global_laser_firing_count.
147 * Revision 1.44 1994/08/31 19:26:57 mike
148 * Prototypes for Next_laser_fire_time, Laser_delay_time.
150 * Revision 1.43 1994/08/18 10:47:22 john
151 * Cleaned up game sequencing and player death stuff
152 * in preparation for making the player explode into
155 * Revision 1.42 1994/08/11 18:03:53 matt
158 * Revision 1.41 1994/06/29 20:41:38 matt
159 * Added new pause mode; cleaned up countdown & game startup code
161 * Revision 1.40 1994/06/24 17:03:49 john
162 * Added VFX support. Also took all game sequencing stuff like
163 * EndGame out and put it into gameseq.c
165 * Revision 1.39 1994/06/20 15:01:08 yuan
166 * Added death when mine blows up...
167 * Continues onto next level.
169 * Revision 1.38 1994/06/17 18:07:20 matt
170 * Moved some vars out of ifdef
172 * Revision 1.37 1994/06/15 11:09:22 yuan
173 * Moved gauge_message to mono screen for now.
175 * Revision 1.36 1994/05/30 20:22:11 yuan
178 * Revision 1.35 1994/05/27 10:32:48 yuan
179 * New dialog boxes (Walls and Triggers) added.
182 * Revision 1.34 1994/05/20 11:56:45 matt
183 * Cleaned up find_vector_intersection() interface
184 * Killed check_point_in_seg(), check_player_seg(), check_object_seg()
186 * Revision 1.33 1994/05/19 21:45:21 matt
187 * Removed unused prototypes
189 * Revision 1.32 1994/05/19 18:53:17 yuan
190 * Changing player structure...
192 * Revision 1.31 1994/05/16 16:38:35 yuan
193 * Fixed palette add so it doesn't show up in the menu.
195 * Revision 1.30 1994/05/16 09:28:17 matt
196 * Renamed init_player() to be init_player_stats(), added new funtion
197 * init_player_object()
199 * Revision 1.29 1994/05/14 17:14:57 matt
200 * Got rid of externs in source (non-header) files
212 //#include "segment.h"
215 extern ubyte Scanline_double;
219 typedef struct cockpit_span_line {
226 extern cockpit_span_line win_cockpit_mask[480];
231 extern fix FrameTime; // time in seconds since last frame
232 extern fix RealFrameTime; // time in seconds since last frame
233 extern fix GameTime; // time in game (sum of FrameTime)
234 extern int FrameCount; // how many frames rendered
235 extern fix Next_laser_fire_time; // Time at which player can next fire his selected laser.
236 extern fix Last_laser_fired_time;
237 extern fix Next_missile_fire_time; // Time at which player can next fire his selected missile.
238 extern fix Laser_delay_time; // Delay between laser fires.
239 extern int Cheats_enabled;
241 extern int Missile_view_enabled;
243 extern object *Missile_viewer;
251 extern int Cockpit_3d_view[2]; // left & right
252 extern int Coop_view_player[2]; // left & right
253 extern int Marker_viewer_num[2]; // left & right
255 // constants for ft_preference
258 #define FP_FORWARD 2 // this is the default
261 #define FP_FIRST_TIME 5
263 extern int ft_preference;
265 // The following bits define the game modes.
266 #define GM_EDITOR 1 // You came into the game from the editor
267 #define GM_SERIAL 2 // You are in serial mode
268 #define GM_NETWORK 4 // You are in network mode
269 #define GM_MULTI_ROBOTS 8 // You are in a multiplayer mode with robots.
270 #define GM_MULTI_COOP 16 // You are in a multiplayer mode and can't hurt other players.
271 #define GM_MODEM 32 // You are in a modem (serial) game
273 #define GM_UNKNOWN 64 // You are not in any mode, kind of dangerous...
274 #define GM_GAME_OVER 128 // Game has been finished
276 #define GM_TEAM 256 // Team mode for network play
277 #define GM_CAPTURE 512 // Capture the flag mode for D2
278 #define GM_HOARD 1024 // New hoard mode for D2 Christmas
280 #define GM_NORMAL 0 // You are in normal play mode, no multiplayer stuff
281 #define GM_MULTI 38 // You are in some type of multiplayer game
284 // Deathmatch mode on a network is GM_NETWORK
285 // Deathmatch mode via modem with robots is GM_MODEM | GM_MULTI_ROBOTS
286 // Cooperative mode via serial link is GM_SERIAL | GM_MULTI_COOP
288 #define NDL 5 // Number of difficulty levels.
289 #define NUM_DETAIL_LEVELS 6
291 extern int Game_mode;
293 extern int Game_paused;
294 extern int gauge_message_on;
296 #ifndef NDEBUG // if debugging, these are variables
298 extern int Slew_on; // in slew or sim mode?
299 extern int Game_double_buffer; // double buffering?
302 #else // if not debugging, these are constants
304 #define Slew_on 0 // no slewing in real game
305 #define Game_double_buffer 1 // always double buffer in real game
311 #define Scanline_double 0 // PC doesn't do scanline doubling
315 extern ubyte Scanline_double; // but the Macintosh does
321 #define SUSP_NONE 0 // Everything moving normally
322 #define SUSP_ROBOTS 1 // Robot AI doesn't move
323 #define SUSP_WEAPONS 2 // Lasers, etc. don't move
325 extern int Game_suspended; // if non-zero, nothing moves but player
328 void init_game(void);
330 void close_game(void);
331 void init_cockpit(void);
332 void calc_frame_time(void);
334 int do_flythrough(object *obj,int first_time);
336 extern jmp_buf LeaveGame; // Do a long jump to this when game is over.
337 extern int Difficulty_level; // Difficulty level in 0..NDL-1, 0 = easiest, NDL-1 = hardest
338 extern int Detail_level; // Detail level in 0..NUM_DETAIL_LEVELS-1, 0 = boringest, NUM_DETAIL_LEVELS = coolest
339 extern int Global_laser_firing_count;
340 extern int Global_missile_firing_count;
341 extern int Render_depth;
342 extern fix Auto_fire_fusion_cannon_time, Fusion_charge;
344 extern int PaletteRedAdd, PaletteGreenAdd, PaletteBlueAdd;
346 #define MAX_PALETTE_ADD 30
348 extern void PALETTE_FLASH_ADD(int dr, int dg, int db);
350 //sets the rgb values for palette flash
351 #define PALETTE_FLASH_SET(_r,_g,_b) PaletteRedAdd=(_r), PaletteGreenAdd=(_g), PaletteBlueAdd=(_b)
353 extern int draw_gauges_on;
355 extern void init_game_screen(void);
357 extern void game_flush_inputs(); // clear all inputs
359 extern int Playing_game; // True if playing game
360 extern int Auto_flythrough; // if set, start flythough automatically
361 extern int Mark_count; // number of debugging marks set
362 extern char faded_in;
364 extern void stop_time(void);
365 extern void start_time(void);
366 extern void reset_time(void); // called when starting level
368 // If automap_flag == 1, then call automap routine to write message.
369 extern void save_screen_shot(int automap_flag);
372 extern grs_canvas * get_current_game_screen();
375 //valid modes for cockpit
376 #define CM_FULL_COCKPIT 0 // normal screen with cockput
377 #define CM_REAR_VIEW 1 // looking back with bitmap
378 #define CM_STATUS_BAR 2 // small status bar, w/ reticle
379 #define CM_FULL_SCREEN 3 // full screen, no cockpit (w/ reticle)
380 #define CM_LETTERBOX 4 // half-height window (for cutscenes)
382 extern int Cockpit_mode; // what sort of cockpit or window is up?
383 extern int Game_window_w, // width and height of player's game window
386 extern int Rear_view; // if true, looking back.
389 void fly_init(object *obj);
391 // selects a given cockpit (or lack of one).
392 void select_cockpit(int mode);
394 // force cockpit redraw next time. call this if you've trashed the screen
395 void reset_cockpit(void); // called if you've trashed the screen
397 // functions to save, clear, and resture palette flash effects
398 void palette_save(void);
399 void reset_palette_add(void);
400 void palette_restore(void);
402 // put up the help message
405 // show a message in a nice little box
406 void show_boxed_message(char *msg);
408 // erases message drawn with show_boxed_message()
409 void clear_boxed_message();
411 // turns off rear view & rear view cockpit
412 void reset_rear_view(void);
414 extern int Game_turbo_mode;
416 // returns ptr to escort robot, or NULL
417 object *find_escort();
419 extern void apply_modified_palette(void);
421 //Flickering light system
423 short segnum, sidenum;
424 unsigned long mask; // determines flicker pattern
425 fix timer; // time until next change
426 fix delay; // time between changes
429 #define MAX_FLICKERING_LIGHTS 100
431 extern flickering_light Flickering_lights[MAX_FLICKERING_LIGHTS];
432 extern int Num_flickering_lights;
434 // returns ptr to flickering light structure, or NULL if can't find
435 flickering_light *find_flicker(int segnum, int sidenum);
437 // turn flickering off (because light has been turned off)
438 void disable_flicker(int segnum, int sidenum);
440 // turn flickering off (because light has been turned on)
441 void enable_flicker(int segnum, int sidenum);
443 // returns 1 if ok, 0 if error
444 int add_flicker(int segnum, int sidenum, fix delay, unsigned long mask);
446 int gr_toggle_fullscreen_game(void);
449 * reads a flickering_light structure from a CFILE
451 void flickering_light_read(flickering_light *fl, CFILE *fp);