public override void SerializeBlock(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion <= EngineVersion.GBA_BatmanVengeance && !s.GameSettings.GBA_IsMilan)
            {
                if (s.GameSettings.GBA_IsShanghai)
                {
                    s.Goto(ShanghaiOffsetTable.GetPointer(0));
                }

                Length    = s.Serialize <ushort>(Length, name: nameof(Length));
                PalOffset = s.Serialize <ushort>(PalOffset, name: nameof(PalOffset));

                if (s.GameSettings.GBA_IsShanghai)
                {
                    s.Goto(ShanghaiOffsetTable.GetPointer(1));
                }

                Palette = s.SerializeObjectArray <RGBA5551Color>((RGBA5551Color[])Palette, Length, name: nameof(Palette));
            }
            else if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage)
            {
                Palette = s.SerializeObjectArray <BGRA4441Color>((BGRA4441Color[])Palette, BlockSize / 2, name: nameof(Palette));
            }
            else
            {
                Palette = s.SerializeObjectArray <RGBA5551Color>((RGBA5551Color[])Palette, BlockSize / 2, name: nameof(Palette));
            }
        }
Exemple #2
0
        public override void SerializeBlock(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion == EngineVersion.GBC_R1_PocketPC)
            {
                FileOffsets = s.SerializeArraySize <uint, uint>(FileOffsets, name: nameof(FileOffsets));
                FileOffsets = s.SerializeArray <uint>(FileOffsets, FileOffsets.Length, name: nameof(FileOffsets));
                if (Files == null)
                {
                    Files = new SoundFile_PPC[FileOffsets.Length];
                }
                for (int i = 0; i < FileOffsets.Length; i++)
                {
                    if (FileOffsets[i] == 0)
                    {
                        continue;
                    }
                    s.Goto(BlockStartPointer + FileOffsets[i]);
                    Files[i] = s.SerializeObject <SoundFile_PPC>(Files[i], name: $"{nameof(Files)}[{i}]");
                }
            }
            else
            {
                DataOffsetsOffset  = s.Serialize <ushort>(DataOffsetsOffset, name: nameof(DataOffsetsOffset));
                UShort_02          = s.Serialize <ushort>(UShort_02, name: nameof(UShort_02));
                SoundIDOffsetCount = s.Serialize <ushort>(SoundIDOffsetCount, name: nameof(SoundIDOffsetCount));
                SoundOffsetCount   = s.Serialize <ushort>(SoundOffsetCount, name: nameof(SoundOffsetCount));

                s.DoAt(BlockStartPointer + DataOffsetsOffset, () => {
                    SoundIDOffsets = s.SerializeArray <ushort>(SoundIDOffsets, SoundIDOffsetCount, name: nameof(SoundIDOffsets));
                    SoundOffsets   = s.SerializeArray <ushort>(SoundOffsets, SoundOffsetCount, name: nameof(SoundOffsets));
                });
                if (SoundIDs == null)
                {
                    SoundIDs = new SoundID[SoundIDOffsetCount];
                }
                if (Sounds == null)
                {
                    Sounds = new Sound[SoundOffsetCount];
                }
                for (int i = 0; i < SoundIDs.Length; i++)
                {
                    s.Goto(BlockStartPointer + SoundIDOffsets[i]);
                    SoundIDs[i] = s.SerializeObject <SoundID>(SoundIDs[i], name: $"{nameof(SoundIDs)}[{i}]");
                }
                for (int i = 0; i < Sounds.Length; i++)
                {
                    int nextOff = i < Sounds.Length - 1 ? SoundOffsets[i + 1] : (int)BlockSize;
                    int length  = nextOff - SoundOffsets[i];
                    s.Goto(BlockStartPointer + SoundOffsets[i]);
                    Sounds[i] = s.SerializeObject <Sound>(Sounds[i], onPreSerialize: d => d.Length = length, name: $"{nameof(Sounds)}[{i}]");
                    if (Sounds[i].SoundProgramID.HasValue)
                    {
                        Sounds[i].SoundProgram = s.DoAt(DependencyTable.GetPointer(Sounds[i].SoundProgramID.Value - 1), () => {
                            return(s.SerializeObject <GBC_SoundProgram>(Sounds[i].SoundProgram, name: nameof(Sound.SoundProgram)));
                        });
                    }
                }
            }
        }
        public override void SerializeBlock(SerializerObject s)
        {
            s.Goto(ShanghaiOffsetTable.GetPointer(0));
            ActorsCount = s.Serialize <uint>(ActorsCount, name: nameof(ActorsCount));

            s.Goto(ShanghaiOffsetTable.GetPointer(1));
            Actors = s.SerializeObjectArray <GBA_Actor>(Actors, ActorsCount, x => x.Type = IsCaptor ? GBA_Actor.ActorType.Captor : GBA_Actor.ActorType.Actor, name: nameof(Actors));
        }
        }                                                  // TODO: What is this?

        public override void SerializeImpl(SerializerObject s)
        {
            Unknown1Offset = s.Serialize <ushort>(Unknown1Offset, name: nameof(Unknown1Offset));
            Unknown2Offset = s.Serialize <ushort>(Unknown2Offset, name: nameof(Unknown2Offset));
            ActionsCount   = s.Serialize <byte>(ActionsCount, name: nameof(ActionsCount));

            Actions = s.SerializeObjectArray <GBC_Action>(Actions, ActionsCount, name: nameof(Actions));

            s.DoAt(Offset + Unknown1Offset, () =>
            {
                Data1Offsets = s.SerializeArray <ushort>(Data1Offsets, ActionsCount, name: nameof(Data1Offsets));

                if (ActionData1 == null)
                {
                    ActionData1 = new GBC_ActionData1[ActionsCount];
                }

                for (int i = 0; i < Data1Offsets.Length; i++)
                {
                    if (Data1Offsets[i] != 0)
                    {
                        ActionData1[i] = s.DoAt(Offset + Data1Offsets[i], () => s.SerializeObject <GBC_ActionData1>(ActionData1[i], name: $"{nameof(ActionData1)}[{i}]"));
                    }
                }
            });

            s.Goto(Offset + Unknown2Offset);
            ActionData2 = s.SerializeObjectArray <GBC_ActionData2>(ActionData2, ActionsCount, name: nameof(ActionData2));
        }
Exemple #5
0
        public override void SerializeBlock(SerializerObject s)
        {
            s.SerializeBitValues <byte>(bitFunc => {
                IsObjAnimation = bitFunc(IsObjAnimation ? 1 : 0, 1, name: nameof(IsObjAnimation)) == 1;
                Batman_Byte00  = (byte)bitFunc(Batman_Byte00, 7, name: nameof(Batman_Byte00));
            });

            Index_Palette   = s.Serialize <byte>(Index_Palette, name: nameof(Index_Palette));
            AnimationsCount = s.Serialize <byte>(AnimationsCount, name: nameof(AnimationsCount));
            Index_TileSet   = s.Serialize <byte>(Index_TileSet, name: nameof(Index_TileSet));

            if (s.GameSettings.EngineVersion < EngineVersion.GBA_BatmanVengeance)
            {
                TilemapWidth  = s.Serialize <byte>(TilemapWidth, name: nameof(TilemapWidth));
                TilemapHeight = s.Serialize <byte>(TilemapHeight, name: nameof(TilemapHeight));
                Padding       = s.SerializeArray <byte>(Padding, 2, name: nameof(Padding));
            }
            var animOffsetsBase = s.CurrentPointer;

            AnimationOffsets = s.SerializeArray <uint>(AnimationOffsets, AnimationsCount, name: nameof(AnimationOffsets));

            if (Animations == null)
            {
                Animations = new GBA_BatmanVengeance_Animation[AnimationOffsets.Length];
            }
            BlockEndPointer = Offset + BlockSize;
            for (int i = 0; i < AnimationOffsets.Length; i++)
            {
                Animations[i] = s.DoAt(animOffsetsBase + AnimationOffsets[i], () => s.SerializeObject <GBA_BatmanVengeance_Animation>(Animations[i], onPreSerialize: a => a.Puppet = this, name: $"{nameof(Animations)}[{i}]"));
            }

            s.Goto(Offset + BlockSize);
        }
    public override void SerializeImpl(SerializerObject s)
    {
        SlotDesc = s.SerializeObject <RRR_SavSlotDesc>(SlotDesc, name: nameof(SlotDesc));
        long pos = s.CurrentFileOffset;

        Univers = s.SerializeObject <RRR_UniversSave>(Univers, name: nameof(Univers));
        s.Goto(new Pointer(pos + 0x11440, Offset.File));
    }
    public override void SerializeImpl(SerializerObject s)
    {
        MaxFile    = s.Serialize <uint>(MaxFile, name: nameof(MaxFile));
        MaxDir     = s.Serialize <uint>(MaxDir, name: nameof(MaxDir));
        PosFat     = s.Serialize <uint>(PosFat, name: nameof(PosFat));
        NextPosFat = s.Serialize <int>(NextPosFat, name: nameof(NextPosFat));
        FirstIndex = s.Serialize <uint>(FirstIndex, name: nameof(FirstIndex));
        LastIndex  = s.Serialize <uint>(LastIndex, name: nameof(LastIndex));

        s.Goto(new Pointer(PosFat, Offset.File));
        Files = s.SerializeObjectArray <FileReference>(Files, (int)MaxFile, name: nameof(Files));

        if (NextPosFat != -1)
        {
            s.Goto(new Pointer(NextPosFat - HeaderLength, Offset.File));
        }
    }
Exemple #8
0
    public void SerializeFatFiles(SerializerObject s)
    {
        s.Goto(new Pointer(FatFilesOffset, Offset.File));

        XORIfNecessary(s, () =>
        {
            FatFiles = s.SerializeObjectArray <Jade_BIG_FatFile>(FatFiles, (int)NumFat, onPreSerialize: x => x.Pre_Big = this, name: nameof(FatFiles));
        });
    }
Exemple #9
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);
            }
        }
Exemple #10
0
        public override void SerializeImpl(SerializerObject s)
        {
            Sync      = s.SerializeArray <byte>(Sync, 12, name: nameof(Sync));
            Header    = s.SerializeArray <byte>(Header, 4, name: nameof(Header));
            SubHeader = s.SerializeArray <byte>(SubHeader, 8, name: nameof(SubHeader));

            Object = s.SerializeObject <T>(Object, name: nameof(Object));

            s.Goto(Offset + ISO9960_BinFile.SectorDataSize + ISO9960_BinFile.SectorHeaderSize);
            EDC = s.SerializeArray <byte>(EDC, 4, name: nameof(EDC));
            ECC = s.SerializeArray <byte>(ECC, 276, name: nameof(ECC));
        }
Exemple #11
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);
        }
        public override void SerializeBlock(SerializerObject s)
        {
            if (Data == null)
            {
                Data = new byte[ShanghaiOffsetTable.Length][];
            }

            for (int i = 0; i < Data.Length; i++)
            {
                var next = i == Data.Length - 1 ? Offset + BlockSize : ShanghaiOffsetTable.GetPointer(i + 1);

                Data[i] = s.DoAt(ShanghaiOffsetTable.GetPointer(i), () => s.SerializeArray <byte>(Data[i], next - ShanghaiOffsetTable.GetPointer(i), name: $"{Data}[{i}]"));
            }

            s.Goto(Offset + BlockSize);
        }
Exemple #13
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            VersionsCount         = s.Serialize <byte>(VersionsCount, name: nameof(VersionsCount));
            RuntimeCurrentVersion = s.Serialize <byte>(RuntimeCurrentVersion, name: nameof(RuntimeCurrentVersion));

            s.DoAt(Offset + 0x02, () => VersionCodes        = s.SerializeStringArray(VersionCodes, VersionsCount, 5, name: nameof(VersionCodes)));
            s.DoAt(Offset + 0x52, () => VersionModes        = s.SerializeStringArray(VersionModes, VersionsCount, 20, name: nameof(VersionModes)));
            s.DoAt(Offset + 0x192, () => VersionMemoryInfos = s.SerializeObjectArray <R1_PC_VersionMemoryInfo>(VersionMemoryInfos, VersionsCount, name: nameof(VersionMemoryInfos)));

            s.DoAt(Offset + (s.GameSettings.EngineVersion == EngineVersion.R1_PC_Kit ? 0x392 : 0x312), () =>
            {
                DefaultPrimaryHeader   = s.SerializeString(DefaultPrimaryHeader, 5, name: nameof(DefaultPrimaryHeader));
                DefaultSecondaryHeader = s.SerializeString(DefaultSecondaryHeader, 5, name: nameof(DefaultSecondaryHeader));
                UnkHeaderValue         = s.Serialize <ushort>(UnkHeaderValue, name: nameof(UnkHeaderValue));
            });

            // Make sure we actually end up at the end of the file.
            s.Goto(Offset + (s.GameSettings.EngineVersion == EngineVersion.R1_PC_Kit ? 0x39E : 0x31E));
        }
Exemple #14
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);
     }
 }
Exemple #15
0
        }                                                       // 16x16 secondary tile indices

        public override void SerializeImpl(SerializerObject s)
        {
            Indices_8Offset = s.Serialize <uint>(Indices_8Offset, name: nameof(Indices_8Offset));
            Indices_8Count  = s.Serialize <uint>(Indices_8Count, name: nameof(Indices_8Count));

            Indices_16Offset = s.Serialize <uint>(Indices_16Offset, name: nameof(Indices_16Offset));
            Indices_16Count  = s.Serialize <uint>(Indices_16Count, name: nameof(Indices_16Count));

            MapWidth      = s.Serialize <uint>(MapWidth, name: nameof(MapWidth));
            MapHeight     = s.Serialize <uint>(MapHeight, name: nameof(MapHeight));
            MapDataLength = s.Serialize <uint>(MapDataLength, name: nameof(MapDataLength));

            Indices_32 = s.SerializeArray <ushort>(Indices_32, MapWidth * MapHeight, name: nameof(Indices_32));

            Tiles_8 = s.DoAt(Offset + Indices_8Offset, () => s.SerializeObjectArray <GBARRR_MapTiles>(Tiles_8, Indices_8Count, name: nameof(Tiles_8), onPreSerialize: x => x.Type = Type));

            Indices_16 = s.DoAt(Offset + Indices_16Offset, () => s.SerializeObjectArray <GBARRR_TileReferences>(Indices_16, Indices_16Count, name: nameof(Indices_16)));

            // Move to end of block so block size can be checked correctly
            s.Goto(Offset + Indices_16Offset + Indices_16Count * 4 * 2);
        }