From 5d95ef4340d95400ac351ddb127208a62a69949d Mon Sep 17 00:00:00 2001 From: AnonymousRandomPerson Date: Sat, 6 Dec 2025 14:34:25 -0500 Subject: [PATCH] Decomped EnableIqSkill and DisableIqSkill Decomped with help from @taxicat1. --- asm/include/main_02058D04.inc | 2 - asm/main_02058D04.s | 61 ------------------------------ include/main_02058E68.h | 4 ++ src/dungeon_pokemon_attributes_1.c | 3 +- src/main_02058E68.c | 28 ++++++++++++++ 5 files changed, 33 insertions(+), 65 deletions(-) diff --git a/asm/include/main_02058D04.inc b/asm/include/main_02058D04.inc index ace7307e..2e2dac5e 100644 --- a/asm/include/main_02058D04.inc +++ b/asm/include/main_02058D04.inc @@ -3,5 +3,3 @@ .public GetIqGroup .public GetResolvedPerformanceProgressFlag .public IQ_GROUP_SKILLS -.public IQ_SKILL_RESTRICTIONS -.public IqSkillFlagTest diff --git a/asm/main_02058D04.s b/asm/main_02058D04.s index 33c314b2..f0c6c40b 100644 --- a/asm/main_02058D04.s +++ b/asm/main_02058D04.s @@ -54,64 +54,3 @@ _02058D90: .align 2, 0 _02058DA0: .word IQ_GROUP_SKILLS arm_func_end GetLearnableIqSkills - - arm_func_start DisableIqSkill -DisableIqSkill: ; 0x02058DA4 - stmdb sp!, {r3, r4, r5, lr} - mov r4, r0 - mov r5, r1 - bl IqSkillFlagTest - cmp r0, #0 - beq _02058DE4 - mov r0, r5, asr #4 - add r0, r5, r0, lsr #27 - mov r2, r0, asr #5 - sub r0, r5, r2, lsl #5 - mov r1, #1 - mvn r0, r1, lsl r0 - ldr r1, [r4, r2, lsl #2] - and r0, r1, r0 - str r0, [r4, r2, lsl #2] - ldmia sp!, {r3, r4, r5, pc} -_02058DE4: - mov r0, r4 - mov r1, r5 - bl EnableIqSkill - ldmia sp!, {r3, r4, r5, pc} - arm_func_end DisableIqSkill - - arm_func_start EnableIqSkill -EnableIqSkill: ; 0x02058DF4 - stmdb sp!, {r4, r5, r6, lr} - ldr r2, _02058E64 ; =IQ_SKILL_RESTRICTIONS - mov r3, r1, lsl #1 - ldrsh ip, [r2, r3] - mov r3, #0 - mov r4, #1 -_02058E0C: - mov r5, r3, lsl #1 - ldrsh r5, [r2, r5] - cmp ip, r5 - bne _02058E3C - mov lr, r3, asr #4 - add lr, r3, lr, lsr #27 - mov r6, lr, asr #5 - sub lr, r3, r6, lsl #5 - mvn lr, r4, lsl lr - ldr r5, [r0, r6, lsl #2] - and r5, r5, lr - str r5, [r0, r6, lsl #2] -_02058E3C: - add r3, r3, #1 - cmp r3, #0x45 - blt _02058E0C - mov ip, r1, lsr #5 - ldr r3, [r0, ip, lsl #2] - sub r1, r1, ip, lsl #5 - mov r2, #1 - orr r1, r3, r2, lsl r1 - str r1, [r0, ip, lsl #2] - ldmia sp!, {r4, r5, r6, pc} - .align 2, 0 -_02058E64: .word IQ_SKILL_RESTRICTIONS - arm_func_end EnableIqSkill diff --git a/include/main_02058E68.h b/include/main_02058E68.h index 35a5b927..a9693f5b 100644 --- a/include/main_02058E68.h +++ b/include/main_02058E68.h @@ -3,6 +3,10 @@ #include "enums.h" +// Disables an IQ skill. +void DisableIqSkill(u32 *iq_skills_flags, s32 iq_id); +// Enables an IQ skill and disables any other skills that are incompatible with it. +void EnableIqSkill(u32 *iq_skills_flags, u32 iq_id); // Gets the th skill on the list of IQ skills that a given monster species can learn. enum iq_skill_id GetSpeciesIqSkill(s16 monster_id, u8 index); diff --git a/src/dungeon_pokemon_attributes_1.c b/src/dungeon_pokemon_attributes_1.c index 8120a7a6..609b18c0 100644 --- a/src/dungeon_pokemon_attributes_1.c +++ b/src/dungeon_pokemon_attributes_1.c @@ -11,8 +11,7 @@ #include "performance_progress.h" #include "pokemon.h" -extern void DisableIqSkill(u32 *iq_skills_flags, enum iq_skill_id iq_id); -extern void EnableIqSkill(u32 *iq_skills_flags, enum iq_skill_id iq_id); +extern bool8 GetPerformanceFlagWithChecks(s32 flag_id); bool8 CanSeeInvisibleMonsters(struct entity *entity) { diff --git a/src/main_02058E68.c b/src/main_02058E68.c index 6de54a27..9dd7dc5c 100644 --- a/src/main_02058E68.c +++ b/src/main_02058E68.c @@ -1,6 +1,34 @@ #include "main_02058E68.h" #include "iq_skills.h" #include "main_02052B28.h" +#include "monster_parameters.h" +#include "pokemon.h" + +void DisableIqSkill(u32 *iq_skills_flags, s32 iq_id) +{ + if (IqSkillFlagTest(iq_skills_flags, iq_id)) + { + s32 flags_group_index = iq_id / 32; + iq_skills_flags[flags_group_index] &= ~(1 << iq_id - (flags_group_index << 5)); + } + else + EnableIqSkill(iq_skills_flags, iq_id); +} + +void EnableIqSkill(u32 *iq_skills_flags, u32 iq_id) +{ + for (s32 id = 0; id < NUM_IQ_SKILLS; id++) + { + if (IQ_SKILL_RESTRICTIONS[iq_id] == IQ_SKILL_RESTRICTIONS[id]) + { + s32 flags_group_index = id / 32; + iq_skills_flags[flags_group_index] &= ~(1 << id - (flags_group_index * 32)); + } + } + + u32 flags_group_index = iq_id / 32; + iq_skills_flags[flags_group_index] |= 1 << iq_id - (flags_group_index * 32); +} enum iq_skill_id GetSpeciesIqSkill(s16 monster_id, u8 index) {