1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
INCLUDE "constants.asm"
SECTION "home/items.asm@TossItem", ROM0
TossItem:
ldh a, [hROMBank]
push af
ld a, BANK(_TossItem)
call Bankswitch
push hl
push de
push bc
call _TossItem
pop bc
pop de
pop hl
pop af
call Bankswitch
ret
ReceiveItem::
; function to add an item (in varying quantities) to the player's bag or PC box
; INPUT:
; HL = address of inventory (either wNumBagItems or wNumBoxItems)
; [wCurItem] = item ID
; [wItemQuantity] = item quantity
; sets carry flag if successful, unsets carry flag if unsuccessful
push bc
ldh a, [hROMBank]
push af
ld a, BANK(_ReceiveItem)
call Bankswitch
push hl
push de
call _ReceiveItem
pop de
pop hl
pop bc
ld a, b
call Bankswitch
pop bc
ret
SECTION "home/items.asm@GiveItem", ROM0
GiveItem::
; Give player quantity c of item b,
; and copy the item's name to wcf4b.
; Return carry on success.
ld a, b
ld [wNamedObjectIndexBuffer], a
ld [wCurItem], a
ld a, c
ld [wItemQuantity], a
ld hl, wNumBagItems
call ReceiveItem
ret nc
call GetItemName
call CopyStringToStringBuffer2
scf
ret
|