public byte[] GetMetaTileData(ref byte[] tileType, int tileNum, int layer) { switch (layer) { case 1: if (!this.bg1Exists) { return(null); } tileType = bg1MetaTiles.GetTileTypeInfo(tileNum); return(bg1MetaTiles.GetTileInfo(tileNum)); case 2: if (!this.bg2Exists) { return(null); } tileType = bg2MetaTiles.GetTileTypeInfo(tileNum); return(bg2MetaTiles.GetTileInfo(tileNum)); default: return(null); } }
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"); } }
public byte[] GetMetaTileData(int tileNum, int layer) { switch (layer) { case 1: return(bg1MetaTiles.GetTileInfo(tileNum)); case 2: return(bg2MetaTiles.GetTileInfo(tileNum)); default: return(null); } }