WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit a24bde3

Browse files
Decomped CanLearnIqSkill
1 parent b28359d commit a24bde3

File tree

9 files changed

+150
-136
lines changed

9 files changed

+150
-136
lines changed

asm/include/main_02058C4C.inc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
#pragma once
2-
.public GetIqGroup
3-
.public GetPerformanceFlagWithChecks
4-
.public IQ_GROUP_SKILLS
5-
.public IQ_SKILLS
6-
.public IQ_SKILL_RESTRICTIONS
7-
.public IqSkillFlagTest
82
.public TACTICS_UNLOCK_LEVEL_TABLE

asm/include/main_02058D04.inc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
.public CanLearnIqSkill
3+
.public GetIqGroup
4+
.public GetPerformanceFlagWithChecks
5+
.public IQ_GROUP_SKILLS
6+
.public IQ_SKILL_RESTRICTIONS
7+
.public IqSkillFlagTest

asm/main_02058C4C.s

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -51,132 +51,3 @@ _02058CB0:
5151
.align 2, 0
5252
_02058CD4: .word TACTICS_UNLOCK_LEVEL_TABLE
5353
arm_func_end GetUnlockedTacticFlags
54-
55-
arm_func_start CanLearnIqSkill
56-
CanLearnIqSkill: ; 0x02058CD8
57-
cmp r1, #0
58-
moveq r0, #0
59-
bxeq lr
60-
ldr r2, _02058D00 ; =IQ_SKILLS
61-
ldr r1, [r2, r1, lsl #2]
62-
cmp r1, r0
63-
movle r0, #1
64-
movgt r0, #0
65-
and r0, r0, #0xff
66-
bx lr
67-
.align 2, 0
68-
_02058D00: .word IQ_SKILLS
69-
arm_func_end CanLearnIqSkill
70-
71-
arm_func_start GetLearnableIqSkills
72-
GetLearnableIqSkills: ; 0x02058D04
73-
stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr}
74-
mov r6, #0
75-
mov sl, r0
76-
mov sb, r1
77-
mov r8, r2
78-
mov r5, r6
79-
ldr r4, _02058DA0 ; =IQ_GROUP_SKILLS
80-
mov fp, #0x19
81-
b _02058D74
82-
_02058D28:
83-
mov r0, sb
84-
bl GetIqGroup
85-
mla r1, r0, fp, r4
86-
and r0, r5, #0xff
87-
ldrb r7, [r0, r1]
88-
cmp r7, #0xff
89-
beq _02058D7C
90-
cmp r7, #0x18
91-
bne _02058D58
92-
mov r0, #3
93-
bl GetPerformanceFlagWithChecks
94-
b _02058D64
95-
_02058D58:
96-
mov r0, r8
97-
mov r1, r7
98-
bl CanLearnIqSkill
99-
_02058D64:
100-
cmp r0, #0
101-
strneb r7, [sl, r6]
102-
addne r6, r6, #1
103-
add r5, r5, #1
104-
_02058D74:
105-
cmp r5, #0x19
106-
blt _02058D28
107-
_02058D7C:
108-
mov r1, r6
109-
mov r0, #0
110-
b _02058D90
111-
_02058D88:
112-
strb r0, [sl, r1]
113-
add r1, r1, #1
114-
_02058D90:
115-
cmp r1, #0x45
116-
blt _02058D88
117-
mov r0, r6
118-
ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc}
119-
.align 2, 0
120-
_02058DA0: .word IQ_GROUP_SKILLS
121-
arm_func_end GetLearnableIqSkills
122-
123-
arm_func_start DisableIqSkill
124-
DisableIqSkill: ; 0x02058DA4
125-
stmdb sp!, {r3, r4, r5, lr}
126-
mov r4, r0
127-
mov r5, r1
128-
bl IqSkillFlagTest
129-
cmp r0, #0
130-
beq _02058DE4
131-
mov r0, r5, asr #4
132-
add r0, r5, r0, lsr #27
133-
mov r2, r0, asr #5
134-
sub r0, r5, r2, lsl #5
135-
mov r1, #1
136-
mvn r0, r1, lsl r0
137-
ldr r1, [r4, r2, lsl #2]
138-
and r0, r1, r0
139-
str r0, [r4, r2, lsl #2]
140-
ldmia sp!, {r3, r4, r5, pc}
141-
_02058DE4:
142-
mov r0, r4
143-
mov r1, r5
144-
bl EnableIqSkill
145-
ldmia sp!, {r3, r4, r5, pc}
146-
arm_func_end DisableIqSkill
147-
148-
arm_func_start EnableIqSkill
149-
EnableIqSkill: ; 0x02058DF4
150-
stmdb sp!, {r4, r5, r6, lr}
151-
ldr r2, _02058E64 ; =IQ_SKILL_RESTRICTIONS
152-
mov r3, r1, lsl #1
153-
ldrsh ip, [r2, r3]
154-
mov r3, #0
155-
mov r4, #1
156-
_02058E0C:
157-
mov r5, r3, lsl #1
158-
ldrsh r5, [r2, r5]
159-
cmp ip, r5
160-
bne _02058E3C
161-
mov lr, r3, asr #4
162-
add lr, r3, lr, lsr #27
163-
mov r6, lr, asr #5
164-
sub lr, r3, r6, lsl #5
165-
mvn lr, r4, lsl lr
166-
ldr r5, [r0, r6, lsl #2]
167-
and r5, r5, lr
168-
str r5, [r0, r6, lsl #2]
169-
_02058E3C:
170-
add r3, r3, #1
171-
cmp r3, #0x45
172-
blt _02058E0C
173-
mov ip, r1, lsr #5
174-
ldr r3, [r0, ip, lsl #2]
175-
sub r1, r1, ip, lsl #5
176-
mov r2, #1
177-
orr r1, r3, r2, lsl r1
178-
str r1, [r0, ip, lsl #2]
179-
ldmia sp!, {r4, r5, r6, pc}
180-
.align 2, 0
181-
_02058E64: .word IQ_SKILL_RESTRICTIONS
182-
arm_func_end EnableIqSkill

asm/main_02058D04.s

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
.include "asm/macros.inc"
2+
.include "main_02058D04.inc"
3+
4+
.text
5+
6+
arm_func_start GetLearnableIqSkills
7+
GetLearnableIqSkills: ; 0x02058D04
8+
stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr}
9+
mov r6, #0
10+
mov sl, r0
11+
mov sb, r1
12+
mov r8, r2
13+
mov r5, r6
14+
ldr r4, _02058DA0 ; =IQ_GROUP_SKILLS
15+
mov fp, #0x19
16+
b _02058D74
17+
_02058D28:
18+
mov r0, sb
19+
bl GetIqGroup
20+
mla r1, r0, fp, r4
21+
and r0, r5, #0xff
22+
ldrb r7, [r0, r1]
23+
cmp r7, #0xff
24+
beq _02058D7C
25+
cmp r7, #0x18
26+
bne _02058D58
27+
mov r0, #3
28+
bl GetPerformanceFlagWithChecks
29+
b _02058D64
30+
_02058D58:
31+
mov r0, r8
32+
mov r1, r7
33+
bl CanLearnIqSkill
34+
_02058D64:
35+
cmp r0, #0
36+
strneb r7, [sl, r6]
37+
addne r6, r6, #1
38+
add r5, r5, #1
39+
_02058D74:
40+
cmp r5, #0x19
41+
blt _02058D28
42+
_02058D7C:
43+
mov r1, r6
44+
mov r0, #0
45+
b _02058D90
46+
_02058D88:
47+
strb r0, [sl, r1]
48+
add r1, r1, #1
49+
_02058D90:
50+
cmp r1, #0x45
51+
blt _02058D88
52+
mov r0, r6
53+
ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc}
54+
.align 2, 0
55+
_02058DA0: .word IQ_GROUP_SKILLS
56+
arm_func_end GetLearnableIqSkills
57+
58+
arm_func_start DisableIqSkill
59+
DisableIqSkill: ; 0x02058DA4
60+
stmdb sp!, {r3, r4, r5, lr}
61+
mov r4, r0
62+
mov r5, r1
63+
bl IqSkillFlagTest
64+
cmp r0, #0
65+
beq _02058DE4
66+
mov r0, r5, asr #4
67+
add r0, r5, r0, lsr #27
68+
mov r2, r0, asr #5
69+
sub r0, r5, r2, lsl #5
70+
mov r1, #1
71+
mvn r0, r1, lsl r0
72+
ldr r1, [r4, r2, lsl #2]
73+
and r0, r1, r0
74+
str r0, [r4, r2, lsl #2]
75+
ldmia sp!, {r3, r4, r5, pc}
76+
_02058DE4:
77+
mov r0, r4
78+
mov r1, r5
79+
bl EnableIqSkill
80+
ldmia sp!, {r3, r4, r5, pc}
81+
arm_func_end DisableIqSkill
82+
83+
arm_func_start EnableIqSkill
84+
EnableIqSkill: ; 0x02058DF4
85+
stmdb sp!, {r4, r5, r6, lr}
86+
ldr r2, _02058E64 ; =IQ_SKILL_RESTRICTIONS
87+
mov r3, r1, lsl #1
88+
ldrsh ip, [r2, r3]
89+
mov r3, #0
90+
mov r4, #1
91+
_02058E0C:
92+
mov r5, r3, lsl #1
93+
ldrsh r5, [r2, r5]
94+
cmp ip, r5
95+
bne _02058E3C
96+
mov lr, r3, asr #4
97+
add lr, r3, lr, lsr #27
98+
mov r6, lr, asr #5
99+
sub lr, r3, r6, lsl #5
100+
mvn lr, r4, lsl lr
101+
ldr r5, [r0, r6, lsl #2]
102+
and r5, r5, lr
103+
str r5, [r0, r6, lsl #2]
104+
_02058E3C:
105+
add r3, r3, #1
106+
cmp r3, #0x45
107+
blt _02058E0C
108+
mov ip, r1, lsr #5
109+
ldr r3, [r0, ip, lsl #2]
110+
sub r1, r1, ip, lsl #5
111+
mov r2, #1
112+
orr r1, r3, r2, lsl r1
113+
str r1, [r0, ip, lsl #2]
114+
ldmia sp!, {r4, r5, r6, pc}
115+
.align 2, 0
116+
_02058E64: .word IQ_SKILL_RESTRICTIONS
117+
arm_func_end EnableIqSkill

include/iq_skills.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "enums.h"
55

6+
// Table of 4-byte values for each IQ skill that represent the required IQ value to unlock a skill.
7+
extern const s32 IQ_SKILLS[69];
68
extern const enum iq_skill_id IQ_GROUP_SKILLS[16][25];
79

810
#endif //PMDSKY_IQ_SKILLS_H

include/main_02058CD8.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef PMDSKY_MAIN_02058CD8_H
2+
#define PMDSKY_MAIN_02058CD8_H
3+
4+
#include "enums.h"
5+
#include "util.h"
6+
7+
// Returns whether an IQ skill can be learned with a given IQ amount or not.
8+
// If the specified amount is 0, it always returns false.
9+
bool8 CanLearnIqSkill(s32 iq_amount, enum iq_skill_id iq_id);
10+
11+
#endif //PMDSKY_MAIN_02058CD8_H

main.lsf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ Static main
130130
Object asm/main_02054E4C.o
131131
Object src/main_02058C3C.o
132132
Object asm/main_02058C4C.o
133+
Object src/main_02058CD8.o
134+
Object asm/main_02058D04.o
133135
Object src/main_02058E68.o
134136
Object asm/main_02058E8C.o
135137
Object src/pokemon.o

src/dungeon_pokemon_attributes_1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
#include "dungeon_parameters_3.h"
44
#include "dungeon_parameters_4.h"
55
#include "dungeon_util_static.h"
6+
#include "main_02058CD8.h"
67
#include "main_02058E68.h"
78
#include "overlay_29_022FF898.h"
89
#include "overlay_29_023000E4.h"
910
#include "pokemon.h"
1011

11-
extern bool8 CanLearnIqSkill(s32 iq_amount, enum iq_skill_id iq_id);
1212
extern void DisableIqSkill(u32 *iq_skills_flags, enum iq_skill_id iq_id);
1313
extern void EnableIqSkill(u32 *iq_skills_flags, enum iq_skill_id iq_id);
1414
extern bool8 GetPerformanceFlagWithChecks(s32 flag_id);

src/main_02058CD8.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include "main_02058CD8.h"
2+
#include "iq_skills.h"
3+
4+
bool8 CanLearnIqSkill(s32 iq_amount, enum iq_skill_id iq_id)
5+
{
6+
if (iq_id == IQ_NONE)
7+
return 0;
8+
9+
return IQ_SKILLS[iq_id] <= iq_amount;
10+
}

0 commit comments

Comments
 (0)