summaryrefslogtreecommitdiff
path: root/home/inventory.asm
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-07-07 18:50:58 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-07-07 19:43:11 -0400
commitbbf2f51a02b2544f1bef32a5868503b474ae2fef (patch)
treed73507228a57e4f3cece2fb93fe7df3a9439553f /home/inventory.asm
parent51ac538c25f8c0a6d88101569a17f02d09855d31 (diff)
Move all code out of home.asm into home/
This results in 64 home/*.asm files, comparable to pokecrystal's 57.
Diffstat (limited to 'home/inventory.asm')
-rw-r--r--home/inventory.asm55
1 files changed, 55 insertions, 0 deletions
diff --git a/home/inventory.asm b/home/inventory.asm
new file mode 100644
index 00000000..ebaa4047
--- /dev/null
+++ b/home/inventory.asm
@@ -0,0 +1,55 @@
+; subtracts the amount the player paid from their money
+; OUTPUT: carry = 0(success) or 1(fail because there is not enough money)
+SubtractAmountPaidFromMoney::
+ farjp SubtractAmountPaidFromMoney_
+
+; adds the amount the player sold to their money
+AddAmountSoldToMoney::
+ ld de, wPlayerMoney + 2
+ ld hl, hMoney + 2 ; total price of items
+ ld c, 3 ; length of money in bytes
+ predef AddBCDPredef ; add total price to money
+ ld a, MONEY_BOX
+ ld [wTextBoxID], a
+ call DisplayTextBoxID ; redraw money text box
+ ld a, SFX_PURCHASE
+ call PlaySoundWaitForCurrent
+ jp WaitForSoundToFinish
+
+; function to remove an item (in varying quantities) from the player's bag or PC box
+; INPUT:
+; HL = address of inventory (either wNumBagItems or wNumBoxItems)
+; [wWhichPokemon] = index (within the inventory) of the item to remove
+; [wItemQuantity] = quantity to remove
+RemoveItemFromInventory::
+ ldh a, [hLoadedROMBank]
+ push af
+ ld a, BANK(RemoveItemFromInventory_)
+ ldh [hLoadedROMBank], a
+ ld [MBC1RomBank], a
+ call RemoveItemFromInventory_
+ pop af
+ ldh [hLoadedROMBank], a
+ ld [MBC1RomBank], a
+ ret
+
+; 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)
+; [wcf91] = item ID
+; [wItemQuantity] = item quantity
+; sets carry flag if successful, unsets carry flag if unsuccessful
+AddItemToInventory::
+ push bc
+ ldh a, [hLoadedROMBank]
+ push af
+ ld a, BANK(AddItemToInventory_)
+ ldh [hLoadedROMBank], a
+ ld [MBC1RomBank], a
+ call AddItemToInventory_
+ pop bc
+ ld a, b
+ ldh [hLoadedROMBank], a
+ ld [MBC1RomBank], a
+ pop bc
+ ret