RAM_OVL36:021BD62C ; =============== S U B R O U T I N E =======================================
RAM_OVL36:021BD62C
RAM_OVL36:021BD62C
RAM_OVL36:021BD62C ; void __fastcall everstoneHandler(void *pDaycarePKM, void *pEggStruct, u64 *eggSeed)
RAM_OVL36:021BD62C everstoneHandler
RAM_OVL36:021BD62C
RAM_OVL36:021BD62C var_20= -0x20
RAM_OVL36:021BD62C var_1C= -0x1C
RAM_OVL36:021BD62C
RAM_OVL36:021BD62C F8 B5 PUSH {R3-R7,LR}
RAM_OVL36:021BD62E 82 B0 SUB SP, SP, #8
RAM_OVL36:021BD630 05 1C MOVS R5, R0
RAM_OVL36:021BD632 16 1C MOVS R6, R2
RAM_OVL36:021BD634 00 22 MOVS R2, #0 ; declare/define bool for pkm1 has estone to false
RAM_OVL36:021BD636 0C 1C MOVS R4, R1
RAM_OVL36:021BD638 00 92 STR R2, [SP] ; save bool
RAM_OVL36:021BD63A 28 68 LDR R0, [R5] ; pkm1
RAM_OVL36:021BD63C 06 21 MOVS R1, #6
RAM_OVL36:021BD63E 00 22 MOVS R2, #0
RAM_OVL36:021BD640 5F F6 4E FB BL getPKMStat ; get item of first pkm
RAM_OVL36:021BD644 E5 28 CMP R0, #0xE5 ; 's'
RAM_OVL36:021BD646 01 D1 BNE pkm2Everstone
RAM_OVL36:021BD648 01 20 MOVS R0, #1 ; if pkm has estone, pass true
RAM_OVL36:021BD64A 00 90 STR R0, [SP] ; save true to sp
RAM_OVL36:021BD64C
RAM_OVL36:021BD64C pkm2Everstone ; CODE XREF: everstoneHandler+1Aj
RAM_OVL36:021BD64C 68 68 LDR R0, [R5,#4] ; if the first didn't have estone, come straight here and get the pointer to pkm2
RAM_OVL36:021BD64E 06 21 MOVS R1, #6
RAM_OVL36:021BD650 00 22 MOVS R2, #0
RAM_OVL36:021BD652 00 27 MOVS R7, #0
RAM_OVL36:021BD654 5F F6 44 FB BL getPKMStat ; get item of second pkm
RAM_OVL36:021BD658 E5 28 CMP R0, #0xE5 ; 's'
RAM_OVL36:021BD65A 00 D1 BNE pickEverstone ; if pkm2 doesn't have estone, drop down to nature grab
RAM_OVL36:021BD65C 01 27 MOVS R7, #1 ; r7 = true if it has the estone
RAM_OVL36:021BD65E
RAM_OVL36:021BD65E pickEverstone ; CODE XREF: everstoneHandler+2Ej
RAM_OVL36:021BD65E 28 68 LDR R0, [R5] ; 1st pkm
RAM_OVL36:021BD660 70 21 MOVS R1, #0x70 ; 'p'
RAM_OVL36:021BD662 00 22 MOVS R2, #0
RAM_OVL36:021BD664 5F F6 3C FB BL getPKMStat ; get nature of first pkm
RAM_OVL36:021BD668 01 90 STR R0, [SP,#4] ; save nature1 to sp+4
RAM_OVL36:021BD66A 68 68 LDR R0, [R5,#4]
RAM_OVL36:021BD66C 70 21 MOVS R1, #0x70 ; 'p'
RAM_OVL36:021BD66E 00 22 MOVS R2, #0
RAM_OVL36:021BD670 5F F6 36 FB BL getPKMStat ; get nature of pkm2
RAM_OVL36:021BD674 05 1C MOVS R5, R0 ; save nature2 to r5
RAM_OVL36:021BD676 00 98 LDR R0, [SP] ; load 'does pkm1 have estone' bool
RAM_OVL36:021BD678 00 28 CMP R0, #0 ; if not, jump past the rand call and set up the nature pass
RAM_OVL36:021BD67A 1D D0 BEQ pkm1EverstoneCheck
RAM_OVL36:021BD67C 00 2F CMP R7, #0 ; check 'does pkm2 have estone' bool
RAM_OVL36:021BD67E 1B D0 BEQ pkm1EverstoneCheck ; if both of these pass, both pkms have everstones. the game has to determine which nature to use. run the inline rng and take the top bit to pick which nature
RAM_OVL36:021BD680 B0 68 LDR R0, [R6,#8] ; num1
RAM_OVL36:021BD682 F1 68 LDR R1, [R6,#0xC]
RAM_OVL36:021BD684 32 68 LDR R2, [R6] ; num2
RAM_OVL36:021BD686 73 68 LDR R3, [R6,#4] ; num1
RAM_OVL36:021BD688 CF F6 46 EE BLX mul64
RAM_OVL36:021BD68C 33 69 LDR R3, [R6,#0x10] ; 00269ec3
RAM_OVL36:021BD68E 72 69 LDR R2, [R6,#0x14] ; 00000000
RAM_OVL36:021BD690 18 18 ADDS R0, R3, R0 ; add
RAM_OVL36:021BD692 4A 41 ADCS R2, R1 ; add
RAM_OVL36:021BD694 00 21 MOVS R1, #0 ; initialize some variable
RAM_OVL36:021BD696 30 60 STR R0, [R6] ; store back the bottom half of the inline seed
RAM_OVL36:021BD698 D0 0F LSRS R0, R2, #0x1F ; u32 >> 31
RAM_OVL36:021BD69A 49 00 LSLS R1, R1, #1 ; 0 << 1, this makes no sense.
RAM_OVL36:021BD69C 72 60 STR R2, [R6,#4] ; store back top half of seed
RAM_OVL36:021BD69E 01 43 ORRS R1, R0 ; (u32 >> 31) | (0 << 1), only useful for setting the status bit
RAM_OVL36:021BD6A0 05 D1 BNE usePKM2
RAM_OVL36:021BD6A2 01 98 LDR R0, [SP,#4] ; if u32 >> 31 is 0, load nature1 into r0
RAM_OVL36:021BD6A4 02 B0 ADD SP, SP, #8 ; unwind
RAM_OVL36:021BD6A6 E0 60 STR R0, [R4,#0xC] ; store nature1 to egg struct in nature spot
RAM_OVL36:021BD6A8 01 20 MOVS R0, #1 ; bool eStone = TRUE
RAM_OVL36:021BD6AA E0 64 STR R0, [R4,#0x4C] ; set estoneParent1 to true
RAM_OVL36:021BD6AC F8 BD POP {R3-R7,PC}
RAM_OVL36:021BD6AE ; ---------------------------------------------------------------------------
RAM_OVL36:021BD6AE
RAM_OVL36:021BD6AE usePKM2 ; CODE XREF: everstoneHandler+74j
RAM_OVL36:021BD6AE 01 20 MOVS R0, #1 ; bool eStone = TRUE
RAM_OVL36:021BD6B0 02 B0 ADD SP, SP, #8 ; unwind
RAM_OVL36:021BD6B2 E5 60 STR R5, [R4,#0xC] ; store nature2 to egg struct in nature spot
RAM_OVL36:021BD6B4 20 65 STR R0, [R4,#0x50] ; set estoneParent2 to true
RAM_OVL36:021BD6B6 F8 BD POP {R3-R7,PC}
RAM_OVL36:021BD6B8 ; ---------------------------------------------------------------------------
RAM_OVL36:021BD6B8
RAM_OVL36:021BD6B8 pkm1EverstoneCheck ; CODE XREF: everstoneHandler+4Ej
RAM_OVL36:021BD6B8 ; everstoneHandler+52j
RAM_OVL36:021BD6B8 00 98 LDR R0, [SP] ; load 'does pkm1 have estone' bool
RAM_OVL36:021BD6BA 00 28 CMP R0, #0 ; if it doesn't, jump past
RAM_OVL36:021BD6BC 05 D0 BEQ pkm2EverstoneCheck
RAM_OVL36:021BD6BE 01 98 LDR R0, [SP,#4] ; if bool is true, load nature1 into r0
RAM_OVL36:021BD6C0 02 B0 ADD SP, SP, #8 ; unwind
RAM_OVL36:021BD6C2 E0 60 STR R0, [R4,#0xC] ; store nature1 to egg struct in nature spot
RAM_OVL36:021BD6C4 01 20 MOVS R0, #1 ; bool eStone = TRUE
RAM_OVL36:021BD6C6 E0 64 STR R0, [R4,#0x4C] ; set estoneParent1 to true
RAM_OVL36:021BD6C8 F8 BD POP {R3-R7,PC}
RAM_OVL36:021BD6CA ; ---------------------------------------------------------------------------
RAM_OVL36:021BD6CA
RAM_OVL36:021BD6CA pkm2EverstoneCheck ; CODE XREF: everstoneHandler+90j
RAM_OVL36:021BD6CA 00 2F CMP R7, #0 ; r7 is the 'does pkm2 have estone' bool
RAM_OVL36:021BD6CC 02 D0 BEQ return ; if this is false, neither pkm has an everstone. finish.
RAM_OVL36:021BD6CE 01 20 MOVS R0, #1 ; bool eStone = TRUE
RAM_OVL36:021BD6D0 E5 60 STR R5, [R4,#0xC] ; store nature2 to egg struct in nature spot
RAM_OVL36:021BD6D2 20 65 STR R0, [R4,#0x50] ; set estoneParent2 to true
RAM_OVL36:021BD6D4
RAM_OVL36:021BD6D4 return ; CODE XREF: everstoneHandler+A0j
RAM_OVL36:021BD6D4 02 B0 ADD SP, SP, #8 ; unwind
RAM_OVL36:021BD6D6 F8 BD POP {R3-R7,PC}
RAM_OVL36:021BD6D6 ; End of function everstoneHandler
RAM_OVL36:021BD6D6