This commit was generated by cvs2svn to compensate for changes in r2,
[btb/d2x.git] / main / mglobal.c
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 #ifdef RCS
15 static char rcsid[] = "$Id: mglobal.c,v 1.1.1.1 2001-01-19 03:29:59 bradleyb Exp $";
16 #endif
17
18 #include <conf.h>
19 #include "fix.h"
20 #include "vecmat.h"
21 #include "inferno.h"
22 #include "segment.h"
23 #include "object.h"
24 #include "bm.h"
25 #include "3d.h"
26 #include "game.h"
27
28
29 // Global array of vertices, common to one mine.
30 vms_vector Vertices[MAX_VERTICES];
31 g3s_point Segment_points[MAX_VERTICES];
32
33 fix FrameTime = 0x1000; // Time since last frame, in seconds
34 fix GameTime = 0;                       //      Time in game, in seconds
35
36 //How many frames we've rendered
37 int FrameCount = 0;
38
39 //      This is the global mine which create_new_mine returns.
40 segment Segments[MAX_SEGMENTS];
41 segment2        Segment2s[MAX_SEGMENTS];
42 //lsegment      Lsegments[MAX_SEGMENTS];
43
44 // Number of vertices in current mine (ie, Vertices, pointed to by Vp)
45 int             Num_vertices = 0;
46 int             Num_segments = 0;
47
48 int             Highest_vertex_index=0;
49 int             Highest_segment_index=0;
50
51 //      Translate table to get opposite side of a face on a segment.
52 char    Side_opposite[MAX_SIDES_PER_SEGMENT] = {WRIGHT, WBOTTOM, WLEFT, WTOP, WFRONT, WBACK};
53
54 #define TOLOWER(c) ((((c)>='A') && ((c)<='Z'))?((c)+('a'-'A')):(c))
55
56 #ifdef PASSWORD
57 #define encrypt(a,b,c,d)        a ^ TOLOWER((((int) PASSWORD)>>24)&255), \
58                                                                         b ^ TOLOWER((((int) PASSWORD)>>16)&255), \
59                                                                         c ^ TOLOWER((((int) PASSWORD)>>8)&255), \
60                                                                         d ^ TOLOWER((((int) PASSWORD))&255)
61 #else
62 #define encrypt(a,b,c,d) a,b,c,d
63 #endif
64
65 byte Side_to_verts[MAX_SIDES_PER_SEGMENT][4] = {
66                         { encrypt(7,6,2,3) },                   // left
67                         { encrypt(0,4,7,3) },                   // top
68                         { encrypt(0,1,5,4) },                   // right
69                         { encrypt(2,6,5,1) },                   // bottom
70                         { encrypt(4,5,6,7) },                   // back
71                         { encrypt(3,2,1,0) },                   // front
72 };              
73
74 //      Note, this MUST be the same as Side_to_verts, it is an int for speed reasons.
75 int Side_to_verts_int[MAX_SIDES_PER_SEGMENT][4] = {
76                         { encrypt(7,6,2,3) },                   // left
77                         { encrypt(0,4,7,3) },                   // top
78                         { encrypt(0,1,5,4) },                   // right
79                         { encrypt(2,6,5,1) },                   // bottom
80                         { encrypt(4,5,6,7) },                   // back
81                         { encrypt(3,2,1,0) },                   // front
82 };              
83
84 // Texture map stuff
85
86 int NumTextures = 0;
87 bitmap_index Textures[MAX_TEXTURES];            // All textures.
88
89 fix     Next_laser_fire_time;                   //      Time at which player can next fire his selected laser.
90 fix     Next_missile_fire_time;                 //      Time at which player can next fire his selected missile.
91 //--unused-- fix        Laser_delay_time = F1_0/6;              //      Delay between laser fires.
92
93 #if defined(MACINTOSH) && defined(APPLE_DEMO)
94 #define DEFAULT_DIFFICULTY              0               // trainee for apple demo
95 #else
96 #define DEFAULT_DIFFICULTY              1
97 #endif
98
99 int     Difficulty_level=DEFAULT_DIFFICULTY;    //      Difficulty level in 0..NDL-1, 0 = easiest, NDL-1 = hardest
100 int     Detail_level=NUM_DETAIL_LEVELS-2;               //      Detail level in 0..NUM_DETAIL_LEVELS-1, 0 = boringest, NUM_DETAIL_LEVELS = coolest
101