mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-03-06 08:41:04 +00:00
Get rid of all the static arrays with sizes based on MAXXDIM and MAXYDIM
git-svn-id: https://svn.eduke32.com/eduke32@4695 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
80b8e08eb7
commit
021d1241eb
5 changed files with 151 additions and 54 deletions
|
@ -752,7 +752,8 @@ EXTERN int32_t yxaspect, viewingrange;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
EXTERN intptr_t ylookup[MAXYDIM+1];
|
EXTERN intptr_t *ylookup;
|
||||||
|
EXTERN int32_t ylookupsiz;
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -804,7 +805,7 @@ EXTERN int32_t g_visibility, parallaxvisibility;
|
||||||
EXTERN int32_t g_rotatespriteNoWidescreen;
|
EXTERN int32_t g_rotatespriteNoWidescreen;
|
||||||
|
|
||||||
EXTERN int32_t windowx1, windowy1, windowx2, windowy2;
|
EXTERN int32_t windowx1, windowy1, windowx2, windowy2;
|
||||||
EXTERN int16_t startumost[MAXXDIM], startdmost[MAXXDIM];
|
EXTERN int16_t *startumost, *startdmost;
|
||||||
|
|
||||||
// The maximum tile offset ever used in any tiled parallaxed multi-sky.
|
// The maximum tile offset ever used in any tiled parallaxed multi-sky.
|
||||||
#define PSKYOFF_MAX 4
|
#define PSKYOFF_MAX 4
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#ifndef __compat_h__
|
#ifndef __compat_h__
|
||||||
#define __compat_h__
|
#define __compat_h__
|
||||||
|
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
|
@ -811,6 +813,18 @@ static inline void *xrealloc(void * const ptr, const bsize_t size)
|
||||||
return newptr;
|
return newptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void *xaligned_malloc(const bsize_t alignment, const bsize_t size)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
void *ptr = _aligned_malloc(size, alignment);
|
||||||
|
#else
|
||||||
|
void *ptr = memalign(alignment, size);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (ptr == NULL) handle_memerr();
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef EXTERNC
|
#ifdef EXTERNC
|
||||||
}
|
}
|
||||||
|
@ -820,6 +834,10 @@ static inline void *xrealloc(void * const ptr, const bsize_t size)
|
||||||
if (var != NULL) { Bfree(var); var = NULL; } \
|
if (var != NULL) { Bfree(var); var = NULL; } \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
#define ALIGNED_FREE_AND_NULL(var) do { \
|
||||||
|
if (var != NULL) { Baligned_free(var); var = NULL; } \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define MAYBE_FCLOSE_AND_NULL(fileptr) do { \
|
#define MAYBE_FCLOSE_AND_NULL(fileptr) do { \
|
||||||
if (fileptr) { Bfclose(fileptr); fileptr=NULL; } \
|
if (fileptr) { Bfclose(fileptr); fileptr=NULL; } \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -892,14 +910,27 @@ static inline void *xrealloc(void * const ptr, const bsize_t size)
|
||||||
# define Xmalloc(size) (EDUKE32_PRE_XALLLOC, xmalloc(size))
|
# define Xmalloc(size) (EDUKE32_PRE_XALLLOC, xmalloc(size))
|
||||||
# define Xcalloc(nmemb, size) (EDUKE32_PRE_XALLLOC, xcalloc(nmemb, size))
|
# define Xcalloc(nmemb, size) (EDUKE32_PRE_XALLLOC, xcalloc(nmemb, size))
|
||||||
# define Xrealloc(ptr, size) (EDUKE32_PRE_XALLLOC, xrealloc(ptr, size))
|
# define Xrealloc(ptr, size) (EDUKE32_PRE_XALLLOC, xrealloc(ptr, size))
|
||||||
|
# define Xaligned_alloc(size, alignment) (EDUKE32_PRE_XALLLOC, xaligned_malloc(size, alignment))
|
||||||
# define Bexit(status) do { initprintf("exit(%d) at %s:%d in %s()\n", status, __FILE__, __LINE__, EDUKE32_FUNCTION); exit(status); } while (0)
|
# define Bexit(status) do { initprintf("exit(%d) at %s:%d in %s()\n", status, __FILE__, __LINE__, EDUKE32_FUNCTION); exit(status); } while (0)
|
||||||
#else
|
#else
|
||||||
# define Xstrdup xstrdup
|
# define Xstrdup xstrdup
|
||||||
# define Xmalloc xmalloc
|
# define Xmalloc xmalloc
|
||||||
# define Xcalloc xcalloc
|
# define Xcalloc xcalloc
|
||||||
# define Xrealloc xrealloc
|
# define Xrealloc xrealloc
|
||||||
|
#ifdef _WIN32
|
||||||
|
# define Xaligned_alloc(alignment, size) _aligned_malloc(size, alignment)
|
||||||
|
#else
|
||||||
|
# define Xaligned_alloc(alignment, size) memalign(alignment, size)
|
||||||
|
#endif
|
||||||
# define Bexit exit
|
# define Bexit exit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# define Baligned_free(ptr) _aligned_free(ptr)
|
||||||
|
#else
|
||||||
|
# define Baligned_free(ptr) Bfree(ptr)
|
||||||
|
#endif
|
||||||
|
|
||||||
//////////
|
//////////
|
||||||
|
|
||||||
#endif // __compat_h__
|
#endif // __compat_h__
|
||||||
|
|
|
@ -138,7 +138,25 @@ void calc_ylookup(int32_t bpl, int32_t lastyidx)
|
||||||
|
|
||||||
Bassert(lastyidx <= MAXYDIM);
|
Bassert(lastyidx <= MAXYDIM);
|
||||||
|
|
||||||
for (i=0; i<=lastyidx; i++)
|
if (lastyidx > ylookupsiz)
|
||||||
|
{
|
||||||
|
if (ylookup)
|
||||||
|
Baligned_free(ylookup);
|
||||||
|
|
||||||
|
ylookup = (intptr_t *)Xaligned_alloc(16, lastyidx * sizeof(intptr_t));
|
||||||
|
ylookupsiz = lastyidx;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0; i<=lastyidx-4; i+=4)
|
||||||
|
{
|
||||||
|
ylookup[i] = j;
|
||||||
|
ylookup[i + 1] = j + bpl;
|
||||||
|
ylookup[i + 2] = j + (bpl << 1);
|
||||||
|
ylookup[i + 3] = j + (bpl * 3);
|
||||||
|
j += (bpl << 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (; i<=lastyidx; i++)
|
||||||
{
|
{
|
||||||
ylookup[i] = j;
|
ylookup[i] = j;
|
||||||
j += bpl;
|
j += bpl;
|
||||||
|
|
|
@ -139,6 +139,7 @@ int32_t editorgridextent = 131072;
|
||||||
#define MAXYSIZ 256
|
#define MAXYSIZ 256
|
||||||
#define MAXZSIZ 255
|
#define MAXZSIZ 255
|
||||||
#define MAXVOXMIPS 5
|
#define MAXVOXMIPS 5
|
||||||
|
#define DISTRECIPSIZ (65536+256)
|
||||||
intptr_t voxoff[MAXVOXELS][MAXVOXMIPS]; // used in KenBuild
|
intptr_t voxoff[MAXVOXELS][MAXVOXMIPS]; // used in KenBuild
|
||||||
static char voxlock[MAXVOXELS][MAXVOXMIPS];
|
static char voxlock[MAXVOXELS][MAXVOXMIPS];
|
||||||
int32_t voxscale[MAXVOXELS];
|
int32_t voxscale[MAXVOXELS];
|
||||||
|
@ -146,7 +147,7 @@ int32_t voxscale[MAXVOXELS];
|
||||||
static int32_t ggxinc[MAXXSIZ+1], ggyinc[MAXXSIZ+1];
|
static int32_t ggxinc[MAXXSIZ+1], ggyinc[MAXXSIZ+1];
|
||||||
static int32_t lowrecip[1024], nytooclose;
|
static int32_t lowrecip[1024], nytooclose;
|
||||||
static const int32_t nytoofar = 65536*16384-1048576;
|
static const int32_t nytoofar = 65536*16384-1048576;
|
||||||
static uint32_t distrecip[65536+256];
|
static uint32_t *distrecip;
|
||||||
|
|
||||||
static int32_t *lookups = NULL;
|
static int32_t *lookups = NULL;
|
||||||
static int32_t dommxoverlay = 1, beforedrawrooms = 1;
|
static int32_t dommxoverlay = 1, beforedrawrooms = 1;
|
||||||
|
@ -166,7 +167,7 @@ float vid_brightness = DEFAULT_BRIGHTNESS;
|
||||||
|
|
||||||
//Textured Map variables
|
//Textured Map variables
|
||||||
static char globalpolytype;
|
static char globalpolytype;
|
||||||
static int16_t *dotp1[MAXYDIM], *dotp2[MAXYDIM];
|
static int16_t **dotp1, **dotp2;
|
||||||
|
|
||||||
static int8_t tempbuf[MAXWALLS];
|
static int8_t tempbuf[MAXWALLS];
|
||||||
|
|
||||||
|
@ -217,7 +218,7 @@ static int32_t cachesize = 0;
|
||||||
static char *artptrs[MAXARTFILES_TOTAL];
|
static char *artptrs[MAXARTFILES_TOTAL];
|
||||||
|
|
||||||
static int32_t no_radarang2 = 0;
|
static int32_t no_radarang2 = 0;
|
||||||
static int16_t radarang[1280], radarang2[MAXXDIM];
|
static int16_t radarang[1280], *radarang2;
|
||||||
|
|
||||||
uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[4096+256];
|
uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[4096+256];
|
||||||
const char pow2char[8] = {1,2,4,8,16,32,64,128};
|
const char pow2char[8] = {1,2,4,8,16,32,64,128};
|
||||||
|
@ -2239,8 +2240,15 @@ int16_t bunchp2[MAXWALLSB], thesector[MAXWALLSB];
|
||||||
|
|
||||||
int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB];
|
int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB];
|
||||||
|
|
||||||
|
static int32_t nodesperline, ysavecnt;
|
||||||
|
static int16_t *smost, *umost, *dmost, *bakumost, *bakdmost;
|
||||||
|
static int16_t *uplc, *dplc, *uwall, *dwall;
|
||||||
|
static int32_t *swplc, *lplc, *swall, *lwall;
|
||||||
|
#ifdef HIGH_PRECISION_SPRITE
|
||||||
|
static float *swallf;
|
||||||
|
#endif
|
||||||
|
|
||||||
static int32_t smostcnt;
|
static int32_t smostcnt;
|
||||||
static int16_t smost[MAXYSAVES];
|
|
||||||
static int32_t smoststart[MAXWALLSB];
|
static int32_t smoststart[MAXWALLSB];
|
||||||
static char smostwalltype[MAXWALLSB];
|
static char smostwalltype[MAXWALLSB];
|
||||||
static int32_t smostwall[MAXWALLSB], smostwallcnt = -1;
|
static int32_t smostwall[MAXWALLSB], smostwallcnt = -1;
|
||||||
|
@ -2249,15 +2257,6 @@ static int32_t spritesx[MAXSPRITESONSCREEN];
|
||||||
static int32_t spritesy[MAXSPRITESONSCREEN+1];
|
static int32_t spritesy[MAXSPRITESONSCREEN+1];
|
||||||
static int32_t spritesz[MAXSPRITESONSCREEN];
|
static int32_t spritesz[MAXSPRITESONSCREEN];
|
||||||
|
|
||||||
static int16_t umost[MAXXDIM], dmost[MAXXDIM];
|
|
||||||
static int16_t bakumost[MAXXDIM], bakdmost[MAXXDIM];
|
|
||||||
static int16_t uplc[MAXXDIM], dplc[MAXXDIM];
|
|
||||||
static int16_t uwall[MAXXDIM], dwall[MAXXDIM];
|
|
||||||
static int32_t swplc[MAXXDIM], lplc[MAXXDIM];
|
|
||||||
static int32_t swall[MAXXDIM], lwall[MAXXDIM+4];
|
|
||||||
#ifdef HIGH_PRECISION_SPRITE
|
|
||||||
static float swallf[MAXXDIM];
|
|
||||||
#endif
|
|
||||||
int32_t xdimen = -1, xdimenrecip, halfxdimen, xdimenscale, xdimscale;
|
int32_t xdimen = -1, xdimenrecip, halfxdimen, xdimenscale, xdimscale;
|
||||||
int32_t ydimen;
|
int32_t ydimen;
|
||||||
static int32_t wx1, wy1, wx2, wy2;
|
static int32_t wx1, wy1, wx2, wy2;
|
||||||
|
@ -2303,7 +2302,7 @@ static int32_t globaly1, globalx2;
|
||||||
int16_t sectorborder[256];
|
int16_t sectorborder[256];
|
||||||
int32_t ydim16, qsetmode = 0;
|
int32_t ydim16, qsetmode = 0;
|
||||||
int16_t pointhighlight=-1, linehighlight=-1, highlightcnt=0;
|
int16_t pointhighlight=-1, linehighlight=-1, highlightcnt=0;
|
||||||
static int32_t lastx[MAXYDIM];
|
static int32_t *lastx;
|
||||||
|
|
||||||
static char paletteloaded = 0;
|
static char paletteloaded = 0;
|
||||||
|
|
||||||
|
@ -3165,33 +3164,27 @@ static void prepwall(int32_t z, const walltype *wal)
|
||||||
//
|
//
|
||||||
int32_t animateoffs(int16_t tilenum, int16_t fakevar)
|
int32_t animateoffs(int16_t tilenum, int16_t fakevar)
|
||||||
{
|
{
|
||||||
int32_t i, k, offs=0, animnum=picanm[tilenum].num;
|
int i, k, offs = 0;
|
||||||
|
int const animnum = picanm[tilenum].num;
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(fakevar);
|
UNREFERENCED_PARAMETER(fakevar);
|
||||||
|
|
||||||
i = totalclocklock>>(picanm[tilenum].sf&PICANM_ANIMSPEED_MASK);
|
if (animnum <= 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (picanm[tilenum].num > 0)
|
i = totalclocklock >> (picanm[tilenum].sf & PICANM_ANIMSPEED_MASK);
|
||||||
|
|
||||||
|
switch (picanm[tilenum].sf & PICANM_ANIMTYPE_MASK)
|
||||||
{
|
{
|
||||||
switch (picanm[tilenum].sf&PICANM_ANIMTYPE_MASK)
|
|
||||||
{
|
|
||||||
case PICANM_ANIMTYPE_OSC:
|
case PICANM_ANIMTYPE_OSC:
|
||||||
k = (i%(animnum<<1));
|
k = (i % (animnum << 1));
|
||||||
if (k < animnum)
|
offs = (k < animnum) ? k : (animnum << 1) - k;
|
||||||
offs = k;
|
|
||||||
else
|
|
||||||
offs = (animnum<<1)-k;
|
|
||||||
break;
|
break;
|
||||||
case PICANM_ANIMTYPE_FWD:
|
case PICANM_ANIMTYPE_FWD: offs = i % (animnum + 1); break;
|
||||||
offs = i%(animnum+1);
|
case PICANM_ANIMTYPE_BACK: offs = -(i % (animnum + 1)); break;
|
||||||
break;
|
|
||||||
case PICANM_ANIMTYPE_BACK:
|
|
||||||
offs = -(i%(animnum+1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(offs);
|
return offs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5005,7 +4998,7 @@ static void drawalls(int32_t bunch)
|
||||||
if ((cz[2] < cz[0]) || (cz[3] < cz[1]) || (globalposz < cz[4]))
|
if ((cz[2] < cz[0]) || (cz[3] < cz[1]) || (globalposz < cz[4]))
|
||||||
{
|
{
|
||||||
i = x2-x1+1;
|
i = x2-x1+1;
|
||||||
if (smostcnt+i < MAXYSAVES)
|
if (smostcnt+i < ysavecnt)
|
||||||
{
|
{
|
||||||
smoststart[smostwallcnt] = smostcnt;
|
smoststart[smostwallcnt] = smostcnt;
|
||||||
smostwall[smostwallcnt] = z;
|
smostwall[smostwallcnt] = z;
|
||||||
|
@ -5094,7 +5087,7 @@ static void drawalls(int32_t bunch)
|
||||||
if ((fz[2] > fz[0]) || (fz[3] > fz[1]) || (globalposz > fz[4]))
|
if ((fz[2] > fz[0]) || (fz[3] > fz[1]) || (globalposz > fz[4]))
|
||||||
{
|
{
|
||||||
i = x2-x1+1;
|
i = x2-x1+1;
|
||||||
if (smostcnt+i < MAXYSAVES)
|
if (smostcnt+i < ysavecnt)
|
||||||
{
|
{
|
||||||
smoststart[smostwallcnt] = smostcnt;
|
smoststart[smostwallcnt] = smostcnt;
|
||||||
smostwall[smostwallcnt] = z;
|
smostwall[smostwallcnt] = z;
|
||||||
|
@ -5188,10 +5181,9 @@ static void drawalls(int32_t bunch)
|
||||||
# endif
|
# endif
|
||||||
{
|
{
|
||||||
static char fn[32], tmpbuf[80];
|
static char fn[32], tmpbuf[80];
|
||||||
static char bakframe[MAXXDIM*MAXYDIM];
|
|
||||||
|
|
||||||
char purple = getclosestcol(63, 0, 63);
|
char purple = getclosestcol(63, 0, 63);
|
||||||
char yellow = getclosestcol(63, 63, 0);
|
char yellow = getclosestcol(63, 63, 0);
|
||||||
|
char *bakframe = (char *)Xaligned_alloc(16, xdim*ydim);
|
||||||
|
|
||||||
begindrawing(); //{{{
|
begindrawing(); //{{{
|
||||||
Bmemcpy(bakframe, (char *)frameplace, xdim*ydim);
|
Bmemcpy(bakframe, (char *)frameplace, xdim*ydim);
|
||||||
|
@ -5221,6 +5213,8 @@ static void drawalls(int32_t bunch)
|
||||||
|
|
||||||
Bmemcpy((char *)frameplace, bakframe, xdim*ydim);
|
Bmemcpy((char *)frameplace, bakframe, xdim*ydim);
|
||||||
enddrawing(); //}}}
|
enddrawing(); //}}}
|
||||||
|
|
||||||
|
Baligned_free(bakframe);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -5946,11 +5940,11 @@ draw_as_face_sprite:
|
||||||
{
|
{
|
||||||
top += topinc; bot += botinc;
|
top += topinc; bot += botinc;
|
||||||
zz = z; z = mulscale20(top,krecipasm(bot));
|
zz = z; z = mulscale20(top,krecipasm(bot));
|
||||||
lwall[x] = (z>>8);
|
|
||||||
i = ((z+zz)>>1);
|
i = ((z+zz)>>1);
|
||||||
lwall[x-2] = (i>>8);
|
|
||||||
lwall[x-3] = ((i+zz)>>9);
|
lwall[x-3] = ((i+zz)>>9);
|
||||||
|
lwall[x-2] = (i>>8);
|
||||||
lwall[x-1] = ((i+z)>>9);
|
lwall[x-1] = ((i+z)>>9);
|
||||||
|
lwall[x] = (z>>8);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lwall[sx1] < 0) lwall[sx1] = 0;
|
if (lwall[sx1] < 0) lwall[sx1] = 0;
|
||||||
|
@ -6839,8 +6833,8 @@ static void fillpolygon(int32_t npoints)
|
||||||
for (i=0, y=miny; y<=maxy; y++, i++)
|
for (i=0, y=miny; y<=maxy; y++, i++)
|
||||||
{
|
{
|
||||||
//They're pointers! - watch how you optimize this thing
|
//They're pointers! - watch how you optimize this thing
|
||||||
dotp1[y] = &smost[i*MAXNODESPERLINE];
|
dotp1[y] = &smost[i*nodesperline];
|
||||||
dotp2[y] = &smost[i*MAXNODESPERLINE + (MAXNODESPERLINE>>1)];
|
dotp2[y] = &smost[i*nodesperline + (nodesperline>>1)];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (z=npoints-1; z>=0; z--)
|
for (z=npoints-1; z>=0; z--)
|
||||||
|
@ -6897,8 +6891,8 @@ static void fillpolygon(int32_t npoints)
|
||||||
|
|
||||||
for (i=0, y=miny; y<=maxy; y++, i++)
|
for (i=0, y=miny; y<=maxy; y++, i++)
|
||||||
{
|
{
|
||||||
int16_t *const xptr = &smost[i*MAXNODESPERLINE];
|
int16_t *const xptr = &smost[i*nodesperline];
|
||||||
int16_t *const xptr2 = &smost[i*MAXNODESPERLINE + (MAXNODESPERLINE>>1)];
|
int16_t *const xptr2 = &smost[i*nodesperline + (nodesperline>>1)];
|
||||||
|
|
||||||
const int32_t cnt = dotp1[y]-xptr;
|
const int32_t cnt = dotp1[y]-xptr;
|
||||||
|
|
||||||
|
@ -7909,6 +7903,7 @@ static void dosetaspect(void)
|
||||||
oxyaspect = xyaspect;
|
oxyaspect = xyaspect;
|
||||||
j = xyaspect*320;
|
j = xyaspect*320;
|
||||||
horizlookup2[horizycent-1] = divscale26(131072,j);
|
horizlookup2[horizycent-1] = divscale26(131072,j);
|
||||||
|
|
||||||
for (i=0; i < horizycent-1; i++)
|
for (i=0; i < horizycent-1; i++)
|
||||||
{
|
{
|
||||||
horizlookup[i] = divscale28(1, i-(horizycent-1));
|
horizlookup[i] = divscale28(1, i-(horizycent-1));
|
||||||
|
@ -7951,13 +7946,15 @@ static void dosetaspect(void)
|
||||||
radarang2[i] = (int16_t)((radarang[k]+j)>>6);
|
radarang2[i] = (int16_t)((radarang[k]+j)>>6);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xdimen != oxdimen)
|
if (xdimen != oxdimen && voxlock[0][0])
|
||||||
{
|
{
|
||||||
EDUKE32_STATIC_ASSERT((uint64_t) MAXXDIM*(ARRAY_SIZE(distrecip)-1) <= INT32_MAX);
|
EDUKE32_STATIC_ASSERT((uint64_t) MAXXDIM*(DISTRECIPSIZ-1) <= INT32_MAX);
|
||||||
|
|
||||||
|
if (distrecip == NULL)
|
||||||
|
distrecip = (uint32_t *)Xaligned_alloc(16, DISTRECIPSIZ * sizeof(uint32_t));
|
||||||
|
|
||||||
i = 1;
|
i = 1;
|
||||||
|
|
||||||
#ifdef CLASSIC_SLICE_BY_4
|
|
||||||
for (; i<(int32_t) ARRAY_SIZE(distrecip)-4; i+=4)
|
for (; i<(int32_t) ARRAY_SIZE(distrecip)-4; i+=4)
|
||||||
{
|
{
|
||||||
distrecip[i] = (xdimen * i)>>20;
|
distrecip[i] = (xdimen * i)>>20;
|
||||||
|
@ -7965,7 +7962,7 @@ static void dosetaspect(void)
|
||||||
distrecip[i+2] = (xdimen * (i+2))>>20;
|
distrecip[i+2] = (xdimen * (i+2))>>20;
|
||||||
distrecip[i+3] = (xdimen * (i+3))>>20;
|
distrecip[i+3] = (xdimen * (i+3))>>20;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
for (; i<(int32_t) ARRAY_SIZE(distrecip); i++)
|
for (; i<(int32_t) ARRAY_SIZE(distrecip); i++)
|
||||||
distrecip[i] = (xdimen * i)>>20;
|
distrecip[i] = (xdimen * i)>>20;
|
||||||
|
|
||||||
|
@ -9056,6 +9053,7 @@ void uninitengine(void)
|
||||||
|
|
||||||
DO_FREE_AND_NULL(pic);
|
DO_FREE_AND_NULL(pic);
|
||||||
DO_FREE_AND_NULL(lookups);
|
DO_FREE_AND_NULL(lookups);
|
||||||
|
ALIGNED_FREE_AND_NULL(distrecip);
|
||||||
|
|
||||||
for (i=0; i<MAXPALOOKUPS; i++)
|
for (i=0; i<MAXPALOOKUPS; i++)
|
||||||
if (palookup[i] != NULL && (i==0 || palookup[i] != palookup[0]))
|
if (palookup[i] != NULL && (i==0 || palookup[i] != palookup[0]))
|
||||||
|
@ -9067,10 +9065,10 @@ void uninitengine(void)
|
||||||
#ifdef DYNALLOC_ARRAYS
|
#ifdef DYNALLOC_ARRAYS
|
||||||
DO_FREE_AND_NULL(blockptr);
|
DO_FREE_AND_NULL(blockptr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITHKPLIB
|
#ifdef WITHKPLIB
|
||||||
DO_FREE_AND_NULL(kpzbuf);
|
DO_FREE_AND_NULL(kpzbuf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uninitsystem();
|
uninitsystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11384,6 +11382,51 @@ int32_t saveboard(const char *filename, const vec3_t *dapos, int16_t daang, int1
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define YSAVES ((xdim*MAXSPRITES)>>7)
|
||||||
|
|
||||||
|
static void initsmost(void)
|
||||||
|
{
|
||||||
|
int32_t i;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
void **ptr;
|
||||||
|
size_t size;
|
||||||
|
} dynarray[] = {
|
||||||
|
{ (void **)&smost, YSAVES * sizeof(int16_t) },
|
||||||
|
{ (void **)&umost, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&dmost, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&startumost, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&startdmost, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&bakumost, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&bakdmost, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&uplc, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&dplc, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&uwall, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&dwall, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&swplc, xdim * sizeof(int32_t) },
|
||||||
|
{ (void **)&lplc, xdim * sizeof(int32_t) },
|
||||||
|
{ (void **)&swall, xdim * sizeof(int32_t) },
|
||||||
|
{ (void **)&lwall, (xdim + 4) * sizeof(int32_t) },
|
||||||
|
{ (void **)&radarang2, xdim * sizeof(int16_t) },
|
||||||
|
{ (void **)&ylookup, (ydim + 1) * sizeof(intptr_t) },
|
||||||
|
{ (void **)&dotp1, ydim * sizeof(intptr_t) },
|
||||||
|
{ (void **)&dotp2, ydim * sizeof(intptr_t) },
|
||||||
|
{ (void **)&lastx, ydim * sizeof(int32_t) },
|
||||||
|
};
|
||||||
|
|
||||||
|
for (i = 0; i < (signed)ARRAY_SIZE(dynarray); i++)
|
||||||
|
{
|
||||||
|
if (*dynarray[i].ptr)
|
||||||
|
Baligned_free(*dynarray[i].ptr);
|
||||||
|
|
||||||
|
*dynarray[i].ptr = Xaligned_alloc(16, dynarray[i].size);
|
||||||
|
}
|
||||||
|
|
||||||
|
ysavecnt = YSAVES;
|
||||||
|
nodesperline = tabledivide32_noinline(YSAVES, ydim);
|
||||||
|
ylookupsiz = ydim + 1;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// setgamemode
|
// setgamemode
|
||||||
|
@ -11434,6 +11477,13 @@ int32_t setgamemode(char davidoption, int32_t daxdim, int32_t daydim, int32_t da
|
||||||
fxdim = (float) xdim;
|
fxdim = (float) xdim;
|
||||||
fydim = (float) ydim;
|
fydim = (float) ydim;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
initsmost();
|
||||||
|
|
||||||
|
#ifdef HIGH_PRECISION_SPRITE
|
||||||
|
swallf = (float *) Xrealloc(swallf, xdim * sizeof(float));
|
||||||
|
#endif
|
||||||
|
|
||||||
if (lookups != NULL)
|
if (lookups != NULL)
|
||||||
Bfree(lookups);
|
Bfree(lookups);
|
||||||
|
|
||||||
|
@ -14864,7 +14914,7 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
||||||
|
|
||||||
if ((cx1 > cx2) || (cy1 > cy2)) return;
|
if ((cx1 > cx2) || (cy1 > cy2)) return;
|
||||||
if (z <= 16) return;
|
if (z <= 16) return;
|
||||||
DO_TILE_ANIM(picnum, 0xc000);
|
DO_TILE_ANIM(picnum, (int16_t)0xc000);
|
||||||
if ((tilesiz[picnum].x <= 0) || (tilesiz[picnum].y <= 0)) return;
|
if ((tilesiz[picnum].x <= 0) || (tilesiz[picnum].y <= 0)) return;
|
||||||
|
|
||||||
// Experimental / development bits. ONLY FOR INTERNAL USE!
|
// Experimental / development bits. ONLY FOR INTERNAL USE!
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
#define MAXPERMS 512
|
#define MAXPERMS 512
|
||||||
#define MAXARTFILES_BASE 200
|
#define MAXARTFILES_BASE 200
|
||||||
#define MAXARTFILES_TOTAL 220
|
#define MAXARTFILES_TOTAL 220
|
||||||
// MAXYSAVES is 983040 (!) right now:
|
|
||||||
#define MAXYSAVES ((MAXXDIM*MAXSPRITES)>>7)
|
|
||||||
#define MAXNODESPERLINE (MAXYSAVES/MAXYDIM) // 307
|
|
||||||
#define MAXCLIPDIST 1024
|
#define MAXCLIPDIST 1024
|
||||||
|
|
||||||
// Uncomment to clear the screen before each top-level draw (classic only).
|
// Uncomment to clear the screen before each top-level draw (classic only).
|
||||||
|
|
Loading…
Reference in a new issue