public bool GetBG2Data(ref byte[] bg2RoomData, ref MetaTileSet bg2MetaTiles) { if (bg2RoomDataAddr != null) { bg2MetaTiles = new MetaTileSet(bg2MetaTilesAddr, false); var data = DataHelper.GetData((AddrData)bg2RoomDataAddr); data.CopyTo(bg2RoomData, 0); return(true); } return(false); }
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 bool GetBG1Data(ref byte[] bg1RoomData, ref MetaTileSet bg1MetaTiles) { if (bg1RoomDataAddr != null) { if (bg1Use20344B0) { DataHelper.GetData((AddrData)bg1RoomDataAddr).CopyTo(bg1RoomData, 0); bg1Use20344B0 = true; } else { bg1MetaTiles = new MetaTileSet(bg1MetaTilesAddr, true); DataHelper.GetData((AddrData)bg1RoomDataAddr).CopyTo(bg1RoomData, 0); } return(true); } return(false); }
public bool GetBG2Data(ref byte[] bg2RoomData, ref MetaTileSet bg2MetaTiles) { if (bg2RoomDataAddr != null) { bg2MetaTiles = new MetaTileSet(bg2MetaTilesAddr, false, areaPath + "/" + DataType.bg2MetaTileSet + "Dat.bin"); byte[] data = null; string bg2Path = roomPath + "/" + DataType.bg2Data + "Dat.bin"; data = Project.Instance.GetSavedData(bg2Path, true); if (data == null) { data = DataHelper.GetData((AddrData)bg2RoomDataAddr); } data.CopyTo(bg2RoomData, 0); return(true); } return(false); }
public bool GetBG1Data(ref byte[] bg1RoomData, ref MetaTileSet bg1MetaTiles) { if (bg1RoomDataAddr != null) { byte[] data = null; string bg1Path = roomPath + "/" + DataType.bg1Data + "Dat.bin"; data = Project.Instance.GetSavedData(bg1Path, true); if (data == null) { data = DataHelper.GetData((AddrData)bg1RoomDataAddr); } if (!bg1Use20344B0) { bg1MetaTiles = new MetaTileSet(bg1MetaTilesAddr, metaTileTypeAddr1, true, areaPath, 1); } data.CopyTo(bg1RoomData, 0); return(!bg1Use20344B0); } return(false); }