Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Repoint the stack to a more convenient place
- add sp, $9E ; sp = $DF53, PP move 3 of 28th (?) Pokémon
- ; Get the target item (in d) and a new location for the stack (in hl)
- pop hl ; PP moves 1 and 2
- pop de ; PP move 3, only d matters
- ld sp, hl ; Repoint the stack (again)
- ; The new location should contain the sequence 20 A4 69 AD (which will be pop'd into hl)
- ; Now, edit the save file to put a TM in the items pocket (heya ACE !)
- pop hl ; ld hl, $A420
- ; d contains the ID of the target TM
- push de ; Perform ld a, d in conjunction with later "pop af"
- or $50 ; Padding w/ terminator (for box names)
- pop af ; Reminds me of a meme... hm.
- sub [hl] ; hl points to the item to be modified, we compute the difference
- push af ; Save that
- ; Load the new item ID into [hl]
- call LoadToHL ; Increments hl but who cares
- or a ; Padding
- or $50 ; Padding & terminator
- pop af ; Get back difference
- ; Repoint hl to save file's checksum
- pop hl ; ld hl, $AD69
- add [hl] ; Add the difference between both items to fix the checksum
- call LoadToHL+1 ; Skip loading d into a
- di ; Padding
- di
- ld d, b ; Terminator
- ; If needed, perform carry
- call nc, IncAtHL ; Condition inverted by second LoadToHL
- ; Reset game to stabilize everything
- rst $00
- ; These two auxiliary functions perform operations that can't be spelled by box names
- ; They can be anywhere (in WRAM, probably)
- LoadToHL:
- ld a, d
- ld [hli], a
- ccf ; Used to complement the carry of the second addition
- ret
- IncAtHL:
- inc [hl]
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement