Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/home/inventory.asm
1270 views
1
; subtracts the amount the player paid from their money
2
; OUTPUT: carry = 0(success) or 1(fail because there is not enough money)
3
SubtractAmountPaidFromMoney::
4
farjp SubtractAmountPaidFromMoney_
5
6
; adds the amount the player sold to their money
7
AddAmountSoldToMoney::
8
ld de, wPlayerMoney + 2
9
ld hl, hMoney + 2 ; total price of items
10
ld c, 3 ; length of money in bytes
11
predef AddBCDPredef ; add total price to money
12
ld a, MONEY_BOX
13
ld [wTextBoxID], a
14
call DisplayTextBoxID ; redraw money text box
15
ld a, SFX_PURCHASE
16
call PlaySoundWaitForCurrent
17
jp WaitForSoundToFinish
18
19
; function to remove an item (in varying quantities) from the player's bag or PC box
20
; INPUT:
21
; HL = address of inventory (either wNumBagItems or wNumBoxItems)
22
; [wWhichPokemon] = index (within the inventory) of the item to remove
23
; [wItemQuantity] = quantity to remove
24
RemoveItemFromInventory::
25
homecall RemoveItemFromInventory_
26
ret
27
28
; function to add an item (in varying quantities) to the player's bag or PC box
29
; INPUT:
30
; HL = address of inventory (either wNumBagItems or wNumBoxItems)
31
; [wCurItem] = item ID
32
; [wItemQuantity] = item quantity
33
; sets carry flag if successful, unsets carry flag if unsuccessful
34
AddItemToInventory::
35
push bc
36
homecall_sf AddItemToInventory_
37
pop bc
38
ret
39
40