2007-09-05 21:56:58 +00:00
|
|
|
// "Build Engine & Tools" Copyright (c) 1993-1997 Ken Silverman
|
|
|
|
// Ken Silverman's official web site: "http://www.advsys.net/ken"
|
|
|
|
// See the included license file "BUILDLIC.TXT" for license info.
|
|
|
|
//
|
|
|
|
// This file has been modified from Ken Silverman's original release
|
2012-03-12 04:47:04 +00:00
|
|
|
// by Jonathon Fowler (jf@jonof.id.au)
|
2018-11-05 07:28:01 +00:00
|
|
|
// by the EDuke32 team (development@voidpoint.com)
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2016-03-14 00:07:44 +00:00
|
|
|
#pragma once
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#ifndef build_h_
|
|
|
|
#define build_h_
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2017-07-10 13:44:01 +00:00
|
|
|
#if !defined __cplusplus || (__cplusplus < 201103L && !defined _MSC_VER)
|
|
|
|
# error C++11 or greater is required.
|
|
|
|
#endif
|
|
|
|
|
2017-10-09 07:37:08 +00:00
|
|
|
#if defined _MSC_VER && _MSC_VER < 1800
|
|
|
|
# error Visual Studio 2013 is the minimum supported version.
|
|
|
|
#endif
|
|
|
|
|
2018-11-18 18:09:48 +00:00
|
|
|
#include "collections.h"
|
2008-02-16 22:27:08 +00:00
|
|
|
#include "compat.h"
|
2018-02-16 06:38:21 +00:00
|
|
|
#include "glad/glad.h"
|
2013-02-07 21:01:24 +00:00
|
|
|
#include "glbuild.h"
|
2016-06-21 00:33:06 +00:00
|
|
|
#include "palette.h"
|
2018-11-18 18:09:48 +00:00
|
|
|
#include "pragmas.h"
|
2008-02-16 22:27:08 +00:00
|
|
|
|
2019-03-01 08:51:50 +00:00
|
|
|
#include "vfs.h"
|
|
|
|
#include "cache1d.h"
|
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
2007-09-05 21:56:58 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-12-30 20:34:55 +00:00
|
|
|
enum rendmode_t {
|
2012-12-30 20:34:34 +00:00
|
|
|
REND_CLASSIC,
|
|
|
|
REND_POLYMOST = 3,
|
|
|
|
REND_POLYMER
|
|
|
|
};
|
|
|
|
|
2012-09-02 14:08:43 +00:00
|
|
|
#define PI 3.14159265358979323846
|
2016-10-03 02:43:48 +00:00
|
|
|
#define fPI 3.14159265358979323846f
|
2012-09-02 14:07:36 +00:00
|
|
|
|
2007-09-05 21:56:58 +00:00
|
|
|
#define MAXSECTORSV8 4096
|
|
|
|
#define MAXWALLSV8 16384
|
|
|
|
#define MAXSPRITESV8 16384
|
|
|
|
|
|
|
|
#define MAXSECTORSV7 1024
|
|
|
|
#define MAXWALLSV7 8192
|
|
|
|
#define MAXSPRITESV7 4096
|
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
#define MAXVOXMIPS 5
|
|
|
|
|
2017-08-27 10:20:41 +00:00
|
|
|
#if !defined GEKKO && !defined __OPENDINGUX__
|
2012-05-01 12:40:24 +00:00
|
|
|
# define MAXSECTORS MAXSECTORSV8
|
|
|
|
# define MAXWALLS MAXWALLSV8
|
|
|
|
# define MAXSPRITES MAXSPRITESV8
|
|
|
|
|
|
|
|
# define MAXXDIM 7680
|
|
|
|
# define MAXYDIM 3200
|
2017-08-27 10:20:41 +00:00
|
|
|
# define MINXDIM 640
|
|
|
|
# define MINYDIM 480
|
2012-05-06 20:23:20 +00:00
|
|
|
|
|
|
|
// additional space beyond wall, in walltypes:
|
|
|
|
# define M32_FIXME_WALLS 512
|
|
|
|
# define M32_FIXME_SECTORS 2
|
2012-05-01 12:40:24 +00:00
|
|
|
#else
|
|
|
|
# define MAXSECTORS MAXSECTORSV7
|
|
|
|
# define MAXWALLS MAXWALLSV7
|
|
|
|
# define MAXSPRITES MAXSPRITESV7
|
|
|
|
|
2017-08-27 10:20:41 +00:00
|
|
|
#ifdef GEKKO
|
|
|
|
# define MAXXDIM 860
|
|
|
|
# define MAXYDIM 490
|
|
|
|
# else
|
|
|
|
# define MAXXDIM 320
|
|
|
|
# define MAXYDIM 200
|
|
|
|
# endif
|
2012-05-06 20:23:20 +00:00
|
|
|
|
2017-08-27 10:20:41 +00:00
|
|
|
# define MINXDIM MAXXDIM
|
|
|
|
# define MINYDIM MAXYDIM
|
2012-05-06 20:23:20 +00:00
|
|
|
# define M32_FIXME_WALLS 0
|
|
|
|
# define M32_FIXME_SECTORS 0
|
2012-05-01 12:40:24 +00:00
|
|
|
#endif
|
|
|
|
|
2013-10-13 09:08:31 +00:00
|
|
|
#ifdef LUNATIC
|
|
|
|
# define NEW_MAP_FORMAT
|
|
|
|
// A marker for LuaJIT C function callbacks, but not merely:
|
|
|
|
# define LUNATIC_CB ATTRIBUTE((used))
|
|
|
|
// Used for variables and functions referenced from Lua:
|
|
|
|
# define LUNATIC_EXTERN ATTRIBUTE((used))
|
2017-01-23 11:20:03 +00:00
|
|
|
# define LUNATIC_FASTCALL
|
2013-10-13 09:08:31 +00:00
|
|
|
#else
|
|
|
|
# ifdef NEW_MAP_FORMAT
|
|
|
|
# error "New map format can only be used with Lunatic"
|
|
|
|
# endif
|
|
|
|
# define LUNATIC_EXTERN static
|
2017-01-23 11:20:03 +00:00
|
|
|
# define LUNATIC_FASTCALL __fastcall
|
2013-10-13 09:08:31 +00:00
|
|
|
#endif
|
|
|
|
|
2019-09-13 20:18:37 +00:00
|
|
|
#define MAXWALLSB ((MAXWALLS>>2)+(MAXWALLS>>3))
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2012-01-19 21:58:06 +00:00
|
|
|
#define MAXTILES 30720
|
2013-12-28 17:04:22 +00:00
|
|
|
#define MAXUSERTILES (MAXTILES-16) // reserve 16 tiles at the end
|
|
|
|
|
2017-06-27 02:23:40 +00:00
|
|
|
#define MAXVOXELS 1024
|
2007-09-05 21:56:58 +00:00
|
|
|
#define MAXSTATUS 1024
|
|
|
|
#define MAXPLAYERS 16
|
2013-08-04 20:37:45 +00:00
|
|
|
// Maximum number of component tiles in a multi-psky:
|
2019-09-19 20:02:45 +00:00
|
|
|
#define MAXPSKYTILES 16
|
2018-04-06 01:43:22 +00:00
|
|
|
#define MAXSPRITESONSCREEN 2560
|
2007-09-05 21:56:58 +00:00
|
|
|
#define MAXUNIQHUDID 256 //Extra slots so HUD models can store animation state without messing game sprites
|
|
|
|
|
2008-07-22 12:17:05 +00:00
|
|
|
#define TSPR_TEMP 99
|
2008-07-22 09:05:34 +00:00
|
|
|
|
2009-04-29 19:43:51 +00:00
|
|
|
#define PR_LIGHT_PRIO_MAX 0
|
|
|
|
#define PR_LIGHT_PRIO_MAX_GAME 1
|
|
|
|
#define PR_LIGHT_PRIO_HIGH 2
|
|
|
|
#define PR_LIGHT_PRIO_HIGH_GAME 3
|
|
|
|
#define PR_LIGHT_PRIO_LOW 4
|
|
|
|
#define PR_LIGHT_PRIO_LOW_GAME 5
|
|
|
|
|
2013-04-15 10:48:09 +00:00
|
|
|
// Convenient sprite iterators, must not be used if any sprites inside the loop
|
|
|
|
// are potentially deleted or their sector changed...
|
2012-05-29 20:01:48 +00:00
|
|
|
#define SPRITES_OF(Statnum, Iter) Iter=headspritestat[Statnum]; Iter>=0; Iter=nextspritestat[Iter]
|
|
|
|
#define SPRITES_OF_SECT(Sectnum, Iter) Iter=headspritesect[Sectnum]; Iter>=0; Iter=nextspritesect[Iter]
|
2013-04-15 10:48:09 +00:00
|
|
|
// ... in which case this iterator may be used:
|
|
|
|
#define SPRITES_OF_SECT_SAFE(Sectnum, Iter, Next) Iter=headspritesect[Sectnum]; \
|
2013-04-15 18:50:21 +00:00
|
|
|
Iter>=0 && (Next=nextspritesect[Iter], 1); Iter=Next
|
2013-09-05 17:37:38 +00:00
|
|
|
#define SPRITES_OF_STAT_SAFE(Statnum, Iter, Next) Iter=headspritestat[Statnum]; \
|
|
|
|
Iter>=0 && (Next=nextspritestat[Iter], 1); Iter=Next
|
2012-05-29 20:01:48 +00:00
|
|
|
|
2012-12-25 16:13:50 +00:00
|
|
|
#define CLEARLINES2D(Startline, Numlines, Color) \
|
|
|
|
clearbuf((char *)(frameplace + ((Startline)*bytesperline)), (bytesperline*(Numlines))>>2, (Color))
|
|
|
|
|
2012-05-29 20:01:48 +00:00
|
|
|
|
2011-05-15 23:16:37 +00:00
|
|
|
////////// True Room over Room (YAX == rot -17 of "PRO") //////////
|
|
|
|
#define YAX_ENABLE
|
|
|
|
//#define YAX_DEBUG
|
|
|
|
//#define ENGINE_SCREENSHOT_DEBUG
|
|
|
|
|
2013-04-09 17:35:11 +00:00
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
# if !defined NEW_MAP_FORMAT
|
|
|
|
# define YAX_ENABLE__COMPAT
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
|
2011-03-02 21:21:47 +00:00
|
|
|
////////// yax defs //////////
|
2011-05-07 18:23:34 +00:00
|
|
|
#define SECTORFLD(Sect,Fld, Cf) (*((Cf) ? (§or[Sect].floor##Fld) : (§or[Sect].ceiling##Fld)))
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
#define YAX_CEILING 0 // don't change!
|
|
|
|
#define YAX_FLOOR 1 // don't change!
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2013-04-09 17:35:11 +00:00
|
|
|
# ifdef NEW_MAP_FORMAT
|
|
|
|
# define YAX_MAXBUNCHES 512
|
|
|
|
# define YAX_BIT__COMPAT 1024
|
|
|
|
# define YAX_NEXTWALLBIT__COMPAT(Cf) (1<<(10+Cf))
|
|
|
|
# define YAX_NEXTWALLBITS__COMPAT (YAX_NEXTWALLBIT__COMPAT(0)|YAX_NEXTWALLBIT__COMPAT(1))
|
|
|
|
# else
|
|
|
|
# define YAX_MAXBUNCHES 256
|
|
|
|
# define YAX_BIT 1024
|
|
|
|
// "has next wall when constrained"-bit (1<<10: ceiling, 1<<11: floor)
|
|
|
|
# define YAX_NEXTWALLBIT(Cf) (1<<(10+Cf))
|
|
|
|
# define YAX_NEXTWALLBITS (YAX_NEXTWALLBIT(0)|YAX_NEXTWALLBIT(1))
|
|
|
|
# endif
|
|
|
|
|
2013-03-29 15:59:14 +00:00
|
|
|
int32_t get_alwaysshowgray(void); // editor only
|
2011-05-07 18:23:34 +00:00
|
|
|
void yax_updategrays(int32_t posze);
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2011-05-07 18:23:34 +00:00
|
|
|
#ifdef YAX_ENABLE
|
2013-04-09 17:35:11 +00:00
|
|
|
# ifdef NEW_MAP_FORMAT
|
|
|
|
// New map format -- no hijacking of otherwise used members.
|
|
|
|
# define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(&Ptr[Wall].upwall + Cf))
|
|
|
|
# define YAX_NEXTWALLDEFAULT(Cf) (-1)
|
|
|
|
# else
|
|
|
|
// More user tag hijacking: lotag/extra. :/
|
|
|
|
# define YAX_PTRNEXTWALL(Ptr, Wall, Cf) (*(int16_t *)(&Ptr[Wall].lotag + 2*Cf))
|
|
|
|
# define YAX_NEXTWALLDEFAULT(Cf) (((Cf)==YAX_CEILING) ? 0 : -1)
|
|
|
|
extern int16_t yax_bunchnum[MAXSECTORS][2];
|
|
|
|
extern int16_t yax_nextwall[MAXWALLS][2];
|
|
|
|
# endif
|
|
|
|
|
2012-02-16 19:25:18 +00:00
|
|
|
# define YAX_NEXTWALL(Wall, Cf) YAX_PTRNEXTWALL(wall, Wall, Cf)
|
2011-04-11 22:28:58 +00:00
|
|
|
|
2011-05-07 18:23:34 +00:00
|
|
|
# define YAX_ITER_WALLS(Wal, Itervar, Cfvar) Cfvar=0, Itervar=(Wal); Itervar!=-1; \
|
2012-08-16 21:48:08 +00:00
|
|
|
Itervar=yax_getnextwall(Itervar, Cfvar), \
|
|
|
|
(void)(Itervar==-1 && Cfvar==0 && (Cfvar=1) && (Itervar=yax_getnextwall((Wal), Cfvar)))
|
2011-04-14 20:48:08 +00:00
|
|
|
|
2011-05-15 22:37:24 +00:00
|
|
|
# define SECTORS_OF_BUNCH(Bunchnum, Cf, Itervar) Itervar = headsectbunch[Cf][Bunchnum]; \
|
|
|
|
Itervar != -1; Itervar = nextsectbunch[Cf][Itervar]
|
|
|
|
|
Support for drawing 'island sectors' for TROR/classic (and with limited
functionality, Polymost).
The new feature can be enabled/disabled with the 'r_tror_nomaskpass' cvar.
The basic idea is that when drawing lower or upper levels, a first pass
is performed that ignores all red walls for which the TROR nextwall link
'towards' the viewer arrives at a red wall. Thus, in the worst case, there
can be up to twice as many rendering passes now (when it is discovered that
the no-mask-pass isn't different that what would be drawn with the ordinary
one, the latter is skipped, since we've already drawn all needed geometry).
Hovever, this kind of multi-pass splitting is only suitable for simple scenes,
like the upper subway in the TROR test map. In particular, multiple islands
shouldn't 'see' each other.
Two issues are worth mentioning: first, care needs to be taken for translucent
ceilings or floors, since drawing them twice isn't the same as drawing them
once. This is done for classic, but not for Polymost. Second, sprites (which
are always drawn _after_ the geometry for a given pass) are still clipped to
the geometry of the ordinary pass, resulting in their disappearance from
certain angles.
--
Additionaly, a change made it into this commit that fixes redundant collection
of sprites in TROR:classic/Polymost.
git-svn-id: https://svn.eduke32.com/eduke32@2024 1a8010ca-5511-0410-912e-c29ae57300e0
2011-09-15 17:04:14 +00:00
|
|
|
extern int32_t r_tror_nomaskpass;
|
|
|
|
|
2013-04-09 17:35:11 +00:00
|
|
|
# ifdef NEW_MAP_FORMAT
|
|
|
|
// Moved below declarations of sector, wall, sprite.
|
|
|
|
# else
|
2011-03-02 21:21:47 +00:00
|
|
|
int16_t yax_getbunch(int16_t i, int16_t cf);
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb)
|
2014-10-29 17:06:05 +00:00
|
|
|
{
|
|
|
|
*cb = yax_getbunch(i, YAX_CEILING);
|
|
|
|
*fb = yax_getbunch(i, YAX_FLOOR);
|
|
|
|
}
|
2011-04-11 22:28:58 +00:00
|
|
|
int16_t yax_getnextwall(int16_t wal, int16_t cf);
|
|
|
|
void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall);
|
2013-04-09 17:35:11 +00:00
|
|
|
# endif
|
|
|
|
|
|
|
|
void yax_setbunch(int16_t i, int16_t cf, int16_t bunchnum);
|
|
|
|
void yax_setbunches(int16_t i, int16_t cb, int16_t fb);
|
2011-09-15 17:02:12 +00:00
|
|
|
int16_t yax_vnextsec(int16_t line, int16_t cf);
|
2011-05-12 23:31:13 +00:00
|
|
|
void yax_update(int32_t resetstat);
|
2012-10-01 17:52:18 +00:00
|
|
|
int32_t yax_getneighborsect(int32_t x, int32_t y, int32_t sectnum, int32_t cf);
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
static FORCE_INLINE CONSTEXPR int32_t yax_waltosecmask(int32_t const walclipmask)
|
2011-05-07 18:23:34 +00:00
|
|
|
{
|
|
|
|
// blocking: walstat&1 --> secstat&512
|
|
|
|
// hitscan: walstat&64 --> secstat&2048
|
|
|
|
return ((walclipmask&1)<<9) | ((walclipmask&64)<<5);
|
|
|
|
}
|
|
|
|
void yax_preparedrawrooms(void);
|
2012-08-13 18:25:37 +00:00
|
|
|
void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t),
|
|
|
|
int16_t sectnum, int32_t didmirror, int32_t smoothr);
|
2011-04-22 22:48:06 +00:00
|
|
|
# define YAX_SKIPSECTOR(i) if (graysectbitmap[(i)>>3]&(1<<((i)&7))) continue
|
|
|
|
# define YAX_SKIPWALL(i) if (graywallbitmap[(i)>>3]&(1<<((i)&7))) continue
|
|
|
|
#else
|
2011-05-07 18:23:34 +00:00
|
|
|
# define yax_preparedrawrooms()
|
2012-08-13 18:25:37 +00:00
|
|
|
# define yax_drawrooms(SpriteAnimFunc, sectnum, didmirror, smoothr)
|
2011-04-22 22:48:06 +00:00
|
|
|
# define YAX_SKIPSECTOR(i) (i)=(i)
|
|
|
|
# define YAX_SKIPWALL(i) (i)=(i)
|
|
|
|
#endif
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2007-09-05 21:56:58 +00:00
|
|
|
#define CLIPMASK0 (((1L)<<16)+1L)
|
|
|
|
#define CLIPMASK1 (((256L)<<16)+64L)
|
|
|
|
|
2019-04-18 17:24:26 +00:00
|
|
|
#define NEXTWALL(i) (wall[wall[i].nextwall])
|
|
|
|
#define POINT2(i) (wall[wall[i].point2])
|
|
|
|
|
2011-02-15 21:02:43 +00:00
|
|
|
// max x/y val (= max editorgridextent in Mapster32)
|
|
|
|
#define BXY_MAX 524288
|
|
|
|
|
2013-11-22 19:26:52 +00:00
|
|
|
// rotatesprite 'orientation' (actually much more) bits
|
2012-08-19 13:02:37 +00:00
|
|
|
enum {
|
2013-11-22 19:26:52 +00:00
|
|
|
RS_TRANS1 = 1,
|
|
|
|
RS_AUTO = 2,
|
|
|
|
RS_YFLIP = 4,
|
|
|
|
RS_NOCLIP = 8,
|
|
|
|
RS_TOPLEFT = 16,
|
|
|
|
RS_TRANS2 = 32,
|
|
|
|
RS_NOMASK = 64,
|
|
|
|
RS_PERM = 128,
|
|
|
|
|
|
|
|
RS_ALIGN_L = 256,
|
|
|
|
RS_ALIGN_R = 512,
|
|
|
|
RS_ALIGN_MASK = 768,
|
|
|
|
RS_STRETCH = 1024,
|
|
|
|
|
2013-03-25 04:31:58 +00:00
|
|
|
ROTATESPRITE_FULL16 = 2048,
|
2012-08-19 13:02:37 +00:00
|
|
|
// ROTATESPRITE_MAX-1 is the mask of all externally available orientation bits
|
2013-03-25 04:31:58 +00:00
|
|
|
ROTATESPRITE_MAX = 4096,
|
2012-08-19 13:02:37 +00:00
|
|
|
|
|
|
|
RS_CENTERORIGIN = (1<<30),
|
|
|
|
};
|
2012-08-19 12:57:57 +00:00
|
|
|
|
2007-09-05 21:56:58 +00:00
|
|
|
//Make all variables in BUILD.H defined in the ENGINE,
|
|
|
|
//and externed in GAME
|
2018-11-18 18:09:48 +00:00
|
|
|
#ifdef engine_c_
|
2007-09-05 21:56:58 +00:00
|
|
|
# define EXTERN
|
|
|
|
#else
|
|
|
|
# define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2012-11-09 22:31:02 +00:00
|
|
|
#ifdef __cplusplus
|
2018-03-17 03:26:01 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined __cplusplus && (defined USE_OPENGL || defined POLYMER)
|
|
|
|
# define STRUCT_TRACKERS_ENABLED
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef STRUCT_TRACKERS_ENABLED
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2018-03-17 03:26:01 +00:00
|
|
|
extern "C" {
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void sector_tracker_hook(uintptr_t address);
|
|
|
|
static FORCE_INLINE void wall_tracker_hook(uintptr_t address);
|
|
|
|
static FORCE_INLINE void sprite_tracker_hook(uintptr_t address);
|
2014-11-26 04:39:23 +00:00
|
|
|
}
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#define TRACKER_NAME_ SectorTracker
|
|
|
|
#define TRACKER_GLOBAL_HOOK_ sector_tracker_hook
|
2012-11-09 22:31:02 +00:00
|
|
|
#include "tracker.hpp"
|
2014-11-22 12:32:56 +00:00
|
|
|
#undef TRACKER_NAME_
|
|
|
|
#undef TRACKER_GLOBAL_HOOK_
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#define TRACKER_NAME_ WallTracker
|
|
|
|
#define TRACKER_GLOBAL_HOOK_ wall_tracker_hook
|
2012-11-09 22:31:02 +00:00
|
|
|
#include "tracker.hpp"
|
2014-11-22 12:32:56 +00:00
|
|
|
#undef TRACKER_NAME_
|
|
|
|
#undef TRACKER_GLOBAL_HOOK_
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#define TRACKER_NAME_ SpriteTracker
|
|
|
|
#define TRACKER_GLOBAL_HOOK_ sprite_tracker_hook
|
2012-11-09 22:31:02 +00:00
|
|
|
#include "tracker.hpp"
|
2014-11-22 12:32:56 +00:00
|
|
|
#undef TRACKER_NAME_
|
|
|
|
#undef TRACKER_GLOBAL_HOOK_
|
2012-11-09 22:31:02 +00:00
|
|
|
|
|
|
|
#define Tracker(Container, Type) Container##Tracker<Type>
|
2012-11-26 08:26:04 +00:00
|
|
|
#define TrackerCast(x) x.cast()
|
2012-11-09 22:31:02 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define Tracker(Container, Type) Type
|
2012-11-26 08:26:04 +00:00
|
|
|
#define TrackerCast(x) x
|
2012-11-09 22:31:02 +00:00
|
|
|
|
|
|
|
#endif // __cplusplus
|
|
|
|
|
Lose the 'packed' attribute for types declared in build.h.
Most of them are already aligned to their natural boundaries, so lowering
the alignment to 1 byte can only worsen things by making the C compiler
generate poorer (unaligned access) code for some platforms.
The layout of structures is not specified by the C Standard, but is rather
given by a particular platform + toolchain's ABI (application binary interface).
Most ABIs follow the expected pattern "alignment of scalars is their size,
alignment of arrays is that of its element type, alignment of structs is the
maximum alignment of its members". A couple of links to particular ABIs are
given in build.h.
Problems are expected with archs that care about unaligned access when a pointer
to a non-packed struct is taken that resides in a packed aggregate, but these
uses should be weeded out (I'm not sure if there are any in our codebase).
The following types are affected, only hitdata_t changes its size:
sectortype, walltype, spritetype, spriteext_t, spritesmooth_t,
struct validmode_t, picanm_t, palette_t, vec2_t, vec3_t, hitdata_t.
git-svn-id: https://svn.eduke32.com/eduke32@3455 1a8010ca-5511-0410-912e-c29ae57300e0
2013-02-03 12:48:11 +00:00
|
|
|
// Links to various ABIs specifying (or documenting non-normatively) the
|
|
|
|
// alignment requirements of aggregates:
|
|
|
|
//
|
|
|
|
// System V AMD64: http://www.x86-64.org/documentation/abi-0.99.pdf
|
|
|
|
// (x86-64.org down as of 2013-02-02?)
|
|
|
|
// "An array uses the same alignment as its elements, except that a local or global
|
|
|
|
// array variable of length at least 16 bytes or a C99 variable-length array variable
|
|
|
|
// always has alignment of at least 16 bytes."
|
|
|
|
// (Not reproducible with GCC or LuaJIT on Ubuntu)
|
|
|
|
//
|
|
|
|
// Win64: http://msdn.microsoft.com/en-us/library/9dbwhz68.aspx
|
|
|
|
//
|
|
|
|
// x86: http://en.wikipedia.org/wiki/Data_structure_alignment#Typical_alignment_of_C_structs_on_x86
|
|
|
|
|
2013-05-16 21:54:52 +00:00
|
|
|
enum {
|
|
|
|
SPR_XFLIP = 4,
|
|
|
|
SPR_YFLIP = 8,
|
|
|
|
|
|
|
|
SPR_WALL = 16,
|
|
|
|
SPR_FLOOR = 32,
|
|
|
|
SPR_ALIGN_MASK = 32+16,
|
|
|
|
};
|
|
|
|
|
2015-01-12 08:44:46 +00:00
|
|
|
#define UNTRACKED_STRUCTS
|
|
|
|
#include "buildtypes.h"
|
|
|
|
#undef UNTRACKED_STRUCTS
|
2018-03-17 03:25:57 +00:00
|
|
|
#undef buildtypes_h__
|
|
|
|
#include "buildtypes.h"
|
2015-01-19 00:11:25 +00:00
|
|
|
|
2017-01-05 05:30:00 +00:00
|
|
|
#if !defined NEW_MAP_FORMAT
|
2019-04-18 17:25:14 +00:00
|
|
|
using sectortype = sectortypev7;
|
|
|
|
using usectortype = usectortypev7;
|
2013-05-06 19:43:28 +00:00
|
|
|
|
2019-04-18 17:25:14 +00:00
|
|
|
using walltype = walltypev7;
|
|
|
|
using uwalltype = uwalltypev7;
|
2017-01-05 05:30:00 +00:00
|
|
|
#else
|
2019-04-18 17:25:14 +00:00
|
|
|
using sectortype = sectortypevx;
|
|
|
|
using usectortype = usectortypevx;
|
2013-05-06 19:43:28 +00:00
|
|
|
|
2019-04-18 17:25:14 +00:00
|
|
|
using walltype = walltypevx;
|
|
|
|
using uwalltype = uwalltypevx;
|
2017-01-05 05:30:00 +00:00
|
|
|
#endif
|
2013-05-06 19:43:28 +00:00
|
|
|
|
2019-04-18 17:25:14 +00:00
|
|
|
using spritetype = spritetypev7;
|
|
|
|
using uspritetype = uspritetypev7;
|
|
|
|
using tspritetype = uspritetypev7;
|
|
|
|
|
|
|
|
using uspriteptr_t = uspritetype const *;
|
|
|
|
using uwallptr_t = uwalltype const *;
|
|
|
|
using usectorptr_t = usectortype const *;
|
|
|
|
using tspriteptr_t = tspritetype *;
|
2018-03-17 03:25:57 +00:00
|
|
|
|
2018-01-31 04:13:25 +00:00
|
|
|
// this is probably never going to be necessary
|
|
|
|
EDUKE32_STATIC_ASSERT(sizeof(sectortype) == sizeof(usectortype));
|
|
|
|
EDUKE32_STATIC_ASSERT(sizeof(walltype) == sizeof(uwalltype));
|
|
|
|
EDUKE32_STATIC_ASSERT(sizeof(spritetype) == sizeof(uspritetype));
|
|
|
|
|
2017-01-05 05:30:00 +00:00
|
|
|
#ifdef NEW_MAP_FORMAT
|
2013-04-09 17:35:11 +00:00
|
|
|
|
2013-05-06 19:43:28 +00:00
|
|
|
# define SECTORVX_SZ1 offsetof(sectortypevx, ceilingpicnum)
|
|
|
|
# define SECTORVX_SZ4 sizeof(sectortypevx)-offsetof(sectortypevx, visibility)
|
2013-04-09 17:35:11 +00:00
|
|
|
|
2017-01-05 05:30:00 +00:00
|
|
|
static inline void copy_v7_from_vx_sector(usectortypev7 *v7sec, const sectortypevx *vxsec)
|
2013-04-09 17:35:11 +00:00
|
|
|
{
|
2013-05-06 19:43:28 +00:00
|
|
|
/* [wallptr..wallnum] */
|
|
|
|
Bmemcpy(v7sec, vxsec, SECTORVX_SZ1);
|
|
|
|
|
|
|
|
/* ceiling* */
|
|
|
|
v7sec->ceilingpicnum = vxsec->ceilingpicnum;
|
|
|
|
v7sec->ceilingheinum = vxsec->ceilingheinum;
|
|
|
|
v7sec->ceilingstat = vxsec->ceilingstat;
|
|
|
|
v7sec->ceilingz = vxsec->ceilingz;
|
|
|
|
v7sec->ceilingshade = vxsec->ceilingshade;
|
|
|
|
v7sec->ceilingpal = vxsec->ceilingpal;
|
|
|
|
v7sec->ceilingxpanning = vxsec->ceilingxpanning;
|
|
|
|
v7sec->ceilingypanning = vxsec->ceilingypanning;
|
|
|
|
|
|
|
|
/* floor* */
|
|
|
|
v7sec->floorpicnum = vxsec->floorpicnum;
|
|
|
|
v7sec->floorheinum = vxsec->floorheinum;
|
|
|
|
v7sec->floorstat = vxsec->floorstat;
|
|
|
|
v7sec->floorz = vxsec->floorz;
|
|
|
|
v7sec->floorshade = vxsec->floorshade;
|
|
|
|
v7sec->floorpal = vxsec->floorpal;
|
|
|
|
v7sec->floorxpanning = vxsec->floorxpanning;
|
|
|
|
v7sec->floorypanning = vxsec->floorypanning;
|
|
|
|
|
|
|
|
/* [visibility..extra] */
|
|
|
|
Bmemcpy(&v7sec->visibility, &vxsec->visibility, SECTORVX_SZ4);
|
2013-04-09 17:35:11 +00:00
|
|
|
|
|
|
|
/* Clear YAX_BIT of ceiling and floor. (New-map format build saves TROR
|
|
|
|
* maps as map-text.) */
|
|
|
|
v7sec->ceilingstat &= ~YAX_BIT__COMPAT;
|
|
|
|
v7sec->floorstat &= ~YAX_BIT__COMPAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void inplace_vx_from_v7_sector(sectortypevx *vxsec)
|
|
|
|
{
|
|
|
|
const sectortypev7 *v7sec = (sectortypev7 *)vxsec;
|
2017-01-05 05:30:00 +00:00
|
|
|
usectortypev7 bakv7sec;
|
2013-05-06 19:43:28 +00:00
|
|
|
|
|
|
|
// Can't do this in-place since the members were rearranged.
|
|
|
|
Bmemcpy(&bakv7sec, v7sec, sizeof(sectortypev7));
|
|
|
|
|
|
|
|
/* [wallptr..wallnum] is already at the right place */
|
|
|
|
|
|
|
|
/* ceiling* */
|
|
|
|
vxsec->ceilingpicnum = bakv7sec.ceilingpicnum;
|
|
|
|
vxsec->ceilingheinum = bakv7sec.ceilingheinum;
|
|
|
|
vxsec->ceilingstat = bakv7sec.ceilingstat;
|
|
|
|
vxsec->ceilingz = bakv7sec.ceilingz;
|
|
|
|
vxsec->ceilingshade = bakv7sec.ceilingshade;
|
|
|
|
vxsec->ceilingpal = bakv7sec.ceilingpal;
|
|
|
|
vxsec->ceilingxpanning = bakv7sec.ceilingxpanning;
|
|
|
|
vxsec->ceilingypanning = bakv7sec.ceilingypanning;
|
|
|
|
|
|
|
|
/* floor* */
|
|
|
|
vxsec->floorpicnum = bakv7sec.floorpicnum;
|
|
|
|
vxsec->floorheinum = bakv7sec.floorheinum;
|
|
|
|
vxsec->floorstat = bakv7sec.floorstat;
|
|
|
|
vxsec->floorz = bakv7sec.floorz;
|
|
|
|
vxsec->floorshade = bakv7sec.floorshade;
|
|
|
|
vxsec->floorpal = bakv7sec.floorpal;
|
|
|
|
vxsec->floorxpanning = bakv7sec.floorxpanning;
|
|
|
|
vxsec->floorypanning = bakv7sec.floorypanning;
|
|
|
|
|
|
|
|
/* [visibility..extra] */
|
|
|
|
Bmemmove(&vxsec->visibility, &bakv7sec.visibility, SECTORVX_SZ4);
|
2013-04-09 17:35:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void inplace_vx_tweak_sector(sectortypevx *vxsec, int32_t yaxp)
|
|
|
|
{
|
|
|
|
if (yaxp)
|
|
|
|
{
|
|
|
|
int32_t cisext = (vxsec->ceilingstat&YAX_BIT__COMPAT);
|
|
|
|
int32_t fisext = (vxsec->floorstat&YAX_BIT__COMPAT);
|
|
|
|
|
|
|
|
vxsec->ceilingbunch = cisext ? vxsec->ceilingxpanning : -1;
|
|
|
|
vxsec->floorbunch = fisext ? vxsec->floorxpanning : -1;
|
|
|
|
|
|
|
|
if (cisext)
|
|
|
|
vxsec->ceilingxpanning = 0;
|
|
|
|
if (fisext)
|
|
|
|
vxsec->floorxpanning = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vxsec->ceilingbunch = vxsec->floorbunch = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear YAX_BIT of ceiling and floor (map-int VX doesn't use it). */
|
|
|
|
vxsec->ceilingstat &= ~YAX_BIT__COMPAT;
|
|
|
|
vxsec->floorstat &= ~YAX_BIT__COMPAT;
|
|
|
|
}
|
|
|
|
|
2013-05-06 19:43:28 +00:00
|
|
|
# undef SECTORVX_SZ1
|
|
|
|
# undef SECTORVX_SZ4
|
2013-04-09 17:35:11 +00:00
|
|
|
|
2014-03-10 20:08:27 +00:00
|
|
|
# define WALLVX_SZ2 offsetof(walltypevx, blend)-offsetof(walltypevx, cstat)
|
2013-04-09 17:35:11 +00:00
|
|
|
|
2017-01-05 05:30:00 +00:00
|
|
|
static inline void copy_v7_from_vx_wall(uwalltypev7 *v7wal, const walltypevx *vxwal)
|
2013-04-09 17:35:11 +00:00
|
|
|
{
|
|
|
|
/* [x..nextsector] */
|
|
|
|
Bmemcpy(v7wal, vxwal, offsetof(walltypevx, upwall));
|
|
|
|
/* [cstat..extra] */
|
|
|
|
Bmemcpy(&v7wal->cstat, &vxwal->cstat, WALLVX_SZ2);
|
|
|
|
/* Clear YAX_NEXTWALLBITS. */
|
|
|
|
v7wal->cstat &= ~YAX_NEXTWALLBITS__COMPAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void inplace_vx_from_v7_wall(walltypevx *vxwal)
|
|
|
|
{
|
|
|
|
const walltypev7 *v7wal = (walltypev7 *)vxwal;
|
|
|
|
|
|
|
|
/* [cstat..extra] */
|
|
|
|
Bmemmove(&vxwal->cstat, &v7wal->cstat, WALLVX_SZ2);
|
2014-03-10 20:08:27 +00:00
|
|
|
|
|
|
|
vxwal->blend = vxwal->filler_ = 0;
|
2013-04-09 17:35:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void inplace_vx_tweak_wall(walltypevx *vxwal, int32_t yaxp)
|
|
|
|
{
|
|
|
|
if (yaxp)
|
|
|
|
{
|
|
|
|
int32_t haveupwall = (vxwal->cstat & YAX_NEXTWALLBIT__COMPAT(YAX_CEILING));
|
|
|
|
int32_t havednwall = (vxwal->cstat & YAX_NEXTWALLBIT__COMPAT(YAX_FLOOR));
|
|
|
|
|
|
|
|
vxwal->upwall = haveupwall ? vxwal->lotag : -1;
|
|
|
|
vxwal->dnwall = havednwall ? vxwal->extra : -1;
|
|
|
|
|
|
|
|
if (haveupwall)
|
|
|
|
vxwal->lotag = 0;
|
|
|
|
if (havednwall)
|
|
|
|
vxwal->extra = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
vxwal->upwall = vxwal->dnwall = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear YAX_NEXTWALLBITS (map-int VX doesn't use it). */
|
|
|
|
vxwal->cstat &= ~YAX_NEXTWALLBITS__COMPAT;
|
|
|
|
}
|
|
|
|
|
|
|
|
# undef WALLVX_SZ2
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2017-01-05 05:29:11 +00:00
|
|
|
#include "clip.h"
|
|
|
|
|
2017-06-05 10:04:56 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-07-09 02:29:48 +00:00
|
|
|
typedef struct {
|
2009-01-09 09:29:17 +00:00
|
|
|
uint32_t mdanimtims;
|
|
|
|
int16_t mdanimcur;
|
2010-05-02 23:27:30 +00:00
|
|
|
int16_t angoff, pitch, roll;
|
2014-10-25 03:36:34 +00:00
|
|
|
vec3_t offset;
|
2009-01-10 07:38:50 +00:00
|
|
|
uint8_t flags;
|
|
|
|
uint8_t xpanning, ypanning;
|
2009-04-24 02:53:50 +00:00
|
|
|
uint8_t filler;
|
|
|
|
float alpha;
|
Lose the 'packed' attribute for types declared in build.h.
Most of them are already aligned to their natural boundaries, so lowering
the alignment to 1 byte can only worsen things by making the C compiler
generate poorer (unaligned access) code for some platforms.
The layout of structures is not specified by the C Standard, but is rather
given by a particular platform + toolchain's ABI (application binary interface).
Most ABIs follow the expected pattern "alignment of scalars is their size,
alignment of arrays is that of its element type, alignment of structs is the
maximum alignment of its members". A couple of links to particular ABIs are
given in build.h.
Problems are expected with archs that care about unaligned access when a pointer
to a non-packed struct is taken that resides in a packed aggregate, but these
uses should be weeded out (I'm not sure if there are any in our codebase).
The following types are affected, only hitdata_t changes its size:
sectortype, walltype, spritetype, spriteext_t, spritesmooth_t,
struct validmode_t, picanm_t, palette_t, vec2_t, vec3_t, hitdata_t.
git-svn-id: https://svn.eduke32.com/eduke32@3455 1a8010ca-5511-0410-912e-c29ae57300e0
2013-02-03 12:48:11 +00:00
|
|
|
// NOTE: keep 'tspr' on an 8-byte boundary:
|
2016-06-21 00:33:58 +00:00
|
|
|
uspritetype *tspr;
|
2011-12-25 15:34:06 +00:00
|
|
|
#if !defined UINTPTR_MAX
|
|
|
|
# error Need UINTPTR_MAX define to select between 32- and 64-bit structs
|
|
|
|
#endif
|
|
|
|
#if UINTPTR_MAX == 0xffffffff
|
2012-11-15 21:10:00 +00:00
|
|
|
/* On a 32-bit build, pad the struct so it has the same size everywhere. */
|
2012-11-05 02:49:08 +00:00
|
|
|
intptr_t dummy_;
|
2011-12-04 18:09:50 +00:00
|
|
|
#endif
|
2009-01-10 07:38:50 +00:00
|
|
|
} spriteext_t;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2009-07-09 02:29:48 +00:00
|
|
|
typedef struct {
|
2008-05-31 01:57:14 +00:00
|
|
|
float smoothduration;
|
2009-01-09 09:29:17 +00:00
|
|
|
int16_t mdcurframe, mdoldframe;
|
|
|
|
int16_t mdsmooth;
|
2009-01-10 07:38:50 +00:00
|
|
|
uint8_t filler[2];
|
|
|
|
} spritesmooth_t;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2017-06-25 11:23:53 +00:00
|
|
|
#ifndef NEW_MAP_FORMAT
|
|
|
|
typedef struct {
|
|
|
|
uint8_t blend;
|
|
|
|
} wallext_t;
|
|
|
|
#endif
|
|
|
|
|
2007-09-05 21:56:58 +00:00
|
|
|
#define SPREXT_NOTMD 1
|
|
|
|
#define SPREXT_NOMDANIM 2
|
2007-12-20 19:14:38 +00:00
|
|
|
#define SPREXT_AWAY1 4
|
|
|
|
#define SPREXT_AWAY2 8
|
2008-08-23 23:37:01 +00:00
|
|
|
#define SPREXT_TSPRACCESS 16
|
2011-08-17 18:52:16 +00:00
|
|
|
#define SPREXT_TEMPINVISIBLE 32
|
2008-07-12 10:57:52 +00:00
|
|
|
|
2015-10-21 19:54:14 +00:00
|
|
|
#define TSPR_EXTRA_MDHACK 1
|
2013-03-21 10:19:32 +00:00
|
|
|
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
EXTERN int32_t guniqhudid;
|
|
|
|
EXTERN int32_t spritesortcnt;
|
2013-07-04 19:38:37 +00:00
|
|
|
extern int32_t g_loadedMapVersion;
|
2015-01-08 15:14:00 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *mhkfile;
|
|
|
|
char *title;
|
|
|
|
uint8_t md4[16];
|
|
|
|
} usermaphack_t;
|
2015-01-18 20:31:37 +00:00
|
|
|
|
|
|
|
extern usermaphack_t g_loadedMapHack;
|
2017-01-01 13:23:35 +00:00
|
|
|
extern int compare_usermaphacks(const void *, const void *);
|
2015-01-08 15:14:00 +00:00
|
|
|
extern usermaphack_t *usermaphacks;
|
|
|
|
extern int32_t num_usermaphacks;
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
|
|
|
|
#if !defined DEBUG_MAIN_ARRAYS
|
2009-01-10 07:38:50 +00:00
|
|
|
EXTERN spriteext_t *spriteext;
|
|
|
|
EXTERN spritesmooth_t *spritesmooth;
|
2017-06-25 11:23:53 +00:00
|
|
|
# ifndef NEW_MAP_FORMAT
|
|
|
|
EXTERN wallext_t *wallext;
|
|
|
|
# endif
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2007-09-06 10:43:42 +00:00
|
|
|
EXTERN sectortype *sector;
|
|
|
|
EXTERN walltype *wall;
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
EXTERN spritetype *sprite;
|
2019-04-18 17:25:24 +00:00
|
|
|
EXTERN tspriteptr_t tsprite;
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
#else
|
|
|
|
EXTERN spriteext_t spriteext[MAXSPRITES+MAXUNIQHUDID];
|
|
|
|
EXTERN spritesmooth_t spritesmooth[MAXSPRITES+MAXUNIQHUDID];
|
2017-06-25 11:23:53 +00:00
|
|
|
# ifndef NEW_MAP_FORMAT
|
|
|
|
EXTERN wallext_t wallext[MAXWALLS];
|
|
|
|
# endif
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
|
|
|
|
EXTERN sectortype sector[MAXSECTORS + M32_FIXME_SECTORS];
|
|
|
|
EXTERN walltype wall[MAXWALLS + M32_FIXME_WALLS];
|
|
|
|
EXTERN spritetype sprite[MAXSPRITES];
|
2016-06-21 00:33:58 +00:00
|
|
|
EXTERN uspritetype tsprite[MAXSPRITESONSCREEN];
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
#endif
|
|
|
|
|
2018-03-17 03:26:01 +00:00
|
|
|
#ifdef STRUCT_TRACKERS_ENABLED
|
2012-11-25 16:24:41 +00:00
|
|
|
EXTERN uint32_t sectorchanged[MAXSECTORS + M32_FIXME_SECTORS];
|
|
|
|
EXTERN uint32_t wallchanged[MAXWALLS + M32_FIXME_WALLS];
|
|
|
|
EXTERN uint32_t spritechanged[MAXSPRITES];
|
2018-03-17 03:26:01 +00:00
|
|
|
#endif
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2013-04-09 17:35:11 +00:00
|
|
|
#ifdef NEW_MAP_FORMAT
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int16_t yax_getbunch(int16_t i, int16_t cf)
|
2013-04-09 17:35:11 +00:00
|
|
|
{
|
|
|
|
return cf ? sector[i].floorbunch : sector[i].ceilingbunch;
|
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void yax_getbunches(int16_t i, int16_t *cb, int16_t *fb)
|
2013-04-09 17:35:11 +00:00
|
|
|
{
|
|
|
|
*cb = yax_getbunch(i, YAX_CEILING);
|
|
|
|
*fb = yax_getbunch(i, YAX_FLOOR);
|
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int16_t yax_getnextwall(int16_t wal, int16_t cf)
|
2013-04-09 17:35:11 +00:00
|
|
|
{
|
|
|
|
return cf ? wall[wal].dnwall : wall[wal].upwall;
|
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void yax_setnextwall(int16_t wal, int16_t cf, int16_t thenextwall)
|
2013-04-09 17:35:11 +00:00
|
|
|
{
|
|
|
|
YAX_NEXTWALL(wal, cf) = thenextwall;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-03-17 03:26:01 +00:00
|
|
|
#ifdef STRUCT_TRACKERS_ENABLED
|
2017-06-24 06:31:21 +00:00
|
|
|
static FORCE_INLINE void sector_tracker_hook(uintptr_t const address)
|
2012-11-09 22:31:02 +00:00
|
|
|
{
|
2015-01-11 04:55:07 +00:00
|
|
|
uintptr_t const usector = address - (uintptr_t)sector;
|
2014-10-25 03:36:34 +00:00
|
|
|
|
2015-01-11 04:55:07 +00:00
|
|
|
#if DEBUGGINGAIDS
|
|
|
|
Bassert(usector < ((MAXSECTORS + M32_FIXME_SECTORS) * sizeof(sectortype)));
|
|
|
|
#endif
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2016-06-21 00:34:18 +00:00
|
|
|
++sectorchanged[usector / sizeof(sectortype)];
|
2012-11-09 22:31:02 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 06:31:21 +00:00
|
|
|
static FORCE_INLINE void wall_tracker_hook(uintptr_t const address)
|
2012-11-09 22:31:02 +00:00
|
|
|
{
|
2015-01-11 04:55:07 +00:00
|
|
|
uintptr_t const uwall = address - (uintptr_t)wall;
|
2014-10-25 03:36:34 +00:00
|
|
|
|
2015-01-11 04:55:07 +00:00
|
|
|
#if DEBUGGINGAIDS
|
|
|
|
Bassert(uwall < ((MAXWALLS + M32_FIXME_WALLS) * sizeof(walltype)));
|
|
|
|
#endif
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2016-06-21 00:34:18 +00:00
|
|
|
++wallchanged[uwall / sizeof(walltype)];
|
2012-11-09 22:31:02 +00:00
|
|
|
}
|
|
|
|
|
2017-06-24 06:31:21 +00:00
|
|
|
static FORCE_INLINE void sprite_tracker_hook(uintptr_t const address)
|
2012-11-09 22:31:02 +00:00
|
|
|
{
|
2015-01-11 04:55:07 +00:00
|
|
|
uintptr_t const usprite = address - (uintptr_t)sprite;
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2015-01-11 04:55:07 +00:00
|
|
|
#if DEBUGGINGAIDS
|
|
|
|
Bassert(usprite < (MAXSPRITES * sizeof(spritetype)));
|
|
|
|
#endif
|
2014-10-25 03:36:34 +00:00
|
|
|
|
2016-06-21 00:34:18 +00:00
|
|
|
++spritechanged[usprite / sizeof(spritetype)];
|
2012-11-09 22:31:02 +00:00
|
|
|
}
|
2018-03-17 03:26:01 +00:00
|
|
|
#endif
|
2012-11-09 22:31:02 +00:00
|
|
|
|
2014-10-25 03:36:34 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt;
|
|
|
|
EXTERN int16_t thewall[MAXWALLSB];
|
2019-04-18 17:25:24 +00:00
|
|
|
EXTERN tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1];
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2016-06-21 00:33:14 +00:00
|
|
|
EXTERN int32_t wx1, wy1, wx2, wy2;
|
2018-07-14 21:36:44 +00:00
|
|
|
EXTERN int32_t xdim, ydim, numpages, upscalefactor;
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int32_t yxaspect, viewingrange;
|
2014-10-29 17:04:28 +00:00
|
|
|
EXTERN intptr_t *ylookup;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2019-01-30 00:19:56 +00:00
|
|
|
EXTERN int32_t rotatesprite_y_offset;
|
|
|
|
EXTERN int32_t rotatesprite_yxaspect;
|
|
|
|
|
2014-05-17 12:36:40 +00:00
|
|
|
#ifndef GEKKO
|
2007-09-05 21:56:58 +00:00
|
|
|
#define MAXVALIDMODES 256
|
2014-05-17 12:36:40 +00:00
|
|
|
#else
|
|
|
|
#define MAXVALIDMODES 16
|
|
|
|
#endif
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int32_t validmodecnt;
|
2007-09-05 21:56:58 +00:00
|
|
|
struct validmode_t {
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t xdim,ydim;
|
2007-09-05 21:56:58 +00:00
|
|
|
char bpp;
|
|
|
|
char fs; // bit 0 = fullscreen flag
|
|
|
|
char filler[2];
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t extra; // internal use
|
2007-09-05 21:56:58 +00:00
|
|
|
};
|
|
|
|
EXTERN struct validmode_t validmode[MAXVALIDMODES];
|
|
|
|
|
2011-03-23 17:41:01 +00:00
|
|
|
EXTERN int32_t numyaxbunches;
|
|
|
|
#ifdef YAX_ENABLE
|
|
|
|
// Singly-linked list of sectnums grouped by bunches and ceiling (0)/floor (1)
|
|
|
|
// Usage e.g.:
|
|
|
|
// int16_t bunchnum = yax_getbunch(somesector, YAX_CEILING);
|
|
|
|
// Iteration over all sectors whose floor bunchnum equals 'bunchnum' (i.e. "all
|
|
|
|
// floors of the other side"):
|
|
|
|
// for (i=headsectbunch[1][bunchnum]; i!=-1; i=nextsectbunch[1][i])
|
|
|
|
// <do stuff with sector i...>
|
|
|
|
|
|
|
|
EXTERN int16_t headsectbunch[2][YAX_MAXBUNCHES], nextsectbunch[2][MAXSECTORS];
|
|
|
|
#endif
|
|
|
|
|
2012-03-14 22:30:24 +00:00
|
|
|
EXTERN int32_t Numsprites;
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int16_t numsectors, numwalls;
|
2008-04-10 08:24:06 +00:00
|
|
|
EXTERN char display_mirror;
|
2014-04-19 22:42:21 +00:00
|
|
|
// totalclocklock: the totalclock value that is backed up once on each
|
|
|
|
// drawrooms() and is used for animateoffs().
|
|
|
|
EXTERN int32_t totalclock, totalclocklock;
|
2014-07-28 06:43:16 +00:00
|
|
|
static inline int32_t BGetTime(void) { return totalclock; }
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int32_t numframes, randomseed;
|
|
|
|
EXTERN int16_t sintable[2048];
|
2015-09-23 17:54:50 +00:00
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
EXTERN uint8_t palette[768];
|
2012-03-20 18:32:00 +00:00
|
|
|
EXTERN int16_t numshades;
|
2007-09-05 21:56:58 +00:00
|
|
|
EXTERN char *palookup[MAXPALOOKUPS];
|
2015-09-23 17:55:02 +00:00
|
|
|
extern uint8_t *basepaltable[MAXBASEPALS];
|
2015-09-23 17:54:50 +00:00
|
|
|
EXTERN uint8_t paletteloaded;
|
2015-09-23 17:55:19 +00:00
|
|
|
EXTERN char *blendtable[MAXBLENDTABS];
|
2015-12-28 02:04:36 +00:00
|
|
|
EXTERN uint8_t whitecol, redcol;
|
2015-09-23 17:54:50 +00:00
|
|
|
|
2017-07-08 19:42:11 +00:00
|
|
|
EXTERN int32_t maxspritesonscreen;
|
2017-07-08 19:41:49 +00:00
|
|
|
|
2015-09-23 17:54:50 +00:00
|
|
|
enum {
|
|
|
|
PALETTE_MAIN = 1<<0,
|
|
|
|
PALETTE_SHADE = 1<<1,
|
|
|
|
PALETTE_TRANSLUC = 1<<2,
|
|
|
|
};
|
|
|
|
|
2013-08-04 20:37:45 +00:00
|
|
|
EXTERN char showinvisibility;
|
2012-12-14 19:28:05 +00:00
|
|
|
EXTERN int32_t g_visibility, parallaxvisibility;
|
2012-12-14 19:27:55 +00:00
|
|
|
EXTERN int32_t g_rotatespriteNoWidescreen;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2015-04-09 07:51:48 +00:00
|
|
|
// blendtable[1] to blendtable[numalphatabs] are considered to be
|
|
|
|
// alpha-blending tables:
|
|
|
|
EXTERN uint8_t numalphatabs;
|
|
|
|
|
2016-06-21 00:34:18 +00:00
|
|
|
EXTERN vec2_t windowxy1, windowxy2;
|
2014-10-29 17:04:28 +00:00
|
|
|
EXTERN int16_t *startumost, *startdmost;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2013-08-04 20:37:45 +00:00
|
|
|
// The maximum tile offset ever used in any tiled parallaxed multi-sky.
|
2016-10-14 07:40:56 +00:00
|
|
|
#define PSKYOFF_MAX 8
|
2015-05-27 08:47:34 +00:00
|
|
|
#define DEFAULTPSKY -1
|
2013-08-04 20:37:45 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
// The proportion at which looking up/down affects the apparent 'horiz' of
|
|
|
|
// a parallaxed sky, scaled by 65536 (so, a value of 65536 makes it align
|
|
|
|
// with the drawn surrounding scene):
|
|
|
|
int32_t horizfrac;
|
|
|
|
|
|
|
|
// The texel index offset in the y direction of a parallaxed sky:
|
|
|
|
// XXX: currently always 0.
|
|
|
|
int32_t yoffs;
|
|
|
|
|
2013-11-22 19:26:44 +00:00
|
|
|
int8_t lognumtiles; // 1<<lognumtiles: number of tiles in multi-sky
|
|
|
|
int8_t tileofs[MAXPSKYTILES]; // for 0 <= j < (1<<lognumtiles): tile offset relative to basetile
|
2017-11-29 07:29:48 +00:00
|
|
|
|
|
|
|
int32_t yscale;
|
2013-08-04 20:37:45 +00:00
|
|
|
} psky_t;
|
|
|
|
|
Clean up parallaxed sky functionality, part 2.
- Rename sky_t members: yscale -> horizfrac, bits -> lognumtiles.
- Add default sky (8 tiles, horizfrac=32768 (i.e. 1/2 the scene horiz), offsets
all zero) and CLOUDYOCEAN sky (8 tiles, horizfrac=65536, offsets all zero)
to multipsky[].
- Get rid of "psky_t g_psky", merely maintaining a g_pskyidx instead. Set it up
at map load time so as to keep the behavior of the legacy per-map psky:
the last sector index with a matching psky ceiling wins.
- In mapstate_t, save g_pskyidx too, not (former) pskybits and pskyoffs[].
- Make on-map-load global psky setup consistent for the game and editor by
factoring it out into common.c: G_SetupGlobalPsky().
- Remove a couple of useless initializations, add some static assertions.
This commit is more likely to introduce subtle differences in behavior.
Specifically, getpsky() now always returns the default sky properties instead of
the global sky ones (but with all-zero offsets) when no match for a suiting
multi-psky is found. This is only likely to affect the yscale/horizfrac of
non-multi-pskies when a global non-default multi-psky has been set up.
Bump BYTEVERSION again.
git-svn-id: https://svn.eduke32.com/eduke32@3976 1a8010ca-5511-0410-912e-c29ae57300e0
2013-08-04 20:37:48 +00:00
|
|
|
// Index of map-global (legacy) multi-sky:
|
|
|
|
EXTERN int32_t g_pskyidx;
|
2015-05-27 08:47:34 +00:00
|
|
|
// New multi-psky
|
2013-08-04 20:37:45 +00:00
|
|
|
EXTERN int32_t pskynummultis;
|
2015-05-27 08:47:34 +00:00
|
|
|
EXTERN psky_t * multipsky;
|
2013-08-04 20:37:45 +00:00
|
|
|
// Mapping of multi-sky index to base sky tile number:
|
2015-05-27 08:47:34 +00:00
|
|
|
EXTERN int32_t * multipskytile;
|
2013-08-04 20:37:45 +00:00
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t getpskyidx(int32_t picnum)
|
2013-08-11 15:28:51 +00:00
|
|
|
{
|
|
|
|
int32_t j;
|
|
|
|
|
2015-06-06 15:04:17 +00:00
|
|
|
for (j=pskynummultis-1; j>0; j--) // NOTE: j==0 on non-early loop end
|
2013-08-11 15:28:51 +00:00
|
|
|
if (picnum == multipskytile[j])
|
|
|
|
break; // Have a match.
|
|
|
|
|
|
|
|
return j;
|
|
|
|
}
|
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
EXTERN psky_t * tileSetupSky(int32_t tilenum);
|
2015-05-27 08:47:34 +00:00
|
|
|
|
2013-08-04 20:37:45 +00:00
|
|
|
EXTERN char parallaxtype;
|
2015-05-19 22:05:20 +00:00
|
|
|
EXTERN int32_t parallaxyoffs_override, parallaxyscale_override;
|
|
|
|
extern int16_t pskybits_override;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2012-03-13 20:07:17 +00:00
|
|
|
// last sprite in the freelist, that is the spritenum for which
|
|
|
|
// .statnum==MAXSTATUS && nextspritestat[spritenum]==-1
|
|
|
|
// (or -1 if freelist is empty):
|
|
|
|
EXTERN int16_t tailspritefree;
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int16_t headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1];
|
|
|
|
EXTERN int16_t prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES];
|
|
|
|
EXTERN int16_t nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES];
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2017-06-24 09:21:13 +00:00
|
|
|
EXTERN vec2s_t tilesiz[MAXTILES];
|
2014-09-30 04:14:21 +00:00
|
|
|
|
2007-09-05 21:56:58 +00:00
|
|
|
EXTERN char picsiz[MAXTILES];
|
|
|
|
EXTERN char walock[MAXTILES];
|
2018-11-18 18:05:26 +00:00
|
|
|
|
|
|
|
extern const char pow2char_[];
|
|
|
|
static CONSTEXPR const char pow2char[8] = {1,2,4,8,16,32,64,128};
|
|
|
|
static CONSTEXPR const int32_t pow2long[32] =
|
|
|
|
{
|
|
|
|
1, 2, 4, 8,
|
|
|
|
16, 32, 64, 128,
|
|
|
|
256, 512, 1024, 2048,
|
|
|
|
4096, 8192, 16384, 32768,
|
|
|
|
65536, 131072, 262144, 524288,
|
|
|
|
1048576, 2097152, 4194304, 8388608,
|
|
|
|
16777216, 33554432, 67108864, 134217728,
|
|
|
|
268435456, 536870912, 1073741824, 2147483647
|
|
|
|
};
|
2012-11-17 19:46:28 +00:00
|
|
|
|
|
|
|
// picanm[].sf:
|
|
|
|
// |bit(1<<7)
|
|
|
|
// |animtype|animtype|texhitscan|nofullbright|speed|speed|speed|speed|
|
|
|
|
enum {
|
|
|
|
PICANM_ANIMTYPE_NONE = 0,
|
|
|
|
PICANM_ANIMTYPE_OSC = (1<<6),
|
|
|
|
PICANM_ANIMTYPE_FWD = (2<<6),
|
|
|
|
PICANM_ANIMTYPE_BACK = (3<<6),
|
|
|
|
|
|
|
|
PICANM_ANIMTYPE_SHIFT = 6,
|
|
|
|
PICANM_ANIMTYPE_MASK = (3<<6), // must be 192
|
|
|
|
PICANM_MISC_MASK = (3<<4),
|
|
|
|
PICANM_TEXHITSCAN_BIT = (2<<4),
|
|
|
|
PICANM_NOFULLBRIGHT_BIT = (1<<4),
|
|
|
|
PICANM_ANIMSPEED_MASK = 15, // must be 15
|
|
|
|
};
|
|
|
|
|
|
|
|
// NOTE: If the layout of this struct is changed, loadpics() must be modified
|
|
|
|
// accordingly.
|
|
|
|
typedef struct {
|
|
|
|
uint8_t num; // animate number
|
|
|
|
int8_t xofs, yofs;
|
|
|
|
uint8_t sf; // anim. speed and flags
|
2019-09-19 20:02:45 +00:00
|
|
|
uint8_t extra;
|
2012-11-17 19:46:28 +00:00
|
|
|
} picanm_t;
|
|
|
|
EXTERN picanm_t picanm[MAXTILES];
|
2018-12-15 01:37:19 +00:00
|
|
|
typedef struct { int16_t newtile; int16_t owner; } rottile_t;
|
2018-11-18 18:13:48 +00:00
|
|
|
EXTERN rottile_t rottile[MAXTILES];
|
2008-02-16 22:27:08 +00:00
|
|
|
EXTERN intptr_t waloff[MAXTILES]; // stores pointers to cache -- SA
|
2007-04-22 03:44:54 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int32_t windowpos, windowx, windowy;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
|
|
|
//These variables are for auto-mapping with the draw2dscreen function.
|
|
|
|
//When you load a new board, these bits are all set to 0 - since
|
|
|
|
//you haven't mapped out anything yet. Note that these arrays are
|
|
|
|
//bit-mapped.
|
|
|
|
//If you want draw2dscreen() to show sprite #54 then you say:
|
|
|
|
// spritenum = 54;
|
|
|
|
// show2dsprite[spritenum>>3] |= (1<<(spritenum&7));
|
|
|
|
//And if you want draw2dscreen() to not show sprite #54 then you say:
|
|
|
|
// spritenum = 54;
|
|
|
|
// show2dsprite[spritenum>>3] &= ~(1<<(spritenum&7));
|
|
|
|
|
|
|
|
EXTERN char show2dsector[(MAXSECTORS+7)>>3];
|
|
|
|
EXTERN char show2dwall[(MAXWALLS+7)>>3];
|
|
|
|
EXTERN char show2dsprite[(MAXSPRITES+7)>>3];
|
|
|
|
|
2012-11-09 17:35:58 +00:00
|
|
|
// In the editor, gotpic is only referenced from inline assembly;
|
|
|
|
// the compiler needs that hint or building with LTO will discard it.
|
2014-07-22 07:25:54 +00:00
|
|
|
#if !defined __clang__ && !defined NOASM
|
2012-11-15 06:42:00 +00:00
|
|
|
# define GOTPIC_USED ATTRIBUTE((used))
|
|
|
|
#else
|
|
|
|
# define GOTPIC_USED
|
|
|
|
#endif
|
|
|
|
|
|
|
|
EXTERN char GOTPIC_USED gotpic[(MAXTILES+7)>>3];
|
2007-09-05 21:56:58 +00:00
|
|
|
EXTERN char gotsector[(MAXSECTORS+7)>>3];
|
|
|
|
|
2008-12-23 23:27:53 +00:00
|
|
|
EXTERN char editorcolors[256];
|
|
|
|
|
2015-03-24 00:40:48 +00:00
|
|
|
EXTERN char faketile[(MAXTILES+7)>>3];
|
2009-11-18 01:17:56 +00:00
|
|
|
EXTERN char *faketiledata[MAXTILES];
|
|
|
|
|
|
|
|
EXTERN char spritecol2d[MAXTILES][2];
|
2015-07-08 03:34:46 +00:00
|
|
|
EXTERN uint8_t tilecols[MAXTILES];
|
|
|
|
|
2015-09-23 17:55:11 +00:00
|
|
|
extern uint8_t vgapal16[4*256];
|
2009-11-18 01:17:56 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern uint32_t drawlinepat;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
|
|
|
extern void faketimerhandler(void);
|
|
|
|
|
|
|
|
extern char apptitle[256];
|
2014-12-13 22:33:04 +00:00
|
|
|
|
2012-02-27 19:40:28 +00:00
|
|
|
extern int32_t novoxmips;
|
2010-08-26 15:24:12 +00:00
|
|
|
|
2012-12-31 01:50:45 +00:00
|
|
|
#ifdef DEBUGGINGAIDS
|
2010-08-26 15:24:12 +00:00
|
|
|
extern float debug1, debug2;
|
2012-12-31 01:50:45 +00:00
|
|
|
#endif
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2012-01-19 21:57:46 +00:00
|
|
|
extern int16_t tiletovox[MAXTILES];
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t usevoxels, voxscale[MAXVOXELS];
|
2011-03-04 08:50:58 +00:00
|
|
|
|
|
|
|
#ifdef USE_OPENGL
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t usemodels, usehightile;
|
|
|
|
extern int32_t rendmode;
|
2007-09-05 21:56:58 +00:00
|
|
|
#endif
|
2018-02-15 03:49:23 +00:00
|
|
|
extern uint8_t globalr, globalg, globalb;
|
2015-03-24 00:40:48 +00:00
|
|
|
EXTERN uint16_t h_xsize[MAXTILES], h_ysize[MAXTILES];
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int8_t h_xoffs[MAXTILES], h_yoffs[MAXTILES];
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2016-06-21 00:33:06 +00:00
|
|
|
EXTERN char *globalpalwritten;
|
|
|
|
|
2015-03-09 20:32:36 +00:00
|
|
|
enum {
|
|
|
|
GLOBAL_NO_GL_TILESHADES = 1<<0,
|
|
|
|
GLOBAL_NO_GL_FULLBRIGHT = 1<<1,
|
2017-12-12 05:14:06 +00:00
|
|
|
GLOBAL_NO_GL_FOGSHADE = 1<<2,
|
2015-03-09 20:32:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern int32_t globalflags;
|
|
|
|
|
2011-02-21 23:08:21 +00:00
|
|
|
extern const char *engineerrstr;
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
EXTERN int32_t editorzrange[2];
|
2008-11-05 11:49:13 +00:00
|
|
|
|
2018-04-12 21:03:12 +00:00
|
|
|
static FORCE_INLINE int32_t videoGetRenderMode(void)
|
2009-02-19 09:39:19 +00:00
|
|
|
{
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifndef USE_OPENGL
|
2012-12-30 20:34:55 +00:00
|
|
|
return REND_CLASSIC;
|
2009-02-19 09:39:19 +00:00
|
|
|
#else
|
|
|
|
return rendmode;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-09-05 21:56:58 +00:00
|
|
|
/*************************************************************************
|
|
|
|
POSITION VARIABLES:
|
|
|
|
|
|
|
|
POSX is your x - position ranging from 0 to 65535
|
|
|
|
POSY is your y - position ranging from 0 to 65535
|
|
|
|
(the length of a side of the grid in EDITBORD would be 1024)
|
|
|
|
POSZ is your z - position (height) ranging from 0 to 65535, 0 highest.
|
|
|
|
ANG is your angle ranging from 0 to 2047. Instead of 360 degrees, or
|
|
|
|
2 * PI radians, I use 2048 different angles, so 90 degrees would
|
|
|
|
be 512 in my system.
|
|
|
|
|
|
|
|
SPRITE VARIABLES:
|
|
|
|
|
|
|
|
EXTERN short headspritesect[MAXSECTORS+1], headspritestat[MAXSTATUS+1];
|
|
|
|
EXTERN short prevspritesect[MAXSPRITES], prevspritestat[MAXSPRITES];
|
|
|
|
EXTERN short nextspritesect[MAXSPRITES], nextspritestat[MAXSPRITES];
|
|
|
|
|
|
|
|
Example: if the linked lists look like the following:
|
2009-11-14 02:30:47 +00:00
|
|
|
????????????????
|
2016-06-05 04:46:28 +00:00
|
|
|
Sector lists: Status lists:
|
2009-11-14 02:30:47 +00:00
|
|
|
????????????????J
|
2016-06-05 04:46:28 +00:00
|
|
|
Sector0: 4, 5, 8 Status0: 2, 0, 8
|
|
|
|
Sector1: 16, 2, 0, 7 Status1: 4, 5, 16, 7, 3, 9
|
|
|
|
Sector2: 3, 9
|
2009-11-14 02:30:47 +00:00
|
|
|
????????????????
|
2007-09-05 21:56:58 +00:00
|
|
|
Notice that each number listed above is shown exactly once on both the
|
|
|
|
left and right side. This is because any sprite that exists must
|
|
|
|
be in some sector, and must have some kind of status that you define.
|
|
|
|
|
|
|
|
|
|
|
|
Coding example #1:
|
|
|
|
To go through all the sprites in sector 1, the code can look like this:
|
|
|
|
|
|
|
|
sectnum = 1;
|
|
|
|
i = headspritesect[sectnum];
|
|
|
|
while (i != -1)
|
|
|
|
{
|
|
|
|
nexti = nextspritesect[i];
|
|
|
|
|
|
|
|
//your code goes here
|
|
|
|
//ex: printf("Sprite %d is in sector %d\n",i,sectnum);
|
|
|
|
|
|
|
|
i = nexti;
|
|
|
|
}
|
|
|
|
|
|
|
|
Coding example #2:
|
|
|
|
To go through all sprites with status = 1, the code can look like this:
|
|
|
|
|
|
|
|
statnum = 1; //status 1
|
|
|
|
i = headspritestat[statnum];
|
|
|
|
while (i != -1)
|
|
|
|
{
|
|
|
|
nexti = nextspritestat[i];
|
|
|
|
|
|
|
|
//your code goes here
|
|
|
|
//ex: printf("Sprite %d has a status of 1 (active)\n",i,statnum);
|
|
|
|
|
|
|
|
i = nexti;
|
|
|
|
}
|
|
|
|
|
|
|
|
insertsprite(short sectnum, short statnum);
|
|
|
|
deletesprite(short spritenum);
|
|
|
|
changespritesect(short spritenum, short newsectnum);
|
|
|
|
changespritestat(short spritenum, short newstatnum);
|
|
|
|
|
|
|
|
TILE VARIABLES:
|
|
|
|
NUMTILES - the number of tiles found TILES.DAT.
|
|
|
|
TILESIZX[MAXTILES] - simply the x-dimension of the tile number.
|
|
|
|
TILESIZY[MAXTILES] - simply the y-dimension of the tile number.
|
2012-03-13 20:07:40 +00:00
|
|
|
WALOFF[MAXTILES] - the actual address pointing to the top-left
|
2007-09-05 21:56:58 +00:00
|
|
|
corner of the tile.
|
|
|
|
PICANM[MAXTILES] - flags for animating the tile.
|
|
|
|
|
|
|
|
TIMING VARIABLES:
|
|
|
|
TOTALCLOCK - When the engine is initialized, TOTALCLOCK is set to zero.
|
|
|
|
From then on, it is incremented 120 times a second by 1. That
|
|
|
|
means that the number of seconds elapsed is totalclock / 120.
|
|
|
|
NUMFRAMES - The number of times the draw3dscreen function was called
|
|
|
|
since the engine was initialized. This helps to determine frame
|
|
|
|
rate. (Frame rate = numframes * 120 / totalclock.)
|
|
|
|
|
|
|
|
OTHER VARIABLES:
|
|
|
|
|
|
|
|
STARTUMOST[320] is an array of the highest y-coordinates on each column
|
|
|
|
that my engine is allowed to write to. You need to set it only
|
|
|
|
once.
|
|
|
|
STARTDMOST[320] is an array of the lowest y-coordinates on each column
|
|
|
|
that my engine is allowed to write to. You need to set it only
|
|
|
|
once.
|
|
|
|
SINTABLE[2048] is a sin table with 2048 angles rather than the
|
|
|
|
normal 360 angles for higher precision. Also since SINTABLE is in
|
|
|
|
all integers, the range is multiplied by 16383, so instead of the
|
|
|
|
normal -1<sin(x)<1, the range of sintable is -16383<sintable[]<16383
|
|
|
|
If you use this sintable, you can possibly speed up your code as
|
|
|
|
well as save space in memory. If you plan to use sintable, 2
|
|
|
|
identities you may want to keep in mind are:
|
|
|
|
sintable[ang&2047] = sin(ang * (3.141592/1024)) * 16383
|
|
|
|
sintable[(ang+512)&2047] = cos(ang * (3.141592/1024)) * 16383
|
|
|
|
NUMSECTORS - the total number of existing sectors. Modified every time
|
|
|
|
you call the loadboard function.
|
|
|
|
***************************************************************************/
|
|
|
|
|
2009-01-13 12:23:18 +00:00
|
|
|
typedef struct {
|
|
|
|
vec3_t pos;
|
2012-08-10 19:12:01 +00:00
|
|
|
int16_t sprite, wall, sect;
|
2009-01-13 12:23:18 +00:00
|
|
|
} hitdata_t;
|
|
|
|
|
2015-04-12 08:07:10 +00:00
|
|
|
typedef struct artheader_t {
|
|
|
|
int32_t tilestart, tileend, numtiles;
|
|
|
|
} artheader_t;
|
2015-05-03 07:04:49 +00:00
|
|
|
#define ARTv1_UNITOFFSET ((signed)(4*sizeof(int32_t) + 2*sizeof(int16_t) + sizeof(picanm_t)))
|
2009-07-24 02:31:34 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t enginePreInit(void); // a partial setup of the engine used for launch windows
|
|
|
|
int32_t engineInit(void);
|
|
|
|
int32_t enginePostInit(void);
|
|
|
|
void engineUnInit(void);
|
2007-09-05 21:56:58 +00:00
|
|
|
void initspritelists(void);
|
2018-10-16 06:09:20 +00:00
|
|
|
int32_t engineFatalError(char const * msg);
|
2015-09-23 17:54:50 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t engineLoadBoard(const char *filename, char flags, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
|
|
|
|
int32_t engineLoadMHK(const char *filename);
|
|
|
|
void engineClearLightsFromMHK();
|
2012-03-18 08:50:41 +00:00
|
|
|
#ifdef HAVE_CLIPSHAPE_FEATURE
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t engineLoadClipMaps(void);
|
Inreased debugging level for catching oob accesses to 'main' arrays.
If enabled, this makes the following arrays be allocated statically:
spriteext, spritesmooth, sector, wall, sprite, tsprite, while
necessarily disabling the clipshape feature (because it relies on
setting sector/wall to different malloc'd block temporarily).
To compile, pass DEBUGANYWAY=1 in addition to RELEASE=0 to 'make',
and it's really only useful with CC=clang, of course.
git-svn-id: https://svn.eduke32.com/eduke32@2270 1a8010ca-5511-0410-912e-c29ae57300e0
2012-01-19 23:17:34 +00:00
|
|
|
#endif
|
2012-10-01 17:52:30 +00:00
|
|
|
int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int16_t dacursectnum);
|
2015-04-12 08:07:10 +00:00
|
|
|
|
2018-10-16 06:09:20 +00:00
|
|
|
void tileSetupDummy(int32_t tile);
|
|
|
|
void tileSetData(int32_t tile, int32_t tsiz, char const *buffer);
|
|
|
|
void tileDelete(int32_t tile);
|
2018-04-12 21:03:47 +00:00
|
|
|
void tileSetSize(int32_t picnum, int16_t dasizx, int16_t dasizy);
|
2019-03-01 08:51:50 +00:00
|
|
|
int32_t artReadHeader(buildvfs_kfd fil, char const *fn, artheader_t *local);
|
2018-10-16 06:09:20 +00:00
|
|
|
int32_t artReadHeaderFromBuffer(uint8_t const *buf, artheader_t *local);
|
|
|
|
int32_t artCheckUnitFileHeader(uint8_t const *buf, int32_t length);
|
2019-09-19 20:02:45 +00:00
|
|
|
void tileConvertAnimFormat(int32_t const picnum, int32_t const picanmdisk);
|
2019-03-01 08:51:50 +00:00
|
|
|
void artReadManifest(buildvfs_kfd fil, artheader_t const *local);
|
|
|
|
void artPreloadFile(buildvfs_kfd fil, artheader_t const *local);
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t artLoadFiles(const char *filename, int32_t askedsize);
|
|
|
|
void artClearMapArt(void);
|
|
|
|
void artSetupMapArt(const char *filename);
|
|
|
|
bool tileLoad(int16_t tilenume);
|
|
|
|
void tileLoadData(int16_t tilenume, int32_t dasiz, char *buffer);
|
2019-03-02 23:21:37 +00:00
|
|
|
int32_t tileCRC(int16_t tileNum);
|
2018-04-12 21:03:47 +00:00
|
|
|
void artConvertRGB(palette_t *pic, uint8_t const *buf, int32_t bufsizx, int32_t sizx, int32_t sizy);
|
2019-09-19 20:02:45 +00:00
|
|
|
void tileUpdatePicSiz(int32_t picnum);
|
2015-04-12 08:07:10 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
int32_t qloadkvx(int32_t voxindex, const char *filename);
|
2016-10-25 05:43:50 +00:00
|
|
|
void vox_undefine(int32_t const);
|
2018-04-12 21:03:30 +00:00
|
|
|
intptr_t tileCreate(int16_t tilenume, int32_t xsiz, int32_t ysiz);
|
|
|
|
void tileCopySection(int32_t tilenume1, int32_t sx1, int32_t sy1, int32_t xsiz, int32_t ysiz, int32_t tilenume2, int32_t sx2, int32_t sy2);
|
2009-01-09 09:29:17 +00:00
|
|
|
void squarerotatetile(int16_t tilenume);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2018-07-14 21:36:44 +00:00
|
|
|
int32_t videoSetGameMode(char davidoption, int32_t daupscaledxdim, int32_t daupscaledydim, int32_t dabpp, int32_t daupscalefactor);
|
2018-04-12 21:02:51 +00:00
|
|
|
void videoNextPage(void);
|
|
|
|
void videoSetCorrectedAspect();
|
|
|
|
void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2);
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderSetAspect(int32_t daxrange, int32_t daaspect);
|
2018-04-12 21:04:00 +00:00
|
|
|
void renderFlushPerms(void);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2015-07-17 00:12:40 +00:00
|
|
|
void plotlines2d(const int32_t *xx, const int32_t *yy, int32_t numpoints, int col) ATTRIBUTE((nonnull(1,2)));
|
2010-08-14 21:32:28 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void plotpixel(int32_t x, int32_t y, char col);
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderSetTarget(int16_t tilenume, int32_t xsiz, int32_t ysiz);
|
|
|
|
void renderRestoreTarget(void);
|
|
|
|
void renderPrepareMirror(int32_t dax, int32_t day, fix16_t daang, int16_t dawall,
|
2018-03-07 04:21:18 +00:00
|
|
|
int32_t *tposx, int32_t *tposy, fix16_t *tang);
|
2019-09-19 20:02:45 +00:00
|
|
|
void renderPrepareMirrorOld(int32_t dax, int32_t day, int32_t daz, fix16_t daang, fix16_t dahoriz,
|
|
|
|
int16_t dawall, int16_t dasector, int32_t *tposx, int32_t *tposy, fix16_t *tang);
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderCompleteMirror(void);
|
2019-09-19 20:02:45 +00:00
|
|
|
void renderCompleteMirrorOld(void);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz, fix16_t daang, fix16_t dahoriz, int16_t dacursectnum);
|
2018-03-09 05:55:50 +00:00
|
|
|
|
|
|
|
static FORCE_INLINE int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, int16_t daang, int16_t dahoriz, int16_t dacursectnum)
|
|
|
|
{
|
2018-04-12 21:03:47 +00:00
|
|
|
return renderDrawRoomsQ16(daposx, daposy, daposz, fix16_from_int(daang), fix16_from_int(dahoriz), dacursectnum);
|
2018-03-09 05:55:50 +00:00
|
|
|
}
|
2018-03-07 12:02:03 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderDrawMasks(void);
|
2018-04-12 21:02:51 +00:00
|
|
|
void videoClearViewableArea(int32_t dacol);
|
|
|
|
void videoClearScreen(int32_t dacol);
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang);
|
2013-03-25 04:32:24 +00:00
|
|
|
void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
2014-03-05 21:12:54 +00:00
|
|
|
int8_t dashade, char dapalnum, int32_t dastat, uint8_t daalpha, uint8_t dablend,
|
|
|
|
int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2);
|
2018-04-12 21:04:00 +00:00
|
|
|
void renderDrawLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, char col);
|
2018-10-16 06:09:20 +00:00
|
|
|
void drawlinergb(int32_t x1, int32_t y1, int32_t x2, int32_t y2, palette_t p);
|
2012-08-16 21:48:08 +00:00
|
|
|
int32_t printext16(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol,
|
|
|
|
const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
|
|
|
|
void printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t backcol,
|
|
|
|
const char *name, char fontsize) ATTRIBUTE((nonnull(5)));
|
2016-06-21 00:34:25 +00:00
|
|
|
void Buninitart(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2012-02-02 17:35:05 +00:00
|
|
|
////////// specialized rotatesprite wrappers for (very) often used cases //////////
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void rotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
2013-03-25 04:32:24 +00:00
|
|
|
int8_t dashade, char dapalnum, int32_t dastat,
|
|
|
|
int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2)
|
|
|
|
{
|
2014-03-05 21:12:54 +00:00
|
|
|
rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, cx1, cy1, cx2, cy2);
|
2013-03-25 04:32:24 +00:00
|
|
|
}
|
2013-04-05 17:52:50 +00:00
|
|
|
// Don't clip at all, i.e. the whole screen real estate is available:
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void rotatesprite_fs(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
2012-08-16 21:48:08 +00:00
|
|
|
int8_t dashade, char dapalnum, int32_t dastat)
|
2012-02-02 17:35:05 +00:00
|
|
|
{
|
2014-03-05 21:12:54 +00:00
|
|
|
rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, 0,0,xdim-1,ydim-1);
|
2012-02-02 17:35:05 +00:00
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void rotatesprite_fs_alpha(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
2015-01-15 06:45:14 +00:00
|
|
|
int8_t dashade, char dapalnum, int32_t dastat, uint8_t alpha)
|
|
|
|
{
|
|
|
|
rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, alpha, 0, 0, 0, xdim-1, ydim-1);
|
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void rotatesprite_win(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
2012-08-16 21:48:08 +00:00
|
|
|
int8_t dashade, char dapalnum, int32_t dastat)
|
2012-02-04 21:35:00 +00:00
|
|
|
{
|
2016-06-21 00:34:18 +00:00
|
|
|
rotatesprite_(sx, sy, z, a, picnum, dashade, dapalnum, dastat, 0, 0, windowxy1.x,windowxy1.y,windowxy2.x,windowxy2.y);
|
2012-02-04 21:35:00 +00:00
|
|
|
}
|
|
|
|
|
2019-04-06 06:37:32 +00:00
|
|
|
void bfirst_search_init(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const maxelts, int const firstelt);
|
|
|
|
void bfirst_search_try(int16_t * const list, uint8_t * const bitmap, int32_t * const eltnumptr, int const elt);
|
2012-01-14 14:48:30 +00:00
|
|
|
|
2018-10-16 06:09:20 +00:00
|
|
|
void getzrange(const vec3_t *pos, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
2012-08-16 21:48:08 +00:00
|
|
|
int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(1,3,4,5,6)));
|
|
|
|
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)));
|
2012-02-20 19:54:24 +00:00
|
|
|
void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
|
|
|
|
int16_t *neartagsector, int16_t *neartagwall, int16_t *neartagsprite,
|
|
|
|
int32_t *neartaghitdist, int32_t neartagrange, uint8_t tagsearch,
|
|
|
|
int32_t (*blacklist_sprite_func)(int32_t)) ATTRIBUTE((nonnull(6,7,8)));
|
2012-08-16 21:48:08 +00:00
|
|
|
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);
|
2019-04-06 06:37:42 +00:00
|
|
|
void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum) ATTRIBUTE((nonnull(3)));
|
2019-09-19 20:02:45 +00:00
|
|
|
inline void updatesectorbreadth(int32_t const x, int32_t const y, int16_t *sectnum) ATTRIBUTE((nonnull(3)))
|
|
|
|
{
|
|
|
|
updatesector(x, y, sectnum);
|
|
|
|
}
|
2019-04-06 06:37:42 +00:00
|
|
|
void updatesectorexclude(int32_t const x, int32_t const y, int16_t * const sectnum,
|
|
|
|
const uint8_t * const excludesectbitmap) ATTRIBUTE((nonnull(3,4)));
|
|
|
|
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * const sectnum) ATTRIBUTE((nonnull(4)));
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t inside(int32_t x, int32_t y, int16_t sectnum);
|
2013-01-16 20:38:41 +00:00
|
|
|
void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags);
|
2009-01-09 09:29:17 +00:00
|
|
|
void setfirstwall(int16_t sectnum, int16_t newfirstwall);
|
2019-04-18 17:25:24 +00:00
|
|
|
int32_t try_facespr_intersect(uspriteptr_t const spr, const vec3_t *refpos,
|
2019-03-19 17:08:59 +00:00
|
|
|
int32_t vx, int32_t vy, int32_t vz,
|
|
|
|
vec3_t *intp, int32_t strictly_smaller_than_p);
|
2011-05-15 22:37:24 +00:00
|
|
|
|
2019-04-19 08:31:42 +00:00
|
|
|
int findwallbetweensectors(int sect1, int sect2);
|
|
|
|
static FORCE_INLINE bool sectoradjacent(int sect1, int sect2) { return findwallbetweensectors(sect1, sect2) != -1; }
|
2019-04-19 08:31:47 +00:00
|
|
|
int32_t getwalldist(vec2_t const &in, int const wallnum, vec2_t * const out = nullptr);
|
|
|
|
int32_t getsectordist(vec2_t const &in, int const sectnum, vec2_t * const out = nullptr);
|
2011-05-15 22:37:24 +00:00
|
|
|
extern const int16_t *chsecptr_onextwall;
|
2011-01-16 00:23:39 +00:00
|
|
|
int32_t checksectorpointer(int16_t i, int16_t sectnum);
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
void mouseGetValues(int32_t *mousx, int32_t *mousy, int32_t *bstatus) ATTRIBUTE((nonnull(1,2,3)));
|
2014-11-22 12:28:52 +00:00
|
|
|
|
2014-11-22 18:37:24 +00:00
|
|
|
#if !KRANDDEBUG && !defined LUNATIC
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t krand(void)
|
2014-11-22 12:28:52 +00:00
|
|
|
{
|
|
|
|
randomseed = (randomseed * 1664525ul) + 221297ul;
|
|
|
|
return ((uint32_t) randomseed)>>16;
|
|
|
|
}
|
|
|
|
#else
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t krand(void);
|
2014-11-22 12:28:52 +00:00
|
|
|
#endif
|
|
|
|
|
2012-07-01 22:11:14 +00:00
|
|
|
int32_t ksqrt(uint32_t num);
|
2017-01-23 11:20:03 +00:00
|
|
|
int32_t LUNATIC_FASTCALL getangle(int32_t xvect, int32_t yvect);
|
2009-02-28 07:44:54 +00:00
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
static FORCE_INLINE CONSTEXPR uint32_t uhypsq(int32_t const dx, int32_t const dy)
|
2012-07-01 22:11:14 +00:00
|
|
|
{
|
|
|
|
return (uint32_t)dx*dx + (uint32_t)dy*dy;
|
|
|
|
}
|
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
static FORCE_INLINE int32_t logapproach(int32_t const val, int32_t const targetval)
|
2014-03-23 14:29:09 +00:00
|
|
|
{
|
2019-04-18 17:24:10 +00:00
|
|
|
int32_t const dif = targetval - val;
|
2014-03-23 14:29:09 +00:00
|
|
|
return (dif>>1) ? val + (dif>>1) : targetval;
|
|
|
|
}
|
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
void rotatepoint(vec2_t const pivot, vec2_t p, int16_t const daang, vec2_t * const p2) ATTRIBUTE((nonnull(4)));
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t lastwall(int16_t point);
|
2014-03-25 21:04:33 +00:00
|
|
|
int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction);
|
2012-12-28 17:17:58 +00:00
|
|
|
|
2019-04-18 17:25:24 +00:00
|
|
|
int32_t getceilzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1)));
|
|
|
|
int32_t getflorzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1)));
|
|
|
|
void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day,
|
2012-12-28 17:17:58 +00:00
|
|
|
int32_t *ceilz, int32_t *florz) ATTRIBUTE((nonnull(1,4,5)));
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day)
|
2012-12-28 17:17:58 +00:00
|
|
|
{
|
2019-04-18 17:25:24 +00:00
|
|
|
return getceilzofslopeptr((usectorptr_t)§or[sectnum], dax, day);
|
2012-12-28 17:17:58 +00:00
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day)
|
2012-12-28 17:17:58 +00:00
|
|
|
{
|
2019-04-18 17:25:24 +00:00
|
|
|
return getflorzofslopeptr((usectorptr_t)§or[sectnum], dax, day);
|
2012-12-28 17:17:58 +00:00
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz)
|
2012-12-28 17:17:58 +00:00
|
|
|
{
|
2019-04-18 17:25:24 +00:00
|
|
|
getzsofslopeptr((usectorptr_t)§or[sectnum], dax, day, ceilz, florz);
|
2012-12-28 17:17:58 +00:00
|
|
|
}
|
|
|
|
|
2013-04-16 20:08:45 +00:00
|
|
|
// Is <wal> a red wall in a safe fashion, i.e. only if consistency invariant
|
|
|
|
// ".nextsector >= 0 iff .nextwall >= 0" holds.
|
2019-04-18 17:25:24 +00:00
|
|
|
static FORCE_INLINE CONSTEXPR int32_t redwallp(uwallptr_t wal)
|
2013-01-01 15:24:42 +00:00
|
|
|
{
|
|
|
|
return (wal->nextwall >= 0 && wal->nextsector >= 0);
|
|
|
|
}
|
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
static FORCE_INLINE CONSTEXPR int32_t E_SpriteIsValid(const int32_t i)
|
2014-01-31 21:12:56 +00:00
|
|
|
{
|
|
|
|
return ((unsigned)i < MAXSPRITES && sprite[i].statnum != MAXSTATUS);
|
|
|
|
}
|
|
|
|
|
2019-04-18 17:25:24 +00:00
|
|
|
int clipshape_idx_for_sprite(uspriteptr_t curspr, int curidx);
|
2014-08-17 19:42:01 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z);
|
|
|
|
void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z);
|
2018-04-02 22:00:23 +00:00
|
|
|
int32_t sectorofwall(int16_t wallNum);
|
|
|
|
int32_t sectorofwall_noquick(int16_t wallNum);
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t loopnumofsector(int16_t sectnum, int16_t wallnum);
|
2011-04-14 20:48:08 +00:00
|
|
|
void setslope(int32_t sectnum, int32_t cf, int16_t slope);
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2019-04-05 17:45:16 +00:00
|
|
|
int32_t lintersect(int32_t originX, int32_t originY, int32_t originZ,
|
|
|
|
int32_t destX, int32_t destY, int32_t destZ,
|
|
|
|
int32_t lineStartX, int32_t lineStartY, int32_t lineEndX, int32_t lineEndY,
|
|
|
|
int32_t *intersectionX, int32_t *intersectionY, int32_t *intersectionZ);
|
2010-09-27 21:52:04 +00:00
|
|
|
|
|
|
|
int32_t rayintersect(int32_t x1, int32_t y1, int32_t z1, int32_t vx, int32_t vy, int32_t vz, int32_t x3,
|
|
|
|
int32_t y3, int32_t x4, int32_t y4, int32_t *intx, int32_t *inty, int32_t *intz);
|
2013-12-31 11:51:54 +00:00
|
|
|
#if !defined NETCODE_DISABLE
|
2013-01-28 22:00:37 +00:00
|
|
|
void do_insertsprite_at_headofstat(int16_t spritenum, int16_t statnum);
|
|
|
|
int32_t insertspritestat(int16_t statnum);
|
2018-12-08 00:40:39 +00:00
|
|
|
void do_deletespritestat(int16_t deleteme);
|
2013-01-28 22:00:37 +00:00
|
|
|
void do_insertsprite_at_headofsect(int16_t spritenum, int16_t sectnum);
|
|
|
|
void do_deletespritesect(int16_t deleteme);
|
2013-12-31 11:51:54 +00:00
|
|
|
#endif
|
2012-03-13 20:05:51 +00:00
|
|
|
int32_t insertsprite(int16_t sectnum, int16_t statnum);
|
|
|
|
int32_t deletesprite(int16_t spritenum);
|
2009-02-28 07:44:54 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t changespritesect(int16_t spritenum, int16_t newsectnum);
|
|
|
|
int32_t changespritestat(int16_t spritenum, int16_t newstatnum);
|
2012-11-05 02:49:08 +00:00
|
|
|
int32_t setsprite(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
|
|
|
|
int32_t setspritez(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2)));
|
2009-01-09 09:29:17 +00:00
|
|
|
|
2019-04-18 17:25:24 +00:00
|
|
|
int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyofs);
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE int32_t spriteheightofs(int16_t i, int32_t *height, int32_t alsotileyofs)
|
2012-11-25 13:18:57 +00:00
|
|
|
{
|
2019-04-18 17:25:24 +00:00
|
|
|
return spriteheightofsptr((uspriteptr_t)&sprite[i], height, alsotileyofs);
|
2012-11-25 13:18:57 +00:00
|
|
|
}
|
2011-03-02 21:21:47 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
int videoCaptureScreen(const char *filename, char inverseit) ATTRIBUTE((nonnull(1)));
|
|
|
|
int videoCaptureScreenTGA(const char *filename, char inverseit) ATTRIBUTE((nonnull(1)));
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2017-12-01 06:19:19 +00:00
|
|
|
struct OutputFileCounter {
|
|
|
|
uint16_t count = 0;
|
2019-03-01 08:51:50 +00:00
|
|
|
buildvfs_FILE opennextfile(char *, char *);
|
|
|
|
buildvfs_FILE opennextfile_withext(char *, const char *);
|
2017-12-01 06:19:19 +00:00
|
|
|
};
|
|
|
|
|
2007-09-05 21:56:58 +00:00
|
|
|
// PLAG: line utility functions
|
2019-04-18 17:24:10 +00:00
|
|
|
typedef struct s_equation
|
|
|
|
{
|
|
|
|
float a, b, c;
|
|
|
|
} _equation;
|
|
|
|
|
|
|
|
int32_t wallvisible(int32_t const x, int32_t const y, int16_t const wallnum);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
|
|
|
#define STATUS2DSIZ 144
|
2009-05-01 06:35:27 +00:00
|
|
|
#define STATUS2DSIZ2 26
|
|
|
|
|
2011-05-22 21:52:22 +00:00
|
|
|
//void qsetmode640350(void);
|
|
|
|
//void qsetmode640480(void);
|
2018-04-12 21:02:51 +00:00
|
|
|
void videoSet2dMode(int32_t,int32_t);
|
2007-09-05 21:56:58 +00:00
|
|
|
void clear2dscreen(void);
|
2018-04-12 21:03:47 +00:00
|
|
|
void editorDraw2dGrid(int32_t posxe, int32_t posye, int32_t posze, int16_t cursectnum,
|
2012-08-16 21:48:08 +00:00
|
|
|
int16_t ange, int32_t zoome, int16_t gride);
|
2018-04-12 21:03:47 +00:00
|
|
|
void editorDraw2dScreen(const vec3_t *pos, int16_t cursectnum,
|
2012-08-16 21:48:08 +00:00
|
|
|
int16_t ange, int32_t zoome, int16_t gride) ATTRIBUTE((nonnull(1)));
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t editorDraw2dLine(int32_t x1, int32_t y1, int32_t x2, int32_t y2, int col);
|
|
|
|
void editorDraw2dCircle(int32_t x1, int32_t y1, int32_t r, int32_t eccen, char col);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t videoSetRenderMode(int32_t renderer);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2018-04-12 21:03:47 +00:00
|
|
|
void renderSetRollAngle(int32_t rolla);
|
2008-07-24 11:16:20 +00:00
|
|
|
#endif
|
2007-09-05 21:56:58 +00:00
|
|
|
|
|
|
|
// pal: pass -1 to invalidate all palettes for the tile, or >=0 for a particular palette
|
|
|
|
// how: pass -1 to invalidate all instances of the tile in texture memory, or a bitfield
|
|
|
|
// bit 0: opaque or masked (non-translucent) texture, using repeating
|
|
|
|
// bit 1: ignored
|
|
|
|
// bit 2: 33% translucence, using repeating
|
|
|
|
// bit 3: 67% translucence, using repeating
|
|
|
|
// bit 4: opaque or masked (non-translucent) texture, using clamping
|
|
|
|
// bit 5: ignored
|
|
|
|
// bit 6: 33% translucence, using clamping
|
|
|
|
// bit 7: 67% translucence, using clamping
|
|
|
|
// clamping is for sprites, repeating is for walls
|
2018-04-12 21:03:47 +00:00
|
|
|
void tileInvalidate(int16_t tilenume, int32_t pal, int32_t how);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2018-04-12 21:03:47 +00:00
|
|
|
void polymostSet2dView(void); // sets up GL for 2D drawing
|
2007-09-05 21:56:58 +00:00
|
|
|
|
|
|
|
void polymost_glreset(void);
|
2009-01-09 09:29:17 +00:00
|
|
|
void polymost_precache(int32_t dapicnum, int32_t dapalnum, int32_t datype);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2017-07-15 21:56:17 +00:00
|
|
|
typedef uint16_t polytintflags_t;
|
|
|
|
|
2018-02-15 03:49:23 +00:00
|
|
|
enum cutsceneflags {
|
|
|
|
CUTSCENE_FORCEFILTER = 1,
|
|
|
|
CUTSCENE_FORCENOFILTER = 2,
|
|
|
|
CUTSCENE_TEXTUREFILTER = 4,
|
|
|
|
};
|
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t glanisotropy;
|
|
|
|
extern int32_t gltexfiltermode;
|
2018-03-21 20:41:26 +00:00
|
|
|
extern int32_t r_useindexedcolortextures;
|
2015-03-28 09:49:37 +00:00
|
|
|
|
|
|
|
enum {
|
2016-09-18 03:54:21 +00:00
|
|
|
TEXFILTER_OFF = 0, // GL_NEAREST
|
2015-03-28 09:49:37 +00:00
|
|
|
TEXFILTER_ON = 5, // GL_LINEAR_MIPMAP_LINEAR
|
|
|
|
};
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t glmultisample, glnvmultisamplehint;
|
2014-09-30 04:06:57 +00:00
|
|
|
extern int32_t glprojectionhacks;
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t gltexmaxsize;
|
2007-09-05 21:56:58 +00:00
|
|
|
void gltexapplyprops (void);
|
2013-05-15 02:17:17 +00:00
|
|
|
void texcache_invalidate(void);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2016-01-08 01:33:20 +00:00
|
|
|
# ifdef USE_GLEXT
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t r_detailmapping;
|
|
|
|
extern int32_t r_glowmapping;
|
2016-01-08 01:33:20 +00:00
|
|
|
# endif
|
2015-02-11 05:23:04 +00:00
|
|
|
|
2016-01-08 01:33:20 +00:00
|
|
|
# ifdef USE_GLEXT
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t r_vbocount;
|
2016-01-08 01:33:20 +00:00
|
|
|
# endif
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t r_animsmoothing;
|
|
|
|
extern int32_t r_parallaxskyclamping;
|
|
|
|
extern int32_t r_parallaxskypanning;
|
|
|
|
extern int32_t r_fullbrights;
|
|
|
|
extern int32_t r_downsize;
|
2009-04-30 01:07:08 +00:00
|
|
|
extern int32_t r_downsizevar;
|
2009-01-09 09:29:17 +00:00
|
|
|
extern int32_t mdtims, omdtims;
|
2009-03-27 21:54:55 +00:00
|
|
|
extern int32_t glrendmode;
|
2019-09-19 20:02:45 +00:00
|
|
|
|
|
|
|
extern int32_t r_rortexture;
|
|
|
|
extern int32_t r_rortexturerange;
|
|
|
|
extern int32_t r_rorphase;
|
2007-09-05 21:56:58 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
void hicinit(void);
|
2017-12-12 05:13:58 +00:00
|
|
|
void hicsetpalettetint(int32_t palnum, char r, char g, char b, char sr, char sg, char sb, polytintflags_t effect);
|
2007-09-05 21:56:58 +00:00
|
|
|
// flags bitset: 1 = don't compress
|
2012-08-16 21:48:08 +00:00
|
|
|
int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float alphacut,
|
|
|
|
float xscale, float yscale, float specpower, float specfactor, char flags);
|
2015-02-18 01:47:00 +00:00
|
|
|
int32_t hicsetskybox(int32_t picnum, int32_t palnum, char *faces[6], int32_t flags);
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t hicclearsubst(int32_t picnum, int32_t palnum);
|
|
|
|
|
2018-10-16 06:09:20 +00:00
|
|
|
int32_t Ptile2tile(int32_t tile, int32_t palette) ATTRIBUTE((pure));
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t md_loadmodel(const char *fn);
|
2012-01-17 04:31:59 +00:00
|
|
|
int32_t md_setmisc(int32_t modelid, float scale, int32_t shadeoff, float zadd, float yoffset, int32_t flags);
|
2009-02-28 07:44:54 +00:00
|
|
|
// int32_t md_tilehasmodel(int32_t tilenume, int32_t pal);
|
|
|
|
|
2012-07-01 22:11:33 +00:00
|
|
|
extern const char *G_DefaultDefFile(void);
|
|
|
|
extern const char *G_DefFile(void);
|
Patch from Hendricks266 and whatever changes happened to be in my tree. I hope they work ;)
"The most noticeable change is the addition of the "includedefault" CON and DEF command, which will attempt to include eduke.con (or nam.con, or ww2gi.con), then game.con, or duke3d.def, or nam.def, or ww2gi.def. This is useful for TCs like my add-ons, where for my pseudo-mutators I currently say "include EDUKE.CON", but I also have to juggle this terrible order of paths, so that I can have an EDUKE.CON file in my HRP which says "include GAME.CON" to allow the mainline game to actually run, but also allow DukePlus to load its EDUKE.CON file (since it uses that and not an -x switch), and also allow any custom EDUKE.CON files in the root to be used."
git-svn-id: https://svn.eduke32.com/eduke32@1909 1a8010ca-5511-0410-912e-c29ae57300e0
2011-06-19 00:11:52 +00:00
|
|
|
extern char *g_defNamePtr;
|
|
|
|
|
2018-02-17 22:30:39 +00:00
|
|
|
extern GrowArray<char *> g_defModules;
|
2012-03-18 08:50:41 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CLIPSHAPE_FEATURE
|
2018-02-17 22:30:39 +00:00
|
|
|
extern GrowArray<char *> g_clipMapFiles;
|
2012-03-18 08:50:41 +00:00
|
|
|
#endif
|
2011-07-21 22:39:29 +00:00
|
|
|
|
2011-03-04 08:50:58 +00:00
|
|
|
#ifdef USE_OPENGL
|
2015-03-24 00:40:48 +00:00
|
|
|
// TODO: dynamically allocate this
|
|
|
|
|
|
|
|
typedef struct { vec3f_t add; int16_t angadd, flags, fov; } hudtyp;
|
|
|
|
|
2009-02-28 07:44:54 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
// maps build tiles to particular animation frames of a model
|
2015-03-24 00:40:48 +00:00
|
|
|
int16_t modelid;
|
|
|
|
int16_t framenum; // calculate the number from the name when declaring
|
|
|
|
int16_t nexttile;
|
|
|
|
uint16_t smoothduration;
|
|
|
|
hudtyp *hudmem[2];
|
|
|
|
int8_t skinnum;
|
|
|
|
char pal;
|
2009-02-28 07:44:54 +00:00
|
|
|
} tile2model_t;
|
|
|
|
|
2012-01-19 21:58:06 +00:00
|
|
|
# define EXTRATILES (MAXTILES/8)
|
2009-02-28 07:44:54 +00:00
|
|
|
|
|
|
|
EXTERN int32_t mdinited;
|
|
|
|
EXTERN tile2model_t tile2model[MAXTILES+EXTRATILES];
|
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
static FORCE_INLINE int32_t md_tilehasmodel(int32_t const tilenume, int32_t const pal)
|
2009-02-28 07:44:54 +00:00
|
|
|
{
|
2015-01-11 04:55:07 +00:00
|
|
|
return mdinited ? tile2model[Ptile2tile(tilenume,pal)].modelid : -1;
|
2009-02-28 07:44:54 +00:00
|
|
|
}
|
2012-01-10 23:44:35 +00:00
|
|
|
#endif // defined USE_OPENGL
|
2009-02-28 07:44:54 +00:00
|
|
|
|
2012-08-16 21:48:08 +00:00
|
|
|
int32_t md_defineframe(int32_t modelid, const char *framename, int32_t tilenume,
|
|
|
|
int32_t skinnum, float smoothduration, int32_t pal);
|
|
|
|
int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *frameend,
|
|
|
|
int32_t fps, int32_t flags);
|
|
|
|
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum,
|
2015-03-28 09:49:11 +00:00
|
|
|
int32_t surfnum, float param, float specpower, float specfactor, int32_t flags);
|
2015-03-24 00:40:48 +00:00
|
|
|
int32_t md_definehud (int32_t modelid, int32_t tilex, vec3f_t add,
|
2014-09-30 04:06:57 +00:00
|
|
|
int32_t angadd, int32_t flags, int32_t fov);
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t md_undefinetile(int32_t tile);
|
|
|
|
int32_t md_undefinemodel(int32_t modelid);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2011-01-16 00:23:39 +00:00
|
|
|
int32_t loaddefinitionsfile(const char *fn);
|
2007-09-05 21:56:58 +00:00
|
|
|
|
2012-08-16 21:48:08 +00:00
|
|
|
// if loadboard() fails with -2 return, try loadoldboard(). if it fails with
|
|
|
|
// -2, board is dodgy
|
2018-04-12 21:03:47 +00:00
|
|
|
int32_t engineLoadBoardV5V6(const char *filename, char fromwhere, vec3_t *dapos, int16_t *daang, int16_t *dacursectnum);
|
2013-04-25 21:10:22 +00:00
|
|
|
|
2017-06-05 10:04:56 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2016-06-21 00:32:53 +00:00
|
|
|
#include "hash.h"
|
2016-01-08 01:33:46 +00:00
|
|
|
|
2009-02-14 14:31:58 +00:00
|
|
|
#ifdef POLYMER
|
|
|
|
# include "polymer.h"
|
2018-03-21 20:41:26 +00:00
|
|
|
#endif
|
|
|
|
#ifdef USE_OPENGL
|
|
|
|
# include "polymost.h"
|
2009-02-14 14:31:58 +00:00
|
|
|
#endif
|
|
|
|
|
2017-06-05 10:04:56 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-04-12 21:04:00 +00:00
|
|
|
static FORCE_INLINE void renderDisableFog(void)
|
2013-01-26 17:07:58 +00:00
|
|
|
{
|
|
|
|
#ifdef USE_OPENGL
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() >= REND_POLYMOST)
|
2013-01-26 17:07:58 +00:00
|
|
|
{
|
2018-03-21 20:41:26 +00:00
|
|
|
polymost_setFogEnabled(false);
|
2013-01-26 17:07:58 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2018-04-12 21:04:00 +00:00
|
|
|
static FORCE_INLINE void renderEnableFog(void)
|
2013-01-26 17:07:58 +00:00
|
|
|
{
|
|
|
|
#ifdef USE_OPENGL
|
2018-04-12 21:03:12 +00:00
|
|
|
if (videoGetRenderMode() >= REND_POLYMOST && !nofog)
|
2018-03-21 20:41:26 +00:00
|
|
|
polymost_setFogEnabled(true);
|
2013-01-26 17:07:58 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-05-26 00:47:54 +00:00
|
|
|
static vec2_t const zerovec = { 0, 0 };
|
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef LUNATIC
|
|
|
|
extern const int32_t engine_main_arrays_are_static;
|
|
|
|
extern const int32_t engine_v8;
|
|
|
|
int32_t Mulscale(int32_t a, int32_t b, int32_t sh);
|
|
|
|
#endif
|
2013-01-26 17:07:58 +00:00
|
|
|
|
2019-04-18 17:24:10 +00:00
|
|
|
static FORCE_INLINE CONSTEXPR bool inside_p(int32_t const x, int32_t const y, int const sectnum) { return (sectnum >= 0 && inside(x, y, sectnum) == 1); }
|
2019-04-09 19:21:22 +00:00
|
|
|
|
|
|
|
#define SET_AND_RETURN(Lval, Rval) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
(Lval) = (Rval); \
|
|
|
|
return; \
|
|
|
|
} while (0)
|
|
|
|
|
SW: setsprite, setspritez, getzrange, clipmove, pushmove, neartag, dragpoint, screencapture, md_tilehasmodel, preparemirror, saveboard, loadboard, pos
git-svn-id: https://svn.eduke32.com/eduke32@5201 1a8010ca-5511-0410-912e-c29ae57300e0
2015-05-19 22:00:38 +00:00
|
|
|
static inline int32_t clipmove_old(int32_t *x, int32_t *y, int32_t *z, 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,3,4)));
|
|
|
|
|
|
|
|
static inline int32_t clipmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t xvect, int32_t yvect, int32_t walldist,
|
|
|
|
int32_t ceildist, int32_t flordist, uint32_t cliptype)
|
|
|
|
{
|
|
|
|
vec3_t vector = { *x, *y, *z };
|
|
|
|
|
|
|
|
int32_t result = clipmove(&vector, sectnum, xvect, yvect, walldist, ceildist, flordist, cliptype);
|
|
|
|
|
|
|
|
*x = vector.x;
|
|
|
|
*y = vector.y;
|
|
|
|
*z = vector.z;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int32_t pushmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist,
|
|
|
|
int32_t ceildist, int32_t flordist, uint32_t cliptype) ATTRIBUTE((nonnull(1,2,3,4)));
|
|
|
|
|
|
|
|
static inline int32_t pushmove_old(int32_t *x, int32_t *y, int32_t *z, int16_t *sectnum, int32_t walldist,
|
|
|
|
int32_t ceildist, int32_t flordist, uint32_t cliptype)
|
|
|
|
{
|
|
|
|
vec3_t vector = { *x, *y, *z };
|
|
|
|
|
|
|
|
int32_t result = pushmove(&vector, sectnum, walldist, ceildist, flordist, cliptype);
|
|
|
|
|
|
|
|
*x = vector.x;
|
|
|
|
*y = vector.y;
|
|
|
|
*z = vector.z;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void getzrange_old(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
|
|
|
int32_t *florhit, int32_t walldist, uint32_t cliptype) ATTRIBUTE((nonnull(5,6,7,8)));
|
|
|
|
|
|
|
|
static inline void getzrange_old(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t *ceilz, int32_t *ceilhit, int32_t *florz,
|
|
|
|
int32_t *florhit, int32_t walldist, uint32_t cliptype)
|
|
|
|
{
|
|
|
|
const vec3_t vector = { x, y, z };
|
|
|
|
getzrange(&vector, sectnum, ceilz, ceilhit, florz, florhit, walldist, cliptype);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int32_t setspritez_old(int16_t spritenum, int32_t x, int32_t y, int32_t z)
|
|
|
|
{
|
|
|
|
const vec3_t vector = { x, y, z };
|
|
|
|
return setspritez(spritenum, &vector);
|
|
|
|
}
|
|
|
|
|
2016-06-21 00:33:30 +00:00
|
|
|
extern int32_t rintersect(int32_t x1, int32_t y1, int32_t z1,
|
|
|
|
int32_t vx_, int32_t vy_, int32_t vz,
|
|
|
|
int32_t x3, int32_t y3, int32_t x4, int32_t y4,
|
|
|
|
int32_t *intx, int32_t *inty, int32_t *intz);
|
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
extern int32_t(*animateoffs_replace)(int const tilenum, int fakevar);
|
|
|
|
extern void(*paletteLoadFromDisk_replace)(void);
|
|
|
|
extern int32_t(*getpalookup_replace)(int32_t davis, int32_t dashade);
|
|
|
|
extern void(*initspritelists_replace)(void);
|
|
|
|
extern int32_t(*insertsprite_replace)(int16_t sectnum, int16_t statnum);
|
|
|
|
extern int32_t(*deletesprite_replace)(int16_t spritenum);
|
|
|
|
extern int32_t(*changespritesect_replace)(int16_t spritenum, int16_t newsectnum);
|
|
|
|
extern int32_t(*changespritestat_replace)(int16_t spritenum, int16_t newstatnum);
|
|
|
|
extern void(*loadvoxel_replace)(int32_t voxel);
|
|
|
|
#ifdef USE_OPENGL
|
|
|
|
extern void(*PolymostProcessVoxels_Callback)(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
extern int32_t automapping;
|
|
|
|
extern int32_t bloodhack;
|
|
|
|
extern intptr_t voxoff[MAXVOXELS][MAXVOXMIPS]; // used in KenBuild
|
|
|
|
extern int8_t voxreserve[(MAXVOXELS+7)>>3];
|
|
|
|
|
2014-11-26 04:39:23 +00:00
|
|
|
#ifdef __cplusplus
|
2007-09-05 21:56:58 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-11-22 12:32:56 +00:00
|
|
|
#endif // build_h_
|