Exemple #1
0
        /// <summary>
        /// Gets a pointer from the table
        /// </summary>
        /// <param name="index">The offset index</param>
        /// <returns>The pointer</returns>
        public Pointer GetPointer(int index, bool isRelativeOffset = false)
        {
            UsedOffsets[index] = true;
            var pointerTable = PointerTables.GBA_PointerTable(Offset.Context, Context.GetFile(((GBA_Manager)Offset.Context.Settings.GetGameManager).GetROMFilePath(Context)));

            if (Context.Settings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage)
            {
                if (Block == null)
                {
                    return(pointerTable[GBA_Pointer.UiOffsetTable] + Offsets[index]);
                }
                else
                {
                    if (Block.DecompressedBlockOffset != null)
                    {
                        return(Block.DecompressedBlockOffset + Offsets[index]);
                    }
                    else
                    {
                        return(Block.Offset + Offsets[index]);
                    }
                }
            }
            else
            {
                if (isRelativeOffset && Block != null)
                {
                    return(Block.Offset + Offsets[index]);
                }
                else
                {
                    return(pointerTable[GBA_Pointer.UiOffsetTable] + (Offsets[index] * 4));
                }
            }
        }
Exemple #2
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}]"));
                }
            }
        }
        /// <summary>
        /// Gets a pointer from the table
        /// </summary>
        /// <param name="index">The offset index</param>
        /// <returns>The pointer</returns>
        public Pointer GetPointer(int index, bool isRelativeOffset = false)
        {
            if (index >= OffsetsCount)
            {
                throw new Exception($"Invalid offset index {index}, length is {OffsetsCount}");
            }

            UsedOffsets[index] = true;

            var manager      = (GBA_Manager)Offset.Context.Settings.GetGameManager;
            var pointerTable = PointerTables.GBA_PointerTable(Offset.Context, Context.GetFile(manager.GetROMFilePath(Context)));

            var root = pointerTable[GBA_Pointer.UiOffsetTable];

            if (manager.GetLevelType(Context) == GBA_Manager.LevelType.R3SinglePak)
            {
                root = pointerTable[GBA_Pointer.R3SinglePak_OffsetTable];
            }

            if (Context.Settings.EngineVersion == EngineVersion.GBA_SplinterCell_NGage)
            {
                if (Block == null)
                {
                    return(root + Offsets[index]);
                }
                else
                {
                    if (Block.DecompressedBlockOffset != null)
                    {
                        return(Block.DecompressedBlockOffset + Offsets[index]);
                    }
                    else
                    {
                        return(Block.Offset + Offsets[index]);
                    }
                }
            }
            else
            {
                if (isRelativeOffset && Block != null)
                {
                    return(Block.Offset + Offsets[index]);
                }
                else
                {
                    return(root + (Offsets[index] * 4));
                }
            }
        }
Exemple #4
0
        // TODO: Find the way the game gets the vignette offsets
        public override async UniTask ExtractVignetteAsync(GameSettings settings, string outputDir)
        {
            // Create a context
            using (var context = new Context(settings))
            {
                // Load the ROM
                await LoadFilesAsync(context);

                // Get the file
                var file = context.GetFile(GetROMFilePath(context));

                // Get the deserialize
                var s = context.Deserializer;

                var pointerTable = PointerTables.GBA_PointerTable(context, file);

                int vigCount = settings.GameModeSelection == GameModeSelection.Rayman3GBAUSPrototype ? 18 : 20;

                var palettes = new ARGB1555Color[vigCount][];

                for (int i = 0; i < vigCount; i++)
                {
                    palettes[i] = s.DoAt(pointerTable[GBA_Pointer.VignettePalettes] + (512 * i), () => s.SerializeObjectArray <ARGB1555Color>(default, 256));
Exemple #5
0
        public GBA_R3MadTraxSprite[] LoadMadTraxSprites(Context context)
        {
            var output = new List <GBA_R3MadTraxSprite>();

            var file         = (Files)context.Settings.World;
            var pointerTable = PointerTables.GBA_PointerTable(context, context.GetFile(GetROMFilePath(context)));
            var s            = context.Deserializer;

            s.Goto(pointerTable[GBA_Pointer.MadTrax_Sprites]);

            int index = 0;

            loadSprites(width: 8, height: 8, length: 9); // Gumsi
            loadSprites(width: 8, height: 8, length: 9); // Rayman
            loadSprites(width: 2, height: 4, length: 5); // Big blocks

            if (file == Files.client_pad2 || file == Files.client_pad3)
            {
                loadSprites(width: 2, height: 4, length: 2); // Big blocks (are these correct?)
                loadSprites(width: 2, height: 4, length: 5); // Blocks
                loadSprites(width: 1, height: 2, length: 2); // Effect
                loadSprites(width: 4, height: 4, length: 1);
                loadSprites(width: 2, height: 2, length: 4);
                loadSprites(width: 2, height: 2, length: 1);
                loadSprites(width: 1, height: 1, length: 3);

                loadSprites(width: 8, height: 8, length: 1);                                     // ?
                s.Goto(s.CurrentPointer + 0x20 * 1);                                             // ?

                loadSprites(width: 4, height: 8, assmbleWidth: 8, assembleHeight: 2, length: 1); // Controls screen
            }
            else
            {
                loadSprites(width: 4, height: 4, length: 1);                                    // Big blocks
                loadSprites(width: 2, height: 4, length: 1);                                    // Missile
                loadSprites(width: 4, height: 4, length: file == Files.client_pad145 ? 6 : 21); // Blocks
                loadSprites(width: 2, height: 4, length: 6);                                    // Missiles
                loadSprites(width: 2, height: 2, length: 1);                                    // Missiles
                loadSprites(width: 2, height: 1, length: 1);                                    // Effect
                loadSprites(width: 2, height: 4, length: 1);                                    // Vertical bar

                if (file != Files.client_pad145)
                {
                    loadSprites(width: 2, height: 1, length: 1); // Arrow
                }
                loadSprites(width: 2, height: 2, length: 4);

                loadSprites(width: 4, height: 4, length: 7); // Explosion
                loadSprites(width: 2, height: 2, length: 1);
                loadSprites(width: 4, height: 4, length: 1);
                loadSprites(width: 1, height: 1, length: 3);

                s.Goto(s.CurrentPointer + 0x20 * 4);                                             // ?

                loadSprites(width: 4, height: 4, assmbleWidth: 8, assembleHeight: 5, length: 1); // Controls screen
            }

            if (file == Files.client_pad145 || file == Files.client_pad2 || file == Files.client_pad3)
            {
                loadSprites(width: 4, height: 8, assmbleWidth: 8, assembleHeight: 1, length: 1); // Restart
            }
            if (file == Files.client_pad2 || file == Files.client_pad3)
            {
                loadSprites(width: 4, height: 8, assmbleWidth: 8, assembleHeight: 1, length: 1); // Try again
            }
            else
            {
                loadSprites(width: 8, height: 8, length: 1); // Fail
            }
            if (file == Files.client_pad145 || file == Files.client_pad2 || file == Files.client_pad3)
            {
                loadSprites(width: 4, height: 8, assmbleWidth: 8, assembleHeight: 1, length: 1); // Thank you
            }
            else
            {
                loadSprites(width: 4, height: 4, assmbleWidth: 8, assembleHeight: 3, length: 1); // Win
            }
            loadSprites(width: 4, height: 8, assmbleWidth: 8, assembleHeight: 1, length: 1);     // Connection failed

            if (file != Files.client_pad2 && file != Files.client_pad3)
            {
                loadSprites(width: 4, height: 8, assmbleWidth: 4, assembleHeight: 1, length: 1); // Pause
                loadSprites(width: 4, height: 4, length: 1);                                     // Balloon small
                loadSprites(width: 8, height: 8, length: 1);                                     // Balloon big
                loadSprites(width: 8, height: 4, length: 4);                                     // 3, 2, 1, Go!
                loadSprites(width: 2, height: 2, length: 9);                                     // 1-9
                loadSprites(width: 4, height: 2, assmbleWidth: 2, assembleHeight: 1, length: 1); // Level
            }

            void loadSprites(int width, int height, int assmbleWidth = 1, int assembleHeight = 1, int length = 1)
            {
                for (int i = 0; i < length; i++)
                {
                    output.Add(s.SerializeObject <GBA_R3MadTraxSprite>(default, onPreSerialize: x =>