internal void MarkRectAsDirty(VirtScreen vs, int left, int right, int top, int bottom, int dirtybit = 0)
{
int lp, rp;
if (left > right || top > bottom)
return;
if (top > vs.Height || bottom < 0)
return;
if (top < 0)
top = 0;
if (bottom > vs.Height)
bottom = vs.Height;
if (vs == MainVirtScreen && dirtybit != 0)
{
lp = left / 8 + _screenStartStrip;
if (lp < 0)
lp = 0;
rp = (right + vs.XStart) / 8;
if (_game.Version >= 7)
{
if (rp > 409)
rp = 409;
}
else
{
if (rp >= 200)
rp = 200;
}
for (; lp <= rp; lp++)
Gdi.SetGfxUsageBit(lp, dirtybit);
}
// The following code used to be in the separate method setVirtscreenDirty
lp = left / 8;
rp = right / 8;
if ((lp >= Gdi.NumStrips) || (rp < 0))
return;
if (lp < 0)
lp = 0;
if (rp >= Gdi.NumStrips)
rp = Gdi.NumStrips - 1;
while (lp <= rp)
{
if (top < vs.TDirty[lp])
vs.TDirty[lp] = top;
if (bottom > vs.BDirty[lp])
vs.BDirty[lp] = bottom;
lp++;
}
}