예제 #1
0
        }                                                     // References to some of the states in the normal state array

        public override void SerializeImpl(SerializerObject s)
        {
            UnknownStatesPointer    = s.SerializeObject <SNES_Pointer>(UnknownStatesPointer, onPreSerialize: x => x.MemoryBankOverride = 4, name: nameof(UnknownStatesPointer));
            ImageDescriptorsPointer = s.SerializeObject <SNES_Pointer>(ImageDescriptorsPointer, onPreSerialize: x => x.MemoryBankOverride = 4, name: nameof(ImageDescriptorsPointer));

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

            XPosition = s.Serialize <short>(XPosition, name: nameof(XPosition));
            YPosition = s.Serialize <short>(YPosition, name: nameof(YPosition));

            Bytes_0A = s.SerializeArray <byte>(Bytes_0A, 6, name: nameof(Bytes_0A));

            StatesPointer = s.SerializeObject <SNES_Pointer>(StatesPointer, onPreSerialize: x => x.MemoryBankOverride = 4, name: nameof(StatesPointer));

            if (!s.FullSerialize)
            {
                return;
            }

            // Serialize data from pointers
            States           = s.DoAt(StatesPointer.GetPointer(), () => s.SerializeObjectArray <SNES_Proto_State>(States, 5 * 0x15, name: nameof(States)));
            ImageDescriptors = s.DoAt(ImageDescriptorsPointer.GetPointer(), () => s.SerializeObjectArray <SNES_Proto_ImageDescriptor>(ImageDescriptors, States.Max(state => state.Animation?.Layers.Max(layer => layer.ImageIndex + 1) ?? 0), name: nameof(ImageDescriptors)));

            UnknownStatesPointers = s.DoAt(UnknownStatesPointer.GetPointer(), () => s.SerializeObjectArray <SNES_Pointer>(UnknownStatesPointers, 16, onPreSerialize: x => x.MemoryBankOverride = 4, name: nameof(UnknownStatesPointers)));

            if (UnknownStates == null)
            {
                UnknownStates = new SNES_Proto_State[UnknownStatesPointers.Length];
            }

            for (int i = 0; i < UnknownStates.Length; i++)
            {
                UnknownStates[i] = s.DoAt(UnknownStatesPointers[i].GetPointer(), () => s.SerializeObject <SNES_Proto_State>(UnknownStates[i], name: $"{nameof(UnknownStates)}[{i}]"));
            }
        }
예제 #2
0
 public override void SerializeImpl(SerializerObject s)
 {
     PaletteCount  = s.Serialize <byte>(PaletteCount, name: nameof(PaletteCount));
     PaletteLength = s.Serialize <byte>(PaletteLength, name: nameof(PaletteLength));
     if (Palettes == null)
     {
         Palettes = new BaseColor[PaletteCount][];
     }
     if (ColorFormat == 0x5515)                   // 1555
     {
         for (int i = 0; i < Palettes.Length; i++)
         {
             Palettes[i] = s.SerializeObjectArray <BGRA5551Color>((BGRA5551Color[])Palettes[i], PaletteLength == 0 ? 256 : PaletteLength, name: $"{nameof(Palettes)}[{i}]");
         }
     }
     else if (ColorFormat == 0x8888)                     // 8888
     {
         for (int i = 0; i < Palettes.Length; i++)
         {
             Palettes[i] = s.SerializeObjectArray <BGRA8888Color>((BGRA8888Color[])Palettes[i], PaletteLength == 0 ? 256 : PaletteLength, name: $"{nameof(Palettes)}[{i}]");
         }
     }
     else if (ColorFormat == 0x4444)
     {
         for (int i = 0; i < Palettes.Length; i++)
         {
             Palettes[i] = s.SerializeObjectArray <BGRA4444Color>((BGRA4444Color[])Palettes[i], PaletteLength == 0 ? 256 : PaletteLength, name: $"{nameof(Palettes)}[{i}]");
         }
     }
 }
예제 #3
0
        public override void SerializeBlock(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion >= EngineVersion.GBA_SplinterCell)
            {
                MatrixOffsets = s.SerializeArray <ushort>(MatrixOffsets, FrameCount, name: nameof(MatrixOffsets));
                s.Align(4);
                if (Matrices == null)
                {
                    Matrices = new GBA_AffineMatrix[FrameCount][];
                }

                for (int i = 0; i < Matrices.Length; i++)
                {
                    ushort offset = MatrixOffsets[i];
                    uint   count  = (uint)Math.Min((BlockSize - offset) / 8, 32);
                    s.DoAt(Offset + offset, () => {
                        Matrices[i] = s.SerializeObjectArray <GBA_AffineMatrix>(Matrices[i], count, name: $"{nameof(Matrices)}[{i}]");
                    });
                }
                s.Goto(Offset + BlockSize);
            }
            else
            {
                if (Matrices == null)
                {
                    Matrices = new GBA_AffineMatrix[1][];
                }
                Matrices[0] = s.SerializeObjectArray <GBA_AffineMatrix>(Matrices[0], BlockSize / 8, name: $"{nameof(Matrices)}[{0}]");
            }
        }
예제 #4
0
        public override void SerializeImpl(SerializerObject s)
        {
            bool determineTileSize = false;

            if (Count == 0)
            {
                Headers = s.SerializeObjectArray <Header>(Headers, 2, name: nameof(Headers));

                if (Headers[0].TileOffset % 4 != 0 || Headers[0].ExtraBytes >= 4 || (Headers[0].TileOffset / 4) < 2)
                {
                    return;                                                                                                 // Invalid
                }
                Count             = (uint)(Headers[0].TileOffset / 4) - 1;
                determineTileSize = true;
                s.Goto(Offset);
            }
            Headers = s.SerializeObjectArray <Header>(Headers, Count + 1, name: nameof(Headers));
            if (TileData == null)
            {
                TileData = new byte[Count][];
                for (int i = 0; i < Count; i++)
                {
                    s.DoAt(Offset + Headers[i].TileOffset, () => {
                        int length = (Headers[i + 1].TileOffset - Headers[i].TileOffset - Headers[i].ExtraBytes);

                        if (determineTileSize && i == 0)
                        {
                            if (Math.Sqrt(length * 2) % 1 == 0)
                            {
                                int val = Mathf.RoundToInt(Mathf.Sqrt(length * 2));
                                if ((val != 0) && ((val & (val - 1)) == 0))
                                {
                                    TileSize = (uint)val;
                                }
                            }
                        }

                        if (length != TileSize * TileSize / 2)
                        {
                            s.DoEncoded(new LZSSEncoder((uint)length, hasHeader: false), () => {
                                TileData[i] = s.SerializeArray <byte>(TileData[i], s.CurrentLength, name: $"{nameof(TileData)}[{i}]");
                            });
                        }
                        else
                        {
                            TileData[i] = s.SerializeArray <byte>(TileData[i], length, name: $"{nameof(TileData)}[{i}]");
                        }
                        if (determineTileSize && i == 0)
                        {
                            int len = TileData[i].Length;
                            if (Math.Sqrt(len * 2) % 1 == 0)
                            {
                                TileSize = (uint)Mathf.RoundToInt(Mathf.Sqrt(len * 2));
                            }
                        }
                    });
                }
            }
        }
예제 #5
0
        public override void SerializeImpl(SerializerObject s)
        {
            Command = s.Serialize <InstructionCommand>(Command, name: nameof(Command));

            switch (Command)
            {
            case InstructionCommand.SpriteNew:
                LayerInfosCount = s.Serialize <byte>(LayerInfosCount, name: nameof(LayerInfosCount));
                LayerInfos      = s.SerializeObjectArray <LayerInfo>(LayerInfos, LayerInfosCount, name: nameof(LayerInfos));
                ChannelData?.Temp_LayerSpriteCountState?.Add(LayerInfosCount);
                break;

            case InstructionCommand.SpriteMove:
                ChannelIndex = s.Serialize <byte>(ChannelIndex, name: nameof(ChannelIndex));
                XPos         = s.Serialize <sbyte>(XPos, name: nameof(XPos));
                YPos         = s.Serialize <sbyte>(YPos, name: nameof(YPos));
                break;

            case InstructionCommand.SetTileGraphics:
                ChannelIndex      = s.Serialize <byte>(ChannelIndex, name: nameof(ChannelIndex));
                TileGraphicsInfos = s.SerializeObjectArray <TileGraphicsInfo>(TileGraphicsInfos, TileGraphicsInfos?.Length ?? ChannelData?.Temp_LayerSpriteCountState[ChannelIndex] ?? 0, name: nameof(TileGraphicsInfos));
                break;

            case InstructionCommand.SetCollisionBox:
                XPos       = s.Serialize <sbyte>(XPos, name: nameof(XPos));
                YPos       = s.Serialize <sbyte>(YPos, name: nameof(YPos));
                HalfWidth  = s.Serialize <byte>(HalfWidth, name: nameof(HalfWidth));
                HalfHeight = s.Serialize <byte>(HalfHeight, name: nameof(HalfHeight));
                break;

            case InstructionCommand.SetInvisible:   // Set sprite->field6 to 0 for all sprites in layer
            case InstructionCommand.SetVisible:     // Set sprite->field6 to 1 for all sprites in layer
                ChannelIndex = s.Serialize <byte>(ChannelIndex, name: nameof(ChannelIndex));
                break;

            case InstructionCommand.Unknown_0C:
            case InstructionCommand.Unknown_0D:
            case InstructionCommand.Unknown_0E:
                UnkHitboxValue = s.Serialize <byte>(UnkHitboxValue, name: nameof(UnkHitboxValue));
                break;

            case InstructionCommand.SetMapDimensions:
                DD_Map_Width  = s.Serialize <byte>(DD_Map_Width, name: nameof(DD_Map_Width));
                DD_Map_Height = s.Serialize <byte>(DD_Map_Height, name: nameof(DD_Map_Height));
                break;

            case InstructionCommand.SetMapGraphics:
                DD_Map_TileGraphics = s.SerializeObject <TileMapInfo>(DD_Map_TileGraphics, name: nameof(DD_Map_TileGraphics));
                break;

            case InstructionCommand.Terminator:
                ChannelData?.Temp_LayerSpriteCountState?.Clear();
                break;

            case InstructionCommand.SpriteDelete:
            default:
                throw new ArgumentOutOfRangeException(nameof(Command), Command, null);
            }
        }
예제 #6
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            // Get info
            var pointerTable = s.GameSettings.EngineVersion != EngineVersion.R1Jaguar_Proto ? PointerTables.JaguarR1_PointerTable(s.GameSettings.EngineVersion, this.Offset.file) : null;
            var manager      = (R1Jaguar_Manager)s.GameSettings.GetGameManager;
            var levels       = manager.GetNumLevels;

            // Serialize the references for the prototype
            if (s.GameSettings.EngineVersion == EngineVersion.R1Jaguar_Proto)
            {
                s.DoAt(new Pointer(0x8BB6A8, Offset.file), () =>
                {
                    References = s.SerializeObjectArray <R1Jaguar_ReferenceEntry>(References, 1676, onPreSerialize: (x => x.StringBase = new Pointer(0x8C0538, Offset.file)), name: nameof(References));

                    // Unknown initial 4 bytes, part of the string table
                    UnkReferenceValue = s.Serialize <uint>(UnkReferenceValue, name: nameof(UnkReferenceValue));
                });
            }

            // Serialize event definition data
            if (s.GameSettings.EngineVersion == EngineVersion.R1Jaguar)
            {
                if (!s.Context.FileExists("RAM_EventDefinitions"))
                {
                    // Copied to 0x001f9000 in memory. All pointers to 0x001Fxxxx likely point to an entry in this table
                    s.DoAt(pointerTable[JaguarR1_Pointer.EventDefinitions], () =>
                    {
                        byte[] EventDefsDataBytes = s.SerializeArray <byte>(null, manager.EventCount * 0x28,
                                                                            name: nameof(EventDefsDataBytes));
                        var file = new MemoryMappedByteArrayFile("RAM_EventDefinitions", EventDefsDataBytes, s.Context,
                                                                 0x001f9000)
                        {
                            Endianness = BinaryFile.Endian.Big
                        };
                        s.Context.AddFile(file);
                        s.DoAt(file.StartPointer,
                               () => EventDefinitions = s.SerializeObjectArray <R1Jaguar_EventDefinition>(EventDefinitions,
                                                                                                          manager.EventCount, name: nameof(EventDefinitions)));
                    });
                }
            }
            else
            {
                var offset = s.GameSettings.EngineVersion == EngineVersion.R1Jaguar_Proto ? GetProtoDataPointer(R1Jaguar_Proto_References.MS_rayman) : pointerTable[JaguarR1_Pointer.EventDefinitions];

                // Pointers all point to the ROM, not RAM
                s.DoAt(offset, () => EventDefinitions = s.SerializeObjectArray <R1Jaguar_EventDefinition>(EventDefinitions,
                                                                                                          manager.EventCount, name: nameof(EventDefinitions)));
            }

            if (AdditionalEventDefinitions == null)
            {
                if (s.GameSettings.EngineVersion != EngineVersion.R1Jaguar_Proto)
                {
                    AdditionalEventDefinitions = manager.AdditionalEventDefinitionPointers.Select(p =>
                    {
                        return(s.DoAt(new Pointer(p, pointerTable[JaguarR1_Pointer.EventDefinitions].file), () => s.SerializeObject <R1Jaguar_EventDefinition>(default, name: nameof(AdditionalEventDefinitions))));
예제 #7
0
 public override void SerializeImpl(SerializerObject s)
 {
     s.Goto(Offset + 0x1C);
     Name = s.SerializeString(Name, name: nameof(Name));
     s.Goto(Offset + 0x2C);
     HuffTableOffset = s.Serialize <ushort>(HuffTableOffset, name: nameof(HuffTableOffset));
     HuffTableLength = s.Serialize <ushort>(HuffTableLength, name: nameof(HuffTableLength));
     s.DoAt(Offset + HuffTableOffset, () => {
         HuffTable = s.SerializeObjectArray <HuffTableEntry>(HuffTable, HuffTableLength / 6, name: nameof(HuffTable));
     });
     NumTables = s.Serialize <ushort>(NumTables, name: nameof(NumTables));
     Tables    = s.SerializeObjectArray <Table>(Tables, NumTables, onPreSerialize: t => t.HuffTable = HuffTable, name: nameof(Tables));
 }
예제 #8
0
        public override void SerializeBlock(SerializerObject s)
        {
            Flags = s.Serialize <byte>(Flags, name: nameof(Flags));

            if (!s.GameSettings.GBA_IsMilan)
            {
                Byte_01             = s.Serialize <byte>(Byte_01, name: nameof(Byte_01));
                AffineMatricesIndex = s.Serialize <byte>((byte)AffineMatricesIndex, name: nameof(AffineMatricesIndex));
                Byte_03             = s.Serialize <byte>(Byte_03, name: nameof(Byte_03));
                FrameCount          = (byte)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}]");
                }
            }
            else
            {
                FrameCount          = s.Serialize <byte>(FrameCount, name: nameof(FrameCount));
                Milan_Ushort_02     = s.Serialize <ushort>(Milan_Ushort_02, name: nameof(Milan_Ushort_02));
                AffineMatricesIndex = s.Serialize <ushort>(AffineMatricesIndex, name: nameof(AffineMatricesIndex));
                Milan_Int_06        = s.Serialize <int>(Milan_Int_06, name: nameof(Milan_Int_06));

                var offsetBase = s.CurrentPointer;

                Milan_LayerOffsets = s.SerializeArray <ushort>(Milan_LayerOffsets, FrameCount + 1, name: nameof(Milan_LayerOffsets)); // +1 since last offset is the end

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

                for (int i = 0; i < FrameCount; i++)
                {
                    Layers[i] = s.DoAt(offsetBase + Milan_LayerOffsets[i], () => s.SerializeObjectArray <GBA_AnimationChannel>(Layers[i], (Milan_LayerOffsets[i + 1] - Milan_LayerOffsets[i]) / 6, name: $"{nameof(Layers)}[{i}]"));
                }

                s.Goto(offsetBase + Milan_LayerOffsets.LastOrDefault());
            }
        }
예제 #9
0
        public override void SerializeBlock(SerializerObject s)
        {
            if (DependencyTable.DependenciesCount > 0)
            {
                if (Vignettes == null)
                {
                    Vignettes = new GBC_Vignette[DependencyTable.DependenciesCount];
                }

                for (int i = 0; i < Vignettes.Length; i++)
                {
                    Vignettes[i] = s.DoAt(DependencyTable.GetPointer(i), () => s.SerializeObject <GBC_Vignette>(Vignettes[i], name: $"{nameof(Vignettes)}[{i}]"));
                }
            }
            else
            {
                // Serialize data
                Width      = s.Serialize <byte>(Width, name: nameof(Width));
                Height     = s.Serialize <byte>(Height, name: nameof(Height));
                UnkData    = s.SerializeArray <byte>(UnkData, 14, name: nameof(UnkData));
                Palette    = s.SerializeObjectArray <RGBA5551Color>(Palette, 4 * 8, name: nameof(Palette));
                TileSet    = s.SerializeArray <byte>(TileSet, Width * Height * 0x10, name: nameof(TileSet));
                PalIndices = s.SerializeArray <byte>(PalIndices, Width * Height, name: nameof(PalIndices));
            }
        }
예제 #10
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            NumberOfLanguages = s.Serialize <byte>(NumberOfLanguages, name: nameof(NumberOfLanguages));
            LanguageUtilized  = s.Serialize <byte>(LanguageUtilized, name: nameof(LanguageUtilized));
            KeyboardType      = s.Serialize <KeyboardTypes>(KeyboardType, name: nameof(KeyboardType));

            // Most versions have 3 languages, but sometimes the NumberOfLanguages is set to 1 because only 1 is available. Other versions may have up to 5.
            var numLangNames = Mathf.Clamp(NumberOfLanguages, 3, 5);

            if (s.GameSettings.EngineVersion == EngineVersion.R1_PS1_Edu && (s.GameSettings.EduVolume.StartsWith("IT") || s.GameSettings.EduVolume.StartsWith("CS")))
            {
                numLangNames = 5;
            }

            if (s.GameSettings.EngineVersion == EngineVersion.R1_PC_Edu && (s.GameSettings.EduVolume.StartsWith("HN") || s.GameSettings.EduVolume.StartsWith("IS") || s.GameSettings.EduVolume.StartsWith("NL")))
            {
                numLangNames = 5;
            }

            LanguageNames = s.SerializeStringArray(LanguageNames, numLangNames, 11, name: nameof(LanguageNames));

            var align = 3 + LanguageNames.Length * 11 + 8;

            if (align % 4 != 0)
            {
                s.SerializeArray <byte>(new byte[align % 4], 4 - (align % 4), name: "Align");
            }

            TextDefineCount = s.Serialize <uint>(TextDefineCount, name: nameof(TextDefineCount));
            Unk1            = s.Serialize <ushort>(Unk1, name: nameof(Unk1));
            Unk2            = s.Serialize <ushort>(Unk2, name: nameof(Unk2));

            TextDefine = s.SerializeObjectArray <R1_PC_LocFileString>(TextDefine, TextDefineCount, name: nameof(TextDefine));
        }
예제 #11
0
        public override void SerializeBlock(SerializerObject s)
        {
            // Serialize data
            Height            = s.Serialize <byte>(Height, name: nameof(Height));
            Width             = s.Serialize <byte>(Width, name: nameof(Width));
            UnkData0          = s.SerializeArray <byte>(UnkData0, 4, name: nameof(UnkData0));
            PaletteCount      = s.Serialize <byte>(PaletteCount, name: nameof(PaletteCount));
            PaletteBlockCount = s.Serialize <byte>(PaletteBlockCount, name: nameof(PaletteBlockCount));
            PaletteOffset     = s.Serialize <uint>(PaletteOffset, name: nameof(PaletteOffset));
            TileDataOffset    = s.Serialize <uint>(TileDataOffset, name: nameof(TileDataOffset));

            var basePtr = s.CurrentPointer;

            s.Goto(basePtr + TileDataOffset);
            TileSet    = s.SerializeArray <byte>(TileSet, Width * Height * 0x10, name: nameof(TileSet));
            PalIndices = s.SerializeArray <byte>(PalIndices, Width * Height, name: nameof(PalIndices));

            s.Goto(basePtr + PaletteOffset);
            if (Palette == null)
            {
                Palette = new RGBA5551Color[PaletteBlockCount][];
            }
            for (int i = 0; i < PaletteBlockCount; i++)
            {
                Palette[i] = s.SerializeObjectArray <RGBA5551Color>(Palette[i], PaletteCount * 4, name: $"{nameof(Palette)}[{i}]");
            }
        }
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            if (Commands == null)
            {
                // Create a temporary list
                var cmd = new List <R1Jaguar_LevelLoadCommand>();

                int index = 0;

                // Loop until we reach the end command
                while (cmd.LastOrDefault()?.Type != R1Jaguar_LevelLoadCommand.LevelLoadCommandType.End)
                {
                    cmd.Add(s.SerializeObject((R1Jaguar_LevelLoadCommand)null, name: $"Commands[{index}]"));
                    index++;
                }

                // Set the commands
                Commands = cmd.ToArray();
            }
            else
            {
                // Serialize the commands
                s.SerializeObjectArray(Commands, Commands.Length, name: nameof(Commands));
            }
        }
예제 #13
0
        public override void SerializeImpl(SerializerObject s)
        {
            Name       = s.SerializeString(Name, 32, name: nameof(Name));
            Attributes = s.Serialize <ushort>(Attributes, name: nameof(Attributes));
            Version    = s.Serialize <ushort>(Version, name: nameof(Version));

            CreationTime     = s.SerializeObject <Palm_DateTime>(CreationTime, name: nameof(CreationTime));
            ModificationTime = s.SerializeObject <Palm_DateTime>(ModificationTime, name: nameof(ModificationTime));
            BackupTime       = s.SerializeObject <Palm_DateTime>(BackupTime, name: nameof(BackupTime));

            ModificationNumber  = s.Serialize <uint>(ModificationNumber, name: nameof(ModificationNumber));
            AppInfoAreaPointer  = s.SerializePointer(AppInfoAreaPointer, name: nameof(AppInfoAreaPointer));
            SortInfoAreaPointer = s.SerializePointer(SortInfoAreaPointer, name: nameof(SortInfoAreaPointer));

            DataBaseType = s.SerializeString(DataBaseType, 4, name: nameof(DataBaseType));
            CreatorID    = s.SerializeString(CreatorID, 4, name: nameof(CreatorID));
            UniqueID     = s.Serialize <uint>(UniqueID, name: nameof(UniqueID));

            NextRecordListID = s.Serialize <uint>(NextRecordListID, name: nameof(NextRecordListID));
            RecordsCount     = s.Serialize <ushort>(RecordsCount, name: nameof(RecordsCount));

            Records = s.SerializeObjectArray <Palm_DatabaseRecord>(Records, RecordsCount, onPreSerialize: x => x.Type = Type, name: nameof(Records));

            // Set the length of every record
            for (int i = 0; i < RecordsCount; i++)
            {
                Records[i].Length = (i == RecordsCount - 1 ? s.CurrentLength : Records[i + 1].DataPointer.FileOffset) - Records[i].DataPointer.FileOffset;
            }

            // TODO: Serialize sort info
        }
예제 #14
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            InstrumentSize = s.Serialize <uint>(InstrumentSize, name: nameof(InstrumentSize));
            InstrumentName = s.SerializeString(InstrumentName, 22, Encoding.ASCII, name: nameof(InstrumentName));
            InstrumentType = s.Serialize <byte>(InstrumentType, name: nameof(InstrumentType));
            NumSamples     = s.Serialize <ushort>(NumSamples, name: nameof(NumSamples));
            if (NumSamples > 0)
            {
                SampleHeaderSize         = s.Serialize <uint>(SampleHeaderSize, name: nameof(SampleHeaderSize));
                SampleKeymapAssignments  = s.SerializeArray <byte>(SampleKeymapAssignments, 96, name: nameof(SampleKeymapAssignments));
                PointsForVolumeEnvelope  = s.SerializeArray <ushort>(PointsForVolumeEnvelope, 24, name: nameof(PointsForVolumeEnvelope));
                PointsForPanningEnvelope = s.SerializeArray <ushort>(PointsForPanningEnvelope, 24, name: nameof(PointsForPanningEnvelope));

                NumVolumePoints       = s.Serialize <byte>(NumVolumePoints, name: nameof(NumVolumePoints));
                NumPanningPoints      = s.Serialize <byte>(NumPanningPoints, name: nameof(NumPanningPoints));
                VolumeSustainPoint    = s.Serialize <byte>(VolumeSustainPoint, name: nameof(VolumeSustainPoint));
                VolumeLoopStartPoint  = s.Serialize <byte>(VolumeLoopStartPoint, name: nameof(VolumeLoopStartPoint));
                VolumeLoopEndPoint    = s.Serialize <byte>(VolumeLoopEndPoint, name: nameof(VolumeLoopEndPoint));
                PanningSustainPoint   = s.Serialize <byte>(PanningSustainPoint, name: nameof(PanningSustainPoint));
                PanningLoopStartPoint = s.Serialize <byte>(PanningLoopStartPoint, name: nameof(PanningLoopStartPoint));
                PanningLoopEndPoint   = s.Serialize <byte>(PanningLoopEndPoint, name: nameof(PanningLoopEndPoint));
                VolumeType            = s.Serialize <byte>(VolumeType, name: nameof(VolumeType));
                PanningType           = s.Serialize <byte>(PanningType, name: nameof(PanningType));
                VibratoType           = s.Serialize <byte>(VibratoType, name: nameof(VibratoType));
                VibratoSweep          = s.Serialize <byte>(VibratoSweep, name: nameof(VibratoSweep));
                VibratoDepth          = s.Serialize <byte>(VibratoDepth, name: nameof(VibratoDepth));
                VibratoRate           = s.Serialize <byte>(VibratoRate, name: nameof(VibratoRate));
                VolumeFadeout         = s.Serialize <ushort>(VolumeFadeout, name: nameof(VolumeFadeout));
                Reserved = s.SerializeArray <byte>(Reserved, 2, name: nameof(Reserved));

                Samples = s.SerializeObjectArray <XM_Sample>(Samples, NumSamples, name: nameof(Samples));
            }
        }
예제 #15
0
        /// <summary>
        /// Serializes the data
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            // Serialize header values
            Unknown1 = s.Serialize <ushort>(Unknown1, name: nameof(Unknown1));
            Width    = s.Serialize <ushort>(Width, name: nameof(Width));
            Height   = s.Serialize <ushort>(Height, name: nameof(Height));
            Unknown2 = s.Serialize <ushort>(Unknown2, name: nameof(Unknown2));

            // Get the block width
            var blockWidth = GetBlockWidth(s.GameSettings.EngineVersion);

            // Create block array
            if (ImageBlocks == null)
            {
                // Get the size of each block
                var blockSize = Height * blockWidth;

                ImageBlocks = new ARGB1555Color[BlockGroupSize / blockSize][];
            }

            // Serialize blocks
            for (int i = 0; i < ImageBlocks.Length; i++)
            {
                ImageBlocks[i] = s.SerializeObjectArray <ARGB1555Color>(ImageBlocks[i], blockWidth * Height, name: nameof(ImageBlocks) + "[" + i + "]");
            }
        }
예제 #16
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            if (Commands == null)
            {
                // Create a temporary list
                var cmd = new List <R1_EventCommand>();

                int index = 0;

                // Loop until we reach the invalid command
                while (cmd.LastOrDefault()?.Command != R1_EventCommandType.INVALID_CMD && cmd.LastOrDefault()?.Command != R1_EventCommandType.INVALID_CMD_DEMO)
                {
                    cmd.Add(s.SerializeObject((R1_EventCommand)null, name: $"Commands [{index}]"));
                    index++;
                }

                // Set the commands
                Commands = cmd.ToArray();
            }
            else
            {
                // Serialize the commands
                s.SerializeObjectArray(Commands, Commands.Length, name: nameof(Commands));
            }
        }
예제 #17
0
        public override void SerializeImpl(SerializerObject s)
        {
            PointersPointer = s.SerializePointer <GBAIsometric_LevelDataLayerDataPointers>(PointersPointer, resolve: true, name: nameof(PointersPointer));
            StructType      = s.Serialize <MapLayerType>(StructType, name: nameof(StructType));
            Width           = s.Serialize <ushort>(Width, name: nameof(Width));
            Height          = s.Serialize <ushort>(Height, name: nameof(Height));
            Ushort_0A       = s.Serialize <ushort>(Ushort_0A, name: nameof(Ushort_0A));
            MapDataPointer  = s.SerializePointer(MapDataPointer, name: nameof(MapDataPointer));
            Pointer_20      = s.SerializePointer(Pointer_20, name: nameof(Pointer_20));

            if (StructType == MapLayerType.Map)
            {
                Palette       = s.SerializeObjectArray <ARGB1555Color>(Palette, 256, name: nameof(Palette));
                RemainingData = s.SerializeArray <byte>(RemainingData, 44, name: nameof(RemainingData));
            }

            // TODO: Remove try/catch
            try
            {
                s.DoAt(MapDataPointer, () =>
                {
                    s.DoEncoded(new RHREncoder(), () =>
                    {
                        MapData = s.SerializeArray <ushort>(MapData, Width * Height, name: nameof(MapData));
                    });
                });
            }
            catch (Exception ex)
            {
                Debug.LogWarning($"Failed to decompress {MapDataPointer}: {ex.Message}\n{ex.InnerException?.StackTrace}");
            }
        }
        public override void SerializeImpl(SerializerObject s)
        {
            TileSetPointer    = s.SerializePointer <GBAIsometric_RHR_TileSet>(TileSetPointer, resolve: true, name: nameof(TileSetPointer));
            StructType        = s.Serialize <MapLayerType>(StructType, name: nameof(StructType));
            Width             = s.Serialize <ushort>(Width, name: nameof(Width));
            Height            = s.Serialize <ushort>(Height, name: nameof(Height));
            Ushort_0A         = s.Serialize <ushort>(Ushort_0A, name: nameof(Ushort_0A));
            MapDataPointer    = s.SerializePointer(MapDataPointer, name: nameof(MapDataPointer));
            MapPalettePointer = s.SerializePointer(MapPalettePointer, name: nameof(MapPalettePointer));
            MapPalette        = s.DoAt(MapPalettePointer, () => s.SerializeObjectArray <RGBA5551Color>(MapPalette, 256, name: nameof(MapPalette)));

            s.DoAt(MapDataPointer, () =>
            {
                s.DoEncoded(new RHREncoder(), () => MapData = s.SerializeArray <ushort>(MapData, Width * Height, name: nameof(MapData)));
            });

            // Debug tilemaps
            //ushort[] fullMap = CreateFullMap(MapData);
            //string logString = $"{Offset}: Max Tilemap Value - {fullMap.Max()}";
            //UnityEngine.Debug.Log(logString);
            //s.Log(logString);
            //byte[] result = new byte[fullMap.Length * sizeof(ushort)];
            //Buffer.BlockCopy(fullMap, 0, result, 0, result.Length);
            //Util.ByteArrayToFile(s.Context.BasePath + "full_tilemap/" + Offset.StringAbsoluteOffset + ".bin", result);
        }
예제 #19
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            // Serialize header
            EventsPointer = s.SerializePointer(EventsPointer, name: nameof(EventsPointer));
            EventCount    = s.Serialize <byte>(EventCount, name: nameof(EventCount));
            s.SerializeArray <byte>(new byte[3], 3, name: "Padding");
            EventLinksPointer = s.SerializePointer(EventLinksPointer, name: nameof(EventLinksPointer));
            EventLinkCount    = s.Serialize <byte>(EventLinkCount, name: nameof(EventLinkCount));
            s.SerializeArray <byte>(new byte[3], 3, name: "Padding");

            if (EventCount != EventLinkCount)
            {
                Debug.LogError("Event counts don't match");
            }

            s.DoAt(EventsPointer, (() =>
            {
                // Serialize every event
                Events = s.SerializeObjectArray <R1_EventData>(Events, EventCount, name: nameof(Events));
            }));

            s.DoAt(EventLinksPointer, (() =>
            {
                // Serialize the event linking table
                EventLinkingTable = s.SerializeArray <byte>(EventLinkingTable, EventLinkCount, name: nameof(EventLinkingTable));
            }));
        }
예제 #20
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            PatternHeaderLength   = s.Serialize <uint>(PatternHeaderLength, name: nameof(PatternHeaderLength));
            PackingType           = s.Serialize <byte>(PackingType, name: nameof(PackingType));
            NumRows               = s.Serialize <ushort>(NumRows, name: nameof(NumRows));
            PackedPatternDataSize = s.Serialize <ushort>(PackedPatternDataSize, name: nameof(PackedPatternDataSize));

            if (PatternRows == null)
            {
                PatternRows = s.SerializeObjectArray <XM_PatternRow>(PatternRows, NumChannels * NumRows, name: nameof(PatternRows));
            }
            else
            {
                PatternRows = s.SerializeObjectArray <XM_PatternRow>(PatternRows, PatternRows.Length, name: nameof(PatternRows));
            }
        }
예제 #21
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            // Serialize ROM header
            base.SerializeImpl(s);

            var manager = ((GBA_Manager)s.Context.Settings.GetGameManager);

            // Get the pointer table
            var pointerTable = PointerTables.GBA_PointerTable(s.Context, Offset.file);
            var lvlType      = manager.GetLevelType(s.Context);

            // Serialize the offset table
            if (lvlType != GBA_Manager.LevelType.R3SinglePak)
            {
                s.DoAt(pointerTable[GBA_Pointer.UiOffsetTable], () => Data = s.SerializeObject <GBA_Data>(Data, name: nameof(Data)));
            }

            // Serialize level info
            if (pointerTable.ContainsKey(GBA_Pointer.LevelInfo))
            {
                LevelInfo = s.DoAt(pointerTable[GBA_Pointer.LevelInfo], () => s.SerializeObjectArray <GBA_R3_SceneInfo>(LevelInfo, manager.LevelCount, name: nameof(LevelInfo)));
            }

            // Serialize localization
            if (pointerTable.ContainsKey(GBA_Pointer.Localization))
            {
                if (s.GameSettings.GBA_IsMilan)
                {
                    s.DoAt(pointerTable[GBA_Pointer.Localization], () => Milan_Localization = s.SerializeObject <GBA_Milan_LocTable>(Milan_Localization, name: nameof(Milan_Localization)));
                }
                else
                {
                    s.DoAt(pointerTable[GBA_Pointer.Localization], () => Localization = s.SerializeObject <GBA_LocLanguageTable>(Localization, name: nameof(Localization)));
                }
            }

            // Serialize actor type data
            if (pointerTable.ContainsKey(GBA_Pointer.ActorTypeTable))
            {
                ActorTypeTable = s.DoAt(pointerTable[GBA_Pointer.ActorTypeTable], () => s.SerializeObjectArray <GBA_ActorTypeTableEntry>(ActorTypeTable, manager.ActorTypeTableLength, name: nameof(ActorTypeTable)));
            }

            if (lvlType == GBA_Manager.LevelType.R3SinglePak)
            {
                R3SinglePak_OffsetTable = s.DoAt(pointerTable[GBA_Pointer.R3SinglePak_OffsetTable], () => s.SerializeObject <GBA_OffsetTable>(R3SinglePak_OffsetTable, name: nameof(R3SinglePak_OffsetTable)));
                R3SinglePak_Palette     = s.DoAt(pointerTable[GBA_Pointer.R3SinglePak_Palette], () => s.SerializeObjectArray <RGBA5551Color>(R3SinglePak_Palette, 256, name: nameof(R3SinglePak_Palette)));
                R3SinglePak_TileMap     = s.DoAt(pointerTable[GBA_Pointer.R3SinglePak_TileMap], () => s.SerializeArray <ushort>(R3SinglePak_TileMap, 0x400, name: nameof(R3SinglePak_TileMap)));
                R3SinglePak_TileSet     = s.DoAt(pointerTable[GBA_Pointer.R3SinglePak_TileSet], () => s.SerializeArray <byte>(R3SinglePak_TileSet, (R3SinglePak_TileMap.Max() + 1) * 0x40, name: nameof(R3SinglePak_TileSet)));

                if (R3SinglePak_Puppets == null)
                {
                    R3SinglePak_Puppets = new GBA_Puppet[R3SinglePak_OffsetTable.OffsetsCount];
                }

                for (int i = 0; i < R3SinglePak_Puppets.Length; i++)
                {
                    R3SinglePak_Puppets[i] = s.DoAt(R3SinglePak_OffsetTable.GetPointer(i), () => s.SerializeObject <GBA_Puppet>(R3SinglePak_Puppets[i], name: $"{nameof(R3SinglePak_Puppets)}[{i}]"));
                }
            }
        }
예제 #22
0
        protected void SerializeTileMap(SerializerObject s)
        {
            switch (StructType)
            {
            case Type.Layer2D:
            case Type.SplinterCellZoom:
            case Type.PoP:
                MapData = s.SerializeObjectArray <MapTile>(MapData, Width * Height, onPreSerialize: m => {
                    if (!UsesTileKitDirectly)
                    {
                        if (TileKitIndex == 1)
                        {
                            m.GBATileType = MapTile.GBA_TileType.FGTile;
                        }
                        else
                        {
                            m.GBATileType = MapTile.GBA_TileType.BGTile;
                        }
                    }
                    m.Is8Bpp = ColorMode == GBA_ColorMode.Color8bpp;
                }, name: nameof(MapData));
                break;

            case Type.RotscaleLayerMode7:
                Mode7Data = s.SerializeArray <byte>(Mode7Data, Width * Height, name: nameof(Mode7Data));
                break;

            case Type.Collision:
                CollisionData = s.SerializeArray <GBA_TileCollisionType>(CollisionData, Width * Height, name: nameof(CollisionData));
                break;
            }
        }
예제 #23
0
        public override void SerializeImpl(SerializerObject s)
        {
            AnimSetsPointer = s.SerializePointer(AnimSetsPointer, name: nameof(AnimSetsPointer));
            TileSetPointer  = s.SerializePointer(TileSetPointer, name: nameof(TileSetPointer));
            PalettesPointer = s.SerializePointer(PalettesPointer, name: nameof(PalettesPointer));
            AnimSetsCount   = s.Serialize <ushort>(AnimSetsCount, name: nameof(AnimSetsCount));
            PalettesCount   = s.Serialize <ushort>(PalettesCount, name: nameof(PalettesCount));

            AnimSets = s.DoAt(AnimSetsPointer, () => s.SerializeObjectArray <GBAVV_Map2D_AnimSet>(AnimSets, AnimSetsCount, name: nameof(AnimSets)));

            var tileSetLength = AnimSets.SelectMany(x => x.AnimationFrames).Select(x =>
                                                                                   x.TileOffset + (x.TileShapes.Select(t => (GBAVV_Map2D_AnimSet.TileShapes[t.ShapeIndex].x * GBAVV_Map2D_AnimSet.TileShapes[t.ShapeIndex].y) / 2).Sum())).Max();

            TileSet  = s.DoAt(TileSetPointer, () => s.SerializeArray <byte>(TileSet, tileSetLength, name: nameof(TileSet)));
            Palettes = s.DoAt(PalettesPointer, () => s.SerializeObjectArray <GBAVV_Map2D_ObjPal>(Palettes, PalettesCount, name: nameof(Palettes)));
        }
예제 #24
0
        public void SerializeLevelData(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion == EngineVersion.R1_GBA)
            {
                s.DoAt(MapDataPointer, () => {
                    if ((CompressionFlags & 1) == 1)
                    {
                        s.DoEncoded(new GBA_LZSSEncoder(), () => {
                            MapData = s.SerializeObject <MapData>(MapData, name: nameof(MapData));
                        });
                    }
                    else
                    {
                        MapData = s.SerializeObject <MapData>(MapData, name: nameof(MapData));
                    }
                });
                s.DoAt(TilePaletteIndicesPointer, () => {
                    if ((CompressionFlags & 2) == 2)
                    {
                        s.DoEncoded(new GBA_LZSSEncoder(), () => TilePaletteIndices = s.SerializeArray <byte>(TilePaletteIndices, s.CurrentLength, name: nameof(TilePaletteIndices)));
                    }
                    else
                    {
                        uint numTileBlocks = (TilePaletteIndicesPointer.AbsoluteOffset - TileBlockIndicesPointer.AbsoluteOffset) / 2;
                        TilePaletteIndices = s.SerializeArray <byte>(TilePaletteIndices, numTileBlocks, name: nameof(TilePaletteIndices));
                    }
                });

                s.DoAt(TileBlockIndicesPointer, () => TileBlockIndices = s.SerializeArray <ushort>(TileBlockIndices, TilePaletteIndices.Length, name: nameof(TileBlockIndices)));
                s.DoAt(TilePalettePointer, () => TilePalettes          = s.SerializeObjectArray <RGBA5551Color>(TilePalettes, 10 * 16, name: nameof(TilePalettes)));

                ushort maxBlockIndex = TileBlockIndices.Max();
                s.DoAt(TileDataPointer, () => TileData = s.SerializeArray <byte>(TileData, 0x20 * ((uint)maxBlockIndex + 1), name: nameof(TileData)));
            }
            else if (s.GameSettings.EngineVersion == EngineVersion.R1_DSi)
            {
                s.DoAt(MapDataPointer, () => s.DoEncoded(new GBA_LZSSEncoder(), () => MapData = s.SerializeObject <MapData>(MapData, name: nameof(MapData))));
                s.DoAt(TileDataPointer, () => {
                    s.DoEncoded(new GBA_LZSSEncoder(), () => TileData = s.SerializeArray <byte>(TileData, s.CurrentLength, name: nameof(TileData)));
                });
                s.DoAt(TilePalettePointer, () => TilePalettes = s.SerializeObjectArray <RGBA5551Color>(TilePalettes, 256, name: nameof(TilePalettes)));
                s.DoAt(TileBlockIndicesPointer, () => {
                    uint maxTileInd  = MapData.Tiles.Max(t => t.TileMapY);
                    TileBlockIndices = s.SerializeArray <ushort>(TileBlockIndices, (maxTileInd + 1) * 4, name: nameof(TileBlockIndices));
                });
            }
        }
예제 #25
0
 public override void SerializeImpl(SerializerObject s)
 {
     TileSet_4bpp = s.SerializeArray <byte>(TileSet_4bpp, TileSetCount_4bpp * 0x20, name: nameof(TileSet_4bpp));
     TileSet_8bpp = s.SerializeArray <byte>(TileSet_8bpp, (TileSetCount_Total - TileSetCount_4bpp) * 0x40, name: nameof(TileSet_8bpp));
     TileSet_4bpp_ConvertIndexTable = s.SerializeArray <ushort>(TileSet_4bpp_ConvertIndexTable, TileSetCount_4bpp, name: nameof(TileSet_4bpp_ConvertIndexTable));
     s.Align();
     TileSet_4bpp_ConvertDatas = s.SerializeObjectArray <ConvertData>(TileSet_4bpp_ConvertDatas, TileSet_4bpp_ConvertIndexTable.Max() + 1, name: nameof(TileSet_4bpp_ConvertDatas));
 }
 public override void SerializeImpl(SerializerObject s)
 {
     Byte_00    = s.Serialize <byte>(Byte_00, name: nameof(Byte_00));
     LayerCount = s.Serialize <byte>(LayerCount, name: nameof(LayerCount));
     Byte_02    = s.Serialize <byte>(Byte_02, name: nameof(Byte_02));
     Byte_03    = s.Serialize <byte>(Byte_03, name: nameof(Byte_03));
     Layers     = s.SerializeObjectArray <GBA_BatmanVengeance_AnimationChannel>(Layers, LayerCount, name: nameof(Layers));
 }
예제 #27
0
 public override void SerializeImpl(SerializerObject s)
 {
     NumPoints = s.Serialize <byte>(NumPoints, name: nameof(NumPoints));
     NumPointsWithUShort_02 = s.Serialize <byte>(NumPointsWithUShort_02, name: nameof(NumPointsWithUShort_02));
     Byte_02 = s.Serialize <byte>(Byte_02, name: nameof(Byte_02));
     Byte_03 = s.Serialize <byte>(Byte_03, name: nameof(Byte_03));
     Points  = s.SerializeObjectArray <Point>(Points, NumPoints, name: nameof(Points));
 }
예제 #28
0
 public override void SerializeBlock(SerializerObject s)
 {
     s.DoEndian(R1Engine.Serialize.BinaryFile.Endian.Little, () => {
         Count = s.Serialize <ushort>(Count, name: nameof(Count));
     });
     if (Keyframes == null)
     {
         // To serialize the keyframes, we need to keep track of the layer sprite count changes between them
         Temp_LayerSpriteCountState = new List <int>();
         Keyframes = s.SerializeObjectArray <GBC_Keyframe>(Keyframes, Count - 1, onPreSerialize: x => x.ChannelData = this, name: nameof(Keyframes));
         Temp_LayerSpriteCountState = null;// We serialized this now, so we can remove this list
     }
     else
     {
         Keyframes = s.SerializeObjectArray <GBC_Keyframe>(Keyframes, Count - 1, name: nameof(Keyframes));
     }
 }
예제 #29
0
        public override void SerializeBlock(SerializerObject s)
        {
            var blockOffset = s.CurrentPointer;

            // Serialize data (always little endian)
            s.DoEndian(R1Engine.Serialize.BinaryFile.Endian.Little, () =>
            {
                // Parse data
                GameObjectsCount     = s.Serialize <ushort>(GameObjectsCount, name: nameof(GameObjectsCount));
                GameObjectsOffset    = s.Serialize <ushort>(GameObjectsOffset, name: nameof(GameObjectsOffset));
                KnotsHeight          = s.Serialize <byte>(KnotsHeight, name: nameof(KnotsHeight));
                KnotsWidth           = s.Serialize <byte>(KnotsWidth, name: nameof(KnotsWidth));
                KnotsOffset          = s.Serialize <ushort>(KnotsOffset, name: nameof(KnotsOffset));
                Height               = s.Serialize <ushort>(Height, name: nameof(Height));
                Width                = s.Serialize <ushort>(Width, name: nameof(Width));
                Timeout              = s.Serialize <byte>(Timeout, name: nameof(Timeout));
                Index_PlayField      = s.Serialize <byte>(Index_PlayField, name: nameof(Index_PlayField));
                IndexMin_ActorModels = s.Serialize <byte>(IndexMin_ActorModels, name: nameof(IndexMin_ActorModels));
                IndexMax_ActorModels = s.Serialize <byte>(IndexMax_ActorModels, name: nameof(IndexMax_ActorModels));
                ObjPalette           = s.SerializeObjectArray <RGBA5551Color>(ObjPalette, 8 * 4, name: nameof(ObjPalette));
                TilePalette          = s.SerializeObjectArray <RGBA5551Color>(TilePalette, 8 * 4, name: nameof(TilePalette));
                MainActor_0          = s.Serialize <ushort>(MainActor_0, name: nameof(MainActor_0));
                MainActor_1          = s.Serialize <ushort>(MainActor_1, name: nameof(MainActor_1));
                MainActor_2          = s.Serialize <ushort>(MainActor_2, name: nameof(MainActor_2));
                Index_SoundBank      = s.Serialize <byte>(Index_SoundBank, name: nameof(Index_SoundBank));

                // TODO: Parse data (UnkActorStructs?)
                UnknownData = s.SerializeArray <byte>(UnknownData, (blockOffset + GameObjectsOffset).AbsoluteOffset - s.CurrentPointer.AbsoluteOffset, name: nameof(UnknownData));

                // Parse from pointers
                GameObjects = s.DoAt(blockOffset + GameObjectsOffset, () => s.SerializeObjectArray <GBC_GameObject>(GameObjects, GameObjectsCount, name: nameof(GameObjects)));
                Knots       = s.DoAt(blockOffset + KnotsOffset, () => s.SerializeObjectArray <GBC_Knot>(Knots, KnotsHeight * KnotsWidth, name: nameof(Knots)));
                s.Goto(Knots.Last().Offset + Knots.Last().ActorsCount * 2 + 1); // Go to end of the block
            });

            // Parse data from pointers
            PlayField = s.DoAt(DependencyTable.GetPointer(Index_PlayField - 1), () => s.SerializeObject <GBC_PlayField>(PlayField, name: nameof(PlayField)));
            SoundBank = s.DoAt(DependencyTable.GetPointer(Index_SoundBank - 1), () => s.SerializeObject <GBC_SoundBank>(SoundBank, name: nameof(SoundBank)));

            // Parse actor models
            foreach (var actor in GameObjects.Where(x => x.Index_ActorModel > 1))
            {
                actor.ActorModel = s.DoAt(DependencyTable.GetPointer(actor.Index_ActorModel - 1), () => s.SerializeObject <GBC_ActorModelBlock>(actor.ActorModel, name: $"{nameof(actor.ActorModel)}[{actor.Index_ActorModel}]"));
            }
        }
예제 #30
0
        /// <summary>
        /// Serializes the data
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            // Serialize map size
            Width  = s.Serialize <ushort>(Width, name: nameof(Width));
            Height = s.Serialize <ushort>(Height, name: nameof(Height));

            // Serialize tiles
            Tiles = s.SerializeObjectArray <MapTile>(Tiles, Width * Height, name: nameof(Tiles));
        }