public void BlitScreen(bool copyTileData = false) { Profiler.GetInstance().Restart("Vid"); screen.CopyFrameData(LCDMap); if (copyTileData) { var tileMap = new uint[16 * 24 * 8 * 8]; for (int TR = 0; TR < 24; ++TR) { for (int TC = 0; TC < 16; ++TC) { var baseVRAMIndex = (TR * 0x100) + (TC * 0x10); for (int TY = 0; TY < 8; ++TY) { // Index into tilemap is TR * 0x100 + TC * 0x10 + TY * 2 // Index into return is TR * 0x400 + TC * 0x08 + TY * 0x80 var baseReturnIndex = (TR * 0x400) + (TC * 0x08) + (TY * 0x80); int pal = 0; for (int TX = 0; TX < 8; TX++) { pal = GetPixelPaletteNumberFromTile(baseVRAMIndex, TX, TY, false, false); tileMap[baseReturnIndex++] = BGPalette_DMG[pal].Value; } } } } screen.CopyTileData(tileMap); } GBMonitor.BlitTime = Profiler.GetInstance().StopAndGetTimeAsFrameTimePercent("Vid"); }