private byte NextByte() { if (currentPoint.EOD) { return(0xFF); } int data = _levelDataAccessor.GetData(currentPoint.XPointer, currentPoint.YPointer); currentPoint.XPointer++; if (currentPoint.XPointer >= 0x10 * _level.ScreenLength) { currentPoint.XPointer = 0; currentPoint.YPointer++; if (currentPoint.YPointer >= 27) { currentPoint.EOD = true; } } return((byte)data); }
public void RenderTiles(int blockX = 0, int blockY = 0, int blockWidth = Level.BLOCK_WIDTH, int blockHeight = Level.BLOCK_HEIGHT) { int maxRow = blockY + blockHeight; int maxCol = blockX + blockWidth; if (maxRow > Level.BLOCK_HEIGHT) { maxRow = Level.BLOCK_HEIGHT; } if (maxCol > Level.BLOCK_WIDTH) { maxCol = Level.BLOCK_WIDTH; } for (int row = blockY; row < maxRow; row++) { for (int col = blockX; col < maxCol; col++) { int tileValue = _levelDataAccessor.GetData(col, row); if (tileValue < 0) { continue; } int paletteIndex = (tileValue & 0XC0) >> 6; TileBlock tile = _tileSet.TileBlocks[tileValue]; int x = col * 16, y = row * 16; RenderTile(x, y, _graphicsAccessor.GetRelativeTile(tile.UpperLeft), _buffer, _palette.RgbColors[paletteIndex]); RenderTile(x + 8, y, _graphicsAccessor.GetRelativeTile(tile.UpperRight), _buffer, _palette.RgbColors[paletteIndex]); RenderTile(x, y + 8, _graphicsAccessor.GetRelativeTile(tile.LowerLeft), _buffer, _palette.RgbColors[paletteIndex]); RenderTile(x + 8, y + 8, _graphicsAccessor.GetRelativeTile(tile.LowerRight), _buffer, _palette.RgbColors[paletteIndex]); if (_withTerrainOverlay) { TileTerrain terrain = _terrain.Where(t => t.HasTerrain(tile.Property)).FirstOrDefault(); if (terrain != null) { TileBlockOverlay overlay = terrain.Overlay; if (overlay != null) { RenderTile(x, y, _graphicsAccessor.GetOverlayTile(0, overlay.UpperLeft), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .75); RenderTile(x + 8, y, _graphicsAccessor.GetOverlayTile(0, overlay.UpperRight), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .75); RenderTile(x, y + 8, _graphicsAccessor.GetOverlayTile(0, overlay.LowerLeft), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .75); RenderTile(x + 8, y + 8, _graphicsAccessor.GetOverlayTile(0, overlay.LowerRight), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .75); } } } if (_withInteractionOverlay) { TileInteraction interaction = _terrain.Where(t => t.HasTerrain(tile.Property)).FirstOrDefault()?.Interactions.Where(i => i.HasInteraction(tile.Property)).FirstOrDefault(); if (interaction != null) { TileBlockOverlay overlay = interaction.Overlay; if (overlay != null) { RenderTile(x, y, _graphicsAccessor.GetOverlayTile(0, overlay.UpperLeft), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .85); RenderTile(x + 8, y, _graphicsAccessor.GetOverlayTile(0, overlay.UpperRight), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .85); RenderTile(x, y + 8, _graphicsAccessor.GetOverlayTile(0, overlay.LowerLeft), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .85); RenderTile(x + 8, y + 8, _graphicsAccessor.GetOverlayTile(0, overlay.LowerRight), _buffer, _palette.RgbColors[overlay.PaletteIndex], useTransparency: true, opacity: .85); } } } } } }