Subversion Repositories eduke32

Rev

Rev 5001 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5001 Rev 5017
Line 62... Line 62...
62
# define HIGH_PRECISION_SPRITE
62
# define HIGH_PRECISION_SPRITE
63
#endif
63
#endif
64
64
65
#if !defined EDUKE32_TOUCH_DEVICES && !defined GEKKO && !defined __OPENDINGUX__
65
#if !defined EDUKE32_TOUCH_DEVICES && !defined GEKKO && !defined __OPENDINGUX__
66
// Handle absolute z difference of floor/ceiling to camera >= 1<<24.
66
// Handle absolute z difference of floor/ceiling to camera >= 1<<24.
-
 
67
// Also: higher precision view-relative x and y for drawvox().
67
# define CLASSIC_Z_DIFF_64
68
# define CLASSIC_Z_DIFF_64
68
#endif
69
#endif
69
70
70
#define MULTI_COLUMN_VLINE
71
#define MULTI_COLUMN_VLINE
71
//#define DEBUG_TILESIZY_512
72
//#define DEBUG_TILESIZY_512
Line 3355... Line 3356...
3355
}
3356
}
3356
3357
3357
#ifdef CLASSIC_Z_DIFF_64
3358
#ifdef CLASSIC_Z_DIFF_64
3358
typedef int64_t zint_t;
3359
typedef int64_t zint_t;
3359
3360
-
 
3361
// For drawvox()
-
 
3362
static inline zint_t mulscale16z(int32_t a, int32_t d)
-
 
3363
{
-
 
3364
    return ((zint_t)a * d)>>16;
-
 
3365
}
-
 
3366
3360
static inline zint_t mulscale20z(int32_t a, int32_t d)
3367
static inline zint_t mulscale20z(int32_t a, int32_t d)
3361
{
3368
{
3362
    return ((zint_t)a * d)>>20;
3369
    return ((zint_t)a * d)>>20;
3363
}
3370
}
3364
3371
Line 3366... Line 3373...
3366
{
3373
{
3367
    return (((zint_t)a * d) + ((zint_t)S * D)) >> 24;
3374
    return (((zint_t)a * d) + ((zint_t)S * D)) >> 24;
3368
}
3375
}
3369
#else
3376
#else
3370
typedef int32_t zint_t;
3377
typedef int32_t zint_t;
-
 
3378
# define mulscale16z mulscale16
3371
# define mulscale20z mulscale20
3379
# define mulscale20z mulscale20
3372
# define dmulscale24z dmulscale24
3380
# define dmulscale24z dmulscale24
3373
#endif
3381
#endif
3374
3382
3375
//
3383
//
Line 5390... Line 5398...
5390
        }
5398
        }
5391
#endif
5399
#endif
5392
    }
5400
    }
5393
}
5401
}
5394
5402
-
 
5403
// High-precision integer type for view-relative x and y in drawvox().
-
 
5404
typedef zint_t voxint_t;
5395
5405
5396
//
5406
//
5397
// drawvox
5407
// drawvox
5398
//
5408
//
5399
static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasprang,
5409
static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasprang,
Line 5464... Line 5474...
5464
    y = (daspry-globalposy) - dmulscale18(daypivot,sprcosang, daxpivot,sprsinang);
5474
    y = (daspry-globalposy) - dmulscale18(daypivot,sprcosang, daxpivot,sprsinang);
5465
5475
5466
    cosang = mulscale16(cosang, dayscalerecip);
5476
    cosang = mulscale16(cosang, dayscalerecip);
5467
    sinang = mulscale16(sinang, dayscalerecip);
5477
    sinang = mulscale16(sinang, dayscalerecip);
5468
5478
5469
    const int32_t gxstart = y*cosang - x*sinang;
5479
    const voxint_t gxstart = (voxint_t)y*cosang - (voxint_t)x*sinang;
5470
    const int32_t gystart = x*cosang + y*sinang;
5480
    const voxint_t gystart = (voxint_t)x*cosang + (voxint_t)y*sinang;
5471
    const int32_t gxinc = dmulscale10(sprsinang,cosang, sprcosang,-sinang);
5481
    const int32_t gxinc = dmulscale10(sprsinang,cosang, sprcosang,-sinang);
5472
    const int32_t gyinc = dmulscale10(sprcosang,cosang, sprsinang,sinang);
5482
    const int32_t gyinc = dmulscale10(sprcosang,cosang, sprsinang,sinang);
5473
5483
5474
    x = 0; y = 0; j = max(daxsiz,daysiz);
5484
    x = 0; y = 0; j = max(daxsiz,daysiz);
5475
    for (i=0; i<=j; i++)
5485
    for (i=0; i<=j; i++)
Line 5575... Line 5585...
5575
5585
5576
        //Fix for non 90 degree viewing ranges
5586
        //Fix for non 90 degree viewing ranges
5577
        const int32_t nxoff = mulscale16(x2-x1,viewingrangerecip);
5587
        const int32_t nxoff = mulscale16(x2-x1,viewingrangerecip);
5578
        x1 = mulscale16(x1, viewingrangerecip);
5588
        x1 = mulscale16(x1, viewingrangerecip);
5579
5589
5580
        const int32_t ggxstart = gxstart + ggyinc[ys];
5590
        const voxint_t ggxstart = gxstart + ggyinc[ys];
5581
        const int32_t ggystart = gystart - ggxinc[ys];
5591
        const voxint_t ggystart = gystart - ggxinc[ys];
5582
5592
5583
        for (x=xs; x!=xe; x+=xi)
5593
        for (x=xs; x!=xe; x+=xi)
5584
        {
5594
        {
5585
            const intptr_t slabxoffs = (intptr_t)&davoxptr[B_LITTLE32(longptr[x])];
5595
            const intptr_t slabxoffs = (intptr_t)&davoxptr[B_LITTLE32(longptr[x])];
5586
            int16_t *const shortptr = (int16_t *)&davoxptr[((x*(daysiz+1))<<1) + xyvoxoffs];
5596
            int16_t *const shortptr = (int16_t *)&davoxptr[((x*(daysiz+1))<<1) + xyvoxoffs];
5587
5597
5588
            int32_t nx = mulscale16(ggxstart+ggxinc[x], viewingrangerecip) + x1;
5598
            voxint_t nx = mulscale16z(ggxstart+ggxinc[x], viewingrangerecip) + x1;
5589
            int32_t ny = ggystart + ggyinc[x];
5599
            voxint_t ny = ggystart + ggyinc[x];
5590
5600
5591
            for (y=ys; y!=ye; y+=yi,nx+=dagyinc,ny-=dagxinc)
5601
            for (y=ys; y!=ye; y+=yi,nx+=dagyinc,ny-=dagxinc)
5592
            {
5602
            {
5593
                if (ny <= nytooclose || ny >= nytoofar)
5603
                if (ny <= nytooclose || ny >= nytoofar)
5594
                    continue;
5604
                    continue;
Line 5776... Line 5786...
5776
5786
5777
    *cstatptr = cstat;
5787
    *cstatptr = cstat;
5778
    return blendidx;
5788
    return blendidx;
5779
}
5789
}
5780
5790
-
 
5791
static inline int32_t mulscale_triple30(int32_t a, int32_t b, int32_t c)
-
 
5792
{
-
 
5793
    return ((int64_t)a * b * c)>>30;
-
 
5794
}
-
 
5795
5781
static void drawsprite_classic(int32_t snum)
5796
static void drawsprite_classic(int32_t snum)
5782
{
5797
{
5783
    int32_t x1, y1, x2, y2, i, j, k, x;
5798
    int32_t x1, y1, x2, y2, i, j, k, x;
5784
    int32_t z, zz, z1, z2, xp1, yp1, xp2, yp2;
5799
    int32_t z, zz, z1, z2, xp1, yp1, xp2, yp2;
5785
    int32_t dax, day, dax1, dax2, y;
5800
    int32_t dax, day, dax1, dax2, y;
Line 6786... Line 6801...
6786
            const int32_t xv = mulscale16(nxrepeat,xyaspect);
6801
            const int32_t xv = mulscale16(nxrepeat,xyaspect);
6787
6802
6788
            const int32_t xspan = ((B_LITTLE32(longptr[0])+B_LITTLE32(longptr[1]))>>1);
6803
            const int32_t xspan = ((B_LITTLE32(longptr[0])+B_LITTLE32(longptr[1]))>>1);
6789
            const int32_t yspan = B_LITTLE32(longptr[2]);
6804
            const int32_t yspan = B_LITTLE32(longptr[2]);
6790
6805
6791
            const int32_t xsiz = mulscale30(siz,xv*xspan);
6806
            const int32_t xsiz = mulscale_triple30(siz, xv, xspan);
6792
            const int32_t ysiz = mulscale30(siz,nyrepeat*yspan);
6807
            const int32_t ysiz = mulscale_triple30(siz, nyrepeat, yspan);
6793
6808
6794
            //Watch out for divscale overflow
6809
            //Watch out for divscale overflow
6795
            if (((xspan>>11) < xsiz) && (yspan < (ysiz>>1)))
6810
            if (((xspan>>11) < xsiz) && (yspan < (ysiz>>1)))
6796
            {
6811
            {
6797
                x1 = xb-(xsiz>>1);
6812
                x1 = xb-(xsiz>>1);