Esempio n. 1
0
        public override void Load(ExtendedBinaryReader reader, bool keepOpen = false)
        {
            string header = reader.ReadNullTerminatedString();

            reader.FixPadding(16);
            uint   textureOffset = reader.ReadUInt32();
            uint   textureCount  = reader.ReadUInt32();
            int    layerOffset   = reader.ReadInt32();
            int    layerCount    = reader.ReadInt32();
            int    unknownOffset = reader.ReadInt32();
            int    unknownCount  = reader.ReadInt32();
            uint   unknown28     = reader.ReadUInt32();
            uint   unknown2C     = reader.ReadUInt32();
            string projectDir    = reader.ReadStringElsewhere();
            uint   unknown34     = reader.ReadUInt32();
            uint   unknown38     = reader.ReadUInt32();
            uint   unknown3C     = reader.ReadUInt32();

            reader.JumpTo(textureOffset);
            for (int i = 0; i < textureCount; ++i)
            {
                Textures.Add(new MATexture(reader));
            }

            reader.JumpTo(layerOffset);
            for (int i = 0; i < layerCount; ++i)
            {
                Layers.Add(new MALayer(reader));
            }
        }
Esempio n. 2
0
            public static object ReadByType(ExtendedBinaryReader reader, ArgumentType type)
            {
                switch (type)
                {
                case AT_Bool:
                    return(reader.ReadBoolean());

                case AT_Byte:
                    return(reader.ReadByte());

                case AT_Int16:
                    return(reader.ReadInt16());

                case AT_Int32:
                    return(reader.ReadInt32());

                case AT_Float:
                    return(reader.ReadSingle());

                case AT_String:
                    return(reader.ReadStringElsewhere());

                case AT_StringPtr:
                    return(reader.ReadNullTerminatedStringPointer());

                case AT_CodePointer:
                    return(reader.ReadInt32());

                case AT_DataReference:
                    return(reader.ReadUInt32());

                case AT_DataBlock:
                    long position = reader.ReadUInt32();
                    long length   = reader.ReadUInt32();
                    if (reader.Offset > position)
                    {
                        reader.Offset = (uint)position;
                    }
                    return(new StreamBlock(position, length));

                default:
                    return(null);
                }
            }
        public override void Load(ExtendedBinaryReader fileReader, bool keepOpen = false)
        {
            // Read STSC
            base.Load(fileReader);

            StreamBlock block;

            // System text
            block = GetStreamBlockAndJump(0, fileReader);
            while (!EndOfBlock(fileReader, block))
            {
                SystemText.Add(fileReader.ReadStringElsewhere());
            }

            // CGs
            block = GetStreamBlockAndJump(1, fileReader);
            while (!EndOfBlock(fileReader, block))
            {
                CGs.Add(fileReader.ReadStruct <CGEntry>());
            }

            // Movies
            block = GetStreamBlockAndJump(2, fileReader);
            while (!EndOfBlock(fileReader, block))
            {
                Movies.Add(fileReader.ReadStruct <MovieEntry>());
            }

            // Memories
            block = GetStreamBlockAndJump(3, fileReader);
            while (!EndOfBlock(fileReader, block))
            {
                Memories.Add(fileReader.ReadStruct <MemoryEntry>());
            }

            // Characters
            block = GetStreamBlockAndJump(4, fileReader);
            while (!EndOfBlock(fileReader, block))
            {
                Characters.Add(fileReader.ReadStruct <CharacterEntry>());
            }

            // Unknown2
            block = GetStreamBlockAndJump(5, fileReader);
            while (!EndOfBlock(fileReader, block))
            {
                Unknown2.Add(fileReader.ReadStruct <Unknown2Entry>());
            }

            // Unknown3
            block = GetStreamBlockAndJump(6, fileReader);
            while (!EndOfBlock(fileReader, block))
            {
                Unknown3.Add(fileReader.ReadStruct <Unknown3Entry>());
            }

            // Voices
            block = GetStreamBlockAndJump(7, fileReader);
            while (!EndOfBlock(fileReader, block))
            {
                Voices.Add(fileReader.ReadStruct <VoiceEntry>());
            }

            // Unknown4
            block = GetStreamBlockAndJump(8, fileReader);
            while (!EndOfBlock(fileReader, block))
            {
                Unknown4.Add(fileReader.ReadStruct <Unknown4Entry>());
            }

            // Older versions may not include art books and drama CDs
            if (Version == 7)
            {
                // Art Book Page
                block = GetStreamBlockAndJump(9, fileReader);
                while (!EndOfBlock(fileReader, block))
                {
                    ArtBookPages.Add(fileReader.ReadStruct <ArtBookPageEntry>());
                }

                // DramaCDs
                block = GetStreamBlockAndJump(10, fileReader);
                while (!EndOfBlock(fileReader, block))
                {
                    DramaCDs.Add(fileReader.ReadStruct <DramaCDEntry>());
                }
            }
        }
Esempio n. 4
0
        public override void Load(ExtendedBinaryReader reader, bool keepOpen = false)
        {
            // Store the current reader
            _internalReader = reader;

            // Filename Section
            //  This section contains an array of addresses to each of the file's name and the strings
            //   itself right after, this section is only used for finding file indices from within game

            //  This is a workaround for reading different versions of PCK files as some files seem to
            //   have smaller padding (0x08 for Signatures, 0x04 for Padding)
            //   while DAL: RR has larger padding (0x14 for Signatures, 0x08 for Padding)
            //  This workaround works by checking the padding in the signature to determine the version
            int  sigSize = reader.CheckDALSignature("Filename");
            bool oldPCK  = false;

            if (sigSize < 0x14)
            {
                oldPCK = true;
            }

            // The length of the Filename section
            int fileNameSectionSize = reader.ReadInt32();
            // Address to the list of filenames
            int fileNameSectionAddress = (int)reader.BaseStream.Position;

            // Jump to the Pack section
            reader.JumpTo(fileNameSectionSize);

            // Makes sure the reader is aligned
            reader.FixPadding(oldPCK ? 0x04u : 0x08u);

            // Pack Section
            //  This section contains an array of file information and then all of it's data

            // Check Signature
            string packSig = reader.ReadDALSignature("Pack");

            if (packSig != "Pack" && packSig.Length <= 4)
            {
                throw new SignatureMismatchException("Pack", packSig);
            }

            // The length of the Pack section
            int packSectionSize = reader.ReadInt32();
            int fileCount       = reader.ReadInt32();

            // Read file entries
            for (int i = 0; i < fileCount; ++i)
            {
                FileEntries.Add(new FileEntry());
                FileEntries[i].DataPosition = reader.ReadInt32();
                FileEntries[i].DataLength   = reader.ReadInt32();
            }

            // Jump back to the Filename section so we can get all of the file names
            reader.JumpTo(fileNameSectionAddress);

            // Reads all the file names
            for (int i = 0; i < fileCount; ++i)
            {
                int position = reader.ReadInt32() + (oldPCK ? 0xC : 0x18);
                FileEntries[i].FileName = reader.ReadStringElsewhere(position);
            }

            // Load all data into memory if the loader plans to close the stream
            if (!keepOpen)
            {
                Preload();
            }
        }
        public void aLoad(Stream fileStream)
        {
            base.Load(fileStream);
            var reader = new ExtendedBinaryReader(fileStream);
            var array  = Instructions[0].GetArgument <byte[]>(1);

            for (int i = 0; i < array.Length / 4; ++i)
            {
                int address = BitConverter.ToInt32(array, i * 4);
                SystemText.Add(reader.ReadStringElsewhere(address));
            }
            array = Instructions[1].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x6C; ++i)
            {
                int nameAddress = BitConverter.ToInt32(array, i * 0x6C);
                var entry       = new CGEntry();
                entry.Name          = reader.ReadStringElsewhere(nameAddress);
                entry.ID            = BitConverter.ToInt32(array, i * 0x6C + 0x0004);
                entry.CGID          = BitConverter.ToInt32(array, i * 0x6C + 0x0008);
                entry.CGID2         = BitConverter.ToInt32(array, i * 0x6C + 0x000C);
                entry.Unknown5      = BitConverter.ToUInt32(array, i * 0x6C + 0x0010);
                entry.Unknown6      = BitConverter.ToUInt16(array, i * 0x6C + 0x0014);
                entry.TextureWidth  = BitConverter.ToInt16(array, i * 0x6C + 0x0016);
                entry.TextureHeight = BitConverter.ToInt16(array, i * 0x6C + 0x0018);
                entry.Unknown7      = BitConverter.ToUInt16(array, i * 0x6C + 0x001A);
                entry.Unknown81     = array[i * 0x6C + 0x001C];
                entry.Unknown82     = array[i * 0x6C + 0x001D];
                entry.Unknown83     = array[i * 0x6C + 0x001E];
                entry.Page          = array[i * 0x6C + 0x001F];
                entry.FrameCount    = array[i * 0x6C + 0x0020];
                entry.GameID        = (GameID)array[i * 0x6C + 0x0021];
                entry.Unknown93     = array[i * 0x6C + 0x0022];
                entry.Unknown94     = array[i * 0x6C + 0x0023];
                entry.Unknown10     = BitConverter.ToUInt32(array, i * 0x6C + 0x0024);
                entry.Unknown11     = BitConverter.ToUInt32(array, i * 0x6C + 0x0028);
                entry.Unknown12     = BitConverter.ToUInt32(array, i * 0x6C + 0x002C);
                entry.Unknown13     = BitConverter.ToUInt32(array, i * 0x6C + 0x0030);
                entry.Unknown14     = BitConverter.ToUInt32(array, i * 0x6C + 0x0034);
                entry.Unknown15     = BitConverter.ToUInt32(array, i * 0x6C + 0x0038);
                entry.Unknown16     = BitConverter.ToUInt32(array, i * 0x6C + 0x003C);
                entry.Unknown17     = BitConverter.ToUInt32(array, i * 0x6C + 0x0040);
                entry.Unknown18     = BitConverter.ToUInt32(array, i * 0x6C + 0x0044);
                entry.Unknown19     = BitConverter.ToUInt32(array, i * 0x6C + 0x0048);
                entry.Unknown20     = BitConverter.ToUInt32(array, i * 0x6C + 0x004C);
                entry.Unknown21     = BitConverter.ToUInt32(array, i * 0x6C + 0x0050);
                entry.Unknown22     = BitConverter.ToUInt32(array, i * 0x6C + 0x0054);
                entry.Unknown23     = BitConverter.ToUInt32(array, i * 0x6C + 0x0058);
                entry.Unknown24     = BitConverter.ToUInt32(array, i * 0x6C + 0x005C);
                entry.Unknown25     = BitConverter.ToUInt32(array, i * 0x6C + 0x0060);
                entry.Unknown26     = BitConverter.ToUInt32(array, i * 0x6C + 0x0064);
                entry.Unknown27     = BitConverter.ToUInt32(array, i * 0x6C + 0x0068);
                CGs.Add(entry);
            }

            array = Instructions[2].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x10; ++i)
            {
                var entry = new MovieEntry();
                entry.FriendlyName = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 0));
                entry.FilePath     = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 4));
                entry.ID           = BitConverter.ToInt32(array, i * 0x10 + 8);
                entry.Unknown4     = array[i * 0x10 + 12];
                entry.GameID       = (GameID)array[i * 0x10 + 13];
                entry.Unknown5     = BitConverter.ToInt16(array, i * 0x10 + 14);
                Movies.Add(entry);
            }

            array = Instructions[3].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x10; ++i)
            {
                var entry = new MemoryEntry();
                entry.Name        = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 0));
                entry.Description = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 4));
                entry.ID          = BitConverter.ToInt32(array, i * 0x10 + 8);
                entry.GameID      = (GameID)array[i * 0x10 + 12];
                entry.Game        = (MemoryEntry.MemoryGame)array[i * 0x10 + 13];
                Memories.Add(entry);
            }

            array = Instructions[4].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x08; ++i)
            {
                var entry = new CharacterEntry();
                entry.FriendlyName = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x08 + 0));
                entry.ID           = BitConverter.ToInt32(array, i * 0x08 + 4);
                Characters.Add(entry);
            }
            array = Instructions[5].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x08; ++i)
            {
                var entry = new Unknown2Entry();
                entry.Unknown1 = BitConverter.ToInt32(array, i * 0x08 + 0);
                entry.Unknown2 = BitConverter.ToInt32(array, i * 0x08 + 4);
                Unknown2.Add(entry);
            }
            array = Instructions[6].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x06; ++i)
            {
                var entry = new Unknown3Entry();
                entry.ID       = BitConverter.ToInt16(array, i * 0x06 + 0);
                entry.Unknown2 = BitConverter.ToInt32(array, i * 0x06 + 2);
                Unknown3.Add(entry);
            }
            array = Instructions[7].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x10; ++i)
            {
                var entry = new VoiceEntry();
                entry.UnknownName  = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 0));
                entry.KnownName    = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 4));
                entry.PreferedName = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 8));
                entry.ID           = BitConverter.ToInt32(array, i * 0x10 + 12);
                Voices.Add(entry);
            }
            array = Instructions[8].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x06; ++i)
            {
                var entry = new Unknown4Entry();
                entry.Unknown1 = BitConverter.ToInt16(array, i * 0x06 + 0);
                entry.Unknown2 = BitConverter.ToInt32(array, i * 0x06 + 2);
                Unknown4.Add(entry);
            }
            array = Instructions[9].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x14; ++i)
            {
                var entry = new ArtBookPageEntry();
                entry.PagePathThumbnail = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x14 + 0));
                entry.PagePathData      = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x14 + 4));
                entry.Name   = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x14 + 8));
                entry.ID     = BitConverter.ToInt32(array, i * 0x14 + 12);
                entry.GameID = (GameID)BitConverter.ToInt16(array, i * 0x14 + 16);
                entry.Page   = BitConverter.ToInt16(array, i * 0x14 + 18);
                ArtBookPages.Add(entry);
            }
            array = Instructions[10].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x1C; ++i)
            {
                var entry = new DramaCDEntry();
                entry.FileName      = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x1C + 0));
                entry.FriendlyName  = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x1C + 4));
                entry.SourceAlbum   = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x1C + 8));
                entry.InternalName  = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x1C + 12));
                entry.ID            = BitConverter.ToInt16(array, i * 0x1C + 16);
                entry.Game          = (GameID)BitConverter.ToInt16(array, i * 0x1C + 18);
                entry.Unknown7      = BitConverter.ToInt16(array, i * 0x1C + 20);
                entry.SourceTrackID = BitConverter.ToInt16(array, i * 0x1C + 22);
                entry.Unknown9      = BitConverter.ToInt16(array, i * 0x1C + 24);
                DramaCDs.Add(entry);
            }

            return;
        }