private void RenderTileDataPixel(byte[] currentTileData, SpriteDataFlags flags, int outputX, int localX) { if (_device.GbcMode) { // TODO: support other flags. int actualX = localX & 7; // Horizontal flip when specified. if ((flags & SpriteDataFlags.XFlip) != 0) { actualX = 7 - actualX; } if (LY == 0) { } int paletteIndex = (int)(flags & SpriteDataFlags.PaletteNumberMask); int colorIndex = GetPixelColorIndex(actualX, currentTileData); RenderPixel(outputX, LY, colorIndex, GetGbcColor(_bgPaletteMemory, paletteIndex, colorIndex)); } else { int colorIndex = GetPixelColorIndex(localX & 7, currentTileData); int greyshadeIndex = GetGreyshadeIndex(Bgp, colorIndex); RenderPixel(outputX, LY, colorIndex, _greyshades[greyshadeIndex]); } }
private void CopyTileData(int tileMapAddress, int tileIndex, int tileDataAddress, byte[] buffer, SpriteDataFlags flags) { byte dataIndex = _vram[(ushort)(tileMapAddress + tileIndex)]; if ((_lcdc & LcdControlFlags.BgWindowTileDataSelect) != LcdControlFlags.BgWindowTileDataSelect) { // Index is signed number in [-128..127] => compensate for it. dataIndex = unchecked ((byte)((sbyte)dataIndex + 0x80)); } int bankOffset = ((flags & SpriteDataFlags.TileVramBank) != 0) ? 0x2000 : 0x0000; Buffer.BlockCopy(_vram, bankOffset + tileDataAddress + (dataIndex << 4), buffer, 0, 2); }