Exemple #1
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}]"));
                }
            }
        }
Exemple #2
0
        internal static CMapTable GetCMAP(Reader reader)
        {
            reader.Position = 4;
            ushort numTables     = (ushort)reader.ReadUint16();
            ushort searchRange   = (ushort)reader.ReadUint16();
            ushort entrySelector = (ushort)reader.ReadUint16();
            ushort rangeShift    = (ushort)reader.ReadUint16();

            int offset = -1;
            int length = -1;

            for (int i = 0; i < numTables; ++i)
            {
                OffsetTable table = new OffsetTable();
                table.Read(reader);
                if (table.Tag == "cmap")
                {
                    offset = (int)table.Offset;
                    length = (int)table.Length;
                    break;
                }
            }

            CMapTable cmap = new CMapTable();

            cmap.Read(reader, offset, length);
            return(cmap);
        }
Exemple #3
0
        public override void SerializeOffsetData(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion > EngineVersion.GBA_R3_MadTrax)
            {
                // Serialize tile palette
                if (Palettes == null)
                {
                    Palettes = new GBA_Palette[PaletteCount];
                }
                for (int p = 0; p < Palettes.Length; p++)
                {
                    Palettes[p] = s.DoAt(OffsetTable.GetPointer(PaletteIndices[p]), () => s.SerializeObject <GBA_Palette>(Palettes[p], name: $"{nameof(Palettes)}[{p}]"));
                }

                // Serialize tile animations
                if (AnimatedTileKitManagerIndex != 0xFF)
                {
                    AnimatedTileKitManager = s.DoAt(OffsetTable.GetPointer(AnimatedTileKitManagerIndex), () => s.SerializeObject <GBA_AnimatedTileKitManager>(AnimatedTileKitManager, name: nameof(AnimatedTileKitManager)));
                    if (AnimatedTileKits == null)
                    {
                        AnimatedTileKits = new GBA_AnimatedTileKit[AnimatedTileKitManager.Length];
                    }
                    for (int i = 0; i < AnimatedTileKits.Length; i++)
                    {
                        AnimatedTileKits[i] = s.DoAt(OffsetTable.GetPointer(AnimatedTileKitManager.TileKitBlocks[i]), () => s.SerializeObject <GBA_AnimatedTileKit>(AnimatedTileKits[i], name: $"{nameof(AnimatedTileKits)}[{i}]"));
                    }
                    Debug.Log("Level " + s.GameSettings.Level + " (" + s.GameSettings.World + ") has " + AnimatedTileKits.Length + " animated tilekits.");
                }
            }
        }
        /************************
         * public static methods
         */


        public static new OTFontVal ReadFont(OTFile file, uint FontFileNumber, uint filepos)
        {
            OTFontVal f = null;

            OffsetTable ot = ReadOffsetTable(file, filepos);

            if (ot != null)
            {
                if (ot.numTables == ot.DirectoryEntries.Count)
                {
                    OutlineType olt = OutlineType.OUTLINE_INVALID;
                    for (int i = 0; i < ot.DirectoryEntries.Count; i++)
                    {
                        DirectoryEntry temp   = (DirectoryEntry)ot.DirectoryEntries[i];
                        string         sTable = (string)temp.tag;
                        if (sTable == "CFF ")
                        {
                            olt = OutlineType.OUTLINE_POSTSCRIPT;
                            break;
                        }
                        else if (sTable == "glyf")
                        {
                            olt = OutlineType.OUTLINE_TRUETYPE;
                            break;
                        }
                    }

                    f = new OTFontVal(file, FontFileNumber, ot, olt);
                }
            }
            return(f);
        }
Exemple #5
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}]"));
                }
            }
        }
Exemple #6
0
 /// <summary>
 /// Load the offset table with a given slot count from the page data
 /// </summary>
 private void LoadOffsetTable(int slotCount)
 {
     for (var i = 2; i <= (slotCount * 2); i += 2)
     {
         OffsetTable.Add(BitConverter.ToUInt16(PageData, PageData.Length - i));
     }
 }
Exemple #7
0
        void Unpack24bpp()
        {
            int extra_row = m_output.Length - m_stride;
            var rows      = new int[3] {
                0, extra_row, extra_row
            };
            var offset_table = OffsetTable.Clone() as int[];

            for (int y = 0; y < m_height; ++y)
            {
                int dst = rows[0];
                for (int x = 0; x < m_width;)
                {
                    int ctl = m_input.GetBits(ControlTable1, 13);
                    if (0xB8 == ctl)
                    {
                        ctl += m_input.GetBits(ControlTable2, 13);
                    }

                    int pos      = m_input.GetBits(PosTable24, 6) * 2;
                    int x_offset = offset_table[pos];
                    int y_offset = offset_table[pos + 1];
                    if (pos > 0)
                    {
                        offset_table[pos]     = offset_table[pos - 2];
                        offset_table[pos + 1] = offset_table[pos - 1];
                        offset_table[pos - 2] = x_offset;
                        offset_table[pos - 1] = y_offset;
                    }

                    int src = rows[y_offset] + (x + x_offset) * 4;
                    if (ctl >= 0xD8)
                    {
                        int count = ctl - 0xD6;
                        Binary.CopyOverlapped(m_output, src, dst, count * 4);
                        dst += count * 4;
                        x   += count;
                    }
                    else
                    {
                        for (int j = 2; j >= 0; --j)
                        {
                            byte r = RgbBits[j, ctl];
                            if (0xFD == r)
                            {
                                r = GetDelta(DeltaTable);
                            }

                            m_output[dst + j] = (byte)(m_output[src + j] - r);
                        }
                        dst += 4;
                        ++x;
                    }
                }
                rows[2]  = rows[1];
                rows[1]  = rows[0];
                rows[0] += m_stride;
            }
        }
 public SettingEntry(OffsetTable offsetTable, BinaryContainer binary, int startOffset) : base(offsetTable, binary, startOffset)
 {
     _typeCache = Type;
     if (_typeCache == SettingEntryType.Binary || _typeCache == SettingEntryType.UnicodeString)
     {
         offsetTable["BinaryValue"].Length = GetValue <int>();
     }
 }
Exemple #9
0
        protected GpdFile(OffsetTable offsetTable, BinaryContainer binary, int startOffset)
            : base(offsetTable, binary, startOffset)
        {
            _entryTableSize = EntryTableLength * EntrySize;
            _freeTableSize  = FreeSpaceTableLength * FreeSpaceEntrySize;
            _tableSize      = _entryTableSize + _freeTableSize + 0x18;

            Initialize();
        }
Exemple #10
0
 private TrueTypeFont(string source, OffsetTable offsetTable, IReadOnlyDictionary <string, TableRecordEntry> entries, CmapTable cmapTable, NameTable nameTable, KernTable kernTable)
 {
     this.Source             = source;
     this.OffsetTable        = offsetTable;
     this.TableRecordEntries = entries;
     this.CmapTable          = cmapTable;
     this.NameTable          = nameTable;
     this.KernTable          = kernTable;
 }
 protected DashboardFile(OffsetTable offsetTable, BinaryContainer binary, int startOffset) : base(offsetTable, binary, startOffset)
 {
     //if (!HasEntry(EntryType.Setting, (int)SettingId.GamercardZone)) Settings.Set(SettingId.GamercardZone, 0);
     //if (!HasEntry(EntryType.Setting, (int)SettingId.GamercardRegion)) Settings.Set(SettingId.GamercardRegion, 2);
     //if (!HasEntry(EntryType.Setting, (int)SettingId.YearsOnLive)) Settings.Set(SettingId.YearsOnLive, 0);
     //if (!HasEntry(EntryType.Setting, (int)SettingId.GamercardMotto)) Settings.Set(SettingId.GamercardMotto, String.Empty);
     //if (!HasEntry(EntryType.Setting, (int)SettingId.GamercardUserLocation)) Settings.Set(SettingId.GamercardUserLocation, String.Empty);
     //if (!HasEntry(EntryType.Setting, (int)SettingId.GamercardUserName)) Settings.Set(SettingId.GamercardUserName, String.Empty);
     //if (!HasEntry(EntryType.Setting, (int)SettingId.GamercardUserBio)) Settings.Set(SettingId.GamercardUserBio, String.Empty);
     //if (!HasEntry(EntryType.Setting, (int)SettingId.GamercardRep)) Settings.Set(SettingId.GamercardRep, (float)0.0);
 }
Exemple #12
0
 public override void SerializeOffsetData(SerializerObject s)
 {
     if (s.GameSettings.GBA_IsShanghai)
     {
         TileSet = s.DoAt(OffsetTable.GetPointer(0), () => s.SerializeObject <GBA_SpriteTileSet>(TileSet, name: nameof(TileSet)));
     }
     else
     {
         Palette = s.DoAt(OffsetTable.GetPointer(Index_Palette), () => s.SerializeObject <GBA_SpritePalette>(Palette, name: nameof(Palette)));
         TileSet = s.DoAt(OffsetTable.GetPointer(Index_TileSet), () => s.SerializeObject <GBA_SpriteTileSet>(TileSet, name: nameof(TileSet)));
     }
 }
Exemple #13
0
        private void AssertHasAllRequiredTables(OffsetTable offsetTable)
        {
            var required = new[] { "cmap", "glyf", "head", "hhea", "hmtx", "loca", "maxp", "name", "post" };
            var tables   = offsetTable.Entries.Keys;

            var missingTables = required.Except(tables).ToList();

            if (missingTables.Any())
            {
                throw new FormatException("Missing tables: " + string.Join(", ", missingTables));
            }
        }
Exemple #14
0
        /// <summary>
        /// Refresh the Page
        /// </summary>
        public virtual void Refresh(bool suppressLoad)
        {
            if (PageAddress != PageAddress.Empty)
            {
                if (!suppressLoad)
                {
                    OffsetTable.Clear();
                }

                LoadPage(suppressLoad);
            }
        }
Exemple #15
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)));
         }
     }
 }
Exemple #16
0
        public override void SerializeBlock(SerializerObject s)
        {
            // Serialize blocks
            if (Blocks == null)
            {
                Blocks = new T[OffsetTable.OffsetsCount];
            }

            for (int i = 0; i < Blocks.Length; i++)
            {
                Blocks[i] = s.DoAt(OffsetTable.GetPointer(i), () => s.SerializeObject <T>(Blocks[i], name: $"{nameof(Blocks)}[{i}]"));
            }
        }
Exemple #17
0
        public static TrueTypeFont FromFile(string path)
        {
            using (var reader = new FontReader(File.OpenRead(path)))
            {
                var offsetTable = OffsetTable.FromReader(reader);
                var entries     = ReadTableRecords(reader, offsetTable);

                var cmap = ReadCmapTable(path, reader, entries);
                var name = ReadNameTable(path, reader, entries);
                var kern = ReadKernTable(reader, entries);

                return(new TrueTypeFont(path, offsetTable, entries, cmap, name, kern));
            }
        }
Exemple #18
0
        public static TrueTypeFont FromStream(Stream stream)
        {
            using (var reader = new FontReader(stream))
            {
                var offsetTable = OffsetTable.FromReader(reader);
                var entries     = ReadTableRecords(reader, offsetTable);

                var cmap = ReadCmapTable(string.Empty, reader, entries);
                var name = ReadNameTable(string.Empty, reader, entries);
                var kern = ReadKernTable(reader, entries);

                return(new TrueTypeFont(string.Empty, offsetTable, entries, cmap, name, kern));
            }
        }
Exemple #19
0
 public override void SerializeOffsetData(SerializerObject s)
 {
     base.SerializeOffsetData(s);
     if (SubBlocks == null)
     {
         SubBlocks = new GBA_DummyBlock[OffsetTable.OffsetsCount];
     }
     for (int i = 0; i < OffsetTable.Offsets.Length; i++)
     {
         s.DoAt(OffsetTable.GetPointer(i), () => {
             SubBlocks[i] = s.SerializeObject <GBA_DummyBlock>(SubBlocks[i], name: $"{nameof(SubBlocks)}[{i}]");
         });
     }
 }
Exemple #20
0
        public static bool TryGetTablePosition(FontReader reader, string tableName, out long offset)
        {
            reader.Seek(0);
            var offsetTable = OffsetTable.FromReader(reader);
            var entries     = ReadTableRecords(reader, offsetTable);

            if (entries.TryGetValue(tableName, out var cmapEntry))
            {
                offset = cmapEntry.Offset;
                return(true);
            }

            offset = 0;
            return(false);
        }
Exemple #21
0
        internal Font(FontStreamReader reader, OffsetTable offsetTable)
        {
            this.reader      = reader;
            this.offsetTable = offsetTable;

            HeadTable = HeadTable.Read(reader, offsetTable.Entries["head"]);
            if (offsetTable.Entries.ContainsKey("fpgm"))
            {
                fpgmTable = FpgmTable.Read(reader, offsetTable.Entries["fpgm"]);
            }
            cmapTable = CmapTable.Read(reader, offsetTable.Entries["cmap"]);
            locaTable = LocaTable.Read(this, reader, offsetTable.Entries["loca"]);
            glyfTable = GlyfTable.Read(reader, offsetTable.Entries["glyf"]);

            //TODO run fpgm
        }
Exemple #22
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}]"));
                }
            }
        }
        public override void SerializeOffsetData(SerializerObject s)
        {
            if (ActorModels == null)
            {
                ActorModels = new GBA_Shanghai_ActorModel[ActorModelsCount];
            }

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

            // Set the actor models
            foreach (var a in Actors)
            {
                a.GBA_ActorModel = ActorModels[a.Index_ActorModel];
            }
        }
        public override void SerializeOffsetData(SerializerObject s)
        {
            var blockIndex = 0;

            PlayField = s.DoAt(OffsetTable.GetPointer(blockIndex++), () => s.SerializeObject <GBA_PlayField>(PlayField, name: nameof(PlayField)));

            if (s.GameSettings.EngineVersion == EngineVersion.GBA_TomClancysRainbowSixRogueSpear)
            {
                TomClancy_TilePalette = s.DoAt(OffsetTable.GetPointer(blockIndex++), () => s.SerializeObject <GBA_Palette>(TomClancy_TilePalette, name: nameof(TomClancy_TilePalette)));
                TomClancy_ObjPalette  = s.DoAt(OffsetTable.GetPointer(blockIndex++), () => s.SerializeObject <GBA_Palette>(TomClancy_ObjPalette, name: nameof(TomClancy_ObjPalette)));
            }

            ActorsBlock = s.DoAt(OffsetTable.GetPointer(blockIndex++), () => s.SerializeObject <GBA_Milan_ActorsBlock>(ActorsBlock, name: nameof(ActorsBlock)));

            Block_02 = s.DoAt(OffsetTable.GetPointer(blockIndex++), () => s.SerializeObject <GBA_DummyBlock>(Block_02, name: nameof(Block_02)));
            Block_03 = s.DoAt(OffsetTable.GetPointer(blockIndex++), () => s.SerializeObject <GBA_DummyBlock>(Block_03, name: nameof(Block_03)));

            CaptorsBlock = s.DoAt(OffsetTable.GetPointer(blockIndex++), () => s.SerializeObject <GBA_Milan_ActorsBlock>(CaptorsBlock, x => x.IsCaptor = true, name: nameof(CaptorsBlock)));
        }
        public override void SerializeOffsetData(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion == EngineVersion.GBA_BatmanVengeance)
            {
                SpriteGroup_BatmanVengeance = s.DoAt(OffsetTable.GetPointer(SpriteGroupOffsetIndex), () => s.SerializeObject <GBA_BatmanVengeance_SpriteGroup>(SpriteGroup_BatmanVengeance, name: nameof(SpriteGroup_BatmanVengeance)));
            }
            else
            {
                SpriteGroup = s.DoAt(OffsetTable.GetPointer(SpriteGroupOffsetIndex), () => s.SerializeObject <GBA_SpriteGroup>(SpriteGroup, name: nameof(SpriteGroup)));
            }

            // Parse state data
            for (var i = 0; i < States.Length; i++)
            {
                if (States[i].StateDataType != -1)
                {
                    States[i].StateData = s.DoAt(OffsetTable.GetPointer(States[i].StateDataOffsetIndex), () => s.SerializeObject <GBA_ActorStateData>(States[i].StateData, name: $"{nameof(GBA_ActorState.StateData)}[{i}]"));
                }
            }
        }
Exemple #26
0
        public static void SendLoginSuccess(this Client client, byte region)
        {
            using (var p = new BufferWriter(CServerMsg.LoginResponse))
            {
                p.WriteInt(); //success code ( 0 )

                OffsetTable offsets = null;

                switch (region)
                {
                case 0:     //sea
                    offsets = OffsetTable.SeaTable;
                    break;

                case 1:     //eu
                    offsets = OffsetTable.EuTable;
                    break;
                }

                if (offsets == null)
                {
                    p.WriteInt(0);
                }
                else
                {
                    p.WriteInt(offsets.Offsets.Count); //loop count length

                    foreach (var x in offsets.Offsets) //all offets
                    {
                        p.WriteInt(x.Key);             //Map position
                        p.WriteInt(x.Key ^ x.Value);   //Real offset value
                    }
                }

                client.Send(p);
            }
        }
Exemple #27
0
        public override void SerializeOffsetData(SerializerObject s)
        {
            if (s.GameSettings.EngineVersion == EngineVersion.GBA_BatmanVengeance)
            {
                Puppet_BatmanVengeance = s.DoAt(OffsetTable.GetPointer(Index_Puppet), () => s.SerializeObject <GBA_BatmanVengeance_Puppet>(Puppet_BatmanVengeance, name: nameof(Puppet_BatmanVengeance)));
            }
            else if (s.GameSettings.GBA_IsMilan)
            {
                if (s.GameSettings.EngineVersion == EngineVersion.GBA_TomClancysRainbowSixRogueSpear)
                {
                    TomClancy_Puppets = s.DoAt(OffsetTable.GetPointer(0), () => s.SerializeObject <GBA_BlockArray <GBA_BatmanVengeance_Puppet> >(TomClancy_Puppets, name: nameof(TomClancy_Puppets)));
                }
                else
                {
                    Milan_Puppets = s.DoAt(OffsetTable.GetPointer(0), () => s.SerializeObject <GBA_BlockArray <GBA_Puppet> >(Milan_Puppets, name: nameof(Milan_Puppets)));
                }

                Milan_Actions = s.DoAt(OffsetTable.GetPointer(1), () => s.SerializeObject <GBA_BlockArray <GBA_Milan_ActionBlock> >(Milan_Actions, name: nameof(Milan_Actions)));
            }
            else
            {
                Puppet = s.DoAt(OffsetTable.GetPointer(Index_Puppet), () => s.SerializeObject <GBA_Puppet>(Puppet, name: nameof(Puppet)));
            }

            if (!s.GameSettings.GBA_IsMilan)
            {
                // Parse state data
                for (var i = 0; i < Actions.Length; i++)
                {
                    if (Actions[i].StateDataType != -1)
                    {
                        Actions[i].StateData = s.DoAt(OffsetTable.GetPointer(Actions[i].Index_StateData), () => s.SerializeObject <GBA_ActorStateData>(Actions[i].StateData, name: $"{nameof(GBA_Action.StateData)}[{i}]"));
                    }
                }
            }
        }
Exemple #28
0
 public XdbfEntry(OffsetTable offsetTable, BinaryContainer binary, int startOffset) : base(offsetTable, binary, startOffset)
 {
 }
 public XisoTableData(OffsetTable offsetTable, BinaryContainer binary, int startOffset) : base(offsetTable, binary, startOffset)
 {
 }
        /******************
         * protected methods
         */


        protected static OffsetTable ReadOffsetTable(OTFileVal file, uint filepos)
        {
            // read the Offset Table from the file

            Validator v = file.GetValidator();

            const int SIZEOF_OFFSETTABLE = 12;

            OffsetTable ot = null;


            // read the offset table

            MBOBuffer buf = file.ReadPaddedBuffer(filepos, SIZEOF_OFFSETTABLE);

            if (buf != null)
            {
                if (OTFile.IsValidSfntVersion(buf.GetUint(0)))
                {
                    ot = new OffsetTable(buf);
                }
                else
                {
                    v.Error(T.T_NULL, E._OFFSET_E_InvalidSFNT, null, "0x" + buf.GetUint(0).ToString("x8"));
                }
            }


            // now read the directory entries

            if (ot != null)
            {
                const int SIZEOF_DIRECTORYENTRY = 16;


                for (int i = 0; i < ot.numTables; i++)
                {
                    uint      dirFilePos = (uint)(filepos + SIZEOF_OFFSETTABLE + i * SIZEOF_DIRECTORYENTRY);
                    MBOBuffer DirEntBuf  = file.ReadPaddedBuffer(dirFilePos, SIZEOF_DIRECTORYENTRY);

                    if (DirEntBuf != null)
                    {
                        DirectoryEntry de = new DirectoryEntry();

                        de.tag      = new OTTag(DirEntBuf.GetBuffer());
                        de.checkSum = DirEntBuf.GetUint(4);
                        de.offset   = DirEntBuf.GetUint(8);
                        de.length   = DirEntBuf.GetUint(12);

                        ot.DirectoryEntries.Add(de);

                        if (de.offset > file.GetFileLength())
                        {
                            v.Error(T.T_NULL, E._DE_E_OffsetPastEOF, de.tag, "0x" + de.offset.ToString("x8"));
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return(ot);
        }
Exemple #31
0
 public MonoSymbolFile()
 {
     ot = new OffsetTable ();
 }
Exemple #32
0
        MonoSymbolFile(Stream stream)
        {
            reader = new MyBinaryReader (stream);

            try {
                long magic = reader.ReadInt64 ();
                int major_version = reader.ReadInt32 ();
                int minor_version = reader.ReadInt32 ();

                if (magic != OffsetTable.Magic)
                    throw new MonoSymbolFileException ("Symbol file is not a valid");
                if (major_version != OffsetTable.MajorVersion)
                    throw new MonoSymbolFileException (
                        "Symbol file has version {0} but expected {1}", major_version, OffsetTable.MajorVersion);
                if (minor_version != OffsetTable.MinorVersion)
                    throw new MonoSymbolFileException ("Symbol file has version {0}.{1} but expected {2}.{3}",
                        major_version, minor_version,
                        OffsetTable.MajorVersion, OffsetTable.MinorVersion);

                MajorVersion = major_version;
                MinorVersion = minor_version;
                guid = new Guid (reader.ReadBytes (16));

                ot = new OffsetTable (reader, major_version, minor_version);
            } catch (Exception e) {
                throw new MonoSymbolFileException ("Cannot read symbol file", e);
            }

            source_file_hash = new Dictionary<int, SourceFileEntry> ();
            compile_unit_hash = new Dictionary<int, CompileUnitEntry> ();
        }