aboutsummaryrefslogtreecommitdiffstats
path: root/engine/events/pick_up_item.asm
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
committerdannye <33dannye@gmail.com>2020-11-04 00:06:44 -0600
commit5647ca687b92954dcf37a6ea6bfbc9a341c32de4 (patch)
treedde1937a1bfdb3a835f4155e1c2eb8f1aaf86f63 /engine/events/pick_up_item.asm
parentMerge pull request #55 from Deokishisu/patch-1 (diff)
downloadpokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.gz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.tar.xz
pokeyellow-5647ca687b92954dcf37a6ea6bfbc9a341c32de4.zip
Sync with pokered
Diffstat (limited to 'engine/events/pick_up_item.asm')
-rw-r--r--engine/events/pick_up_item.asm54
1 files changed, 54 insertions, 0 deletions
diff --git a/engine/events/pick_up_item.asm b/engine/events/pick_up_item.asm
new file mode 100644
index 00000000..548db5be
--- /dev/null
+++ b/engine/events/pick_up_item.asm
@@ -0,0 +1,54 @@
+PickUpItem:
+ call EnableAutoTextBoxDrawing
+
+ ldh a, [hSpriteIndexOrTextID]
+ ld b, a
+ ld hl, wMissableObjectList
+.missableObjectsListLoop
+ ld a, [hli]
+ cp $ff
+ ret z
+ cp b
+ jr z, .isMissable
+ inc hl
+ jr .missableObjectsListLoop
+
+.isMissable
+ ld a, [hl]
+ ldh [hMissableObjectIndex], a
+
+ ld hl, wMapSpriteExtraData
+ ldh a, [hSpriteIndexOrTextID]
+ dec a
+ add a
+ ld d, 0
+ ld e, a
+ add hl, de
+ ld a, [hl]
+ ld b, a ; item
+ ld c, 1 ; quantity
+ call GiveItem
+ jr nc, .BagFull
+
+ ldh a, [hMissableObjectIndex]
+ ld [wMissableObjectIndex], a
+ predef HideObject
+ ld a, 1
+ ld [wDoNotWaitForButtonPressAfterDisplayingText], a
+ ld hl, FoundItemText
+ jr .print
+
+.BagFull
+ ld hl, NoMoreRoomForItemText
+.print
+ call PrintText
+ ret
+
+FoundItemText:
+ text_far _FoundItemText
+ sound_get_item_1
+ text_end
+
+NoMoreRoomForItemText:
+ text_far _NoMoreRoomForItemText
+ text_end