Bond697

Everstone Handler

Aug 24th, 2012
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 8.42 KB | None | 0 0
  1. RAM_OVL36:021BD62C             ; =============== S U B R O U T I N E =======================================
  2. RAM_OVL36:021BD62C
  3. RAM_OVL36:021BD62C
  4. RAM_OVL36:021BD62C             ; void __fastcall everstoneHandler(void *pDaycarePKM, void *pEggStruct, u64 *eggSeed)
  5. RAM_OVL36:021BD62C             everstoneHandler
  6. RAM_OVL36:021BD62C
  7. RAM_OVL36:021BD62C             var_20= -0x20
  8. RAM_OVL36:021BD62C             var_1C= -0x1C
  9. RAM_OVL36:021BD62C
  10. RAM_OVL36:021BD62C F8 B5       PUSH    {R3-R7,LR}
  11. RAM_OVL36:021BD62E 82 B0       SUB     SP, SP, #8
  12. RAM_OVL36:021BD630 05 1C       MOVS    R5, R0
  13. RAM_OVL36:021BD632 16 1C       MOVS    R6, R2
  14. RAM_OVL36:021BD634 00 22       MOVS    R2, #0                          ; declare/define bool for pkm1 has estone to false
  15. RAM_OVL36:021BD636 0C 1C       MOVS    R4, R1
  16. RAM_OVL36:021BD638 00 92       STR     R2, [SP]                        ; save bool
  17. RAM_OVL36:021BD63A 28 68       LDR     R0, [R5]                        ; pkm1
  18. RAM_OVL36:021BD63C 06 21       MOVS    R1, #6
  19. RAM_OVL36:021BD63E 00 22       MOVS    R2, #0
  20. RAM_OVL36:021BD640 5F F6 4E FB BL      getPKMStat                      ; get item of first pkm
  21. RAM_OVL36:021BD644 E5 28       CMP     R0, #0xE5 ; 's'
  22. RAM_OVL36:021BD646 01 D1       BNE     pkm2Everstone
  23. RAM_OVL36:021BD648 01 20       MOVS    R0, #1                          ; if pkm has estone, pass true
  24. RAM_OVL36:021BD64A 00 90       STR     R0, [SP]                        ; save true to sp
  25. RAM_OVL36:021BD64C
  26. RAM_OVL36:021BD64C             pkm2Everstone                           ; CODE XREF: everstoneHandler+1Aj
  27. 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
  28. RAM_OVL36:021BD64E 06 21       MOVS    R1, #6
  29. RAM_OVL36:021BD650 00 22       MOVS    R2, #0
  30. RAM_OVL36:021BD652 00 27       MOVS    R7, #0
  31. RAM_OVL36:021BD654 5F F6 44 FB BL      getPKMStat                      ; get item of second pkm
  32. RAM_OVL36:021BD658 E5 28       CMP     R0, #0xE5 ; 's'
  33. RAM_OVL36:021BD65A 00 D1       BNE     pickEverstone                   ; if pkm2 doesn't have estone, drop down to nature grab
  34. RAM_OVL36:021BD65C 01 27       MOVS    R7, #1                          ; r7 = true if it has the estone
  35. RAM_OVL36:021BD65E
  36. RAM_OVL36:021BD65E             pickEverstone                           ; CODE XREF: everstoneHandler+2Ej
  37. RAM_OVL36:021BD65E 28 68       LDR     R0, [R5]                        ; 1st pkm
  38. RAM_OVL36:021BD660 70 21       MOVS    R1, #0x70 ; 'p'
  39. RAM_OVL36:021BD662 00 22       MOVS    R2, #0
  40. RAM_OVL36:021BD664 5F F6 3C FB BL      getPKMStat                      ; get nature of first pkm
  41. RAM_OVL36:021BD668 01 90       STR     R0, [SP,#4]                     ; save nature1 to sp+4
  42. RAM_OVL36:021BD66A 68 68       LDR     R0, [R5,#4]
  43. RAM_OVL36:021BD66C 70 21       MOVS    R1, #0x70 ; 'p'
  44. RAM_OVL36:021BD66E 00 22       MOVS    R2, #0
  45. RAM_OVL36:021BD670 5F F6 36 FB BL      getPKMStat                      ; get nature of pkm2
  46. RAM_OVL36:021BD674 05 1C       MOVS    R5, R0                          ; save nature2 to r5
  47. RAM_OVL36:021BD676 00 98       LDR     R0, [SP]                        ; load 'does pkm1 have estone' bool
  48. RAM_OVL36:021BD678 00 28       CMP     R0, #0                          ; if not, jump past the rand call and set up the nature pass
  49. RAM_OVL36:021BD67A 1D D0       BEQ     pkm1EverstoneCheck
  50. RAM_OVL36:021BD67C 00 2F       CMP     R7, #0                          ; check 'does pkm2 have estone' bool
  51. 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
  52. RAM_OVL36:021BD680 B0 68       LDR     R0, [R6,#8]                     ; num1
  53. RAM_OVL36:021BD682 F1 68       LDR     R1, [R6,#0xC]
  54. RAM_OVL36:021BD684 32 68       LDR     R2, [R6]                        ; num2
  55. RAM_OVL36:021BD686 73 68       LDR     R3, [R6,#4]                     ; num1
  56. RAM_OVL36:021BD688 CF F6 46 EE BLX     mul64
  57. RAM_OVL36:021BD68C 33 69       LDR     R3, [R6,#0x10]                  ; 00269ec3
  58. RAM_OVL36:021BD68E 72 69       LDR     R2, [R6,#0x14]                  ; 00000000
  59. RAM_OVL36:021BD690 18 18       ADDS    R0, R3, R0                      ; add
  60. RAM_OVL36:021BD692 4A 41       ADCS    R2, R1                          ; add
  61. RAM_OVL36:021BD694 00 21       MOVS    R1, #0                          ; initialize some variable
  62. RAM_OVL36:021BD696 30 60       STR     R0, [R6]                        ; store back the bottom half of the inline seed
  63. RAM_OVL36:021BD698 D0 0F       LSRS    R0, R2, #0x1F                   ; u32 >> 31
  64. RAM_OVL36:021BD69A 49 00       LSLS    R1, R1, #1                      ; 0 << 1, this makes no sense.
  65. RAM_OVL36:021BD69C 72 60       STR     R2, [R6,#4]                     ; store back top half of seed
  66. RAM_OVL36:021BD69E 01 43       ORRS    R1, R0                          ; (u32 >> 31) | (0 << 1), only useful for setting the status bit
  67. RAM_OVL36:021BD6A0 05 D1       BNE     usePKM2
  68. RAM_OVL36:021BD6A2 01 98       LDR     R0, [SP,#4]                     ; if u32 >> 31 is 0, load nature1 into r0
  69. RAM_OVL36:021BD6A4 02 B0       ADD     SP, SP, #8                      ; unwind
  70. RAM_OVL36:021BD6A6 E0 60       STR     R0, [R4,#0xC]                   ; store nature1 to egg struct in nature spot
  71. RAM_OVL36:021BD6A8 01 20       MOVS    R0, #1                          ; bool eStone = TRUE
  72. RAM_OVL36:021BD6AA E0 64       STR     R0, [R4,#0x4C]                  ; set estoneParent1 to true
  73. RAM_OVL36:021BD6AC F8 BD       POP     {R3-R7,PC}
  74. RAM_OVL36:021BD6AE             ; ---------------------------------------------------------------------------
  75. RAM_OVL36:021BD6AE
  76. RAM_OVL36:021BD6AE             usePKM2                                 ; CODE XREF: everstoneHandler+74j
  77. RAM_OVL36:021BD6AE 01 20       MOVS    R0, #1                          ; bool eStone = TRUE
  78. RAM_OVL36:021BD6B0 02 B0       ADD     SP, SP, #8                      ; unwind
  79. RAM_OVL36:021BD6B2 E5 60       STR     R5, [R4,#0xC]                   ; store nature2 to egg struct in nature spot
  80. RAM_OVL36:021BD6B4 20 65       STR     R0, [R4,#0x50]                  ; set estoneParent2 to true
  81. RAM_OVL36:021BD6B6 F8 BD       POP     {R3-R7,PC}
  82. RAM_OVL36:021BD6B8             ; ---------------------------------------------------------------------------
  83. RAM_OVL36:021BD6B8
  84. RAM_OVL36:021BD6B8             pkm1EverstoneCheck                      ; CODE XREF: everstoneHandler+4Ej
  85. RAM_OVL36:021BD6B8                                                     ; everstoneHandler+52j
  86. RAM_OVL36:021BD6B8 00 98       LDR     R0, [SP]                        ; load 'does pkm1 have estone' bool
  87. RAM_OVL36:021BD6BA 00 28       CMP     R0, #0                          ; if it doesn't, jump past
  88. RAM_OVL36:021BD6BC 05 D0       BEQ     pkm2EverstoneCheck
  89. RAM_OVL36:021BD6BE 01 98       LDR     R0, [SP,#4]                     ; if bool is true, load nature1 into r0
  90. RAM_OVL36:021BD6C0 02 B0       ADD     SP, SP, #8                      ; unwind
  91. RAM_OVL36:021BD6C2 E0 60       STR     R0, [R4,#0xC]                   ; store nature1 to egg struct in nature spot
  92. RAM_OVL36:021BD6C4 01 20       MOVS    R0, #1                          ; bool eStone = TRUE
  93. RAM_OVL36:021BD6C6 E0 64       STR     R0, [R4,#0x4C]                  ; set estoneParent1 to true
  94. RAM_OVL36:021BD6C8 F8 BD       POP     {R3-R7,PC}
  95. RAM_OVL36:021BD6CA             ; ---------------------------------------------------------------------------
  96. RAM_OVL36:021BD6CA
  97. RAM_OVL36:021BD6CA             pkm2EverstoneCheck                      ; CODE XREF: everstoneHandler+90j
  98. RAM_OVL36:021BD6CA 00 2F       CMP     R7, #0                          ; r7 is the 'does pkm2 have estone' bool
  99. RAM_OVL36:021BD6CC 02 D0       BEQ     return                          ; if this is false, neither pkm has an everstone.  finish.
  100. RAM_OVL36:021BD6CE 01 20       MOVS    R0, #1                          ; bool eStone = TRUE
  101. RAM_OVL36:021BD6D0 E5 60       STR     R5, [R4,#0xC]                   ; store nature2 to egg struct in nature spot
  102. RAM_OVL36:021BD6D2 20 65       STR     R0, [R4,#0x50]                  ; set estoneParent2 to true
  103. RAM_OVL36:021BD6D4
  104. RAM_OVL36:021BD6D4             return                                  ; CODE XREF: everstoneHandler+A0j
  105. RAM_OVL36:021BD6D4 02 B0       ADD     SP, SP, #8                      ; unwind
  106. RAM_OVL36:021BD6D6 F8 BD       POP     {R3-R7,PC}
  107. RAM_OVL36:021BD6D6             ; End of function everstoneHandler
Advertisement