Advertisement
chainswordcs

Pokemon Gold/Silver Wrong-Pocket TM13 reverse engineering and notes

May 16th, 2022
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. Part One: What precisely does wrong-pocket TM13 do?
  2.  
  3. For the Pokemon that was last selected in the party menu (with the A Button),
  4.  
  5. For all of that Pokemon's moves,
  6. Add more 'Remaining PP' equal to:
  7. < Move's current 'Maximum PP' (considering PP UPs) - Move's original 'Maximum PP' (ignoring PP UPs) >
  8.  
  9. So...
  10.  
  11. For any move with 0 PP UPs used on it:
  12. the 'Remaining PP' doesn't change.
  13.  
  14. For a move that had 20 'Maximum PP', had 1 PP UP used, and now has 24 'Maximum PP':
  15. the 'Remaining PP' increases by 4.
  16.  
  17. For a move that had 20 'Maximum PP', had 3 PP UPs used, and now has 32 'Maximum PP':
  18. the 'Remaining PP' increases by 12.
  19.  
  20. etc.
  21.  
  22. Note 1: This allows for a 'Remaining PP' value higher than the current allowed 'Maximum PP' value.
  23.  
  24. Note 2: If the 'Remaining PP' goes over 63, it overflows and turns into a smaller number.
  25. BUT ALSO, increments* the number of PP UPs used.
  26. (If it was 1, it becomes 2. If it was 2, it becomes 3. If it was 3, it becomes 0.)
  27.  
  28. ----------------------------------------------------------------------------------------------------
  29.  
  30. Part Two: Adding notes and tracing through the code
  31.  
  32. ApplyPPUp:
  33. ld a, MON_MOVES
  34. call GetPartyParamLocation
  35. push hl
  36. ld de, wPPUpPPBuffer
  37. predef FillPP
  38. pop hl
  39. ld bc, MON_PP - MON_MOVES
  40. add hl, bc
  41. ld de, wPPUpPPBuffer
  42. ld b, 0
  43. .loop
  44. inc b
  45. ld a, b
  46. cp NUM_MOVES + 1
  47. ret z ; (After <=5 loops) if we reach the end of the move list, give up and return.
  48. ld a, [wUsePPUp]
  49. dec a
  50. jr nz, .use ; Problem #1, wTempTMHM (wUsePPUp) is supposed to be $01 but instead it is $CC. (This happens in the function RestorePPEffect.do_ppup)
  51. ; Execution SHOULD fall through but it jumps to .use
  52.  
  53. ; Comment: Why is the previous line even in the code? The ApplyPPUp function is only referenced once in the code.
  54. ; Perhaps earlier in development, PP-restoring items also used this code path.
  55.  
  56. ld a, [wMenuCursorY] ; In normal execution, we check if the current 'focused' move is or isnt the one that
  57. inc a ; the player selected. If it isn't, then jump to .skip and loop back.
  58. cp b ; But if it IS, then fall through to .use
  59. jr nz, .skip ; But this section of code is always skipped by TM13 anyway (:
  60.  
  61. .use
  62. ld a, [hl] ; Problem #2!!!
  63. and PP_UP_MASK ; Normally when a PP UP has been used, it adds one to the "PP UPs used"
  64. ld a, [de] ; counter for the given move *BEFORE* reaching this code. (This happens in the function RestorePPEffect.do_ppup)
  65. call nz, ComputeMaxPP ; As a result, TM13 doesn't quite work as a PP UP.
  66. .skip
  67. inc hl ; Try the next move in the list
  68. inc de
  69. jr .loop ; Loop.
  70.  
  71. ; Fun facts / what else matters?:
  72. ; The last selected party Pokemon matters
  73. ; All of the registers do not matter (each one is overwritten before being used within this function).
  74.  
  75. ; Note! There is another area of code that gets executed related to
  76. ; adding more 'Remaining PP' to a given move.
  77. ; Because it was easy enough to empirically observe, I have chosen not to debug that code.
  78. ; (I debugged this code first anyway, and this whole process has already taken 4 hours.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement