- Changed creation of warped GL textures so that it is done after the buffer has been

processed by the GL code.
- Fixed: A_Jump used a wrong index into the jump address table.
- Fixed: The recent changes in the DECORATE parser require the special parameter
  to A_CallSpecial to be an expression, not a constant.
- Removed game filters from old style decorations. No WAD in existence ever 
  used them and removing them allows to make the parser more robust.


git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@159 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
Christoph Oelckers 2008-08-14 19:10:59 +00:00
parent 59501a6aed
commit 8c77bc8d50
14 changed files with 157 additions and 218 deletions

View file

@ -1,4 +1,6 @@
August 14, 2008 (Changes by Graf Zahl)
- Removed game filters from old style decorations. No WAD in existence ever
used them and removing them allows to make the parser more robust.
- Added a few more macros so that the action function code doesn't have
to reference its arguments directly, except 'self'. This may be helpful if it
becomes necessary to restructure this code once DoomScript becomes real.

View file

@ -128,9 +128,7 @@ void AdjustSpriteOffsets()
{
tex->LeftOffset=x;
tex->TopOffset=y;
FGLTexture *gltex = FGLTexture::ValidateTexture(tex);
gltex->LeftOffset[FGLTexture::GLUSE_PATCH]=x+1;
gltex->TopOffset[FGLTexture::GLUSE_PATCH]=y+1;
tex->KillNative();
}
}
}

View file

@ -23,8 +23,6 @@
** covered by the terms of the GNU Lesser General Public License as published
** by the Free Software Foundation; either version 2.1 of the License, or (at
** your option) any later version.
** 5. Full disclosure of the entire project's source code, except for third
** party libraries is mandatory. (NOTE: This clause is non-negotiable!)
**
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
@ -531,204 +529,6 @@ void FGLBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int
}
//===========================================================================
//
// FWarpTexture::CopyTrueColorPixels
//
// Since the base texture can be anything the warping must be done in
// true color
//
//===========================================================================
int FWarpTexture::CopyTrueColorPixels(FBitmap *bmp, int xx, int yy, int rotate, FCopyInfo *inf)
{
int buf_pitch = bmp->GetPitch();
int buf_width = bmp->GetWidth();
int buf_height = bmp->GetHeight();
if (gl_warp_shader || gl_glsl_renderer || rotate != 0 || inf != NULL || Width > 256 || Height > 256)
{
return SourcePic->CopyTrueColorPixels(bmp, xx, yy, rotate, inf);
}
FGLBitmap inb;
if (!inb.Create(Width, Height))
return false;
DWORD * in = (DWORD *)inb.GetPixels();
DWORD * out;
bool direct;
FGLTexture *gltex = FGLTexture::ValidateTexture(this);
gltex->createWarped = true;
if (Width == buf_width && Height == buf_height && xx==0 && yy==0)
{
out = (DWORD*)bmp->GetPixels();
direct=true;
}
else
{
out = new DWORD[Width*Height];
direct=false;
}
GenTime = r_FrameTime;
if (SourcePic->bMasked) memset(in, 0, Width*Height*sizeof(DWORD));
int ret = SourcePic->CopyTrueColorPixels(&inb, 0, 0);
static DWORD linebuffer[256]; // anything larger will bring down performance so it is excluded above.
DWORD timebase = DWORD(r_FrameTime*Speed*23/28);
int xsize = Width;
int ysize = Height;
int xmask = xsize - 1;
int ymask = ysize - 1;
int ds_xbits;
int i,x;
for(ds_xbits=-1,i=Width; i; i>>=1, ds_xbits++);
for (x = xsize-1; x >= 0; x--)
{
int yt, yf = (finesine[(timebase+(x+17)*128)&FINEMASK]>>13) & ymask;
const DWORD *source = in + x;
DWORD *dest = out + x;
for (yt = ysize; yt; yt--, yf = (yf+1)&ymask, dest += xsize)
{
*dest = *(source+(yf<<ds_xbits));
}
}
timebase = DWORD(r_FrameTime*Speed*32/28);
int y;
for (y = ysize-1; y >= 0; y--)
{
int xt, xf = (finesine[(timebase+y*128)&FINEMASK]>>13) & xmask;
DWORD *source = out + (y<<ds_xbits);
DWORD *dest = linebuffer;
for (xt = xsize; xt; xt--, xf = (xf+1)&xmask)
{
*dest++ = *(source+xf);
}
memcpy (out+y*xsize, linebuffer, xsize*sizeof(DWORD));
}
if (!direct)
{
// Negative offsets cannot occur here.
if (xx<0) xx=0;
if (yy<0) yy=0;
DWORD * targ = ((DWORD*)bmp->GetPixels()) + xx + yy*buf_width;
int linelen=MIN<int>(Width, buf_width-xx);
int linecount=MIN<int>(Height, buf_height-yy);
for(i=0;i<linecount;i++)
{
memcpy(targ, &out[Width*i], linelen*sizeof(DWORD));
targ+=buf_width;
}
delete [] out;
}
GenTime=r_FrameTime;
return ret;
}
//===========================================================================
//
// FWarpTexture::CopyTrueColorPixels
//
// Since the base texture can be anything the warping must be done in
// true color
//
//===========================================================================
int FWarp2Texture::CopyTrueColorPixels(FBitmap *bmp, int xx, int yy, int rotate, FCopyInfo *inf)
{
int buf_pitch = bmp->GetPitch();
int buf_width = bmp->GetWidth();
int buf_height = bmp->GetHeight();
if (gl_warp_shader || gl_glsl_renderer || rotate != 0 || inf != NULL || Width > 256 || Height > 256)
{
return SourcePic->CopyTrueColorPixels(bmp, xx, yy, rotate, inf);
}
FGLBitmap inb;
if (!inb.Create(Width, Height))
return false;
DWORD * in = (DWORD *)inb.GetPixels();
DWORD * out;
bool direct;
FGLTexture *gltex = FGLTexture::ValidateTexture(this);
gltex->createWarped = true;
if (Width == buf_width && Height == buf_height && xx==0 && yy==0)
{
out = (DWORD*)bmp->GetPixels();
direct=true;
}
else
{
out = new DWORD[Width*Height];
direct=false;
}
GenTime = r_FrameTime;
if (SourcePic->bMasked) memset(in, 0, Width*Height*sizeof(DWORD));
int ret = SourcePic->CopyTrueColorPixels(&inb, 0, 0);
int xsize = Width;
int ysize = Height;
int xmask = xsize - 1;
int ymask = ysize - 1;
int ybits;
int x, y;
int i;
for(ybits=-1,i=ysize; i; i>>=1, ybits++);
DWORD timebase = (r_FrameTime * Speed * 40 / 28);
for (x = xsize-1; x >= 0; x--)
{
for (y = ysize-1; y >= 0; y--)
{
int xt = (x + 128
+ ((finesine[(y*128 + timebase*5 + 900) & 8191]*2)>>FRACBITS)
+ ((finesine[(x*256 + timebase*4 + 300) & 8191]*2)>>FRACBITS)) & xmask;
int yt = (y + 128
+ ((finesine[(y*128 + timebase*3 + 700) & 8191]*2)>>FRACBITS)
+ ((finesine[(x*256 + timebase*4 + 1200) & 8191]*2)>>FRACBITS)) & ymask;
const DWORD *source = in + (xt << ybits) + yt;
DWORD *dest = out + (x << ybits) + y;
*dest = *source;
}
}
if (!direct)
{
// This can only happen for sprites so
// negative offsets cannot occur here.
if (xx<0) xx=0;
if (yy<0) yy=0;
DWORD * targ = ((DWORD*)bmp->GetPixels()) + xx + yy*buf_width;
int linelen=MIN<int>(Width, buf_width-xx);
int linecount=MIN<int>(Height, buf_height-yy);
for(i=0;i<linecount;i++)
{
memcpy(targ, &out[Width*i], linelen*sizeof(DWORD));
targ+=buf_pitch/4;
}
delete [] out;
}
GenTime=r_FrameTime;
return ret;
}
//===========================================================================
//
// Camera texture rendering
@ -891,7 +691,7 @@ FGLTexture::FGLTexture(FTexture * tx)
if ((gl.flags & RFL_GLSL) && tx->UseBasePalette() && HasGlobalBrightmap &&
tx->UseType != FTexture::TEX_Autopage && tx->UseType != FTexture::TEX_Decal &&
tx->UseType != FTexture::TEX_MiscPatch && tx->UseType != FTexture::TEX_FontChar &&
tex->bm_info.Brightmap == NULL
tex->bm_info.Brightmap == NULL && tx->bWarped == 0
)
{
tex->bm_info.Brightmap = new FBrightmapTexture(tx);
@ -1176,6 +976,83 @@ void FGLTexture::Clean(bool all)
createWarped = false;
}
//===========================================================================
//
// FGLTexture::WarpBuffer
//
//===========================================================================
BYTE *FGLTexture::WarpBuffer(BYTE *buffer, int Width, int Height, int warp)
{
DWORD *in = (DWORD*)buffer;
DWORD *out = (DWORD*)new BYTE[4*Width*Height];
float Speed = static_cast<FWarpTexture*>(tex)->GetSpeed();
static_cast<FWarpTexture*>(tex)->GenTime = r_FrameTime;
static DWORD linebuffer[256]; // anything larger will bring down performance so it is excluded above.
DWORD timebase = DWORD(r_FrameTime*Speed*23/28);
int xsize = Width;
int ysize = Height;
int xmask = xsize - 1;
int ymask = ysize - 1;
int ds_xbits;
int i,x;
if (warp == 1)
{
for(ds_xbits=-1,i=Width; i; i>>=1, ds_xbits++);
for (x = xsize-1; x >= 0; x--)
{
int yt, yf = (finesine[(timebase+(x+17)*128)&FINEMASK]>>13) & ymask;
const DWORD *source = in + x;
DWORD *dest = out + x;
for (yt = ysize; yt; yt--, yf = (yf+1)&ymask, dest += xsize)
{
*dest = *(source+(yf<<ds_xbits));
}
}
timebase = DWORD(r_FrameTime*Speed*32/28);
int y;
for (y = ysize-1; y >= 0; y--)
{
int xt, xf = (finesine[(timebase+y*128)&FINEMASK]>>13) & xmask;
DWORD *source = out + (y<<ds_xbits);
DWORD *dest = linebuffer;
for (xt = xsize; xt; xt--, xf = (xf+1)&xmask)
{
*dest++ = *(source+xf);
}
memcpy (out+y*xsize, linebuffer, xsize*sizeof(DWORD));
}
}
else
{
int ybits;
for(ybits=-1,i=ysize; i; i>>=1, ybits++);
DWORD timebase = (r_FrameTime * Speed * 40 / 28);
for (x = xsize-1; x >= 0; x--)
{
for (int y = ysize-1; y >= 0; y--)
{
int xt = (x + 128
+ ((finesine[(y*128 + timebase*5 + 900) & 8191]*2)>>FRACBITS)
+ ((finesine[(x*256 + timebase*4 + 300) & 8191]*2)>>FRACBITS)) & xmask;
int yt = (y + 128
+ ((finesine[(y*128 + timebase*3 + 700) & 8191]*2)>>FRACBITS)
+ ((finesine[(x*256 + timebase*4 + 1200) & 8191]*2)>>FRACBITS)) & ymask;
const DWORD *source = in + (xt << ybits) + yt;
DWORD *dest = out + (x << ybits) + y;
*dest = *source;
}
}
}
delete [] buffer;
return (BYTE*)out;
}
//===========================================================================
//
// Initializes the buffer for the texture data
@ -1241,6 +1118,12 @@ unsigned char * FGLTexture::CreateTexBuffer(ETexUse use, int _cm, int translatio
tex->FTexture::CopyTrueColorPixels(&bmp, GetLeftOffset(use) - tex->LeftOffset, GetTopOffset(use) - tex->TopOffset);
}
if ((!(gl.flags & RFL_GLSL) || !gl_warp_shader) && tex->bWarped && W <= 256 && H <= 256)
{
buffer = WarpBuffer(buffer, W, H, tex->bWarped);
createWarped = true;
}
return buffer;
}

View file

@ -140,6 +140,7 @@ private:
bool bHasColorkey; // only for hires
GL_RECT * areas;
GLShader * Shader;
bool ShaderSet;
short LeftOffset[2];
short TopOffset[2];
@ -159,6 +160,7 @@ private:
int CheckExternalFile(bool & hascolorkey);
unsigned char * LoadHiresTexture(int *width, int *height, int cm);
BYTE *WarpBuffer(BYTE *buffer, int Width, int Height, int warp);
void CheckForAlpha(const unsigned char * buffer);

View file

@ -45,28 +45,26 @@ public:
// A texture that returns a wiggly version of another texture.
class FWarpTexture : public FTexture
{
friend class FGLTexture;
public:
FWarpTexture (FTexture *source);
~FWarpTexture ();
virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL);
const BYTE *GetColumn (unsigned int column, const Span **spans_out);
const BYTE *GetPixels ();
void Unload ();
bool CheckModified ();
// [OpenGL]
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
bool UseBasePalette() { return false; }
float GetSpeed() const { return Speed; }
int GetSourceLump() { return SourcePic->GetSourceLump(); }
void SetSpeed(float fac) { Speed = fac; }
FTexture *GetRedirect(bool wantwarped);
DWORD GenTime;
protected:
FTexture *SourcePic;
BYTE *Pixels;
Span **Spans;
DWORD GenTime;
float Speed;
virtual void MakeTexture (DWORD time);
@ -78,10 +76,6 @@ class FWarp2Texture : public FWarpTexture
public:
FWarp2Texture (FTexture *source);
// [OpenGL]
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL);
bool UseBasePalette() { return false; }
protected:
void MakeTexture (DWORD time);
};

View file

@ -3,5 +3,5 @@
// This file was automatically generated by the
// updaterevision tool. Do not edit by hand.
#define ZD_SVN_REVISION_STRING "1169"
#define ZD_SVN_REVISION_NUMBER 1169
#define ZD_SVN_REVISION_STRING "1170"
#define ZD_SVN_REVISION_NUMBER 1170

View file

@ -184,6 +184,7 @@ protected:
bool bTranslucentPatches:1;
void MakeTexture ();
FTexture *GetRedirect(bool wantwarped);
private:
void CheckForHacks ();
@ -755,6 +756,18 @@ void FMultiPatchTexture::CheckForHacks ()
//
//==========================================================================
FTexture *FMultiPatchTexture::GetRedirect(bool wantwarped)
{
if (bRedirect) return Parts->Texture;
else return this;
}
//==========================================================================
//
// FMultiPatchTexture :: TexPart :: TexPart
//
//==========================================================================
FMultiPatchTexture::TexPart::TexPart()
{
OriginX = OriginY = 0;

View file

@ -515,6 +515,11 @@ bool FTexture::UseBasePalette()
return true;
}
FTexture *FTexture::GetRedirect(bool wantwarped)
{
return this;
}
FDummyTexture::FDummyTexture ()

View file

@ -147,6 +147,7 @@ public:
int CopyTrueColorTranslated(FBitmap *bmp, int x, int y, int rotate, FRemapTable *remap, FCopyInfo *inf = NULL);
virtual bool UseBasePalette();
virtual int GetSourceLump() { return -1; }
virtual FTexture *GetRedirect(bool wantwarped);
virtual void Unload () = 0;

View file

@ -222,3 +222,29 @@ void FWarp2Texture::MakeTexture (DWORD time)
}
}
//==========================================================================
//
// FMultiPatchTexture :: TexPart :: TexPart
//
//==========================================================================
FTexture *FWarpTexture::GetRedirect(bool wantwarped)
{
if (!wantwarped) return SourcePic;
else return this;
}
//==========================================================================
//
// FMultiPatchTexture :: CopyTrueColorPixels
//
// This doesn't warp. It's just here in case someone tries to use a warp
// texture for compositing a multipatch texture
//
//==========================================================================
int FWarpTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
{
return SourcePic->CopyTrueColorPixels(bmp, x, y, rotate, inf);
}

View file

@ -244,6 +244,10 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
info->GameFilter = 0x80;
MakeStateDefines(parent->ActorInfo->StateList);
// There isn't a single WAD out there which uses game filters with old style
// decorations so this may as well be disabled. Without this option is is much
// easier to detect incorrect declarations
#if 0
sc.MustGetString ();
while (!sc.Compare ("{"))
{
@ -295,6 +299,10 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def)
{
info->GameFilter &= ~0x80;
}
#else
info->GameFilter = GAME_Any;
sc.MustGetStringName("{");
#endif
states.Clear ();
memset (&extra, 0, sizeof(extra));

View file

@ -460,7 +460,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Jump)
}
else
{
ACTION_JUMP(jumps[(pr_cajump() % (count - 1)) + 2]);
ACTION_JUMP(jumps[(pr_cajump() % (count - 1))]);
}
}
ACTION_SET_RESULT(false); // Jumps should never set the result for inventory state chains!

View file

@ -122,7 +122,9 @@ static void ParseDecorate (FScanner &sc)
}
default:
// Yuck! Too bad that there's no better way to check this properly
// without the option of game filters following, anything but an opening brace
// here means a syntax error.
sc.MustGetStringName("{");
sc.RestorePos(pos);
ParseOldDecoration(sc, DEF_Decoration);
break;

View file

@ -421,7 +421,12 @@ bool DoActionSpecials(FScanner &sc, FState & state, bool multistate, int * state
int paramindex=PrepareStateParameters(&state, 6);
StateParameters[paramindex]=special;
// The function expects the special to be passed as expression so we
// have to convert it.
specname.Format("%d", special);
FScanner sc2;
sc2.OpenMem("", (char*)specname.GetChars(), int(specname.Len()));
StateParameters[paramindex] = ParseExpression(sc2, false, bag.Info->Class);
// Make this consistent with all other parameter parsing
if (sc.CheckToken('('))