-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathHOVERDEF.H
271 lines (188 loc) · 6.46 KB
/
HOVERDEF.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/* Hovertank 3-D Source Code
* Copyright (C) 1993-2014 Flat Rock Software
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
=============================================================================
HOVERTANK MAIN
=============================================================================
*/
#include "JM_SB.H"
#include "IDLIB.H"
#include <MATH.H>
//#define PROFILE
#ifndef PROFILE
#define ADAPTIVE
#endif
//#define TESTCASE
#define MAXTICS 8
#define NUMLEVELS 20
/*
=============================================================================
REFRESH
=============================================================================
*/
#define VIEWX 0 // corner of view window
#define VIEWY 0
#define VIEWWIDTH (40*8) // size of view window
#define VIEWHEIGHT (18*8)
#define VIEWXH (VIEWX+VIEWWIDTH-1)
#define VIEWYH (VIEWY+VIEWHEIGHT-1)
#define CENTERX (VIEWX+VIEWWIDTH/2) // middle of view window
#define CENTERY (VIEWY+VIEWHEIGHT/2)
#define STATUSLINES (9*8) // dash board
#define GLOBAL1 (1l<<16)
#define TILEGLOBAL GLOBAL1
#define TILESHIFT 16
#define MINDIST (2*GLOBAL1/5)
#define FOCALLENGTH (TILEGLOBAL) // in global coordinates
#define ANGLES 360 // must be divisable by 4
#define MAPSIZE 64 // maps are 64*64 max
#define MAXOBJECTS 100 // max number of tanks, etc / map
//
// 1 sign bit
// 15 bits units
// 16 bits fractional
//
#define SIGNBIT 0x80000000l
typedef long fixed;
#define NORTH 0
#define EAST 1
#define SOUTH 2
#define WEST 3
/*
=============================================================================
DASH INSTRUMENTS
=============================================================================
*/
#define TIMESECX 3
#define TIMESECY 54
#define TIMEMINX 1
#define TIMEMINY 54
#define RADARX 284 // center of radar
#define RADARY 36
#define RADARSIZE 26 // each way
#define RADARRANGE (TILEGLOBAL*18) // each way
#define RADARSCALE (RADARRANGE/RADARSIZE)
/*
=============================================================================
HOVMAIN
=============================================================================
*/
extern int tedlevel;
extern memptr scalesegs[NUMPICS];
/*
=============================================================================
HOVDRAW
=============================================================================
*/
typedef struct {int x,y;} tilept;
typedef struct {fixed x,y;} globpt;
typedef struct
{
int x1,x2,leftclip,rightclip;// first pixel of wall (may not be visable)
unsigned height1,height2,color;
} walltype;
#define MAXWALLS 100
#define DANGERHIGH 90
#define DANGERLOW 10
#define MIDWALL (MAXWALLS/2)
//==========================================================================
extern tilept tile,lasttile,focal,left,mid,right;
extern globpt edge,view;
extern unsigned screenloc[3];
extern int screenpage,tics;
extern long lasttimecount;
#define SHIFTFRAMES 256
extern int yshift[SHIFTFRAMES]; // screen sliding variables
extern int firstangle,lastangle;
extern fixed prestep;
extern int traceclip,tracetop;
extern fixed sintable[ANGLES+ANGLES/4],*costable;
extern fixed viewx,viewy,viewsin,viewcos; // the focal point
extern int viewangle;
extern fixed scale,scaleglobal;
extern unsigned slideofs;
extern int zbuffer[VIEWXH+1];
extern walltype walls[MAXWALLS],*leftwall,*rightwall;
//==========================================================================
void DrawLine (int xl, int xh, int y,int color);
void DrawWall (walltype *wallptr);
void TraceRay (unsigned angle);
fixed FixedByFrac (fixed a, fixed b);
fixed FixedAdd (fixed a, fixed b);
void TransformPoint (fixed gx, fixed gy, int *screenx, unsigned *screenheight);
fixed TransformX (fixed gx, fixed gy);
int FollowTrace (fixed tracex, fixed tracey, long deltax, long deltay, int max);
void ForwardTrace (void);
int FinishWall (void);
int TurnClockwise (void);
int TurnCounterClockwise (void);
void FollowWall (void);
void NewScene (void);
void BuildTables (void);
/*
=============================================================================
HOVLOOP
=============================================================================
*/
//
// temp stuff
//
extern int statx,staty;
extern unsigned tilemap[MAPSIZE][MAPSIZE];
typedef enum
{nothing,playerobj,refugeeobj,droneobj,tankobj,mutantobj,warpobj,
pshotobj,pbigshotobj,mshotobj,inertobj,shieldobj} classtype;
typedef struct
{
int active;
classtype class;
fixed x,y;
fixed viewx,viewy; // x,y in view coordinate space (NOT pixels!)
int angle;
int hitpoints;
int radarx,radary,radarcolor;
long speed;
unsigned size; // global radius for hit rect calculation
fixed xl,xh,yl,yh; // hit rectangle
int ticcount;
int shapenum,stage;
int temp1,temp2;
dirtype dir;
void (*think)();
} objtype;
typedef struct {int min,sec;} timetype;
extern timetype timestruct;
extern ControlStruct c;
extern int guncount,bordertime;
extern fixed warpx,warpy; // where to spawn warp gate
extern fixed xmove,ymove;
extern int godmode,singlestep,leveldone,resetgame;
extern int numrefugees,totalrefugees,savedcount,killedcount;
extern objtype objlist[MAXOBJECTS],obon,*new,*obj,*lastobj,*check;
void PlayerThink (void);
void PlayLoop (void);
void PlayGame (void);
/*
=============================================================================
HOVSCALE
=============================================================================
*/
extern unsigned scaleblockwidth,
scaleblockheight,
scaleblockdest;
int SC_ScaleShape (int x,int y,unsigned scale, memptr shape);