2018-11-05 07:28:01 +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
|
|
|
|
// by Jonathon Fowler (jf@jonof.id.au)
|
|
|
|
// by the EDuke32 team (development@voidpoint.com)
|
|
|
|
|
2016-06-21 00:33:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-03-15 22:46:03 +00:00
|
|
|
#include "cmdlib.h"
|
|
|
|
|
2008-12-02 10:44:39 +00:00
|
|
|
#ifndef ENGINE_PRIV_H
|
|
|
|
#define ENGINE_PRIV_H
|
|
|
|
|
2014-01-12 14:54:36 +00:00
|
|
|
#define MAXARTFILES_BASE 200
|
|
|
|
#define MAXARTFILES_TOTAL 220
|
2008-12-02 10:44:39 +00:00
|
|
|
#define MAXCLIPDIST 1024
|
|
|
|
|
2013-05-04 16:36:12 +00:00
|
|
|
// Uncomment to clear the screen before each top-level draw (classic only).
|
|
|
|
// FIXME: doesn't work with mirrors.
|
2011-05-17 21:48:13 +00:00
|
|
|
//#define ENGINE_CLEAR_SCREEN
|
2011-05-12 23:31:13 +00:00
|
|
|
|
2020-04-12 05:44:55 +00:00
|
|
|
extern intptr_t asm1, asm2;
|
2012-11-15 14:28:11 +00:00
|
|
|
extern int32_t globalx1, globaly2;
|
|
|
|
|
2014-11-28 08:14:00 +00:00
|
|
|
|
2016-06-21 00:33:30 +00:00
|
|
|
|
2021-03-14 22:38:39 +00:00
|
|
|
static inline int32_t getclipmask(int32_t a, int32_t b, int32_t c, int32_t d)
|
2019-09-22 19:26:07 +00:00
|
|
|
{
|
2021-03-14 22:38:39 +00:00
|
|
|
// Ken did this
|
|
|
|
d = ((a<0)<<3) + ((b<0)<<2) + ((c<0)<<1) + (d<0);
|
|
|
|
return (((d<<4)^0xf0)|d);
|
2019-09-22 19:26:07 +00:00
|
|
|
}
|
|
|
|
|
2021-03-14 22:38:39 +00:00
|
|
|
|
2019-09-22 19:26:07 +00:00
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
extern int16_t thesector[MAXWALLSB], thewall[MAXWALLSB];
|
|
|
|
extern int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB];
|
|
|
|
extern int16_t maskwall[MAXWALLSB], maskwallcnt;
|
2019-04-18 17:25:24 +00:00
|
|
|
extern tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1];
|
2021-03-19 14:12:54 +00:00
|
|
|
extern int32_t xdimen, xdimenscale, xdimscale, ydimen;
|
2014-11-28 08:14:00 +00:00
|
|
|
extern float fxdimen;
|
2020-10-07 02:28:38 +00:00
|
|
|
extern int32_t globalposx, globalposy, globalposz;
|
2020-09-01 13:00:35 +00:00
|
|
|
extern fixed_t qglobalhoriz, qglobalang;
|
2014-10-25 03:32:26 +00:00
|
|
|
extern float fglobalposx, fglobalposy, fglobalposz;
|
2009-01-10 07:38:50 +00:00
|
|
|
extern int16_t globalang, globalcursectnum;
|
|
|
|
extern int32_t globalpal, cosglobalang, singlobalang;
|
|
|
|
extern int32_t cosviewingrangeglobalang, sinviewingrangeglobalang;
|
|
|
|
extern int32_t xyaspect;
|
|
|
|
extern int32_t globalshade;
|
|
|
|
extern int16_t globalpicnum;
|
2012-11-15 14:28:11 +00:00
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
extern int32_t globalorientation;
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2019-06-25 18:35:05 +00:00
|
|
|
extern char inpreparemirror;
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2014-04-21 17:00:54 +00:00
|
|
|
extern int16_t sectorborder[256];
|
2009-01-10 07:38:50 +00:00
|
|
|
extern int32_t hitallsprites;
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2009-01-10 07:38:50 +00:00
|
|
|
extern int32_t xb1[MAXWALLSB];
|
|
|
|
extern int32_t rx1[MAXWALLSB], ry1[MAXWALLSB];
|
2014-09-30 04:14:21 +00:00
|
|
|
extern int16_t bunchp2[MAXWALLSB];
|
2012-01-26 21:58:08 +00:00
|
|
|
extern int16_t numscans, numbunches;
|
2016-06-21 00:33:30 +00:00
|
|
|
extern int32_t rxi[8], ryi[8];
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2016-06-21 00:33:30 +00:00
|
|
|
|
2010-06-07 09:03:16 +00:00
|
|
|
// int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dastat);
|
2009-01-10 07:38:50 +00:00
|
|
|
int32_t wallfront(int32_t l1, int32_t l2);
|
2013-02-10 16:24:11 +00:00
|
|
|
|
2020-09-01 13:00:35 +00:00
|
|
|
void set_globalang(fixed_t const ang);
|
2008-12-02 10:44:39 +00:00
|
|
|
|
2019-09-19 20:02:45 +00:00
|
|
|
int32_t animateoffs(int tilenum, int fakevar);
|
|
|
|
|
2019-04-18 17:25:24 +00:00
|
|
|
static FORCE_INLINE int32_t bad_tspr(tspriteptr_t tspr)
|
2013-04-29 19:24:19 +00:00
|
|
|
{
|
2013-05-01 17:42:07 +00:00
|
|
|
// NOTE: tspr->owner >= MAXSPRITES (could be model) has to be handled by
|
|
|
|
// caller.
|
|
|
|
return (tspr->owner < 0 || (unsigned)tspr->picnum >= MAXTILES);
|
2013-04-29 19:24:19 +00:00
|
|
|
}
|
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void setgotpic(int32_t tilenume)
|
2008-12-02 10:44:39 +00:00
|
|
|
{
|
2018-04-06 01:42:27 +00:00
|
|
|
gotpic[tilenume>>3] |= pow2char[tilenume&7];
|
2008-12-02 10:44:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-04 20:37:45 +00:00
|
|
|
// Get properties of parallaxed sky to draw.
|
2016-10-14 07:40:50 +00:00
|
|
|
// Returns: pointer to tile offset array. Sets-by-pointer the other three.
|
2020-07-14 22:06:19 +00:00
|
|
|
const int16_t* getpsky(int32_t picnum, int32_t* dapyscale, int32_t* dapskybits, int32_t* dapyoffs, int32_t* daptileyscale);
|
2014-10-25 03:32:26 +00:00
|
|
|
|
2017-02-25 08:15:53 +00:00
|
|
|
static FORCE_INLINE void set_globalpos(int32_t const x, int32_t const y, int32_t const z)
|
2014-10-25 03:32:26 +00:00
|
|
|
{
|
2019-06-25 11:30:22 +00:00
|
|
|
globalposx = x, fglobalposx = (float)x;
|
|
|
|
globalposy = y, fglobalposy = (float)y;
|
|
|
|
globalposz = z, fglobalposz = (float)z;
|
2014-10-25 03:32:26 +00:00
|
|
|
}
|
|
|
|
|
2019-06-25 11:30:22 +00:00
|
|
|
|
2019-12-26 06:27:48 +00:00
|
|
|
// x1, y1: in/out
|
|
|
|
// rest x/y: out
|
|
|
|
template <typename T>
|
|
|
|
static inline void get_wallspr_points(T const * const spr, int32_t *x1, int32_t *x2,
|
|
|
|
int32_t *y1, int32_t *y2)
|
|
|
|
{
|
|
|
|
//These lines get the 2 points of the rotated sprite
|
|
|
|
//Given: (x1, y1) starts out as the center point
|
|
|
|
|
|
|
|
const int32_t tilenum=spr->picnum, ang=spr->ang;
|
|
|
|
const int32_t xrepeat = spr->xrepeat;
|
2020-05-24 10:31:38 +00:00
|
|
|
int32_t xoff = tileLeftOffset(tilenum) + spr->xoffset;
|
2019-12-26 06:27:48 +00:00
|
|
|
int32_t k, l, dax, day;
|
|
|
|
|
|
|
|
if (spr->cstat&4)
|
|
|
|
xoff = -xoff;
|
|
|
|
|
2020-11-14 09:00:37 +00:00
|
|
|
dax = bsin(ang) * xrepeat;
|
|
|
|
day = -bcos(ang) * xrepeat;
|
2019-12-26 06:27:48 +00:00
|
|
|
|
2020-11-20 07:18:26 +00:00
|
|
|
l = tileWidth(tilenum);
|
2019-12-26 06:27:48 +00:00
|
|
|
k = (l>>1)+xoff;
|
|
|
|
|
2021-01-04 11:36:54 +00:00
|
|
|
*x1 -= MulScale(dax,k, 16);
|
|
|
|
*x2 = *x1 + MulScale(dax,l, 16);
|
2019-12-26 06:27:48 +00:00
|
|
|
|
2021-01-04 11:36:54 +00:00
|
|
|
*y1 -= MulScale(day,k, 16);
|
|
|
|
*y2 = *y1 + MulScale(day,l, 16);
|
2019-12-26 06:27:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// x1, y1: in/out
|
|
|
|
// rest x/y: out
|
|
|
|
template <typename T>
|
|
|
|
static inline void get_floorspr_points(T const * const spr, int32_t px, int32_t py,
|
|
|
|
int32_t *x1, int32_t *x2, int32_t *x3, int32_t *x4,
|
|
|
|
int32_t *y1, int32_t *y2, int32_t *y3, int32_t *y4)
|
|
|
|
{
|
|
|
|
const int32_t tilenum = spr->picnum;
|
2020-11-14 09:00:37 +00:00
|
|
|
const int32_t cosang = bcos(spr->ang);
|
|
|
|
const int32_t sinang = bsin(spr->ang);
|
2019-12-26 06:27:48 +00:00
|
|
|
|
2020-11-20 07:18:26 +00:00
|
|
|
vec2_t const span = { tileWidth(tilenum), tileHeight(tilenum)};
|
2019-12-26 06:27:48 +00:00
|
|
|
vec2_t const repeat = { spr->xrepeat, spr->yrepeat };
|
|
|
|
|
2020-05-24 10:31:38 +00:00
|
|
|
vec2_t adjofs = { tileLeftOffset(tilenum) + spr->xoffset, tileTopOffset(tilenum) + spr->yoffset };
|
2019-12-26 06:27:48 +00:00
|
|
|
|
|
|
|
if (spr->cstat & 4)
|
|
|
|
adjofs.x = -adjofs.x;
|
|
|
|
|
|
|
|
if (spr->cstat & 8)
|
|
|
|
adjofs.y = -adjofs.y;
|
|
|
|
|
|
|
|
vec2_t const center = { ((span.x >> 1) + adjofs.x) * repeat.x, ((span.y >> 1) + adjofs.y) * repeat.y };
|
|
|
|
vec2_t const rspan = { span.x * repeat.x, span.y * repeat.y };
|
2021-01-04 11:36:54 +00:00
|
|
|
vec2_t const ofs = { -MulScale(cosang, rspan.y, 16), -MulScale(sinang, rspan.y, 16) };
|
2019-12-26 06:27:48 +00:00
|
|
|
|
2021-01-04 10:40:08 +00:00
|
|
|
*x1 += DMulScale(sinang, center.x, cosang, center.y, 16) - px;
|
|
|
|
*y1 += DMulScale(sinang, center.y, -cosang, center.x, 16) - py;
|
2019-12-26 06:27:48 +00:00
|
|
|
|
2021-01-04 11:36:54 +00:00
|
|
|
*x2 = *x1 - MulScale(sinang, rspan.x, 16);
|
|
|
|
*y2 = *y1 + MulScale(cosang, rspan.x, 16);
|
2019-12-26 06:27:48 +00:00
|
|
|
|
|
|
|
*x3 = *x2 + ofs.x, *x4 = *x1 + ofs.x;
|
|
|
|
*y3 = *y2 + ofs.y, *y4 = *y1 + ofs.y;
|
|
|
|
}
|
|
|
|
|
2020-11-09 19:56:28 +00:00
|
|
|
inline int widthBits(int num)
|
|
|
|
{
|
2021-03-15 22:46:03 +00:00
|
|
|
return sizeToBits(tileWidth(num));
|
2020-11-09 19:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline int heightBits(int num)
|
|
|
|
{
|
2021-03-15 22:46:03 +00:00
|
|
|
return sizeToBits(tileHeight(num));
|
2020-11-09 19:56:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-02 10:44:39 +00:00
|
|
|
#endif /* ENGINE_PRIV_H */
|