]> icculus.org git repositories - btb/d2x.git/blob - main/game.h
fixes d1 still textures which are animated in d2, refactorizes d1 texture reading
[btb/d2x.git] / main / game.h
1 /* $Id: game.h,v 1.5 2003-10-10 09:36:35 btb Exp $ */
2 /*
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.
13 */
14
15 /*
16  *
17  * Constants & prototypes which pertain to the game only
18  *
19  * Old Log:
20  * Revision 1.3  1995/09/14  13:44:34  allender
21  * fixed function prototypes to have void return value to satify
22  * moto compiler
23  *
24  * Revision 1.2  1995/08/17  09:25:05  allender
25  * externed Scanline_double variable
26  *
27  * Revision 1.1  1995/05/16  15:56:46  allender
28  * Initial revision
29  *
30  * Revision 2.1  1995/03/06  15:23:22  john
31  * New screen techniques.
32  *
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.
36  *
37  * Revision 1.79  1995/02/13  10:37:17  john
38  * Saved Buggin' cheat mode to save file.
39  *
40  * Revision 1.78  1995/02/01  16:34:12  john
41  * Linted.
42  *
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.
45  *
46  * Revision 1.76  1995/01/26  22:11:36  mike
47  * Purple chromo-blaster (ie, fusion cannon) spruce up (chromification)
48  *
49  * Revision 1.75  1995/01/26  16:45:31  mike
50  * Add autofire fusion cannon stuff.
51  *
52  * Revision 1.74  1994/12/11  23:18:06  john
53  * Added -nomusic.
54  * Added RealFrameTime.
55  * Put in a pause when sound initialization error.
56  * Made controlcen countdown and framerate use RealFrameTime.
57  *
58  * Revision 1.73  1994/12/09  00:41:24  mike
59  * fix hang in automap print screen
60  *
61  * Revision 1.72  1994/12/04  13:47:00  mike
62  * enhance custom detail level support.
63  *
64  * Revision 1.71  1994/12/02  15:05:44  matt
65  * Added new "official" cheats
66  *
67  * Revision 1.70  1994/11/28  18:14:09  rob
68  * Added game_mode flag for team games.
69  *
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
72  *
73  * Revision 1.68  1994/11/04  16:26:10  john
74  * Fixed bug with letterbox mode game after you finish a game.
75  *
76  * Revision 1.67  1994/11/02  11:59:48  john
77  * Moved menu out of game into inferno main loop.
78  *
79  * Revision 1.66  1994/10/26  23:02:19  matt
80  * Made palette flash saturate negative values
81  *
82  * Revision 1.65  1994/10/26  15:21:05  mike
83  * Detail level stuff.  Make Render_depth public.
84  *
85  * Revision 1.64  1994/10/19  00:13:01  matt
86  * Added prototypes
87  *
88  * Revision 1.63  1994/10/09  14:54:39  matt
89  * Made player cockpit state & window size save/restore with saved games & automap
90  *
91  * Revision 1.62  1994/10/08  19:56:32  matt
92  * Added prototype
93  *
94  * Revision 1.61  1994/10/07  22:19:32  mike
95  * Increase number of difficulty levels from 4 to 5.
96  *
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
99  *
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
102  *
103  * Revision 1.58  1994/10/03  23:44:13  matt
104  * Save & restore palette effect around menus & pause message
105  *
106  * Revision 1.57  1994/09/29  17:42:12  matt
107  * Cleaned up game_mode a little
108  *
109  * Revision 1.56  1994/09/28  23:12:01  matt
110  * Macroized palette flash system
111  *
112  * Revision 1.55  1994/09/24  16:56:13  rob
113  * Added new fields for the Game_mode bitvector for modem play.
114  *
115  * Revision 1.54  1994/09/24  14:16:20  mike
116  * Added new game mode constants.
117  *
118  * Revision 1.53  1994/09/22  19:00:57  mike
119  * Move NDL from robot.h to here.
120  *
121  * Revision 1.52  1994/09/22  10:46:51  mike
122  * Add difficulty levels.
123  *
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.
127  *
128  * Revision 1.50  1994/09/15  21:23:10  matt
129  * Changed system to keep track of whether & what cockpit is up
130  *
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.
134  *
135  * Revision 1.48  1994/09/13  16:40:10  mike
136  * Prototype Global_missile_firing_count.
137  *
138  * Revision 1.47  1994/09/13  11:19:05  mike
139  * Add Next_missile_fire_time.
140  *
141  * Revision 1.46  1994/09/12  09:52:50  john
142  * Made global flush function that flushes keyboard,mouse, and joystick.
143  *
144  * Revision 1.45  1994/09/03  15:24:14  mike
145  * Make global Global_laser_firing_count.
146  *
147  * Revision 1.44  1994/08/31  19:26:57  mike
148  * Prototypes for Next_laser_fire_time, Laser_delay_time.
149  *
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
153  * pieces when dead.
154  *
155  * Revision 1.42  1994/08/11  18:03:53  matt
156  * Added prototype
157  *
158  * Revision 1.41  1994/06/29  20:41:38  matt
159  * Added new pause mode; cleaned up countdown & game startup code
160  *
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
164  *
165  * Revision 1.39  1994/06/20  15:01:08  yuan
166  * Added death when mine blows up...
167  * Continues onto next level.
168  *
169  * Revision 1.38  1994/06/17  18:07:20  matt
170  * Moved some vars out of ifdef
171  *
172  * Revision 1.37  1994/06/15  11:09:22  yuan
173  * Moved gauge_message to mono screen for now.
174  *
175  * Revision 1.36  1994/05/30  20:22:11  yuan
176  * New triggers.
177  *
178  * Revision 1.35  1994/05/27  10:32:48  yuan
179  * New dialog boxes (Walls and Triggers) added.
180  *
181  *
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()
185  *
186  * Revision 1.33  1994/05/19  21:45:21  matt
187  * Removed unused prototypes
188  *
189  * Revision 1.32  1994/05/19  18:53:17  yuan
190  * Changing player structure...
191  *
192  * Revision 1.31  1994/05/16  16:38:35  yuan
193  * Fixed palette add so it doesn't show up in the menu.
194  *
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()
198  *
199  * Revision 1.29  1994/05/14  17:14:57  matt
200  * Got rid of externs in source (non-header) files
201  *
202  */
203
204 #ifndef _GAME_H
205 #define _GAME_H
206
207 #include <setjmp.h>
208
209 #include "vecmat.h"
210 #include "object.h"
211
212 //#include "segment.h"
213
214 #ifdef MACINTOSH
215 extern ubyte Scanline_double;
216 #endif
217
218 #ifdef WINDOWS
219 typedef struct cockpit_span_line {
220         short num;
221         struct {
222                 short xmin, xmax;
223         } span[5];
224 } cockpit_span_line;
225
226 extern cockpit_span_line win_cockpit_mask[480];
227 #endif
228
229
230 // from mglobal.c
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;
240
241 extern int Missile_view_enabled;
242
243 extern object *Missile_viewer;
244
245 #define CV_NONE     0
246 #define CV_ESCORT   1
247 #define CV_REAR     2
248 #define CV_COOP     3
249 #define CV_MARKER   4
250
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
254
255 // constants for ft_preference
256 #define FP_RIGHT        0
257 #define FP_UP           1
258 #define FP_FORWARD      2       // this is the default
259 #define FP_LEFT         3
260 #define FP_DOWN         4
261 #define FP_FIRST_TIME   5
262
263 extern int ft_preference;
264
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
272
273 #define GM_UNKNOWN      64      // You are not in any mode, kind of dangerous...
274 #define GM_GAME_OVER    128     // Game has been finished
275
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
279
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
282
283 // Examples:
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
287
288 #define NDL 5       // Number of difficulty levels.
289 #define NUM_DETAIL_LEVELS   6
290
291 extern int Game_mode;
292
293 extern int Game_paused;
294 extern int gauge_message_on;
295
296 #ifndef NDEBUG      // if debugging, these are variables
297
298 extern int Slew_on;                 // in slew or sim mode?
299 extern int Game_double_buffer;      // double buffering?
300
301
302 #else               // if not debugging, these are constants
303
304 #define Slew_on             0       // no slewing in real game
305 #define Game_double_buffer  1       // always double buffer in real game
306
307 #endif
308
309 #ifndef MACINTOSH
310
311 #define Scanline_double     0       // PC doesn't do scanline doubling
312
313 #else
314
315 extern ubyte Scanline_double;       // but the Macintosh does
316
317 #endif
318
319 // Suspend flags
320
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
324
325 extern int Game_suspended;          // if non-zero, nothing moves but player
326
327 // from game.c
328 void init_game(void);
329 void game(void);
330 void close_game(void);
331 void init_cockpit(void);
332 void calc_frame_time(void);
333
334 int do_flythrough(object *obj,int first_time);
335
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;
343
344 extern int PaletteRedAdd, PaletteGreenAdd, PaletteBlueAdd;
345
346 #define MAX_PALETTE_ADD 30
347
348 extern void PALETTE_FLASH_ADD(int dr, int dg, int db);
349
350 //sets the rgb values for palette flash
351 #define PALETTE_FLASH_SET(_r,_g,_b) PaletteRedAdd=(_r), PaletteGreenAdd=(_g), PaletteBlueAdd=(_b)
352
353 extern int draw_gauges_on;
354
355 extern void init_game_screen(void);
356
357 extern void game_flush_inputs();    // clear all inputs
358
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;
363
364 extern void stop_time(void);
365 extern void start_time(void);
366 extern void reset_time(void);       // called when starting level
367
368 // If automap_flag == 1, then call automap routine to write message.
369 extern void save_screen_shot(int automap_flag);
370
371 #ifndef WINDOWS
372 extern grs_canvas * get_current_game_screen();
373 #endif
374
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)
381
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
384            Game_window_h;
385
386 extern int Rear_view;           // if true, looking back.
387
388 // initalize flying
389 void fly_init(object *obj);
390
391 // selects a given cockpit (or lack of one).
392 void select_cockpit(int mode);
393
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
396
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);
401
402 // put up the help message
403 void do_show_help();
404
405 // show a message in a nice little box
406 void show_boxed_message(char *msg);
407
408 // erases message drawn with show_boxed_message()
409 void clear_boxed_message();
410
411 // turns off rear view & rear view cockpit
412 void reset_rear_view(void);
413
414 extern int Game_turbo_mode;
415
416 // returns ptr to escort robot, or NULL
417 object *find_escort();
418
419 extern void apply_modified_palette(void);
420
421 //Flickering light system
422 typedef struct  {
423         short segnum, sidenum;
424         ulong mask;             // determines flicker pattern
425         fix timer;              // time until next change
426         fix delay;              // time between changes
427 } flickering_light;
428
429 #define MAX_FLICKERING_LIGHTS 100
430
431 extern flickering_light Flickering_lights[MAX_FLICKERING_LIGHTS];
432 extern int Num_flickering_lights;
433
434 // returns ptr to flickering light structure, or NULL if can't find
435 flickering_light *find_flicker(int segnum, int sidenum);
436
437 // turn flickering off (because light has been turned off)
438 void disable_flicker(int segnum, int sidenum);
439
440 // turn flickering off (because light has been turned on)
441 void enable_flicker(int segnum, int sidenum);
442
443 // returns 1 if ok, 0 if error
444 int add_flicker(int segnum, int sidenum, fix delay, ulong mask);
445
446 int gr_toggle_fullscreen_game(void);
447
448 /*
449  * reads a flickering_light structure from a CFILE
450  */
451 void flickering_light_read(flickering_light *fl, CFILE *fp);
452
453 extern int maxfps;
454
455 #endif /* _GAME_H */