]> icculus.org git repositories - btb/d2x.git/blob - main/game.h
allow -h for help
[btb/d2x.git] / main / game.h
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 #ifndef _GAME_H
15 #define _GAME_H
16
17 #include <setjmp.h>
18
19 #include "vecmat.h"
20 #include "object.h"
21
22 //#include "segment.h"
23
24 #ifdef MACINTOSH
25 extern ubyte Scanline_double;
26 #endif
27
28 #ifdef WINDOWS
29 typedef struct cockpit_span_line {
30         short num;
31         struct {
32                 short xmin, xmax;
33         } span[5];
34 } cockpit_span_line;
35
36 extern cockpit_span_line win_cockpit_mask[480];
37 #endif
38
39
40
41 //from mglobal.c
42 extern fix FrameTime;                                   //time in seconds since last frame
43 extern fix RealFrameTime;                                       //time in seconds since last frame
44 extern fix GameTime;                                            //time in game (sum of FrameTime)
45 extern int FrameCount;                                  //how many frames rendered
46 extern fix      Next_laser_fire_time;   //      Time at which player can next fire his selected laser.
47 extern fix      Last_laser_fired_time;
48 extern fix      Next_missile_fire_time; //      Time at which player can next fire his selected missile.
49 extern fix      Laser_delay_time;                       //      Delay between laser fires.
50 extern int Cheats_enabled;
51
52 extern int Missile_view_enabled;
53
54 extern object *Missile_viewer;
55
56 #define CV_NONE 0
57 #define CV_ESCORT       1
58 #define CV_REAR 2
59 #define CV_COOP 3
60 #define CV_MARKER       4
61
62 extern int Cockpit_3d_view[2];          //left & right
63 extern int Coop_view_player[2];         //left & right
64 extern int Marker_viewer_num[2];                //left & right
65
66 //constants for ft_preference
67 #define FP_RIGHT                0
68 #define FP_UP                   1
69 #define FP_FORWARD      2               //this is the default
70 #define FP_LEFT         3
71 #define FP_DOWN         4
72 #define FP_FIRST_TIME   5
73
74 extern int ft_preference;
75
76 //      The following bits define the game modes.
77 #define GM_EDITOR                                               1                       //      You came into the game from the editor
78 #define GM_SERIAL                                               2                       // You are in serial mode
79 #define GM_NETWORK                                      4                       // You are in network mode
80 #define GM_MULTI_ROBOTS                         8                       //      You are in a multiplayer mode with robots.
81 #define GM_MULTI_COOP                           16                      //      You are in a multiplayer mode and can't hurt other players.
82 #define GM_MODEM                                                32                      // You are in a modem (serial) game
83
84 #define GM_UNKNOWN                                      64                      //      You are not in any mode, kind of dangerous...
85 #define GM_GAME_OVER                                    128             //      Game has been finished
86
87 #define GM_TEAM                                         256             // Team mode for network play
88 #define GM_CAPTURE                                      512             // Capture the flag mode for D2
89 #define GM_HOARD                                                1024            // New hoard mode for D2 Christmas
90
91 #define GM_NORMAL                                               0                       //      You are in normal play mode, no multiplayer stuff
92 #define GM_MULTI                                                38                      //      You are in some type of multiplayer game
93
94 //      Examples:
95 //      Deathmatch mode on a network is GM_NETWORK
96 //      Deathmatch mode via modem with robots is GM_MODEM | GM_MULTI_ROBOTS
97 // Cooperative mode via serial link is GM_SERIAL | GM_MULTI_COOP
98
99 #define NDL     5               //      Number of difficulty levels.
100 #define NUM_DETAIL_LEVELS       6
101
102 extern int Game_mode;
103
104 extern int Game_paused;
105 extern int gauge_message_on;
106
107 #ifndef NDEBUG          //if debugging, these are variables
108
109 extern int Slew_on;                                                     //in slew or sim mode?
110 extern int Game_double_buffer;                  //double buffering?
111
112
113 #else                                   //if not debugging, these are constants
114
115 #define Slew_on                                 0               //no slewing in real game
116 #define Game_double_buffer      1               //always double buffer in real game
117
118
119 #endif
120
121 #ifndef MACINTOSH
122
123 #define Scanline_double         0               // PC doesn't do scanline doubling
124
125 #else
126
127 extern ubyte Scanline_double;                   // but the Macintosh does
128
129 #endif
130
131 //Suspend flags
132
133 #define SUSP_NONE                       0                       //Everything moving normally 
134 #define SUSP_ROBOTS             1                       //Robot AI doesn't move
135 #define SUSP_WEAPONS            2                       //Lasers, etc. don't move               
136
137 extern int Game_suspended;                      //if non-zero, nothing moves but player
138
139 // from game.c
140 void init_game(void);
141 void game(void);
142 void close_game(void);
143 void init_cockpit(void);
144 void calc_frame_time(void);
145
146 int do_flythrough(object *obj,int first_time);
147
148 extern jmp_buf LeaveGame;                                       // Do a long jump to this when game is over.
149 extern int      Difficulty_level;                               //      Difficulty level in 0..NDL-1, 0 = easiest, NDL-1 = hardest
150 extern int      Detail_level;                                   //      Detail level in 0..NUM_DETAIL_LEVELS-1, 0 = boringest, NUM_DETAIL_LEVELS = coolest
151 extern int      Global_laser_firing_count;
152 extern int      Global_missile_firing_count;
153 extern int      Render_depth;
154 extern fix      Auto_fire_fusion_cannon_time, Fusion_charge;
155
156 extern int PaletteRedAdd, PaletteGreenAdd, PaletteBlueAdd;
157
158 #define MAX_PALETTE_ADD 30
159
160 extern void PALETTE_FLASH_ADD(int dr, int dg, int db);
161
162 //sets the rgb values for palette flash
163 #define PALETTE_FLASH_SET(_r,_g,_b) PaletteRedAdd=(_r), PaletteGreenAdd=(_g), PaletteBlueAdd=(_b)
164
165 extern int draw_gauges_on;
166
167 extern void init_game_screen(void);
168
169 extern void game_flush_inputs();                // clear all inputs
170
171 extern int Playing_game;                // True if playing game
172 extern int Auto_flythrough;     //if set, start flythough automatically
173 extern int Mark_count;                  // number of debugging marks set
174 extern char faded_in;
175
176 extern void stop_time(void);
177 extern void start_time(void);
178 extern void reset_time(void);           //called when starting level
179
180 //      If automap_flag == 1, then call automap routine to write message.
181 extern void save_screen_shot(int automap_flag);
182
183 #ifndef WINDOWS
184 extern grs_canvas * get_current_game_screen();
185 #endif
186
187 //valid modes for cockpit
188 #define CM_FULL_COCKPIT         0       //normal screen with cockput
189 #define CM_REAR_VIEW                    1       //looking back with bitmap
190 #define CM_STATUS_BAR           2       //small status bar, w/ reticle
191 #define CM_FULL_SCREEN          3       //full screen, no cockpit (w/ reticle)
192 #define CM_LETTERBOX                    4       //half-height window (for cutscenes)
193
194 extern int Cockpit_mode;                //what sort of cockpit or window is up?
195 extern int Game_window_w,               //width and height of player's game window
196                           Game_window_h;
197
198 extern int Rear_view;                   //if true, looking back.
199
200 //initalize flying
201 void fly_init(object *obj);
202
203 //selects a given cockpit (or lack of one).
204 void select_cockpit(int mode);
205
206 //force cockpit redraw next time. call this if you've trashed the screen
207 void reset_cockpit(void);               //called if you've trashed the screen
208
209 //functions to save, clear, and resture palette flash effects
210 void palette_save(void);
211 void reset_palette_add(void);
212 void palette_restore(void);
213
214 //put up the help message
215 void do_show_help();
216
217 //show a message in a nice little box
218 void show_boxed_message(char *msg);
219
220 //erases message drawn with show_boxed_message()
221 void clear_boxed_message();
222
223 //turns off rear view & rear view cockpit
224 void reset_rear_view(void);
225
226 extern int Game_turbo_mode;
227
228 //returns ptr to escort robot, or NULL
229 object *find_escort();
230
231 extern void apply_modified_palette(void);
232
233 //Flickering light system
234 typedef struct  {
235         short segnum,sidenum;
236         ulong   mask;                                   // determines flicker pattern
237         fix     timer;                          // time until next change
238         fix     delay;                          // time between changes
239 } flickering_light;
240
241 #define MAX_FLICKERING_LIGHTS 100
242
243 extern flickering_light Flickering_lights[MAX_FLICKERING_LIGHTS];
244 extern int Num_flickering_lights;
245
246 //returns ptr to flickering light structure, or NULL if can't find
247 flickering_light *find_flicker(int segnum,int sidenum);
248
249 //turn flickering off (because light has been turned off)
250 void disable_flicker(int segnum,int sidenum);
251
252 //turn flickering off (because light has been turned on)
253 void enable_flicker(int segnum,int sidenum);
254
255 //returns 1 if ok, 0 if error
256 int add_flicker(int segnum,int sidenum,fix delay,ulong mask);
257
258 #endif
259