-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHijack_PersonalityTableBuild2.s
More file actions
67 lines (46 loc) · 1.73 KB
/
Hijack_PersonalityTableBuild2.s
File metadata and controls
67 lines (46 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
.thumb
Hijack_PersonalityTableBuild2: @ hook at overlay 16, 0x26E8 (0x0223D828)
.start:
push {lr}
push {r0-r7}
ldr r3, =0x020501E0 @ table of active personality values (and also cached battle data ptr)
mov r5, #0 @ loop variable
ldr r6, [r4, #0x30] @ load other battle data ptr??
ldr r2, =0x219C
add r6, r6, r2 @ r6 now contains pointer to active battle member array
ldr r7, =0x0223DFAD @ GetMainBattleData_GetAdrOfPkmnInParty
.loop:
mov r0, r4
@ the table appears to be in this format:
@ [<active friendly mon 1>, <active enemy mon 1>, <active friendly mon 2>, <active enemy mon 2>]
@ whose party these pokemon come from can depend on whether you are in a single battle, double battle, double with partner, etc.
@ get pokemon-in-party index from active party member table
ldrb r2, [r6, r5]
@ skip if invalid/blank ID
cmp r2, #6
beq .loop_check
@ load loop variable as party index
@ note about the party index:
@ 0 and 2 are either the player or partner pokemon, and 1 and 3 are enemy trainer(s).
@ in a single battle, the party ID of the enemy trainer is 1. in a double battle, it is either 2 or 3 depending on
@ whether the player is facing one or two trainers.
@ luckily, if the player is by himself in a double battle, party 2 just maps to party 0, so it is safe to just go
@ ahead and use the loop variable as the party ID (same goes for one-trainer vs two-trainer double battles with 1 and 3).
mov r1, r5
push {r3}
blx r7
pop {r3}
@ store personality value in our table
ldr r0, [r0]
lsl r1, r5, #2
str r0, [r3, r1]
.loop_check:
add r5, r5, #1
cmp r5, #4
bls .loop
.end:
@ restore old code
pop {r0-r7}
ldr r0, [r4, #0x2C]
mov r1, #0x4
pop {pc}