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