Skip to content

Commit 370216f

Browse files
committed
Allow skill learning on promotion
1 parent 4c880ef commit 370216f

11 files changed

+216
-7
lines changed

Engine Hacks/Popups.event

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ gPromotionPopupTable:
2929
PopRBattlePopup(PopR_InitLightRankNew, gPopup_PopR_NewWType, 96)
3030
PopRBattlePopup(PopR_InitElderRankNew, gPopup_PopR_NewWType, 96)
3131

32+
// Skill system
33+
PopRBattlePopup(InitPromotionSkillPopup|1, SkillLearnedPopup, 96)
34+
3235
PopRBattlePopupEnd
3336

3437
#endif // POPUPS

Engine Hacks/Skill System/Internals/SkillPopups.event

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ InitLevelUpSkillPopup:
2222
POIN (GetUnitLevelSkills|1)
2323
POIN (SkillAdder|1)
2424

25+
InitPromotionSkillPopup:
26+
#incbin "asm/InitPromotionSkillPopup.dmp"
27+
POIN (GetUnitLevelSkills|1)
28+
POIN (SkillAdder|1)
29+
2530
ALIGN 4
2631
SkillLearnedPopup:
2732
// Popup macros are defined in [PopupRework/]Extensions/PopupDefinitions.txt
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
2+
.thumb
3+
4+
gpBeforeBattleUnit = 0x0203E18C @ unused, but here for reference
5+
gpAfterBattleUnit = 0x0203E188 @ this is the one we are looking at
6+
7+
gPopupItem = 0x030005F4
8+
9+
lGetUnitLevelSkills = EALiterals+0x00
10+
lAddSkill = EALiterals+0x04
11+
12+
InitPromotionSkillPopup:
13+
@ We are going to do learning and showing popups at the same time even if this is probably a turbo bad idea
14+
15+
push {lr}
16+
17+
ldr r0, =gpAfterBattleUnit
18+
ldr r0, [r0]
19+
20+
bl TryLearnSkill
21+
22+
cmp r0, #0
23+
beq end
24+
25+
yes:
26+
ldr r1, =gPopupItem
27+
strh r0, [r1]
28+
29+
mov r0, #1
30+
31+
end:
32+
pop {r3}
33+
BXR3:
34+
bx r3
35+
36+
.pool
37+
.align
38+
39+
TryLearnSkill:
40+
@ Arguments: r0 = (Battle) Unit
41+
@ Returns: r0 = Skill Id Learned (0 if none)
42+
43+
push {r0-r1, r4, lr} @ note: pushing r0-r1 allocated 8 bytes on the stack
44+
45+
ldrb r1, [r0, #0x08] @ r1 = battle unit level
46+
47+
mov r4, r0 @ var r4 = bu
48+
49+
ldr r3, lGetUnitLevelSkills
50+
51+
@ implied @ arg r0 = (battle) unit
52+
@ implied @ arg r1 = level
53+
mov r2, sp @ arg r2 = output buffer
54+
55+
bl BXR3
56+
57+
@ implied @ ret r0 = output buffer
58+
59+
ldrb r0, [r0] @ get first skill in output buffer
60+
61+
cmp r0, #0
62+
beq TryLearnSkill.end @ Do not learn anything if list was empty
63+
64+
ldr r3, lAddSkill
65+
66+
mov r1, r0 @ arg r1 = skill id
67+
mov r0, r4 @ arg r0 = unit
68+
69+
mov r4, r1 @ var r4 = skill id
70+
71+
bl BXR3
72+
73+
cmp r0, #0
74+
beq TryLearnSkill.no_skill
75+
76+
@ return skill id
77+
mov r0, r4
78+
79+
b TryLearnSkill.end
80+
81+
TryLearnSkill.no_skill:
82+
@ return 0
83+
mov r0, #0
84+
85+
TryLearnSkill.end:
86+
pop {r1-r2, r4} @ note: popping r1-r2 freed 8 bytes on the stack
87+
88+
pop {r1}
89+
bx r1
90+
91+
EALiterals:
92+
@ POIN (GetUnitLevelSkills|1)
93+
@ POIN (AddSkill|1)

Engine Hacks/Skill System/Skill Removal Menu/RemoveSkillMenu.event

+42-7
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ PUSH; ORG 0x59BAC4
6868
POP
6969

7070
// Promotion proc Hook (unused since no skill learning on promotion)
71-
// PUSH; ORG 0xB126FC
72-
// _6C_JUMP(_pProc_FromPromotionProc)
73-
// POP
71+
PUSH; ORG 0xB126BC
72+
_6C_JUMP(_pProc_FromPromotionProc)
73+
POP
7474

7575
ALIGN 4
7676
_pProc_FromBattleProc:
@@ -95,16 +95,51 @@ _pProc_FromMiscActionProc:
9595
_6C_YIELD
9696
_6C_END
9797

98-
// ALIGN 4
99-
// _pProc_FromPromotionProc:
100-
// _6C_CALL_ROUTINE_2(prCheckForSkillForgetting|1)
101-
// _6C_END
98+
ALIGN 4
99+
_pProc_FromPromotionProc:
100+
_6C_NEW_CHILD_BLOCKING(_pProc_FromPromotionProc_SubProc)
101+
_6C_CALL_ROUTINE(0x0CC698|1)
102+
_6C_END
103+
104+
ALIGN 4
105+
_pProc_FromPromotionProc_SubProc:
106+
_6C_CALL_ROUTINE(_prPromotionInit|1)
107+
108+
_6C_LABEL(0) // trainee promotion
109+
_6C_LABEL(1) // prep screen promotion
110+
_6C_CALL_ROUTINE(_prPromotionPrepScreenSetup|1)
111+
112+
_6C_CALL_ROUTINE_2(_prPromotionCheck|1)
113+
114+
_6C_CALL_ROUTINE_ARG(0x0AE2F4|1, 0x40) // StartFadeOut(0x40)
115+
_6C_WHILE_ROUTINE(0x0AE2B8|1) // FadeOutExists
116+
117+
_6C_GOTO(776)
118+
119+
_6C_LABEL(2) // map promotion
120+
_6C_CALL_ROUTINE_2(_prPromotionCheck|1)
121+
_6C_GOTO(776)
122+
123+
_6C_LABEL(776)
124+
_6C_END
102125

103126
ALIGN 4
104127
_prCheckForBattleSkillForgetting:
105128
#incbin "asm/CheckForBattleSkillForgetting.dmp"
106129
POIN (prCheckForSkillForgetting|1)
107130

131+
ALIGN 4
132+
_prPromotionInit:
133+
#incbin "asm/PromotionInit.dmp"
134+
135+
ALIGN 4
136+
_prPromotionCheck:
137+
#incbin "asm/PromotionCheck.dmp"
138+
POIN (prCheckForSkillForgetting|1)
139+
140+
_prPromotionPrepScreenSetup:
141+
#incbin "asm/PromotionPrepScreenSetup.dmp"
142+
108143
}
109144

110145
ALIGN 4
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
.thumb
3+
4+
.include "Definitions.inc"
5+
6+
lCheckForSkillForgetting = EALiterals+0x00
7+
8+
PromotionCheck:
9+
push {r4, lr}
10+
11+
mov r4, r0
12+
13+
ldr r0, [r4, #0x14] @ get parent
14+
ldr r0, [r0, #0x14] @ get parent's parent (welcome to promotion procs)
15+
ldr r0, [r0, #0x38] @ get unit
16+
17+
@ implied @ arg r0 = unit
18+
mov r1, r4 @ arg r1 = parent proc
19+
20+
ldr r3, lCheckForSkillForgetting
21+
_blr r3
22+
23+
pop {r4}
24+
25+
pop {r1}
26+
bx r1
27+
28+
.pool
29+
.align
30+
31+
EALiterals:
32+
@ POIN (CheckForSkillForgetting|1)
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
.thumb
3+
4+
.include "Definitions.inc"
5+
6+
PromotionInit:
7+
ldr r1, [r0, #0x14] @ r1 = parent
8+
ldr r1, [r1, #0x14] @ r1 = parent's parent
9+
10+
mov r2, #0x31
11+
ldrb r1, [r1, r2] @ r1 = promotion context id
12+
13+
ldr r3, =0x08002F24|1
14+
bx r3
15+
16+
.pool
17+
.align
18+
19+
EALiterals:
20+
@ nothing
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
.thumb
3+
4+
.include "Definitions.inc"
5+
6+
@ gLCDIOBuffer = 0x03003080
7+
8+
PromotionPrepScreenSetup:
9+
push {r4, lr}
10+
11+
mov r0, #0
12+
_blh 0x08001B58 @ SetBgConfig
13+
14+
_blh 0x080156F4 @ ReloadGameCoreGfx
15+
16+
_blh 0x0804E884 @ ClearBG0BG1
17+
18+
pop {r4}
19+
20+
pop {r1}
21+
bx r1

0 commit comments

Comments
 (0)