Rev 5010 | 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 | |
4747 | terminx | 9 | #ifndef build_h_ |
10 | #define build_h_ |
||
573 | terminx | 11 | |
618 | terminx | 12 | #include "compat.h" |
1230 | terminx | 13 | #include "pragmas.h" |
3467 | helixhorne | 14 | #include "glbuild.h" |
618 | terminx | 15 | |
4766 | hendricks2 | 16 | #ifdef __cplusplus |
573 | terminx | 17 | extern "C" { |
18 | #endif |
||
19 | |||
3347 | terminx | 20 | enum rendmode_t { |
3346 | terminx | 21 | REND_CLASSIC, |
22 | REND_POLYMOST = 3, |
||
23 | REND_POLYMER |
||
24 | }; |
||
25 | |||
2988 | helixhorne | 26 | #define PI 3.14159265358979323846 |
2987 | helixhorne | 27 | |
573 | terminx | 28 | #define MAXSECTORSV8 4096 |
29 | #define MAXWALLSV8 16384 |
||
30 | #define MAXSPRITESV8 16384 |
||
31 | |||
32 | #define MAXSECTORSV7 1024 |
||
33 | #define MAXWALLSV7 8192 |
||
34 | #define MAXSPRITESV7 4096 |
||
35 | |||
2629 | helixhorne | 36 | #ifndef GEKKO |
37 | # define MAXSECTORS MAXSECTORSV8 |
||
38 | # define MAXWALLS MAXWALLSV8 |
||
39 | # define MAXSPRITES MAXSPRITESV8 |
||
40 | |||
41 | # define MAXXDIM 7680 |
||
42 | # define MAXYDIM 3200 |
||
2645 | helixhorne | 43 | |
44 | // additional space beyond wall, in walltypes: |
||
45 | # define M32_FIXME_WALLS 512 |
||
46 | # define M32_FIXME_SECTORS 2 |
||
2629 | helixhorne | 47 | #else |
48 | # define MAXSECTORS MAXSECTORSV7 |
||
49 | # define MAXWALLS MAXWALLSV7 |
||
50 | # define MAXSPRITES MAXSPRITESV7 |
||
51 | |||
2645 | helixhorne | 52 | # define MAXXDIM 860 |
53 | # define MAXYDIM 490 |
||
54 | |||
55 | # define M32_FIXME_WALLS 0 |
||
56 | # define M32_FIXME_SECTORS 0 |
||
2629 | helixhorne | 57 | #endif |
58 | |||
4102 | hendricks2 | 59 | #ifdef LUNATIC |
60 | # define NEW_MAP_FORMAT |
||
61 | // A marker for LuaJIT C function callbacks, but not merely: |
||
62 | # define LUNATIC_CB ATTRIBUTE((used)) |
||
63 | // Used for variables and functions referenced from Lua: |
||
64 | # define LUNATIC_EXTERN ATTRIBUTE((used)) |
||
65 | #else |
||
66 | # ifdef NEW_MAP_FORMAT |
||
67 | # error "New map format can only be used with Lunatic" |
||
68 | # endif |
||
69 | # define LUNATIC_EXTERN static |
||
70 | #endif |
||
71 | |||
687 | plagman | 72 | #define MAXWALLSB ((MAXWALLS>>2)+(MAXWALLS>>3)) |
573 | terminx | 73 | |
2267 | helixhorne | 74 | #define MAXTILES 30720 |
4225 | helixhorne | 75 | #define MAXUSERTILES (MAXTILES-16) // reserve 16 tiles at the end |
76 | |||
573 | terminx | 77 | #define MAXVOXELS 4096 |
78 | #define MAXSTATUS 1024 |
||
79 | #define MAXPLAYERS 16 |
||
1782 | plagman | 80 | #define MAXBASEPALS 8 |
573 | terminx | 81 | #define MAXPALOOKUPS 256 |
4301 | helixhorne | 82 | #define MAXBLENDTABS 256 |
3975 | helixhorne | 83 | // Maximum number of defined multi-pskies: |
1882 | helixhorne | 84 | #define MAXPSKYMULTIS 8 |
3975 | helixhorne | 85 | // Maximum number of component tiles in a multi-psky: |
86 | #define MAXPSKYTILES 8 |
||
573 | terminx | 87 | #define MAXSPRITESONSCREEN 4096 |
88 | #define MAXUNIQHUDID 256 //Extra slots so HUD models can store animation state without messing game sprites |
||
89 | |||
1552 | terminx | 90 | #define RESERVEDPALS 4 // don't forget to increment this when adding reserved pals |
573 | terminx | 91 | #define DETAILPAL (MAXPALOOKUPS - 1) |
92 | #define GLOWPAL (MAXPALOOKUPS - 2) |
||
1350 | terminx | 93 | #define SPECULARPAL (MAXPALOOKUPS - 3) |
94 | #define NORMALPAL (MAXPALOOKUPS - 4) |
||
573 | terminx | 95 | |
888 | terminx | 96 | #define TSPR_TEMP 99 |
886 | terminx | 97 | |
1355 | terminx | 98 | #define PR_LIGHT_PRIO_MAX 0 |
99 | #define PR_LIGHT_PRIO_MAX_GAME 1 |
||
100 | #define PR_LIGHT_PRIO_HIGH 2 |
||
101 | #define PR_LIGHT_PRIO_HIGH_GAME 3 |
||
102 | #define PR_LIGHT_PRIO_LOW 4 |
||
103 | #define PR_LIGHT_PRIO_LOW_GAME 5 |
||
104 | |||
3679 | helixhorne | 105 | // Convenient sprite iterators, must not be used if any sprites inside the loop |
106 | // are potentially deleted or their sector changed... |
||
2707 | helixhorne | 107 | #define SPRITES_OF(Statnum, Iter) Iter=headspritestat[Statnum]; Iter>=0; Iter=nextspritestat[Iter] |
108 | #define SPRITES_OF_SECT(Sectnum, Iter) Iter=headspritesect[Sectnum]; Iter>=0; Iter=nextspritesect[Iter] |
||
3679 | helixhorne | 109 | // ... in which case this iterator may be used: |
110 | #define SPRITES_OF_SECT_SAFE(Sectnum, Iter, Next) Iter=headspritesect[Sectnum]; \ |
||
3685 | helixhorne | 111 | Iter>=0 && (Next=nextspritesect[Iter], 1); Iter=Next |
4045 | helixhorne | 112 | #define SPRITES_OF_STAT_SAFE(Statnum, Iter, Next) Iter=headspritestat[Statnum]; \ |
113 | Iter>=0 && (Next=nextspritestat[Iter], 1); Iter=Next |
||
2707 | helixhorne | 114 | |
3321 | helixhorne | 115 | #define CLEARLINES2D(Startline, Numlines, Color) \ |
116 | clearbuf((char *)(frameplace + ((Startline)*bytesperline)), (bytesperline*(Numlines))>>2, (Color)) |
||
2707 | helixhorne | 117 | |
3321 | helixhorne | 118 | |
1887 | helixhorne | 119 | ////////// True Room over Room (YAX == rot -17 of "PRO") ////////// |
120 | #define YAX_ENABLE |
||
121 | //#define YAX_DEBUG |
||
122 | //#define ENGINE_SCREENSHOT_DEBUG |
||
123 | |||
3658 | helixhorne | 124 | #ifdef YAX_ENABLE |
125 | # if !defined NEW_MAP_FORMAT |
||
126 | # define YAX_ENABLE__COMPAT |
||
127 | # endif |
||
128 | #endif |
||
129 | |||
1816 | helixhorne | 130 | ////////// yax defs ////////// |
1877 | helixhorne | 131 | #define SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (§or[Sect].floor##Fld) : (§or[Sect].ceiling##Fld))) |
132 | |||
1854 | helixhorne | 133 | #define YAX_CEILING 0 // don't change! |
134 | #define YAX_FLOOR 1 // don't change! |
||
1816 | helixhorne | 135 | |
3658 | helixhorne | 136 | # ifdef NEW_MAP_FORMAT |
137 | # define YAX_MAXBUNCHES 512 |
||
138 | # define YAX_BIT__COMPAT 1024 |
||
139 | # define YAX_NEXTWALLBIT__COMPAT(Cf) (1<<(10+Cf)) |
||
140 | # define YAX_NEXTWALLBITS__COMPAT (YAX_NEXTWALLBIT__COMPAT(0)|YAX_NEXTWALLBIT__COMPAT(1)) |
||
141 | # else |
||
142 | # define YAX_MAXBUNCHES 256 |
||
143 | # define YAX_BIT 1024 |
||
144 | // "has next wall when constrained"-bit (1<<10: ceiling, 1<<11: floor) |
||
145 | # define YAX_NEXTWALLBIT(Cf) (1<<(10+Cf)) |
||
146 | # define YAX_NEXTWALLBITS (YAX_NEXTWALLBIT(0)|YAX_NEXTWALLBIT(1)) |
||
147 | # endif |
||
148 | |||
3623 | helixhorne | 149 | int32_t get_alwaysshowgray(void); // editor only |
1877 | helixhorne | 150 | void yax_updategrays(int32_t posze); |
1816 | helixhorne | 151 | |
1877 | helixhorne | 152 | #ifdef YAX_ENABLE |
3658 | helixhorne | 153 | # ifdef NEW_MAP_FORMAT |
154 | // New map format -- no hijacking of otherwise used members. |
||
155 | # define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(&Ptr[Wall].upwall + Cf)) |
||
156 | # define YAX_NEXTWALLDEFAULT(Cf) (-1) |
||
157 | # else |
||
158 | // More user tag hijacking: lotag/extra. :/ |
||
159 | # define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(int16_t *)(&Ptr[Wall].lotag + 2*Cf)) |
||
160 | # define YAX_NEXTWALLDEFAULT(Cf) (((Cf)==YAX_CEILING) ? 0 : -1) |
||
161 | extern int16_t yax_bunchnum[MAXSECTORS][2]; |
||
162 | extern int16_t yax_nextwall[MAXWALLS][2]; |
||
163 | # endif |
||
164 | |||
2349 | helixhorne | 165 | # define YAX_NEXTWALL(Wall, Cf) YAX_PTRNEXTWALL(wall, Wall, Cf) |
1865 | helixhorne | 166 | |
1877 | helixhorne | 167 | # define YAX_ITER_WALLS(Wal, Itervar, Cfvar) Cfvar=0, Itervar=(Wal); Itervar!=-1; \ |
2896 | helixhorne | 168 | Itervar=yax_getnextwall(Itervar, Cfvar), \ |
169 | (void)(Itervar==-1 && Cfvar==0 && (Cfvar=1) && (Itervar=yax_getnextwall((Wal), Cfvar))) |
||
1866 | helixhorne | 170 | |
1886 | helixhorne | 171 | # define SECTORS_OF_BUNCH(Bunchnum, Cf, Itervar) Itervar = headsectbunch[Cf][Bunchnum]; \ |
172 | Itervar != -1; Itervar = nextsectbunch[Cf][Itervar] |
||
173 | |||
2024 | helixhorne | 174 | extern int32_t r_tror_nomaskpass; |
175 | |||
3658 | helixhorne | 176 | # ifdef NEW_MAP_FORMAT |
177 | // Moved below declarations of sector, wall, sprite. |
||
178 | # else |
||
1816 | helixhorne | 179 | int16_t yax_getbunch(int16_t i, int16_t cf); |
4898 | terminx | 180 | FORCE_INLINE void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb) |
4700 | terminx | 181 | { |
182 | *cb = yax_getbunch(i, YAX_CEILING); |
||
183 | *fb = yax_getbunch(i, YAX_FLOOR); |
||
184 | } |
||
3658 | helixhorne | 185 | int16_t yax_getnextwall(int16_t wal, int16_t cf); |
186 | void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall); |
||
187 | # endif |
||
188 | |||
1816 | helixhorne | 189 | void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum); |
1843 | helixhorne | 190 | void yax_setbunches(int16_t i, int16_t cb, int16_t fb); |
2018 | helixhorne | 191 | int16_t yax_vnextsec(int16_t line, int16_t cf); |
1882 | helixhorne | 192 | void yax_update(int32_t resetstat); |
3039 | helixhorne | 193 | int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf); |
1877 | helixhorne | 194 | |
4898 | terminx | 195 | FORCE_INLINE int32_t yax_waltosecmask(int32_t walclipmask) |
1877 | helixhorne | 196 | { |
197 | // blocking: walstat&1 --> secstat&512 |
||
198 | // hitscan: walstat&64 --> secstat&2048 |
||
199 | return ((walclipmask&1)<<9) | ((walclipmask&64)<<5); |
||
200 | } |
||
201 | void yax_preparedrawrooms(void); |
||
2880 | helixhorne | 202 | void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t), |
203 | int16_t sectnum, int32_t didmirror, int32_t smoothr); |
||
1869 | helixhorne | 204 | # define YAX_SKIPSECTOR(i) if (graysectbitmap[(i)>>3]&(1<<((i)&7))) continue |
205 | # define YAX_SKIPWALL(i) if (graywallbitmap[(i)>>3]&(1<<((i)&7))) continue |
||
206 | #else |
||
1877 | helixhorne | 207 | # define yax_preparedrawrooms() |
2880 | helixhorne | 208 | # define yax_drawrooms(SpriteAnimFunc, sectnum, didmirror, smoothr) |
1869 | helixhorne | 209 | # define YAX_SKIPSECTOR(i) (i)=(i) |
210 | # define YAX_SKIPWALL(i) (i)=(i) |
||
211 | #endif |
||
1816 | helixhorne | 212 | |
573 | terminx | 213 | #define CLIPMASK0 (((1L)<<16)+1L) |
214 | #define CLIPMASK1 (((256L)<<16)+64L) |
||
215 | |||
1797 | helixhorne | 216 | // max x/y val (= max editorgridextent in Mapster32) |
217 | #define BXY_MAX 524288 |
||
218 | |||
4175 | helixhorne | 219 | // rotatesprite 'orientation' (actually much more) bits |
2935 | helixhorne | 220 | enum { |
4175 | helixhorne | 221 | RS_TRANS1 = 1, |
222 | RS_AUTO = 2, |
||
223 | RS_YFLIP = 4, |
||
224 | RS_NOCLIP = 8, |
||
225 | RS_TOPLEFT = 16, |
||
226 | RS_TRANS2 = 32, |
||
227 | RS_NOMASK = 64, |
||
228 | RS_PERM = 128, |
||
229 | |||
230 | RS_ALIGN_L = 256, |
||
231 | RS_ALIGN_R = 512, |
||
232 | RS_ALIGN_MASK = 768, |
||
233 | RS_STRETCH = 1024, |
||
234 | |||
3608 | hendricks2 | 235 | ROTATESPRITE_FULL16 = 2048, |
2935 | helixhorne | 236 | // ROTATESPRITE_MAX-1 is the mask of all externally available orientation bits |
3608 | hendricks2 | 237 | ROTATESPRITE_MAX = 4096, |
2929 | helixhorne | 238 | |
2935 | helixhorne | 239 | RS_CENTERORIGIN = (1<<30), |
240 | }; |
||
241 | |||
573 | terminx | 242 | //Make all variables in BUILD.H defined in the ENGINE, |
243 | //and externed in GAME |
||
244 | #ifdef ENGINE |
||
245 | # define EXTERN |
||
246 | #else |
||
247 | # define EXTERN extern |
||
248 | #endif |
||
249 | |||
3138 | Plagman | 250 | #ifdef __cplusplus |
251 | |||
4898 | terminx | 252 | FORCE_INLINE void sector_tracker_hook(uintptr_t address); |
253 | FORCE_INLINE void wall_tracker_hook(uintptr_t address); |
||
254 | FORCE_INLINE void sprite_tracker_hook(uintptr_t address); |
||
3138 | Plagman | 255 | |
4766 | hendricks2 | 256 | } |
257 | |||
4747 | terminx | 258 | #define TRACKER_NAME_ SectorTracker |
259 | #define TRACKER_GLOBAL_HOOK_ sector_tracker_hook |
||
3138 | Plagman | 260 | #include "tracker.hpp" |
4747 | terminx | 261 | #undef TRACKER_NAME_ |
262 | #undef TRACKER_GLOBAL_HOOK_ |
||
3138 | Plagman | 263 | |
4747 | terminx | 264 | #define TRACKER_NAME_ WallTracker |
265 | #define TRACKER_GLOBAL_HOOK_ wall_tracker_hook |
||
3138 | Plagman | 266 | #include "tracker.hpp" |
4747 | terminx | 267 | #undef TRACKER_NAME_ |
268 | #undef TRACKER_GLOBAL_HOOK_ |
||
3138 | Plagman | 269 | |
4747 | terminx | 270 | #define TRACKER_NAME_ SpriteTracker |
271 | #define TRACKER_GLOBAL_HOOK_ sprite_tracker_hook |
||
3138 | Plagman | 272 | #include "tracker.hpp" |
4747 | terminx | 273 | #undef TRACKER_NAME_ |
274 | #undef TRACKER_GLOBAL_HOOK_ |
||
3138 | Plagman | 275 | |
276 | #define Tracker(Container, Type) Container##Tracker<Type> |
||
3238 | hendricks2 | 277 | #define TrackerCast(x) x.cast() |
3138 | Plagman | 278 | |
4766 | hendricks2 | 279 | extern "C" { |
280 | |||
3138 | Plagman | 281 | #else |
282 | |||
283 | #define Tracker(Container, Type) Type |
||
3238 | hendricks2 | 284 | #define TrackerCast(x) x |
3138 | Plagman | 285 | |
286 | #endif // __cplusplus |
||
287 | |||
3455 | helixhorne | 288 | // Links to various ABIs specifying (or documenting non-normatively) the |
289 | // alignment requirements of aggregates: |
||
290 | // |
||
291 | // System V AMD64: http://www.x86-64.org/documentation/abi-0.99.pdf |
||
292 | // (x86-64.org down as of 2013-02-02?) |
||
293 | // "An array uses the same alignment as its elements, except that a local or global |
||
294 | // array variable of length at least 16 bytes or a C99 variable-length array variable |
||
295 | // always has alignment of at least 16 bytes." |
||
296 | // (Not reproducible with GCC or LuaJIT on Ubuntu) |
||
297 | // |
||
298 | // Win64: http://msdn.microsoft.com/en-us/library/9dbwhz68.aspx |
||
299 | // |
||
300 | // x86: http://en.wikipedia.org/wiki/Data_structure_alignment#Typical_alignment_of_C_structs_on_x86 |
||
573 | terminx | 301 | |
3775 | helixhorne | 302 | enum { |
303 | SPR_XFLIP = 4, |
||
304 | SPR_YFLIP = 8, |
||
305 | |||
306 | SPR_WALL = 16, |
||
307 | SPR_FLOOR = 32, |
||
308 | SPR_ALIGN_MASK = 32+16, |
||
309 | }; |
||
310 | |||
4937 | helixhorne | 311 | #if !defined NEW_MAP_FORMAT |
4909 | terminx | 312 | #include "buildtypes.h" |
313 | #define UNTRACKED_STRUCTS |
||
314 | #undef buildtypes_h__ |
||
315 | #include "buildtypes.h" |
||
316 | #undef UNTRACKED_STRUCTS |
||
4937 | helixhorne | 317 | #endif |
573 | terminx | 318 | |
3658 | helixhorne | 319 | #ifdef NEW_MAP_FORMAT |
320 | //////////////////// Lunatic new-generation map format //////////////////// |
||
321 | |||
4937 | helixhorne | 322 | #include "buildtypes.h" |
323 | |||
3658 | helixhorne | 324 | // 44 bytes |
325 | typedef struct |
||
326 | { |
||
327 | Tracker(Sector, int16_t) wallptr, wallnum; |
||
3731 | helixhorne | 328 | |
3658 | helixhorne | 329 | Tracker(Sector, int16_t) ceilingpicnum, ceilingheinum, ceilingbunch; |
3731 | helixhorne | 330 | Tracker(Sector, uint16_t) ceilingstat; |
331 | Tracker(Sector, int32_t) ceilingz; |
||
3658 | helixhorne | 332 | Tracker(Sector, int8_t) ceilingshade; |
333 | Tracker(Sector, uint8_t) ceilingpal, /*CM_FLOORZ:*/ ceilingxpanning, ceilingypanning; |
||
3731 | helixhorne | 334 | |
3658 | helixhorne | 335 | Tracker(Sector, int16_t) floorpicnum, floorheinum, floorbunch; |
3731 | helixhorne | 336 | Tracker(Sector, uint16_t) floorstat; |
337 | Tracker(Sector, int32_t) floorz; |
||
3658 | helixhorne | 338 | Tracker(Sector, int8_t) floorshade; |
339 | Tracker(Sector, uint8_t) floorpal, floorxpanning, floorypanning; |
||
3731 | helixhorne | 340 | |
4416 | helixhorne | 341 | Tracker(Sector, uint8_t) /*CM_CEILINGZ:*/ visibility, fogpal; |
3658 | helixhorne | 342 | Tracker(Sector, uint16_t) lotag, hitag; |
343 | Tracker(Sector, int16_t) extra; |
||
344 | } sectortypevx; |
||
345 | |||
3731 | helixhorne | 346 | # define SECTORVX_SZ1 offsetof(sectortypevx, ceilingpicnum) |
347 | # define SECTORVX_SZ4 sizeof(sectortypevx)-offsetof(sectortypevx, visibility) |
||
3658 | helixhorne | 348 | |
349 | static inline void copy_v7_from_vx_sector(sectortypev7 *v7sec, const sectortypevx *vxsec) |
||
350 | { |
||
3731 | helixhorne | 351 | /* [wallptr..wallnum] */ |
352 | Bmemcpy(v7sec, vxsec, SECTORVX_SZ1); |
||
3658 | helixhorne | 353 | |
3731 | helixhorne | 354 | /* ceiling* */ |
355 | v7sec->ceilingpicnum = vxsec->ceilingpicnum; |
||
356 | v7sec->ceilingheinum = vxsec->ceilingheinum; |
||
357 | v7sec->ceilingstat = vxsec->ceilingstat; |
||
358 | v7sec->ceilingz = vxsec->ceilingz; |
||
359 | v7sec->ceilingshade = vxsec->ceilingshade; |
||
360 | v7sec->ceilingpal = vxsec->ceilingpal; |
||
361 | v7sec->ceilingxpanning = vxsec->ceilingxpanning; |
||
362 | v7sec->ceilingypanning = vxsec->ceilingypanning; |
||
363 | |||
364 | /* floor* */ |
||
365 | v7sec->floorpicnum = vxsec->floorpicnum; |
||
366 | v7sec->floorheinum = vxsec->floorheinum; |
||
367 | v7sec->floorstat = vxsec->floorstat; |
||
368 | v7sec->floorz = vxsec->floorz; |
||
369 | v7sec->floorshade = vxsec->floorshade; |
||
370 | v7sec->floorpal = vxsec->floorpal; |
||
371 | v7sec->floorxpanning = vxsec->floorxpanning; |
||
372 | v7sec->floorypanning = vxsec->floorypanning; |
||
373 | |||
374 | /* [visibility..extra] */ |
||
375 | Bmemcpy(&v7sec->visibility, &vxsec->visibility, SECTORVX_SZ4); |
||
376 | |||
3658 | helixhorne | 377 | /* Clear YAX_BIT of ceiling and floor. (New-map format build saves TROR |
378 | * maps as map-text.) */ |
||
379 | v7sec->ceilingstat &= ~YAX_BIT__COMPAT; |
||
380 | v7sec->floorstat &= ~YAX_BIT__COMPAT; |
||
381 | } |
||
382 | |||
383 | static inline void inplace_vx_from_v7_sector(sectortypevx *vxsec) |
||
384 | { |
||
385 | const sectortypev7 *v7sec = (sectortypev7 *)vxsec; |
||
3731 | helixhorne | 386 | sectortypev7 bakv7sec; |
3658 | helixhorne | 387 | |
3731 | helixhorne | 388 | // Can't do this in-place since the members were rearranged. |
389 | Bmemcpy(&bakv7sec, v7sec, sizeof(sectortypev7)); |
||
390 | |||
391 | /* [wallptr..wallnum] is already at the right place */ |
||
392 | |||
393 | /* ceiling* */ |
||
394 | vxsec->ceilingpicnum = bakv7sec.ceilingpicnum; |
||
395 | vxsec->ceilingheinum = bakv7sec.ceilingheinum; |
||
396 | vxsec->ceilingstat = bakv7sec.ceilingstat; |
||
397 | vxsec->ceilingz = bakv7sec.ceilingz; |
||
398 | vxsec->ceilingshade = bakv7sec.ceilingshade; |
||
399 | vxsec->ceilingpal = bakv7sec.ceilingpal; |
||
400 | vxsec->ceilingxpanning = bakv7sec.ceilingxpanning; |
||
401 | vxsec->ceilingypanning = bakv7sec.ceilingypanning; |
||
402 | |||
403 | /* floor* */ |
||
404 | vxsec->floorpicnum = bakv7sec.floorpicnum; |
||
405 | vxsec->floorheinum = bakv7sec.floorheinum; |
||
406 | vxsec->floorstat = bakv7sec.floorstat; |
||
407 | vxsec->floorz = bakv7sec.floorz; |
||
408 | vxsec->floorshade = bakv7sec.floorshade; |
||
409 | vxsec->floorpal = bakv7sec.floorpal; |
||
410 | vxsec->floorxpanning = bakv7sec.floorxpanning; |
||
411 | vxsec->floorypanning = bakv7sec.floorypanning; |
||
412 | |||
413 | /* [visibility..extra] */ |
||
414 | Bmemmove(&vxsec->visibility, &bakv7sec.visibility, SECTORVX_SZ4); |
||
3658 | helixhorne | 415 | } |
416 | |||
417 | static inline void inplace_vx_tweak_sector(sectortypevx *vxsec, int32_t yaxp) |
||
418 | { |
||
419 | if (yaxp) |
||
420 | { |
||
421 | int32_t cisext = (vxsec->ceilingstat&YAX_BIT__COMPAT); |
||
422 | int32_t fisext = (vxsec->floorstat&YAX_BIT__COMPAT); |
||
423 | |||
424 | vxsec->ceilingbunch = cisext ? vxsec->ceilingxpanning : -1; |
||
425 | vxsec->floorbunch = fisext ? vxsec->floorxpanning : -1; |
||
426 | |||
427 | if (cisext) |
||
428 | vxsec->ceilingxpanning = 0; |
||
429 | if (fisext) |
||
430 | vxsec->floorxpanning = 0; |
||
431 | } |
||
432 | else |
||
433 | { |
||
434 | vxsec->ceilingbunch = vxsec->floorbunch = -1; |
||
435 | } |
||
436 | |||
437 | /* Clear YAX_BIT of ceiling and floor (map-int VX doesn't use it). */ |
||
438 | vxsec->ceilingstat &= ~YAX_BIT__COMPAT; |
||
439 | vxsec->floorstat &= ~YAX_BIT__COMPAT; |
||
440 | } |
||
441 | |||
3731 | helixhorne | 442 | # undef SECTORVX_SZ1 |
443 | # undef SECTORVX_SZ4 |
||
3658 | helixhorne | 444 | |
4368 | helixhorne | 445 | // 38 bytes |
3658 | helixhorne | 446 | typedef struct |
447 | { |
||
448 | Tracker(Wall, int32_t) x, y; |
||
449 | Tracker(Wall, int16_t) point2, nextwall, nextsector; |
||
450 | Tracker(Wall, int16_t) upwall, dnwall; |
||
451 | Tracker(Wall, uint16_t) cstat; |
||
452 | Tracker(Wall, int16_t) picnum, overpicnum; |
||
453 | Tracker(Wall, int8_t) shade; |
||
454 | Tracker(Wall, uint8_t) pal, xrepeat, yrepeat, xpanning, ypanning; |
||
455 | Tracker(Wall, uint16_t) lotag, hitag; |
||
456 | Tracker(Wall, int16_t) extra; |
||
4368 | helixhorne | 457 | Tracker(Wall, uint8_t) blend, filler_; |
3658 | helixhorne | 458 | } walltypevx; |
459 | |||
4368 | helixhorne | 460 | # define WALLVX_SZ2 offsetof(walltypevx, blend)-offsetof(walltypevx, cstat) |
3658 | helixhorne | 461 | |
462 | static inline void copy_v7_from_vx_wall(walltypev7 *v7wal, const walltypevx *vxwal) |
||
463 | { |
||
464 | /* [x..nextsector] */ |
||
465 | Bmemcpy(v7wal, vxwal, offsetof(walltypevx, upwall)); |
||
466 | /* [cstat..extra] */ |
||
467 | Bmemcpy(&v7wal->cstat, &vxwal->cstat, WALLVX_SZ2); |
||
468 | /* Clear YAX_NEXTWALLBITS. */ |
||
469 | v7wal->cstat &= ~YAX_NEXTWALLBITS__COMPAT; |
||
470 | } |
||
471 | |||
472 | static inline void inplace_vx_from_v7_wall(walltypevx *vxwal) |
||
473 | { |
||
474 | const walltypev7 *v7wal = (walltypev7 *)vxwal; |
||
475 | |||
476 | /* [cstat..extra] */ |
||
477 | Bmemmove(&vxwal->cstat, &v7wal->cstat, WALLVX_SZ2); |
||
4368 | helixhorne | 478 | |
479 | vxwal->blend = vxwal->filler_ = 0; |
||
3658 | helixhorne | 480 | } |
481 | |||
482 | static inline void inplace_vx_tweak_wall(walltypevx *vxwal, int32_t yaxp) |
||
483 | { |
||
484 | if (yaxp) |
||
485 | { |
||
486 | int32_t haveupwall = (vxwal->cstat & YAX_NEXTWALLBIT__COMPAT(YAX_CEILING)); |
||
487 | int32_t havednwall = (vxwal->cstat & YAX_NEXTWALLBIT__COMPAT(YAX_FLOOR)); |
||
488 | |||
489 | vxwal->upwall = haveupwall ? vxwal->lotag : -1; |
||
490 | vxwal->dnwall = havednwall ? vxwal->extra : -1; |
||
491 | |||
492 | if (haveupwall) |
||
493 | vxwal->lotag = 0; |
||
494 | if (havednwall) |
||
495 | vxwal->extra = -1; |
||
496 | } |
||
497 | else |
||
498 | { |
||
499 | vxwal->upwall = vxwal->dnwall = -1; |
||
500 | } |
||
501 | |||
502 | /* Clear YAX_NEXTWALLBITS (map-int VX doesn't use it). */ |
||
503 | vxwal->cstat &= ~YAX_NEXTWALLBITS__COMPAT; |
||
504 | } |
||
505 | |||
506 | # undef WALLVX_SZ2 |
||
507 | |||
508 | // NOTE: spritetype is currently the same for V7/8/9 and VX in-memory map formats. |
||
509 | |||
510 | typedef sectortypevx sectortype; |
||
511 | typedef walltypevx walltype; |
||
4937 | helixhorne | 512 | |
513 | typedef sectortype tsectortype; |
||
514 | typedef walltype twalltype; |
||
515 | typedef spritetype tspritetype; |
||
3658 | helixhorne | 516 | //////////////////// END Lunatic new-generation map format //////////////// |
517 | #else |
||
518 | typedef sectortypev7 sectortype; |
||
519 | typedef walltypev7 walltype; |
||
520 | #endif |
||
521 | |||
1454 | terminx | 522 | typedef struct { |
1205 | terminx | 523 | uint32_t mdanimtims; |
524 | int16_t mdanimcur; |
||
1625 | terminx | 525 | int16_t angoff, pitch, roll; |
4680 | terminx | 526 | vec3_t offset; |
1206 | terminx | 527 | uint8_t flags; |
528 | uint8_t xpanning, ypanning; |
||
1341 | terminx | 529 | uint8_t filler; |
530 | float alpha; |
||
3455 | helixhorne | 531 | // NOTE: keep 'tspr' on an 8-byte boundary: |
4898 | terminx | 532 | tspritetype *tspr; |
2207 | helixhorne | 533 | #if !defined UINTPTR_MAX |
534 | # error Need UINTPTR_MAX define to select between 32- and 64-bit structs |
||
535 | #endif |
||
536 | #if UINTPTR_MAX == 0xffffffff |
||
3188 | helixhorne | 537 | /* On a 32-bit build, pad the struct so it has the same size everywhere. */ |
3116 | hendricks2 | 538 | intptr_t dummy_; |
2148 | helixhorne | 539 | #endif |
1206 | terminx | 540 | } spriteext_t; |
573 | terminx | 541 | |
1454 | terminx | 542 | typedef struct { |
747 | terminx | 543 | float smoothduration; |
1205 | terminx | 544 | int16_t mdcurframe, mdoldframe; |
545 | int16_t mdsmooth; |
||
1206 | terminx | 546 | uint8_t filler[2]; |
547 | } spritesmooth_t; |
||
573 | terminx | 548 | |
549 | #define SPREXT_NOTMD 1 |
||
550 | #define SPREXT_NOMDANIM 2 |
||
587 | terminx | 551 | #define SPREXT_AWAY1 4 |
552 | #define SPREXT_AWAY2 8 |
||
1010 | terminx | 553 | #define SPREXT_TSPRACCESS 16 |
1968 | helixhorne | 554 | #define SPREXT_TEMPINVISIBLE 32 |
853 | terminx | 555 | |
3584 | helixhorne | 556 | #define CSTAT_SPRITE_MDHACK 1024 |
557 | |||
2270 | helixhorne | 558 | EXTERN int32_t guniqhudid; |
559 | EXTERN int32_t spritesortcnt; |
||
3926 | helixhorne | 560 | extern int32_t g_loadedMapVersion; |
2270 | helixhorne | 561 | |
4884 | hendricks2 | 562 | typedef struct { |
563 | char *mhkfile; |
||
564 | char *title; |
||
565 | uint8_t md4[16]; |
||
566 | } usermaphack_t; |
||
4933 | helixhorne | 567 | |
568 | extern usermaphack_t g_loadedMapHack; |
||
4884 | hendricks2 | 569 | extern int32_t compare_usermaphacks(const void *, const void *); |
570 | extern usermaphack_t *usermaphacks; |
||
571 | extern int32_t num_usermaphacks; |
||
572 | |||
2270 | helixhorne | 573 | #if !defined DEBUG_MAIN_ARRAYS |
1206 | terminx | 574 | EXTERN spriteext_t *spriteext; |
575 | EXTERN spritesmooth_t *spritesmooth; |
||
573 | terminx | 576 | |
574 | terminx | 577 | EXTERN sectortype *sector; |
578 | EXTERN walltype *wall; |
||
2270 | helixhorne | 579 | EXTERN spritetype *sprite; |
4898 | terminx | 580 | EXTERN tspritetype *tsprite; |
2270 | helixhorne | 581 | #else |
582 | EXTERN spriteext_t spriteext[MAXSPRITES+MAXUNIQHUDID]; |
||
583 | EXTERN spritesmooth_t spritesmooth[MAXSPRITES+MAXUNIQHUDID]; |
||
584 | |||
585 | EXTERN sectortype sector[MAXSECTORS + M32_FIXME_SECTORS]; |
||
586 | EXTERN walltype wall[MAXWALLS + M32_FIXME_WALLS]; |
||
587 | EXTERN spritetype sprite[MAXSPRITES]; |
||
4958 | helixhorne | 588 | EXTERN tspritetype tsprite[MAXSPRITESONSCREEN]; |
2270 | helixhorne | 589 | #endif |
590 | |||
3234 | Plagman | 591 | EXTERN uint32_t sectorchanged[MAXSECTORS + M32_FIXME_SECTORS]; |
592 | EXTERN uint32_t wallchanged[MAXWALLS + M32_FIXME_WALLS]; |
||
593 | EXTERN uint32_t spritechanged[MAXSPRITES]; |
||
3138 | Plagman | 594 | |
3658 | helixhorne | 595 | #ifdef NEW_MAP_FORMAT |
4898 | terminx | 596 | FORCE_INLINE int16_t yax_getbunch(int16_t i, int16_t cf) |
3658 | helixhorne | 597 | { |
598 | return cf ? sector[i].floorbunch : sector[i].ceilingbunch; |
||
599 | } |
||
600 | |||
4898 | terminx | 601 | FORCE_INLINE void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb) |
3658 | helixhorne | 602 | { |
603 | *cb = yax_getbunch(i, YAX_CEILING); |
||
604 | *fb = yax_getbunch(i, YAX_FLOOR); |
||
605 | } |
||
606 | |||
4898 | terminx | 607 | FORCE_INLINE int16_t yax_getnextwall(int16_t wal, int16_t cf) |
3658 | helixhorne | 608 | { |
609 | return cf ? wall[wal].dnwall : wall[wal].upwall; |
||
610 | } |
||
611 | |||
4898 | terminx | 612 | FORCE_INLINE void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall) |
3658 | helixhorne | 613 | { |
614 | YAX_NEXTWALL(wal, cf) = thenextwall; |
||
615 | } |
||
616 | #endif |
||
617 | |||
4898 | terminx | 618 | FORCE_INLINE void sector_tracker_hook(uintptr_t address) |
3138 | Plagman | 619 | { |
4898 | terminx | 620 | uintptr_t const usector = address - (uintptr_t)sector; |
4680 | terminx | 621 | |
4898 | terminx | 622 | #if DEBUGGINGAIDS |
623 | Bassert(usector < ((MAXSECTORS + M32_FIXME_SECTORS) * sizeof(sectortype))); |
||
624 | #endif |
||
4680 | terminx | 625 | |
4898 | terminx | 626 | sectorchanged[usector / sizeof(sectortype)]++; |
3138 | Plagman | 627 | } |
628 | |||
4898 | terminx | 629 | FORCE_INLINE void wall_tracker_hook(uintptr_t address) |
3138 | Plagman | 630 | { |
4898 | terminx | 631 | uintptr_t const uwall = address - (uintptr_t)wall; |
4680 | terminx | 632 | |
4898 | terminx | 633 | #if DEBUGGINGAIDS |
634 | Bassert(uwall < ((MAXWALLS + M32_FIXME_WALLS) * sizeof(walltype))); |
||
635 | #endif |
||
4680 | terminx | 636 | |
4898 | terminx | 637 | wallchanged[uwall / sizeof(walltype)]++; |
3138 | Plagman | 638 | } |
639 | |||
4898 | terminx | 640 | FORCE_INLINE void sprite_tracker_hook(uintptr_t address) |
3138 | Plagman | 641 | { |
4898 | terminx | 642 | uintptr_t const usprite = address - (uintptr_t)sprite; |
3138 | Plagman | 643 | |
4898 | terminx | 644 | #if DEBUGGINGAIDS |
645 | Bassert(usprite < (MAXSPRITES * sizeof(spritetype))); |
||
646 | #endif |
||
4680 | terminx | 647 | |
4898 | terminx | 648 | spritechanged[usprite / sizeof(spritetype)]++; |
3138 | Plagman | 649 | } |
650 | |||
4680 | terminx | 651 | |
1205 | terminx | 652 | EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt; |
653 | EXTERN int16_t thewall[MAXWALLSB]; |
||
4898 | terminx | 654 | EXTERN tspritetype *tspriteptr[MAXSPRITESONSCREEN + 1]; |
573 | terminx | 655 | |
1205 | terminx | 656 | EXTERN int32_t xdim, ydim, numpages; |
657 | EXTERN int32_t yxaspect, viewingrange; |
||
4695 | terminx | 658 | EXTERN intptr_t *ylookup; |
573 | terminx | 659 | |
4472 | hendricks2 | 660 | #ifndef GEKKO |
573 | terminx | 661 | #define MAXVALIDMODES 256 |
4472 | hendricks2 | 662 | #else |
663 | #define MAXVALIDMODES 16 |
||
664 | #endif |
||
1205 | terminx | 665 | EXTERN int32_t validmodecnt; |
573 | terminx | 666 | struct validmode_t { |
1205 | terminx | 667 | int32_t xdim,ydim; |
573 | terminx | 668 | char bpp; |
669 | char fs; // bit 0 = fullscreen flag |
||
670 | char filler[2]; |
||
1205 | terminx | 671 | int32_t extra; // internal use |
573 | terminx | 672 | }; |
673 | EXTERN struct validmode_t validmode[MAXVALIDMODES]; |
||
674 | |||
1854 | helixhorne | 675 | EXTERN int32_t numyaxbunches; |
676 | #ifdef YAX_ENABLE |
||
677 | // Singly-linked list of sectnums grouped by bunches and ceiling (0)/floor (1) |
||
678 | // Usage e.g.: |
||
679 | // int16_t bunchnum = yax_getbunch(somesector, YAX_CEILING); |
||
680 | // Iteration over all sectors whose floor bunchnum equals 'bunchnum' (i.e. "all |
||
681 | // floors of the other side"): |
||
682 | // for (i=headsectbunch[1][bunchnum]; i!=-1; i=nextsectbunch[1][i]) |
||
683 | // <do stuff with sector i...> |
||
684 | |||
685 | EXTERN int16_t headsectbunch[2][YAX_MAXBUNCHES], nextsectbunch[2][MAXSECTORS]; |
||
686 | #endif |
||
687 | |||
2478 | helixhorne | 688 | EXTERN int32_t Numsprites; |
1205 | terminx | 689 | EXTERN int16_t numsectors, numwalls; |
701 | plagman | 690 | EXTERN char display_mirror; |
4450 | helixhorne | 691 | // totalclocklock: the totalclock value that is backed up once on each |
692 | // drawrooms() and is used for animateoffs(). |
||
693 | EXTERN int32_t totalclock, totalclocklock; |
||
4558 | hendricks2 | 694 | static inline int32_t BGetTime(void) { return totalclock; } |
695 | |||
1205 | terminx | 696 | EXTERN int32_t numframes, randomseed; |
697 | EXTERN int16_t sintable[2048]; |
||
1206 | terminx | 698 | EXTERN uint8_t palette[768]; |
2504 | helixhorne | 699 | EXTERN int16_t numshades; |
573 | terminx | 700 | EXTERN char *palookup[MAXPALOOKUPS]; |
3729 | Plagman | 701 | EXTERN uint8_t **basepaltableptr; |
3975 | helixhorne | 702 | EXTERN char showinvisibility; |
3287 | helixhorne | 703 | EXTERN int32_t g_visibility, parallaxvisibility; |
3284 | helixhorne | 704 | EXTERN int32_t g_rotatespriteNoWidescreen; |
573 | terminx | 705 | |
1205 | terminx | 706 | EXTERN int32_t windowx1, windowy1, windowx2, windowy2; |
4695 | terminx | 707 | EXTERN int16_t *startumost, *startdmost; |
573 | terminx | 708 | |
3975 | helixhorne | 709 | // The maximum tile offset ever used in any tiled parallaxed multi-sky. |
710 | #define PSKYOFF_MAX 4 |
||
573 | terminx | 711 | |
3975 | helixhorne | 712 | typedef struct { |
713 | // The proportion at which looking up/down affects the apparent 'horiz' of |
||
714 | // a parallaxed sky, scaled by 65536 (so, a value of 65536 makes it align |
||
715 | // with the drawn surrounding scene): |
||
716 | int32_t horizfrac; |
||
717 | |||
718 | // The texel index offset in the y direction of a parallaxed sky: |
||
719 | // XXX: currently always 0. |
||
720 | int32_t yoffs; |
||
721 | |||
4171 | helixhorne | 722 | int8_t lognumtiles; // 1<<lognumtiles: number of tiles in multi-sky |
723 | int8_t tileofs[MAXPSKYTILES]; // for 0 <= j < (1<<lognumtiles): tile offset relative to basetile |
||
3975 | helixhorne | 724 | } psky_t; |
725 | |||
3976 | helixhorne | 726 | // Index of map-global (legacy) multi-sky: |
727 | EXTERN int32_t g_pskyidx; |
||
3975 | helixhorne | 728 | // New multi-psky -- up to MAXPSKYMULTIS (effectively constant after initialization): |
729 | EXTERN int32_t pskynummultis; |
||
730 | EXTERN psky_t multipsky[MAXPSKYMULTIS]; |
||
731 | // Mapping of multi-sky index to base sky tile number: |
||
732 | EXTERN int32_t multipskytile[MAXPSKYMULTIS]; |
||
733 | |||
4898 | terminx | 734 | FORCE_INLINE int32_t getpskyidx(int32_t picnum) |
4006 | helixhorne | 735 | { |
736 | int32_t j; |
||
737 | |||
738 | for (j=pskynummultis; j>0; j--) // NOTE: j==0 on non-early loop end |
||
739 | if (picnum == multipskytile[j]) |
||
740 | break; // Have a match. |
||
741 | |||
742 | return j; |
||
743 | } |
||
744 | |||
3975 | helixhorne | 745 | EXTERN char parallaxtype; |
746 | |||
2470 | helixhorne | 747 | // last sprite in the freelist, that is the spritenum for which |
748 | // .statnum==MAXSTATUS && nextspritestat[spritenum]==-1 |
||
749 | // (or -1 if freelist is empty): |
||
750 | EXTERN int16_t tailspritefree; |
||
751 | |||
1205 | terminx | 752 | EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; |
753 | EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; |
||
754 | EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; |
||
573 | terminx | 755 | |
4623 | terminx | 756 | EXTERN vec2_t tilesiz[MAXTILES]; |
757 | |||
573 | terminx | 758 | EXTERN char picsiz[MAXTILES]; |
759 | EXTERN char walock[MAXTILES]; |
||
3326 | helixhorne | 760 | extern const char pow2char[8]; |
761 | extern const int32_t pow2long[32]; |
||
3202 | helixhorne | 762 | |
763 | // picanm[].sf: |
||
764 | // |bit(1<<7) |
||
765 | // |animtype|animtype|texhitscan|nofullbright|speed|speed|speed|speed| |
||
766 | enum { |
||
767 | PICANM_ANIMTYPE_NONE = 0, |
||
768 | PICANM_ANIMTYPE_OSC = (1<<6), |
||
769 | PICANM_ANIMTYPE_FWD = (2<<6), |
||
770 | PICANM_ANIMTYPE_BACK = (3<<6), |
||
771 | |||
772 | PICANM_ANIMTYPE_SHIFT = 6, |
||
773 | PICANM_ANIMTYPE_MASK = (3<<6), // must be 192 |
||
774 | PICANM_MISC_MASK = (3<<4), |
||
775 | PICANM_TEXHITSCAN_BIT = (2<<4), |
||
776 | PICANM_NOFULLBRIGHT_BIT = (1<<4), |
||
777 | PICANM_ANIMSPEED_MASK = 15, // must be 15 |
||
778 | }; |
||
779 | |||
780 | // NOTE: If the layout of this struct is changed, loadpics() must be modified |
||
781 | // accordingly. |
||
782 | typedef struct { |
||
783 | uint8_t num; // animate number |
||
784 | int8_t xofs, yofs; |
||
785 | uint8_t sf; // anim. speed and flags |
||
786 | } picanm_t; |
||
787 | EXTERN picanm_t picanm[MAXTILES]; |
||
618 | terminx | 788 | EXTERN intptr_t waloff[MAXTILES]; // stores pointers to cache -- SA |
573 | terminx | 789 | |
1205 | terminx | 790 | EXTERN int32_t windowpos, windowx, windowy; |
573 | terminx | 791 | |
792 | //These variables are for auto-mapping with the draw2dscreen function. |
||
793 | //When you load a new board, these bits are all set to 0 - since |
||
794 | //you haven't mapped out anything yet. Note that these arrays are |
||
795 | //bit-mapped. |
||
796 | //If you want draw2dscreen() to show sprite #54 then you say: |
||
797 | // spritenum = 54; |
||
798 | // show2dsprite[spritenum>>3] |= (1<<(spritenum&7)); |
||
799 | //And if you want draw2dscreen() to not show sprite #54 then you say: |
||
800 | // spritenum = 54; |
||
801 | // show2dsprite[spritenum>>3] &= ~(1<<(spritenum&7)); |
||
802 | |||
803 | EXTERN char show2dsector[(MAXSECTORS+7)>>3]; |
||
804 | EXTERN char show2dwall[(MAXWALLS+7)>>3]; |
||
805 | EXTERN char show2dsprite[(MAXSPRITES+7)>>3]; |
||
806 | |||
3136 | Plagman | 807 | // In the editor, gotpic is only referenced from inline assembly; |
808 | // the compiler needs that hint or building with LTO will discard it. |
||
4543 | hendricks2 | 809 | #if !defined __clang__ && !defined NOASM |
3162 | hendricks2 | 810 | # define GOTPIC_USED ATTRIBUTE((used)) |
811 | #else |
||
812 | # define GOTPIC_USED |
||
813 | #endif |
||
814 | |||
815 | EXTERN char GOTPIC_USED gotpic[(MAXTILES+7)>>3]; |
||
573 | terminx | 816 | EXTERN char gotsector[(MAXSECTORS+7)>>3]; |
817 | |||
1190 | terminx | 818 | EXTERN char editorcolors[256]; |
819 | |||
1544 | terminx | 820 | EXTERN int32_t faketilesiz[MAXTILES]; |
821 | EXTERN char *faketiledata[MAXTILES]; |
||
822 | |||
823 | EXTERN char spritecol2d[MAXTILES][2]; |
||
824 | extern char vgapal16[4*256]; |
||
825 | |||
1205 | terminx | 826 | extern uint32_t drawlinepat; |
573 | terminx | 827 | |
828 | extern void faketimerhandler(void); |
||
829 | |||
830 | extern char apptitle[256]; |
||
831 | typedef struct { |
||
1205 | terminx | 832 | char r,g,b,f; |
573 | terminx | 833 | } palette_t; |
834 | extern palette_t curpalette[256], curpalettefaded[256], palfadergb; |
||
835 | extern char palfadedelta; |
||
836 | |||
4811 | helixhorne | 837 | extern int8_t g_noFloorPal[MAXPALOOKUPS]; |
838 | |||
2391 | helixhorne | 839 | extern int32_t novoxmips; |
573 | terminx | 840 | |
3349 | terminx | 841 | #ifdef DEBUGGINGAIDS |
1702 | plagman | 842 | extern float debug1, debug2; |
3349 | terminx | 843 | #endif |
1702 | plagman | 844 | |
2266 | helixhorne | 845 | extern int16_t tiletovox[MAXTILES]; |
1205 | terminx | 846 | extern int32_t usevoxels, voxscale[MAXVOXELS]; |
1820 | terminx | 847 | |
848 | #ifdef USE_OPENGL |
||
1205 | terminx | 849 | extern int32_t usemodels, usehightile; |
850 | extern int32_t rendmode; |
||
573 | terminx | 851 | #endif |
1205 | terminx | 852 | EXTERN int32_t h_xsize[MAXTILES], h_ysize[MAXTILES]; |
853 | EXTERN int8_t h_xoffs[MAXTILES], h_yoffs[MAXTILES]; |
||
573 | terminx | 854 | |
5056 | hendricks2 | 855 | enum { |
856 | GLOBAL_NO_GL_TILESHADES = 1<<0, |
||
857 | GLOBAL_NO_GL_FULLBRIGHT = 1<<1, |
||
858 | }; |
||
859 | |||
860 | extern int32_t globalflags; |
||
861 | |||
1799 | helixhorne | 862 | extern const char *engineerrstr; |
573 | terminx | 863 | |
1205 | terminx | 864 | EXTERN int32_t editorzrange[2]; |
1121 | terminx | 865 | |
4898 | terminx | 866 | FORCE_INLINE int32_t getrendermode(void) |
1228 | terminx | 867 | { |
1820 | terminx | 868 | #ifndef USE_OPENGL |
3347 | terminx | 869 | return REND_CLASSIC; |
1228 | terminx | 870 | #else |
871 | return rendmode; |
||
872 | #endif |
||
873 | } |
||
874 | |||
573 | terminx | 875 | /************************************************************************* |
876 | POSITION VARIABLES: |
||
877 | |||
878 | POSX is your x - position ranging from 0 to 65535 |
||
879 | POSY is your y - position ranging from 0 to 65535 |
||
880 | (the length of a side of the grid in EDITBORD would be 1024) |
||
881 | POSZ is your z - position (height) ranging from 0 to 65535, 0 highest. |
||
882 | ANG is your angle ranging from 0 to 2047. Instead of 360 degrees, or |
||
883 | 2 * PI radians, I use 2048 different angles, so 90 degrees would |
||
884 | be 512 in my system. |
||
885 | |||
886 | SPRITE VARIABLES: |
||
887 | |||
888 | EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1]; |
||
889 | EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES]; |
||
890 | EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES]; |
||
891 | |||
892 | Example: if the linked lists look like the following: |
||
1540 | terminx | 893 | ???????????????? |
573 | terminx | 894 | Sector lists: Status lists: |
1540 | terminx | 895 | ????????????????J |
573 | terminx | 896 | Sector0: 4, 5, 8 Status0: 2, 0, 8 |
897 | Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9 |
||
898 | Sector2: 3, 9 |
||
1540 | terminx | 899 | ???????????????? |
573 | terminx | 900 | Notice that each number listed above is shown exactly once on both the |
901 | left and right side. This is because any sprite that exists must |
||
902 | be in some sector, and must have some kind of status that you define. |
||
903 | |||
904 | |||
905 | Coding example #1: |
||
906 | To go through all the sprites in sector 1, the code can look like this: |
||
907 | |||
908 | sectnum = 1; |
||
909 | i = headspritesect[sectnum]; |
||
910 | while (i != -1) |
||
911 | { |
||
912 | nexti = nextspritesect[i]; |
||
913 | |||
914 | //your code goes here |
||
915 | //ex: printf("Sprite %d is in sector %d\n",i,sectnum); |
||
916 | |||
917 | i = nexti; |
||
918 | } |
||
919 | |||
920 | Coding example #2: |
||
921 | To go through all sprites with status = 1, the code can look like this: |
||
922 | |||
923 | statnum = 1; //status 1 |
||
924 | i = headspritestat[statnum]; |
||
925 | while (i != -1) |
||
926 | { |
||
927 | nexti = nextspritestat[i]; |
||
928 | |||
929 | //your code goes here |
||
930 | //ex: printf("Sprite %d has a status of 1 (active)\n",i,statnum); |
||
931 | |||
932 | i = nexti; |
||
933 | } |
||
934 | |||
935 | insertsprite(short sectnum, short statnum); |
||
936 | deletesprite(short spritenum); |
||
937 | changespritesect(short spritenum, short newsectnum); |
||
938 | changespritestat(short spritenum, short newstatnum); |
||
939 | |||
940 | TILE VARIABLES: |
||
941 | NUMTILES - the number of tiles found TILES.DAT. |
||
942 | TILESIZX[MAXTILES] - simply the x-dimension of the tile number. |
||
943 | TILESIZY[MAXTILES] - simply the y-dimension of the tile number. |
||
2471 | helixhorne | 944 | WALOFF[MAXTILES] - the actual address pointing to the top-left |
573 | terminx | 945 | corner of the tile. |
946 | PICANM[MAXTILES] - flags for animating the tile. |
||
947 | |||
948 | TIMING VARIABLES: |
||
949 | TOTALCLOCK - When the engine is initialized, TOTALCLOCK is set to zero. |
||
950 | From then on, it is incremented 120 times a second by 1. That |
||
951 | means that the number of seconds elapsed is totalclock / 120. |
||
952 | NUMFRAMES - The number of times the draw3dscreen function was called |
||
953 | since the engine was initialized. This helps to determine frame |
||
954 | rate. (Frame rate = numframes * 120 / totalclock.) |
||
955 | |||
956 | OTHER VARIABLES: |
||
957 | |||
958 | STARTUMOST[320] is an array of the highest y-coordinates on each column |
||
959 | that my engine is allowed to write to. You need to set it only |
||
960 | once. |
||
961 | STARTDMOST[320] is an array of the lowest y-coordinates on each column |
||
962 | that my engine is allowed to write to. You need to set it only |
||
963 | once. |
||
964 | SINTABLE[2048] is a sin table with 2048 angles rather than the |
||
965 | normal 360 angles for higher precision. Also since SINTABLE is in |
||
966 | all integers, the range is multiplied by 16383, so instead of the |
||
967 | normal -1<sin(x)<1, the range of sintable is -16383<sintable[]<16383 |
||
968 | If you use this sintable, you can possibly speed up your code as |
||
969 | well as save space in memory. If you plan to use sintable, 2 |
||
970 | identities you may want to keep in mind are: |
||
971 | sintable[ang&2047] = sin(ang * (3.141592/1024)) * 16383 |
||
972 | sintable[(ang+512)&2047] = cos(ang * (3.141592/1024)) * 16383 |
||
973 | NUMSECTORS - the total number of existing sectors. Modified every time |
||
974 | you call the loadboard function. |
||
975 | ***************************************************************************/ |
||
976 | |||
1454 | terminx | 977 | typedef struct { |
1208 | terminx | 978 | vec3_t pos; |
2877 | helixhorne | 979 | int16_t sprite, wall, sect; |
1208 | terminx | 980 | } hitdata_t; |
981 | |||
1465 | terminx | 982 | |
1205 | terminx | 983 | int32_t preinitengine(void); // a partial setup of the engine used for launch windows |
984 | int32_t initengine(void); |
||
573 | terminx | 985 | void uninitengine(void); |
986 | void initspritelists(void); |
||
4564 | hendricks2 | 987 | int32_t loadlookups(int32_t fp); |
4811 | helixhorne | 988 | void generatefogpals(void); |
4564 | hendricks2 | 989 | void fillemptylookups(void); |
3913 | helixhorne | 990 | int32_t loadboard(const char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum); |
1760 | helixhorne | 991 | int32_t loadmaphack(const char *filename); |
992 | void delete_maphack_lights(); |
||
2495 | hendricks2 | 993 | #ifdef HAVE_CLIPSHAPE_FEATURE |
994 | int32_t clipmapinfo_load(void); |
||
2270 | helixhorne | 995 | #endif |
3042 | helixhorne | 996 | int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum); |
3202 | helixhorne | 997 | void set_tilesiz(int32_t picnum, int16_t dasizx, int16_t dasizy); |
3606 | hendricks2 | 998 | int32_t tile_exists(int32_t picnum); |
1760 | helixhorne | 999 | int32_t loadpics(const char *filename, int32_t askedsize); |
4257 | helixhorne | 1000 | void E_MapArt_Clear(void); |
1001 | void E_MapArt_Setup(const char *filename); |
||
1205 | terminx | 1002 | void loadtile(int16_t tilenume); |
1760 | helixhorne | 1003 | int32_t qloadkvx(int32_t voxindex, const char *filename); |
2697 | helixhorne | 1004 | intptr_t allocatepermanenttile(int16_t tilenume, int32_t xsiz, int32_t ysiz); |
4555 | hendricks2 | 1005 | 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); |
4812 | helixhorne | 1006 | void makepalookup(int32_t palnum, const char *remapbuf, int8_t r, int8_t g, int8_t b, char noFloorPal); |
2014 | helixhorne | 1007 | //void setvgapalette(void); |
1781 | plagman | 1008 | void setbasepaltable(uint8_t **basepaltable, uint8_t basepalcount); |
2224 | helixhorne | 1009 | void setbrightness(char dabrightness, uint8_t dapalid, uint8_t flags); |
573 | terminx | 1010 | void setpalettefade(char r, char g, char b, char offset); |
1205 | terminx | 1011 | void squarerotatetile(int16_t tilenume); |
2312 | helixhorne | 1012 | void fade_screen_black(int32_t moreopaquep); |
573 | terminx | 1013 | |
1205 | terminx | 1014 | int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t dabpp); |
573 | terminx | 1015 | void nextpage(void); |
1712 | helixhorne | 1016 | void setaspect_new(); |
1205 | terminx | 1017 | void setview(int32_t x1, int32_t y1, int32_t x2, int32_t y2); |
1018 | void setaspect(int32_t daxrange, int32_t daaspect); |
||
573 | terminx | 1019 | void flushperms(void); |
1020 | |||
1801 | helixhorne | 1021 | void plotlines2d(const int32_t *xx, const int32_t *yy, int32_t numpoints, char col) ATTRIBUTE((nonnull(1,2))); |
1695 | helixhorne | 1022 | |
1205 | terminx | 1023 | void plotpixel(int32_t x, int32_t y, char col); |
1024 | char getpixel(int32_t x, int32_t y); |
||
1025 | void setviewtotile(int16_t tilenume, int32_t xsiz, int32_t ysiz); |
||
573 | terminx | 1026 | void setviewback(void); |
3719 | helixhorne | 1027 | void preparemirror(int32_t dax, int32_t day, int16_t daang, int16_t dawall, |
1028 | int32_t *tposx, int32_t *tposy, int16_t *tang); |
||
573 | terminx | 1029 | void completemirror(void); |
1030 | |||
2896 | helixhorne | 1031 | int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, |
1032 | int16_t daang, int32_t dahoriz, int16_t dacursectnum); |
||
573 | terminx | 1033 | void drawmasks(void); |
1205 | terminx | 1034 | void clearview(int32_t dacol); |
1035 | void clearallviews(int32_t dacol); |
||
1036 | void drawmapview(int32_t dax, int32_t day, int32_t zoome, int16_t ang); |
||
3609 | hendricks2 | 1037 | void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, |
4360 | helixhorne | 1038 | int8_t dashade, char dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend, |
1039 | int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2); |
||
1205 | terminx | 1040 | void drawline256(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col); |
2896 | helixhorne | 1041 | int32_t printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, |
1042 | const char *name, char fontsize) ATTRIBUTE((nonnull(5))); |
||
1043 | void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol, |
||
1044 | const char *name, char fontsize) ATTRIBUTE((nonnull(5))); |
||
573 | terminx | 1045 | |
2308 | helixhorne | 1046 | ////////// specialized rotatesprite wrappers for (very) often used cases ////////// |
4898 | terminx | 1047 | FORCE_INLINE void rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, |
3609 | hendricks2 | 1048 | int8_t dashade, char dapalnum, int32_t dastat, |
1049 | int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2) |
||
1050 | { |
||
4360 | helixhorne | 1051 | rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, cx1, cy1, cx2, cy2); |
3609 | hendricks2 | 1052 | } |
3639 | helixhorne | 1053 | // Don't clip at all, i.e. the whole screen real estate is available: |
4898 | terminx | 1054 | FORCE_INLINE void rotatesprite_fs(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, |
2896 | helixhorne | 1055 | int8_t dashade, char dapalnum, int32_t dastat) |
2308 | helixhorne | 1056 | { |
4360 | helixhorne | 1057 | rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, 0,0,xdim-1,ydim-1); |
2308 | helixhorne | 1058 | } |
1059 | |||
4919 | terminx | 1060 | FORCE_INLINE void rotatesprite_fs_alpha(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, |
1061 | int8_t dashade, char dapalnum, int32_t dastat, uint8_t alpha) |
||
1062 | { |
||
1063 | rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, alpha, 0, 0, 0, xdim-1, ydim-1); |
||
1064 | } |
||
1065 | |||
4898 | terminx | 1066 | FORCE_INLINE void rotatesprite_win(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum, |
2896 | helixhorne | 1067 | int8_t dashade, char dapalnum, int32_t dastat) |
2318 | helixhorne | 1068 | { |
4360 | helixhorne | 1069 | rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, windowx1,windowy1,windowx2,windowy2); |
2318 | helixhorne | 1070 | } |
1071 | |||
2256 | helixhorne | 1072 | void bfirst_search_init(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int32_t maxnum, int16_t firstelt); |
1073 | void bfirst_search_try(int16_t *list, uint8_t *bitmap, int32_t *eltnumptr, int16_t elt); |
||
1074 | |||
2896 | helixhorne | 1075 | int32_t clipmove(vec3_t *vect, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist, |
1076 | int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2))); |
||
3811 | helixhorne | 1077 | int32_t clipmovex(vec3_t *pos, int16_t *sectnum, int32_t xvect, int32_t yvect, |
1078 | int32_t walldist, int32_t ceildist, int32_t flordist, uint32_t cliptype, |
||
1079 | uint8_t noslidep) ATTRIBUTE((nonnull(1,2))); |
||
1205 | terminx | 1080 | int32_t clipinsidebox(int32_t x, int32_t y, int16_t wallnum, int32_t walldist); |
2896 | helixhorne | 1081 | int32_t clipinsideboxline(int32_t x, int32_t y, int32_t x1, int32_t y1, |
1082 | int32_t x2, int32_t y2, int32_t walldist); |
||
1083 | int32_t pushmove(vec3_t *vect, int16_t *sectnum, int32_t walldist, |
||
1084 | int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2))); |
||
1085 | void getzrange(const vec3_t *vect, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz, |
||
1086 | int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6))); |
||
1087 | int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32_t vz, |
||
1088 | hitdata_t *hitinfo, uint32_t cliptype) ATTRIBUTE((nonnull(1,6))); |
||
2373 | helixhorne | 1089 | void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, |
1090 | int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite, |
||
1091 | int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch, |
||
1092 | int32_t (*blacklist_sprite_func)(int32_t)) ATTRIBUTE((nonnull(6,7,8))); |
||
2896 | helixhorne | 1093 | int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, |
1094 | int32_t x2, int32_t y2, int32_t z2, int16_t sect2); |
||
1740 | helixhorne | 1095 | void updatesector(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3))); |
3037 | helixhorne | 1096 | void updatesectorbreadth(int32_t x, int32_t y, int16_t *sectnum) ATTRIBUTE((nonnull(3))); |
2896 | helixhorne | 1097 | void updatesectorexclude(int32_t x, int32_t y, int16_t *sectnum, |
3037 | helixhorne | 1098 | const uint8_t *excludesectbitmap) ATTRIBUTE((nonnull(3,4))); |
1740 | helixhorne | 1099 | void updatesectorz(int32_t x, int32_t y, int32_t z, int16_t *sectnum) ATTRIBUTE((nonnull(4))); |
1205 | terminx | 1100 | int32_t inside(int32_t x, int32_t y, int16_t sectnum); |
3394 | helixhorne | 1101 | void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags); |
1205 | terminx | 1102 | void setfirstwall(int16_t sectnum, int16_t newfirstwall); |
1886 | helixhorne | 1103 | |
1104 | extern const int16_t *chsecptr_onextwall; |
||
1760 | helixhorne | 1105 | int32_t checksectorpointer(int16_t i, int16_t sectnum); |
573 | terminx | 1106 | |
1740 | helixhorne | 1107 | void getmousevalues(int32_t *mousx, int32_t *mousy, int32_t *bstatus) ATTRIBUTE((nonnull(1,2,3))); |
4744 | terminx | 1108 | |
4759 | helixhorne | 1109 | #if !KRANDDEBUG && !defined LUNATIC |
4744 | terminx | 1110 | FORCE_INLINE int32_t krand(void) |
1111 | { |
||
1112 | randomseed = (randomseed * 1664525ul) + 221297ul; |
||
1113 | return ((uint32_t) randomseed)>>16; |
||
1114 | } |
||
1115 | #else |
||
1205 | terminx | 1116 | int32_t krand(void); |
4744 | terminx | 1117 | #endif |
1118 | |||
2791 | helixhorne | 1119 | int32_t ksqrt(uint32_t num); |
2991 | helixhorne | 1120 | int32_t __fastcall getangle(int32_t xvect, int32_t yvect); |
1230 | terminx | 1121 | |
4898 | terminx | 1122 | FORCE_INLINE uint32_t uhypsq(int32_t dx, int32_t dy) |
2791 | helixhorne | 1123 | { |
1124 | return (uint32_t)dx*dx + (uint32_t)dy*dy; |
||
1125 | } |
||
1126 | |||
4898 | terminx | 1127 | FORCE_INLINE int32_t logapproach(int32_t val, int32_t targetval) |
4392 | helixhorne | 1128 | { |
1129 | int32_t dif = targetval - val; |
||
1130 | return (dif>>1) ? val + (dif>>1) : targetval; |
||
1131 | } |
||
1132 | |||
2896 | helixhorne | 1133 | void rotatepoint(int32_t xpivot, int32_t ypivot, int32_t x, int32_t y, |
1134 | int16_t daang, int32_t *x2, int32_t *y2) ATTRIBUTE((nonnull(6,7))); |
||
1205 | terminx | 1135 | int32_t lastwall(int16_t point); |
4395 | helixhorne | 1136 | int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction); |
3323 | helixhorne | 1137 | |
1138 | int32_t getceilzofslopeptr(const sectortype *sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1))); |
||
1139 | int32_t getflorzofslopeptr(const sectortype *sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1))); |
||
1140 | void getzsofslopeptr(const sectortype *sec, int32_t dax, int32_t day, |
||
1141 | int32_t *ceilz, int32_t *florz) ATTRIBUTE((nonnull(1,4,5))); |
||
1142 | |||
4898 | terminx | 1143 | FORCE_INLINE int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day) |
3323 | helixhorne | 1144 | { |
1145 | return getceilzofslopeptr(§or[sectnum], dax, day); |
||
1146 | } |
||
1147 | |||
4898 | terminx | 1148 | FORCE_INLINE int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day) |
3323 | helixhorne | 1149 | { |
1150 | return getflorzofslopeptr(§or[sectnum], dax, day); |
||
1151 | } |
||
1152 | |||
4898 | terminx | 1153 | FORCE_INLINE void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) |
3323 | helixhorne | 1154 | { |
1155 | getzsofslopeptr(§or[sectnum], dax, day, ceilz, florz); |
||
1156 | } |
||
1157 | |||
3686 | helixhorne | 1158 | // Is <wal> a red wall in a safe fashion, i.e. only if consistency invariant |
1159 | // ".nextsector >= 0 iff .nextwall >= 0" holds. |
||
4898 | terminx | 1160 | FORCE_INLINE int32_t redwallp(const walltype *wal) |
3362 | helixhorne | 1161 | { |
1162 | return (wal->nextwall >= 0 && wal->nextsector >= 0); |
||
1163 | } |
||
1164 | |||
4898 | terminx | 1165 | FORCE_INLINE int32_t E_SpriteIsValid(const int32_t i) |
4281 | helixhorne | 1166 | { |
1167 | return ((unsigned)i < MAXSPRITES && sprite[i].statnum != MAXSTATUS); |
||
1168 | } |
||
1169 | |||
4574 | helixhorne | 1170 | int32_t clipshape_idx_for_sprite(spritetype *curspr, int32_t curidx); |
1171 | |||
1205 | terminx | 1172 | void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z); |
1173 | void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z); |
||
1174 | int32_t sectorofwall(int16_t theline); |
||
1790 | helixhorne | 1175 | int32_t sectorofwall_noquick(int16_t theline); |
1205 | terminx | 1176 | int32_t loopnumofsector(int16_t sectnum, int16_t wallnum); |
1866 | helixhorne | 1177 | void setslope(int32_t sectnum, int32_t cf, int16_t slope); |
573 | terminx | 1178 | |
4903 | terminx | 1179 | int32_t lintersect(int32_t x1, int32_t y1, int32_t z1, int32_t x2, int32_t y2, int32_t z2, int32_t x3, |
1708 | helixhorne | 1180 | int32_t y3, int32_t x4, int32_t y4, int32_t *intx, int32_t *inty, int32_t *intz); |
1181 | |||
1182 | int32_t rayintersect(int32_t x1, int32_t y1, int32_t z1, int32_t vx, int32_t vy, int32_t vz, int32_t x3, |
||
1183 | int32_t y3, int32_t x4, int32_t y4, int32_t *intx, int32_t *inty, int32_t *intz); |
||
4233 | helixhorne | 1184 | #if !defined NETCODE_DISABLE |
3443 | terminx | 1185 | void do_insertsprite_at_headofstat(int16_t spritenum, int16_t statnum); |
1186 | int32_t insertspritestat(int16_t statnum); |
||
1187 | void do_insertsprite_at_headofsect(int16_t spritenum, int16_t sectnum); |
||
1188 | void do_deletespritesect(int16_t deleteme); |
||
4233 | helixhorne | 1189 | #endif |
2465 | helixhorne | 1190 | int32_t insertsprite(int16_t sectnum, int16_t statnum); |
1191 | int32_t deletesprite(int16_t spritenum); |
||
1230 | terminx | 1192 | |
1205 | terminx | 1193 | int32_t changespritesect(int16_t spritenum, int16_t newsectnum); |
1194 | int32_t changespritestat(int16_t spritenum, int16_t newstatnum); |
||
3116 | hendricks2 | 1195 | int32_t setsprite(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2))); |
1196 | int32_t setspritez(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2))); |
||
573 | terminx | 1197 | |
3228 | helixhorne | 1198 | int32_t spriteheightofsptr(const spritetype *spr, int32_t *height, int32_t alsotileyofs); |
4898 | terminx | 1199 | FORCE_INLINE int32_t spriteheightofs(int16_t i, int32_t *height, int32_t alsotileyofs) |
3228 | helixhorne | 1200 | { |
1201 | return spriteheightofsptr(&sprite[i], height, alsotileyofs); |
||
1202 | } |
||
1816 | helixhorne | 1203 | |
1852 | helixhorne | 1204 | int32_t screencapture(const char *filename, char inverseit, const char *versionstr) ATTRIBUTE((nonnull(1))); |
573 | terminx | 1205 | |
4766 | hendricks2 | 1206 | int32_t getclosestcol_lim(int32_t r, int32_t g, int32_t b, int32_t lastokcol); |
1207 | |||
4898 | terminx | 1208 | FORCE_INLINE int32_t getclosestcol(int32_t r, int32_t g, int32_t b) |
4308 | helixhorne | 1209 | { |
1210 | return getclosestcol_lim(r, g, b, 255); |
||
1211 | } |
||
1212 | |||
573 | terminx | 1213 | // PLAG: line utility functions |
1214 | typedef struct s_equation { |
||
1215 | float a, b, c; |
||
1216 | } _equation; |
||
1394 | plagman | 1217 | int32_t wallvisible(int32_t x, int32_t y, int16_t wallnum); |
573 | terminx | 1218 | |
1219 | #define STATUS2DSIZ 144 |
||
1359 | terminx | 1220 | #define STATUS2DSIZ2 26 |
1221 | |||
1892 | helixhorne | 1222 | //void qsetmode640350(void); |
1223 | //void qsetmode640480(void); |
||
1205 | terminx | 1224 | void qsetmodeany(int32_t,int32_t); |
573 | terminx | 1225 | void clear2dscreen(void); |
2896 | helixhorne | 1226 | void draw2dgrid(int32_t posxe, int32_t posye, int32_t posze, int16_t cursectnum, |
1227 | int16_t ange, int32_t zoome, int16_t gride); |
||
1228 | void draw2dscreen(const vec3_t *pos, int16_t cursectnum, |
||
1229 | int16_t ange, int32_t zoome, int16_t gride) ATTRIBUTE((nonnull(1))); |
||
1730 | helixhorne | 1230 | int32_t drawline16(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col); |
1231 | void drawcircle16(int32_t x1, int32_t y1, int32_t r, int32_t eccen, char col); |
||
573 | terminx | 1232 | |
1205 | terminx | 1233 | int32_t setrendermode(int32_t renderer); |
573 | terminx | 1234 | |
1820 | terminx | 1235 | #ifdef USE_OPENGL |
1205 | terminx | 1236 | void setrollangle(int32_t rolla); |
895 | terminx | 1237 | #endif |
573 | terminx | 1238 | |
1239 | // pal: pass -1 to invalidate all palettes for the tile, or >=0 for a particular palette |
||
1240 | // how: pass -1 to invalidate all instances of the tile in texture memory, or a bitfield |
||
1241 | // bit 0: opaque or masked (non-translucent) texture, using repeating |
||
1242 | // bit 1: ignored |
||
1243 | // bit 2: 33% translucence, using repeating |
||
1244 | // bit 3: 67% translucence, using repeating |
||
1245 | // bit 4: opaque or masked (non-translucent) texture, using clamping |
||
1246 | // bit 5: ignored |
||
1247 | // bit 6: 33% translucence, using clamping |
||
1248 | // bit 7: 67% translucence, using clamping |
||
1249 | // clamping is for sprites, repeating is for walls |
||
1205 | terminx | 1250 | void invalidatetile(int16_t tilenume, int32_t pal, int32_t how); |
573 | terminx | 1251 | |
1252 | void setpolymost2dview(void); // sets up GL for 2D drawing |
||
1253 | |||
1854 | helixhorne | 1254 | int32_t polymost_drawtilescreen(int32_t tilex, int32_t tiley, int32_t wallnum, int32_t dimen, int32_t tilezoom, |
1255 | int32_t usehitile, uint8_t *loadedhitile); |
||
573 | terminx | 1256 | void polymost_glreset(void); |
1205 | terminx | 1257 | void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype); |
573 | terminx | 1258 | |
1820 | terminx | 1259 | #ifdef USE_OPENGL |
1205 | terminx | 1260 | extern int32_t glanisotropy; |
1261 | extern int32_t glusetexcompr; |
||
1262 | extern int32_t gltexfiltermode; |
||
1263 | extern int32_t glredbluemode; |
||
2145 | helixhorne | 1264 | extern int32_t glusetexcache, glusememcache; |
1205 | terminx | 1265 | extern int32_t glmultisample, glnvmultisamplehint; |
4607 | terminx | 1266 | extern int32_t glprojectionhacks; |
1205 | terminx | 1267 | extern int32_t gltexmaxsize; |
573 | terminx | 1268 | void gltexapplyprops (void); |
3758 | terminx | 1269 | void texcache_invalidate(void); |
573 | terminx | 1270 | |
5001 | terminx | 1271 | #ifndef EDUKE32_GLES |
1205 | terminx | 1272 | extern int32_t r_detailmapping; |
1273 | extern int32_t r_glowmapping; |
||
5001 | terminx | 1274 | #endif |
1275 | |||
1205 | terminx | 1276 | extern int32_t r_vertexarrays; |
1277 | extern int32_t r_vbos; |
||
1278 | extern int32_t r_vbocount; |
||
1279 | extern int32_t r_animsmoothing; |
||
1280 | extern int32_t r_parallaxskyclamping; |
||
1281 | extern int32_t r_parallaxskypanning; |
||
1282 | extern int32_t r_fullbrights; |
||
1283 | extern int32_t r_downsize; |
||
1357 | terminx | 1284 | extern int32_t r_downsizevar; |
1205 | terminx | 1285 | extern int32_t mdtims, omdtims; |
1275 | terminx | 1286 | extern int32_t glrendmode; |
573 | terminx | 1287 | #endif |
1288 | |||
1289 | void hicinit(void); |
||
1290 | // effect bitset: 1 = greyscale, 2 = invert |
||
1205 | terminx | 1291 | void hicsetpalettetint(int32_t palnum, char r, char g, char b, char effect); |
573 | terminx | 1292 | // flags bitset: 1 = don't compress |
2896 | helixhorne | 1293 | int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut, |
1294 | float xscale, float yscale, float specpower, float specfactor, char flags); |
||
5010 | terminx | 1295 | int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6], int32_t flags); |
1205 | terminx | 1296 | int32_t hicclearsubst(int32_t picnum, int32_t palnum); |
573 | terminx | 1297 | |
2412 | helixhorne | 1298 | int32_t Ptile2tile(int32_t tile, int32_t pallet) ATTRIBUTE((pure)); |
1205 | terminx | 1299 | int32_t md_loadmodel(const char *fn); |
2264 | hendricks2 | 1300 | int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags); |
1230 | terminx | 1301 | // int32_t md_tilehasmodel(int32_t tilenume, int32_t pal); |
1302 | |||
2796 | helixhorne | 1303 | extern const char *G_DefaultDefFile(void); |
1304 | extern const char *G_DefFile(void); |
||
1909 | terminx | 1305 | extern char *g_defNamePtr; |
1306 | |||
1937 | hendricks2 | 1307 | extern char **g_defModules; |
2495 | hendricks2 | 1308 | extern int32_t g_defModulesNum; |
1937 | hendricks2 | 1309 | |
2495 | hendricks2 | 1310 | #ifdef HAVE_CLIPSHAPE_FEATURE |
1311 | extern char **g_clipMapFiles; |
||
1312 | extern int32_t g_clipMapFilesNum; |
||
1313 | #endif |
||
1314 | |||
1820 | terminx | 1315 | #ifdef USE_OPENGL |
1230 | terminx | 1316 | typedef struct |
1317 | { |
||
1318 | // maps build tiles to particular animation frames of a model |
||
1319 | int32_t modelid; |
||
1320 | int32_t skinnum; |
||
1321 | int32_t framenum; // calculate the number from the name when declaring |
||
1322 | float smoothduration; |
||
1323 | int32_t next; |
||
1324 | char pal; |
||
1325 | } tile2model_t; |
||
1326 | |||
2267 | helixhorne | 1327 | # define EXTRATILES (MAXTILES/8) |
1230 | terminx | 1328 | |
1329 | EXTERN int32_t mdinited; |
||
1330 | EXTERN tile2model_t tile2model[MAXTILES+EXTRATILES]; |
||
1331 | |||
4898 | terminx | 1332 | FORCE_INLINE int32_t md_tilehasmodel(int32_t tilenume,int32_t pal) |
1230 | terminx | 1333 | { |
4898 | terminx | 1334 | return mdinited ? tile2model[Ptile2tile(tilenume,pal)].modelid : -1; |
1230 | terminx | 1335 | } |
2244 | helixhorne | 1336 | #endif // defined USE_OPENGL |
1230 | terminx | 1337 | |
2896 | helixhorne | 1338 | int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume, |
1339 | int32_t skinnum, float smoothduration, int32_t pal); |
||
1340 | int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend, |
||
1341 | int32_t fps, int32_t flags); |
||
1342 | int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, |
||
1343 | int32_t surfnum, float param, float specpower, float specfactor); |
||
4607 | terminx | 1344 | int32_t md_definehud (int32_t modelid, int32_t tilex, float xadd, float yadd, float zadd, |
1345 | int32_t angadd, int32_t flags, int32_t fov); |
||
1205 | terminx | 1346 | int32_t md_undefinetile(int32_t tile); |
1347 | int32_t md_undefinemodel(int32_t modelid); |
||
573 | terminx | 1348 | |
1760 | helixhorne | 1349 | int32_t loaddefinitionsfile(const char *fn); |
573 | terminx | 1350 | |
2896 | helixhorne | 1351 | // if loadboard() fails with -2 return, try loadoldboard(). if it fails with |
1352 | // -2, board is dodgy |
||
3913 | helixhorne | 1353 | int32_t loadoldboard(const char *filename, char fromwhere, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum); |
573 | terminx | 1354 | |
3710 | helixhorne | 1355 | |
1025 | terminx | 1356 | // Hash functions |
1201 | terminx | 1357 | |
4749 | terminx | 1358 | typedef struct _hashitem // size is 12/24 bytes. |
1025 | terminx | 1359 | { |
1178 | terminx | 1360 | char *string; |
4607 | terminx | 1361 | intptr_t key; |
1201 | terminx | 1362 | struct _hashitem *next; |
1206 | terminx | 1363 | } hashitem_t; |
1025 | terminx | 1364 | |
1201 | terminx | 1365 | typedef struct |
1025 | terminx | 1366 | { |
1205 | terminx | 1367 | int32_t size; |
1206 | terminx | 1368 | hashitem_t **items; |
1369 | } hashtable_t; |
||
1025 | terminx | 1370 | |
1206 | terminx | 1371 | void hash_init(hashtable_t *t); |
1372 | void hash_free(hashtable_t *t); |
||
4607 | terminx | 1373 | intptr_t hash_findcase(const hashtable_t *t, const char *s); |
1374 | intptr_t hash_find(const hashtable_t *t, const char *s); |
||
1375 | void hash_add(hashtable_t *t, const char *s, intptr_t key, int32_t replace); |
||
1867 | helixhorne | 1376 | void hash_delete(hashtable_t *t, const char *s); |
1025 | terminx | 1377 | |
1227 | plagman | 1378 | #ifdef POLYMER |
1379 | # include "polymer.h" |
||
1660 | terminx | 1380 | #else |
3389 | helixhorne | 1381 | # ifdef USE_OPENGL |
1382 | # include "polymost.h" |
||
1383 | # endif |
||
1227 | plagman | 1384 | #endif |
1385 | |||
4898 | terminx | 1386 | FORCE_INLINE void push_nofog(void) |
3438 | helixhorne | 1387 | { |
1388 | #ifdef USE_OPENGL |
||
3784 | terminx | 1389 | if (getrendermode() >= REND_POLYMOST) |
3438 | helixhorne | 1390 | { |
1391 | bglDisable(GL_FOG); |
||
1392 | } |
||
1393 | #endif |
||
1394 | } |
||
1395 | |||
4898 | terminx | 1396 | FORCE_INLINE void pop_nofog(void) |
3438 | helixhorne | 1397 | { |
1398 | #ifdef USE_OPENGL |
||
5001 | terminx | 1399 | if (getrendermode() >= REND_POLYMOST && !nofog) |
1400 | bglEnable(GL_FOG); |
||
3438 | helixhorne | 1401 | #endif |
1402 | } |
||
1403 | |||
4766 | hendricks2 | 1404 | #ifdef LUNATIC |
1405 | extern const int32_t engine_main_arrays_are_static; |
||
1406 | extern const int32_t engine_v8; |
||
1407 | int32_t Mulscale(int32_t a, int32_t b, int32_t sh); |
||
1408 | #endif |
||
3438 | helixhorne | 1409 | |
4766 | hendricks2 | 1410 | #ifdef __cplusplus |
573 | terminx | 1411 | } |
1412 | #endif |
||
1413 | |||
4747 | terminx | 1414 | #endif // build_h_ |