Replace runtime pow2 calculations with pow2char LUT usage

I don't know that this is any faster, but there's something to be said for standardization and consistency. I will be making most of this stuff use bitmap_set/test/clear() soon.

git-svn-id: https://svn.eduke32.com/eduke32@7876 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/build/src/build.cpp
#	source/build/src/polymost.cpp
This commit is contained in:
terminx 2019-08-04 02:51:50 +00:00 committed by Christoph Oelckers
parent 9c5db5aac0
commit 9f9a158946
18 changed files with 120 additions and 119 deletions

View file

@ -222,8 +222,8 @@ static FORCE_INLINE CONSTEXPR int32_t yax_waltosecmask(int32_t const walclipmask
void yax_preparedrawrooms(void);
void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t),
int16_t sectnum, int32_t didmirror, int32_t smoothr);
# define YAX_SKIPSECTOR(i) if (graysectbitmap[(i)>>3]&(1<<((i)&7))) continue
# define YAX_SKIPWALL(i) if (graywallbitmap[(i)>>3]&(1<<((i)&7))) continue
# define YAX_SKIPSECTOR(i) if (graysectbitmap[(i)>>3]&pow2char[(i)&7]) continue
# define YAX_SKIPWALL(i) if (graywallbitmap[(i)>>3]&pow2char[(i)&7]) continue
#else
# define yax_preparedrawrooms()
# define yax_drawrooms(SpriteAnimFunc, sectnum, didmirror, smoothr)
@ -813,7 +813,6 @@ EXTERN char picsiz[MAXTILES];
EXTERN char walock[MAXTILES];
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,

View file

@ -1163,9 +1163,11 @@ CONSTEXPR size_t logbasenegative(T n)
////////// Bitfield manipulation //////////
static FORCE_INLINE void bitmap_set(uint8_t *const ptr, int const n) { ptr[n >> 3] |= 1 << (n & 7); }
static FORCE_INLINE void bitmap_clear(uint8_t *const ptr, int const n) { ptr[n >> 3] &= ~(1 << (n & 7)); }
static FORCE_INLINE CONSTEXPR char bitmap_test(uint8_t const *const ptr, int const n) { return ptr[n >> 3] & (1 << (n & 7)); }
static CONSTEXPR const char pow2char[8] = {1,2,4,8,16,32,64,128};
static FORCE_INLINE void bitmap_set(uint8_t *const ptr, int const n) { ptr[n>>3] |= pow2char[n&7]; }
static FORCE_INLINE void bitmap_clear(uint8_t *const ptr, int const n) { ptr[n>>3] &= ~pow2char[n&7]; }
static FORCE_INLINE CONSTEXPR char bitmap_test(uint8_t const *const ptr, int const n) { return ptr[n>>3] & pow2char[n&7]; }
////////// Utility functions //////////

View file

@ -1223,10 +1223,10 @@ void editorDraw2dScreen(const vec3_t *pos, int16_t cursectnum, int16_t ange, int
for (i=0; i<numwalls; i++)
{
int32_t j = wall[i].nextwall;
if ((graywallbitmap[i>>3]&(1<<(i&7))) && (j < 0 || (graywallbitmap[j>>3]&(1<<(j&7)))))
graybitmap[i>>3] |= (1<<(i&7));
if ((graywallbitmap[i>>3]&pow2char[i&7]) && (j < 0 || (graywallbitmap[j>>3]&pow2char[j&7])))
graybitmap[i>>3] |= pow2char[i&7];
else
graybitmap[i>>3] &= ~(1<<(i&7));
graybitmap[i>>3] &= ~pow2char[i&7];
}
}
@ -1238,11 +1238,11 @@ void editorDraw2dScreen(const vec3_t *pos, int16_t cursectnum, int16_t ange, int
#else
if (alwaysshowgray)
for (i=numwalls-1; i>=0; i--)
if (graybitmap[i>>3]&(1<<(i&7)))
if (graybitmap[i>>3]&pow2char[i&7])
editorDraw2dWall(i, posxe, posye, posze, zoome, 1+2);
for (i=numwalls-1; i>=0; i--)
if ((graybitmap[i>>3]&(1<<(i&7)))==0)
if ((graybitmap[i>>3]&pow2char[i&7])==0)
editorDraw2dWall(i, posxe, posye, posze, zoome, 2);
#endif
}
@ -1301,8 +1301,8 @@ void editorDraw2dScreen(const vec3_t *pos, int16_t cursectnum, int16_t ange, int
int32_t j = m32_wallsprite[i];
if (j<MAXWALLS)
{
if (alwaysshowgray || !(graybitmap[j>>3]&(1<<(j&7))))
editorDraw2dWall(j, posxe, posye, posze, zoome, !!(graybitmap[j>>3]&(1<<(j&7))));
if (alwaysshowgray || !(graybitmap[j>>3]&pow2char[j&7]))
editorDraw2dWall(j, posxe, posye, posze, zoome, !!(graybitmap[j>>3]&pow2char[j&7]));
}
else
{

View file

@ -766,8 +766,8 @@ static void addclipline(int32_t dax1, int32_t day1, int32_t dax2, int32_t day2,
clipit[clipnum].x2 = dax2; clipit[clipnum].y2 = day2;
clipobjectval[clipnum] = daoval;
uint32_t const mask = (1 << (clipnum & 7));
uint8_t &value = clipignore[clipnum >> 3];
uint32_t const mask = pow2char[clipnum&7];
uint8_t &value = clipignore[clipnum>>3];
value = (value & ~mask) | (-nofix & mask);
clipnum++;

View file

@ -1492,7 +1492,7 @@ static int32_t defsparser(scriptfile *script)
break;
default:
if (framei >= 0 && framei<1024)
usedframebitmap[framei>>3] |= (1<<(framei&7));
usedframebitmap[framei>>3] |= pow2char[framei&7];
}
model_ok &= happy;

View file

@ -289,7 +289,7 @@ void yax_updategrays(int32_t posze)
keep &= (sector[i].ceilingz >= editorzrange[0] && sector[i].floorz <= editorzrange[1]);
if (!keep) // outside bounds, gray out!
graysectbitmap[i>>3] |= (1<<(i&7));
graysectbitmap[i>>3] |= pow2char[i&7];
}
#ifdef YAX_ENABLE
@ -297,18 +297,18 @@ void yax_updategrays(int32_t posze)
{
for (i=0; i<numsectors; i++)
if (!(mingoodz <= sector[i].ceilingz && sector[i].floorz <= maxgoodz))
graysectbitmap[i>>3] |= (1<<(i&7));
graysectbitmap[i>>3] |= pow2char[i&7];
}
#endif
numgraysects = 0;
for (i=0; i<numsectors; i++)
{
if (graysectbitmap[i>>3]&(1<<(i&7)))
if (graysectbitmap[i>>3]&pow2char[i&7])
{
numgraysects++;
for (j=sector[i].wallptr; j<sector[i].wallptr+sector[i].wallnum; j++)
graywallbitmap[j>>3] |= (1<<(j&7));
graywallbitmap[j>>3] |= pow2char[j&7];
}
}
}
@ -531,14 +531,14 @@ void yax_update(int32_t resetstat)
{
yax_getbunches(i, &cb, &fb);
if (cb>=0)
havebunch[cb>>3] |= (1<<(cb&7));
havebunch[cb>>3] |= pow2char[cb&7];
if (fb>=0)
havebunch[fb>>3] |= (1<<(fb&7));
havebunch[fb>>3] |= pow2char[fb&7];
}
for (i=0; i<YAX_MAXBUNCHES; i++)
{
if ((havebunch[i>>3]&(1<<(i&7)))==0)
if ((havebunch[i>>3]&pow2char[i&7])==0)
{
bunchmap[i] = 255;
dasub++;
@ -700,7 +700,7 @@ static void yax_scanbunches(int32_t bbeg, int32_t numhere, const uint8_t *lastgo
/*
if ((w=yax_getnextwall(j,!yax_globalcf))>=0)
if ((ns=wall[w].nextsector)>=0)
if ((lastgotsector[ns>>3]&(1<<(ns&7)))==0)
if ((lastgotsector[ns>>3]&pow2char[ns&7])==0)
continue;
*/
walldist = yax_walldist(j);
@ -923,13 +923,13 @@ void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t),
for (i=0; i<numsectors; i++)
{
if (!(gotsector[i>>3]&(1<<(i&7))))
if (!(gotsector[i>>3]&pow2char[i&7]))
continue;
j = yax_getbunch(i, cf);
if (j >= 0 && !(havebunch[j>>3]&(1<<(j&7))))
if (j >= 0 && !(havebunch[j>>3]&pow2char[j&7]))
{
if (videoGetRenderMode() == REND_CLASSIC && (haveymost[j>>3]&(1<<(j&7)))==0)
if (videoGetRenderMode() == REND_CLASSIC && (haveymost[j>>3]&pow2char[j&7])==0)
{
yaxdebug("%s, l %d: skipped bunch %d (no *most)", cf?"v":"^", lev, j);
continue;
@ -939,7 +939,7 @@ void yax_drawrooms(void (*SpriteAnimFunc)(int32_t,int32_t,int32_t,int32_t),
(cf==0 && globalposz >= sector[i].ceilingz) ||
(cf==1 && globalposz <= sector[i].floorz))
{
havebunch[j>>3] |= (1<<(j&7));
havebunch[j>>3] |= pow2char[j&7];
bunches[cf][bnchnum[cf]++] = j;
bnchend[lev][cf]++;
numhere++;
@ -1811,7 +1811,7 @@ void printscans(void)
for (bssize_t s=0; s<numscans; s++)
{
if (bunchp2[s] >= 0 && (didscan[s>>3] & (1<<(s&7)))==0)
if (bunchp2[s] >= 0 && (didscan[s>>3] & pow2char[s&7])==0)
{
printf("scan ");
@ -1823,13 +1823,13 @@ void printscans(void)
printf("%s%d(%d) ", cond ? "!" : "", z, thewall[z]);
if (didscan[z>>3] & (1<<(z&7)))
if (didscan[z>>3] & pow2char[z&7])
{
printf("*");
break;
}
didscan[z>>3] |= (1<<(z&7));
didscan[z>>3] |= pow2char[z&7];
z = bunchp2[z];
} while (z >= 0);
@ -4251,7 +4251,7 @@ static void classicDrawBunches(int32_t bunch)
int16_t bn[2];
# if 0
int32_t obunchchk = (1 && yax_globalbunch>=0 &&
haveymost[yax_globalbunch>>3]&(1<<(yax_globalbunch&7)));
haveymost[yax_globalbunch>>3]&pow2char[yax_globalbunch&7]);
// if (obunchchk)
const int32_t x2 = yax_globalbunch*xdimen;
@ -4271,10 +4271,10 @@ static void classicDrawBunches(int32_t bunch)
for (i=0; i<2; i++)
if (checkcf&(1<<i))
{
if ((haveymost[bn[i]>>3]&(1<<(bn[i]&7)))==0)
if ((haveymost[bn[i]>>3]&pow2char[bn[i]&7])==0)
{
// init yax *most arrays for that bunch
haveymost[bn[i]>>3] |= (1<<(bn[i]&7));
haveymost[bn[i]>>3] |= pow2char[bn[i]&7];
for (x=xdimen*bn[i]; x<xdimen*(bn[i]+1); x++)
{
yumost[x] = ydimen;
@ -4313,7 +4313,7 @@ static void classicDrawBunches(int32_t bunch)
#ifdef YAX_ENABLE
// this is to prevent double-drawing of translucent masked ceilings
if (r_tror_nomaskpass==0 || yax_globallev==YAX_MAXDRAWS || (sec->ceilingstat&256)==0 ||
yax_nomaskpass==1 || !(yax_gotsector[sectnum>>3]&(1<<(sectnum&7))))
yax_nomaskpass==1 || !(yax_gotsector[sectnum>>3]&pow2char[sectnum&7]))
#endif
{
if ((sec->ceilingstat&3) == 2)
@ -4328,7 +4328,7 @@ static void classicDrawBunches(int32_t bunch)
#ifdef YAX_ENABLE
// this is to prevent double-drawing of translucent masked floors
if (r_tror_nomaskpass==0 || yax_globallev==YAX_MAXDRAWS || (sec->floorstat&256)==0 ||
yax_nomaskpass==1 || !(yax_gotsector[sectnum>>3]&(1<<(sectnum&7))))
yax_nomaskpass==1 || !(yax_gotsector[sectnum>>3]&pow2char[sectnum&7]))
#endif
{
if ((sec->floorstat&3) == 2)
@ -10886,7 +10886,7 @@ restart_grand:
#ifdef YAX_ENABLE
pendingsectnum = -1;
#endif
sectbitmap[sect1>>3] |= (1<<(sect1&7));
sectbitmap[sect1>>3] |= pow2char[sect1&7];
clipsectorlist[0] = sect1; danum = 1;
for (dacnt=0; dacnt<danum; dacnt++)
@ -10941,9 +10941,9 @@ restart_grand:
if (ns < 0)
continue;
if (!(sectbitmap[ns>>3] & (1<<(ns&7))) && pendingsectnum==-1)
if (!(sectbitmap[ns>>3] & pow2char[ns&7]) && pendingsectnum==-1)
{
sectbitmap[ns>>3] |= (1<<(ns&7));
sectbitmap[ns>>3] |= pow2char[ns&7];
pendingsectnum = ns;
pendingvec.x = x;
pendingvec.y = y;
@ -11011,9 +11011,9 @@ restart_grand:
return 0;
add_nextsector:
if (!(sectbitmap[nexts>>3] & (1<<(nexts&7))))
if (!(sectbitmap[nexts>>3] & pow2char[nexts&7]))
{
sectbitmap[nexts>>3] |= (1<<(nexts&7));
sectbitmap[nexts>>3] |= pow2char[nexts&7];
clipsectorlist[danum++] = nexts;
}
}
@ -11030,7 +11030,7 @@ add_nextsector:
#endif
}
if (sectbitmap[sect2>>3] & (1<<(sect2&7)))
if (sectbitmap[sect2>>3] & pow2char[sect2&7])
return 1;
return 0;
@ -11232,13 +11232,13 @@ void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags)
wall[w].x = dax;
wall[w].y = day;
walbitmap[w>>3] |= (1<<(w&7));
walbitmap[w>>3] |= pow2char[w&7];
for (YAX_ITER_WALLS(w, j, tmpcf))
{
if ((walbitmap[j>>3]&(1<<(j&7)))==0)
if ((walbitmap[j>>3]&pow2char[j&7])==0)
{
walbitmap[j>>3] |= (1<<(j&7));
walbitmap[j>>3] |= pow2char[j&7];
yaxwalls[numyaxwalls++] = j;
}
}
@ -11271,7 +11271,7 @@ void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags)
break;
}
if ((walbitmap[w>>3] & (1<<(w&7))))
if ((walbitmap[w>>3] & pow2char[w&7]))
{
if (clockwise)
break;
@ -11288,7 +11288,7 @@ void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags)
int32_t w;
// TODO: extern a separate bitmap instead?
for (w=0; w<numwalls; w++)
if (walbitmap[w>>3] & (1<<(w&7)))
if (walbitmap[w>>3] & pow2char[w&7])
{
editwall[w>>3] |= 1<<(w&7);
if (flags&2)

View file

@ -324,7 +324,7 @@ void texdbg_bglGenTextures(GLsizei n, GLuint *textures, const char *srcfn)
uint32_t hash = srcfn ? texdbg_getcode(srcfn) : 0;
for (i=0; i<n; i++)
if (textures[i] < texnameallocsize && (texnameused[textures[i]>>3]&(1<<(textures[i]&7))))
if (textures[i] < texnameallocsize && (texnameused[textures[i]>>3]&pow2char[textures[i]&7]))
initprintf("texdebug %x Gen: overwriting used tex name %u from %x\n", hash, textures[i], texnamefromwhere[textures[i]]);
bglGenTextures(n, textures);
@ -339,7 +339,7 @@ void texdbg_bglGenTextures(GLsizei n, GLuint *textures, const char *srcfn)
for (i=0; i<n; i++)
{
texnameused[textures[i]>>3] |= (1<<(textures[i]&7));
texnameused[textures[i]>>3] |= pow2char[textures[i]&7];
texnamefromwhere[textures[i]] = hash;
}
}
@ -354,9 +354,9 @@ void texdbg_bglDeleteTextures(GLsizei n, const GLuint *textures, const char *src
for (i=0; i<n; i++)
if (textures[i] < texnameallocsize)
{
if ((texnameused[textures[i]>>3]&(1<<(textures[i]&7)))==0)
if ((texnameused[textures[i]>>3]&pow2char[textures[i]&7])==0)
initprintf("texdebug %x Del: deleting unused tex name %u\n", hash, textures[i]);
else if ((texnameused[textures[i]>>3]&(1<<(textures[i]&7))) &&
else if ((texnameused[textures[i]>>3]&pow2char[textures[i]&7]) &&
texnamefromwhere[textures[i]] != hash)
initprintf("texdebug %x Del: deleting foreign tex name %u from %x\n", hash,
textures[i], texnamefromwhere[textures[i]]);
@ -367,7 +367,7 @@ void texdbg_bglDeleteTextures(GLsizei n, const GLuint *textures, const char *src
if (texnameallocsize)
for (i=0; i<n; i++)
{
texnameused[textures[i]>>3] &= ~(1<<(textures[i]&7));
texnameused[textures[i]>>3] &= ~pow2char[textures[i]&7];
texnamefromwhere[textures[i]] = 0;
}
}

View file

@ -373,13 +373,13 @@ int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap)
}
for (i=anm->startframe; i<anm->endframe; i++)
usedframebitmap[i>>3] |= (1<<(i&7));
usedframebitmap[i>>3] |= pow2char[i&7];
}
sub = 0;
for (i=0; i<m->numframes; i++)
{
if (!(usedframebitmap[i>>3]&(1<<(i&7))))
if (!(usedframebitmap[i>>3]&pow2char[i&7]))
{
sub++;
otonframe[i] = -1;

View file

@ -4718,7 +4718,7 @@ static void polymost_drawalls(int32_t const bunch)
int16_t bn[2];
# if 0
int32_t obunchchk = (1 && yax_globalbunch>=0 &&
haveymost[yax_globalbunch>>3]&(1<<(yax_globalbunch&7)));
haveymost[yax_globalbunch>>3]&pow2char[yax_globalbunch&7]);
// if (obunchchk)
const int32_t x2 = yax_globalbunch*xdimen;
@ -4733,10 +4733,10 @@ static void polymost_drawalls(int32_t const bunch)
for (i=0; i<2; i++)
if (checkcf&(1<<i))
{
if ((haveymost[bn[i]>>3]&(1<<(bn[i]&7)))==0)
if ((haveymost[bn[i]>>3]&pow2char[bn[i]&7])==0)
{
// init yax *most arrays for that bunch
haveymost[bn[i]>>3] |= (1<<(bn[i]&7));
haveymost[bn[i]>>3] |= pow2char[bn[i]&7];
yax_vsp[bn[i]*2][1].x = xbl;
yax_vsp[bn[i]*2][2].x = xbr;
yax_vsp[bn[i]*2][1].cy[0] = xbb;

View file

@ -723,10 +723,10 @@ const char *ExtGetWallCaption(int16_t wallnum)
Bmemset(tempbuf,0,sizeof(tempbuf));
if (editwall[wallnum>>3]&(1<<(wallnum&7)))
if (editwall[wallnum>>3]&pow2char[wallnum&7])
{
Bsprintf(tempbuf,"%d", wallength(wallnum));
editwall[wallnum>>3] &= ~(1<<(wallnum&7));
editwall[wallnum>>3] &= ~pow2char[wallnum&7];
return tempbuf;
}
@ -2009,9 +2009,9 @@ int32_t ParentalLock = 0;
uint8_t g_ambiencePlaying[(MAXSPRITES+7)>>3];
#define testbit(bitarray, i) (bitarray[(i)>>3] & (1<<((i)&7)))
#define setbit(bitarray, i) bitarray[(i)>>3] |= (1<<((i)&7))
#define clearbit(bitarray, i) bitarray[(i)>>3] &= ~(1<<((i)&7))
#define testbit(bitarray, i) (bitarray[(i)>>3] & pow2char[(i)&7])
#define setbit(bitarray, i) bitarray[(i)>>3] |= pow2char[(i)&7]
#define clearbit(bitarray, i) bitarray[(i)>>3] &= ~pow2char[(i)&7]
// adapted from actors.c
static void M32_MoveFX(void)
@ -3065,7 +3065,7 @@ static int32_t m32gettile(int32_t idInitialTile)
for (; dir==0 || dir*(kend-k)>=1; k+=dir)
{
tilemarked[localartlookup[k]>>3] ^= (1<<(localartlookup[k]&7));
tilemarked[localartlookup[k]>>3] ^= pow2char[localartlookup[k]&7];
if (dir==0)
break;
}
@ -3132,7 +3132,7 @@ static int32_t OnSaveTileGroup(void)
TMPERRMSG_RETURN("Cannot save tile group: maximum number of groups (%d) exceeded.", MAX_TILE_GROUPS);
for (i=0; i<MAXTILES; i++)
n += !!(tilemarked[i>>3]&(1<<(i&7)));
n += !!(tilemarked[i>>3]&pow2char[i&7]);
if (n==0)
TMPERRMSG_RETURN("Cannot save tile group: no tiles marked.");
@ -3173,7 +3173,7 @@ static int32_t OnSaveTileGroup(void)
TMPERRMSG_RETURN("Could not seek to end of file `%s'.", default_tiles_cfg);
#define TTAB "\t"
#define TBITCHK(i) ((i)<MAXTILES && (tilemarked[(i)>>3]&(1<<((i)&7))))
#define TBITCHK(i) ((i)<MAXTILES && (tilemarked[(i)>>3]&pow2char[(i)&7]))
Bfprintf(fp, OURNEWL);
Bfprintf(fp, "tilegroup \"%s\"" OURNEWL"{" OURNEWL, name);
Bfprintf(fp, TTAB "hotkey \"%c\"" OURNEWL OURNEWL, hotkey);
@ -3194,7 +3194,7 @@ static int32_t OnSaveTileGroup(void)
for (k=lasti; k<i; k++)
{
s_TileGroups[tile_groups].pIds[j++] = k;
tilemarked[k>>3] &= ~(1<<(k&7));
tilemarked[k>>3] &= ~pow2char[k&7];
}
lasti = -1;
@ -3213,7 +3213,7 @@ static int32_t OnSaveTileGroup(void)
for (k=lasti; k<MAXTILES; k++)
{
s_TileGroups[tile_groups].pIds[j++] = k;
tilemarked[k>>3] &= ~(1<<(k&7));
tilemarked[k>>3] &= ~pow2char[k&7];
}
Bfprintf(fp, TTAB "tilerange %d %d" OURNEWL, lasti, MAXTILES-1);
}
@ -3221,7 +3221,7 @@ static int32_t OnSaveTileGroup(void)
k = 0;
for (i=0; i<MAXTILES; i++)
if (tilemarked[i>>3]&(1<<(i&7)))
if (tilemarked[i>>3]&pow2char[i&7])
{
k = 1;
break;
@ -3446,7 +3446,7 @@ static void tilescreen_drawbox(int32_t iTopLeft, int32_t iSelected, int32_t nXTi
int32_t TileDim, int32_t offset,
int32_t tileNum, int32_t idTile)
{
int32_t marked = (IsValidTile(idTile) && tilemarked[idTile>>3]&(1<<(idTile&7)));
int32_t marked = (IsValidTile(idTile) && tilemarked[idTile>>3]&pow2char[idTile&7]);
//
// Draw white box around currently selected tile or marked tile
@ -3585,7 +3585,7 @@ restart:
#endif
idTile = localartlookup[ tileNum ];
if (loadedhitile[idTile>>3]&(1<<(idTile&7)))
if (loadedhitile[idTile>>3]&pow2char[idTile&7])
{
if (runi==1)
continue;
@ -4223,7 +4223,7 @@ static void mouseaction_movesprites(int32_t *sumxvect, int32_t *sumyvect, int32_
dayvect = yvect;
}
if (highlightcnt<=0 || (show2dsprite[searchwall>>3] & (1<<(searchwall&7)))==0)
if (highlightcnt<=0 || (show2dsprite[searchwall>>3] & pow2char[searchwall&7])==0)
{
clipmove(&tvec, &tsect, daxvect,dayvect, sp->clipdist,64<<4,64<<4, spnoclip?1:CLIPMASK0);
setsprite(searchwall, &tvec);
@ -5086,7 +5086,7 @@ static void Keys3d(void)
{
k=eitherSHIFT?1:16;
if (highlightsectorcnt > 0 && (hlsectorbitmap[searchsector>>3]&(1<<(searchsector&7))))
if (highlightsectorcnt > 0 && (hlsectorbitmap[searchsector>>3]&pow2char[searchsector&7]))
{
while (k-- > 0)
{
@ -5124,14 +5124,14 @@ static void Keys3d(void)
{
int32_t clamped=0;
k = (highlightsectorcnt>0 && (hlsectorbitmap[searchsector>>3]&(1<<(searchsector&7))));
k = (highlightsectorcnt>0 && (hlsectorbitmap[searchsector>>3]&pow2char[searchsector&7]));
tsign *= (1+3*eitherCTRL);
if (k == 0)
{
if (ASSERT_AIMING)
{
if (!eitherSHIFT && AIMING_AT_SPRITE && (show2dsprite[searchwall>>3]&(1<<(searchwall&7))))
if (!eitherSHIFT && AIMING_AT_SPRITE && (show2dsprite[searchwall>>3]&pow2char[searchwall&7]))
{
for (i=0; i<highlightcnt; i++)
if (highlight[i]&16384)
@ -5335,7 +5335,7 @@ static void Keys3d(void)
k = 0;
if (highlightsectorcnt > 0 && searchsector>=0 && searchsector<numsectors)
{
if (hlsectorbitmap[searchsector>>3]&(1<<(searchsector&7)))
if (hlsectorbitmap[searchsector>>3]&pow2char[searchsector&7])
k = highlightsectorcnt;
}
@ -5402,10 +5402,10 @@ static void Keys3d(void)
SECTORFLD(sect,z, moveFloors) += dz;
#ifdef YAX_ENABLE
bunchnum = yax_getbunch(sect, moveFloors);
if (bunchnum >= 0 && !(havebunch[bunchnum>>3]&(1<<(bunchnum&7))))
if (bunchnum >= 0 && !(havebunch[bunchnum>>3]&pow2char[bunchnum&7]))
{
maxbunchnum = max(maxbunchnum, bunchnum);
havebunch[bunchnum>>3] |= (1<<(bunchnum&7));
havebunch[bunchnum>>3] |= pow2char[bunchnum&7];
tempzar[bunchnum] = &SECTORFLD(sect,z, moveFloors);
}
#endif
@ -5419,9 +5419,9 @@ static void Keys3d(void)
for (i=0; i<numsectors; i++)
{
yax_getbunches(i, &cb, &fb);
if (cb >= 0 && (havebunch[cb>>3]&(1<<(cb&7))))
if (cb >= 0 && (havebunch[cb>>3]&pow2char[cb&7]))
sector[i].ceilingz = *tempzar[cb];
if (fb >= 0 && (havebunch[fb>>3]&(1<<(fb&7))))
if (fb >= 0 && (havebunch[fb>>3]&pow2char[fb&7]))
sector[i].floorz = *tempzar[fb];
}
}
@ -5450,7 +5450,7 @@ static void Keys3d(void)
}
else
{
k = !!(show2dsprite[searchwall>>3]&(1<<(searchwall&7)));
k = !!(show2dsprite[searchwall>>3]&pow2char[searchwall&7]);
tsign *= (updownunits << ((eitherCTRL && mouseaction)*3));
@ -7275,7 +7275,7 @@ static void Keys2d(void)
///__bigcomment__
if ((i=tcursectornum)>=0 && g_fillCurSector && (hlsectorbitmap[i>>3]&(1<<(i&7)))==0)
if ((i=tcursectornum)>=0 && g_fillCurSector && (hlsectorbitmap[i>>3]&pow2char[i&7])==0)
{
int32_t col = editorcolors[4];
#ifdef YAX_ENABLE
@ -10186,7 +10186,7 @@ void ExtPreCheckKeys(void) // just before drawrooms
for (w = start_wall; w < end_wall; w++)
{
if (!(wallflag[w>>3]&(1<<(w&7))))
if (!(wallflag[w>>3]&pow2char[w&7]))
{
wallshades[w] = wall[w].shade;
wallpals[w] = wall[w].pal;
@ -10194,7 +10194,7 @@ void ExtPreCheckKeys(void) // just before drawrooms
wall[w].shade = sprite[i].shade;
wall[w].pal = sprite[i].pal;
wallflag[w>>3] |= (1<<(w&7));
wallflag[w>>3] |= pow2char[w&7];
}
// removed: same thing with nextwalls
}
@ -10892,11 +10892,11 @@ void ExtCheckKeys(void)
for (w = start_wall; w < end_wall; w++)
{
if (wallflag[w>>3]&(1<<(w&7)))
if (wallflag[w>>3]&pow2char[w&7])
{
wall[w].shade = wallshades[w];
wall[w].pal = wallpals[w];
wallflag[w>>3] &= ~(1<<(w&7));
wallflag[w>>3] &= ~pow2char[w&7];
}
// removed: same thing with nextwalls
}

View file

@ -571,7 +571,7 @@ static void G_SE40(int32_t smoothratio)
void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz, int32_t smoothratio)
{
if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7)))
if ((gotpic[MIRROR>>3]&pow2char[MIRROR&7])
#ifdef POLYMER
&& (videoGetRenderMode() != REND_POLYMER)
#endif
@ -581,7 +581,7 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, fix16_t a, fix16_t q16horiz
{
// NOTE: We can have g_mirrorCount==0 but gotpic'd MIRROR,
// for example in LNGA2.
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
gotpic[MIRROR>>3] &= ~pow2char[MIRROR&7];
//give scripts the chance to reset gotpics for effects that run in EVENT_DISPLAYROOMS
//EVENT_RESETGOTPICS must be called after the last call to EVENT_DISPLAYROOMS in a frame, but before any engine-side renderDrawRoomsQ16
@ -700,7 +700,7 @@ static void G_ClearGotMirror()
// XXX: fix the sequence of setting/clearing this bit. Right now,
// we always draw one frame without drawing the mirror, after which
// the bit gets set and drawn subsequently.
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
gotpic[MIRROR>>3] &= ~pow2char[MIRROR&7];
}
}
@ -1080,7 +1080,7 @@ void G_DrawRooms(int32_t playerNum, int32_t smoothRatio)
dr_viewingrange = viewingrange;
dr_yxaspect = yxaspect;
#ifdef DEBUG_MIRRORS_ONLY
gotpic[MIRROR>>3] |= (1<<(MIRROR&7));
gotpic[MIRROR>>3] |= pow2char[MIRROR&7];
#else
yax_preparedrawrooms();
renderDrawRoomsQ16(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(q16ang),CAMERA(q16horiz),CAMERA(sect));

View file

@ -5538,8 +5538,8 @@ badindex:
case GAMEARRAY_UINT8: ((int8_t *)arr.pValues)[arrayIndex] = newValue; break;
case GAMEARRAY_BITMAP:
{
uint32_t const mask = (1 << (arrayIndex & 7));
uint8_t &value = ((uint8_t *)arr.pValues)[arrayIndex >> 3];
uint32_t const mask = pow2char[arrayIndex&7];
uint8_t &value = ((uint8_t *)arr.pValues)[arrayIndex>>3];
value = (value & ~mask) | (-!!newValue & mask);
break;
}

View file

@ -787,10 +787,10 @@ static int32_t check_spritelist_consistency()
if (i >= MAXSPRITES)
return 5; // oob sprite index in list, or Numsprites inconsistent
if (havesprite[i>>3]&(1<<(i&7)))
if (havesprite[i>>3]&pow2char[i&7])
return 6; // have a cycle in the list
havesprite[i>>3] |= (1<<(i&7));
havesprite[i>>3] |= pow2char[i&7];
if (sprite[i].sectnum != s)
return 7; // .sectnum inconsistent with list
@ -805,7 +805,7 @@ static int32_t check_spritelist_consistency()
{
csc_i = i;
if (sprite[i].statnum!=MAXSTATUS && !(havesprite[i>>3]&(1<<(i&7))))
if (sprite[i].statnum!=MAXSTATUS && !(havesprite[i>>3]&pow2char[i&7]))
return 9; // have a sprite in the world not in sector list
}
@ -826,10 +826,10 @@ static int32_t check_spritelist_consistency()
// have a cycle in the list, or status list inconsistent with
// sector list (*)
if (!(havesprite[i>>3]&(1<<(i&7))))
if (!(havesprite[i>>3]&pow2char[i&7]))
return 11;
havesprite[i>>3] &= ~(1<<(i&7));
havesprite[i>>3] &= ~pow2char[i&7];
if (sprite[i].statnum != s)
return 12; // .statnum inconsistent with list
@ -846,7 +846,7 @@ static int32_t check_spritelist_consistency()
// Status list contains only a proper subset of the sprites in the
// sector list. Reverse case is handled by (*)
if (havesprite[i>>3]&(1<<(i&7)))
if (havesprite[i>>3]&pow2char[i&7])
return 14;
}
@ -1181,7 +1181,7 @@ int32_t CheckMapCorruption(int32_t printfromlev, uint64_t tryfixing)
// Check for ".nextwall already referenced from wall ..."
if (!corruptcheck_noalreadyrefd && nw>=0 && nw<numwalls)
{
if (seen_nextwalls[nw>>3]&(1<<(nw&7)))
if (seen_nextwalls[nw>>3]&pow2char[nw&7])
{
const int32_t onumct = numcorruptthings;

View file

@ -1259,7 +1259,7 @@ skip_check:
for (WALLS_OF_SECTOR(sectlist[sectcnt], j))
if ((ns=wall[j].nextsector) >= 0 && wall[j].nextsector<numsectors)
{
if (sectbitmap[ns>>3]&(1<<(ns&7)))
if (sectbitmap[ns>>3]&pow2char[ns&7])
continue;
vm.g_st = 1+MAXEVENTS+state;
insptr = apScript + statesinfo[state].ofs;
@ -1667,9 +1667,9 @@ badindex:
}
if (id==M32_SPRITE_VAR_ID)
VM_DoConditional(show2dsprite[index>>3]&(1<<(index&7)));
VM_DoConditional(show2dsprite[index>>3]&pow2char[index&7]);
else
VM_DoConditional(show2dwall[index>>3]&(1<<(index&7)));
VM_DoConditional(show2dwall[index>>3]&pow2char[index&7]);
}
continue;
@ -2333,9 +2333,9 @@ badindex:
}
if (doset)
show2dsprite[index>>3] |= (1<<(index&7));
show2dsprite[index>>3] |= pow2char[index&7];
else
show2dsprite[index>>3] &= ~(1<<(index&7));
show2dsprite[index>>3] &= ~pow2char[index&7];
}
else
{
@ -2346,9 +2346,9 @@ badindex:
}
if (doset)
show2dwall[index>>3] |= (1<<(index&7));
show2dwall[index>>3] |= pow2char[index&7];
else
show2dwall[index>>3] &= ~(1<<(index&7));
show2dwall[index>>3] &= ~pow2char[index&7];
}
vm.miscflags |= VMFLAG_MISC_UPDATEHL;
@ -2370,9 +2370,9 @@ badindex:
X_ERROR_INVALIDSECT(index);
if (doset)
hlsectorbitmap[index>>3] |= (1<<(index&7));
hlsectorbitmap[index>>3] |= pow2char[index&7];
else
hlsectorbitmap[index>>3] &= ~(1<<(index&7));
hlsectorbitmap[index>>3] &= ~pow2char[index&7];
vm.miscflags |= VMFLAG_MISC_UPDATEHLSECT;

View file

@ -1044,7 +1044,7 @@ static void G_SetupLightSwitches()
{
uint16_t const tag = sprite[j].hitag;
if (sprite[j].lotag == SE_12_LIGHT_SWITCH && tagbitmap[tag >> 3] & (1 << (tag & 7)))
if (sprite[j].lotag == SE_12_LIGHT_SWITCH && tagbitmap[tag>>3] & pow2char[tag&7])
actor[j].t_data[0] = 1;
}

View file

@ -1217,7 +1217,7 @@ static int32_t applydiff(const dataspec_t *spec, uint8_t **dumpvar, uint8_t **di
if (cnt < 0) return 1;
eltnum++;
if (((*diffvar+slen)[eltnum>>3] & (1<<(eltnum&7))) == 0)
if (((*diffvar+slen)[eltnum>>3] & pow2char[eltnum&7]) == 0)
{
dump += spec->size * cnt;
continue;
@ -2061,7 +2061,7 @@ static void sv_quotesave()
static void sv_quoteload()
{
for (int i = 0; i < MAXQUOTES; i++)
if (savegame_quotedef[i>>3] & (1<<(i&7)))
if (savegame_quotedef[i>>3] & pow2char[i&7])
{
C_AllocQuote(i);
Bmemcpy(apStrings[i], savegame_quotes[i], MAXQUOTELEN);
@ -2101,7 +2101,7 @@ static void sv_preprojectileload()
for (int i = 0; i < MAXTILES; i++)
{
if (savegame_projectiles[i>>3] & (1<<(i&7)))
if (savegame_projectiles[i>>3] & pow2char[i&7])
savegame_projectilecnt++;
}
@ -2113,7 +2113,7 @@ static void sv_postprojectileload()
{
for (int i = 0, cnt = 0; i < MAXTILES; i++)
{
if (savegame_projectiles[i>>3] & (1<<(i&7)))
if (savegame_projectiles[i>>3] & pow2char[i&7])
{
C_AllocProjectile(i);
Bmemcpy(g_tile[i].proj, &savegame_projectiledata[cnt++], sizeof(projectile_t));

View file

@ -339,7 +339,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
//Draw red lines
for (i=numsectors-1; i>=0; i--)
{
if (!(show2dsector[i>>3]&(1<<(i&7)))) continue;
if (!(show2dsector[i>>3]&pow2char[i&7])) continue;
startwall = sector[i].wallptr;
endwall = sector[i].wallptr + sector[i].wallnum;
@ -355,7 +355,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
if (sector[wal->nextsector].ceilingz == z1 && sector[wal->nextsector].floorz == z2)
if (((wal->cstat|wall[wal->nextwall].cstat)&(16+32)) == 0) continue;
if (!(show2dsector[wal->nextsector>>3]&(1<<(wal->nextsector&7))))
if (!(show2dsector[wal->nextsector>>3]&pow2char[wal->nextsector&7]))
col = editorcolors[7];
else continue;
@ -380,7 +380,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
k = g_player[screenpeek].ps->i;
for (i=numsectors-1; i>=0; i--)
{
if (!(show2dsector[i>>3]&(1<<(i&7)))) continue;
if (!(show2dsector[i>>3]&pow2char[i&7])) continue;
for (j=headspritesect[i]; j>=0; j=nextspritesect[j])
{
spr = &sprite[j];
@ -526,7 +526,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16
//Draw white lines
for (i=numsectors-1; i>=0; i--)
{
if (!(show2dsector[i>>3]&(1<<(i&7)))) continue;
if (!(show2dsector[i>>3]&pow2char[i&7])) continue;
startwall = sector[i].wallptr;
endwall = sector[i].wallptr + sector[i].wallnum;
@ -1013,7 +1013,7 @@ void G_DisplayRest(int32_t smoothratio)
{
const walltype *wal = &wall[sector[i].wallptr];
show2dsector[i>>3] |= (1<<(i&7));
show2dsector[i>>3] |= pow2char[i&7];
for (j=sector[i].wallnum; j>0; j--, wal++)
{
i = wal->nextsector;
@ -1022,7 +1022,7 @@ void G_DisplayRest(int32_t smoothratio)
if (wall[wal->nextwall].cstat&0x0071) continue;
if (sector[i].lotag == 32767) continue;
if (sector[i].ceilingz >= sector[i].floorz) continue;
show2dsector[i>>3] |= (1<<(i&7));
show2dsector[i>>3] |= pow2char[i&7];
}
}

View file

@ -461,7 +461,7 @@ void S_Callback(uint32_t num)
{
extern uint8_t g_ambiencePlaying[(MAXSPRITES+7)>>3];
g_ambiencePlaying[i>>3] &= ~(1<<(i&7));
g_ambiencePlaying[i>>3] &= ~pow2char[i&7];
if (j < k-1)
{