Advertisement
ISSOtm

Pokémon Gold - Withdraw Smash ACE to TM in Item Pocket

Sep 30th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Repoint the stack to a more convenient place
  2. add sp, $9E ; sp = $DF53, PP move 3 of 28th (?) Pokémon
  3.  
  4. ; Get the target item (in d) and a new location for the stack (in hl)
  5. pop hl ; PP moves 1 and 2
  6. pop de ; PP move 3, only d matters
  7. ld sp, hl ; Repoint the stack (again)
  8.  
  9. ; The new location should contain the sequence 20 A4 69 AD (which will be pop'd into hl)
  10.  
  11. ; Now, edit the save file to put a TM in the items pocket (heya ACE !)
  12. pop hl ; ld hl, $A420
  13. ; d contains the ID of the target TM
  14. push de ; Perform ld a, d in conjunction with later "pop af"
  15.  
  16. or $50 ; Padding w/ terminator (for box names)
  17.  
  18. pop af ; Reminds me of a meme... hm.
  19.  
  20. sub [hl] ; hl points to the item to be modified, we compute the difference
  21. push af ; Save that
  22. ; Load the new item ID into [hl]
  23. call LoadToHL ; Increments hl but who cares
  24.  
  25. or a ; Padding
  26. or $50 ; Padding & terminator
  27.  
  28. pop af ; Get back difference
  29. ; Repoint hl to save file's checksum
  30. pop hl ; ld hl, $AD69
  31. add [hl] ; Add the difference between both items to fix the checksum
  32. call LoadToHL+1 ; Skip loading d into a
  33.  
  34. di ; Padding
  35. di
  36. ld d, b ; Terminator
  37.  
  38. ; If needed, perform carry
  39. call nc, IncAtHL ; Condition inverted by second LoadToHL
  40.  
  41. ; Reset game to stabilize everything
  42. rst $00
  43.  
  44.  
  45. ; These two auxiliary functions perform operations that can't be spelled by box names
  46. ; They can be anywhere (in WRAM, probably)
  47.  
  48. LoadToHL:
  49. ld a, d
  50. ld [hli], a
  51. ccf ; Used to complement the carry of the second addition
  52. ret
  53.  
  54. IncAtHL:
  55. inc [hl]
  56. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement