Getting IVs and EVs
The routines are very similar so I ended up just combining the two routines into one. Basically given a slot number of a Pokemon in 0x8004, the routines will return the EVs or IVs, respectively, into the vars 0x8005-0x800A with 0x8003 as the IV/EV switch.
How to insert:
Compile and insert the following routine into free space:
Spoiler:
.text
.align 2
.thumb
.thumb_func
main:
push {r0-r5, lr}
mov r4, #0x0
loop:
cmp r4, #0x6
bhi end
ldr r0, =(0x20370C0) @var 0x8004 = slot number
ldrh r0, [r0]
mov r1, #0x64
mul r1, r1, r0
ldr r0, =(0x2024284)
add r0, r0, r1
ldr r3, =(0x20370BE)
ldrh r3, [r3]
cmp r3, #0x0
beq EVs
add r1, r1, #0x27 @IV
b continue
EVs:
add r1, r1, #0x1A
continue:
ldr r2, =(0x803FBE8 +1)
bl linker
mov r1, r0
@get var
ldr r2, =(0x20370C2) @using vars 0x8005-0x800A
lsl r0, r4, #0x1
add r2, r2, r0
strh r1, [r2] @store IV in var
add r4, r4, #0x1
b loop
linker:
bx r2
end:
pop {r0-r5, pc}
.align 2
Usage:
setvar 0x8003 0x[anything except 0 = IV, 0 = EV]
setvar 0x8004 0x[slot number 0 to 5]
callasm 0x[this routine +1]
The variables will be:
0x8005: HP IV/EV
0x8006: Atk IV/EV
0x8007: Def IV/EV
0x8008: Spd IV/EV
0x8009: S.atk IV/EV
0x800A: S.def IV/EV