Beispiel #1
0
            public override void SerializeImpl(SerializerObject s)
            {
                switch (TileCompression)
                {
                case Compression.RLE1:
                    s.DoEncoded(new RHR_RLETileEncoder(RHR_RLETileEncoder.RLEMode.RLE1), () => {
                        TileIndices = s.SerializeArray <ushort>(TileIndices, 64, name: nameof(TileIndices));
                    });
                    break;

                case Compression.RLE2:
                    s.DoEncoded(new RHR_RLETileEncoder(RHR_RLETileEncoder.RLEMode.RLE2), () => {
                        TileIndices = s.SerializeArray <ushort>(TileIndices, 64, name: nameof(TileIndices));
                    });
                    break;

                case Compression.BlockDiff:
                    BaseMapEntry = s.Serialize <ushort>(BaseMapEntry, name: nameof(BaseMapEntry));
                    Padding      = s.Serialize <ushort>(Padding, name: nameof(Padding));
                    s.DoEncoded(new RHREncoder(RHREncoder.EncoderMode.TileData), () => {
                        TileIndices = s.SerializeArray <ushort>(TileIndices, 64, name: nameof(TileIndices));
                    });
                    break;

                case Compression.Block:
                    s.DoEncoded(new RHREncoder(RHREncoder.EncoderMode.TileData), () => {
                        TileIndices = s.SerializeArray <ushort>(TileIndices, 64, name: nameof(TileIndices));
                    });
                    break;
                }
            }
Beispiel #2
0
 public override void SerializeBlock(SerializerObject s)
 {
     Width        = s.Serialize <uint>(Width, name: nameof(Width));
     Height       = s.Serialize <uint>(Height, name: nameof(Height));
     Speed        = s.Serialize <uint>(Speed, name: nameof(Speed));
     FrameCount   = s.Serialize <uint>(FrameCount, name: nameof(FrameCount));
     FrameOffsets = s.SerializeArray <uint>(FrameOffsets, FrameCount, name: nameof(FrameOffsets));
     if (s.GameSettings.EngineVersion == EngineVersion.GBC_R1_PocketPC)
     {
         if (FrameDataPPC == null)
         {
             FrameDataPPC = new BGR565Color[FrameCount][];
         }
         for (int i = 0; i < FrameDataPPC.Length; i++)
         {
             uint decompressedSize = Width * Height * 2;
             uint nextOff          = i < FrameDataPPC.Length - 1 ? FrameOffsets[i + 1] : BlockSize;
             uint compressedSize   = nextOff - FrameOffsets[i];
             s.DoAt(BlockStartPointer + FrameOffsets[i], () => {
                 s.DoEncoded(new Lzo1xEncoder(compressedSize, decompressedSize), () => {
                     FrameDataPPC[i] = s.SerializeObjectArray <BGR565Color>(FrameDataPPC[i], Width * Height, name: $"{nameof(FrameDataPPC)}[{i}]");
                 });
             });
         }
     }
 }
Beispiel #3
0
        public void SerializeVignette(SerializerObject s, bool isImgDataCompressed)
        {
            // Serialize data from pointers

            s.DoAt(ImageDataPointer, () => {
                if (s.Context.Settings.GameModeSelection == GameModeSelection.RaymanDSi)
                {
                    if (isImgDataCompressed)
                    {
                        s.DoEncoded(new GBA_LZSSEncoder(), () => ImageData = s.SerializeArray <byte>(ImageData, 0x40 * Width * Height, name: nameof(ImageData)));
                    }
                    else
                    {
                        ImageData = s.SerializeArray <byte>(ImageData, 0x40 * Width * Height, name: nameof(ImageData));
                    }
                }
                else
                {
                    ImageData = s.SerializeArray <byte>(ImageData, 0x20 * Width * Height, name: nameof(ImageData));
                }
            });

            s.DoAt(BlockIndicesPointer, () => BlockIndices = s.SerializeArray <ushort>(BlockIndices, Width * Height, name: nameof(BlockIndices)));

            s.DoAt(PaletteIndicesPointer, () => PaletteIndices = s.SerializeArray <byte>(PaletteIndices, Width * Height, name: nameof(PaletteIndices)));

            s.DoAt(PalettesPointer, () => {
                Palettes = s.SerializeObjectArray <ARGB1555Color>(Palettes,
                                                                  (s.Context.Settings.GameModeSelection == GameModeSelection.RaymanDSi) ? 256 : (PaletteCount * 16),
                                                                  name: nameof(Palettes));
            });
        }
Beispiel #4
0
        public override void SerializeBlock(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion == EngineVersion.GBA_BatmanVengeance)
            {
                Byte_03       = s.Serialize <byte>(Byte_03, name: nameof(Byte_03));
                IsCompressed  = s.Serialize <bool>(IsCompressed, name: nameof(IsCompressed));
                TileMapLength = s.Serialize <ushort>(TileMapLength, name: nameof(TileMapLength));
            }
            else
            {
                TileMapLength = s.Serialize <ushort>(TileMapLength, name: nameof(TileMapLength));
                IsCompressed  = s.Serialize <bool>(IsCompressed, name: nameof(IsCompressed));
                Byte_03       = s.Serialize <byte>(Byte_03, name: nameof(Byte_03));
            }

            if (IsDataCompressed ?? IsCompressed)
            {
                s.DoEncoded(new GBA_LZSSEncoder(), () => TileMap = s.SerializeArray <byte>(TileMap, TileMapLength * 32, name: nameof(TileMap)));
                s.Align();
            }
            else
            {
                TileMap = s.SerializeArray <byte>(TileMap, TileMapLength * 32, name: nameof(TileMap));
            }
        }
Beispiel #5
0
        public override void SerializeImpl(SerializerObject s)
        {
            MapLayers = s.SerializeObjectArray <Layer>(MapLayers, 4, name: nameof(MapLayers));

            ObjectsCount    = s.Serialize <int>(ObjectsCount, name: nameof(ObjectsCount));
            WaypointsCount  = s.Serialize <int>(WaypointsCount, name: nameof(WaypointsCount));
            CollisionWidth  = s.Serialize <int>(CollisionWidth, name: nameof(CollisionWidth));
            CollisionHeight = s.Serialize <int>(CollisionHeight, name: nameof(CollisionHeight));

            ObjectsPointer   = s.SerializePointer(ObjectsPointer, name: nameof(ObjectsPointer));
            WaypointsPointer = s.SerializePointer(WaypointsPointer, name: nameof(WaypointsPointer));
            CollisionPointer = s.SerializePointer(CollisionPointer, name: nameof(CollisionPointer));

            Byte_6C = s.Serialize <byte>(Byte_6C, name: nameof(Byte_6C));
            Byte_6D = s.Serialize <byte>(Byte_6D, name: nameof(Byte_6D));
            Byte_6E = s.Serialize <byte>(Byte_6E, name: nameof(Byte_6E));
            Byte_6F = s.Serialize <byte>(Byte_6F, name: nameof(Byte_6F));

            LevelNameLocIndex = s.SerializeObject <GBAIsometric_LocIndex>(LevelNameLocIndex, name: nameof(LevelNameLocIndex));

            // Parse from pointers
            Objects   = s.DoAt(ObjectsPointer, () => s.SerializeObjectArray <GBAIsometric_Object>(Objects, ObjectsCount, name: nameof(Objects)));
            Waypoints = s.DoAt(WaypointsPointer, () => s.SerializeObjectArray <GBAIsometric_RHR_Waypoint>(Waypoints, WaypointsCount, name: nameof(Waypoints)));

            s.DoAt(CollisionPointer, () =>
            {
                s.DoEncoded(new RHREncoder(), () => CollisionData = s.SerializeObjectArray <GBAIsometric_TileCollision>(CollisionData, CollisionWidth * CollisionHeight, name: nameof(CollisionData)));
            });
        }
        public override void SerializeBlock(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion <= EngineVersion.GBA_BatmanVengeance)
            {
                Is8Bit        = s.Serialize <bool>(Is8Bit, name: nameof(Is8Bit));
                IsCompressed  = s.Serialize <bool>(IsCompressed, name: nameof(IsCompressed));
                TileSetLength = s.Serialize <ushort>(TileSetLength, name: nameof(TileSetLength));
            }
            else
            {
                TileSetLength = s.Serialize <ushort>(TileSetLength, name: nameof(TileSetLength));
                IsCompressed  = s.Serialize <bool>(IsCompressed, name: nameof(IsCompressed));
                Is8Bit        = s.Serialize <bool>(Is8Bit, name: nameof(Is8Bit));
            }

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

            if (IsDataCompressed ?? IsCompressed)
            {
                s.DoEncoded(new GBA_LZSSEncoder(), () => TileSet = s.SerializeArray <byte>(TileSet, TileSetLength * tileLength, name: nameof(TileSet)));
                s.Align();
            }
            else
            {
                TileSet = s.SerializeArray <byte>(TileSet, TileSetLength * tileLength, name: nameof(TileSet));
            }
        }
Beispiel #7
0
        public override void SerializeImpl(SerializerObject s)
        {
            DataPointer        = s.SerializePointer(DataPointer, name: nameof(DataPointer));
            DataOffsetsPointer = s.SerializePointer(DataOffsetsPointer, name: nameof(DataOffsetsPointer));

            s.DoAt(DataOffsetsPointer, () =>
            {
                s.DoEncoded(new RHREncoder(), () => DataOffsets = s.SerializeArray <ushort>(DataOffsets, s.CurrentLength / 2, name: nameof(DataOffsets)));
            });
            if (Data == null)
            {
                if (DataOffsets != null)
                {
                    Data = new TileData[DataOffsets.Length];
                    for (int i = 0; i < DataOffsets.Length; i++)
                    {
                        s.DoAt(DataPointer + DataOffsets[i] * 4, () => {
                            Data[i] = s.SerializeObject <TileData>(Data[i], onPreSerialize: td => td.TileCompression = TileCompression, name: $"{nameof(Data)}[{i}]");
                        });
                    }
                }
                else
                {
                    Data = new TileData[0];
                }
            }
        }
 public override void SerializeBlock(SerializerObject s)
 {
     TotalBlockSize   = s.Serialize <uint>(TotalBlockSize, name: nameof(TotalBlockSize));
     DecompressedSize = s.Serialize <uint>(DecompressedSize, name: nameof(DecompressedSize));
     CompressedSize   = s.Serialize <uint>(CompressedSize, name: nameof(CompressedSize));
     s.DoEncoded(new Lzo1xEncoder(CompressedSize, DecompressedSize), () => {
         Value = s.SerializeObject <T>(Value, name: nameof(Value));
     }, R1Engine.Serialize.BinaryFile.Endian.Little);
 }
Beispiel #9
0
        public override void SerializeImpl(SerializerObject s)
        {
            SerializeBlockSize(s);
            if (IsBlockCompressed)
            {
                DecompressedBlockSize = s.Serialize <uint>(DecompressedBlockSize ?? 0, name: nameof(DecompressedBlockSize));
                s.DoEncoded(new ZlibEncoder(CompressedBlockSize.Value, DecompressedBlockSize.Value), () => {
                    BlockSize = s.Serialize <uint>(BlockSize, name: nameof(BlockSize));
                    DecompressedBlockOffset = s.CurrentPointer;
                    SerializeOffsetTable(s);
                    SerializeBlock(s);
                    if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage)
                    {
                        s.Align();
                    }
                    CheckBlockSize(s);
                    // Serialize data from the offset table
                    SerializeOffsetData(s);
                    s.Goto(s.CurrentPointer.file.StartPointer + s.CurrentLength); // no warning
                });
            }
            else
            {
                // GCN blocks don't have offset tables before the block
                if (!IsGCNBlock)
                {
                    SerializeOffsetTable(s);
                }

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

                // Serialize the block
                SerializeBlock(s);

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

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

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

                // Serialize data from the offset table
                SerializeOffsetData(s);
            }
        }
        /// <summary>
        /// Handles the data serialization
        /// </summary>
        /// <param name="s">The serializer object</param>
        public override void SerializeImpl(SerializerObject s)
        {
            MusicDataPointer = s.SerializePointer(MusicDataPointer, name: nameof(MusicDataPointer));
            UShort_04        = s.Serialize <ushort>(UShort_04, name: nameof(UShort_04));
            Short_06         = s.Serialize <short>(Short_06, name: nameof(Short_06));
            Unk = s.SerializeArray <byte>(Unk, 8, name: nameof(Unk));

            s.DoAt(MusicDataPointer, () => {
                s.DoEncoded(new RNCEncoder(), () => {
                    MusicData = s.SerializeObjectArray(MusicData, s.CurrentLength / 0x8, name: nameof(MusicData));
                });
            });
        }
        public override void SerializeImpl(SerializerObject s)
        {
            Info   = s.SerializeObject <GBAIsometric_RHR_SpriteInfo>(Info, name: nameof(Info));
            Is8Bit = s.Serialize <bool>(Is8Bit, name: nameof(Is8Bit));
            GraphicsDataPointer          = s.SerializePointer <GBAIsometric_RHR_GraphicsData>(GraphicsDataPointer, resolve: true, name: nameof(GraphicsDataPointer));
            LookupBufferPositionsPointer = s.SerializePointer(LookupBufferPositionsPointer, name: nameof(LookupBufferPositionsPointer));
            NamePointer = s.SerializePointer(NamePointer, name: nameof(NamePointer));

            LookupBufferPositions = s.DoAt(LookupBufferPositionsPointer, () => s.SerializeArray <ushort>(LookupBufferPositions, Info.CanvasWidth * Info.CanvasHeight, name: nameof(LookupBufferPositions)));
            Name = s.DoAt(NamePointer, () => s.SerializeString(Name, name: nameof(Name)));

            s.DoEncoded(new RHR_SpriteEncoder(Is8Bit, Info, LookupBufferPositions, GraphicsDataPointer.Value), () => {
                Sprite = s.SerializeArray <byte>(Sprite, s.CurrentLength, name: nameof(Sprite));
            });
            //s.DoEncoded(new RHR_SpriteEncoder(Is8Bit, GraphicsDataPointer.Value.CompressionLookupBuffer, GraphicsDataPointer.Value.CompressedDataPointer), () => {
            //    byte[] fullSheet = s.SerializeArray<byte>(default, s.CurrentLength, name: nameof(fullSheet));
            //    //Util.ByteArrayToFile(Context.BasePath + $"sprites/Full_{Offset.StringAbsoluteOffset}.bin", fullSheet);
            //});
        }
Beispiel #12
0
 public override void SerializeImpl(SerializerObject s)
 {
     SerializeBlockSize(s);
     if (IsBlockCompressed)
     {
         DecompressedBlockSize = s.Serialize <uint>(DecompressedBlockSize ?? 0, name: nameof(DecompressedBlockSize));
         s.DoEncoded(new ZlibEncoder(CompressedBlockSize.Value, DecompressedBlockSize.Value), () => {
             BlockSize = s.Serialize <uint>(BlockSize, name: nameof(BlockSize));
             DecompressedBlockOffset = s.CurrentPointer;
             SerializeOffsetTable(s);
             SerializeBlock(s);
             if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage)
             {
                 s.Align();
             }
             CheckBlockSize(s);
             // Serialize data from the offset table
             SerializeOffsetData(s);
             s.Goto(s.CurrentPointer.file.StartPointer + s.CurrentLength); // no warning
         });
     }
     else
     {
         if (!IsGCNBlock)
         {
             SerializeOffsetTable(s);
         }
         SerializeBlock(s);
         if (s.GameSettings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage || IsGCNBlock)
         {
             s.Align();
         }
         CheckBlockSize(s);
         if (IsGCNBlock)
         {
             SerializeOffsetTable(s);
         }
         // Serialize data from the offset table
         SerializeOffsetData(s);
     }
 }