File tree Expand file tree Collapse file tree 4 files changed +13
-10
lines changed
Expand file tree Collapse file tree 4 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,10 @@ inline static fixed_t CONSTFUNC FixedMod(fixed_t a, fixed_t b)
9696 return (a & (b-1 ));
9797}
9898
99- // Approx Reciprocal of v
99+ /*
100+ * Approximate Reciprocal of v
101+ */
102+
100103inline static CONSTFUNC fixed_t FixedReciprocal (fixed_t v)
101104{
102105 unsigned int val = v < 0 ? -v : v;
@@ -115,7 +118,10 @@ inline static CONSTFUNC fixed_t FixedReciprocal(fixed_t v)
115118}
116119
117120
118- // Approx fixed point divide of a/b using reciprocal. -> a * (1/b).
121+ /*
122+ * Approximate fixed point divide of a/b using reciprocal. -> a * (1/b).
123+ */
124+
119125inline static CONSTFUNC fixed_t FixedApproxDiv (fixed_t a, fixed_t b)
120126{
121127 return FixedMul (a, FixedReciprocal (b));
Original file line number Diff line number Diff line change @@ -410,7 +410,7 @@ R_PointToDist
410410 angle = (tantoangle[ FixedDiv (dy,dx)>>DBITS ]+ANG90) >> ANGLETOFINESHIFT;
411411
412412 // use as cosine
413- dist = FixedDiv (dx, finesine[angle] );
413+ dist = FixedApproxDiv (dx, finesine[angle] );
414414
415415 return dist;
416416}
Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ R_RenderMaskedSegRange
172172 }
173173
174174 sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale);
175- dc_iscale = 0xffffffffu / ( unsigned )spryscale;
175+ dc_iscale = FixedReciprocal (( unsigned )spryscale) ;
176176
177177 // draw the texture
178178 col = (column_t *)(
@@ -270,7 +270,7 @@ void R_RenderSegLoop (void)
270270
271271 dc_colormap = walllights[index];
272272 dc_x = rw_x;
273- dc_iscale = 0xffffffffu / ( unsigned )rw_scale;
273+ dc_iscale = FixedReciprocal (( unsigned )rw_scale) ;
274274 }
275275
276276 // draw the wall tiers
Original file line number Diff line number Diff line change @@ -461,8 +461,6 @@ void R_ProjectSprite (mobj_t* thing)
461461 fixed_t tx;
462462 fixed_t tz;
463463
464- fixed_t xscale;
465-
466464 int x1;
467465 int x2;
468466
@@ -478,7 +476,6 @@ void R_ProjectSprite (mobj_t* thing)
478476 vissprite_t * vis;
479477
480478 angle_t ang;
481- fixed_t iscale;
482479
483480 // transform the origin point
484481 tr_x = thing->x - viewx;
@@ -493,7 +490,7 @@ void R_ProjectSprite (mobj_t* thing)
493490 if (tz < MINZ)
494491 return ;
495492
496- xscale = FixedDiv (projection, tz);
493+ const fixed_t xscale = FixedDiv (projection, tz);
497494
498495 gxt = -FixedMul (tr_x,viewsin);
499496 gyt = FixedMul (tr_y,viewcos);
@@ -558,7 +555,7 @@ void R_ProjectSprite (mobj_t* thing)
558555 vis->texturemid = vis->gzt - viewz;
559556 vis->x1 = x1 < 0 ? 0 : x1;
560557 vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
561- iscale = FixedDiv (FRACUNIT, xscale);
558+ const fixed_t iscale = FixedReciprocal ( xscale);
562559
563560 if (flip)
564561 {
You can’t perform that action at this time.
0 commit comments