Advertisement
Guest User

Untitled

a guest
Jul 12th, 2014
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. The fans in the Mistralton City gym of Black 2 will probably cause much grief
  2. for Twitch Plays Pokemon.
  3.  
  4. The fans have three speeds:
  5. - Slow: runs for 120 frames (2 seconds)
  6. - Medium: louder, runs for 120 frames (another 2 seconds)
  7. - Fast: sends unprotected player flying back
  8. Thus the unmodified fan interval is 240 frames (4 seconds).
  9.  
  10. There is a counter which increments once every 2 frames, located at 0231B3F0.
  11. It is 16 bit. That memory location does appear to be used for other things.
  12.  
  13. Here is the function which determines fan speed:
  14. 021E:F184 2878 CMP R0, #78
  15. 021E:F186 D301 BCC #21EF18C
  16. 021E:F188 2002 MOV R0, #2
  17. 021E:F18A 4770 BX LR
  18. 021E:F18C 283C CMP R0, #3C
  19. 021E:F18E D301 BCC #21EF194
  20. 021E:F190 2001 MOV R0, #1
  21. 021E:F192 4770 BX LR
  22. 021E:F194 2000 MOV R0, #0
  23. 021E:F196 4770 BX LR
  24.  
  25. This function returns 0 (corresponds to low fan speed), 1 (corresponds
  26. to medium fan speed) or 2 (corresponds to high fan speed) depending on its
  27. argument. The thresholds are 0x3c (60) and 0x78 (120).
  28.  
  29. The time spent at each speed can be modified by adjusting the thresholds.
  30. Unfourtunately, Thumb-mode instruction encoding doesn't allow immediate
  31. operands to be higher than 0xff (8.5 seconds), which may not be enough.
  32. Here is a replacement function I came up with (note: function must be less
  33. than 20 bytes):
  34.  
  35. 021E:F184 XXXX LSR R0, R0, #YY
  36. 021E:F186 2802 CMP R0, #2
  37. 021E:F188 D300 BCC #21EF18C
  38. 021E:F18A 2002 MOV R0, #2
  39. 021E:F18C 4770 BX LR
  40.  
  41. This uses shifts to divide, and clamps the result to 2. The values
  42. for XXXX and YY are:
  43. - XXXX = 0940, YY = 06: fan interval = 128 frames (2.13 seconds)
  44. - XXXX = 0980, YY = 07: fan interval = 256 frames (4.27 seconds ~ original)
  45. - XXXX = 09C0, YY = 08: fan interval = 512 frames (8.53 seconds)
  46. - XXXX = 0A00, YY = 09: fan interval = 1024 frames (17.1 seconds)
  47. - XXXX = 0A40, YY = 10: fan interval = 2048 frames (34.1 seconds)
  48. - XXXX = 0A80, YY = 11: fan interval = 4096 frames (68.3 seconds)
  49. - XXXX = 0AC0, YY = 12: fan interval = 8192 frames (137 seconds)
  50.  
  51. Here is an action replay code for this:
  52.  
  53. 521EF174 63206B60
  54. 121EF184 0000XXXX
  55. 121EF186 00002802
  56. 121EF188 0000D300
  57. 121EF18A 00002002
  58. 121EF18C 00004770
  59. D0000000 00000000
  60.  
  61. The "521EF174 63206B60" and "D0000000 00000000" make this code conditional.
  62. This is required because Pokemon Black 2 uses dynamically-loaded code
  63. overlays, and unconditional writing will cause the game to freeze in battles.
  64. The "63206B60" is unrelated code from the same overlay.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement