Advertisement
Bond697

XFR Entralink

Mar 5th, 2012
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 2248D50
  2. 2248D94 Tick trigger
  3. 2248DBF
  4. 2246ee0 Base Pointer table address
  5. 2249B31 Store Rand 1 (B)
  6. 2249B32 Store Rand 2 (W)
  7.  
  8. N.B. Rand(x)=(u32*x)>>32 (result in [0,x-1])
  9.  
  10. C-Gear LCRNG advancement
  11. Two timers alternate: short period (1 frame) / long period (2 frames)
  12. Run as long as the C-Gear is on
  13. --
  14. Short Advance
  15. rand(40)+60
  16. --
  17. Long Advance
  18. rand(3)
  19. rand(152)+60
  20. --------------------------------------------------
  21. MEMORY:02178010 Adv1
  22. MEMORY:02178010 PUSH    {R4,LR}
  23. MEMORY:02178012 MOVS    R4, R0
  24. MEMORY:02178014 BL      getTick         @ 0x2248D50
  25. MEMORY:02178018 CMP     R0, #1
  26. MEMORY:0217801A BNE     __return
  27. MEMORY:0217801C LDR     R0, =0x2177401
  28. MEMORY:0217801E MOVS    R1, #0
  29. MEMORY:02178020 MOVS    R2, #0
  30. MEMORY:02178022 BL      loc_21785D4
  31. MEMORY:02178026 CMP     R0, #0
  32. MEMORY:02178028 BEQ     locret_2178040
  33. MEMORY:0217802A MOVS    R0, #0x28 @ '('
  34. MEMORY:0217802C BL      rand__
  35. MEMORY:02178030 LDR     R1, =0xCF2
  36. MEMORY:02178032 ADDS    R0, #0x3C @ '<'
  37. MEMORY:02178034 STRB    R0, [R4,R1]     @ Store rand(0x28)+0x3C at 0x2249B32
  38. MEMORY:02178036 LDR     R0, =dword_21797C4
  39. MEMORY:02178038 LDR     R1, =0x2177FE5
  40. MEMORY:0217803A LDR     R0, [R0]
  41. MEMORY:0217803C BL      sub_217729C
  42. --------------------------------------------------
  43. MEMORY:02177F68 Adv2:
  44. MEMORY:02177F68 PUSH    {R3-R5,LR}
  45. MEMORY:02177F6A MOVS    R4, R0
  46. MEMORY:02177F6C BL      IsTickOne
  47. MEMORY:02177F70 CMP     R0, #0
  48. MEMORY:02177F72 BEQ     __return
  49. MEMORY:02177F74 LDR     R1, =byte_2179698
  50. MEMORY:02177F76 ADD     R0, SP, #0
  51. MEMORY:02177F78 LDRB    R2, [R1]
  52. MEMORY:02177F7A STRB    R2, [R0]
  53. MEMORY:02177F7C LDRB    R2, [R1,#(byte_2179699 - 0x2179698)]
  54. MEMORY:02177F7E STRB    R2, [R0,#1]
  55. MEMORY:02177F80 LDRB    R1, [R1,#(byte_217969A - 0x2179698)]
  56. MEMORY:02177F82 STRB    R1, [R0,#2]
  57. MEMORY:02177F84 MOVS    R0, #3
  58. MEMORY:02177F86 BL      rand__
  59. MEMORY:02177F8A LDR     R1, =0xCF1
  60. MEMORY:02177F8C STRB    R0, [R4,R1]     @ Store rand(3) at 0x2249B31 (1byte)
  61. MEMORY:02177F8E LDRB    R0, [R4,R1]
  62. MEMORY:02177F90 CMP     R0, #3
  63. MEMORY:02177F92 BCC     Adv3
  64. MEMORY:02177F94 MOVS    R0, #0
  65. MEMORY:02177F96 STRB    R0, [R4,R1]     @ If rolled 3 replace with 0 (why?)
  66. --------------------------------------------------
  67. MEMORY:02177F98 Adv3:
  68. MEMORY:02177F98 BL      loc_21777AC
  69. MEMORY:02177F9C LDR     R5, =0xC68
  70. MEMORY:02177F9E MOVS    R0, #0
  71. MEMORY:02177FA0 MOVS    R2, R5
  72. MEMORY:02177FA2 ADDS    R2, #0x89 @ 'ë'
  73. MEMORY:02177FA4 LDRB    R3, [R4,R2]
  74. MEMORY:02177FA6 ADD     R2, SP, #0
  75. MEMORY:02177FA8 LDRH    R1, [R4,R5]
  76. MEMORY:02177FAA LDRB    R2, [R2,R3]
  77. MEMORY:02177FAC MOVS    R3, #1
  78. MEMORY:02177FAE BL      unk_21792A8
  79. MEMORY:02177FB2 CMP     R0, #0
  80. MEMORY:02177FB4 BEQ     locret_2177FCC
  81. MEMORY:02177FB6 MOVS    R0, #0x98 @ 'ÿ'
  82. MEMORY:02177FB8 BL      rand__
  83. MEMORY:02177FBC ADDS    R0, #0x3C @ '<'
  84. MEMORY:02177FBE ADDS    R5, #0x8A @ 'è'
  85. MEMORY:02177FC0 STRB    R0, [R4,R5]     @ Store rand(0x98)+0x3C at 0x2249B32
  86. MEMORY:02177FC2 LDR     R0, =dword_21797C4
  87. MEMORY:02177FC4 LDR     R1, =0x2177F1D
  88. MEMORY:02177FC6 LDR     R0, [R0]
  89. MEMORY:02177FC8 BL      sub_217729C
  90. --------------------------------------------------
  91.  
  92. Loading any area of Entree Forest that contains Pokémon
  93. will advance the RNG by 2 frames:
  94.  
  95. --------------------------------------------------
  96. MEMORY:0217C3FA loc_217C3FA:
  97. MEMORY:0217C3FA LSLS    R7, R4, #2
  98. MEMORY:0217C3FC LDR     R0, [R6,R7]
  99. MEMORY:0217C3FE LSLS    R0, R0, #0x15
  100. MEMORY:0217C400 LSRS    R0, R0, #0x15
  101. MEMORY:0217C402 BEQ     loc_217C45C
  102. MEMORY:0217C404 MOVS    R0, #2
  103. MEMORY:0217C406 BL      rand.event__
  104. MEMORY:0217C40A SUBS    R5, R0, #1
  105. MEMORY:0217C40C MOVS    R0, #2
  106. MEMORY:0217C40E BL      rand.event__
  107. MEMORY:0217C412 SUBS    R1, R0, #1
  108. MEMORY:0217C414 LDR     R2, [SP,#0x10]
  109. MEMORY:0217C416 LSLS    R3, R4, #1
  110. MEMORY:0217C418 LDR     R0, [SP,#0x10]
  111. MEMORY:0217C41A LDRB    R2, [R2,R3]
  112. MEMORY:0217C41C ADDS    R0, R0, R3
  113. MEMORY:0217C41E LDRB    R0, [R0,#1]
  114. MEMORY:0217C420 ADDS    R3, R5, R2
  115. MEMORY:0217C422 LDR     R2, [SP,#0xC]
  116. MEMORY:0217C424 ADDS    R0, R1, R0
  117. MEMORY:0217C426 CMP     R2, R3
  118. MEMORY:0217C428 BNE     loc_217C442
  119. MEMORY:0217C42A LDR     R2, [SP,#8]
  120. MEMORY:0217C42C CMP     R2, R0
  121. MEMORY:0217C42E BNE     loc_217C442
  122. MEMORY:0217C430 CMP     R5, #0
  123. MEMORY:0217C432 BEQ     loc_217C438
  124. MEMORY:0217C434 SUBS    R3, R3, R5
  125. MEMORY:0217C436 B       loc_217C442
  126. --------------------------------------------------
  127.  
  128. For some reason, some Pokémon like Nidoran have
  129. static movement (not RNG based). For all purposes,
  130. consider that they're not here. (more research needed
  131. for exhaustive list).
  132.  
  133. When in Entralink Forest with at least one Pokémon,
  134. the function used to move each around (@0x225249a)
  135. consumes 2 frame: timer is (rand(4)+1)*16 (possible
  136. values 0x10, 0x20, 0x30, 0x40) and direction is
  137. rand(4) with 0=N, 1=S, 2=E and 3=W.
  138.  
  139. This function is also used to move NPC in overworld.
  140.  
  141. The relevant memory locations for the timers are
  142. 0x255239A+(i*0x100) (i is the NPC#) and 0x255239C
  143. +(i*0x100) for the direction.
  144.  
  145. If the timer is shifted 16 bits to the left the
  146. movement is static (not RNG controlled).
  147.  
  148. !!! The "Do you want <x> to join your party" dialog
  149. will stop the NPC timer but not the main C-Gear one
  150.  
  151. !!! As soon as you interact, there is a dummy call to
  152. makePKM that will consume the usual frames of a Pokémon
  153. creation (6 for the PIDRNG). The call to MakePKM that is
  154. actually used is when you press yes.
  155.  
  156. !!! The PID method for entralink is set ability, set
  157. gender. The generated PID will have its last byte and
  158. 17th bit modified accordingly
  159.  
  160. --------------------------------------------------
  161. MEMORY:0219A1C8 MoveNPC:
  162. MEMORY:0219A1C8 LDRH    R0, [R4]
  163. MEMORY:0219A1CA CMP     R0, #0
  164. MEMORY:0219A1CC BNE     loc_219A1FA
  165. MEMORY:0219A1CE MOVS    R1, #2
  166. MEMORY:0219A1D0 LDRSH   R0, [R4,R1]
  167. MEMORY:0219A1D2 SUBS    R0, R0, #1
  168. MEMORY:0219A1D4 STRH    R0, [R4,#2]
  169. MEMORY:0219A1D6 LDRSH   R0, [R4,R1]
  170. MEMORY:0219A1D8 CMP     R0, #0
  171. MEMORY:0219A1DA BGT     loc_219A1FA     @ Skip if [0x225249a]>0
  172. MEMORY:0219A1DC LDR     R0, loc_219A204
  173. MEMORY:0219A1DE SUBS    R1, R1, #3
  174. MEMORY:0219A1E0 BL      NPCTimer
  175. MEMORY:0219A1E4 STRH    R0, [R4,#2]
  176. MEMORY:0219A1E6 LDR     R0, [R4,#4]
  177. MEMORY:0219A1E8 MOVS    R1, R6
  178. MEMORY:0219A1EA BL      NPCDirection        @ Not sure what this rand(4) is used for
  179. MEMORY:0219A1EE ADDS    R1, R0, #0
  180. --------------------------------------------------
  181. MEMORY:0219B110 NPCTimer:
  182. MEMORY:0219B110 PUSH    {R4,LR}
  183. MEMORY:0219B112 MOVS    R4, R0
  184. MEMORY:0219B114 BL      loc_219B0F8     @ This returns 4
  185. MEMORY:0219B118 BL      rand__
  186. MEMORY:0219B11C LSLS    R0, R0, #2
  187. MEMORY:0219B11E LDR     R0, [R4,R0]     @ [R4] is {0x10,0x20,0x30,0x40}
  188. MEMORY:0219B120 POP     {R4,PC}
  189. --------------------------------------------------
  190. MEMORY:0219B124 NPCDirection:
  191. MEMORY:0219B124 PUSH    {R3-R5,LR}
  192. MEMORY:0219B126 MOVS    R5, R1
  193. MEMORY:0219B128 BL      loc_219B140
  194. MEMORY:0219B12C MOVS    R1, R5
  195. MEMORY:0219B12E MOVS    R4, R0
  196. MEMORY:0219B130 BL      loc_219B0F8     @ This returns 4
  197. MEMORY:0219B134 BL      rand__
  198. MEMORY:0219B138 LSLS    R0, R0, #2
  199. MEMORY:0219B13A LDR     R0, [R4,R0]     @ [R4] is {0,1,2,3}
  200. MEMORY:0219B13C POP     {R3-R5,PC}
  201. --------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement