Advertisement
Bond697

Pokerus Generation, Gen 5

Dec 29th, 2012
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 8.51 KB | None | 0 0
  1. RAM_ARM9:0202053C             ; void __fastcall pokerusHandler(void *pPartyBlk)
  2. RAM_ARM9:0202053C             pokerusHandler
  3. RAM_ARM9:0202053C
  4. RAM_ARM9:0202053C             num2            = -0x20
  5. RAM_ARM9:0202053C             var_18          = -0x18
  6. RAM_ARM9:0202053C
  7. RAM_ARM9:0202053C 78 B5                       PUSH    {R3-R6,LR}
  8. RAM_ARM9:0202053E 83 B0                       SUB     SP, SP, #0xC
  9. RAM_ARM9:02020540 06 1C                       MOVS    R6, R0
  10. RAM_ARM9:02020542 FF F7 6F FC                 BL      getPartySize
  11. RAM_ARM9:02020546 00 90                       STR     R0, [SP,#0x20+num2]
  12. RAM_ARM9:02020548 23 F0 06 FD                 BL      mersenneTwisterHandler
  13. RAM_ARM9:0202054C 00 21                       MOVS    R1, #0
  14. RAM_ARM9:0202054E 00 0C                       LSRS    R0, R0, #0x10
  15. RAM_ARM9:02020550 09 04                       LSLS    R1, R1, #0x10
  16. RAM_ARM9:02020552 01 43                       ORRS    R1, R0
  17. RAM_ARM9:02020554 08 04                       LSLS    R0, R1, #0x10
  18. RAM_ARM9:02020556 04 0C                       LSRS    R4, R0, #0x10
  19. RAM_ARM9:02020558 30 1C                       MOVS    R0, R6          ; pPartyBlk
  20. RAM_ARM9:0202055A 00 F0 E3 F8                 BL      pokerusBitmaskForPartyPKM
  21. RAM_ARM9:0202055E 02 90                       STR     R0, [SP,#0x20+var_18]
  22. RAM_ARM9:02020560 01 20 80 03                 MOVS    R0, 0x4000
  23. RAM_ARM9:02020564 84 42                       CMP     R4, R0
  24. RAM_ARM9:02020566 06 D0                       BEQ     loc_2020576
  25. RAM_ARM9:02020568 40 00                       LSLS    R0, R0, #1
  26. RAM_ARM9:0202056A 84 42                       CMP     R4, R0
  27. RAM_ARM9:0202056C 03 D0                       BEQ     loc_2020576
  28. RAM_ARM9:0202056E 03 20 80 03                 MOVS    R0, 0xC000
  29. RAM_ARM9:02020572 84 42                       CMP     R4, R0
  30. RAM_ARM9:02020574 43 D1                       BNE     loc_20205FE
  31. RAM_ARM9:02020576
  32. RAM_ARM9:02020576             loc_2020576                             ; CODE XREF: pokerusHandler+2Aj
  33. RAM_ARM9:02020576                                                     ; pokerusHandler+30j
  34. RAM_ARM9:02020576 00 20                       MOVS    R0, #0
  35. RAM_ARM9:02020578 01 90                       STR     R0, [SP,#0x20+num2+4]
  36. RAM_ARM9:0202057A
  37. RAM_ARM9:0202057A             loc_202057A                             ; CODE XREF: pokerusHandler+6Aj
  38. RAM_ARM9:0202057A                                                     ; pokerusHandler+78j
  39. RAM_ARM9:0202057A 23 F0 ED FC                 BL      mersenneTwisterHandler
  40. RAM_ARM9:0202057E 00 99                       LDR     R1, [SP,#0x20+num2]
  41. RAM_ARM9:02020580 05 1C                       MOVS    R5, R0
  42. RAM_ARM9:02020582 00 29                       CMP     R1, #0
  43. RAM_ARM9:02020584 05 D0                       BEQ     loc_2020592
  44. RAM_ARM9:02020586 00 9A                       LDR     R2, [SP,#0x20+num2] ; num2
  45. RAM_ARM9:02020588 01 9B                       LDR     R3, [SP,#0x20+num2+4]
  46. RAM_ARM9:0202058A 00 21                       MOVS    R1, #0
  47. RAM_ARM9:0202058C 6D F0 54 E8                 BLX     mul64           ; (u64)mt32 * (u64)partyCount >> 32 (there's not really a right-shift, we just use what's in r1.  shh!)
  48. RAM_ARM9:02020590 0D 1C                       ADDS    R5, R1, #0      ; pick poke to give pokerus
  49. RAM_ARM9:02020592
  50. RAM_ARM9:02020592             loc_2020592                             ; CODE XREF: pokerusHandler+48j
  51. RAM_ARM9:02020592 30 1C                       MOVS    R0, R6          ; pPartyBlk
  52. RAM_ARM9:02020594 29 1C                       MOVS    R1, R5          ; slot
  53. RAM_ARM9:02020596 FF F7 CD FC                 BL      getPartyPkmEncAdr ; get address of encrypted portion of pkm
  54. RAM_ARM9:0202059A 05 21                       MOVS    R1, #5          ; field
  55. RAM_ARM9:0202059C 00 22                       MOVS    R2, #0          ; data
  56. RAM_ARM9:0202059E 04 1C                       MOVS    R4, R0
  57. RAM_ARM9:020205A0 FC F7 C0 FB                 BL      getPKMStat      ; species
  58. RAM_ARM9:020205A4 00 28                       CMP     R0, #0          ; if the species is 0, things are fucked because we already randomly picked from the current party size. try again.
  59. RAM_ARM9:020205A6 E8 D0                       BEQ     loc_202057A
  60. RAM_ARM9:020205A8 20 1C                       MOVS    R0, R4          ; pPKMBlock
  61. RAM_ARM9:020205AA 4C 21                       MOVS    R1, #0x4C ; 'L' ; field
  62. RAM_ARM9:020205AC 00 22                       MOVS    R2, #0          ; data
  63. RAM_ARM9:020205AE FC F7 B9 FB                 BL      getPKMStat      ; isEgg
  64. RAM_ARM9:020205B2 00 28                       CMP     R0, #0
  65. RAM_ARM9:020205B4 E1 D1                       BNE     loc_202057A     ; try again if it's an egg
  66. RAM_ARM9:020205B6 01 21                       MOVS    R1, #1
  67. RAM_ARM9:020205B8 A9 40                       LSLS    R1, R5
  68. RAM_ARM9:020205BA 02 98                       LDR     R0, [SP,#0x20+var_18] ; this is the result of the party bitmask to see if it already has pokerus
  69. RAM_ARM9:020205BC 08 42                       TST     R0, R1          ; partyBitmask & (1 << slotNum)
  70. RAM_ARM9:020205BE 1E D1                       BNE     loc_20205FE     ; if it's not 0(equal), then there was a hit and it already has pokerus.  go to the end.
  71. RAM_ARM9:020205C0 00 25                       MOVS    R5, #0
  72. RAM_ARM9:020205C2 07 26                       MOVS    R6, #7
  73. RAM_ARM9:020205C4
  74. RAM_ARM9:020205C4             loc_20205C4                             ; CODE XREF: pokerusHandler+9Aj
  75. RAM_ARM9:020205C4 23 F0 C8 FC                 BL      mersenneTwisterHandler
  76. RAM_ARM9:020205C8 00 0E                       LSRS    R0, R0, #0x18   ; mt32 >> 24
  77. RAM_ARM9:020205CA 29 02                       LSLS    R1, R5, #8      ; r1 = r5 << 8, but r5= 0 if we're this far. wtf?
  78. RAM_ARM9:020205CC 01 43                       ORRS    R1, R0          ; mt32 >> 24 | 0x0
  79. RAM_ARM9:020205CE 08 06                       LSLS    R0, R1, #0x18
  80. RAM_ARM9:020205D0 00 0E                       LSRS    R0, R0, #0x18   ; junk
  81. RAM_ARM9:020205D2 02 1C                       MOVS    R2, R0          ; move result of (mt32 >> 24 | 0) << 24 >> 24 (wtf?!) to r2
  82. RAM_ARM9:020205D4 32 40                       ANDS    R2, R6          ; (mt32 >> 24) & 7
  83. RAM_ARM9:020205D6 F5 D0                       BEQ     loc_20205C4     ; if bits 24-26 of the mt32 are unset, try again for duration and such.  r5 still never gets touched.
  84. RAM_ARM9:020205D8 F0 21                       MOVS    R1, #0xF0 ; '=' ; is the strain non-zero
  85. RAM_ARM9:020205DA 01 42                       TST     R1, R0
  86. RAM_ARM9:020205DC 00 D0                       BEQ     loc_20205E0
  87. RAM_ARM9:020205DE 10 1C                       ADDS    R0, R2, #0      ; if the strain is indeed non-zero, continue with that mt32 >> 24
  88. RAM_ARM9:020205E0
  89. RAM_ARM9:020205E0             loc_20205E0                             ; CODE XREF: pokerusHandler+A0j
  90. RAM_ARM9:020205E0 01 07                       LSLS    R1, R0, #0x1C   ; (mt32 >> 24) << 28 (trim the top 4 bits, the strain)
  91. RAM_ARM9:020205E2 03 1C                       MOVS    R3, R0          ; save mt32 >> 24 to r3
  92. RAM_ARM9:020205E4 09 0E                       LSRS    R1, R1, #0x18   ; duration is now strain(wtf?)
  93. RAM_ARM9:020205E6 0B 43                       ORRS    R3, R1          ; (mt32 >> 24) | ((duration << 4) & 0xFF) - this is why it can't be 8x
  94. RAM_ARM9:020205E8 F3 22                       MOVS    R2, #0xF3 ; '='
  95. RAM_ARM9:020205EA 1A 40                       ANDS    R2, R3          ; ((mt32 >> 24) | ((duration << 4) & 0xFF)) & F3
  96. RAM_ARM9:020205EC 12 06                       LSLS    R2, R2, #0x18   ; typecast to u8
  97. RAM_ARM9:020205EE 12 0E                       LSRS    R2, R2, #0x18
  98. RAM_ARM9:020205F0 52 1C                       ADDS    R2, R2, #1      ; (((mt32 >> 24) | ((duration << 4) & 0xFF)) & F3) + 1
  99. RAM_ARM9:020205F2 12 06                       LSLS    R2, R2, #0x18   ; typecast again to u8.  jesus christ.
  100. RAM_ARM9:020205F4 20 1C                       MOVS    R0, R4          ; pPkm
  101. RAM_ARM9:020205F6 97 21                       MOVS    R1, #0x97 ; 'ù' ; field
  102. RAM_ARM9:020205F8 12 0E                       LSRS    R2, R2, #0x18
  103. RAM_ARM9:020205FA FC F7 A5 FB                 BL      setPKMStat
  104. RAM_ARM9:020205FE
  105. RAM_ARM9:020205FE             loc_20205FE                             ; CODE XREF: pokerusHandler+38j
  106. RAM_ARM9:020205FE                                                     ; pokerusHandler+82j
  107. RAM_ARM9:020205FE 03 B0                       ADD     SP, SP, #0xC
  108. RAM_ARM9:02020600 78 BD                       POP     {R3-R6,PC}
  109. RAM_ARM9:02020600             ; End of function pokerusHandler
  110. RAM_ARM9:02020600
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement