Fix and improve background drawing code

This commit is contained in:
nukeykt 2019-10-29 23:39:24 +09:00 committed by Christoph Oelckers
parent 308f36d0e8
commit 308885d92c

View file

@ -200,6 +200,8 @@ void FlushMessageLine()
void RefreshBackground() void RefreshBackground()
{ {
if (screensize <= 0)
return;
int nTileOffset = 0; int nTileOffset = 0;
int tileX = tilesiz[nBackgroundPic].x; int tileX = tilesiz[nBackgroundPic].x;
int tileY = tilesiz[nBackgroundPic].y; int tileY = tilesiz[nBackgroundPic].y;
@ -208,17 +210,40 @@ void RefreshBackground()
MaskStatus(); MaskStatus();
for (int y = 0; y < ydim; y += tileY) for (int y = 0; y < nViewTop; y += tileY)
{ {
nTileOffset = (y/tileY)&1;
for (int x = 0; x < xdim; x += tileX) for (int x = 0; x < xdim; x += tileX)
{ {
overwritesprite(x, y, nBackgroundPic + nTileOffset, -32, 0, kPalNormal); rotatesprite(x<<16, y<<16, 65536L, 0, nBackgroundPic + nTileOffset, -32, kPalNormal, 8 + 16 + 64, 0, 0, xdim-1, nViewTop-1);
if (nTileOffset == 0) { nTileOffset ^= 1;
nTileOffset = 1; }
} }
else { for (int y = (nViewTop/tileY)*tileY; y <= nViewBottom; y += tileY)
nTileOffset = 0; {
} nTileOffset = (y/tileY)&1;
for (int x = 0; x < nViewLeft; x += tileX)
{
rotatesprite(x<<16, y<<16, 65536L, 0, nBackgroundPic + nTileOffset, -32, kPalNormal, 8 + 16 + 64, 0, nViewTop, nViewLeft-1, nViewBottom);
nTileOffset ^= 1;
}
}
for (int y = (nViewTop/tileY)*tileY; y <= nViewBottom; y += tileY)
{
nTileOffset = ((y/tileY)^((nViewRight+1)/tileX))&1;
for (int x = ((nViewRight+1)/tileX)*tileX; x < xdim; x += tileX)
{
rotatesprite(x<<16, y<<16, 65536L, 0, nBackgroundPic + nTileOffset, -32, kPalNormal, 8 + 16 + 64, nViewRight+1, nViewTop, xdim-1, nViewBottom);
nTileOffset ^= 1;
}
}
for (int y = ((nViewBottom+1)/tileY)*tileY; y < ydim; y += tileY)
{
nTileOffset = (y/tileY)&1;
for (int x = 0; x < xdim; x += tileX)
{
rotatesprite(x<<16, y<<16, 65536L, 0, nBackgroundPic + nTileOffset, -32, kPalNormal, 8 + 16 + 64, 0, nViewBottom+1, xdim-1, ydim-1);
nTileOffset ^= 1;
} }
} }