Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AceStart::
- WRAM1:DA7f 21 1C D3 ld hl, wNumBagItems [$D31C]
- WRAM1:DA82 4E ld c, (hl)
- WRAM1:DA83 0D dec c ;Load how many items in your bag and put it in c
- WRAM1:DA84 23 inc hl
- .L
- WRAM1:DA85 E5 push hl ;Save the starting address
- WRAM1:DA86 C5 push bc ;Save the counter
- WRAM1:DA87 46 ld b, (hl)
- WRAM1:DA88 23 inc hl
- WRAM1:DA89 2A ldi a, (hl) ;Load the first item as "previous item" and then increment hl
- .LOOP
- WRAM1:DA8A 56 ld d, (hl)
- WRAM1:DA8B 23 inc hl
- WRAM1:DA8C 5E ld e, (hl) ;Load the actual item as "current item"
- WRAM1:DA8D BB cp e ;Compare the quantity of previous and current item
- WRAM1:DA8E DA 9C DA jp c, .NO [$DA9C] ;If current quantity < previous quantity:
- WRAM1:DA91 E5 push hl ;Save hl for easy continue later
- WRAM1:DA92 32 ldd (hl), a
- WRAM1:DA93 70 ld (hl), b
- WRAM1:DA94 2B dec hl
- WRAM1:DA95 73 ld (hl), e
- WRAM1:DA96 2B dec hl
- WRAM1:DA97 72 ld (hl), d ;Switch the current item with the previous item in ram
- WRAM1:DA98 E1 pop hl
- WRAM1:DA99 C3 9E DA jp .CONTINUE [$DA9E] ;Get the previous status of hl and then jump to .CONTINUE
- .NO ;Else:
- WRAM1:DA9C 7B ld a, e
- WRAM1:DA9D 42 ld b, d ;Set the "old item" as the "current item"
- .CONTINUE
- WRAM1:DA9E 23 inc hl ;Skip to the next item
- WRAM1:DA9F 0D dec c
- WRAM1:DAA0 C2 8A DA jp nz, .LOOP [$DA8A] ;If all items are done:
- WRAM1:DAA3 C1 pop bc
- WRAM1:DAA4 E1 pop hl
- WRAM1:DAA5 0D dec c
- WRAM1:DAA6 C2 85 DA jp nz, .L [$DA85] ;Restart, but without doing the last item. If all items are ordered, return.
- WRAM1:DAA9 C9 ret
- ;******************** REGISTER ORGANIZATION ********************
- ; A F
- ; Previous item quantity -> [ ][ ] <- Flags
- ;
- ; B C
- ; Previous item index id -> [ ][ ] <- Counter
- ;
- ; D E
- ; Current item index id -> [ ][ ] <- Current item quantity
- ;***************** HOW POKEMON SAVE YOUR ITEMS *****************
- ;
- ; WRAM1:D31C <- How many items you have in your bag
- ; WRAM1:D31D <- Index id of your first item
- ; WRAM1:D31E <- Quantity of your first item
- ; WRAM1:D31F <- Index id of your second item
- ; WRAM1:D320 <- Quantity of your second item
- ; [...]
- ; WRAM1:D343 <- Index id of your 20th item
- ; WRAM1:D344 <- Quantity of your 20th item
- ; WRAM1:D345 = 0xFF (Cancel button, end of list item)
- ; WRAM1:D346 = 0x00
- ;Raw bytes for easy paste in gbc:
- 21 1c d3 4e 0d 23 e5 c5 46 23 2a 56 23 5e bb da 9c da e5 32 70 2b 72 e1 c3 9e da 7b 42 23 0d c2 8a da c1 e1 0d c2 85 da c9
- ;NOTE: pasting this in your ram will "delete" your pc box, and maybe it will also "corrupt" your save data.
- ;Used for this video: https://youtu.be/XTprmo04FKY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement