public void DebugDrawObjs(DirectBitmap image) { int objIndex = 0; int originX = 32, originY = 32; // Render 8 sprites per row // 16 x 8 sprites for (int sy = 0; sy < 8; sy++) { for (int sx = 0; sx < 16; sx++) { Obj obj = Obj[objIndex++]; for (int y = 0; y < obj.Attributes.Dimensions.Height; y++) { for (int x = 0; x < obj.Attributes.Dimensions.Width; x++) { int paletteIndex = obj.PixelValue(x, y); if (paletteIndex == 0) { continue; } image.SetPixel(originX + (sx * 64) + x, originY + (sy * 64) + y, gba.LcdController.Palettes.Palette1[paletteIndex]); } } } } // Draw 64x64 pixel grid GfxHelpers.DrawGrid(image.Bitmap, Color.FromArgb(64, 0, 0, 0), 32, 32, 16, 8, 64, 64); // Draw a second 8x8 pixel grid GfxHelpers.DrawGrid(image.Bitmap, Color.FromArgb(64, 200, 0, 0), 32, 32, 128, 64, 8, 8); }
public void Dump(bool renderViewPortBox) { var image = new DirectBitmap(WidthInPixels(), HeightInPixels()); DebugRenderFull(image); if (renderViewPortBox) { GfxHelpers.DrawViewportBox(image.Bitmap, ScrollX, ScrollY, WidthInPixels(), HeightInPixels()); } image.Bitmap.Save(string.Format("../../../../dump/Bg{0}.png", BgNumber)); }
// Code to dump both BG and Obj tiles. Quite a complex list of parameters in order to make it work for both public void DebugDrawTiles(DirectBitmap image, byte[] vram, int vramBaseOffset, Color[] palette, bool eightBitColour, Func <int, int> getTile4BitPaletteNumber) { int tileCountX = 32; int tileCountY = 32; int tileX = 0; int tileY = 0; int tileSize = eightBitColour ? LcdController.Tile_Size_8bit: LcdController.Tile_Size_4bit; int totalTiles = eightBitColour ? 512 : 1024; for (int tileNumber = 0; tileNumber < totalTiles; tileNumber++) { int tileVramOffset = vramBaseOffset + (tileNumber * tileSize); int paletteOffset = 0; if (eightBitColour == false && getTile4BitPaletteNumber != null) { paletteOffset = getTile4BitPaletteNumber(tileNumber); } // Add one tiles pixels for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { int paletteIndex = TileHelpers.GetTilePixel(x, y, eightBitColour, vram, tileVramOffset, false, false); // 0 == transparent / pal 0 int colIndex = (paletteIndex == 0 ? 0 : paletteOffset + paletteIndex); image.SetPixel(x + (tileX * 8), y + (tileY * 8), palette[colIndex]); } } // Coordinates on the output image tileX++; if (tileX == tileCountX) { tileX = 0; tileY++; } } bool drawGrid = true; if (drawGrid) { GfxHelpers.DrawGrid(image.Bitmap, Color.FromArgb(64, 0, 0, 0), 0, 0, tileCountX, tileCountY, 8, 8); } }