mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-15 23:00:52 +00:00
62 lines
2 KiB
C
62 lines
2 KiB
C
|
|
||
|
template<class TYPE>
|
||
|
void WarpBufferType1(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, unsigned time, float Speed)
|
||
|
{
|
||
|
TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * MAX(width, height));
|
||
|
int ymask = height - 1;
|
||
|
int x, y;
|
||
|
|
||
|
// [mxd] Rewrote to fix animation for NPo2 textures
|
||
|
unsigned timebase = unsigned(time * Speed * 32 / 28);
|
||
|
for (y = height - 1; y >= 0; y--)
|
||
|
{
|
||
|
int xf = (TexMan.sintable[((timebase + y*ymul) >> 2)&TexMan.SINMASK] >> 11) % width;
|
||
|
if (xf < 0) xf += width;
|
||
|
int xt = xf;
|
||
|
const TYPE *sourcep = source + y;
|
||
|
TYPE *dest = Pixels + y;
|
||
|
for (xt = width; xt; xt--, xf = (xf + 1) % width, dest += height)
|
||
|
*dest = sourcep[xf + ymask * xf];
|
||
|
}
|
||
|
timebase = unsigned(time * Speed * 23 / 28);
|
||
|
for (x = width - 1; x >= 0; x--)
|
||
|
{
|
||
|
int yf = (TexMan.sintable[((time + (x + 17)*xmul) >> 2)&TexMan.SINMASK] >> 11) % height;
|
||
|
if (yf < 0) yf += height;
|
||
|
int yt = yf;
|
||
|
const TYPE *sourcep = Pixels + (x + ymask * x);
|
||
|
TYPE *dest = buffer;
|
||
|
for (yt = height; yt; yt--, yf = (yf + 1) % height)
|
||
|
*dest++ = sourcep[yf];
|
||
|
memcpy(Pixels + (x + ymask*x), buffer, height * sizeof(TYPE));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
template<class TYPE>
|
||
|
void WarpBufferType2(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, unsigned time, float Speed)
|
||
|
{
|
||
|
int ymask = height - 1;
|
||
|
int x, y;
|
||
|
|
||
|
unsigned timebase = unsigned(time * Speed * 40 / 28);
|
||
|
// [mxd] Rewrote to fix animation for NPo2 textures
|
||
|
for (x = 0; x < width; x++)
|
||
|
{
|
||
|
TYPE *dest = Pixels + (x + ymask * x);
|
||
|
for (y = 0; y < height; y++)
|
||
|
{
|
||
|
int xt = (x + 128
|
||
|
+ ((TexMan.sintable[((y*ymul + timebase * 5 + 900) >> 2) & TexMan.SINMASK]) >> 13)
|
||
|
+ ((TexMan.sintable[((x*xmul + timebase * 4 + 300) >> 2) & TexMan.SINMASK]) >> 13)) % width;
|
||
|
|
||
|
int yt = (y + 128
|
||
|
+ ((TexMan.sintable[((y*ymul + timebase * 3 + 700) >> 2) & TexMan.SINMASK]) >> 13)
|
||
|
+ ((TexMan.sintable[((x*xmul + timebase * 4 + 1200) >> 2) & TexMan.SINMASK]) >> 13)) % height;
|
||
|
|
||
|
*dest++ = source[(xt + ymask * xt) + yt];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|