forked from FlatRockSoft/Hovertank3D
-
Notifications
You must be signed in to change notification settings - Fork 1
/
HOVERDEF.H
369 lines (254 loc) · 8.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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
/* 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 "IDLIB.H"
#define OLDDRAW
//#define PROFILE
#ifndef PROFILE
#define ADAPTIVE
#endif
//#define TESTCASE
#define MAXTICS 8
#define NUMLEVELS 20
typedef struct { short width;
short height;
short planes;
short screenx;
short screeny;
short screenw;
short screenh;
unsigned short planesize;
} LevelDef;
LevelDef extern *levelheader;
/*
=============================================================================
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 error//0x80000000l
typedef int32_t 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];
//==========================================================================
int CheckKeys(void);
void CachePic (int picnum);
void LoadLevel(void);
void CacheDrawPic(int picnum);
int SoundPlaying (void);
/*
=============================================================================
HOVDRAW
=============================================================================
*/
void FollowWalls (void);
/*
=============================================================================
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;
int wx0,wz0,wx1,wz1;
} walltype;
#define MAXWALLS 100
#define DANGERHIGH 90
#define DANGERLOW 10
#define MIDWALL (MAXWALLS/2)
//==========================================================================
#if 0
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;
#else
extern tilept tile,focal,right;
extern unsigned screenloc[3];
extern int screenpage,tics;
extern int32_t lasttimecount;
extern fixed sintable[ANGLES+ANGLES/4],*costable;
extern fixed viewx,viewy,viewsin,viewcos; // the focal point
extern int zbuffer[VIEWXH+1];
extern walltype walls[MAXWALLS],*rightwall;
#endif
//==========================================================================
#if 0
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);
void StartView (void);
void FinishView (void);
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);
#else
fixed FixedByFrac (fixed a, fixed b);
void TransformPoint (fixed gx, fixed gy, int *screenx, unsigned *screenheight);
fixed TransformX (fixed gx, fixed gy);
void StartView (void);
void FinishView (void);
void BuildTables (void);
#endif
/*
=============================================================================
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;
int32_t speed;
unsigned size; // global radius for hit rect calculation
fixed xl,xh,yl,yh; // hit rectangle
int ticcount;
int shapenum,stage;
union {
int temp1;
void* temp1ptr;
};
int 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 FindFreeObj (void);
void CalcBoundsNew (void);
void CalcBounds (void);
void TransformObon (void);
void PlayerThink (void);
void PlayLoop (void);
void PlayGame (void);
void ClipMove (void);
void StartLevel (unsigned short *plane1);
/*
=============================================================================
HOVSCALE
=============================================================================
*/
extern unsigned scaleblockwidth,
scaleblockheight,
scaleblockdest;
int SC_ScaleShape (int x,int y,unsigned scale, memptr shape);
void SC_Setup (void);
void SC_MakeShape (memptr src,int width,int height, memptr *shapeseg);
/*
=============================================================================
HOVACTS
=============================================================================
*/
void DamagePlayer (void);
void HealPlayer (void);
void Thrust (void);
void SpawnShield (fixed gx, fixed gy);
// ===========================================================