Clean up handling of widescreen bits in dorotatesprite functions.

Don't call setaspect from them, because the only thing that's needed is
(in classic) yxaspect and xyaspect.  Pass these from the helper function
defined earlier instead.

git-svn-id: https://svn.eduke32.com/eduke32@2921 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-08-19 12:51:04 +00:00
parent e014246d82
commit 60a03c2fb3
3 changed files with 44 additions and 23 deletions

View file

@ -6845,17 +6845,24 @@ static int32_t clippoly4(int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2)
// INTERNAL helper function for classic/polymost dorotatesprite // INTERNAL helper function for classic/polymost dorotatesprite
int32_t dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t z, int32_t dastat, // sxptr, sxptr, z: in/out
int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2) // ret_yxaspect, ret_xyaspect: out
void dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t *z, int32_t dastat,
int32_t cx1_plus_cx2, int32_t cy1_plus_cy2,
int32_t *ret_yxaspect, int32_t *ret_xyaspect)
{ {
int32_t x, sx, sy; int32_t x, sx, sy;
int32_t ouryxaspect = yxaspect, ourxyaspect = xyaspect;
if ((dastat&2) == 0) if ((dastat&2) == 0)
if (!(dastat & 1024) && 4*ydim <= 3*xdim) if (!(dastat & 1024) && 4*ydim <= 3*xdim)
{ {
setaspect(65536, (12<<16)/10); *ret_yxaspect = (12<<16)/10;
// *sxptr and *syptr are left unchanged *ret_xyaspect = (1LL<<32)/ouryxaspect;
return z;
// *sxptr and *syptr and *z are left unchanged
return;
} }
// dastat&2: Auto window size scaling // dastat&2: Auto window size scaling
@ -6866,7 +6873,7 @@ int32_t dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t z, int32_t
// nasty hacks go here // nasty hacks go here
if (!(dastat&8)) if (!(dastat&8))
{ {
const int32_t cxs = cx1+cx2+2; const int32_t cxs = cx1_plus_cx2+2;
int32_t sthelse; int32_t sthelse;
const int32_t oxdim = xdim; const int32_t oxdim = xdim;
@ -6877,8 +6884,10 @@ int32_t dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t z, int32_t
if (!(dastat & 1024) && 4*ydim <= 3*xdim) if (!(dastat & 1024) && 4*ydim <= 3*xdim)
{ {
xdim = (4*ydim)/3; xdim = (4*ydim)/3;
// aspect is divscale16(ydim*320, xdim*200)
setaspect(65536, (12<<16)/10); // ouryxaspect is divscale16(ydim*320, xdim*200)
ouryxaspect = (12<<16)/10;
ourxyaspect = (1LL<<32)/ouryxaspect;
} }
sthelse = scale(sx-(320<<15), scale(xdimen, xdim, oxdim), 320); sthelse = scale(sx-(320<<15), scale(xdimen, xdim, oxdim), 320);
@ -6897,7 +6906,7 @@ int32_t dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t z, int32_t
sx = ((cxs+xbord)<<15) + sthelse; sx = ((cxs+xbord)<<15) + sthelse;
} }
sy = ((cy1+cy2+2)<<15)+mulscale16(sy-(200<<15),x); sy = ((cy1_plus_cy2+2)<<15)+mulscale16(sy-(200<<15), x);
} }
else else
{ {
@ -6910,12 +6919,14 @@ int32_t dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t z, int32_t
if (!(dastat & 1024) && 4*ydim <= 3*xdim) if (!(dastat & 1024) && 4*ydim <= 3*xdim)
{ {
xdim = (4*ydim)/3; xdim = (4*ydim)/3;
setaspect(65536, (12<<16)/10);
ouryxaspect = (12<<16)/10;
ourxyaspect = (1LL<<32)/ouryxaspect;
} }
x = scale(xdim,yxaspect,320); x = scale(xdim,ouryxaspect,320);
sx = (xdim<<15)+32768+scale(sx-(320<<15),xdim,320); sx = (xdim<<15)+32768 + scale(sx-(320<<15),xdim,320);
sy = (ydim<<15)+32768+mulscale16(sy-(200<<15),x); sy = (ydim<<15)+32768 + mulscale16(sy-(200<<15),x);
if (dastat & 512) if (dastat & 512)
sx += (oxdim-xdim)<<16; sx += (oxdim-xdim)<<16;
@ -6925,8 +6936,10 @@ int32_t dorotspr_handle_bit2(int32_t *sxptr, int32_t *syptr, int32_t z, int32_t
*sxptr = sx; *sxptr = sx;
*syptr = sy; *syptr = sy;
*z = mulscale16(*z,x);
return mulscale16(z,x); *ret_yxaspect = ouryxaspect;
*ret_xyaspect = ourxyaspect;
} }
@ -6945,6 +6958,8 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
int32_t xsiz, ysiz, xoff, yoff, npoints, yplc, yinc, lx, rx; int32_t xsiz, ysiz, xoff, yoff, npoints, yplc, yinc, lx, rx;
int32_t xv, yv, xv2, yv2; int32_t xv, yv, xv2, yv2;
int32_t ouryxaspect, ourxyaspect;
UNREFERENCED_PARAMETER(uniqid); UNREFERENCED_PARAMETER(uniqid);
//============================================================================= //POLYMOST BEGINS //============================================================================= //POLYMOST BEGINS
#ifdef USE_OPENGL #ifdef USE_OPENGL
@ -6986,14 +7001,14 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
cosang = sintable[(a+512)&2047]; cosang = sintable[(a+512)&2047];
sinang = sintable[a&2047]; sinang = sintable[a&2047];
z = dorotspr_handle_bit2(&sx, &sy, z, dastat, cx1, cy1, cx2, cy2); dorotspr_handle_bit2(&sx, &sy, &z, dastat, cx1+cx2, cy1+cy2, &ouryxaspect, &ourxyaspect);
xv = mulscale14(cosang,z); xv = mulscale14(cosang,z);
yv = mulscale14(sinang,z); yv = mulscale14(sinang,z);
if ((dastat&2) || (dastat&8) == 0) //Don't aspect unscaled perms if ((dastat&2) || (dastat&8) == 0) //Don't aspect unscaled perms
{ {
xv2 = mulscale16(xv,xyaspect); xv2 = mulscale16(xv,ourxyaspect);
yv2 = mulscale16(yv,xyaspect); yv2 = mulscale16(yv,ourxyaspect);
} }
else else
{ {
@ -7058,8 +7073,8 @@ static void dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t
yv = mulscale14(cosang,i); yv = mulscale14(cosang,i);
if ((dastat&2) || (dastat&8)==0) //Don't aspect unscaled perms if ((dastat&2) || (dastat&8)==0) //Don't aspect unscaled perms
{ {
yv2 = mulscale16(-xv,yxaspect); yv2 = mulscale16(-xv,ouryxaspect);
xv2 = mulscale16(yv,yxaspect); xv2 = mulscale16(yv,ouryxaspect);
} }
else else
{ {

View file

@ -77,8 +77,9 @@ extern palette_t palookupfog[MAXPALOOKUPS];
int32_t wallfront(int32_t l1, int32_t l2); int32_t wallfront(int32_t l1, int32_t l2);
int32_t animateoffs(int16_t tilenum, int16_t fakevar); int32_t animateoffs(int16_t tilenum, int16_t fakevar);
int32_t dorotspr_handle_bit2(int32_t *sx, int32_t *sy, int32_t z, int32_t dastat, void dorotspr_handle_bit2(int32_t *sx, int32_t *sy, int32_t *z, int32_t dastat,
int32_t cx1, int32_t cy1, int32_t cx2, int32_t cy2); int32_t cx1_plus_cx2, int32_t cy1_plus_cy2,
int32_t *ret_ouryxaspect, int32_t *ret_ourxyaspect);
////// yax'y stuff ////// ////// yax'y stuff //////
#ifdef USE_OPENGL #ifdef USE_OPENGL

View file

@ -5359,6 +5359,8 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
double d, cosang, sinang, cosang2, sinang2, px[8], py[8], px2[8], py2[8]; double d, cosang, sinang, cosang2, sinang2, px[8], py[8], px2[8], py2[8];
float m[4][4]; float m[4][4];
int32_t ourxyaspect;
#if defined(USE_OPENGL) && defined(POLYMER) #if defined(USE_OPENGL) && defined(POLYMER)
int32_t olddetailmapping = r_detailmapping, oldglowmapping = r_glowmapping; int32_t olddetailmapping = r_detailmapping, oldglowmapping = r_glowmapping;
#endif #endif
@ -5632,14 +5634,17 @@ void polymost_dorotatesprite(int32_t sx, int32_t sy, int32_t z, int16_t a, int16
if (dastat&4) if (dastat&4)
yoff = ysiz-yoff; yoff = ysiz-yoff;
z = dorotspr_handle_bit2(&sx, &sy, z, dastat, cx1, cy1, cx2, cy2); {
int32_t temp;
dorotspr_handle_bit2(&sx, &sy, &z, dastat, cx1+cx2, cy1+cy2, &temp, &ourxyaspect);
}
d = (double)z/(65536.0*16384.0); d = (double)z/(65536.0*16384.0);
cosang2 = cosang = (double)sintable[(a+512)&2047]*d; cosang2 = cosang = (double)sintable[(a+512)&2047]*d;
sinang2 = sinang = (double)sintable[a&2047]*d; sinang2 = sinang = (double)sintable[a&2047]*d;
if ((dastat&2) || (!(dastat&8))) //Don't aspect unscaled perms if ((dastat&2) || (!(dastat&8))) //Don't aspect unscaled perms
{ {
d = (double)xyaspect/65536.0; d = (double)ourxyaspect/65536.0;
cosang2 *= d; cosang2 *= d;
sinang2 *= d; sinang2 *= d;
} }