- Replace divscale##() calls with MulScale() from common.

* Regex for reference: divscale([0-9]+)\((.+)(\)+)
This commit is contained in:
Mitchell Richters 2021-01-04 22:51:41 +11:00
parent f20daa2595
commit aae175f287
21 changed files with 50 additions and 67 deletions

View file

@ -2627,8 +2627,8 @@ int actFloorBounceVector(int *x, int *y, int *z, int nSector, int a5)
int angle = getangle(pWall2->x-pWall->x, pWall2->y-pWall->y)+512; int angle = getangle(pWall2->x-pWall->x, pWall2->y-pWall->y)+512;
int t2 = sector[nSector].floorheinum<<4; int t2 = sector[nSector].floorheinum<<4;
int t3 = approxDist(-0x10000, t2); int t3 = approxDist(-0x10000, t2);
int t4 = divscale16(-0x10000, t3); int t4 = DivScale(-0x10000, t3, 16);
int t5 = divscale16(t2, t3); int t5 = DivScale(t2, t3, 16);
int t6 = MulScale(t5, Cos(angle), 30); int t6 = MulScale(t5, Cos(angle), 30);
int t7 = MulScale(t5, Sin(angle), 30); int t7 = MulScale(t5, Sin(angle), 30);
int t8 = TMulScale(*x, t6, *y, t7, *z, t4, 16); int t8 = TMulScale(*x, t6, *y, t7, *z, t4, 16);
@ -4488,7 +4488,7 @@ int MoveThing(spritetype *pSprite)
} }
if (nVel > 0) if (nVel > 0)
{ {
int t = divscale16(nVelClipped, nVel); int t = DivScale(nVelClipped, nVel, 16);
xvel[nSprite] -= MulScale(t, xvel[nSprite], 16); xvel[nSprite] -= MulScale(t, xvel[nSprite], 16);
yvel[nSprite] -= MulScale(t, yvel[nSprite], 16); yvel[nSprite] -= MulScale(t, yvel[nSprite], 16);
} }
@ -5743,7 +5743,7 @@ void actProcessSprites(void)
int dy = (y - pSprite2->y)>>4; int dy = (y - pSprite2->y)>>4;
int dz = (z - pSprite2->z)>>8; int dz = (z - pSprite2->z)>>8;
int nDist = dx*dx+dy*dy+dz*dz+0x40000; int nDist = dx*dx+dy*dy+dz*dz+0x40000;
int t = divscale16(pXSprite->data2, nDist); int t = DivScale(pXSprite->data2, nDist, 16);
gPlayer[p].flickerEffect += t; gPlayer[p].flickerEffect += t;
} }

View file

@ -332,8 +332,8 @@ void GetWallNormal(int nWall, int *pX, int *pY)
int nLength = ksqrt(dX*dX+dY*dY); int nLength = ksqrt(dX*dX+dY*dY);
if (nLength <= 0) if (nLength <= 0)
nLength = 1; nLength = 1;
*pX = divscale16(dX, nLength); *pX = DivScale(dX, nLength, 16);
*pY = divscale16(dY, nLength); *pY = DivScale(dY, nLength, 16);
} }
bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int x2, int y2, int z2, int *ix, int *iy, int *iz) bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int x2, int y2, int z2, int *ix, int *iy, int *iz)
@ -362,7 +362,7 @@ bool IntersectRay(int wx, int wy, int wdx, int wdy, int x1, int y1, int z1, int
if (check2 > 0 || check2 <= side) if (check2 > 0 || check2 <= side)
return 0; return 0;
} }
int nScale = divscale16(check2, side); int nScale = DivScale(check2, side, 16);
*ix = x1 + MulScale(dX, nScale, 16); *ix = x1 + MulScale(dX, nScale, 16);
*iy = y1 + MulScale(dY, nScale, 16); *iy = y1 + MulScale(dY, nScale, 16);
*iz = z1 + MulScale(dZ, nScale, 16); *iz = z1 + MulScale(dZ, nScale, 16);

View file

@ -1220,7 +1220,7 @@ void debrisMove(int listIndex) {
} }
if (nVel > 0) if (nVel > 0)
{ {
int t = divscale16(nVelClipped, nVel); int t = DivScale(nVelClipped, nVel, 16);
xvel[nSprite] -= MulScale(t, xvel[nSprite], 16); xvel[nSprite] -= MulScale(t, xvel[nSprite], 16);
yvel[nSprite] -= MulScale(t, yvel[nSprite], 16); yvel[nSprite] -= MulScale(t, yvel[nSprite], 16);
} }

View file

@ -1399,7 +1399,7 @@ void ProcessInput(PLAYER *pPlayer)
{ {
int speed = 0x10000; int speed = 0x10000;
if (pXSprite->height > 0) if (pXSprite->height > 0)
speed -= divscale16(pXSprite->height, 256); speed -= DivScale(pXSprite->height, 256, 16);
int x = Cos(pSprite->ang); int x = Cos(pSprite->ang);
int y = Sin(pSprite->ang); int y = Sin(pSprite->ang);
if (pInput->fvel) if (pInput->fvel)

View file

@ -139,7 +139,7 @@ static void fakeProcessInput(PLAYER *pPlayer, InputPacket *pInput)
{ {
int speed = 0x10000; int speed = 0x10000;
if (predict.at6a > 0) if (predict.at6a > 0)
speed -= divscale16(predict.at6a, 0x100); speed -= DivScale(predict.at6a, 0x100, 16);
int x = Cos(predict.at30.asbuild()); int x = Cos(predict.at30.asbuild());
int y = Sin(predict.at30.asbuild()); int y = Sin(predict.at30.asbuild());
if (pInput->fvel) if (pInput->fvel)

View file

@ -506,7 +506,7 @@ void OperateSprite(int nSprite, XSPRITE *pXSprite, EVENT event)
int dy = (pSprite->y - pPlayerSprite->y)>>4; int dy = (pSprite->y - pPlayerSprite->y)>>4;
int dz = (pSprite->z - pPlayerSprite->z)>>8; int dz = (pSprite->z - pPlayerSprite->z)>>8;
int nDist = dx*dx+dy*dy+dz*dz+0x40000; int nDist = dx*dx+dy*dy+dz*dz+0x40000;
gPlayer[p].quakeEffect = divscale16(pXSprite->data1, nDist); gPlayer[p].quakeEffect = DivScale(pXSprite->data1, nDist, 16);
} }
break; break;
case kThingTNTBarrel: case kThingTNTBarrel:

View file

@ -227,11 +227,11 @@ void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsec
int nDist; int nDist;
if (klabs(vX) > klabs(vY)) if (klabs(vX) > klabs(vY))
{ {
nDist = ClipHigh(divscale16(dX,vX), othercameradist); nDist = ClipHigh(DivScale(dX,vX, 16), othercameradist);
} }
else else
{ {
nDist = ClipHigh(divscale16(dY,vY), othercameradist); nDist = ClipHigh(DivScale(dY,vY, 16), othercameradist);
} }
othercameradist = nDist; othercameradist = nDist;
} }
@ -274,11 +274,11 @@ void CalcPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum,
int nDist; int nDist;
if (klabs(vX) > klabs(vY)) if (klabs(vX) > klabs(vY))
{ {
nDist = ClipHigh(divscale16(dX,vX), cameradist); nDist = ClipHigh(DivScale(dX,vX, 16), cameradist);
} }
else else
{ {
nDist = ClipHigh(divscale16(dY,vY), cameradist); nDist = ClipHigh(DivScale(dY,vY, 16), cameradist);
} }
cameradist = nDist; cameradist = nDist;
} }

View file

@ -1818,7 +1818,7 @@ int processSprayCan(PLAYER *pPlayer)
return 1; return 1;
case 7: case 7:
{ {
pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536); pPlayer->throwPower = ClipHigh(DivScale(gFrameClock-pPlayer->throwTime,240, 16), 65536);
if (!(pPlayer->input.actions & SB_FIRE)) if (!(pPlayer->input.actions & SB_FIRE))
{ {
if (!pPlayer->fuseTime) if (!pPlayer->fuseTime)
@ -1856,7 +1856,7 @@ char processTNT(PLAYER *pPlayer)
return 1; return 1;
case 6: case 6:
{ {
pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536); pPlayer->throwPower = ClipHigh(DivScale(gFrameClock-pPlayer->throwTime,240, 16), 65536);
if (!(pPlayer->input.actions & SB_FIRE)) if (!(pPlayer->input.actions & SB_FIRE))
{ {
if (!pPlayer->fuseTime) if (!pPlayer->fuseTime)
@ -1875,7 +1875,7 @@ char processProxy(PLAYER *pPlayer)
switch (pPlayer->weaponState) switch (pPlayer->weaponState)
{ {
case 9: case 9:
pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536); pPlayer->throwPower = ClipHigh(DivScale(gFrameClock-pPlayer->throwTime,240, 16), 65536);
pPlayer->weaponTimer = 0; pPlayer->weaponTimer = 0;
if (!(pPlayer->input.actions & SB_FIRE)) if (!(pPlayer->input.actions & SB_FIRE))
{ {
@ -1892,7 +1892,7 @@ char processRemote(PLAYER *pPlayer)
switch (pPlayer->weaponState) switch (pPlayer->weaponState)
{ {
case 13: case 13:
pPlayer->throwPower = ClipHigh(divscale16(gFrameClock-pPlayer->throwTime,240), 65536); pPlayer->throwPower = ClipHigh(DivScale(gFrameClock-pPlayer->throwTime,240, 16), 65536);
if (!(pPlayer->input.actions & SB_FIRE)) if (!(pPlayer->input.actions & SB_FIRE))
{ {
pPlayer->weaponState = 11; pPlayer->weaponState = 11;

View file

@ -10,17 +10,6 @@
#ifndef pragmas_h_ #ifndef pragmas_h_
#define pragmas_h_ #define pragmas_h_
#define EDUKE32_GENERATE_PRAGMAS \
EDUKE32_SCALER_PRAGMA(1) EDUKE32_SCALER_PRAGMA(2) EDUKE32_SCALER_PRAGMA(3) EDUKE32_SCALER_PRAGMA(4) \
EDUKE32_SCALER_PRAGMA(5) EDUKE32_SCALER_PRAGMA(6) EDUKE32_SCALER_PRAGMA(7) EDUKE32_SCALER_PRAGMA(8) \
EDUKE32_SCALER_PRAGMA(9) EDUKE32_SCALER_PRAGMA(10) EDUKE32_SCALER_PRAGMA(11) EDUKE32_SCALER_PRAGMA(12) \
EDUKE32_SCALER_PRAGMA(13) EDUKE32_SCALER_PRAGMA(14) EDUKE32_SCALER_PRAGMA(15) EDUKE32_SCALER_PRAGMA(16) \
EDUKE32_SCALER_PRAGMA(17) EDUKE32_SCALER_PRAGMA(18) EDUKE32_SCALER_PRAGMA(19) EDUKE32_SCALER_PRAGMA(20) \
EDUKE32_SCALER_PRAGMA(21) EDUKE32_SCALER_PRAGMA(22) EDUKE32_SCALER_PRAGMA(23) EDUKE32_SCALER_PRAGMA(24) \
EDUKE32_SCALER_PRAGMA(25) EDUKE32_SCALER_PRAGMA(26) EDUKE32_SCALER_PRAGMA(27) EDUKE32_SCALER_PRAGMA(28) \
EDUKE32_SCALER_PRAGMA(29) EDUKE32_SCALER_PRAGMA(30) EDUKE32_SCALER_PRAGMA(31) EDUKE32_SCALER_PRAGMA(32)
extern int32_t reciptable[2048]; extern int32_t reciptable[2048];
// break the C version of divscale out from the others // break the C version of divscale out from the others
@ -36,12 +25,6 @@ extern int32_t reciptable[2048];
static inline int32_t divscale(int32_t eax, int32_t ebx, int32_t ecx) { return (int64_t(eax) << ecx) / ebx; } 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 double fdivscale(double eax, double ebx, int32_t ecx) { return (eax * (double)(qw(1) << ecx)) / ebx; }
#define EDUKE32_SCALER_PRAGMA(a) \
static FORCE_INLINE int32_t divscale##a(int32_t eax, int32_t ebx) { return divscale(eax, ebx, a); } \
static FORCE_INLINE double fdivscale##a(double eax, double ebx) { return fdivscale(eax, ebx, a); }
EDUKE32_GENERATE_PRAGMAS
#undef EDUKE32_SCALER_PRAGMA
static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx) static inline int32_t scale(int32_t eax, int32_t edx, int32_t ecx)
{ {
return int64_t(eax) * edx / ecx; return int64_t(eax) * edx / ecx;

View file

@ -184,7 +184,7 @@ int32_t getceilzofslope_old(int32_t sectnum, int32_t dax, int32_t day)
dx = wall[wall[j].point2].x-wall[j].x; dx = wall[wall[j].point2].x-wall[j].x;
dy = wall[wall[j].point2].y-wall[j].y; dy = wall[wall[j].point2].y-wall[j].y;
i = (ksqrtasm_old(dx*dx+dy*dy)); if (i == 0) return(sector[sectnum].ceilingz); i = (ksqrtasm_old(dx*dx+dy*dy)); if (i == 0) return(sector[sectnum].ceilingz);
i = divscale15(sector[sectnum].ceilingheinum,i); i = DivScale(sector[sectnum].ceilingheinum,i, 15);
dx *= i; dy *= i; dx *= i; dy *= i;
return sector[sectnum].ceilingz+DMulScale(dx,day-wall[j].y,-dy,dax-wall[j].x, 23); return sector[sectnum].ceilingz+DMulScale(dx,day-wall[j].y,-dy,dax-wall[j].x, 23);
} }
@ -198,7 +198,7 @@ int32_t getflorzofslope_old(int32_t sectnum, int32_t dax, int32_t day)
dx = wall[wall[j].point2].x-wall[j].x; dx = wall[wall[j].point2].x-wall[j].x;
dy = wall[wall[j].point2].y-wall[j].y; dy = wall[wall[j].point2].y-wall[j].y;
i = (ksqrtasm_old(dx*dx+dy*dy)); if (i == 0) return sector[sectnum].floorz; i = (ksqrtasm_old(dx*dx+dy*dy)); if (i == 0) return sector[sectnum].floorz;
i = divscale15(sector[sectnum].floorheinum,i); i = DivScale(sector[sectnum].floorheinum,i, 15);
dx *= i; dy *= i; dx *= i; dy *= i;
return sector[sectnum].floorz+DMulScale(dx,day-wall[j].y,-dy,dax-wall[j].x, 23); return sector[sectnum].floorz+DMulScale(dx,day-wall[j].y,-dy,dax-wall[j].x, 23);
} }
@ -920,7 +920,7 @@ int pushmove(vec3_t *const vect, int16_t *const sectnum,
else else
{ {
daz2 = dax*dax+day*day; daz2 = dax*dax+day*day;
if (daz >= daz2) t = (1<<30); else t = divscale30(daz, daz2); if (daz >= daz2) t = (1<<30); else t = DivScale(daz, daz2, 30);
} }
dax = wal->x + MulScale(dax, t, 30); dax = wal->x + MulScale(dax, t, 30);
day = wal->y + MulScale(day, t, 30); day = wal->y + MulScale(day, t, 30);
@ -1241,7 +1241,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
int32_t j, dax=wal2->x-wal->x, day=wal2->y-wal->y; int32_t j, dax=wal2->x-wal->x, day=wal2->y-wal->y;
i = nsqrtasm(compat_maybe_truncate_to_int32(uhypsq(dax,day))); if (i == 0) return 1; //continue; i = nsqrtasm(compat_maybe_truncate_to_int32(uhypsq(dax,day))); if (i == 0) return 1; //continue;
i = divscale15(heinum,i); i = DivScale(heinum,i, 15);
dax *= i; day *= i; dax *= i; day *= i;
j = (vz<<8)-DMulScale(dax,vy,-day,vx, 15); j = (vz<<8)-DMulScale(dax,vy,-day,vx, 15);
@ -1250,7 +1250,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
i = ((z - sv->z)<<8)+DMulScale(dax,sv->y-wal->y,-day,sv->x-wal->x, 15); i = ((z - sv->z)<<8)+DMulScale(dax,sv->y-wal->y,-day,sv->x-wal->x, 15);
if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j))) if (((i^j) >= 0) && ((klabs(i)>>1) < klabs(j)))
{ {
i = divscale30(i,j); i = DivScale(i,j, 30);
x1 = sv->x + MulScale(vx,i, 30); x1 = sv->x + MulScale(vx,i, 30);
y1 = sv->y + MulScale(vy,i, 30); y1 = sv->y + MulScale(vy,i, 30);
z1 = sv->z + MulScale(vz,i, 30); z1 = sv->z + MulScale(vz,i, 30);
@ -1262,7 +1262,7 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *
z1 = z; i = z1-sv->z; z1 = z; i = z1-sv->z;
if ((klabs(i)>>1) < vz*how) if ((klabs(i)>>1) < vz*how)
{ {
i = divscale30(i,vz); i = DivScale(i,vz, 30);
x1 = sv->x + MulScale(vx,i, 30); x1 = sv->x + MulScale(vx,i, 30);
y1 = sv->y + MulScale(vy,i, 30); y1 = sv->y + MulScale(vy,i, 30);
} }
@ -1477,7 +1477,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32
{ {
// daz-intz > 0 && daz-intz < k // daz-intz > 0 && daz-intz < k
int32_t xtex = MulScale(ucoefup16, tileWidth(tilenum), 16); int32_t xtex = MulScale(ucoefup16, tileWidth(tilenum), 16);
int32_t vcoefup16 = 65536-divscale16(daz-intz, k); int32_t vcoefup16 = 65536-DivScale(daz-intz, k, 16);
int32_t ytex = MulScale(vcoefup16, tileHeight(tilenum), 16); int32_t ytex = MulScale(vcoefup16, tileHeight(tilenum), 16);
auto texel = (tilePtr(tilenum) + tileHeight(tilenum)*xtex + ytex); auto texel = (tilePtr(tilenum) + tileHeight(tilenum)*xtex + ytex);

View file

@ -390,7 +390,7 @@ static int32_t engineLoadTables(void)
initksqrt(); initksqrt();
for (i=0; i<2048; i++) for (i=0; i<2048; i++)
reciptable[i] = divscale30(2048, i+2048); reciptable[i] = DivScale(2048, i+2048, 30);
for (i=0; i<=512; i++) for (i=0; i<=512; i++)
sintable[i] = bsinf(i); sintable[i] = bsinf(i);
@ -726,12 +726,12 @@ int32_t rintersect_old(int32_t x1, int32_t y1, int32_t z1,
else if (bot < 0 && (topt > 0 || topu > 0 || topu <= bot)) else if (bot < 0 && (topt > 0 || topu > 0 || topu <= bot))
return -1; return -1;
int32_t t = divscale16(topt, bot); int32_t t = DivScale(topt, bot, 16);
*intx = x1 + MulScale(vx, t, 16); *intx = x1 + MulScale(vx, t, 16);
*inty = y1 + MulScale(vy, t, 16); *inty = y1 + MulScale(vy, t, 16);
*intz = z1 + MulScale(vz, t, 16); *intz = z1 + MulScale(vz, t, 16);
t = divscale16(topu, bot); t = DivScale(topu, bot, 16);
return t; return t;
} }
@ -1012,7 +1012,7 @@ int32_t renderDrawRoomsQ16(int32_t daposx, int32_t daposy, int32_t daposz,
// xdimenscale is scale(xdimen,yxaspect,320); // xdimenscale is scale(xdimen,yxaspect,320);
// normalization by viewingrange so that center-of-aim doesn't depend on it // normalization by viewingrange so that center-of-aim doesn't depend on it
qglobalhoriz = MulScale(dahoriz, divscale16(xdimenscale, viewingrange), 16)+IntToFixed(ydimen>>1); qglobalhoriz = MulScale(dahoriz, DivScale(xdimenscale, viewingrange, 16), 16)+IntToFixed(ydimen>>1);
globalcursectnum = dacursectnum; globalcursectnum = dacursectnum;
@ -1590,7 +1590,7 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
int32_t const oyxaspect = yxaspect, oviewingrange = viewingrange; int32_t const oyxaspect = yxaspect, oviewingrange = viewingrange;
renderSetAspect(65536, divscale16((320*5)/8, 200)); renderSetAspect(65536, DivScale((320*5)/8, 200, 16));
memset(gotsector, 0, sizeof(gotsector)); memset(gotsector, 0, sizeof(gotsector));
@ -1599,7 +1599,7 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
zoome <<= 8; zoome <<= 8;
vec2_t const bakgvect = { divscale28(-bcos(ang), zoome), divscale28(-bsin(ang), zoome) }; vec2_t const bakgvect = { DivScale(-bcos(ang), zoome, 28), DivScale(-bsin(ang), zoome, 28) };
vec2_t const vect = { MulScale(-bsin(ang), zoome, 8), MulScale(-bcos(ang), zoome, 8) }; vec2_t const vect = { MulScale(-bsin(ang), zoome, 8), MulScale(-bcos(ang), zoome, 8) };
vec2_t const vect2 = { MulScale(vect.x, yxaspect, 16), MulScale(vect.y, yxaspect, 16) }; vec2_t const vect2 = { MulScale(vect.x, yxaspect, 16), MulScale(vect.y, yxaspect, 16) };
@ -2309,7 +2309,7 @@ int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, in
if (nexts < 0 || wal->cstat&32) if (nexts < 0 || wal->cstat&32)
return 0; return 0;
t = divscale24(t,bot); t = DivScale(t,bot, 24);
x = x1 + MulScale(x21,t, 24); x = x1 + MulScale(x21,t, 24);
y = y1 + MulScale(y21,t, 24); y = y1 + MulScale(y21,t, 24);
z = z1 + MulScale(z21,t, 24); z = z1 + MulScale(z21,t, 24);
@ -2856,7 +2856,7 @@ void videoSetCorrectedAspect()
x = xdim; x = xdim;
y = ydim; y = ydim;
vr = divscale16(x*3, y*4); vr = DivScale(x*3, y*4, 16);
renderSetAspect(vr, yx); renderSetAspect(vr, yx);
} }
@ -2872,7 +2872,7 @@ void videoSetViewableArea(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
windowxy2.y = y2; windowxy2.y = y2;
xdimen = (x2-x1)+1; halfxdimen = (xdimen>>1); xdimen = (x2-x1)+1; halfxdimen = (xdimen>>1);
xdimenrecip = divscale32(1L,xdimen); xdimenrecip = DivScale(1L,xdimen, 32);
ydimen = (y2-y1)+1; ydimen = (y2-y1)+1;
fxdimen = (float) xdimen; fxdimen = (float) xdimen;
@ -2890,13 +2890,13 @@ void renderSetAspect(int32_t daxrange, int32_t daaspect)
{ {
if (daxrange == 65536) daxrange--; // This doesn't work correctly with 65536. All other values are fine. No idea where this is evaluated wrong. if (daxrange == 65536) daxrange--; // This doesn't work correctly with 65536. All other values are fine. No idea where this is evaluated wrong.
viewingrange = daxrange; viewingrange = daxrange;
viewingrangerecip = divscale32(1,daxrange); viewingrangerecip = DivScale(1,daxrange, 32);
#ifdef USE_OPENGL #ifdef USE_OPENGL
fviewingrange = (float) daxrange; fviewingrange = (float) daxrange;
#endif #endif
yxaspect = daaspect; yxaspect = daaspect;
xyaspect = divscale32(1,yxaspect); xyaspect = DivScale(1,yxaspect, 32);
xdimenscale = scale(xdimen,yxaspect,320); xdimenscale = scale(xdimen,yxaspect,320);
xdimscale = scale(320,xyaspect,xdimen); xdimscale = scale(320,xyaspect,xdimen);
} }

View file

@ -2433,7 +2433,7 @@ void polymost_drawrooms()
ghalfy = (float)(ydimen>>1); ghalfy = (float)(ydimen>>1);
grhalfxdown10 = 1.f/(ghalfx*1024.f); grhalfxdown10 = 1.f/(ghalfx*1024.f);
ghoriz = FixedToFloat(qglobalhoriz); ghoriz = FixedToFloat(qglobalhoriz);
ghorizcorrect = FixedToFloat(divscale16(xdimenscale, viewingrange)); ghorizcorrect = FixedToFloat(DivScale(xdimenscale, viewingrange, 16));
//global cos/sin height angle //global cos/sin height angle
if (r_yshearing) if (r_yshearing)
@ -2813,7 +2813,7 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang
set_globalpos(dax, day, daz); set_globalpos(dax, day, daz);
set_globalang(daang); set_globalang(daang);
qglobalhoriz = MulScale(dahoriz, divscale16(xdimenscale, viewingrange), 16)+IntToFixed(ydimen>>1); qglobalhoriz = MulScale(dahoriz, DivScale(xdimenscale, viewingrange, 16), 16)+IntToFixed(ydimen>>1);
gyxscale = ((float)xdimenscale)*(1.0f/131072.f); gyxscale = ((float)xdimenscale)*(1.0f/131072.f);
gxyaspect = ((double)xyaspect*fviewingrange)*(5.0/(65536.0*262144.0)); gxyaspect = ((double)xyaspect*fviewingrange)*(5.0/(65536.0*262144.0));
gviewxrange = fviewingrange * fxdimen * (1.f/(32768.f*1024.f)); gviewxrange = fviewingrange * fxdimen * (1.f/(32768.f*1024.f));
@ -2825,7 +2825,7 @@ void polymost_prepareMirror(int32_t dax, int32_t day, int32_t daz, fixed_t daang
ghalfy = (float)(ydimen>>1); ghalfy = (float)(ydimen>>1);
grhalfxdown10 = 1.f/(ghalfx*1024.f); grhalfxdown10 = 1.f/(ghalfx*1024.f);
ghoriz = FixedToFloat(qglobalhoriz); ghoriz = FixedToFloat(qglobalhoriz);
ghorizcorrect = FixedToFloat(divscale16(xdimenscale, viewingrange)); ghorizcorrect = FixedToFloat(DivScale(xdimenscale, viewingrange, 16));
resizeglcheck(); resizeglcheck();
if (r_yshearing) if (r_yshearing)
{ {

View file

@ -562,7 +562,7 @@ void DrawOverheadMap(int pl_x, int pl_y, int pl_angle, double const smoothratio)
renderDrawMapView(x, y, gZoom, follow_a); renderDrawMapView(x, y, gZoom, follow_a);
} }
int32_t tmpydim = (xdim * 5) / 8; int32_t tmpydim = (xdim * 5) / 8;
renderSetAspect(65536, divscale16(tmpydim * 320, xdim * 200)); renderSetAspect(65536, DivScale(tmpydim * 320, xdim * 200, 16));
drawredlines(x, y, gZoom, follow_a); drawredlines(x, y, gZoom, follow_a);
drawwhitelines(x, y, gZoom, follow_a); drawwhitelines(x, y, gZoom, follow_a);

View file

@ -381,7 +381,7 @@ void DrawView(double smoothRatio, bool sceneonly)
} }
renderSetAspect(viewingRange, divscale16(ydim * 8, xdim * 5)); renderSetAspect(viewingRange, DivScale(ydim * 8, xdim * 5, 16));
if (nFreeze) if (nFreeze)
{ {

View file

@ -1322,7 +1322,7 @@ void bounce(DDukeActor* actor)
l = dax * dax + day * day + daz * daz; l = dax * dax + day * day + daz * daz;
if ((abs(k) >> 14) < l) if ((abs(k) >> 14) < l)
{ {
k = divscale17(k, l); k = DivScale(k, l, 17);
xvect -= MulScale(dax, k, 16); xvect -= MulScale(dax, k, 16);
yvect -= MulScale(day, k, 16); yvect -= MulScale(day, k, 16);
zvect -= MulScale(daz, k, 16); zvect -= MulScale(daz, k, 16);

View file

@ -1114,8 +1114,8 @@ bool view(struct player_struct* pp, int* vx, int* vy, int* vz, short* vsectnum,
if (abs(nx) > abs(ny)) hx -= (nx >> 5); if (abs(nx) > abs(ny)) hx -= (nx >> 5);
else hy -= (ny >> 5); else hy -= (ny >> 5);
} }
if (abs(nx) > abs(ny)) i = divscale16(hx, nx); if (abs(nx) > abs(ny)) i = DivScale(hx, nx, 16);
else i = divscale16(hy, ny); else i = DivScale(hy, ny, 16);
if (i < cameradist) cameradist = i; if (i < cameradist) cameradist = i;
} }
*vx = (*vx) + MulScale(nx, cameradist, 16); *vx = (*vx) + MulScale(nx, cameradist, 16);

View file

@ -529,7 +529,7 @@ void displayrooms(int snum, double smoothratio)
else else
{ {
// Fixme: This should get the aspect ratio from the backend, not the current viewport size. // Fixme: This should get the aspect ratio from the backend, not the current viewport size.
int i = divscale22(1, isRR() ? 64 : p->GetActor()->s.yrepeat + 28); int i = DivScale(1, isRR() ? 64 : p->GetActor()->s.yrepeat + 28, 22);
int viewingaspect = !isRRRA() || !p->DrugMode ? xs_CRoundToInt(double(i) * tan(r_fov * (pi::pi() / 360.))) : getdrugmode(p, i); int viewingaspect = !isRRRA() || !p->DrugMode ? xs_CRoundToInt(double(i) * tan(r_fov * (pi::pi() / 360.))) : getdrugmode(p, i);
renderSetAspect(MulScale(viewingaspect, viewingrange, 16), yxaspect); renderSetAspect(MulScale(viewingaspect, viewingrange, 16), yxaspect);

View file

@ -287,7 +287,7 @@ static int GetPositionInfo(DDukeActor* actor, int soundNum, int sectNum,
orgsndist = sndist = int(16 * (sndorg - campos).Length()); orgsndist = sndist = int(16 * (sndorg - campos).Length());
if ((userflags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL && sp->picnum == MUSICANDSFX && sp->lotag < 999 && (sector[sp->sectnum].lotag & 0xff) < ST_9_SLIDING_ST_DOOR) if ((userflags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL && sp->picnum == MUSICANDSFX && sp->lotag < 999 && (sector[sp->sectnum].lotag & 0xff) < ST_9_SLIDING_ST_DOOR)
sndist = divscale14(sndist, sp->hitag + 1); sndist = DivScale(sndist, sp->hitag + 1, 14);
} }
sndist += dist_adjust; sndist += dist_adjust;

View file

@ -1771,7 +1771,7 @@ drawscreen(PLAYERp pp, double smoothratio)
renderDrawMasks(); renderDrawMasks();
renderSetAspect(viewingRange, divscale16(ydim * 8, xdim * 5)); renderSetAspect(viewingRange, DivScale(ydim * 8, xdim * 5, 16));
if (!ScreenSavePic) UpdatePanel(smoothratio); if (!ScreenSavePic) UpdatePanel(smoothratio);
#define SLIME 2305 #define SLIME 2305

View file

@ -240,7 +240,7 @@ void QuakeViewChange(PLAYERp pp, int *z_diff, int *x_diff, int *y_diff, short *a
{ {
// scale values from epicenter // scale values from epicenter
dist_diff = radius - save_dist; dist_diff = radius - save_dist;
scale_value = divscale16(dist_diff, radius); scale_value = DivScale(dist_diff, radius, 16);
*z_diff = MulScale(*z_diff, scale_value, 16); *z_diff = MulScale(*z_diff, scale_value, 16);
*ang_diff = MulScale(*ang_diff, scale_value, 16); *ang_diff = MulScale(*ang_diff, scale_value, 16);

View file

@ -8901,7 +8901,7 @@ bool SlopeBounce(short SpriteNum, bool *hit_wall)
// make sure divscale doesn't overflow // make sure divscale doesn't overflow
if ((klabs(k)>>14) < l) if ((klabs(k)>>14) < l)
{ {
k = divscale17(k, l); k = DivScale(k, l, 17);
u->xchange -= MulScale(dax, k, 16); u->xchange -= MulScale(dax, k, 16);
u->ychange -= MulScale(day, k, 16); u->ychange -= MulScale(day, k, 16);
u->zchange -= MulScale(daz, k, 12); u->zchange -= MulScale(daz, k, 12);