void ScrollEffect(int dir)
{
var vs = MainVirtScreen;
int step;
var delay = VariableFadeDelay.HasValue ? Variables[VariableFadeDelay.Value] * FadeDelay : PictureDelay;
if ((dir == 0) || (dir == 1))
step = vs.Height;
else
step = vs.Width;
step = (step * delay) / Scrolltime;
int m = _textSurfaceMultiplier;
int vsPitch = vs.Pitch;
switch (dir)
{
case 0:
//up
{
var y = 1 + step;
while (y < vs.Height)
{
if (_townsScreen != null)
{
TownsDrawStripToScreen(vs, 0, vs.TopLine + vs.Height - step, 0, y - step, vs.Width, step);
}
else
{
MoveScreen(0, -step, vs.Height);
var src = vs.Surfaces[0].Pixels;
_gfxManager.CopyRectToScreen(src, vsPitch,
0, y - step,
0, (vs.Height - step) * m,
vs.Width * m, step * m);
_gfxManager.UpdateScreen();
}
WaitForTimer(delay);
y += step;
}
}
break;
case 1:
// down
{
var y = 1 + step;
while (y < vs.Height)
{
MoveScreen(0, step, vs.Height);
if (_townsScreen != null)
{
TownsDrawStripToScreen(vs, 0, vs.TopLine, 0, vs.Height - y, vs.Width, step);
}
else
{
var src = vs.Surfaces[0].Pixels;
_gfxManager.CopyRectToScreen(src,
vsPitch,
0, vs.Height - y,
0, 0,
vs.Width * m, step * m);
_gfxManager.UpdateScreen();
}
WaitForTimer(delay);
y += step;
}
}
break;
case 2:
// left
{
var x = 1 + step;
while (x < vs.Width)
{
MoveScreen(-step, 0, vs.Height);
if (_townsScreen != null)
{
TownsDrawStripToScreen(vs, vs.Width - step, vs.TopLine, x - step, 0, step, vs.Height);
}
else
{
var src = vs.Surfaces[0].Pixels;
_gfxManager.CopyRectToScreen(src,
vsPitch,
x - step, 0,
(vs.Width - step) * m, 0,
step * m, vs.Height * m);
_gfxManager.UpdateScreen();
}
WaitForTimer(delay);
x += step;
}
}
break;
case 3:
// right
{
var x = 1 + step;
while (x < vs.Width)
{
MoveScreen(step, 0, vs.Height);
if (_townsScreen != null)
{
TownsDrawStripToScreen(vs, 0, vs.TopLine, vs.Width - x, 0, step, vs.Height);
}
else
{
var src = vs.Surfaces[0].Pixels;
_gfxManager.CopyRectToScreen(src,
vsPitch,
vs.Width - x, 0,
0, 0,
step, vs.Height);
_gfxManager.UpdateScreen();
}
WaitForTimer(delay);
x += step;
}
}
break;
}
}