Ejemplo n.º 1
0
        public override void SerializeOffsetData(SerializerObject s)
        {
            // Parse level block data
            if (OffsetTable.Offsets[Index_PlayField] != -1)
            {
                PlayField = s.DoAt(OffsetTable.GetPointer(Index_PlayField), () => s.SerializeObject <GBA_PlayField>(PlayField, name: nameof(PlayField)));
            }

            // Parse actor data
            var actors = GetAllActors(s.GameSettings).ToArray();

            for (var i = 0; i < actors.Length; i++)
            {
                if (actors[i].Type == GBA_Actor.ActorType.Captor)
                {
                    actors[i].CaptorData = s.DoAt(OffsetTable.GetPointer(actors[i].Index_CaptorData, isRelativeOffset: IsGCNBlock),
                                                  () => s.SerializeObject <GBA_CaptorData>(actors[i].CaptorData,
                                                                                           onPreSerialize: bab => {
                        bab.IsGCNBlock = IsGCNBlock;
                        bab.Length     = actors[i].LinkedActorsCount;
                    }, name: $"{nameof(GBA_Actor.CaptorData)}[{i}]"));
                }
                else if (actors[i].Type != GBA_Actor.ActorType.Waypoint && actors[i].Type != GBA_Actor.ActorType.Unk && actors[i].Index_ActorModel < OffsetTable.OffsetsCount)
                {
                    actors[i].ActorModel = s.DoAt(OffsetTable.GetPointer(actors[i].Index_ActorModel),
                                                  () => s.SerializeObject <GBA_ActorModel>(actors[i].ActorModel,
                                                                                           name: $"{nameof(GBA_Actor.ActorModel)}[{i}]"));
                }
            }
        }
Ejemplo n.º 2
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
        }
 public override void SerializeImpl(SerializerObject s)
 {
     AnimGroupsPointer = s.SerializePointer(AnimGroupsPointer, name: nameof(AnimGroupsPointer));
     TileSetIndex      = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(TileSetIndex, name: nameof(TileSetIndex));
     AnimBlockIndex    = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(AnimBlockIndex, name: nameof(AnimBlockIndex));
     FrameImagesIndex  = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(FrameImagesIndex, name: nameof(FrameImagesIndex));
     s.Serialize <ushort>(default, name: "Padding");
Ejemplo n.º 4
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}]"));
            }
        }
Ejemplo n.º 5
0
        public override void SerializeOffsetData(SerializerObject s)
        {
            // Parse level block data
            if (OffsetTable.Offsets[PlayFieldIndex] != -1)
            {
                PlayField = s.DoAt(OffsetTable.GetPointer(PlayFieldIndex), () => s.SerializeObject <GBA_PlayField>(PlayField, name: nameof(PlayField)));
            }

            // Parse actor data
            var actors = GetAllActors(s.GameSettings).ToArray();

            for (var i = 0; i < actors.Length; i++)
            {
                if (actors[i].Type == GBA_Actor.ActorType.BoxTrigger)
                {
                    actors[i].BoxActorBlock = s.DoAt(OffsetTable.GetPointer(actors[i].BoxActorBlockOffsetIndex, isRelativeOffset: IsGCNBlock),
                                                     () => s.SerializeObject <GBA_BoxTriggerActorDataBlock>(actors[i].BoxActorBlock,
                                                                                                            onPreSerialize: bab => {
                        bab.IsGCNBlock = IsGCNBlock;
                        bab.Length     = actors[i].LinkedActorsCount;
                    }, name: $"{nameof(GBA_Actor.BoxActorBlock)}[{i}]"));
                }
                else if (actors[i].Type != GBA_Actor.ActorType.Trigger && actors[i].Type != GBA_Actor.ActorType.Unk && actors[i].GraphicsDataIndex < OffsetTable.OffsetsCount)
                {
                    actors[i].GraphicData = s.DoAt(OffsetTable.GetPointer(actors[i].GraphicsDataIndex),
                                                   () => s.SerializeObject <GBA_ActorGraphicData>(actors[i].GraphicData,
                                                                                                  name: $"{nameof(GBA_Actor.GraphicData)}[{i}]"));
                }
            }
        }
        public override void SerializeImpl(SerializerObject s)
        {
            // Get the language count for the current game
            var langCount    = ((GBAIsometric_Spyro_Manager)s.GameSettings.GetGameManager).GetLanguages.Count();
            var pointerTable = PointerTables.GBAIsometric_Spyro_PointerTable(s.GameSettings.GameModeSelection, Offset.file);

            if (s.GameSettings.EngineVersion == EngineVersion.GBAIsometric_Spyro3)
            {
                // Parse loc tables
                LocalizationBlockIndices = s.DoAt(pointerTable.TryGetItem(GBAIsometric_Spyro_Pointer.LocalizationBlockIndices), () => s.SerializeObjectArray <GBAIsometric_Spyro_DataBlockIndex>(LocalizationBlockIndices, langCount, x => x.HasPadding = true, name: nameof(LocalizationBlockIndices)));
                LocalizationDecompressionBlockIndices = s.DoAt(pointerTable.TryGetItem(GBAIsometric_Spyro_Pointer.LocalizationDecompressionBlockIndices), () => s.SerializeObjectArray <GBAIsometric_Spyro_DataBlockIndex>(LocalizationDecompressionBlockIndices, langCount, x => x.HasPadding = true, name: nameof(LocalizationDecompressionBlockIndices)));

                LocTables = s.DoAt(pointerTable.TryGetItem(GBAIsometric_Spyro_Pointer.LocTables), () => s.SerializeObjectArray <GBAIsometric_Spyro_LocTable>(LocTables, 38, name: nameof(LocTables)));

                // Parse block data

                if (LocDecompressHelpers == null)
                {
                    LocDecompressHelpers = new GBAIsometric_Spyro_LocDecompress[langCount][];
                }

                for (int i = 0; i < LocDecompressHelpers.Length; i++)
                {
                    LocDecompressHelpers[i] = LocalizationDecompressionBlockIndices[i].DoAtBlock(size => s.SerializeObjectArray <GBAIsometric_Spyro_LocDecompress>(LocDecompressHelpers[i], size / 3, name: $"{nameof(LocDecompressHelpers)}[{i}]"));
                }

                if (LocBlocks == null)
                {
                    LocBlocks = new GBAIsometric_Spyro_LocBlock[langCount];
                }

                for (int i = 0; i < LocBlocks.Length; i++)
                {
                    LocBlocks[i] = LocalizationBlockIndices[i].DoAtBlock(size =>
                                                                         s.SerializeObject <GBAIsometric_Spyro_LocBlock>(LocBlocks[i], onPreSerialize: lb =>
                    {
                        lb.Length            = LocTables.Max(lt => lt.StartIndex + lt.NumEntries);
                        lb.DecompressHelpers = LocDecompressHelpers[i];
                    }, name: $"{nameof(LocBlocks)}[{i}]"));
                }
            }
            else
            {
                LocalizationPointers = s.DoAt(pointerTable.TryGetItem(GBAIsometric_Spyro_Pointer.LocalizationPointers), () => s.SerializePointerArray(LocalizationPointers, langCount, name: nameof(LocalizationPointers)));

                if (LocBlocks == null)
                {
                    LocBlocks = new GBAIsometric_Spyro_LocBlock[langCount];
                }

                for (int i = 0; i < LocBlocks.Length; i++)
                {
                    LocBlocks[i] = s.DoAt(LocalizationPointers[i], () => s.SerializeObject <GBAIsometric_Spyro_LocBlock>(LocBlocks[i], name: $"{nameof(LocBlocks)}[{i}]"));
                }
            }

            // Store the localization tables so we can access them to get the strings
            s.Context.StoreObject("Loc", LocBlocks.Select(x => x.Strings).ToArray());
        }
 public override void SerializeImpl(SerializerObject s)
 {
     ID           = s.Serialize <uint>(ID, name: nameof(ID));
     Pointer_04   = s.SerializePointer(Pointer_04, name: nameof(Pointer_04));
     MapIndex     = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(MapIndex, name: nameof(MapIndex));
     TileSetIndex = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(TileSetIndex, name: nameof(TileSetIndex));
     PaletteIndex = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(PaletteIndex, name: nameof(PaletteIndex));
     s.Serialize <ushort>(default, name: "Padding");
Ejemplo n.º 8
0
        public override void SerializeImpl(SerializerObject s)
        {
            PalettePointer = s.SerializePointer(PalettePointer, name: nameof(PalettePointer));
            TileSetPointer = s.SerializePointer(TileSetPointer, name: nameof(TileSetPointer));

            Palette = s.DoAt(PalettePointer, () => s.SerializeObject <GBAVV_WorldMap_Palette>(Palette, name: nameof(Palette)));
            TileSet = s.DoAt(TileSetPointer, () => s.SerializeObject <GBAVV_Map2D_TileSet>(TileSet, name: nameof(TileSet)));
        }
Ejemplo n.º 9
0
        public override void SerializeImpl(SerializerObject s)
        {
            // Header
            SceneBlockLength = s.Serialize <uint>(SceneBlockLength, name: nameof(SceneBlockLength));
            Scene            = s.SerializeObject <GBA_Scene>(Scene, onPreSerialize: sc => sc.IsGCNBlock = true, name: nameof(Scene));

            // Data
            s.Goto(Offset + SceneBlockLength);
            PlayFieldBlockLength = s.Serialize <uint>(PlayFieldBlockLength, name: nameof(PlayFieldBlockLength));
            PlayField            = s.SerializeObject <GBA_PlayField>(PlayField, onPreSerialize: pf => pf.IsGCNBlock = true, name: nameof(PlayField));
        }
Ejemplo n.º 10
0
 public override void SerializeImpl(SerializerObject s)
 {
     Flags = s.Serialize <short>(Flags, name: nameof(Flags));
     if (s.GameSettings.GameModeSelection != GameModeSelection.RaymanKartMobile_320x240)
     {
         cg0     = s.Serialize <byte>(cg0, name: nameof(cg0));
         cg1     = s.Serialize <byte>(cg1, name: nameof(cg1));
         Entries = s.SerializeObjectArray <Entry>(Entries, 3, name: nameof(Entries));
     }
     Short2      = s.Serialize <short>(Short2, name: nameof(Short2));
     Byte4       = s.Serialize <byte>(Byte4, name: nameof(Byte4));
     ColorGround = s.SerializeObject <RGB888Color>(ColorGround, name: nameof(ColorGround));
     Color8      = s.SerializeObject <RGB888Color>(Color8, name: nameof(Color8));
 }
        public override void SerializeImpl(SerializerObject s)
        {
            TileSetIndex = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(TileSetIndex, name: nameof(TileSetIndex));
            MapIndex     = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(MapIndex, name: nameof(MapIndex));
            PaletteIndex = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(PaletteIndex, name: nameof(PaletteIndex));

            if (s.GameSettings.EngineVersion == EngineVersion.GBAIsometric_Spyro2)
            {
                Index3 = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(Index3, name: nameof(Index3));
                Index4 = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(Index4, name: nameof(Index4));
            }
            else
            {
                s.Serialize <uint>(default, "Padding");
Ejemplo n.º 12
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));
            }
        }
Ejemplo n.º 13
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));
            }
        }
Ejemplo n.º 14
0
        public override void SerializeBlock(SerializerObject s)
        {
            Data = s.SerializeArray <byte>(Data, BlockSize, name: nameof(Data));

            // Serialize sub-blocks
            if (SubBlocks == null)
            {
                SubBlocks = new GBC_DummyBlock[DependencyTable.DependenciesCount];
            }

            // Get all root pointers
            var rootBlock    = ((GBC_BaseManager)s.GameSettings.GetGameManager).GetLevelList(s.Context);
            var rootTable    = rootBlock.DependencyTable;
            var rootPointers = Enumerable.Range(0, rootTable.Dependencies.Length).Select(x => rootTable.GetPointer(x)).ToArray();

            for (int i = 0; i < DependencyTable.Dependencies.Length; i++)
            {
                var p = DependencyTable.GetPointer(i);

                if (rootPointers.Contains(p) && Offset != rootBlock.Offset)
                {
                    continue;
                }

                SubBlocks[i] = s.DoAt(p, () => s.SerializeObject <GBC_DummyBlock>(SubBlocks[i], name: $"{nameof(SubBlocks)}[{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));
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            // Get offsets
            var offsetTableOffset = s.GameSettings.EngineVersion != EngineVersion.R1Jaguar_Proto ? Offset + 0x1208 : new R1Jaguar_Proto_Manager().GetDataPointer(s.Context, R1Jaguar_Proto_References.test_offlist);
            var eventTableOffset  = s.GameSettings.EngineVersion != EngineVersion.R1Jaguar_Proto ? Offset + 0x1608 : new R1Jaguar_Proto_Manager().GetDataPointer(s.Context, R1Jaguar_Proto_References.test_event);

            MapEvents = s.SerializeObject <R1Jaguar_MapEvents>(MapEvents, name: nameof(MapEvents));

            // Serialize next data block, skipping the padding
            s.DoAt(offsetTableOffset, () => EventOffsetTable = s.SerializeArray <ushort>(EventOffsetTable, MapEvents.EventIndexMap.Max(), name: nameof(EventOffsetTable)));

            if (EventData == null)
            {
                EventData = new R1Jaguar_EventInstance[EventOffsetTable.Length][];
            }

            // Serialize the events based on the offsets
            for (int i = 0; i < EventData.Length; i++)
            {
                s.DoAt(eventTableOffset + EventOffsetTable[i], () =>
                {
                    if (EventData[i] == null)
                    {
                        var temp = new List <R1Jaguar_EventInstance>();

                        var index = 0;
                        while (temp.LastOrDefault()?.Unk_00 != 0)
                        {
                            temp.Add(s.SerializeObject <R1Jaguar_EventInstance>(default, name: $"{nameof(EventData)}[{i}][{index}]"));
Ejemplo n.º 17
0
 public override void SerializeImpl(SerializerObject s)
 {
     DrawIndex = s.Serialize <byte>(DrawIndex, name: nameof(DrawIndex));
     Tile      = s.SerializeObject <TileGraphicsInfo>(Tile, name: nameof(Tile));
     XPos      = s.Serialize <sbyte>(XPos, name: nameof(XPos));
     YPos      = s.Serialize <sbyte>(YPos, name: nameof(YPos));
 }
Ejemplo n.º 18
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}]"));
                }
            }
        }
Ejemplo n.º 19
0
        public override void SerializeBlock(SerializerObject s)
        {
            UShort_00            = s.Serialize <ushort>(UShort_00, name: nameof(UShort_00));
            PatternOffsetsOffset = s.Serialize <ushort>(PatternOffsetsOffset, name: nameof(PatternOffsetsOffset));
            Byte_04      = s.Serialize <byte>(Byte_04, name: nameof(Byte_04));
            PatternCount = s.Serialize <byte>(PatternCount, name: nameof(PatternCount));
            UInt_06      = s.Serialize <uint>(UInt_06, name: nameof(UInt_06));

            s.DoAt(BlockStartPointer + PatternOffsetsOffset, () => {
                PatternOffsets = s.SerializeArray <ushort>(PatternOffsets, PatternCount, name: nameof(PatternOffsets));
            });
            if (Patterns == null)
            {
                Patterns = new Pattern[PatternCount];
            }
            for (int i = 0; i < PatternCount; i++)
            {
                Patterns[i] = s.DoAt(BlockStartPointer + PatternOffsets[i], () => {
                    return(s.SerializeObject <Pattern>(Patterns[i], name: $"{nameof(Patterns)}[{i}]"));
                });
            }
            if (Patterns.Length > 0)
            {
                s.Goto(Patterns[Patterns.Length - 1].Offset + Patterns[Patterns.Length - 1].Size);
            }
        }
Ejemplo n.º 20
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));
                });
            }
        }
Ejemplo n.º 21
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);
            }
        }
Ejemplo n.º 22
0
        public override void SerializeImpl(SerializerObject s)
        {
            Header = s.SerializeObject <LUDI_Header>(Header, name: nameof(Header));
            switch (Header.Type)
            {
            case LUDI_Header.FileType.DataFile:
                OffsetTable = s.SerializeObject <LUDI_OffsetTable>(OffsetTable, name: nameof(OffsetTable));
                break;

            case LUDI_Header.FileType.SpecialFile:
                DataInfo = s.SerializeObject <LUDI_DataInfo>(DataInfo, name: nameof(DataInfo));
                break;

            default:
                throw new NotImplementedException();
            }
        }
Ejemplo n.º 23
0
        public override void SerializeOffsetData(SerializerObject s)
        {
            Palette = s.DoAt(OffsetTable.GetPointer(Index_Palette), () => s.SerializeObject <GBA_SpritePalette>(Palette, name: nameof(Palette)));

            if (!s.GameSettings.GBA_IsMilan)
            {
                TileSet = s.DoAt(OffsetTable.GetPointer(Index_TileSet), () => s.SerializeObject <GBA_SpriteTileSet>(TileSet, onPreSerialize: x =>
                {
                    if (s.GameSettings.EngineVersion == EngineVersion.GBA_Sabrina)
                    {
                        x.IsDataCompressed = BitHelpers.ExtractBits(Byte_04, 1, 5) == 0;
                    }
                }, name: nameof(TileSet)));
            }
            else
            {
                Milan_TileKit = s.DoAt(OffsetTable.GetPointer(Index_TileSet), () => s.SerializeObject <GBA_TileKit>(Milan_TileKit, name: nameof(Milan_TileKit)));
            }

            if (Animations == null)
            {
                Animations = new GBA_Animation[AnimationsCount];
            }

            for (int i = 0; i < Animations.Length; i++)
            {
                Animations[i] = s.DoAt(OffsetTable.GetPointer(AnimationIndexTable[i]), () => s.SerializeObject <GBA_Animation>(Animations[i], name: $"{nameof(Animations)}[{i}]"));
            }

            for (int i = 0; i < Animations.Length; i++)
            {
                if (Animations[i] == null)
                {
                    continue;
                }
                int matrixIndex = Animations[i].AffineMatricesIndex;
                if (matrixIndex != 0)
                {
                    Matrices[matrixIndex] = s.DoAt(OffsetTable.GetPointer(matrixIndex),
                                                   () => s.SerializeObject <GBA_AffineMatrixList>(
                                                       Matrices.ContainsKey(matrixIndex) ? Matrices[matrixIndex] : null,
                                                       onPreSerialize: ml => ml.FrameCount = Animations[i].FrameCount,
                                                       name: $"{nameof(Matrices)}[{matrixIndex}]"));
                }
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            MovementFunctionPointer  = s.SerializeObject <SNES_Pointer>(MovementFunctionPointer, name: nameof(MovementFunctionPointer));
            CollisionFunctionPointer = s.SerializeObject <SNES_Pointer>(CollisionFunctionPointer, name: nameof(CollisionFunctionPointer));
            AnimPointer         = s.SerializeObject <SNES_Pointer>(AnimPointer, name: nameof(AnimPointer));
            Flags               = s.Serialize <StateFlags>(Flags, name: nameof(Flags));
            Byte_07             = s.Serialize <byte>(Byte_07, name: nameof(Byte_07));
            Byte_08_AnimRelated = s.Serialize <byte>(Byte_08_AnimRelated, name: nameof(Byte_08_AnimRelated));
            Byte_09             = s.Serialize <byte>(Byte_09, name: nameof(Byte_09));
            VRAMConfigurationID = s.Serialize <byte>(VRAMConfigurationID, name: nameof(VRAMConfigurationID));
            FrameCount          = s.Serialize <byte>(FrameCount, name: nameof(FrameCount));
            AnimSpeed           = s.Serialize <byte>(AnimSpeed, name: nameof(AnimSpeed));
            Byte_0D             = s.Serialize <byte>(Byte_0D, name: nameof(Byte_0D));
            Byte_0E             = s.Serialize <byte>(Byte_0E, name: nameof(Byte_0E));
            Byte_0F             = s.Serialize <byte>(Byte_0F, name: nameof(Byte_0F));

            // AnimationPointer points to first layer. So, go back 4 bytes to get header
            Animation = s.DoAt(AnimPointer.GetPointer() - 4, () => s.SerializeObject <R1Jaguar_AnimationDescriptor>(Animation, name: nameof(Animation)));
        }
Ejemplo n.º 25
0
 public override void SerializeImpl(SerializerObject s)
 {
     s.DoAt(LBAToPointer(16), () => {
         PrimaryVolumeDescriptor = s.SerializeObject <ISO9960_Sector <ISO9960_VolumeDescriptor_Primary> >(PrimaryVolumeDescriptor, name: nameof(PrimaryVolumeDescriptor));
     });
     s.DoAt(LBAToPointer(PrimaryVolumeDescriptor.Object.PathTableLBA), () => {
         PathTable = s.SerializeObject <ISO9960_Sector <ISO9960_PathTable> >(PathTable, name: nameof(PathTable));
     });
     if (Directories == null)
     {
         Directories = new ISO9960_Sector <ISO9960_Directory> [PathTable.Object.Entries.Length];
         for (int i = 0; i < Directories.Length; i++)
         {
             var entry = PathTable.Object.Entries[i];
             s.DoAt(LBAToPointer(entry.ExtentLBA), () => {
                 Directories[i] = s.SerializeObject <ISO9960_Sector <ISO9960_Directory> >(Directories[i], name: $"{nameof(Directories)}[{i}]");
             });
         }
     }
 }
Ejemplo n.º 26
0
        public override void SerializeImpl(SerializerObject s)
        {
            TileSetIndices = s.SerializeObjectArray <GBAIsometric_Spyro_DataBlockIndex>(TileSetIndices, 4, name: nameof(TileSetIndices));
            MapIndex       = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(MapIndex, name: nameof(MapIndex));
            PaletteIndex   = s.SerializeObject <GBAIsometric_Spyro_DataBlockIndex>(PaletteIndex, name: nameof(PaletteIndex));

            if (TileSets == null)
            {
                TileSets = new byte[TileSetIndices.Length][];
            }

            for (int i = 0; i < TileSets.Length; i++)
            {
                TileSets[i] = TileSetIndices[i].DoAtBlock(size => s.SerializeArray <byte>(TileSets[i], size, name: $"{nameof(TileSets)}[{i}]"));
            }

            Map     = MapIndex.DoAtBlock(size => s.SerializeObject <GBAIsometric_Spyro_SpriteMap>(Map, name: nameof(Map)));
            Palette = PaletteIndex.DoAtBlock(size => s.SerializeObjectArray <RGBA5551Color>(Palette, 256, name: nameof(Palette)));

            s.Log($"Min: {Map.MapData.Where(x => x.TileMapY > 1).Min(x => x.TileMapY)}");
        }
Ejemplo n.º 27
0
 public override void SerializeOffsetData(SerializerObject s)
 {
     base.SerializeOffsetData(s);
     if (s.GameSettings.EngineVersion == EngineVersion.GBA_BatmanVengeance)
     {
         if (StructType != Type.Collision)
         {
             // Serialize tilemap
             TileKit = s.DoAt(OffsetTable.GetPointer(0), () => s.SerializeObject <GBA_TileKit>(TileKit, name: nameof(TileKit)));
         }
     }
 }
Ejemplo n.º 28
0
 public override void SerializeImpl(SerializerObject s)
 {
     FramePointers = s.SerializePointerArray(FramePointers, Length, name: nameof(FramePointers));
     if (Frames == null)
     {
         Frames = new GBARRR_Mode7AnimationFrame[Length];
         for (int i = 0; i < Length; i++)
         {
             Frames[i] = s.DoAt(FramePointers[i], () => s.SerializeObject <GBARRR_Mode7AnimationFrame>(Frames[i], name: $"{nameof(Frames)}[{i}]"));
         }
     }
 }
Ejemplo n.º 29
0
 public override void SerializeImpl(SerializerObject s)
 {
     if (Entries == null)
     {
         List <Entry> entries = new List <Entry>();
         while (entries.Count == 0 || entries.LastOrDefault().DirectoryIdentifierLength != 0)
         {
             entries.Add(s.SerializeObject <Entry>(null, name: $"{nameof(Entries)}[{entries.Count}]"));
         }
         entries.RemoveAt(entries.Count - 1);
         Entries = entries.ToArray();
     }
 }
Ejemplo n.º 30
0
        public override void SerializeImpl(SerializerObject s)
        {
            GraphicsDataPointer        = s.SerializePointer <GBAIsometric_RHR_GraphicsData>(GraphicsDataPointer, resolve: true, name: nameof(GraphicsDataPointer));
            PaletteIndexTablePointer   = s.SerializePointer <GBAIsometric_RHR_PaletteIndexTable>(PaletteIndexTablePointer, resolve: true, onPreSerialize: pit => pit.Length = GraphicsDataPointer.Value.CompressionLookupBufferLength, name: nameof(PaletteIndexTablePointer));
            CombinedTileDataPointer    = s.SerializePointer(CombinedTileDataPointer, name: nameof(CombinedTileDataPointer));
            CombinedTileOffsetsPointer = s.SerializePointer(CombinedTileOffsetsPointer, name: nameof(CombinedTileOffsetsPointer));
            for (int i = 0; i < 4; i++)
            {
                AssembleData[i] = s.SerializeObject <GBAIsometric_RHR_TileAssemble>(AssembleData[i], onPreSerialize: ad => ad.TileCompression = (GBAIsometric_RHR_TileAssemble.Compression)i, name: $"{nameof(AssembleData)}[{i}]");
            }
            PalettesPointer = s.SerializePointer(PalettesPointer, name: nameof(PalettesPointer));

            // Todo: Read these in a less hacky way
            s.DoAt(CombinedTileDataPointer, () => {
                CombinedTileData = s.SerializeArray <ushort>(CombinedTileData, (CombinedTileOffsetsPointer - CombinedTileDataPointer) / 2, name: nameof(CombinedTileData));
            });
            s.DoAt(CombinedTileOffsetsPointer, () => {
                if (CombinedTileDataPointer == CombinedTileOffsetsPointer)
                {
                    CombinedTileOffsets = new ushort[0];
                }
                else
                {
                    uint length = 0;
                    s.DoAt(CombinedTileOffsetsPointer, () => {
                        ushort CombinedTileOffsetsLengthHack = 0;
                        while (CombinedTileOffsetsLengthHack < CombinedTileData.Length)
                        {
                            CombinedTileOffsetsLengthHack = s.Serialize <ushort>(CombinedTileOffsetsLengthHack, name: nameof(CombinedTileOffsetsLengthHack));
                        }
                        length = (uint)((s.CurrentPointer - CombinedTileOffsetsPointer) / 2);
                    });
                    CombinedTileOffsets = s.SerializeArray <ushort>(CombinedTileOffsets, length, name: nameof(CombinedTileOffsets));
                }
            });

            s.DoAt(PalettesPointer, () =>
            {
                if (Palettes == null)
                {
                    Palettes = new RGBA5551Color[PaletteIndexTablePointer.Value.GetMaxPaletteIndex() + 1][];
                }

                for (int i = 0; i < Palettes.Length; i++)
                {
                    Palettes[i] = s.SerializeObjectArray <RGBA5551Color>(Palettes[i], 16, name: $"{nameof(Palettes)}[i]");
                }
            });

            s.DoEncoded(new RHR_SpriteEncoder(false, GraphicsDataPointer.Value.CompressionLookupBuffer, GraphicsDataPointer.Value.CompressedDataPointer), () => {
                byte[] fullSheet = s.SerializeArray <byte>(default, s.CurrentLength, name: nameof(fullSheet));