Subversion Repositories eduke32

Rev

Rev 2470 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
573 terminx 1
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
2
// Ken Silverman's official web site: "http://www.advsys.net/ken"
3
// See the included license file "BUILDLIC.TXT" for license info.
4
//
5
// This file has been modified from Ken Silverman's original release
2456 hendricks2 6
// by Jonathon Fowler (jf@jonof.id.au)
540 terminx 7
 
573 terminx 8
 
9
#ifndef __build_h__
10
#define __build_h__
11
 
618 terminx 12
#include "compat.h"
1230 terminx 13
#include "pragmas.h"
618 terminx 14
 
573 terminx 15
#ifdef __cplusplus
16
extern "C" {
17
#endif
18
 
19
#define MAXSECTORSV8 4096
20
#define MAXWALLSV8 16384
21
#define MAXSPRITESV8 16384
22
 
23
#define MAXSECTORSV7 1024
24
#define MAXWALLSV7 8192
25
#define MAXSPRITESV7 4096
26
 
27
#define MAXSECTORS MAXSECTORSV8
28
#define MAXWALLS MAXWALLSV8
687 plagman 29
#define MAXWALLSB ((MAXWALLS>>2)+(MAXWALLS>>3))
573 terminx 30
#define MAXSPRITES MAXSPRITESV8
31
 
1801 helixhorne 32
// additional space beyond wall, in walltypes:
1804 helixhorne 33
#define M32_FIXME_WALLS 512
34
#define M32_FIXME_SECTORS 2
1801 helixhorne 35
 
2267 helixhorne 36
#define MAXTILES 30720
573 terminx 37
#define MAXVOXELS 4096
38
#define MAXSTATUS 1024
39
#define MAXPLAYERS 16
1857 terminx 40
#define MAXXDIM 7680
41
#define MAXYDIM 3200
1782 plagman 42
#define MAXBASEPALS 8
573 terminx 43
#define MAXPALOOKUPS 256
1882 helixhorne 44
#define MAXPSKYMULTIS 8
573 terminx 45
#define MAXPSKYTILES 256
46
#define MAXSPRITESONSCREEN 4096
47
#define MAXUNIQHUDID 256 //Extra slots so HUD models can store animation state without messing game sprites
48
 
1552 terminx 49
#define RESERVEDPALS 4 // don't forget to increment this when adding reserved pals
573 terminx 50
#define DETAILPAL   (MAXPALOOKUPS - 1)
51
#define GLOWPAL     (MAXPALOOKUPS - 2)
1350 terminx 52
#define SPECULARPAL (MAXPALOOKUPS - 3)
53
#define NORMALPAL   (MAXPALOOKUPS - 4)
573 terminx 54
 
888 terminx 55
#define TSPR_TEMP 99
56
#define TSPR_MIRROR 100
886 terminx 57
 
1355 terminx 58
#define PR_LIGHT_PRIO_MAX       0
59
#define PR_LIGHT_PRIO_MAX_GAME  1
60
#define PR_LIGHT_PRIO_HIGH      2
61
#define PR_LIGHT_PRIO_HIGH_GAME 3
62
#define PR_LIGHT_PRIO_LOW       4
63
#define PR_LIGHT_PRIO_LOW_GAME  5
64
 
1887 helixhorne 65
////////// True Room over Room (YAX == rot -17 of "PRO") //////////
66
#define YAX_ENABLE
67
//#define YAX_DEBUG
68
//#define ENGINE_SCREENSHOT_DEBUG
69
 
1816 helixhorne 70
////////// yax defs //////////
1877 helixhorne 71
#define SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (&sector[Sect].floor##Fld) : (&sector[Sect].ceiling##Fld)))
72
 
73
#define YAX_MAXBUNCHES 256
1816 helixhorne 74
#define YAX_BIT 1024
1865 helixhorne 75
// "has next wall when constrained"-bit (1<<10: ceiling, 1<<11: floor)
76
#define YAX_NEXTWALLBIT(Cf) (1<<(10+Cf))
77
#define YAX_NEXTWALLBITS (YAX_NEXTWALLBIT(0)|YAX_NEXTWALLBIT(1))
1854 helixhorne 78
#define YAX_CEILING 0  // don't change!
79
#define YAX_FLOOR 1  // don't change!
1816 helixhorne 80
 
1877 helixhorne 81
void yax_updategrays(int32_t posze);
1816 helixhorne 82
 
1877 helixhorne 83
#ifdef YAX_ENABLE
1865 helixhorne 84
// more user tag hijacking: lotag/extra :/
2349 helixhorne 85
# define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(&Ptr[Wall].lotag + 2*Cf))
86
# define YAX_NEXTWALL(Wall, Cf) YAX_PTRNEXTWALL(wall, Wall, Cf)
1865 helixhorne 87
 
1877 helixhorne 88
# define YAX_ITER_WALLS(Wal, Itervar, Cfvar) Cfvar=0, Itervar=(Wal); Itervar!=-1; \
1866 helixhorne 89
    Itervar=yax_getnextwall(Itervar, Cfvar), (void)(Itervar==-1 && Cfvar==0 && (Cfvar=1) && (Itervar=yax_getnextwall((Wal), Cfvar)))
90
 
1886 helixhorne 91
# define SECTORS_OF_BUNCH(Bunchnum, Cf, Itervar) Itervar = headsectbunch[Cf][Bunchnum]; \
92
    Itervar != -1; Itervar = nextsectbunch[Cf][Itervar]
93
 
2024 helixhorne 94
extern int32_t r_tror_nomaskpass;
95
 
1882 helixhorne 96
extern int16_t yax_bunchnum[MAXSECTORS][2];
97
extern int16_t yax_nextwall[MAXWALLS][2];
98
 
1816 helixhorne 99
int16_t yax_getbunch(int16_t i, int16_t cf);
1843 helixhorne 100
void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb);
1816 helixhorne 101
void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum);
1843 helixhorne 102
void yax_setbunches(int16_t i, int16_t cb, int16_t fb);
1865 helixhorne 103
int16_t yax_getnextwall(int16_t wal, int16_t cf);
104
void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall);
2018 helixhorne 105
int16_t yax_vnextsec(int16_t line, int16_t cf);
1882 helixhorne 106
void yax_update(int32_t resetstat);
1869 helixhorne 107
int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf, int16_t *ret_bunchnum);
1877 helixhorne 108
 
109
static inline int32_t yax_waltosecmask(int32_t walclipmask)
110
{
111
    // blocking: walstat&1 --> secstat&512
112
    // hitscan: walstat&64 --> secstat&2048
113
    return ((walclipmask&1)<<9) | ((walclipmask&64)<<5);
114
}
115
void yax_preparedrawrooms(void);
1869 helixhorne 116
void yax_drawrooms(void (*ExtAnalyzeSprites)(void), int32_t horiz, int16_t sectnum);
117
# define YAX_SKIPSECTOR(i) if (graysectbitmap[(i)>>3]&(1<<((i)&7))) continue
118
# define YAX_SKIPWALL(i) if (graywallbitmap[(i)>>3]&(1<<((i)&7))) continue
119
#else
1877 helixhorne 120
# define yax_preparedrawrooms()
121
# define yax_drawrooms(ExtAnalyzeSprites, horiz, sectnum)
1869 helixhorne 122
# define YAX_SKIPSECTOR(i) (i)=(i)
123
# define YAX_SKIPWALL(i) (i)=(i)
124
#endif
1816 helixhorne 125
 
573 terminx 126
#define CLIPMASK0 (((1L)<<16)+1L)
127
#define CLIPMASK1 (((256L)<<16)+64L)
128
 
1797 helixhorne 129
// max x/y val (= max editorgridextent in Mapster32)
130
#define BXY_MAX 524288
131
 
573 terminx 132
    //Make all variables in BUILD.H defined in the ENGINE,
133
    //and externed in GAME
134
#ifdef ENGINE
135
#  define EXTERN
136
#else
137
#  define EXTERN extern
138
#endif
139
 
1454 terminx 140
#pragma pack(push,1)
573 terminx 141
 
142
//ceilingstat/floorstat:
143
//   bit 0: 1 = parallaxing, 0 = not                                 "P"
144
//   bit 1: 1 = groudraw, 0 = not
145
//   bit 2: 1 = swap x&y, 0 = not                                    "F"
146
//   bit 3: 1 = double smooshiness                                   "E"
147
//   bit 4: 1 = x-flip                                               "F"
148
//   bit 5: 1 = y-flip                                               "F"
149
//   bit 6: 1 = Align texture to first wall of sector                "R"
1874 helixhorne 150
//   bits 8-7:                                                       "T"
573 terminx 151
//          00 = normal floors
152
//          01 = masked floors
153
//          10 = transluscent masked floors
154
//          11 = reverse transluscent masked floors
1874 helixhorne 155
//   bit 9: 1 = blocking ceiling/floor
156
//   bit 10: 1 = YAX'ed ceiling/floor
1877 helixhorne 157
//   bit 11: 1 = hitscan-sensitive ceiling/floor
158
//   bits 12-15: reserved
573 terminx 159
 
160
    //40 bytes
1454 terminx 161
typedef struct
573 terminx 162
{
1205 terminx 163
    int16_t wallptr, wallnum;
164
    int32_t ceilingz, floorz;
165
    int16_t ceilingstat, floorstat;
166
    int16_t ceilingpicnum, ceilingheinum;
167
    int8_t ceilingshade;
1206 terminx 168
    uint8_t ceilingpal, ceilingxpanning, ceilingypanning;
1205 terminx 169
    int16_t floorpicnum, floorheinum;
170
    int8_t floorshade;
1206 terminx 171
    uint8_t floorpal, floorxpanning, floorypanning;
172
    uint8_t visibility, filler;
1205 terminx 173
    int16_t lotag, hitag, extra;
573 terminx 174
} sectortype;
175
 
176
//cstat:
177
//   bit 0: 1 = Blocking wall (use with clipmove, getzrange)         "B"
178
//   bit 1: 1 = bottoms of invisible walls swapped, 0 = not          "2"
179
//   bit 2: 1 = align picture on bottom (for doors), 0 = top         "O"
180
//   bit 3: 1 = x-flipped, 0 = normal                                "F"
181
//   bit 4: 1 = masking wall, 0 = not                                "M"
182
//   bit 5: 1 = 1-way wall, 0 = not                                  "1"
183
//   bit 6: 1 = Blocking wall (use with hitscan / cliptype 1)        "H"
184
//   bit 7: 1 = Transluscence, 0 = not                               "T"
185
//   bit 8: 1 = y-flipped, 0 = normal                                "F"
186
//   bit 9: 1 = Transluscence reversing, 0 = normal                  "T"
1865 helixhorne 187
//   bits 10 and 11: reserved (in use by YAX)
2125 helixhorne 188
//   bits 12-15: reserved  (14: temp use by editor)
573 terminx 189
 
190
    //32 bytes
1454 terminx 191
typedef struct
573 terminx 192
{
1205 terminx 193
    int32_t x, y;
194
    int16_t point2, nextwall, nextsector, cstat;
195
    int16_t picnum, overpicnum;
196
    int8_t shade;
1206 terminx 197
    uint8_t pal, xrepeat, yrepeat, xpanning, ypanning;
1205 terminx 198
    int16_t lotag, hitag, extra;
573 terminx 199
} walltype;
200
 
201
//cstat:
202
//   bit 0: 1 = Blocking sprite (use with clipmove, getzrange)       "B"
203
//   bit 1: 1 = transluscence, 0 = normal                            "T"
204
//   bit 2: 1 = x-flipped, 0 = normal                                "F"
205
//   bit 3: 1 = y-flipped, 0 = normal                                "F"
206
//   bits 5-4: 00 = FACE sprite (default)                            "R"
207
//             01 = WALL sprite (like masked walls)
208
//             10 = FLOOR sprite (parallel to ceilings&floors)
209
//   bit 6: 1 = 1-sided sprite, 0 = normal                           "1"
210
//   bit 7: 1 = Real centered centering, 0 = foot center             "C"
211
//   bit 8: 1 = Blocking sprite (use with hitscan / cliptype 1)      "H"
212
//   bit 9: 1 = Transluscence reversing, 0 = normal                  "T"
1793 helixhorne 213
//   bit 10: reserved (in use by a renderer hack)
214
//   bit 11: 1 = determine shade based only on its own shade member (see CON's spritenoshade command)
215
//   bit 12: reserved
1433 plagman 216
//   bit 13: 1 = does not cast shadow
1432 plagman 217
//   bit 14: 1 = invisible but casts shadow
573 terminx 218
//   bit 15: 1 = Invisible sprite, 0 = not invisible
219
 
220
    //44 bytes
1454 terminx 221
typedef struct
573 terminx 222
{
1205 terminx 223
    int32_t x, y, z;
224
    int16_t cstat, picnum;
225
    int8_t shade;
1206 terminx 226
    uint8_t pal, clipdist, filler;
227
    uint8_t xrepeat, yrepeat;
1205 terminx 228
    int8_t xoffset, yoffset;
229
    int16_t sectnum, statnum;
230
    int16_t ang, owner, xvel, yvel, zvel;
231
    int16_t lotag, hitag, extra;
573 terminx 232
} spritetype;
233
 
1454 terminx 234
typedef struct {
1205 terminx 235
    uint32_t mdanimtims;
236
    int16_t mdanimcur;
1625 terminx 237
    int16_t angoff, pitch, roll;
1205 terminx 238
    int32_t xoff, yoff, zoff;
1206 terminx 239
    uint8_t flags;
240
    uint8_t xpanning, ypanning;
1341 terminx 241
    uint8_t filler;
242
    float alpha;
853 terminx 243
    spritetype *tspr;
2207 helixhorne 244
#if !defined UINTPTR_MAX
245
# error Need UINTPTR_MAX define to select between 32- and 64-bit structs
246
#endif
247
#if UINTPTR_MAX == 0xffffffff
2148 helixhorne 248
    /* On a 32-bit build, pad the struct so it has the same size everywhere.
249
     * REMINDER: Will break savegames. */
2207 helixhorne 250
    const intptr_t dummy_;
2148 helixhorne 251
#endif
1206 terminx 252
} spriteext_t;
573 terminx 253
 
1454 terminx 254
typedef struct {
747 terminx 255
    float smoothduration;
1205 terminx 256
    int16_t mdcurframe, mdoldframe;
257
    int16_t mdsmooth;
1206 terminx 258
    uint8_t filler[2];
259
} spritesmooth_t;
573 terminx 260
 
261
#define SPREXT_NOTMD 1
262
#define SPREXT_NOMDANIM 2
587 terminx 263
#define SPREXT_AWAY1 4
264
#define SPREXT_AWAY2 8
1010 terminx 265
#define SPREXT_TSPRACCESS 16
1968 helixhorne 266
#define SPREXT_TEMPINVISIBLE 32
853 terminx 267
 
2270 helixhorne 268
EXTERN int32_t guniqhudid;
269
EXTERN int32_t spritesortcnt;
270
 
271
#if !defined DEBUG_MAIN_ARRAYS
1206 terminx 272
EXTERN spriteext_t *spriteext;
273
EXTERN spritesmooth_t *spritesmooth;
573 terminx 274
 
574 terminx 275
EXTERN sectortype *sector;
276
EXTERN walltype *wall;
2270 helixhorne 277
EXTERN spritetype *sprite;
278
EXTERN spritetype *tsprite;
279
#else
280
EXTERN spriteext_t spriteext[MAXSPRITES+MAXUNIQHUDID];
281
EXTERN spritesmooth_t spritesmooth[MAXSPRITES+MAXUNIQHUDID];
282
 
283
EXTERN sectortype sector[MAXSECTORS + M32_FIXME_SECTORS];
284
EXTERN walltype wall[MAXWALLS + M32_FIXME_WALLS];
285
EXTERN spritetype sprite[MAXSPRITES];
286
EXTERN spritetype tsprite[MAXSPRITESONSCREEN];
287
#endif
288
 
1205 terminx 289
EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt;
290
EXTERN int16_t thewall[MAXWALLSB];
1699 plagman 291
EXTERN spritetype *tspriteptr[MAXSPRITESONSCREEN + 1];
573 terminx 292
 
1205 terminx 293
EXTERN int32_t xdim, ydim, numpages;
294
EXTERN int32_t yxaspect, viewingrange;
618 terminx 295
EXTERN intptr_t ylookup[MAXYDIM+1];
573 terminx 296
 
297
#define MAXVALIDMODES 256
1205 terminx 298
EXTERN int32_t validmodecnt;
573 terminx 299
struct validmode_t {
1205 terminx 300
    int32_t xdim,ydim;
573 terminx 301
    char bpp;
302
    char fs;    // bit 0 = fullscreen flag
303
    char filler[2];
1205 terminx 304
    int32_t extra; // internal use
573 terminx 305
};
306
EXTERN struct validmode_t validmode[MAXVALIDMODES];
307
 
1854 helixhorne 308
EXTERN int32_t numyaxbunches;
309
#ifdef YAX_ENABLE
310
// Singly-linked list of sectnums grouped by bunches and ceiling (0)/floor (1)
311
// Usage e.g.:
312
//   int16_t bunchnum = yax_getbunch(somesector, YAX_CEILING);
313
// Iteration over all sectors whose floor bunchnum equals 'bunchnum' (i.e. "all
314
// floors of the other side"):
315
//   for (i=headsectbunch[1][bunchnum]; i!=-1; i=nextsectbunch[1][i])
316
//       <do stuff with sector i...>
317
 
318
EXTERN int16_t headsectbunch[2][YAX_MAXBUNCHES], nextsectbunch[2][MAXSECTORS];
319
#endif
320
 
1205 terminx 321
EXTERN int16_t numsectors, numwalls;
701 plagman 322
EXTERN char display_mirror;
2471 helixhorne 323
EXTERN int32_t totalclock;
1205 terminx 324
EXTERN int32_t numframes, randomseed;
325
EXTERN int16_t sintable[2048];
1206 terminx 326
EXTERN uint8_t palette[768];
1205 terminx 327
EXTERN int16_t numpalookups;
573 terminx 328
EXTERN char *palookup[MAXPALOOKUPS];
329
EXTERN char parallaxtype, showinvisibility;
1205 terminx 330
EXTERN int32_t parallaxyoffs, parallaxyscale;
331
EXTERN int32_t visibility, parallaxvisibility;
573 terminx 332
 
1205 terminx 333
EXTERN int32_t windowx1, windowy1, windowx2, windowy2;
334
EXTERN int16_t startumost[MAXXDIM], startdmost[MAXXDIM];
573 terminx 335
 
1882 helixhorne 336
// original multi-psky handling (only one per map)
1205 terminx 337
EXTERN int16_t pskyoff[MAXPSKYTILES], pskybits;
1882 helixhorne 338
// new multi-psky -- up to MAXPSKYMULTIS
339
EXTERN int16_t pskynummultis;
1886 helixhorne 340
EXTERN int32_t pskymultiyscale[MAXPSKYMULTIS];
1882 helixhorne 341
EXTERN int16_t pskymultilist[MAXPSKYMULTIS], pskymultibits[MAXPSKYMULTIS];
342
EXTERN int16_t pskymultioff[MAXPSKYMULTIS][MAXPSKYTILES];
573 terminx 343
 
2470 helixhorne 344
// last sprite in the freelist, that is the spritenum for which
345
//   .statnum==MAXSTATUS && nextspritestat[spritenum]==-1
346
// (or -1 if freelist is empty):
347
EXTERN int16_t tailspritefree;
348
 
1205 terminx 349
EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1];
350
EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES];
351
EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES];
573 terminx 352
 
1205 terminx 353
EXTERN int16_t tilesizx[MAXTILES], tilesizy[MAXTILES];
573 terminx 354
EXTERN char picsiz[MAXTILES];
355
EXTERN char walock[MAXTILES];
2463 helixhorne 356
EXTERN const int32_t pow2long[32];
1969 helixhorne 357
EXTERN int32_t picanm[MAXTILES];
618 terminx 358
EXTERN intptr_t waloff[MAXTILES];  // stores pointers to cache  -- SA
573 terminx 359
 
1205 terminx 360
EXTERN int32_t windowpos, windowx, windowy;
573 terminx 361
 
362
    //These variables are for auto-mapping with the draw2dscreen function.
363
    //When you load a new board, these bits are all set to 0 - since
364
    //you haven't mapped out anything yet.  Note that these arrays are
365
    //bit-mapped.
366
    //If you want draw2dscreen() to show sprite #54 then you say:
367
    //   spritenum = 54;
368
    //   show2dsprite[spritenum>>3] |= (1<<(spritenum&7));
369
    //And if you want draw2dscreen() to not show sprite #54 then you say:
370
    //   spritenum = 54;
371
    //   show2dsprite[spritenum>>3] &= ~(1<<(spritenum&7));
372
    //Automapping defaults to 0 (do nothing).  If you set automapping to 1,
373
    //   then in 3D mode, the walls and sprites that you see will show up the
374
    //   next time you flip to 2D mode.
375
 
376
EXTERN char show2dsector[(MAXSECTORS+7)>>3];
377
EXTERN char show2dwall[(MAXWALLS+7)>>3];
378
EXTERN char show2dsprite[(MAXSPRITES+7)>>3];
1854 helixhorne 379
//EXTERN char automapping;
573 terminx 380
 
2418 hendricks2 381
EXTERN char gotpic[(MAXTILES+7)>>3];
573 terminx 382
EXTERN char gotsector[(MAXSECTORS+7)>>3];
383
 
1190 terminx 384
EXTERN char editorcolors[256];
385
 
1544 terminx 386
EXTERN int32_t faketilesiz[MAXTILES];
387
EXTERN char *faketiledata[MAXTILES];
388
 
389
EXTERN char spritecol2d[MAXTILES][2];
390
extern char vgapal16[4*256];
391
 
1205 terminx 392
extern uint32_t drawlinepat;
573 terminx 393
 
394
extern void faketimerhandler(void);
395
 
396
extern char apptitle[256];
397
typedef struct {
1205 terminx 398
    char r,g,b,f;
573 terminx 399
} palette_t;
400
extern palette_t curpalette[256], curpalettefaded[256], palfadergb;
401
extern char palfadedelta;
402
 
2391 helixhorne 403
extern int32_t novoxmips;
573 terminx 404
 
1702 plagman 405
extern float debug1, debug2;
406
 
2266 helixhorne 407
extern int16_t tiletovox[MAXTILES];
1205 terminx 408
extern int32_t usevoxels, voxscale[MAXVOXELS];
1820 terminx 409
 
410
#ifdef USE_OPENGL
1205 terminx 411
extern int32_t usemodels, usehightile;
412
extern int32_t rendmode;
573 terminx 413
#endif
1205 terminx 414
EXTERN int32_t h_xsize[MAXTILES], h_ysize[MAXTILES];
415
EXTERN int8_t h_xoffs[MAXTILES], h_yoffs[MAXTILES];
573 terminx 416
 
1799 helixhorne 417
extern const char *engineerrstr;
573 terminx 418
 
1205 terminx 419
EXTERN int32_t editorzrange[2];
1121 terminx 420
 
1228 terminx 421
static inline int32_t getrendermode(void)
422
{
1820 terminx 423
#ifndef USE_OPENGL
1228 terminx 424
    return 0;
425
#else
426
    return rendmode;
427
#endif
428
}
429
 
573 terminx 430
/*************************************************************************
431
POSITION VARIABLES:
432
 
433
        POSX is your x - position ranging from 0 to 65535
434
        POSY is your y - position ranging from 0 to 65535
435
            (the length of a side of the grid in EDITBORD would be 1024)
436
        POSZ is your z - position (height) ranging from 0 to 65535, 0 highest.
437
        ANG is your angle ranging from 0 to 2047.  Instead of 360 degrees, or
438
             2 * PI radians, I use 2048 different angles, so 90 degrees would
439
             be 512 in my system.
440
 
441
SPRITE VARIABLES:
442
 
443
    EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1];
444
    EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES];
445
    EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES];
446
 
447
    Example: if the linked lists look like the following:
1540 terminx 448
         ????????????????
573 terminx 449
               Sector lists:               Status lists:              
1540 terminx 450
         ????????????????J
573 terminx 451
           Sector0:  4, 5, 8             Status0:  2, 0, 8            
452
           Sector1:  16, 2, 0, 7         Status1:  4, 5, 16, 7, 3, 9  
453
           Sector2:  3, 9                                              
1540 terminx 454
         ????????????????
573 terminx 455
    Notice that each number listed above is shown exactly once on both the
456
        left and right side.  This is because any sprite that exists must
457
        be in some sector, and must have some kind of status that you define.
458
 
459
 
460
Coding example #1:
461
    To go through all the sprites in sector 1, the code can look like this:
462
 
463
        sectnum = 1;
464
        i = headspritesect[sectnum];
465
        while (i != -1)
466
        {
467
            nexti = nextspritesect[i];
468
 
469
            //your code goes here
470
            //ex: printf("Sprite %d is in sector %d\n",i,sectnum);
471
 
472
            i = nexti;
473
        }
474
 
475
Coding example #2:
476
    To go through all sprites with status = 1, the code can look like this:
477
 
478
        statnum = 1;        //status 1
479
        i = headspritestat[statnum];
480
        while (i != -1)
481
        {
482
            nexti = nextspritestat[i];
483
 
484
            //your code goes here
485
            //ex: printf("Sprite %d has a status of 1 (active)\n",i,statnum);
486
 
487
            i = nexti;
488
        }
489
 
490
             insertsprite(short sectnum, short statnum);
491
             deletesprite(short spritenum);
492
             changespritesect(short spritenum, short newsectnum);
493
             changespritestat(short spritenum, short newstatnum);
494
 
495
TILE VARIABLES:
496
        NUMTILES - the number of tiles found TILES.DAT.
497
        TILESIZX[MAXTILES] - simply the x-dimension of the tile number.
498
        TILESIZY[MAXTILES] - simply the y-dimension of the tile number.
2471 helixhorne 499
        WALOFF[MAXTILES] - the actual address pointing to the top-left
573 terminx 500
                                 corner of the tile.
501
        PICANM[MAXTILES] - flags for animating the tile.
502
 
503
TIMING VARIABLES:
504
        TOTALCLOCK - When the engine is initialized, TOTALCLOCK is set to zero.
505
            From then on, it is incremented 120 times a second by 1.  That
506
            means that the number of seconds elapsed is totalclock / 120.
507
        NUMFRAMES - The number of times the draw3dscreen function was called
508
            since the engine was initialized.  This helps to determine frame
509
            rate.  (Frame rate = numframes * 120 / totalclock.)
510
 
511
OTHER VARIABLES:
512
 
513
        STARTUMOST[320] is an array of the highest y-coordinates on each column
514
                that my engine is allowed to write to.  You need to set it only
515
                once.
516
        STARTDMOST[320] is an array of the lowest y-coordinates on each column
517
                that my engine is allowed to write to.  You need to set it only
518
                once.
519
        SINTABLE[2048] is a sin table with 2048 angles rather than the
520
            normal 360 angles for higher precision.  Also since SINTABLE is in
521
            all integers, the range is multiplied by 16383, so instead of the
522
            normal -1<sin(x)<1, the range of sintable is -16383<sintable[]<16383
523
            If you use this sintable, you can possibly speed up your code as
524
            well as save space in memory.  If you plan to use sintable, 2
525
            identities you may want to keep in mind are:
526
                sintable[ang&2047]       = sin(ang * (3.141592/1024)) * 16383
527
                sintable[(ang+512)&2047] = cos(ang * (3.141592/1024)) * 16383
528
        NUMSECTORS - the total number of existing sectors.  Modified every time
529
            you call the loadboard function.
530
***************************************************************************/
531
 
1454 terminx 532
typedef struct {
1644 helixhorne 533
    int32_t x, y;
534
} vec2_t;
535
 
536
typedef struct {
1208 terminx 537
    int32_t x, y, z;
538
} vec3_t;
539
 
540
typedef struct {
541
    vec3_t pos;
1210 terminx 542
    int16_t hitsprite, hitwall, hitsect;
1208 terminx 543
} hitdata_t;
544
 
1465 terminx 545
#pragma pack(pop)
546
 
1205 terminx 547
int32_t    preinitengine(void); // a partial setup of the engine used for launch windows
548
int32_t    initengine(void);
573 terminx 549
void   uninitengine(void);
550
void   initspritelists(void);
1760 helixhorne 551
int32_t   loadboard(char *filename, char flags, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
552
int32_t   loadmaphack(const char *filename);
553
void delete_maphack_lights();
2270 helixhorne 554
#if !defined DEBUG_MAIN_ARRAYS
1760 helixhorne 555
int32_t clipmapinfo_load(const char *filename);
2270 helixhorne 556
#endif
1760 helixhorne 557
int32_t   saveboard(const char *filename, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
558
int32_t   loadpics(const char *filename, int32_t askedsize);
1205 terminx 559
void   loadtile(int16_t tilenume);
1760 helixhorne 560
int32_t   qloadkvx(int32_t voxindex, const char *filename);
1205 terminx 561
int32_t   allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz);
2265 helixhorne 562
//void   copytilepiece(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
1205 terminx 563
void   makepalookup(int32_t palnum, char *remapbuf, int8_t r, int8_t g, int8_t b, char dastat);
2014 helixhorne 564
//void   setvgapalette(void);
1781 plagman 565
void   setbasepaltable(uint8_t **basepaltable, uint8_t basepalcount);
2224 helixhorne 566
void   setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags);
573 terminx 567
void   setpalettefade(char r, char g, char b, char offset);
1205 terminx 568
void   squarerotatetile(int16_t tilenume);
2312 helixhorne 569
void fade_screen_black(int32_t moreopaquep);
573 terminx 570
 
1205 terminx 571
int32_t   setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t dabpp);
573 terminx 572
void   nextpage(void);
1712 helixhorne 573
void   setaspect_new();
1205 terminx 574
void   setview(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
575
void   setaspect(int32_t daxrange, int32_t daaspect);
573 terminx 576
void   flushperms(void);
577
 
1801 helixhorne 578
void plotlines2d(const int32_t *xx, const int32_t *yy, int32_t numpoints, char col) ATTRIBUTE((nonnull(1,2)));
1695 helixhorne 579
 
1205 terminx 580
void   plotpixel(int32_t x, int32_t y, char col);
581
char   getpixel(int32_t x, int32_t y);
582
void   setviewtotile(int16_t tilenume, int32_t xsiz, int32_t ysiz);
573 terminx 583
void   setviewback(void);
1205 terminx 584
void   preparemirror(int32_t dax, int32_t day, int32_t daz, int16_t daang, int32_t dahoriz, int16_t dawall, int16_t dasector, int32_t *tposx, int32_t *tposy, int16_t *tang);
573 terminx 585
void   completemirror(void);
586
 
1205 terminx 587
void   drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int32_t dahoriz, int16_t dacursectnum);
573 terminx 588
void   drawmasks(void);
1205 terminx 589
void   clearview(int32_t dacol);
590
void   clearallviews(int32_t dacol);
591
void   drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang);
1658 terminx 592
void   rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, char dapalnum, int32_t dastat, int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2);
1205 terminx 593
void   drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col);
1740 helixhorne 594
int32_t    printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
595
void   printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
573 terminx 596
 
2308 helixhorne 597
////////// specialized rotatesprite wrappers for (very) often used cases //////////
598
// don't clip at all, i.e. the whole screen real estate is available
599
static inline void rotatesprite_fs(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, char dapalnum, int32_t dastat)
600
{
601
    rotatesprite(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0,0,xdim-1,ydim-1);
602
}
603
 
2318 helixhorne 604
static inline void rotatesprite_win(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, int8_t dashade, char dapalnum, int32_t dastat)
605
{
606
    rotatesprite(sx, sy, z, a, picnum, dashade, dapalnum, dastat, windowx1,windowy1,windowx2,windowy2);
607
}
608
 
2256 helixhorne 609
void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int32_t maxnum, int16_t firstelt);
610
void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt);
611
 
1711 helixhorne 612
extern int32_t clipmoveboxtracenum;
1740 helixhorne 613
int32_t   clipmove(vec3_t *vect, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2)));
1205 terminx 614
int32_t   clipinsidebox(int32_t x, int32_t y, int16_t wallnum, int32_t walldist);
615
int32_t   clipinsideboxline(int32_t x, int32_t y, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t walldist);
1740 helixhorne 616
int32_t   pushmove(vec3_t *vect, int16_t *sectnum, int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2)));
617
void   getzrange(const vec3_t *vect, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6)));
618
int32_t   hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz, hitdata_t *hitinfo, uint32_t cliptype) ATTRIBUTE((nonnull(1,6)));
2373 helixhorne 619
void   neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
620
               int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite,
621
               int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch,
622
               int32_t (*blacklist_sprite_func)(int32_t)) ATTRIBUTE((nonnull(6,7,8)));
1205 terminx 623
int32_t   cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2);
1740 helixhorne 624
void   updatesector(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3)));
2256 helixhorne 625
void updatesector_onlynextwalls(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3)));
1740 helixhorne 626
void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, const uint8_t *excludesectbitmap) ATTRIBUTE((nonnull(3)));
627
void   updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) ATTRIBUTE((nonnull(4)));
1205 terminx 628
int32_t   inside(int32_t x, int32_t y, int16_t sectnum);
629
void   dragpoint(int16_t pointhighlight, int32_t dax, int32_t day);
630
void   setfirstwall(int16_t sectnum, int16_t newfirstwall);
1886 helixhorne 631
 
632
extern const int16_t *chsecptr_onextwall;
1760 helixhorne 633
int32_t checksectorpointer(int16_t i, int16_t sectnum);
573 terminx 634
 
1740 helixhorne 635
void   getmousevalues(int32_t *mousx, int32_t *mousy, int32_t *bstatus) ATTRIBUTE((nonnull(1,2,3)));
1205 terminx 636
int32_t    krand(void);
637
int32_t   ksqrt(int32_t num);
1230 terminx 638
// int32_t   getangle(int32_t xvect, int32_t yvect);
639
 
640
//
641
// getangle
642
//
643
 
644
EXTERN int16_t radarang[1280];
645
 
646
static inline int32_t getangle(int32_t xvect, int32_t yvect)
647
{
648
    if ((xvect|yvect) == 0) return(0);
1644 helixhorne 649
    if (xvect == 0) return 512+((yvect<0)<<10);
650
    if (yvect == 0) return ((xvect<0)<<10);
651
    if (xvect == yvect) return 256+((xvect<0)<<10);
652
    if (xvect == -yvect) return 768+((xvect>0)<<10);
1230 terminx 653
    if (klabs(xvect) > klabs(yvect))
1644 helixhorne 654
        return ((radarang[640+scale(160,yvect,xvect)]>>6)+((xvect<0)<<10))&2047;
655
    return ((radarang[640-scale(160,xvect,yvect)]>>6)+512+((yvect<0)<<10))&2047;
1230 terminx 656
}
657
 
1740 helixhorne 658
void   rotatepoint(int32_t xpivot, int32_t ypivot, int32_t x, int32_t y, int16_t daang, int32_t *x2, int32_t *y2) ATTRIBUTE((nonnull(6,7)));
1205 terminx 659
int32_t   lastwall(int16_t point);
660
int32_t   nextsectorneighborz(int16_t sectnum, int32_t thez, int16_t topbottom, int16_t direction);
661
int32_t   getceilzofslope(int16_t sectnum, int32_t dax, int32_t day);
662
int32_t   getflorzofslope(int16_t sectnum, int32_t dax, int32_t day);
1740 helixhorne 663
void   getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) ATTRIBUTE((nonnull(4,5)));
1205 terminx 664
void   alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z);
665
void   alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z);
666
int32_t   sectorofwall(int16_t theline);
1790 helixhorne 667
int32_t   sectorofwall_noquick(int16_t theline);
1205 terminx 668
int32_t   loopnumofsector(int16_t sectnum, int16_t wallnum);
1866 helixhorne 669
void setslope(int32_t sectnum, int32_t cf, int16_t slope);
573 terminx 670
 
1708 helixhorne 671
int32_t lineintersect(int32_t x1, int32_t y1, int32_t z1, int32_t x2, int32_t y2, int32_t z2, int32_t x3,
672
                      int32_t y3, int32_t x4, int32_t y4, int32_t *intx, int32_t *inty, int32_t *intz);
673
 
674
int32_t rayintersect(int32_t x1, int32_t y1, int32_t z1, int32_t vx, int32_t vy, int32_t vz, int32_t x3,
675
                     int32_t y3, int32_t x4, int32_t y4, int32_t *intx, int32_t *inty, int32_t *intz);
676
 
2465 helixhorne 677
int32_t insertsprite(int16_t sectnum, int16_t statnum);
678
int32_t deletesprite(int16_t spritenum);
1230 terminx 679
 
1205 terminx 680
int32_t   changespritesect(int16_t spritenum, int16_t newsectnum);
681
int32_t   changespritestat(int16_t spritenum, int16_t newstatnum);
1740 helixhorne 682
int32_t   setsprite(int16_t spritenum, const vec3_t *new) ATTRIBUTE((nonnull(2)));
1860 helixhorne 683
int32_t   setspritez(int16_t spritenum, const vec3_t *new) ATTRIBUTE((nonnull(2)));
573 terminx 684
 
2004 helixhorne 685
void spriteheightofs(int16_t i, int32_t *height, int32_t *zofs, int32_t alsotileyofs);
1816 helixhorne 686
 
1852 helixhorne 687
int32_t   screencapture(const char *filename, char inverseit, const char *versionstr) ATTRIBUTE((nonnull(1)));
573 terminx 688
 
1207 terminx 689
int32_t   getclosestcol(int32_t r, int32_t g, int32_t b);
690
 
573 terminx 691
// PLAG: line utility functions
692
typedef struct  s_equation {
693
    float       a, b, c;
694
}               _equation;
695
typedef struct  s_point2d {
696
    float       x, y;
697
}               _point2d;
1394 plagman 698
int32_t             wallvisible(int32_t x, int32_t y, int16_t wallnum);
573 terminx 699
 
700
#define STATUS2DSIZ 144
1359 terminx 701
#define STATUS2DSIZ2 26
702
 
1892 helixhorne 703
//void   qsetmode640350(void);
704
//void   qsetmode640480(void);
1205 terminx 705
void   qsetmodeany(int32_t,int32_t);
573 terminx 706
void   clear2dscreen(void);
1733 helixhorne 707
void   draw2dgrid(int32_t posxe, int32_t posye, int32_t posze, int16_t cursectnum, int16_t ange, int32_t zoome, int16_t gride);
1740 helixhorne 708
void   draw2dscreen(const vec3_t *pos, int16_t cursectnum, int16_t ange, int32_t zoome, int16_t gride) ATTRIBUTE((nonnull(1)));
1730 helixhorne 709
int32_t   drawline16(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col);
710
void   drawcircle16(int32_t x1, int32_t y1, int32_t r, int32_t eccen, char col);
573 terminx 711
 
1205 terminx 712
int32_t   setrendermode(int32_t renderer);
573 terminx 713
 
1820 terminx 714
#ifdef USE_OPENGL
1205 terminx 715
void    setrollangle(int32_t rolla);
895 terminx 716
#endif
573 terminx 717
 
718
//  pal: pass -1 to invalidate all palettes for the tile, or >=0 for a particular palette
719
//  how: pass -1 to invalidate all instances of the tile in texture memory, or a bitfield
720
//         bit 0: opaque or masked (non-translucent) texture, using repeating
721
//         bit 1: ignored
722
//         bit 2: 33% translucence, using repeating
723
//         bit 3: 67% translucence, using repeating
724
//         bit 4: opaque or masked (non-translucent) texture, using clamping
725
//         bit 5: ignored
726
//         bit 6: 33% translucence, using clamping
727
//         bit 7: 67% translucence, using clamping
728
//       clamping is for sprites, repeating is for walls
1205 terminx 729
void invalidatetile(int16_t tilenume, int32_t pal, int32_t how);
573 terminx 730
 
1205 terminx 731
int32_t animateoffs(int16_t tilenum, int16_t fakevar);
573 terminx 732
 
733
void setpolymost2dview(void);   // sets up GL for 2D drawing
734
 
1854 helixhorne 735
int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen, int32_t tilezoom,
736
                                int32_t usehitile, uint8_t *loadedhitile);
573 terminx 737
void polymost_glreset(void);
1205 terminx 738
void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype);
573 terminx 739
 
1820 terminx 740
#ifdef USE_OPENGL
1205 terminx 741
extern int32_t glanisotropy;
742
extern int32_t glusetexcompr;
743
extern int32_t gltexfiltermode;
744
extern int32_t glredbluemode;
2145 helixhorne 745
extern int32_t glusetexcache, glusememcache;
1205 terminx 746
extern int32_t glmultisample, glnvmultisamplehint;
747
extern int32_t glwidescreen, glprojectionhacks;
748
extern int32_t gltexmaxsize;
573 terminx 749
void gltexapplyprops (void);
1155 terminx 750
void invalidatecache(void);
573 terminx 751
 
1205 terminx 752
extern int32_t r_detailmapping;
753
extern int32_t r_glowmapping;
754
extern int32_t r_vertexarrays;
755
extern int32_t r_vbos;
756
extern int32_t r_vbocount;
757
extern int32_t r_animsmoothing;
758
extern int32_t r_parallaxskyclamping;
759
extern int32_t r_parallaxskypanning;
760
extern int32_t r_modelocclusionchecking;
761
extern int32_t r_fullbrights;
762
extern int32_t r_downsize;
1357 terminx 763
extern int32_t r_downsizevar;
1205 terminx 764
extern int32_t mdtims, omdtims;
1275 terminx 765
extern int32_t glrendmode;
573 terminx 766
#endif
767
 
768
void hicinit(void);
769
// effect bitset: 1 = greyscale, 2 = invert
1205 terminx 770
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect);
573 terminx 771
// flags bitset: 1 = don't compress
1760 helixhorne 772
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut, float xscale, float yscale, float specpower, float specfactor, char flags);
1205 terminx 773
int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6]);
774
int32_t hicclearsubst(int32_t picnum, int32_t palnum);
573 terminx 775
 
2412 helixhorne 776
int32_t Ptile2tile(int32_t tile, int32_t pallet) ATTRIBUTE((pure));
1205 terminx 777
int32_t md_loadmodel(const char *fn);
2264 hendricks2 778
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags);
1230 terminx 779
// int32_t md_tilehasmodel(int32_t tilenume, int32_t pal);
780
 
1909 terminx 781
extern char defsfilename[BMAX_PATH];
782
extern char *g_defNamePtr;
783
 
1937 hendricks2 784
extern char **g_defModules;
785
extern int g_defModulesNum;
786
 
1820 terminx 787
#ifdef USE_OPENGL
1230 terminx 788
typedef struct
789
{
790
    // maps build tiles to particular animation frames of a model
791
    int32_t     modelid;
792
    int32_t     skinnum;
793
    int32_t     framenum;   // calculate the number from the name when declaring
794
    float   smoothduration;
795
    int32_t     next;
796
    char    pal;
797
} tile2model_t;
798
 
2267 helixhorne 799
# define EXTRATILES (MAXTILES/8)
1230 terminx 800
 
801
EXTERN int32_t mdinited;
802
EXTERN tile2model_t tile2model[MAXTILES+EXTRATILES];
803
 
804
static inline int32_t md_tilehasmodel(int32_t tilenume,int32_t pal)
805
{
806
    if (!mdinited) return -1;
807
    return tile2model[Ptile2tile(tilenume,pal)].modelid;
808
}
2244 helixhorne 809
#endif  // defined USE_OPENGL
1230 terminx 810
 
1205 terminx 811
int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume, int32_t skinnum, float smoothduration, int32_t pal);
812
int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend, int32_t fps, int32_t flags);
1279 plagman 813
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, int32_t surfnum, float param, float specpower, float specfactor);
1814 plagman 814
int32_t md_definehud (int32_t modelid, int32_t tilex, double xadd, double yadd, double zadd, double angadd, int32_t flags, int32_t fov);
1205 terminx 815
int32_t md_undefinetile(int32_t tile);
816
int32_t md_undefinemodel(int32_t modelid);
573 terminx 817
 
1760 helixhorne 818
int32_t loaddefinitionsfile(const char *fn);
573 terminx 819
 
1205 terminx 820
extern int32_t mapversion;      // if loadboard() fails with -2 return, try loadoldboard(). if it fails with -2, board is dodgy
821
int32_t loadoldboard(char *filename, char fromwhere, int32_t *daposx, int32_t *daposy, int32_t *daposz, int16_t *daang, int16_t *dacursectnum);
573 terminx 822
 
1025 terminx 823
// Hash functions
1201 terminx 824
 
825
typedef struct _hashitem // size is 12/24 bits.
1025 terminx 826
{
1178 terminx 827
    char *string;
1205 terminx 828
    int32_t key;
1201 terminx 829
    struct _hashitem *next;
1206 terminx 830
} hashitem_t;
1025 terminx 831
 
1201 terminx 832
typedef struct
1025 terminx 833
{
1205 terminx 834
    int32_t size;
1206 terminx 835
    hashitem_t **items;
836
} hashtable_t;
1025 terminx 837
 
1206 terminx 838
void hash_init(hashtable_t *t);
839
void hash_free(hashtable_t *t);
1867 helixhorne 840
int32_t  hash_findcase(const hashtable_t *t, const char *s);
841
int32_t  hash_find(const hashtable_t *t, const char *s);
1677 terminx 842
void hash_add(hashtable_t *t, const char *s, int32_t key, int32_t replace);
1867 helixhorne 843
void hash_delete(hashtable_t *t, const char *s);
1025 terminx 844
 
1227 plagman 845
#ifdef POLYMER
846
# include "polymer.h"
1660 terminx 847
#else
1820 terminx 848
#ifdef USE_OPENGL
1660 terminx 849
# include "polymost.h"
1227 plagman 850
#endif
1660 terminx 851
#endif
1227 plagman 852
 
573 terminx 853
#ifdef __cplusplus
854
}
855
#endif
856
 
857
#endif // __build_h__