mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
- Replace divscale()
calls with DivScale()
from common.
This commit is contained in:
parent
868aa7f07a
commit
b9c2af130a
14 changed files with 41 additions and 59 deletions
|
@ -6615,7 +6615,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6,
|
|||
int t = thingInfo[pSprite->type-kThingBase].mass;
|
||||
if (t > 0 && pVectorData->impulse)
|
||||
{
|
||||
int t2 = divscale(pVectorData->impulse, t, 8);
|
||||
int t2 = DivScale(pVectorData->impulse, t, 8);
|
||||
xvel[nSprite] += MulScale(a4, t2, 16);
|
||||
yvel[nSprite] += MulScale(a5, t2, 16);
|
||||
zvel[nSprite] += MulScale(a6, t2, 16);
|
||||
|
@ -6645,7 +6645,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6,
|
|||
|
||||
if (t > 0 && pVectorData->impulse)
|
||||
{
|
||||
int t2 = divscale(pVectorData->impulse, t, 8);
|
||||
int t2 = DivScale(pVectorData->impulse, t, 8);
|
||||
xvel[nSprite] += MulScale(a4, t2, 16);
|
||||
yvel[nSprite] += MulScale(a5, t2, 16);
|
||||
zvel[nSprite] += MulScale(a6, t2, 16);
|
||||
|
@ -6702,7 +6702,7 @@ void actFireVector(spritetype *pShooter, int a2, int a3, int a4, int a5, int a6,
|
|||
if (gPhysSpritesCount > 0 && pVectorData->impulse) {
|
||||
int nIndex = debrisGetIndex(pSprite->index);
|
||||
if (nIndex != -1 && (xsprite[pSprite->extra].physAttr & kPhysDebrisVector)) {
|
||||
int impulse = divscale(pVectorData->impulse, ClipLow(gSpriteMass[pSprite->extra].mass, 10), 6);
|
||||
int impulse = DivScale(pVectorData->impulse, ClipLow(gSpriteMass[pSprite->extra].mass, 10), 6);
|
||||
xvel[nSprite] += MulScale(a4, impulse, 16);
|
||||
yvel[nSprite] += MulScale(a5, impulse, 16);
|
||||
zvel[nSprite] += MulScale(a6, impulse, 16);
|
||||
|
|
|
@ -283,7 +283,7 @@ static void beastThinkChase(DBloodActor* actor)
|
|||
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery)
|
||||
{
|
||||
aiSetTarget(pXSprite, pXSprite->target);
|
||||
actor->dudeSlope = divscale(pTarget->z-pSprite->z, nDist, 10);
|
||||
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
|
||||
if (nDist < 0x1400 && nDist > 0xa00 && klabs(nDeltaAngle) < 85 && (pTarget->flags&2)
|
||||
&& IsPlayerSprite(pTarget) && Chance(0x8000))
|
||||
{
|
||||
|
|
|
@ -186,7 +186,7 @@ static void calebThinkChase(DBloodActor* actor)
|
|||
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery)
|
||||
{
|
||||
aiSetTarget(pXSprite, pXSprite->target);
|
||||
actor->dudeSlope = divscale(pTarget->z-pSprite->z, nDist, 10);
|
||||
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
|
||||
if (nDist < 0x599 && klabs(nDeltaAngle) < 28)
|
||||
{
|
||||
XSECTOR *pXSector;
|
||||
|
|
|
@ -116,7 +116,7 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
|
|||
continue;
|
||||
if (tt1.at10)
|
||||
{
|
||||
int t = divscale(nDist, tt1.at10, 12);
|
||||
int t = DivScale(nDist, tt1.at10, 12);
|
||||
x2 += (xvel[nSprite2]*t)>>12;
|
||||
y2 += (yvel[nSprite2]*t)>>12;
|
||||
z2 += (zvel[nSprite2]*t)>>8;
|
||||
|
@ -145,7 +145,7 @@ void cerberusBurnSeqCallback(int, DBloodActor* actor)
|
|||
nClosest = nDist2;
|
||||
aim.dx = CosScale16(nAngle);
|
||||
aim.dy = SinScale16(nAngle);
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
}
|
||||
else
|
||||
aim.dz = tz;
|
||||
|
@ -201,7 +201,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
|
|||
continue;
|
||||
if (tt1.at10)
|
||||
{
|
||||
int t = divscale(nDist, tt1.at10, 12);
|
||||
int t = DivScale(nDist, tt1.at10, 12);
|
||||
x2 += (xvel[nSprite2]*t)>>12;
|
||||
y2 += (yvel[nSprite2]*t)>>12;
|
||||
z2 += (zvel[nSprite2]*t)>>8;
|
||||
|
@ -232,7 +232,7 @@ void cerberusBurnSeqCallback2(int, DBloodActor* actor)
|
|||
nClosest = nDist2;
|
||||
aim.dx = CosScale16(nAngle);
|
||||
aim.dy = SinScale16(nAngle);
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
}
|
||||
else
|
||||
aim.dz = tz;
|
||||
|
|
|
@ -302,7 +302,7 @@ static void cultThinkChase(DBloodActor* actor)
|
|||
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery)
|
||||
{
|
||||
aiSetTarget(pXSprite, pXSprite->target);
|
||||
actor->dudeSlope = divscale(pTarget->z-pSprite->z, nDist, 10);
|
||||
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
|
||||
switch (pSprite->type) {
|
||||
case kDudeCultistTommy:
|
||||
if (nDist < 0x1e00 && nDist > 0xe00 && klabs(nDeltaAngle) < 85 && !TargetNearExplosion(pTarget)
|
||||
|
|
|
@ -140,7 +140,7 @@ void BlastSSeqCallback(int, DBloodActor* actor)
|
|||
continue;
|
||||
if (tt.at10)
|
||||
{
|
||||
int t = divscale(nDist, tt.at10, 12);
|
||||
int t = DivScale(nDist, tt.at10, 12);
|
||||
x2 += (xvel[nSprite2]*t)>>12;
|
||||
y2 += (yvel[nSprite2]*t)>>12;
|
||||
z2 += (zvel[nSprite2]*t)>>8;
|
||||
|
@ -169,20 +169,20 @@ void BlastSSeqCallback(int, DBloodActor* actor)
|
|||
nClosest = nDist2;
|
||||
aim.dx = CosScale16(nAngle);
|
||||
aim.dy = SinScale16(nAngle);
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
if (tz > -0x333)
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
else if (tz < -0x333 && tz > -0xb33)
|
||||
aim.dz = divscale(tz, nDist, 10)+9460;
|
||||
aim.dz = DivScale(tz, nDist, 10)+9460;
|
||||
else if (tz < -0xb33 && tz > -0x3000)
|
||||
aim.dz = divscale(tz, nDist, 10)+9460;
|
||||
aim.dz = DivScale(tz, nDist, 10)+9460;
|
||||
else if (tz < -0x3000)
|
||||
aim.dz = divscale(tz, nDist, 10)-7500;
|
||||
aim.dz = DivScale(tz, nDist, 10)-7500;
|
||||
else
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
}
|
||||
else
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
|
|||
continue;
|
||||
if (tt.at10)
|
||||
{
|
||||
int t = divscale(nDist, tt.at10, 12);
|
||||
int t = DivScale(nDist, tt.at10, 12);
|
||||
x2 += (xvel[nSprite2]*t)>>12;
|
||||
y2 += (yvel[nSprite2]*t)>>12;
|
||||
z2 += (zvel[nSprite2]*t)>>8;
|
||||
|
@ -152,20 +152,20 @@ void ghostBlastSeqCallback(int, DBloodActor* actor)
|
|||
nClosest = nDist2;
|
||||
aim.dx = CosScale16(nAngle);
|
||||
aim.dy = SinScale16(nAngle);
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
if (tz > -0x333)
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
else if (tz < -0x333 && tz > -0xb33)
|
||||
aim.dz = divscale(tz, nDist, 10)+9460;
|
||||
aim.dz = DivScale(tz, nDist, 10)+9460;
|
||||
else if (tz < -0xb33 && tz > -0x3000)
|
||||
aim.dz = divscale(tz, nDist, 10)+9460;
|
||||
aim.dz = DivScale(tz, nDist, 10)+9460;
|
||||
else if (tz < -0x3000)
|
||||
aim.dz = divscale(tz, nDist, 10)-7500;
|
||||
aim.dz = DivScale(tz, nDist, 10)-7500;
|
||||
else
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
}
|
||||
else
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ static void gillThinkChase(DBloodActor* actor)
|
|||
if (nDist < pDudeInfo->seeDist && klabs(nDeltaAngle) <= pDudeInfo->periphery)
|
||||
{
|
||||
aiSetTarget(pXSprite, pXSprite->target);
|
||||
actor->dudeSlope = divscale(pTarget->z-pSprite->z, nDist, 10);
|
||||
actor->dudeSlope = DivScale(pTarget->z-pSprite->z, nDist, 10);
|
||||
if (nDist < 921 && klabs(nDeltaAngle) < 28)
|
||||
{
|
||||
XSECTOR *pXSector;
|
||||
|
|
|
@ -98,7 +98,7 @@ void sub_71BD4(int, DBloodActor* actor)
|
|||
continue;
|
||||
if (tt.at10)
|
||||
{
|
||||
int t = divscale(nDist, tt.at10, 12);
|
||||
int t = DivScale(nDist, tt.at10, 12);
|
||||
x2 += (xvel[nSprite2]*t)>>12;
|
||||
y2 += (yvel[nSprite2]*t)>>12;
|
||||
z2 += (zvel[nSprite2]*t)>>8;
|
||||
|
@ -127,7 +127,7 @@ void sub_71BD4(int, DBloodActor* actor)
|
|||
nClosest = nDist2;
|
||||
aim.dx = CosScale16(nAngle);
|
||||
aim.dy = SinScale16(nAngle);
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
}
|
||||
else
|
||||
aim.dz = tz;
|
||||
|
@ -177,7 +177,7 @@ void sub_720AC(int, DBloodActor* actor)
|
|||
continue;
|
||||
if (tt.at10)
|
||||
{
|
||||
int t = divscale(nDist, tt.at10, 12);
|
||||
int t = DivScale(nDist, tt.at10, 12);
|
||||
x2 += (xvel[nSprite2]*t)>>12;
|
||||
y2 += (yvel[nSprite2]*t)>>12;
|
||||
z2 += (zvel[nSprite2]*t)>>8;
|
||||
|
@ -206,7 +206,7 @@ void sub_720AC(int, DBloodActor* actor)
|
|||
nClosest = nDist2;
|
||||
aim.dx = CosScale16(nAngle);
|
||||
aim.dy = SinScale16(nAngle);
|
||||
aim.dz = divscale(tz, nDist, 10);
|
||||
aim.dz = DivScale(tz, nDist, 10);
|
||||
}
|
||||
else
|
||||
aim.dz = tz;
|
||||
|
|
|
@ -308,7 +308,7 @@ static void ThrowThing(DBloodActor* actor, bool impact)
|
|||
}
|
||||
|
||||
spritetype* pThing = NULL;
|
||||
if ((pThing = actFireThing(pSprite, 0, 0, (dz / 128) - zThrow, curWeapon, divscale(dist / 540, 120, 23))) == NULL) return;
|
||||
if ((pThing = actFireThing(pSprite, 0, 0, (dz / 128) - zThrow, curWeapon, DivScale(dist / 540, 120, 23))) == NULL) return;
|
||||
else if (pThinkInfo->picnum < 0 && pThing->type != kModernThingThrowableRock) pThing->picnum = 0;
|
||||
|
||||
pThing->owner = pSprite->index;
|
||||
|
@ -494,7 +494,7 @@ static void unicultThinkChase(DBloodActor* actor)
|
|||
if ((gFrameClock & 64) == 0 && Chance(0x3000) && !spriteIsUnderwater(pSprite, false))
|
||||
playGenDudeSound(pSprite, kGenDudeSndChasing);
|
||||
|
||||
actor->dudeSlope = divscale(pTarget->z - pSprite->z, dist, 10);
|
||||
actor->dudeSlope = DivScale(pTarget->z - pSprite->z, dist, 10);
|
||||
|
||||
short curWeapon = gGenDudeExtra[pSprite->index].curWeapon; short weaponType = gGenDudeExtra[pSprite->index].weaponType;
|
||||
spritetype* pLeech = leechIsDropped(pSprite); const VECTORDATA* meleeVector = &gVectorData[22];
|
||||
|
@ -1563,7 +1563,7 @@ void dudeLeechOperate(spritetype* pSprite, XSPRITE* pXSprite, EVENT event)
|
|||
int nDist = approxDist(x - pSprite->x, y - pSprite->y);
|
||||
|
||||
if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sectnum, x, y, z, pTarget->sectnum)) {
|
||||
int t = divscale(nDist, 0x1aaaaa, 12);
|
||||
int t = DivScale(nDist, 0x1aaaaa, 12);
|
||||
x += (xvel[nTarget] * t) >> 12;
|
||||
y += (yvel[nTarget] * t) >> 12;
|
||||
int angBak = pSprite->ang;
|
||||
|
@ -1571,7 +1571,7 @@ void dudeLeechOperate(spritetype* pSprite, XSPRITE* pXSprite, EVENT event)
|
|||
int dx = CosScale16(pSprite->ang);
|
||||
int dy = SinScale16(pSprite->ang);
|
||||
int tz = pTarget->z - (pTarget->yrepeat * pDudeInfo->aimHeight) * 4;
|
||||
int dz = divscale(tz - top - 256, nDist, 10);
|
||||
int dz = DivScale(tz - top - 256, nDist, 10);
|
||||
int nMissileType = kMissileLifeLeechAltNormal + (pXSprite->data3 ? 1 : 0);
|
||||
int t2;
|
||||
|
||||
|
|
|
@ -1238,7 +1238,7 @@ int ActionScan(PLAYER *pPlayer, int *a2, int *a3)
|
|||
int nMass = getDudeInfo(pSprite->type)->mass;
|
||||
if (nMass)
|
||||
{
|
||||
int t2 = divscale(0xccccc, nMass, 8);
|
||||
int t2 = DivScale(0xccccc, nMass, 8);
|
||||
xvel[*a2] += MulScale(x, t2, 16);
|
||||
yvel[*a2] += MulScale(y, t2, 16);
|
||||
zvel[*a2] += MulScale(z, t2, 16);
|
||||
|
|
|
@ -259,7 +259,7 @@ void LifeLeechOperate(spritetype *pSprite, XSPRITE *pXSprite, EVENT event)
|
|||
int nDist = approxDist(x - pSprite->x, y - pSprite->y);
|
||||
if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sectnum, x, y, z, pTarget->sectnum))
|
||||
{
|
||||
int t = divscale(nDist, 0x1aaaaa, 12);
|
||||
int t = DivScale(nDist, 0x1aaaaa, 12);
|
||||
x += (xvel[nTarget]*t)>>12;
|
||||
y += (yvel[nTarget]*t)>>12;
|
||||
int angBak = pSprite->ang;
|
||||
|
@ -267,7 +267,7 @@ void LifeLeechOperate(spritetype *pSprite, XSPRITE *pXSprite, EVENT event)
|
|||
int dx = CosScale16(pSprite->ang);
|
||||
int dy = SinScale16(pSprite->ang);
|
||||
int tz = pTarget->z - (pTarget->yrepeat * pDudeInfo->aimHeight) * 4;
|
||||
int dz = divscale(tz - top - 256, nDist, 10);
|
||||
int dz = DivScale(tz - top - 256, nDist, 10);
|
||||
int nMissileType = kMissileLifeLeechAltNormal + (pXSprite->data3 ? 1 : 0);
|
||||
int t2;
|
||||
if (!pXSprite->data3)
|
||||
|
|
|
@ -374,7 +374,7 @@ void UpdateAimVector(PLAYER * pPlayer)
|
|||
continue;
|
||||
if (pWeaponTrack->seeker)
|
||||
{
|
||||
int t = divscale(nDist,pWeaponTrack->seeker, 12);
|
||||
int t = DivScale(nDist,pWeaponTrack->seeker, 12);
|
||||
x2 += (xvel[nSprite]*t)>>12;
|
||||
y2 += (yvel[nSprite]*t)>>12;
|
||||
z2 += (zvel[nSprite]*t)>>8;
|
||||
|
@ -407,7 +407,7 @@ void UpdateAimVector(PLAYER * pPlayer)
|
|||
nClosest = nDist2;
|
||||
aim.dx = CosScale16(angle);
|
||||
aim.dy = SinScale16(angle);
|
||||
aim.dz = divscale(dzCenter, nDist, 10);
|
||||
aim.dz = DivScale(dzCenter, nDist, 10);
|
||||
nTarget = nSprite;
|
||||
}
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ void UpdateAimVector(PLAYER * pPlayer)
|
|||
nClosest = nDist2;
|
||||
aim.dx = CosScale16(angle);
|
||||
aim.dy = SinScale16(angle);
|
||||
aim.dz = divscale(dz, nDist, 10);
|
||||
aim.dz = DivScale(dz, nDist, 10);
|
||||
nTarget = nSprite;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,19 +12,6 @@
|
|||
|
||||
extern int32_t reciptable[2048];
|
||||
|
||||
// break the C version of divscale out from the others
|
||||
// because asm version overflows in drawmapview()
|
||||
|
||||
#define qw(x) ((int64_t)(x)) // quadword cast
|
||||
#define dw(x) ((int32_t)(x)) // doubleword cast
|
||||
#define wo(x) ((int16_t)(x)) // word cast
|
||||
#define by(x) ((uint8_t)(x)) // byte cast
|
||||
|
||||
#define DIVTABLESIZE 16384
|
||||
|
||||
static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx) { return (int64_t(eax) << ecx) / ebx; }
|
||||
static inline double fdivscale(double eax, double ebx, int32_t ecx) { return (eax * (double)(qw(1) << ecx)) / ebx; }
|
||||
|
||||
static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx)
|
||||
{
|
||||
return int64_t(eax) * edx / ecx;
|
||||
|
@ -45,9 +32,4 @@ static inline int32_t krecipasm(int32_t i)
|
|||
return ((reciptable[(i >> 12) & 2047] >> (((i - 0x3f800000) >> 23) & 31)) ^ (i >> 31));
|
||||
}
|
||||
|
||||
#undef qw
|
||||
#undef dw
|
||||
#undef wo
|
||||
#undef by
|
||||
|
||||
#endif // pragmas_h_
|
||||
|
|
Loading…
Reference in a new issue