diff options
author | Pokeglitch <pokeglitchx@gmail.com> | 2018-06-16 10:24:17 -0400 |
---|---|---|
committer | Pokeglitch <pokeglitchx@gmail.com> | 2018-06-16 10:24:17 -0400 |
commit | f11e353fbb7d08f33ac58b49f586f65fb800cfba (patch) | |
tree | 75d14b6d688b54a22d3da14461506fcea1289f85 /engine/items/inventory.asm | |
parent | 758398b87df2b172e85492efad9272d5e7965ac9 (diff) |
More Bank 3 routines
Diffstat (limited to 'engine/items/inventory.asm')
-rwxr-xr-x | engine/items/inventory.asm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/engine/items/inventory.asm b/engine/items/inventory.asm index 9c5a1ec..729ba45 100755 --- a/engine/items/inventory.asm +++ b/engine/items/inventory.asm @@ -587,6 +587,52 @@ GetNumberedTMHM: ; 03:4D1A .not_machine
and a
ret
+
+SECTION "GetItemAmount", ROMX[$4e10], BANK[$03]
+
+; Returns carry if user has the item
+; and the amount in b
+GetItemAmount: ; 03:4e10
+ call CheckAmountInItemPocket
+ ret c
+ call CheckAmountInKeyItems
+ ret c
+ ld b, 0
+ and a
+ ret
+
+; Returns the amount of item b in b
+CheckAmountInItemPocket: ; 03:4E1C
+ ld hl, wItems
+.loop
+ inc hl
+ ld a, [hli]
+ cp -1
+ ret z
+ cp b
+ jr nz, .loop
+
+ ld a, [hl]
+ ld b, a
+ scf
+ ret
+
+; Returns the amount of item b in b
+CheckAmountInKeyItems: ; 03:4E2B
+ ld hl, wNumKeyItems
+ ld a, [hli]
+ and a
+ ret z
+
+.loop
+ ld a, [hli]
+ cp -1
+ ret z
+ cp b
+ jr nz, .loop
+ ld b, 1
+ scf
+ ret
SECTION "_CheckTossableItem", ROMX[$53AD], BANK[$03]
|