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