コード例 #1
0
        public static List <PatchedByteArray> GetISOPatches(EntryData entryData, Context context, DataHelper dataHelper = null)
        {
            dataHelper = dataHelper ?? new DataHelper(context);
            List <PatchedByteArray> patches = new List <PatchedByteArray>();

            SettingsData settings = Settings.GetSettings(context);

            Enum battleSector = settings.BattleConditionalsSector;
            int  battleOffset = settings.BattleConditionalsOffset;

            byte[] battleBytes = dataHelper.ConditionalSetsToByteArray(CommandType.BattleConditional, entryData.BattleConditionals);
            patches.Add(new PatchedByteArray(battleSector, battleOffset, battleBytes));

            if ((settings.BattleConditionalsApplyLimitPatch) && (DataHelper.GetMaxBlocks(entryData.BattleConditionals) > 10))
            {
                patches.Add(new PatchedByteArray(settings.BattleConditionalsLimitPatchSector, settings.BattleConditionalsLimitPatchOffset, settings.BattleConditionalsLimitPatchBytes));
            }

            Enum worldSector = settings.WorldConditionalsSector;
            int  worldOffset = settings.WorldConditionalsOffset;

            byte[] worldBytes = dataHelper.ConditionalSetsToByteArray(CommandType.WorldConditional, entryData.WorldConditionals);
            patches.Add(new PatchedByteArray(worldSector, worldOffset, worldBytes));

            if (settings.WorldConditionalsRepoint)
            {
                byte[] patchBytes = (((uint)(ISOHelper.GetRamOffsetUnsigned(worldSector, context, true) + worldOffset))).ToBytes();
                patches.Add(new PatchedByteArray(settings.WorldConditionalsPointerSector, settings.WorldConditionalsPointerOffset, patchBytes));
            }

            Enum eventSector = settings.EventsSector;
            int  eventOffset = settings.EventsOffset;

            byte[] eventBytes = dataHelper.EventsToByteArray(entryData.Events);
            patches.Add(new PatchedByteArray(eventSector, eventOffset, eventBytes));

            return(patches);
        }