Ejemplo n.º 1
0
        public override void Read(DataStream strIn)
        {
            DataReader reader = new DataReader(strIn, EndiannessMode.LittleEndian, Encoding.GetEncoding("shift_jis"));
            this.id = reader.ReadUInt32();

            this.startBlocks = new string[4];
            for (int i = 0; i < this.startBlocks.Length; i++) {
                ushort textSize = reader.ReadUInt16();
                this.startBlocks[i] = reader.ReadString(textSize).ApplyTable("replace", false);
            }

            this.unknown = reader.ReadBytes(0x0D);

            byte numEndBlocks = reader.ReadByte();
            this.endBlocks = new string[numEndBlocks];
            for (int i = 0; i < this.endBlocks.Length; i++) {
                ushort size = reader.ReadUInt16();
                this.endBlocks[i] = reader.ReadString(size).ApplyTable("replace", false);
            }

            byte numUnknown = reader.ReadByte();
            this.unknown2 = new byte[numUnknown][];
            for (int i = 0; i < this.unknown2.Length; i++) {
                byte dataSize = reader.ReadByte();
                this.unknown2[i] = reader.ReadBytes(dataSize + 4);
            }
        }
Ejemplo n.º 2
0
        public override void Read(DataStream strIn)
        {
            DataReader reader = new DataReader(strIn, EndiannessMode.LittleEndian, Encoding.GetEncoding("shift_jis"));

            ushort numBlocks = reader.ReadUInt16();
            this.blocks = new Block[numBlocks];
            for (int i = 0; i < numBlocks; i++) {
                reader.ReadUInt16();	// Block size

                this.blocks[i]    = new Block();
                this.blocks[i].Id = reader.ReadUInt32();
                this.blocks[i].Elements = new string[3];
                for (int j = 0; j < 3; j++)
                    this.blocks[i].Elements[j] = reader.ReadString(typeof(ushort), "replace", false);

                reader.ReadByte();	// 0x00
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Read a the header from a NDS game ROM.
        /// </summary>
        /// <param name="str">Stream with the ROM. Must be at the correct position.</param>
        public override void Read(DataStream str)
        {
            long startPosition = str.Position;
            DataReader dr = new DataReader(str);

            this.gameTitle        = dr.ReadChars(12);
            this.gameCode         = dr.ReadChars(4);
            this.makerCode        = dr.ReadChars(2);
            this.unitCode         = dr.ReadByte();
            this.encryptionSeed   = dr.ReadByte();
            this.cartridgeSize    = (uint)(1 << (MinCartridge + dr.ReadByte()));
            this.reserved         = dr.ReadBytes(9);
            this.RomVersion       = dr.ReadByte();
            this.internalFlags    = dr.ReadByte();
            this.Arm9Offset       = dr.ReadUInt32();
            this.Arm9EntryAddress = dr.ReadUInt32();
            this.Arm9RamAddress   = dr.ReadUInt32();
            this.Arm9Size         = dr.ReadUInt32();
            this.Arm7Offset       = dr.ReadUInt32();
            this.Arm7EntryAddress = dr.ReadUInt32();
            this.Arm7RamAddress   = dr.ReadUInt32();
            this.Arm7Size         = dr.ReadUInt32();
            this.fntOffset        = dr.ReadUInt32();
            this.fntSize          = dr.ReadUInt32();
            this.FatOffset        = dr.ReadUInt32();
            this.FatSize          = dr.ReadUInt32();
            this.Ov9TableOffset   = dr.ReadUInt32();
            this.Ov9TableSize     = dr.ReadUInt32();
            this.Ov7TableOffset   = dr.ReadUInt32();
            this.Ov7TableSize     = dr.ReadUInt32();
            this.flagsRead        = dr.ReadUInt32();
            this.flagsInit        = dr.ReadUInt32();
            this.bannerOffset     = dr.ReadUInt32();
            this.secureCRC16      = dr.ReadUInt16();
            this.RomTimeout       = dr.ReadUInt16();
            this.Arm9Autoload     = dr.ReadUInt32();
            this.Arm7Autoload     = dr.ReadUInt32();
            this.secureDisable    = dr.ReadUInt64();
            this.RomSize          = dr.ReadUInt32();
            this.headerSize       = dr.ReadUInt32();
            this.reserved2        = dr.ReadBytes(56);
            this.nintendoLogo     = dr.ReadBytes(156);
            this.logoCRC16        = dr.ReadUInt16();
            this.headerCRC16      = dr.ReadUInt16();
            this.debugRomOffset   = dr.ReadUInt32();
            this.debugSize        = dr.ReadUInt32();
            this.debugRamAddress  = dr.ReadUInt32();
            this.reserved3        = dr.ReadUInt32();

            int unknownSize = (int)(this.headerSize - (str.Position - startPosition));
            this.unknown    = dr.ReadBytes(unknownSize);
        }
Ejemplo n.º 4
0
            public override void Read(DataStream stream)
            {
                base.Read(stream);

                DataReader reader = new DataReader(
                    stream,
                    EndiannessMode.LittleEndian,
                    Encoding.GetEncoding("shift_jis"));

                reader.ReadByte();	// Entry length
                int numSubEntries = reader.ReadByte();

                this.SubEntries = new SubEntry[numSubEntries];
                for (int i = 0; i < numSubEntries; i++) {
                    this.SubEntries[i] = new SubEntry();
                    byte len = reader.ReadByte();
                    this.SubEntries[i].ScriptName = reader.ReadString(len);
                    this.SubEntries[i].Unknown = reader.ReadUInt16();
                }
            }
Ejemplo n.º 5
0
            public override void Read(DataStream stream)
            {
                base.Read(stream);

                DataReader reader = new DataReader(
                    stream,
                    EndiannessMode.LittleEndian,
                    Encoding.GetEncoding("shift_jis"));

                byte textSize = reader.ReadByte();
                this.Text = reader.ReadString(textSize);
                this.Unknown = reader.ReadUInt16();
            }
Ejemplo n.º 6
0
            public override void Read(DataStream stream)
            {
                base.Read(stream);

                DataReader reader = new DataReader(
                                        stream,
                                        EndiannessMode.LittleEndian,
                                        Encoding.GetEncoding("shift_jis"));

                byte textSize = reader.ReadByte();
                this.Text = reader.ReadString(textSize).ApplyTable("replace", false);
                this.Text = GetFurigana(this.Text);
            }
Ejemplo n.º 7
0
            public void Read(DataStream str)
            {
                DataReader dr = new DataReader(str, EndiannessMode.LittleEndian, DefaultEncoding);

                byte nodeType = dr.ReadByte();
                ushort fileId = this.IdFirstFile;

                int nameLength;
                string name;

                // Read until the end of the subtable (reachs 0x00)
                while (nodeType != 0x0) {
                    // If the node is a file.
                    if (nodeType < 0x80) {
                        nameLength = nodeType;
                        name = dr.ReadString(nameLength);

                        this.AddFileInfo(name, fileId++);
                    } else {
                        nameLength = nodeType - 0x80;
                        name = dr.ReadString(nameLength);
                        ushort folderId = dr.ReadUInt16();

                        this.AddFolderInfo(name, folderId);
                    }

                    nodeType = dr.ReadByte();
                }
            }