summaryrefslogtreecommitdiff
path: root/engine/items/subtract_paid_money.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/items/subtract_paid_money.asm')
-rw-r--r--engine/items/subtract_paid_money.asm17
1 files changed, 17 insertions, 0 deletions
diff --git a/engine/items/subtract_paid_money.asm b/engine/items/subtract_paid_money.asm
new file mode 100644
index 00000000..fdefe3d6
--- /dev/null
+++ b/engine/items/subtract_paid_money.asm
@@ -0,0 +1,17 @@
+; subtracts the amount the player paid from their money
+; OUTPUT: carry = 0(success) or 1(fail because there is not enough money)
+SubtractAmountPaidFromMoney_::
+ ld de, wPlayerMoney
+ ld hl, hMoney ; total price of items
+ ld c, 3 ; length of money in bytes
+ call StringCmp
+ ret c
+ ld de, wPlayerMoney + 2
+ ld hl, hMoney + 2 ; total price of items
+ ld c, 3 ; length of money in bytes
+ predef SubBCDPredef ; subtract total price from money
+ ld a, MONEY_BOX
+ ld [wTextBoxID], a
+ call DisplayTextBoxID ; redraw money text box
+ and a
+ ret