예제 #1
0
파일: LBD.cs 프로젝트: Figglewatts/libLSD
        /// <summary>
        /// Read an LBD file from a binary stream.
        /// </summary>
        /// <param name="br">The binary stream.</param>
        public LBD(BinaryReader br)
        {
            Header = new LBDHeader(br);

            TileLayout = new LBDTile[Header.TileWidth, Header.TileHeight];
            for (int y = 0; y < Header.TileHeight; y++)
            {
                for (int x = 0; x < Header.TileWidth; x++)
                {
                    TileLayout[x, y] = new LBDTile(br, Header.AddressOffset, Header.ExtraTilesOffset);
                }
            }

            ExtraTiles = new LBDTile[Header.NumberOfExtraTiles];
            for (int i = 0; i < Header.NumberOfExtraTiles; i++)
            {
                ExtraTiles[i] = new LBDTile(br, Header.AddressOffset, Header.ExtraTilesOffset);
            }

            br.BaseStream.Seek(Header.TilesTMDOffset + Header.AddressOffset, SeekOrigin.Begin);
            Tiles = new TMD(br);

            MML = null;
            if (Header.HasMML)
            {
                br.BaseStream.Seek(Header.MMLOffset, SeekOrigin.Begin);
                MML = new MML(br);
            }
        }
예제 #2
0
        /// <summary>
        /// Create a new MOM file by reading from a binary stream.
        /// </summary>
        /// <param name="br">The binary stream.</param>
        /// <exception cref="BadFormatException">If the MOM file did not have the correct ID.</exception>
        public MOM(BinaryReader br)
        {
            _momTop = (uint)br.BaseStream.Position;

            ID = br.ReadUInt32();
            if (ID != MAGIC_NUMBER)
            {
                throw new BadFormatException("MOM file did not have correct magic number!");
            }

            MOMLength = br.ReadUInt32();
            TMDOffset = br.ReadUInt32();
            MOS       = new MOS(br);

            br.BaseStream.Seek(_momTop + TMDOffset, SeekOrigin.Begin);
            TMD = new TMD(br);
        }