Beispiel #1
0
        public override void SerializeImpl(SerializerObject s)
        {
            SerializeBlockSize(s);
            if (IsBlockCompressed)
            {
                DecompressedBlockSize = s.Serialize <uint>(DecompressedBlockSize ?? 0, name: nameof(DecompressedBlockSize));
                s.DoEncoded(new ZlibEncoder(CompressedBlockSize.Value, DecompressedBlockSize.Value), () => {
                    BlockSize = s.Serialize <uint>(BlockSize, name: nameof(BlockSize));
                    DecompressedBlockOffset = s.CurrentPointer;
                    SerializeOffsetTable(s);
                    SerializeBlock(s);
                    if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage)
                    {
                        s.Align();
                    }
                    CheckBlockSize(s);
                    // Serialize data from the offset table
                    SerializeOffsetData(s);
                    s.Goto(s.CurrentPointer.file.StartPointer + s.CurrentLength); // no warning
                });
            }
            else
            {
                // GCN blocks don't have offset tables before the block
                if (!IsGCNBlock)
                {
                    SerializeOffsetTable(s);
                }

                // The Shanghai and Milan branches have a local offset table within each block
                if (s.GameSettings.GBA_IsShanghai || s.GameSettings.GBA_IsMilan)
                {
                    ShanghaiOffsetTable = s.SerializeObject <GBA_ShanghaiLocalOffsetTable>(ShanghaiOffsetTable, x => x.Length = GetShanghaiOffsetTableLength, name: nameof(ShanghaiOffsetTable));
                }

                // Serialize the block
                SerializeBlock(s);

                // Align for GCN and Splinter Cell N-Gage
                if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage || IsGCNBlock)
                {
                    s.Align();
                }

                // Verify that we serialized the entire block
                CheckBlockSize(s);

                // Serialize GCN offset table, located after the block data
                if (IsGCNBlock)
                {
                    SerializeOffsetTable(s);
                }

                // Serialize data from the offset table
                SerializeOffsetData(s);
            }
        }
Beispiel #2
0
        public override void SerializeBlock(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion == EngineVersion.GBA_BatmanVengeance)
            {
                Byte_03       = s.Serialize <byte>(Byte_03, name: nameof(Byte_03));
                IsCompressed  = s.Serialize <bool>(IsCompressed, name: nameof(IsCompressed));
                TileMapLength = s.Serialize <ushort>(TileMapLength, name: nameof(TileMapLength));
            }
            else
            {
                TileMapLength = s.Serialize <ushort>(TileMapLength, name: nameof(TileMapLength));
                IsCompressed  = s.Serialize <bool>(IsCompressed, name: nameof(IsCompressed));
                Byte_03       = s.Serialize <byte>(Byte_03, name: nameof(Byte_03));
            }

            if (IsDataCompressed ?? IsCompressed)
            {
                s.DoEncoded(new GBA_LZSSEncoder(), () => TileMap = s.SerializeArray <byte>(TileMap, TileMapLength * 32, name: nameof(TileMap)));
                s.Align();
            }
            else
            {
                TileMap = s.SerializeArray <byte>(TileMap, TileMapLength * 32, name: nameof(TileMap));
            }
        }
        public override void SerializeBlock(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion <= EngineVersion.GBA_BatmanVengeance)
            {
                Is8Bit        = s.Serialize <bool>(Is8Bit, name: nameof(Is8Bit));
                IsCompressed  = s.Serialize <bool>(IsCompressed, name: nameof(IsCompressed));
                TileSetLength = s.Serialize <ushort>(TileSetLength, name: nameof(TileSetLength));
            }
            else
            {
                TileSetLength = s.Serialize <ushort>(TileSetLength, name: nameof(TileSetLength));
                IsCompressed  = s.Serialize <bool>(IsCompressed, name: nameof(IsCompressed));
                Is8Bit        = s.Serialize <bool>(Is8Bit, name: nameof(Is8Bit));
            }

            var tileLength = s.GameSettings.EngineVersion < EngineVersion.GBA_BatmanVengeance && Is8Bit ? 64 : 32;

            if (IsDataCompressed ?? IsCompressed)
            {
                s.DoEncoded(new GBA_LZSSEncoder(), () => TileSet = s.SerializeArray <byte>(TileSet, TileSetLength * tileLength, name: nameof(TileSet)));
                s.Align();
            }
            else
            {
                TileSet = s.SerializeArray <byte>(TileSet, TileSetLength * tileLength, name: nameof(TileSet));
            }
        }
Beispiel #4
0
 private void SerializeOffsetTable(SerializerObject s)
 {
     s.DoAt((IsGCNBlock ? Offset : s.CurrentPointer) + BlockSize, () => {
         // Align
         s.Align();
         // Serialize the offset table
         OffsetTable = s.SerializeObject <GBA_OffsetTable>(OffsetTable, onPreSerialize: ot => ot.Block = this, name: nameof(OffsetTable));
     });
 }
Beispiel #5
0
 public override void SerializeImpl(SerializerObject s)
 {
     SerializeBlockSize(s);
     if (IsBlockCompressed)
     {
         DecompressedBlockSize = s.Serialize <uint>(DecompressedBlockSize ?? 0, name: nameof(DecompressedBlockSize));
         s.DoEncoded(new ZlibEncoder(CompressedBlockSize.Value, DecompressedBlockSize.Value), () => {
             BlockSize = s.Serialize <uint>(BlockSize, name: nameof(BlockSize));
             DecompressedBlockOffset = s.CurrentPointer;
             SerializeOffsetTable(s);
             SerializeBlock(s);
             if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage)
             {
                 s.Align();
             }
             CheckBlockSize(s);
             // Serialize data from the offset table
             SerializeOffsetData(s);
             s.Goto(s.CurrentPointer.file.StartPointer + s.CurrentLength); // no warning
         });
     }
     else
     {
         if (!IsGCNBlock)
         {
             SerializeOffsetTable(s);
         }
         SerializeBlock(s);
         if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage || IsGCNBlock)
         {
             s.Align();
         }
         CheckBlockSize(s);
         if (IsGCNBlock)
         {
             SerializeOffsetTable(s);
         }
         // Serialize data from the offset table
         SerializeOffsetData(s);
     }
 }
Beispiel #6
0
        public override void SerializeImpl(SerializerObject s)
        {
            LUDI_Header = s.SerializeObject <LUDI_BlockIdentifier>(LUDI_Header, name: nameof(LUDI_Header));

            s.Goto(BlockStartPointer);
            SerializeBlock(s);

            if (s.GameSettings.EngineVersion == EngineVersion.GBC_R1_Palm)
            {
                s.Align(baseOffset: BlockStartPointer);
            }
            CheckBlockSize(s);
        }
Beispiel #7
0
 public override void SerializeImpl(SerializerObject s)
 {
     Length = s.Serialize <byte>(Length, name: nameof(Length));
     NormalActorIndicesCount = s.Serialize <byte>(NormalActorIndicesCount, name: nameof(NormalActorIndicesCount));
     if (s.GameSettings.EngineVersion == EngineVersion.GBA_BatmanVengeance)
     {
         Batman_02          = s.Serialize <byte>(Batman_02, name: nameof(Batman_02));
         Batman_03          = s.Serialize <byte>(Batman_03, name: nameof(Batman_03));
         NormalActorIndices = s.SerializeArray <byte>(NormalActorIndices, NormalActorIndicesCount, name: nameof(NormalActorIndices));
         RemainingData      = s.SerializeArray <ushort>(RemainingData, (Length - (s.CurrentPointer - Offset)) / 2, name: nameof(RemainingData));
     }
     else
     {
         BoxTriggerActorIndicesCount = s.Serialize <byte>(BoxTriggerActorIndicesCount, name: nameof(BoxTriggerActorIndicesCount));
         NormalActorIndices          = s.SerializeArray <byte>(NormalActorIndices, NormalActorIndicesCount, name: nameof(NormalActorIndices));
         BoxTriggerActorIndices2     = s.SerializeArray <byte>(BoxTriggerActorIndices2, BoxTriggerActorIndicesCount, name: nameof(BoxTriggerActorIndices2));
         s.Align(2);
         RemainingData = s.SerializeArray <ushort>(RemainingData, (Length - (s.CurrentPointer - Offset)) / 2, name: nameof(RemainingData));
     }
 }
Beispiel #8
0
        public override void SerializeBlock(SerializerObject s)
        {
            Flags               = s.Serialize <byte>(Flags, name: nameof(Flags));
            Byte_01             = s.Serialize <byte>(Byte_01, name: nameof(Byte_01));
            AffineMatricesIndex = s.Serialize <byte>(AffineMatricesIndex, name: nameof(AffineMatricesIndex));
            Byte_03             = s.Serialize <byte>(Byte_03, name: nameof(Byte_03));
            FrameCount          = BitHelpers.ExtractBits(Byte_03, 6, 0);

            LayersPerFrame = s.SerializeArray <byte>(LayersPerFrame, FrameCount, name: nameof(LayersPerFrame));

            s.Align();

            if (Layers == null)
            {
                Layers = new GBA_AnimationChannel[FrameCount][];
            }

            for (int i = 0; i < FrameCount; i++)
            {
                Layers[i] = s.SerializeObjectArray <GBA_AnimationChannel>(Layers[i], LayersPerFrame[i], name: $"{nameof(Layers)}[{i}]");
            }
        }
        public override void SerializeImpl(SerializerObject s)
        {
            Magic                = s.Serialize <uint>(Magic, name: nameof(Magic));
            Block1_Length        = s.Serialize <uint>(Block1_Length, name: nameof(Block1_Length));
            Uint_08              = s.Serialize <uint>(Uint_08, name: nameof(Uint_08));
            Block1_Structs_Count = s.Serialize <uint>(Block1_Structs_Count, name: nameof(Block1_Structs_Count));
            Block0_Structs_Count = s.Serialize <uint>(Block0_Structs_Count, name: nameof(Block0_Structs_Count));
            Block0_Offset        = s.Serialize <uint>(Block0_Offset, name: nameof(Block0_Offset));
            Block1_Offset        = s.Serialize <uint>(Block1_Offset, name: nameof(Block1_Offset));
            Uint_1C              = s.Serialize <uint>(Uint_1C, name: nameof(Uint_1C));

            Block0_Structs = s.DoAt(Offset + Block0_Offset, () => s.SerializeObjectArray <Block0_Struct>(Block0_Structs, Block0_Structs_Count, name: nameof(Block0_Structs)));
            s.DoAt(Offset + Block1_Offset, () =>
            {
                Block1_Byte_00 = s.Serialize <byte>(Block1_Byte_00, name: nameof(Block1_Byte_00));
                Block1_Byte_01 = s.Serialize <byte>(Block1_Byte_01, name: nameof(Block1_Byte_01));
                Block1_Byte_02 = s.Serialize <byte>(Block1_Byte_02, name: nameof(Block1_Byte_02));
                Block1_Byte_03 = s.Serialize <byte>(Block1_Byte_03, name: nameof(Block1_Byte_03));

                Block1_Structs = s.SerializeObjectArray <Block1_Struct>(Block1_Structs, Block1_Structs_Count, name: nameof(Block1_Structs));
                s.Align();
                Block1_Data = s.SerializeArray <byte>(Block1_Data, (Offset + Block1_Offset + Block1_Length * 2) - s.CurrentPointer, name: nameof(Block1_Data));
            });
        }