コード例 #1
0
 public void DrawTile(ref Bitmap b, Point p, int areaIndex, int layer, int tileNum)
 {
     if (layer == 1)
     {
         bg1MetaTiles.DrawMetaTile(ref b, p, tset, pset, tileNum, true);
     }
     if (layer == 2)
     {
         bg2MetaTiles.DrawMetaTile(ref b, p, tset, pset, tileNum, true);
     }
 }
コード例 #2
0
        private void DrawLayer(ref Bitmap b, int areaIndex, MetaTileSet metaTiles, byte[] roomData, bool overwrite)
        {
            int pos = 0;             //position in roomData

            ushort[] chunks    = new ushort[3];
            ushort[] oldchunks = new ushort[3];
            chunks = new ushort[3] {
                0x00FF, 0x00FF, 0x00FF
            };
            int badTiles = 0;

            for (int j = 0; j < metadata.TileHeight; j++)
            {
                for (int i = 0; i < metadata.TileWidth; i++)
                {
                    //hardcoded because there is no easy way to determine which areas use tileswapping
                    if (Index == 00 && areaIndex == 01 || areaIndex == 02 || areaIndex == 0x15)
                    {
                        oldchunks = chunks;
                        chunks    = GetChunks(areaIndex, (ushort)(i * 16), (ushort)(j * 16));

                        SwapTiles(areaIndex, oldchunks, chunks, (ushort)(i * 16), (ushort)(j * 16));
                    }
                    //which metatile to draw
                    int mt = roomData[pos] | (roomData[pos + 1] << 8);

                    pos += 2;                     //2 bytes per tile
                    if (metaTiles.GetTileInfo(mt) == null)
                    {
                        badTiles++;
                        continue;
                    }
                    try
                    {
                        if (mt != 0xFFFF)                          //nonexistant room data does this, eg. area 0D room 10
                        {
                            metaTiles.DrawMetaTile(ref b, new Point(i * 16, j * 16), tset, pset, mt, overwrite);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Error drawing metatile. i:" + i.ToString() + ", j:" + j.ToString()
                                            + "\n" + e.Message, e);
                    }
                }
            }
            if (badTiles > 0)
            {
                MainWindow.Notify("Found " + badTiles + " bad tiles while trying to draw them, the room may be unused.", "Bad Tiles");
            }
        }