mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-14 08:30:49 +00:00
Add 1 pixel tall and wide texture support to the renderer
- These require manual detection and overriding of the scaling factors to 0, because a right shift of (32-0) bits wraps around to 0 and results in no shift at all rather than leaving the register zeroed out.
This commit is contained in:
parent
8d7e400f8e
commit
9388597443
4 changed files with 59 additions and 12 deletions
|
@ -198,7 +198,10 @@ SetTiltedSpanSize:
|
||||||
mov [y8+2],cl
|
mov [y8+2],cl
|
||||||
mov [y9+2],cl
|
mov [y9+2],cl
|
||||||
mov [y10+2],cl
|
mov [y10+2],cl
|
||||||
|
cmp eax,0 ; if x bits is 0, mask must be 0 too.
|
||||||
|
jz .notted
|
||||||
not eax
|
not eax
|
||||||
|
.notted:
|
||||||
pop ecx
|
pop ecx
|
||||||
|
|
||||||
mov [m1+2],eax
|
mov [m1+2],eax
|
||||||
|
|
|
@ -221,10 +221,26 @@ void R_MapPlane (int y, int x1)
|
||||||
|
|
||||||
distance = planeheight * yslope[y];
|
distance = planeheight * yslope[y];
|
||||||
|
|
||||||
ds_xstep = xs_ToFixed(32-ds_xbits, distance * xstepscale);
|
if (ds_xbits != 0)
|
||||||
ds_ystep = xs_ToFixed(32-ds_ybits, distance * ystepscale);
|
{
|
||||||
ds_xfrac = xs_ToFixed(32-ds_xbits, distance * basexfrac) + pviewx;
|
ds_xstep = xs_ToFixed(32 - ds_xbits, distance * xstepscale);
|
||||||
ds_yfrac = xs_ToFixed(32-ds_ybits, distance * baseyfrac) + pviewy;
|
ds_xfrac = xs_ToFixed(32 - ds_xbits, distance * basexfrac) + pviewx;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ds_xstep = 0;
|
||||||
|
ds_xfrac = 0;
|
||||||
|
}
|
||||||
|
if (ds_ybits != 0)
|
||||||
|
{
|
||||||
|
ds_ystep = xs_ToFixed(32 - ds_ybits, distance * ystepscale);
|
||||||
|
ds_yfrac = xs_ToFixed(32 - ds_ybits, distance * baseyfrac) + pviewy;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ds_ystep = 0;
|
||||||
|
ds_yfrac = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (plane_shade)
|
if (plane_shade)
|
||||||
{
|
{
|
||||||
|
@ -357,7 +373,7 @@ void R_CalcTiltedLighting (double lval, double lend, int width)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void R_MapTiltedPlane (int y, int x1)
|
void R_MapTiltedPlane(int y, int x1)
|
||||||
{
|
{
|
||||||
int x2 = spanend[y];
|
int x2 = spanend[y];
|
||||||
int width = x2 - x1;
|
int width = x2 - x1;
|
||||||
|
@ -366,18 +382,18 @@ void R_MapTiltedPlane (int y, int x1)
|
||||||
DWORD u, v;
|
DWORD u, v;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
iz = plane_sz[2] + plane_sz[1]*(centery-y) + plane_sz[0]*(x1-centerx);
|
iz = plane_sz[2] + plane_sz[1] * (centery - y) + plane_sz[0] * (x1 - centerx);
|
||||||
|
|
||||||
// Lighting is simple. It's just linear interpolation from start to end
|
// Lighting is simple. It's just linear interpolation from start to end
|
||||||
if (plane_shade)
|
if (plane_shade)
|
||||||
{
|
{
|
||||||
uz = (iz + plane_sz[0]*width) * planelightfloat;
|
uz = (iz + plane_sz[0] * width) * planelightfloat;
|
||||||
vz = iz * planelightfloat;
|
vz = iz * planelightfloat;
|
||||||
R_CalcTiltedLighting (vz, uz, width);
|
R_CalcTiltedLighting(vz, uz, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
uz = plane_su[2] + plane_su[1]*(centery-y) + plane_su[0]*(x1-centerx);
|
uz = plane_su[2] + plane_su[1] * (centery - y) + plane_su[0] * (x1 - centerx);
|
||||||
vz = plane_sv[2] + plane_sv[1]*(centery-y) + plane_sv[0]*(x1-centerx);
|
vz = plane_sv[2] + plane_sv[1] * (centery - y) + plane_sv[0] * (x1 - centerx);
|
||||||
|
|
||||||
fb = ylookup[y] + x1 + dc_destorg;
|
fb = ylookup[y] + x1 + dc_destorg;
|
||||||
|
|
||||||
|
@ -1888,6 +1904,15 @@ void R_DrawTiltedPlane (visplane_t *pl, double _xscale, double _yscale, fixed_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hack in support for 1 x Z and Z x 1 texture sizes
|
||||||
|
if (ds_ybits == 0)
|
||||||
|
{
|
||||||
|
plane_sv[2] = plane_sv[1] = plane_sv[0] = 0;
|
||||||
|
}
|
||||||
|
if (ds_xbits = 0)
|
||||||
|
{
|
||||||
|
plane_su[2] = plane_su[1] = plane_su[0] = 0;
|
||||||
|
}
|
||||||
#if defined(X86_ASM)
|
#if defined(X86_ASM)
|
||||||
if (ds_source != ds_curtiltedsource)
|
if (ds_source != ds_curtiltedsource)
|
||||||
R_SetTiltedSpanSource_ASM (ds_source);
|
R_SetTiltedSpanSource_ASM (ds_source);
|
||||||
|
|
|
@ -1104,6 +1104,12 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *l
|
||||||
|
|
||||||
rw_pic->GetHeight(); // Make sure texture size is loaded
|
rw_pic->GetHeight(); // Make sure texture size is loaded
|
||||||
fracbits = 32 - rw_pic->HeightBits;
|
fracbits = 32 - rw_pic->HeightBits;
|
||||||
|
if (fracbits == 32)
|
||||||
|
{ // Hack for one pixel tall textures
|
||||||
|
fracbits = 0;
|
||||||
|
yrepeat = 0;
|
||||||
|
dc_texturemid = 0;
|
||||||
|
}
|
||||||
setupvline(fracbits);
|
setupvline(fracbits);
|
||||||
xoffset = rw_offset;
|
xoffset = rw_offset;
|
||||||
basecolormapdata = basecolormap->Maps;
|
basecolormapdata = basecolormap->Maps;
|
||||||
|
@ -1456,6 +1462,12 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_
|
||||||
|
|
||||||
rw_pic->GetHeight(); // Make sure texture size is loaded
|
rw_pic->GetHeight(); // Make sure texture size is loaded
|
||||||
fracbits = 32- rw_pic->HeightBits;
|
fracbits = 32- rw_pic->HeightBits;
|
||||||
|
if (fracbits == 32)
|
||||||
|
{ // Hack for one pixel tall textures
|
||||||
|
fracbits = 0;
|
||||||
|
yrepeat = 0;
|
||||||
|
dc_texturemid = 0;
|
||||||
|
}
|
||||||
setupmvline(fracbits);
|
setupmvline(fracbits);
|
||||||
xoffset = rw_offset;
|
xoffset = rw_offset;
|
||||||
basecolormapdata = basecolormap->Maps;
|
basecolormapdata = basecolormap->Maps;
|
||||||
|
@ -1631,6 +1643,12 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, f
|
||||||
|
|
||||||
rw_pic->GetHeight(); // Make sure texture size is loaded
|
rw_pic->GetHeight(); // Make sure texture size is loaded
|
||||||
fracbits = 32 - rw_pic->HeightBits;
|
fracbits = 32 - rw_pic->HeightBits;
|
||||||
|
if (fracbits == 32)
|
||||||
|
{ // Hack for one pixel tall textures
|
||||||
|
fracbits = 0;
|
||||||
|
yrepeat = 0;
|
||||||
|
dc_texturemid = 0;
|
||||||
|
}
|
||||||
setuptmvline(fracbits);
|
setuptmvline(fracbits);
|
||||||
xoffset = rw_offset;
|
xoffset = rw_offset;
|
||||||
basecolormapdata = basecolormap->Maps;
|
basecolormapdata = basecolormap->Maps;
|
||||||
|
|
|
@ -210,8 +210,9 @@ void FTexture::CalcBitSize ()
|
||||||
}
|
}
|
||||||
WidthMask = (1 << WidthBits) - 1;
|
WidthMask = (1 << WidthBits) - 1;
|
||||||
|
|
||||||
// The minimum height is 2, because we cannot shift right 32 bits.
|
// <hr>The minimum height is 2, because we cannot shift right 32 bits.</hr>
|
||||||
for (i = 1; (1 << i) < Height; ++i)
|
// Scratch that. Somebody actually made a 1x1 texture, so now we have to handle it.
|
||||||
|
for (i = 0; (1 << i) < Height; ++i)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
HeightBits = i;
|
HeightBits = i;
|
||||||
|
|
Loading…
Reference in a new issue