Esempio n. 1
0
        public STRM(Stream mainStream)
        {
            var sections = new SectionedFile(mainStream, "STRM");

            readHEAD(sections.Open("HEAD"));
            dataStream = sections.Open("DATA");
        }
Esempio n. 2
0
        public void Load(Stream stream)
        {
            var sections = new SectionedFile(stream);

            if (sections.MainId != "RLCN")
            {
                throw new InvalidDataException();
            }
            var section = sections.Open("TTLP");

            using (var r = new BinaryReader(section)) {
                var format   = r.ReadUInt32();            //format
                var extPal   = r.ReadUInt32();            //extpal used
                var byteSize = r.ReadUInt32();
                var pointer  = r.ReadUInt32();

                int paletteLength = (int)(byteSize / BGR555.DataSize);

                stream.Position = pointer;

                var pal = new List <BGR555>(paletteLength);
                for (int colorIndex = 0; colorIndex < paletteLength; ++colorIndex)
                {
                    pal.Add(r.ReadBGR555());
                }
                Palette = new Palette(pal);
            }
        }
Esempio n. 3
0
        private void parseData(SectionedFile sections)
        {
            uint instrumentCount;

            var section    = sections.FindSection("DATA");
            var baseStream = sections.Open(section);

            using (var r = new BinaryReader(new SubStream(baseStream, 0))) {
                r.Skip(8 * 4);
                instrumentCount = r.ReadUInt32();

                instruments = new List <Instrument>((int)instrumentCount);
                for (int instrumentIndex = 0; instrumentIndex < instrumentCount; ++instrumentIndex)
                {
                    byte instrumentType = r.ReadByte();
                    long offset         = r.Read3ByteUInt();
                    //for some inane reason, everything is offset from the start of the file, not the section
                    offset -= section.position;

                    if (instrumentType == 0)
                    {
                        instruments.Add(null);
                        continue;
                    }

                    var instrument = Instrument.parseRecord(instrumentType, new SubStream(baseStream, offset));
                    instruments.Add(instrument);
                }
            }
        }
Esempio n. 4
0
        public NSCR(Stream stream)
        {
            var sections = new SectionedFile(stream);

            if (sections.MainId != "RCSN")
            {
                throw new InvalidDataException("Bad signature");
            }

            using (var r = new BinaryReader(sections.Open("NRCS"))) {
                int WidthPixels = r.ReadUInt16();
                int HeightPixel = r.ReadUInt16();

                if ((WidthPixels % Tile.Width) != 0)
                {
                    throw new InvalidDataException("Width not an even multipiel");
                }
                if ((WidthPixels % Tile.Height) != 0)
                {
                    throw new InvalidDataException("Height not an even multipiel");
                }

                var colorMode = (ColorMode)r.ReadUInt16();
                Format = (TileMapFormat)r.ReadUInt16();

                var WidthTiles  = WidthPixels / Tile.Width;
                var HeightTiles = HeightPixel / Tile.Height;

                TileMap = new TilemapEntry[HeightTiles, WidthTiles];

                var dataSize = r.ReadUInt32();
                LoadMap(r);
            }
        }
Esempio n. 5
0
        private void Load(Stream stream)
        {
            var sections = new SectionedFile(stream);

            if (sections.MainId != "RGCN")
            {
                throw new InvalidDataException();
            }
            ParseRAHC(sections.Open("RAHC"));
        }
Esempio n. 6
0
        public NCER(Stream stream)
        {
            var sections = new SectionedFile(stream);

            if (sections.MainId != "RECN")
            {
                throw new InvalidDataException("Bad signature");
            }

            parseCellBank(sections.Open("KBEC"));
        }
Esempio n. 7
0
        private void Load(Stream stream)
        {
            var sections = new SectionedFile(stream);

            if (sections.MainId != "RNAN")
            {
                throw new InvalidDataException();
            }
            using (var r = new BinaryReader(sections.Open("KNBA"))) {
                LoadKNBA(r);
            }
        }
Esempio n. 8
0
        private void ParseData(SectionedFile sections)
        {
            var          section       = sections.FindSection("DATA");
            var          sectionStream = sections.Open(section);
            BinaryReader reader        = new BinaryReader(sectionStream);

            //for some inane reason it's prefixed with the offset into the file for the data itself
            long offset = reader.ReadUInt32();

            offset -= section.position;

            var commandStream = new SubStream(sectionStream, offset);

            var parser = new SequenceParser(commandStream);

            sequence = parser.Parse();
        }
Esempio n. 9
0
        private void parseData(SectionedFile sections)
        {
            var section    = sections["DATA"];
            var baseStream = sections.Open(section);

            using (var r = new BinaryReader(new SubStream(baseStream, 0))) {
                r.Skip(8 * 4);
                uint waveCount = r.ReadUInt32();

                waves = new List <Wave>((int)waveCount);

                for (uint waveIndex = 0; waveIndex < waveCount; ++waveIndex)
                {
                    long offset = r.ReadUInt32();
                    //for some inane reason the pointer is relative to the start of the file
                    offset -= section.position;
                    var wave = new Wave(new SubStream(baseStream, offset));
                    waves.Add(wave);
                }
            }
        }