mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 00:40:56 +00:00
engine.c: factor out calculation of texture coords / addresses in wall drawing.
git-svn-id: https://svn.eduke32.com/eduke32@3482 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
3b25bbed1b
commit
32b3c074d2
1 changed files with 80 additions and 78 deletions
|
@ -2640,6 +2640,51 @@ skipitaddwall:
|
||||||
while (sectorbordercnt > 0);
|
while (sectorbordercnt > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
////////// *WALLSCAN HELPERS //////////
|
||||||
|
|
||||||
|
#define WSHELPER_DECL inline //ATTRIBUTE((always_inline))
|
||||||
|
|
||||||
|
static WSHELPER_DECL void tweak_tsizes(int32_t *tsizx, int32_t *tsizy)
|
||||||
|
{
|
||||||
|
if (pow2long[picsiz[globalpicnum]&15] == *tsizx)
|
||||||
|
*tsizx = *tsizx-1;
|
||||||
|
else
|
||||||
|
*tsizx = -*tsizx;
|
||||||
|
|
||||||
|
if (pow2long[picsiz[globalpicnum]>>4] == *tsizy)
|
||||||
|
*tsizy = (picsiz[globalpicnum]>>4);
|
||||||
|
else
|
||||||
|
*tsizy = -*tsizy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static WSHELPER_DECL void calc_bufplc(intptr_t *bufplc, int32_t lw, int32_t tsizx, int32_t tsizy)
|
||||||
|
{
|
||||||
|
int32_t i = lw + globalxpanning;
|
||||||
|
|
||||||
|
if (i >= tsizx)
|
||||||
|
{
|
||||||
|
if (tsizx < 0)
|
||||||
|
i %= tsizx;
|
||||||
|
else
|
||||||
|
i &= tsizx;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tsizy < 0)
|
||||||
|
i *= -tsizy;
|
||||||
|
else
|
||||||
|
i <<= tsizy;
|
||||||
|
|
||||||
|
// Address is at the first row of tile storage (which is column-major).
|
||||||
|
*bufplc = waloff[globalpicnum] + i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static WSHELPER_DECL void calc_vplcinc(uint32_t *vplc, int32_t *vinc, int64_t sw, int32_t y1v)
|
||||||
|
{
|
||||||
|
*vinc = sw*globalyscale;
|
||||||
|
*vplc = globalzd + (uint32_t)(*vinc)*(y1v-globalhoriz+1);
|
||||||
|
}
|
||||||
|
|
||||||
#undef NONPOW2_YSIZE_ASM
|
#undef NONPOW2_YSIZE_ASM
|
||||||
#if !defined ENGINE_USING_A_C
|
#if !defined ENGINE_USING_A_C
|
||||||
# if defined CLASSIC_NONPOW2_YSIZE_WALLS || defined CLASSIC_NONPOW2_YSIZE_SPRITES
|
# if defined CLASSIC_NONPOW2_YSIZE_WALLS || defined CLASSIC_NONPOW2_YSIZE_SPRITES
|
||||||
|
@ -2653,12 +2698,12 @@ skipitaddwall:
|
||||||
//
|
//
|
||||||
static void maskwallscan(int32_t x1, int32_t x2)
|
static void maskwallscan(int32_t x1, int32_t x2)
|
||||||
{
|
{
|
||||||
int32_t x, xnice, ynice;
|
int32_t x;
|
||||||
intptr_t p, fpalookup;
|
intptr_t p, fpalookup;
|
||||||
int32_t y1ve[4], y2ve[4], tsizx, tsizy;
|
int32_t y1ve[4], y2ve[4], tsizx, tsizy;
|
||||||
#ifdef MULTI_COLUMN_VLINE
|
#ifdef MULTI_COLUMN_VLINE
|
||||||
char bad;
|
char bad;
|
||||||
int32_t i, u4, d4, dax, z;
|
int32_t u4, d4, dax, z;
|
||||||
#endif
|
#endif
|
||||||
setgotpic(globalpicnum);
|
setgotpic(globalpicnum);
|
||||||
if (globalshiftval < 0)
|
if (globalshiftval < 0)
|
||||||
|
@ -2672,10 +2717,7 @@ static void maskwallscan(int32_t x1, int32_t x2)
|
||||||
|
|
||||||
if (waloff[globalpicnum] == 0) loadtile(globalpicnum);
|
if (waloff[globalpicnum] == 0) loadtile(globalpicnum);
|
||||||
|
|
||||||
xnice = (pow2long[picsiz[globalpicnum]&15] == tsizx);
|
tweak_tsizes(&tsizx, &tsizy);
|
||||||
if (xnice) tsizx = (tsizx-1);
|
|
||||||
ynice = (pow2long[picsiz[globalpicnum]>>4] == tsizy);
|
|
||||||
if (ynice) tsizy = (picsiz[globalpicnum]>>4);
|
|
||||||
|
|
||||||
if (palookup[globalpal] == NULL)
|
if (palookup[globalpal] == NULL)
|
||||||
globalpal = 0;
|
globalpal = 0;
|
||||||
|
@ -2705,14 +2747,10 @@ static void maskwallscan(int32_t x1, int32_t x2)
|
||||||
|
|
||||||
palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swall[x],globvis));
|
palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swall[x],globvis));
|
||||||
|
|
||||||
bufplce[0] = lwall[x] + globalxpanning;
|
calc_bufplc(&bufplce[0], lwall[x], tsizx, tsizy);
|
||||||
if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; }
|
calc_vplcinc(&vplce[0], &vince[0], swall[x], y1ve[0]);
|
||||||
if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy;
|
|
||||||
|
|
||||||
vince[0] = (int64_t)swall[x]*globalyscale;
|
mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0],p+ylookup[y1ve[0]]);
|
||||||
vplce[0] = globalzd + (uint32_t)vince[0]*(y1ve[0]-globalhoriz+1);
|
|
||||||
|
|
||||||
mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],p+ylookup[y1ve[0]]);
|
|
||||||
}
|
}
|
||||||
for (; x<=x2-3; x+=4,p+=4)
|
for (; x<=x2-3; x+=4,p+=4)
|
||||||
{
|
{
|
||||||
|
@ -2725,13 +2763,8 @@ static void maskwallscan(int32_t x1, int32_t x2)
|
||||||
y2ve[z] = min(dwall[dax],startdmost[dax+windowx1]-windowy1)-1;
|
y2ve[z] = min(dwall[dax],startdmost[dax+windowx1]-windowy1)-1;
|
||||||
if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; }
|
if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; }
|
||||||
|
|
||||||
i = lwall[dax] + globalxpanning;
|
calc_bufplc(&bufplce[z], lwall[dax], tsizx, tsizy);
|
||||||
if (i >= tsizx) { if (xnice == 0) i %= tsizx; else i &= tsizx; }
|
calc_vplcinc(&vplce[z], &vince[z], swall[dax], y1ve[z]);
|
||||||
if (ynice == 0) i *= tsizy; else i <<= tsizy;
|
|
||||||
bufplce[z] = waloff[globalpicnum]+i;
|
|
||||||
|
|
||||||
vince[z] = (int64_t)swall[dax]*globalyscale;
|
|
||||||
vplce[z] = globalzd + (uint32_t)vince[z]*(y1ve[z]-globalhoriz+1);
|
|
||||||
}
|
}
|
||||||
if (bad == 15) continue;
|
if (bad == 15) continue;
|
||||||
|
|
||||||
|
@ -2787,19 +2820,15 @@ do_mvlineasm1:
|
||||||
|
|
||||||
palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swall[x],globvis));
|
palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swall[x],globvis));
|
||||||
|
|
||||||
bufplce[0] = lwall[x] + globalxpanning;
|
calc_bufplc(&bufplce[0], lwall[x], tsizx, tsizy);
|
||||||
if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; }
|
calc_vplcinc(&vplce[0], &vince[0], swall[x], y1ve[0]);
|
||||||
if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy;
|
|
||||||
|
|
||||||
vince[0] = (int64_t)swall[x]*globalyscale;
|
|
||||||
vplce[0] = globalzd + (uint32_t)vince[0]*(y1ve[0]-globalhoriz+1);
|
|
||||||
|
|
||||||
#ifdef NONPOW2_YSIZE_ASM
|
#ifdef NONPOW2_YSIZE_ASM
|
||||||
if (globalshiftval==0)
|
if (globalshiftval==0)
|
||||||
mvlineasm1nonpow2(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],p+ylookup[y1ve[0]]);
|
mvlineasm1nonpow2(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0],p+ylookup[y1ve[0]]);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],p+ylookup[y1ve[0]]);
|
mvlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0],p+ylookup[y1ve[0]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
faketimerhandler();
|
faketimerhandler();
|
||||||
|
@ -3659,12 +3688,12 @@ static void wallscan(int32_t x1, int32_t x2,
|
||||||
const int16_t *uwal, const int16_t *dwal,
|
const int16_t *uwal, const int16_t *dwal,
|
||||||
const int32_t *swal, const int32_t *lwal)
|
const int32_t *swal, const int32_t *lwal)
|
||||||
{
|
{
|
||||||
int32_t x, xnice, ynice;
|
int32_t x;
|
||||||
intptr_t fpalookup;
|
intptr_t fpalookup;
|
||||||
int32_t y1ve[4], y2ve[4], tsizx, tsizy;
|
int32_t y1ve[4], y2ve[4], tsizx, tsizy;
|
||||||
#ifdef MULTI_COLUMN_VLINE
|
#ifdef MULTI_COLUMN_VLINE
|
||||||
char bad;
|
char bad;
|
||||||
int32_t i, u4, d4, z;
|
int32_t u4, d4, z;
|
||||||
uintptr_t p;
|
uintptr_t p;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3686,10 +3715,7 @@ static void wallscan(int32_t x1, int32_t x2,
|
||||||
|
|
||||||
if (waloff[globalpicnum] == 0) loadtile(globalpicnum);
|
if (waloff[globalpicnum] == 0) loadtile(globalpicnum);
|
||||||
|
|
||||||
xnice = (pow2long[picsiz[globalpicnum]&15] == tsizx);
|
tweak_tsizes(&tsizx, &tsizy);
|
||||||
if (xnice) tsizx--;
|
|
||||||
ynice = (pow2long[picsiz[globalpicnum]>>4] == tsizy);
|
|
||||||
if (ynice) tsizy = (picsiz[globalpicnum]>>4);
|
|
||||||
|
|
||||||
fpalookup = FP_OFF(palookup[globalpal]);
|
fpalookup = FP_OFF(palookup[globalpal]);
|
||||||
|
|
||||||
|
@ -3713,14 +3739,10 @@ static void wallscan(int32_t x1, int32_t x2,
|
||||||
|
|
||||||
palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swal[x],globvis));
|
palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swal[x],globvis));
|
||||||
|
|
||||||
bufplce[0] = lwal[x] + globalxpanning;
|
calc_bufplc(&bufplce[0], lwal[x], tsizx, tsizy);
|
||||||
if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; }
|
calc_vplcinc(&vplce[0], &vince[0], swal[x], y1ve[0]);
|
||||||
if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy;
|
|
||||||
|
|
||||||
vince[0] = (int64_t)swal[x]*globalyscale;
|
vlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0],x+frameoffset+ylookup[y1ve[0]]);
|
||||||
vplce[0] = globalzd + (uint32_t)vince[0]*(y1ve[0]-globalhoriz+1);
|
|
||||||
|
|
||||||
vlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],x+frameoffset+ylookup[y1ve[0]]);
|
|
||||||
}
|
}
|
||||||
for (; x<=x2-3; x+=4)
|
for (; x<=x2-3; x+=4)
|
||||||
{
|
{
|
||||||
|
@ -3731,13 +3753,8 @@ static void wallscan(int32_t x1, int32_t x2,
|
||||||
y2ve[z] = min(dwal[x+z],dmost[x+z])-1;
|
y2ve[z] = min(dwal[x+z],dmost[x+z])-1;
|
||||||
if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; }
|
if (y2ve[z] < y1ve[z]) { bad += pow2char[z]; continue; }
|
||||||
|
|
||||||
i = lwal[x+z] + globalxpanning;
|
calc_bufplc(&bufplce[z], lwal[x+z], tsizx, tsizy);
|
||||||
if (i >= tsizx) { if (xnice == 0) i %= tsizx; else i &= tsizx; }
|
calc_vplcinc(&vplce[z], &vince[z], swal[x+z], y1ve[z]);
|
||||||
if (ynice == 0) i *= tsizy; else i <<= tsizy;
|
|
||||||
bufplce[z] = waloff[globalpicnum]+i;
|
|
||||||
|
|
||||||
vince[z] = (int64_t)swal[x+z]*globalyscale;
|
|
||||||
vplce[z] = globalzd + (uint32_t)vince[z]*(y1ve[z]-globalhoriz+1);
|
|
||||||
}
|
}
|
||||||
if (bad == 15) continue;
|
if (bad == 15) continue;
|
||||||
|
|
||||||
|
@ -3793,19 +3810,15 @@ do_vlineasm1:
|
||||||
|
|
||||||
palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swal[x],globvis));
|
palookupoffse[0] = fpalookup + getpalookupsh(mulscale16(swal[x],globvis));
|
||||||
|
|
||||||
bufplce[0] = lwal[x] + globalxpanning;
|
calc_bufplc(&bufplce[0], lwal[x], tsizx, tsizy);
|
||||||
if (bufplce[0] >= tsizx) { if (xnice == 0) bufplce[0] %= tsizx; else bufplce[0] &= tsizx; }
|
calc_vplcinc(&vplce[0], &vince[0], swal[x], y1ve[0]);
|
||||||
if (ynice == 0) bufplce[0] *= tsizy; else bufplce[0] <<= tsizy;
|
|
||||||
|
|
||||||
vince[0] = (int64_t)swal[x]*globalyscale;
|
|
||||||
vplce[0] = globalzd + (uint32_t)vince[0]*(y1ve[0]-globalhoriz+1);
|
|
||||||
|
|
||||||
#ifdef NONPOW2_YSIZE_ASM
|
#ifdef NONPOW2_YSIZE_ASM
|
||||||
if (globalshiftval==0)
|
if (globalshiftval==0)
|
||||||
vlineasm1nonpow2(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],x+frameoffset+ylookup[y1ve[0]]);
|
vlineasm1nonpow2(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0],x+frameoffset+ylookup[y1ve[0]]);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
vlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0]+waloff[globalpicnum],x+frameoffset+ylookup[y1ve[0]]);
|
vlineasm1(vince[0],palookupoffse[0],y2ve[0]-y1ve[0]-1,vplce[0],bufplce[0],x+frameoffset+ylookup[y1ve[0]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
faketimerhandler();
|
faketimerhandler();
|
||||||
|
@ -3816,10 +3829,11 @@ do_vlineasm1:
|
||||||
//
|
//
|
||||||
static void transmaskvline(int32_t x)
|
static void transmaskvline(int32_t x)
|
||||||
{
|
{
|
||||||
int32_t vplc, vinc, i;
|
uint32_t vplc;
|
||||||
|
int32_t vinc;
|
||||||
intptr_t palookupoffs;
|
intptr_t palookupoffs;
|
||||||
intptr_t bufplc,p;
|
intptr_t bufplc,p;
|
||||||
int16_t y1v, y2v;
|
int32_t y1v, y2v;
|
||||||
|
|
||||||
if ((x < 0) || (x >= xdimen)) return;
|
if ((x < 0) || (x >= xdimen)) return;
|
||||||
|
|
||||||
|
@ -3830,12 +3844,8 @@ static void transmaskvline(int32_t x)
|
||||||
|
|
||||||
palookupoffs = FP_OFF(palookup[globalpal]) + getpalookupsh(mulscale16(swall[x],globvis));
|
palookupoffs = FP_OFF(palookup[globalpal]) + getpalookupsh(mulscale16(swall[x],globvis));
|
||||||
|
|
||||||
vinc = (int64_t)swall[x]*globalyscale;
|
calc_bufplc(&bufplc, lwall[x], -tilesizx[globalpicnum], -tilesizy[globalpicnum]);
|
||||||
vplc = globalzd + (uint32_t)vinc*(y1v-globalhoriz+1);
|
calc_vplcinc(&vplc, &vinc, swall[x], y1v);
|
||||||
|
|
||||||
i = lwall[x]+globalxpanning;
|
|
||||||
if (i >= tilesizx[globalpicnum]) i %= tilesizx[globalpicnum];
|
|
||||||
bufplc = waloff[globalpicnum]+i*tilesizy[globalpicnum];
|
|
||||||
|
|
||||||
p = ylookup[y1v]+x+frameoffset;
|
p = ylookup[y1v]+x+frameoffset;
|
||||||
|
|
||||||
|
@ -3854,8 +3864,8 @@ static void transmaskvline(int32_t x)
|
||||||
#ifdef MULTI_COLUMN_VLINE
|
#ifdef MULTI_COLUMN_VLINE
|
||||||
static void transmaskvline2(int32_t x)
|
static void transmaskvline2(int32_t x)
|
||||||
{
|
{
|
||||||
int32_t i, y1, y2, x2;
|
int32_t y1, y2, x2;
|
||||||
int16_t y1ve[2], y2ve[2];
|
int32_t y1ve[2], y2ve[2];
|
||||||
|
|
||||||
uintptr_t p;
|
uintptr_t p;
|
||||||
|
|
||||||
|
@ -3876,18 +3886,10 @@ static void transmaskvline2(int32_t x)
|
||||||
|
|
||||||
setuptvlineasm2(globalshiftval,palookupoffse[0],palookupoffse[1]);
|
setuptvlineasm2(globalshiftval,palookupoffse[0],palookupoffse[1]);
|
||||||
|
|
||||||
vince[0] = (int64_t)swall[x]*globalyscale;
|
calc_bufplc(&bufplce[0], lwall[x], -tilesizx[globalpicnum], -tilesizy[globalpicnum]);
|
||||||
vince[1] = (int64_t)swall[x2]*globalyscale;
|
calc_bufplc(&bufplce[1], lwall[x2], -tilesizx[globalpicnum], -tilesizy[globalpicnum]);
|
||||||
vplce[0] = globalzd + (uint32_t)vince[0]*(y1ve[0]-globalhoriz+1);
|
calc_vplcinc(&vplce[0], &vince[0], swall[x], y1ve[0]);
|
||||||
vplce[1] = globalzd + (uint32_t)vince[1]*(y1ve[1]-globalhoriz+1);
|
calc_vplcinc(&vplce[1], &vince[1], swall[x2], y1ve[1]);
|
||||||
|
|
||||||
i = lwall[x] + globalxpanning;
|
|
||||||
if (i >= tilesizx[globalpicnum]) i %= tilesizx[globalpicnum];
|
|
||||||
bufplce[0] = waloff[globalpicnum]+i*tilesizy[globalpicnum];
|
|
||||||
|
|
||||||
i = lwall[x2] + globalxpanning;
|
|
||||||
if (i >= tilesizx[globalpicnum]) i %= tilesizx[globalpicnum];
|
|
||||||
bufplce[1] = waloff[globalpicnum]+i*tilesizy[globalpicnum];
|
|
||||||
|
|
||||||
y1 = max(y1ve[0],y1ve[1]);
|
y1 = max(y1ve[0],y1ve[1]);
|
||||||
y2 = min(y2ve[0],y2ve[1]);
|
y2 = min(y2ve[0],y2ve[1]);
|
||||||
|
|
Loading…
Reference in a new issue