Decomped EnableIqSkill and DisableIqSkill

Decomped with help from @taxicat1.
This commit is contained in:
AnonymousRandomPerson 2025-12-06 14:34:25 -05:00
parent 77d523e047
commit 5d95ef4340
5 changed files with 33 additions and 65 deletions

View File

@ -3,5 +3,3 @@
.public GetIqGroup
.public GetResolvedPerformanceProgressFlag
.public IQ_GROUP_SKILLS
.public IQ_SKILL_RESTRICTIONS
.public IqSkillFlagTest

View File

@ -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

View File

@ -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 <index>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);

View File

@ -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)
{

View File

@ -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)
{