- buildutils: Replace Sin() and Cos() from Exhumed with bsin()/bcos().

This commit is contained in:
Mitchell Richters 2020-11-14 19:45:08 +11:00 committed by Christoph Oelckers
parent 8aa7051f78
commit cf6188b034
25 changed files with 181 additions and 210 deletions

View file

@ -711,7 +711,7 @@ public:
if (nLevelNew == i) if (nLevelNew == i)
{ {
shade = (Sin(16 * currentclock) + 31) >> 8; shade = (bsin(16 * currentclock) + 31) >> 8;
} }
else if (nLevelBest >= i) else if (nLevelBest >= i)
{ {

View file

@ -218,8 +218,8 @@ void FuncAnubis(int a, int nDamage, int nRun)
AnubisList[nAnubis].nFrame = 0; AnubisList[nAnubis].nFrame = 0;
AnubisList[nAnubis].nTarget = nTarget; AnubisList[nAnubis].nTarget = nTarget;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
} }
} }
return; return;
@ -231,8 +231,8 @@ void FuncAnubis(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
int nAngle = sprite[nSprite].ang & 0xFFF8; int nAngle = sprite[nSprite].ang & 0xFFF8;
sprite[nSprite].xvel = Cos(nAngle) >> 2; sprite[nSprite].xvel = bcos(nAngle, -2);
sprite[nSprite].yvel = Sin(nAngle) >> 2; sprite[nSprite].yvel = bsin(nAngle, -2);
} }
switch (nMov & 0xC000) switch (nMov & 0xC000)
@ -257,8 +257,8 @@ void FuncAnubis(int a, int nDamage, int nRun)
case 0x8000: case 0x8000:
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
break; break;
} }
@ -321,8 +321,8 @@ void FuncAnubis(int a, int nDamage, int nRun)
{ {
AnubisList[nAnubis].nAction = 1; AnubisList[nAnubis].nAction = 1;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
AnubisList[nAnubis].nFrame = 0; AnubisList[nAnubis].nFrame = 0;
} }
else else

View file

@ -213,8 +213,8 @@ void BulletHitsSprite(Bullet *pBullet, short nBulletSprite, short nHitSprite, in
{ {
short nAngle = (pSprite->ang + 256) - RandomSize(9); short nAngle = (pSprite->ang + 256) - RandomSize(9);
pHitSprite->xvel = Cos(nAngle) << 1; pHitSprite->xvel = bcos(nAngle, 1);
pHitSprite->yvel = Sin(nAngle) << 1; pHitSprite->yvel = bsin(nAngle, 1);
pHitSprite->zvel = (-(RandomSize(3) + 1)) << 8; pHitSprite->zvel = (-(RandomSize(3) + 1)) << 8;
} }
else else
@ -222,8 +222,8 @@ void BulletHitsSprite(Bullet *pBullet, short nBulletSprite, short nHitSprite, in
int xVel = pHitSprite->xvel; int xVel = pHitSprite->xvel;
int yVel = pHitSprite->yvel; int yVel = pHitSprite->yvel;
pHitSprite->xvel = Cos(pSprite->ang) >> 2; pHitSprite->xvel = bcos(pSprite->ang, -2);
pHitSprite->yvel = Sin(pSprite->ang) >> 2; pHitSprite->yvel = bsin(pSprite->ang, -2);
MoveCreature(nHitSprite); MoveCreature(nHitSprite);
@ -276,8 +276,8 @@ void BulletHitsSprite(Bullet *pBullet, short nBulletSprite, short nHitSprite, in
void BackUpBullet(int *x, int *y, short nAngle) void BackUpBullet(int *x, int *y, short nAngle)
{ {
*x -= Cos(nAngle) >> 11; *x -= bcos(nAngle, -11);
*y -= Sin(nAngle) >> 11; *y -= bsin(nAngle, -11);
} }
int MoveBullet(short nBullet) int MoveBullet(short nBullet)
@ -409,10 +409,10 @@ MOVEEND:
hitdata_t hitData; hitdata_t hitData;
int dz; int dz;
if (bVanilla) if (bVanilla)
dz = -Sin(pBullet->field_C) * 8; dz = -bsin(pBullet->field_C, 3);
else else
dz = -pBullet->field_C * 512; dz = -pBullet->field_C * 512;
hitscan(&startPos, pSprite->sectnum, Cos(pSprite->ang), Sin(pSprite->ang), dz, &hitData, CLIPMASK1); hitscan(&startPos, pSprite->sectnum, bcos(pSprite->ang), bsin(pSprite->ang), dz, &hitData, CLIPMASK1);
x2 = hitData.pos.x; x2 = hitData.pos.x;
y2 = hitData.pos.y; y2 = hitData.pos.y;
z2 = hitData.pos.z; z2 = hitData.pos.z;
@ -691,7 +691,7 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
if (val2 < 10000) if (val2 < 10000)
{ {
var_18 = ((-Sin(val2)) * pBulletInfo->field_4) >> 11; var_18 = (-bsin(val2) * pBulletInfo->field_4) >> 11;
} }
else else
{ {
@ -766,8 +766,8 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
} }
pBullet->z = 0; pBullet->z = 0;
pBullet->x = (sprite[nSprite].clipdist << 2) * Cos(nAngle); pBullet->x = (sprite[nSprite].clipdist << 2) * bcos(nAngle);
pBullet->y = (sprite[nSprite].clipdist << 2) * Sin(nAngle); pBullet->y = (sprite[nSprite].clipdist << 2) * bsin(nAngle);
nBulletEnemy[nBullet] = -1; nBulletEnemy[nBullet] = -1;
if (MoveBullet(nBullet)) if (MoveBullet(nBullet))
@ -777,8 +777,8 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va
else else
{ {
pBullet->field_10 = pBulletInfo->field_4; pBullet->field_10 = pBulletInfo->field_4;
pBullet->x = (Cos(nAngle) >> 3) * pBulletInfo->field_4; pBullet->x = bcos(nAngle, -3) * pBulletInfo->field_4;
pBullet->y = (Sin(nAngle) >> 3) * pBulletInfo->field_4; pBullet->y = bsin(nAngle, -3) * pBulletInfo->field_4;
pBullet->z = var_18 >> 3; pBullet->z = var_18 >> 3;
} }

View file

@ -126,15 +126,5 @@ int GetMyAngle(int x, int y);
int AngleDiff(short a, short b); int AngleDiff(short a, short b);
int AngleDelta(int a, int b, int c); int AngleDelta(int a, int b, int c);
inline int Sin(int angle)
{
return sintable[angle & kAngleMask];
}
inline int Cos(int angle)
{
return sintable[(angle + 512) & kAngleMask];
}
END_PS_NS END_PS_NS

View file

@ -333,8 +333,8 @@ void GameInterface::Ticker()
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
lPlayerXVel += localInput.fvel * Cos(inita) + localInput.svel * Sin(inita); lPlayerXVel += localInput.fvel * bcos(inita) + localInput.svel * bsin(inita);
lPlayerYVel += localInput.fvel * Sin(inita) - localInput.svel * Cos(inita); lPlayerYVel += localInput.fvel * bsin(inita) - localInput.svel * bcos(inita);
lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6); lPlayerXVel -= (lPlayerXVel >> 5) + (lPlayerXVel >> 6);
lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6); lPlayerYVel -= (lPlayerYVel >> 5) + (lPlayerYVel >> 6);
} }

View file

@ -282,8 +282,8 @@ void IdleFish(short nFish, short edx)
sprite[nSprite].ang += (256 - RandomSize(9)) + 1024; sprite[nSprite].ang += (256 - RandomSize(9)) + 1024;
sprite[nSprite].ang &= kAngleMask; sprite[nSprite].ang &= kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 8; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -8);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 8; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -8);
FishList[nFish].nAction = 0; FishList[nFish].nAction = 0;
FishList[nFish].nFrame = 0; FishList[nFish].nFrame = 0;
@ -440,7 +440,7 @@ void FuncFish(int a, int nDamage, int nRun)
FishList[nFish].nFrame = 0; FishList[nFish].nFrame = 0;
int nAngle = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].z - sprite[nSprite].z); int nAngle = GetMyAngle(sprite[nTarget].x - sprite[nSprite].x, sprite[nTarget].z - sprite[nSprite].z);
sprite[nSprite].zvel = Sin(nAngle) >> 5; sprite[nSprite].zvel = bsin(nAngle, -5);
FishList[nFish].field_C = RandomSize(6) + 90; FishList[nFish].field_C = RandomSize(6) + 90;
} }
@ -474,8 +474,8 @@ void FuncFish(int a, int nDamage, int nRun)
if (z <= nHeight) if (z <= nHeight)
{ {
sprite[nSprite].xvel = (Cos(sprite[nSprite].ang) >> 5) - (Cos(sprite[nSprite].ang) >> 7); sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -5) - bcos(sprite[nSprite].ang, -7);
sprite[nSprite].yvel = (Sin(sprite[nSprite].ang) >> 5) - (Sin(sprite[nSprite].ang) >> 7); sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -5) - bsin(sprite[nSprite].ang, -7);
} }
else else
{ {

View file

@ -88,8 +88,8 @@ void BounceGrenade(short nGrenade, short nAngle)
{ {
GrenadeList[nGrenade].field_10 >>= 1; GrenadeList[nGrenade].field_10 >>= 1;
GrenadeList[nGrenade].x = (Cos(nAngle) >> 5) * GrenadeList[nGrenade].field_10; GrenadeList[nGrenade].x = bcos(nAngle, -5) * GrenadeList[nGrenade].field_10;
GrenadeList[nGrenade].y = (Sin(nAngle) >> 5) * GrenadeList[nGrenade].field_10; GrenadeList[nGrenade].y = bsin(nAngle, -5) * GrenadeList[nGrenade].field_10;
D3PlayFX(StaticSound[kSound3], GrenadeList[nGrenade].nSprite); D3PlayFX(StaticSound[kSound3], GrenadeList[nGrenade].nSprite);
} }
@ -126,7 +126,7 @@ int ThrowGrenade(short nPlayer, int, int, int ecx, int push1)
GrenadeList[nGrenade].field_10 = ((90 - GrenadeList[nGrenade].field_E) * (90 - GrenadeList[nGrenade].field_E)) + nVel; GrenadeList[nGrenade].field_10 = ((90 - GrenadeList[nGrenade].field_E) * (90 - GrenadeList[nGrenade].field_E)) + nVel;
sprite[nGrenadeSprite].zvel = (-64 * push1) - 4352; sprite[nGrenadeSprite].zvel = (-64 * push1) - 4352;
int nMov = movesprite(nGrenadeSprite, Cos(nAngle) * (sprite[nPlayerSprite].clipdist << 3), Sin(nAngle) * (sprite[nPlayerSprite].clipdist << 3), ecx, 0, 0, CLIPMASK1); int nMov = movesprite(nGrenadeSprite, bcos(nAngle) * (sprite[nPlayerSprite].clipdist << 3), bsin(nAngle) * (sprite[nPlayerSprite].clipdist << 3), ecx, 0, 0, CLIPMASK1);
if (nMov & 0x8000) if (nMov & 0x8000)
{ {
nAngle = GetWallNormal(nMov & 0x3FFF); nAngle = GetWallNormal(nMov & 0x3FFF);
@ -139,11 +139,8 @@ int ThrowGrenade(short nPlayer, int, int, int ecx, int push1)
sprite[nGrenadeSprite].zvel = sprite[nPlayerSprite].zvel; sprite[nGrenadeSprite].zvel = sprite[nPlayerSprite].zvel;
} }
GrenadeList[nGrenade].x = Cos(nAngle) >> 4; GrenadeList[nGrenade].x = bcos(nAngle, -4) * GrenadeList[nGrenade].field_10;
GrenadeList[nGrenade].x *= GrenadeList[nGrenade].field_10; GrenadeList[nGrenade].y = bsin(nAngle, -4) * GrenadeList[nGrenade].field_10;
GrenadeList[nGrenade].y = Sin(nAngle) >> 4;
GrenadeList[nGrenade].y *= GrenadeList[nGrenade].field_10;
nPlayerGrenade[nPlayer] = -1; nPlayerGrenade[nPlayer] = -1;
@ -240,8 +237,8 @@ void ExplodeGrenade(short nGrenade)
short nAngle = sprite[nPlayerSprite].ang; short nAngle = sprite[nPlayerSprite].ang;
sprite[nGrenadeSprite].z = sprite[nPlayerSprite].z; sprite[nGrenadeSprite].z = sprite[nPlayerSprite].z;
sprite[nGrenadeSprite].x = (Cos(nAngle) >> 5) + sprite[nPlayerSprite].x; sprite[nGrenadeSprite].x = bcos(nAngle, -5) + sprite[nPlayerSprite].x;
sprite[nGrenadeSprite].y = (Sin(nAngle) >> 5) + sprite[nPlayerSprite].y; sprite[nGrenadeSprite].y = bsin(nAngle, -5) + sprite[nPlayerSprite].y;
changespritesect(nGrenadeSprite, sprite[nPlayerSprite].sectnum); changespritesect(nGrenadeSprite, sprite[nPlayerSprite].sectnum);

View file

@ -289,8 +289,8 @@ int CheckCloseRange(short nPlayer, int *x, int *y, int *z, short *nSector)
short nSprite = PlayerList[nPlayer].nSprite; short nSprite = PlayerList[nPlayer].nSprite;
int xVect = Sin(sprite[nSprite].ang + 512); int xVect = bcos(sprite[nSprite].ang);
int yVect = Sin(sprite[nSprite].ang); int yVect = bsin(sprite[nSprite].ang);
vec3_t startPos = { *x, *y, *z }; vec3_t startPos = { *x, *y, *z };
hitdata_t hitData; hitdata_t hitData;
@ -697,8 +697,8 @@ loc_flag:
int theY = sprite[nPlayerSprite].y; int theY = sprite[nPlayerSprite].y;
int theZ = sprite[nPlayerSprite].z; int theZ = sprite[nPlayerSprite].z;
int ebp = Cos(nAngle) * (sprite[nPlayerSprite].clipdist << 3); int ebp = bcos(nAngle) * (sprite[nPlayerSprite].clipdist << 3);
int ebx = Sin(nAngle) * (sprite[nPlayerSprite].clipdist << 3); int ebx = bsin(nAngle) * (sprite[nPlayerSprite].clipdist << 3);
if (WeaponInfo[nWeapon].c) if (WeaponInfo[nWeapon].c)
{ {
@ -711,8 +711,8 @@ loc_flag:
ecx = theVal; ecx = theVal;
int var_44 = (nAngle + 512) & kAngleMask; int var_44 = (nAngle + 512) & kAngleMask;
ebp += (Cos(var_44) >> 11) * ecx; ebp += bcos(var_44, -11) * ecx;
ebx += (Sin(var_44) >> 11) * ecx; ebx += bsin(var_44, -11) * ecx;
} }
int nHeight = (-GetSpriteHeight(nPlayerSprite)) >> 1; int nHeight = (-GetSpriteHeight(nPlayerSprite)) >> 1;
@ -867,8 +867,8 @@ loc_flag:
BuildSnake(nPlayer, nHeight); BuildSnake(nPlayer, nHeight);
nQuake[nPlayer] = 512; nQuake[nPlayer] = 512;
nXDamage[nPlayer] -= Sin(sprite[nPlayerSprite].ang + 512) << 9; nXDamage[nPlayer] -= bcos(sprite[nPlayerSprite].ang, 9);
nYDamage[nPlayer] -= Sin(sprite[nPlayerSprite].ang) << 9; nYDamage[nPlayer] -= bsin(sprite[nPlayerSprite].ang, 9);
break; break;
} }
case kWeaponRing: case kWeaponRing:

View file

@ -329,8 +329,8 @@ void FuncLava(int a, int nDamage, int nRun)
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang); sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
if (nTarget >= 0 && !RandomSize(1)) if (nTarget >= 0 && !RandomSize(1))
{ {
@ -357,8 +357,8 @@ void FuncLava(int a, int nDamage, int nRun)
sprite[nSprite].z = z; sprite[nSprite].z = z;
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang); sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
break; break;
} }
@ -369,8 +369,8 @@ void FuncLava(int a, int nDamage, int nRun)
if ((nVal & 0xC000) == 0x8000) if ((nVal & 0xC000) == 0x8000)
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang); sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
break; break;
} }
else if ((nVal & 0xC000) == 0xC000) else if ((nVal & 0xC000) == 0xC000)
@ -419,7 +419,7 @@ void FuncLava(int a, int nDamage, int nRun)
int nHeight = GetSpriteHeight(nSprite); int nHeight = GetSpriteHeight(nSprite);
GetUpAngle(nSprite, -64000, nTarget, (-(nHeight >> 1))); GetUpAngle(nSprite, -64000, nTarget, (-(nHeight >> 1)));
BuildBullet(nSprite, 10, Cos(sprite[nSprite].ang) << 8, Sin(sprite[nSprite].ang) << 8, -1, sprite[nSprite].ang, nTarget + 10000, 1); BuildBullet(nSprite, 10, bcos(sprite[nSprite].ang, 8), bsin(sprite[nSprite].ang, 8), -1, sprite[nSprite].ang, nTarget + 10000, 1);
} }
else if (var_1C) else if (var_1C)
{ {

View file

@ -632,8 +632,8 @@ void AddFlow(int nSprite, int nSpeed, int b)
sFlowInfo[nFlow].field_14 = (tilesiz[nPic].x << 14) - 1; sFlowInfo[nFlow].field_14 = (tilesiz[nPic].x << 14) - 1;
sFlowInfo[nFlow].field_18 = (tilesiz[nPic].y << 14) - 1; sFlowInfo[nFlow].field_18 = (tilesiz[nPic].y << 14) - 1;
sFlowInfo[nFlow].field_C = -Cos(nAngle) * nSpeed; sFlowInfo[nFlow].field_C = -bcos(nAngle) * nSpeed;
sFlowInfo[nFlow].field_10 = Sin(nAngle) * nSpeed; sFlowInfo[nFlow].field_10 = bsin(nAngle) * nSpeed;
} }
else else
{ {
@ -651,8 +651,8 @@ void AddFlow(int nSprite, int nSpeed, int b)
sFlowInfo[nFlow].field_14 = (tilesiz[nPic].x * wall[var_18].xrepeat) << 8; sFlowInfo[nFlow].field_14 = (tilesiz[nPic].x * wall[var_18].xrepeat) << 8;
sFlowInfo[nFlow].field_18 = (tilesiz[nPic].y * wall[var_18].yrepeat) << 8; sFlowInfo[nFlow].field_18 = (tilesiz[nPic].y * wall[var_18].yrepeat) << 8;
sFlowInfo[nFlow].field_C = -Cos(nAngle) * nSpeed; sFlowInfo[nFlow].field_C = -bcos(nAngle) * nSpeed;
sFlowInfo[nFlow].field_10 = Sin(nAngle) * nSpeed; sFlowInfo[nFlow].field_10 = bsin(nAngle) * nSpeed;
} }
sFlowInfo[nFlow].field_8 = 0; sFlowInfo[nFlow].field_8 = 0;

View file

@ -282,8 +282,8 @@ void FuncLion(int a, int nDamage, int nRun)
LionList[nLion].nAction = 2; LionList[nLion].nAction = 2;
LionList[nLion].nFrame = 0; LionList[nLion].nFrame = 0;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
LionList[nLion].nTarget = nTarget; LionList[nLion].nTarget = nTarget;
return; return;
} }
@ -298,8 +298,8 @@ void FuncLion(int a, int nDamage, int nRun)
if (RandomBit()) if (RandomBit())
{ {
sprite[nSprite].ang = RandomWord() & kAngleMask; sprite[nSprite].ang = RandomWord() & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
} }
else else
{ {
@ -324,13 +324,13 @@ void FuncLion(int a, int nDamage, int nRun)
if (sprite[nSprite].cstat & 0x8000) if (sprite[nSprite].cstat & 0x8000)
{ {
sprite[nSprite].xvel = Cos(nAng) * 2; sprite[nSprite].xvel = bcos(nAng, 1);
sprite[nSprite].yvel = Sin(nAng) * 2; sprite[nSprite].yvel = bsin(nAng, 1);
} }
else else
{ {
sprite[nSprite].xvel = Cos(nAng) >> 1; sprite[nSprite].xvel = bcos(nAng, -1);
sprite[nSprite].yvel = Sin(nAng) >> 1; sprite[nSprite].yvel = bsin(nAng, -1);
} }
} }
@ -342,8 +342,8 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
// loc_378FA: // loc_378FA:
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
break; break;
} }
else if ((nMov & 0xC000) == 0xC000) else if ((nMov & 0xC000) == 0xC000)
@ -374,8 +374,8 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
// loc_378FA: // loc_378FA:
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
break; break;
} }
} }
@ -446,7 +446,7 @@ void FuncLion(int a, int nDamage, int nRun)
vec3_t startPos = { x, y, z }; vec3_t startPos = { x, y, z };
hitdata_t hitData; hitdata_t hitData;
hitscan(&startPos, sprite[nSprite].sectnum, Cos(nScanAngle), Sin(nScanAngle), 0, &hitData, CLIPMASK1); hitscan(&startPos, sprite[nSprite].sectnum, bcos(nScanAngle), bsin(nScanAngle), 0, &hitData, CLIPMASK1);
hitx = hitData.pos.x; hitx = hitData.pos.x;
hity = hitData.pos.y; hity = hitData.pos.y;
@ -471,8 +471,8 @@ void FuncLion(int a, int nDamage, int nRun)
sprite[nSprite].ang = nAngle; sprite[nSprite].ang = nAngle;
LionList[nLion].nAction = 6; LionList[nLion].nAction = 6;
sprite[nSprite].xvel = (Cos(sprite[nSprite].ang)) - (Cos(sprite[nSprite].ang) >> 3); sprite[nSprite].xvel = bcos(sprite[nSprite].ang) - bcos(sprite[nSprite].ang, -3);
sprite[nSprite].yvel = (Sin(sprite[nSprite].ang)) - (Sin(sprite[nSprite].ang) >> 3); sprite[nSprite].yvel = bsin(sprite[nSprite].ang) - bsin(sprite[nSprite].ang, -3);
D3PlayFX(StaticSound[kSound24], nSprite); D3PlayFX(StaticSound[kSound24], nSprite);
} }
@ -510,8 +510,8 @@ void FuncLion(int a, int nDamage, int nRun)
{ {
// loc_378FA: // loc_378FA:
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
break; break;
} }
} }
@ -538,8 +538,8 @@ void FuncLion(int a, int nDamage, int nRun)
sprite[nSprite].zvel = -1000; sprite[nSprite].zvel = -1000;
LionList[nLion].nAction = 6; LionList[nLion].nAction = 6;
sprite[nSprite].xvel = (Cos(sprite[nSprite].ang)) - (Cos(sprite[nSprite].ang) >> 3); sprite[nSprite].xvel = bcos(sprite[nSprite].ang) - bcos(sprite[nSprite].ang, -3);
sprite[nSprite].yvel = (Sin(sprite[nSprite].ang)) - (Sin(sprite[nSprite].ang) >> 3); sprite[nSprite].yvel = bsin(sprite[nSprite].ang) - bsin(sprite[nSprite].ang, -3);
D3PlayFX(StaticSound[kSound24], nSprite); D3PlayFX(StaticSound[kSound24], nSprite);
} }

View file

@ -661,8 +661,8 @@ int MoveCreatureWithCaution(int nSprite)
mychangespritesect(nSprite, nSectorPre); mychangespritesect(nSprite, nSectorPre);
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Sin(sprite[nSprite].ang + 512) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
return 0; return 0;
} }
} }
@ -770,13 +770,13 @@ void CheckSectorFloor(short nSector, int z, int *x, int *y)
if (z >= sector[nSector].floorz) if (z >= sector[nSector].floorz)
{ {
*x += (Cos(nAng) << 3) * nSpeed; *x += bcos(nAng, 3) * nSpeed;
*y += (sintable[nAng] << 3) * nSpeed; // no anglemask in original code *y += bsin(nAng, 3) * nSpeed;
} }
else if (nFlag & 0x800) else if (nFlag & 0x800)
{ {
*x += (Cos(nAng) << 4) * nSpeed; *x += bcos(nAng, 4) * nSpeed;
*y += (sintable[nAng] << 4) * nSpeed; // no anglemask in original code *y += bsin(nAng, 4) * nSpeed;
} }
} }
@ -891,8 +891,8 @@ void MoveSector(short nSector, int nAngle, int *nXVel, int *nYVel)
} }
else else
{ {
nXVect = Sin(nAngle + 512) << 6; nXVect = bcos(nAngle, 6);
nYVect = Sin(nAngle) << 6; nYVect = bsin(nAngle, 6);
} }
short nBlock = sector[nSector].extra; short nBlock = sector[nSector].extra;
@ -1039,8 +1039,8 @@ void MoveSector(short nSector, int nAngle, int *nXVel, int *nYVel)
nSectorB = nNextSector; nSectorB = nNextSector;
clipmove_old((int32_t*)&x, (int32_t*)&y, (int32_t*)&z, &nSectorB, clipmove_old((int32_t*)&x, (int32_t*)&y, (int32_t*)&z, &nSectorB,
-xvect - (Sin(nAngle + 512) * (4 * sprite[i].clipdist)), -xvect - (bcos(nAngle) * (4 * sprite[i].clipdist)),
-yvect - (Sin(nAngle) * (4 * sprite[i].clipdist)), -yvect - (bsin(nAngle) * (4 * sprite[i].clipdist)),
4 * sprite[i].clipdist, 0, 0, CLIPMASK0); 4 * sprite[i].clipdist, 0, 0, CLIPMASK0);
@ -1055,8 +1055,8 @@ void MoveSector(short nSector, int nAngle, int *nXVel, int *nYVel)
else else
{ {
movesprite(i, movesprite(i,
(xvect << 14) + Sin(nAngle + 512) * sprite[i].clipdist, (xvect << 14) + bcos(nAngle) * sprite[i].clipdist,
(yvect << 14) + Sin(nAngle) * sprite[i].clipdist, (yvect << 14) + bsin(nAngle) * sprite[i].clipdist,
0, 0, 0, CLIPMASK0); 0, 0, 0, CLIPMASK0);
} }
} }
@ -1235,10 +1235,10 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
sprite[nSprite].ang = nAngle; sprite[nSprite].ang = nAngle;
int eax = klabs(Cos(sprite[nSprite].zvel)); int eax = klabs(bcos(sprite[nSprite].zvel));
int x = ((Cos(nAngle) * ebx) >> 14) * eax; int x = ((bcos(nAngle) * ebx) >> 14) * eax;
int y = ((Sin(nAngle) * ebx) >> 14) * eax; int y = ((bsin(nAngle) * ebx) >> 14) * eax;
int xshift = x >> 8; int xshift = x >> 8;
int yshift = y >> 8; int yshift = y >> 8;
@ -1251,9 +1251,9 @@ int AngleChase(int nSprite, int nSprite2, int ebx, int ecx, int push1)
sqrtNum = INT_MAX; sqrtNum = INT_MAX;
} }
int z = Sin(sprite[nSprite].zvel) * ksqrt(sqrtNum); int z = bsin(sprite[nSprite].zvel) * ksqrt(sqrtNum);
return movesprite(nSprite, x >> 2, y >> 2, (z >> 13) + (Sin(ecx) >> 5), 0, 0, nClipType); return movesprite(nSprite, x >> 2, y >> 2, (z >> 13) + bsin(ecx, -5), 0, 0, nClipType);
} }
int GetWallNormal(short nWall) int GetWallNormal(short nWall)
@ -1279,8 +1279,8 @@ void WheresMyMouth(int nPlayer, int *x, int *y, int *z, short *sectnum)
*sectnum = sprite[nSprite].sectnum; *sectnum = sprite[nSprite].sectnum;
clipmove_old((int32_t*)x, (int32_t*)y, (int32_t*)z, sectnum, clipmove_old((int32_t*)x, (int32_t*)y, (int32_t*)z, sectnum,
Cos(sprite[nSprite].ang) << 7, bcos(sprite[nSprite].ang, 7),
Sin(sprite[nSprite].ang) << 7, bsin(sprite[nSprite].ang, 7),
5120, 1280, 1280, CLIPMASK1); 5120, 1280, 1280, CLIPMASK1);
} }
@ -1512,8 +1512,8 @@ void FuncCreatureChunk(int a, int, int nRun)
int nSqrt = lsqrt(((sprite[nSprite].yvel >> 10) * (sprite[nSprite].yvel >> 10) int nSqrt = lsqrt(((sprite[nSprite].yvel >> 10) * (sprite[nSprite].yvel >> 10)
+ (sprite[nSprite].xvel >> 10) * (sprite[nSprite].xvel >> 10)) >> 8); + (sprite[nSprite].xvel >> 10) * (sprite[nSprite].xvel >> 10)) >> 8);
sprite[nSprite].xvel = Cos(nAngle) * (nSqrt >> 1); sprite[nSprite].xvel = bcos(nAngle) * (nSqrt >> 1);
sprite[nSprite].yvel = Sin(nAngle) * (nSqrt >> 1); sprite[nSprite].yvel = bsin(nAngle) * (nSqrt >> 1);
return; return;
} }
} }

View file

@ -239,7 +239,7 @@ void FuncMummy(int a, int nDamage, int nRun)
MummyList[nMummy].nAction = 1; MummyList[nMummy].nAction = 1;
MummyList[nMummy].G = 90; MummyList[nMummy].G = 90;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = sintable[sprite[nSprite].ang] >> 2; // NOTE no angle masking in original code sprite[nSprite].yvel = sintable[sprite[nSprite].ang] >> 2; // NOTE no angle masking in original code
} }
} }
@ -281,8 +281,8 @@ void FuncMummy(int a, int nDamage, int nRun)
// loc_2B5A8 // loc_2B5A8
if (!MummyList[nMummy].B) if (!MummyList[nMummy].B)
{ {
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
} }
if (sprite[nSprite].xvel || sprite[nSprite].yvel) if (sprite[nSprite].xvel || sprite[nSprite].yvel)
@ -325,8 +325,8 @@ void FuncMummy(int a, int nDamage, int nRun)
case 0x8000: case 0x8000:
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + ((RandomWord() & 0x3FF) + 1024)) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
return; return;
} }

View file

@ -1383,13 +1383,13 @@ int BuildSpark(int nSprite, int nVal)
if (nVal) if (nVal)
{ {
spr->xvel = Cos(nAngle) >> 5; spr->xvel = bcos(nAngle, -5);
spr->yvel = Sin(nAngle) >> 5; spr->yvel = bsin(nAngle, -5);
} }
else else
{ {
spr->xvel = Cos(nAngle) >> 6; spr->xvel = bcos(nAngle, -6);
spr->yvel = Sin(nAngle) >> 6; spr->yvel = bsin(nAngle, -6);
} }
spr->zvel = -(RandomSize(4) << 7); spr->zvel = -(RandomSize(4) << 7);
@ -2173,7 +2173,7 @@ void DoDrips()
{ {
sBob[i].field_2 += 4; sBob[i].field_2 += 4;
int edx = Sin(sBob[i].field_2 << 3) >> 4; int edx = bsin(sBob[i].field_2 << 3, -4);
short nSector = sBob[i].nSector; short nSector = sBob[i].nSector;
if (sBob[i].field_3) if (sBob[i].field_3)
@ -2426,8 +2426,8 @@ void DoMovingSects()
// loc_23872: // loc_23872:
int nAngle = GetMyAngle(sTrailPoint[nTrail].x - pBlockInfo->x, sTrailPoint[nTrail].y - pBlockInfo->y); int nAngle = GetMyAngle(sTrailPoint[nTrail].x - pBlockInfo->x, sTrailPoint[nTrail].y - pBlockInfo->y);
int nXVel = (Sin(nAngle + 512) << 4) * sMoveSect[i].field_10; int nXVel = bcos(nAngle, 4) * sMoveSect[i].field_10;
int nYVel = (Sin(nAngle) << 4) * sMoveSect[i].field_10; int nYVel = bsin(nAngle, 4) * sMoveSect[i].field_10;
int ebx = (sTrailPoint[nTrail].x - pBlockInfo->x) << 14; int ebx = (sTrailPoint[nTrail].x - pBlockInfo->x) << 14;

View file

@ -227,16 +227,8 @@ void SetHeadVel(short nSprite)
{ {
short nAngle = sprite[nSprite].ang; short nAngle = sprite[nSprite].ang;
if (nVelShift >= 0) sprite[nSprite].xvel = bcos(nAngle, nVelShift);
{ sprite[nSprite].yvel = bsin(nAngle, nVelShift);
sprite[nSprite].xvel = Cos(nAngle) >> (int8_t)(nVelShift);
sprite[nSprite].yvel = Sin(nAngle) >> (int8_t)(nVelShift);
}
else
{
sprite[nSprite].xvel = Cos(nAngle) << (int8_t)(-nVelShift);
sprite[nSprite].yvel = Sin(nAngle) << (int8_t)(-nVelShift);
}
} }
int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2) int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2)
@ -298,10 +290,10 @@ int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2)
pSprite->ang = nAngle; pSprite->ang = nAngle;
int da = pSprite->zvel; int da = pSprite->zvel;
int x = klabs(Cos(da)); int x = klabs(bcos(da));
int v26 = x * ((val1 * Cos(nAngle)) >> 14); int v26 = x * ((val1 * bcos(nAngle)) >> 14);
int v27 = x * ((val1 * Sin(nAngle)) >> 14); int v27 = x * ((val1 * bsin(nAngle)) >> 14);
uint32_t xDiff = klabs((int32_t)(v26 >> 8)); uint32_t xDiff = klabs((int32_t)(v26 >> 8));
uint32_t yDiff = klabs((int32_t)(v27 >> 8)); uint32_t yDiff = klabs((int32_t)(v27 >> 8));
@ -314,9 +306,9 @@ int QueenAngleChase(short nSprite, short nSprite2, int val1, int val2)
sqrtNum = INT_MAX; sqrtNum = INT_MAX;
} }
int nSqrt = ksqrt(sqrtNum) * Sin(da); int nSqrt = ksqrt(sqrtNum) * bsin(da);
return movesprite(nSprite, v26 >> 2, v27 >> 2, (Sin(bobangle) >> 5) + (nSqrt >> 13), 0, 0, CLIPMASK1); return movesprite(nSprite, v26 >> 2, v27 >> 2, bsin(bobangle, -5) + (nSqrt >> 13), 0, 0, CLIPMASK1);
} }
int DestroyTailPart() int DestroyTailPart()
@ -424,8 +416,8 @@ int BuildQueenEgg(short nQueen, int nVal)
{ {
sprite[nSprite2].xrepeat = 30; sprite[nSprite2].xrepeat = 30;
sprite[nSprite2].yrepeat = 30; sprite[nSprite2].yrepeat = 30;
sprite[nSprite2].xvel = Cos(sprite[nSprite2].ang); sprite[nSprite2].xvel = bcos(sprite[nSprite2].ang);
sprite[nSprite2].yvel = Sin(sprite[nSprite2].ang); sprite[nSprite2].yvel = bsin(sprite[nSprite2].ang);
sprite[nSprite2].zvel = -6000; sprite[nSprite2].zvel = -6000;
sprite[nSprite2].cstat = 0; sprite[nSprite2].cstat = 0;
} }
@ -567,8 +559,8 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
} }
sprite[nSprite].ang = nAngle; sprite[nSprite].ang = nAngle;
sprite[nSprite].xvel = Cos(nAngle) >> 1; sprite[nSprite].xvel = bcos(nAngle, -1);
sprite[nSprite].yvel = Sin(nAngle) >> 1; sprite[nSprite].yvel = bsin(nAngle, -1);
} }
break; break;
@ -600,8 +592,8 @@ void FuncQueenEgg(int a, int nDamage, int nRun)
case 0x8000: case 0x8000:
sprite[nSprite].ang += (RandomSize(9) + 768); sprite[nSprite].ang += (RandomSize(9) + 768);
sprite[nSprite].ang &= kAngleMask; sprite[nSprite].ang &= kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 3; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -3);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 3; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -3);
sprite[nSprite].zvel = -RandomSize(5); sprite[nSprite].zvel = -RandomSize(5);
break; break;
} }
@ -975,8 +967,8 @@ __MOVEQS:
// DEMO-TODO: in disassembly angle was used without masking and thus causing OOB issue. // DEMO-TODO: in disassembly angle was used without masking and thus causing OOB issue.
// This behavior probably would be needed emulated for demo compatibility // This behavior probably would be needed emulated for demo compatibility
// int dx = sintable[nAngle + 512] << 10; // int dx = sintable[nAngle + 512] << 10;
int dx = Cos(nAngle) << 10; int dx = bcos(nAngle, 10);
int dy = Sin(nAngle) << 10; int dy = bsin(nAngle, 10);
int dz = (RandomSize(5) - RandomSize(5)) << 7; int dz = (RandomSize(5) - RandomSize(5)) << 7;
movesprite(nSprite, dx, dy, dz, 0, 0, CLIPMASK1); movesprite(nSprite, dx, dy, dz, 0, 0, CLIPMASK1);
@ -1167,8 +1159,8 @@ int BuildQueen(int nSprite, int x, int y, int z, int nSector, int nAngle, int nC
void SetQueenSpeed(short nSprite, int nSpeed) void SetQueenSpeed(short nSprite, int nSpeed)
{ {
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> (2 - nSpeed); sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -(2 - nSpeed));
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> (2 - nSpeed); sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -(2 - nSpeed));
} }
void FuncQueen(int a, int nDamage, int nRun) void FuncQueen(int a, int nDamage, int nRun)

View file

@ -84,8 +84,8 @@ void InitRats()
void SetRatVel(short nSprite) void SetRatVel(short nSprite)
{ {
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
} }
int BuildRat(short nSprite, int x, int y, int z, short nSector, int nAngle) int BuildRat(short nSprite, int x, int y, int z, short nSector, int nAngle)

View file

@ -266,8 +266,8 @@ void FuncRex(int a, int nDamage, int nRun)
RexList[nRex].nAction = 1; RexList[nRex].nAction = 1;
RexList[nRex].nFrame = 0; RexList[nRex].nFrame = 0;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
D3PlayFX(StaticSound[kSound48], nSprite); D3PlayFX(StaticSound[kSound48], nSprite);
@ -300,8 +300,8 @@ void FuncRex(int a, int nDamage, int nRun)
if (((PlotCourseToSprite(nSprite, nTarget) >> 8) >= 60) || RexList[nRex].field_A > 0) if (((PlotCourseToSprite(nSprite, nTarget) >> 8) >= 60) || RexList[nRex].field_A > 0)
{ {
int nAngle = sprite[nSprite].ang & 0xFFF8; int nAngle = sprite[nSprite].ang & 0xFFF8;
sprite[nSprite].xvel = Cos(nAngle) >> 2; sprite[nSprite].xvel = bcos(nAngle, -2);
sprite[nSprite].yvel = Sin(nAngle) >> 2; sprite[nSprite].yvel = bsin(nAngle, -2);
} }
else else
{ {
@ -332,8 +332,8 @@ void FuncRex(int a, int nDamage, int nRun)
case 0x8000: case 0x8000:
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
RexList[nRex].nAction = 1; RexList[nRex].nAction = 1;
RexList[nRex].nFrame = 0; RexList[nRex].nFrame = 0;
nAction = 1; nAction = 1;
@ -351,8 +351,8 @@ void FuncRex(int a, int nDamage, int nRun)
{ {
PlotCourseToSprite(nSprite, nTarget); PlotCourseToSprite(nSprite, nTarget);
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
int nMov = MoveCreatureWithCaution(nSprite); int nMov = MoveCreatureWithCaution(nSprite);
@ -364,8 +364,8 @@ void FuncRex(int a, int nDamage, int nRun)
RexList[nRex].field_A = 60; RexList[nRex].field_A = 60;
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 2; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -2);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 2; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -2);
RexList[nRex].nAction = 1; RexList[nRex].nAction = 1;
RexList[nRex].nFrame = 0; RexList[nRex].nFrame = 0;
nAction = 1; nAction = 1;
@ -384,8 +384,8 @@ void FuncRex(int a, int nDamage, int nRun)
runlist_DamageEnemy(nSprite2, nSprite, 15); runlist_DamageEnemy(nSprite2, nSprite, 15);
int xVel = Cos(nAngle) * 15; int xVel = bcos(nAngle) * 15;
int yVel = Sin(nAngle) * 15; int yVel = bsin(nAngle) * 15;
if (sprite[nSprite2].statnum == 100) if (sprite[nSprite2].statnum == 100)
{ {

View file

@ -135,8 +135,8 @@ int BuildRoach(int nType, int nSprite, int x, int y, int z, short nSector, int a
void GoRoach(short nSprite) void GoRoach(short nSprite)
{ {
sprite[nSprite].xvel = (Cos(sprite[nSprite].ang) >> 1) - (Cos(sprite[nSprite].ang) >> 3); sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1) - bcos(sprite[nSprite].ang, -3);
sprite[nSprite].yvel = (Sin(sprite[nSprite].ang) >> 1) - (Sin(sprite[nSprite].ang) >> 3); sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1) - bsin(sprite[nSprite].ang, -3);
} }
void FuncRoach(int a, int nDamage, int nRun) void FuncRoach(int a, int nDamage, int nRun)

View file

@ -1582,8 +1582,8 @@ int runlist_CheckRadialDamage(short nSprite)
{ {
int nAngle = GetMyAngle(x, y); int nAngle = GetMyAngle(x, y);
sprite[nSprite].xvel += (edi * Cos(nAngle)) >> 3; sprite[nSprite].xvel += (edi * bcos(nAngle)) >> 3;
sprite[nSprite].yvel += (edi * Sin(nAngle)) >> 3; sprite[nSprite].yvel += (edi * bsin(nAngle)) >> 3;
sprite[nSprite].zvel -= edi * 24; sprite[nSprite].zvel -= edi * 24;
if (sprite[nSprite].zvel < -3584) { if (sprite[nSprite].zvel < -3584) {

View file

@ -274,8 +274,8 @@ void FuncScorp(int a, int nDamage, int nRun)
D3PlayFX(StaticSound[kSound41], nSprite); D3PlayFX(StaticSound[kSound41], nSprite);
scorpion[nScorp].nFrame = 0; scorpion[nScorp].nFrame = 0;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang); sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
scorpion[nScorp].nAction = 1; scorpion[nScorp].nAction = 1;
scorpion[nScorp].nTarget = nTarget; scorpion[nScorp].nTarget = nTarget;
@ -359,8 +359,8 @@ void FuncScorp(int a, int nDamage, int nRun)
{ {
scorpion[nScorp].nAction = 1; scorpion[nScorp].nAction = 1;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang); sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
scorpion[nScorp].nFrame = 0; scorpion[nScorp].nFrame = 0;
return; return;
@ -430,8 +430,8 @@ void FuncScorp(int a, int nDamage, int nRun)
int nVel = RandomSize(5) + 1; int nVel = RandomSize(5) + 1;
sprite[nSpiderSprite].xvel = (Cos(sprite[nSpiderSprite].ang) >> 8) * nVel; sprite[nSpiderSprite].xvel = bcos(sprite[nSpiderSprite].ang, -8) * nVel;
sprite[nSpiderSprite].yvel = (Sin(sprite[nSpiderSprite].ang) >> 8) * nVel; sprite[nSpiderSprite].yvel = bsin(sprite[nSpiderSprite].ang, -8) * nVel;
sprite[nSpiderSprite].zvel = (-(RandomSize(5) + 3)) << 8; sprite[nSpiderSprite].zvel = (-(RandomSize(5) + 3)) << 8;
} }
@ -464,8 +464,8 @@ FS_Pink_A:
sprite[nSprite].ang += RandomSize(7) - 63; sprite[nSprite].ang += RandomSize(7) - 63;
sprite[nSprite].ang &= kAngleMask; sprite[nSprite].ang &= kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang); sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
FS_Pink_B: FS_Pink_B:
if (scorpion[nScorp].g) if (scorpion[nScorp].g)

View file

@ -196,9 +196,9 @@ void FuncSoul(int a, int, int nRun)
sprite[nSprite].extra += (nSprite & 0x0F) + 5; sprite[nSprite].extra += (nSprite & 0x0F) + 5;
sprite[nSprite].extra &= kAngleMask; sprite[nSprite].extra &= kAngleMask;
int nVel = (Cos(sprite[nSprite].extra) >> 7); int nVel = bcos(sprite[nSprite].extra, -7);
if (movesprite(nSprite, Cos(sprite[nSprite].ang) * nVel, Sin(sprite[nSprite].ang) * nVel, sprite[nSprite].zvel, 5120, 0, CLIPMASK0) & 0x10000) if (movesprite(nSprite, bcos(sprite[nSprite].ang) * nVel, bsin(sprite[nSprite].ang) * nVel, sprite[nSprite].zvel, 5120, 0, CLIPMASK0) & 0x10000)
{ {
int nSet = sprite[nSprite].hitag; int nSet = sprite[nSprite].hitag;
int nSetSprite = SetList[nSet].nSprite; int nSetSprite = SetList[nSet].nSprite;
@ -363,8 +363,8 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
SetList[nSet].nTarget = nTarget; SetList[nSet].nTarget = nTarget;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
} }
} }
@ -457,8 +457,8 @@ void FuncSet(int a, int nDamage, int nRun)
// loc_338E2 // loc_338E2
int nAngle = sprite[nSprite].ang & 0xFFF8; int nAngle = sprite[nSprite].ang & 0xFFF8;
sprite[nSprite].xvel = Cos(nAngle) >> 1; sprite[nSprite].xvel = bcos(nAngle, -1);
sprite[nSprite].yvel = Sin(nAngle) >> 1; sprite[nSprite].yvel = bsin(nAngle, -1);
if (SetList[nSet].field_D) if (SetList[nSet].field_D)
{ {
@ -488,8 +488,8 @@ void FuncSet(int a, int nDamage, int nRun)
} }
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask; sprite[nSprite].ang = (sprite[nSprite].ang + 256) & kAngleMask;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> 1; sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -1);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> 1; sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -1);
break; break;
} }
else if ((nMov & 0xC000) == 0xC000) else if ((nMov & 0xC000) == 0xC000)
@ -591,8 +591,8 @@ void FuncSet(int a, int nDamage, int nRun)
SetList[nSet].nAction = 8; SetList[nSet].nAction = 8;
SetList[nSet].nFrame = 0; SetList[nSet].nFrame = 0;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang); sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
} }
return; return;
} }

View file

@ -137,7 +137,7 @@ int BuildSnake(short nPlayer, short zVal)
vec3_t pos = { x, y, z }; vec3_t pos = { x, y, z };
hitdata_t hitData; hitdata_t hitData;
hitscan(&pos, sprite[nPlayerSprite].sectnum, Cos(nAngle), Sin(nAngle), 0, &hitData, CLIPMASK1); hitscan(&pos, sprite[nPlayerSprite].sectnum, bcos(nAngle), bsin(nAngle), 0, &hitData, CLIPMASK1);
hitx = hitData.pos.x; hitx = hitData.pos.x;
hity = hitData.pos.y; hity = hitData.pos.y;
@ -333,9 +333,9 @@ void FuncSnake(int a, int, int nRun)
{ {
SEARCH_ENEMY: SEARCH_ENEMY:
nMov = movesprite(nSprite, nMov = movesprite(nSprite,
600 * Cos(sprite[nSprite].ang), 600 * bcos(sprite[nSprite].ang),
600 * Sin(sprite[nSprite].ang), 600 * bsin(sprite[nSprite].ang),
Sin(SnakeList[nSnake].sE) >> 5, bsin(SnakeList[nSnake].sE, -5),
0, 0, CLIPMASK1); 0, 0, CLIPMASK1);
FindSnakeEnemy(nSnake); FindSnakeEnemy(nSnake);
@ -370,8 +370,8 @@ SEARCH_ENEMY:
else else
{ {
short nAngle = sprite[nSprite].ang; short nAngle = sprite[nSprite].ang;
int var_30 = -(64 * Cos(nAngle)); int var_30 = -bcos(nAngle, 6);
int var_34 = -(64 * Sin(nAngle)); int var_34 = -bsin(nAngle, 6);
int var_20 = SnakeList[nSnake].sE; int var_20 = SnakeList[nSnake].sE;
@ -395,9 +395,9 @@ SEARCH_ENEMY:
mychangespritesect(nSprite2, nSector); mychangespritesect(nSprite2, nSector);
int eax = (Sin(var_20) * SnakeList[nSnake].c[i]) >> 9; int eax = (bsin(var_20) * SnakeList[nSnake].c[i]) >> 9;
movesprite(nSprite2, var_30 + var_30 * i + eax * Cos(var_28), var_30 + var_34 * i + eax * Sin(var_28), movesprite(nSprite2, var_30 + var_30 * i + eax * bcos(var_28), var_30 + var_34 * i + eax * bsin(var_28),
-zVal*(i-1), 0, 0, CLIPMASK1); -zVal*(i-1), 0, 0, CLIPMASK1);
var_20 = (var_20 + 128) & kAngleMask; var_20 = (var_20 + 128) & kAngleMask;

View file

@ -192,7 +192,7 @@ void FuncSpider(int a, int nDamage, int nRun)
SpiderList[nSpider].nFrame = 0; SpiderList[nSpider].nFrame = 0;
SpiderList[nSpider].nTarget = nTarget; SpiderList[nSpider].nTarget = nTarget;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = sintable[sprite[nSprite].ang]; // NOTE - not angle masking here in original code sprite[nSprite].yvel = sintable[sprite[nSprite].ang]; // NOTE - not angle masking here in original code
return; return;
} }
@ -243,8 +243,8 @@ void FuncSpider(int a, int nDamage, int nRun)
if (RandomSize(3)) if (RandomSize(3))
{ {
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang); sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
} }
else else
{ {
@ -350,8 +350,8 @@ void FuncSpider(int a, int nDamage, int nRun)
case 0x8000: case 0x8000:
{ {
sprite[nSprite].ang = (sprite[nSprite].ang + 256) & 0x7EF; sprite[nSprite].ang = (sprite[nSprite].ang + 256) & 0x7EF;
sprite[nSprite].xvel = Cos(sprite[nSprite].ang); sprite[nSprite].xvel = bcos(sprite[nSprite].ang);
sprite[nSprite].yvel = Sin(sprite[nSprite].ang); sprite[nSprite].yvel = bsin(sprite[nSprite].ang);
return; return;
} }
case 0xC000: case 0xC000:

View file

@ -170,8 +170,8 @@ static void analyzesprites()
int xval = pSprite->x - x; int xval = pSprite->x - x;
int yval = pSprite->y - y; int yval = pSprite->y - y;
int vcos = Cos(nAngle); int vcos = bcos(nAngle);
int vsin = Sin(nAngle); int vsin = bsin(nAngle);
int edx = ((vcos * yval) + (xval * vsin)) >> 14; int edx = ((vcos * yval) + (xval * vsin)) >> 14;
@ -242,7 +242,7 @@ void DrawView(double smoothRatio, bool sceneonly)
fixed_t dang = IntToFixed(1024); fixed_t dang = IntToFixed(1024);
zbob = Sin(2 * bobangle) >> 3; zbob = bsin(2 * bobangle, -3);
int nPlayerSprite = PlayerList[nLocalPlayer].nSprite; int nPlayerSprite = PlayerList[nLocalPlayer].nSprite;
int nPlayerOldCstat = sprite[nPlayerSprite].cstat; int nPlayerOldCstat = sprite[nPlayerSprite].cstat;
@ -333,8 +333,8 @@ void DrawView(double smoothRatio, bool sceneonly)
else else
{ {
clipmove_old((int32_t*)&playerX, (int32_t*)&playerY, (int32_t*)&playerZ, &nSector, clipmove_old((int32_t*)&playerX, (int32_t*)&playerY, (int32_t*)&playerZ, &nSector,
-2000 * Sin(inita + 512), -2000 * bcos(inita),
-2000 * Sin(inita), -2000 * bsin(inita),
4, 0, 0, CLIPMASK1); 4, 0, 0, CLIPMASK1);
pan = q16horiz(0); pan = q16horiz(0);

View file

@ -71,16 +71,8 @@ void InitWasps()
void SetWaspVel(short nSprite) void SetWaspVel(short nSprite)
{ {
if (nWaspVelShift < 0) sprite[nSprite].xvel = bcos(sprite[nSprite].ang, -nWaspVelShift);
{ sprite[nSprite].yvel = bsin(sprite[nSprite].ang, -nWaspVelShift);
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) << -nWaspVelShift;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) << -nWaspVelShift;
}
else
{
sprite[nSprite].xvel = Cos(sprite[nSprite].ang) >> nWaspVelShift;
sprite[nSprite].yvel = Sin(sprite[nSprite].ang) >> nWaspVelShift;
}
} }
int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle) int BuildWasp(short nSprite, int x, int y, int z, short nSector, short nAngle)
@ -284,7 +276,7 @@ void FuncWasp(int a, int nDamage, int nRun)
case 0: case 0:
{ {
sprite[nSprite].zvel = Sin(WaspList[nWasp].field_E) >> 4; sprite[nSprite].zvel = bsin(WaspList[nWasp].field_E, -4);
WaspList[nWasp].field_E += WaspList[nWasp].field_10; WaspList[nWasp].field_E += WaspList[nWasp].field_10;
WaspList[nWasp].field_E &= kAngleMask; WaspList[nWasp].field_E &= kAngleMask;