Files
pokegold-spaceworld/engine/items/get_item_amount.asm
Narishma-gb e88fe24e15 Use the same Makefile build system as Gen 1+2 repos (#163)
This uses catch-all files like main.asm to reduce the total quantity and size of
build objects (from 1.1 GB to 70 MB).

---------

Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com>
2026-07-05 15:36:09 -04:00

44 lines
518 B
NASM

; Returns carry if user has the item
; and the amount in b
GetItemAmount:
call CheckAmountInItemPocket
ret c
call CheckAmountInKeyItems
ret c
ld b, 0
and a
ret
; Returns the amount of item b in b
CheckAmountInItemPocket:
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:
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