summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/coins.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/coins.c b/src/coins.c
index e1694b29c..50c31cac0 100644
--- a/src/coins.c
+++ b/src/coins.c
@@ -2,8 +2,9 @@
#include "coins.h"
#include "text.h"
#include "window.h"
-#include "text_window.h"
+#include "strings.h"
#include "string_util.h"
+#include "new_menu_helpers.h"
#include "menu.h"
#include "international_string_util.h"
@@ -11,10 +12,6 @@
EWRAM_DATA u8 sCoinsWindowId = 0;
-extern void sub_819746C(u8 windowId, bool8 copyToVram);
-
-extern const u8 gText_Coins[];
-
void PrintCoinsString(u32 coinAmount)
{
u32 xAlign;
@@ -53,7 +50,6 @@ void SetCoins(u16 coinAmount)
gSaveBlock1Ptr->coins = coinAmount ^ gSaveBlock2Ptr->encryptionKey;
}
-/* Can't match it lol
bool8 GiveCoins(u16 toAdd)
{
u16 newAmount;
@@ -67,10 +63,22 @@ bool8 GiveCoins(u16 toAdd)
}
else
{
- newAmount = ownedCoins + toAdd;
- if (newAmount > MAX_COINS)
- newAmount = MAX_COINS;
+ ownedCoins += toAdd;
+ if (ownedCoins > MAX_COINS)
+ ownedCoins = MAX_COINS;
+ newAmount = ownedCoins;
}
SetCoins(newAmount);
return TRUE;
-}*/
+}
+
+bool8 TakeCoins(u16 toSub)
+{
+ u16 ownedCoins = GetCoins();
+ if (ownedCoins >= toSub)
+ {
+ SetCoins(ownedCoins - toSub);
+ return TRUE;
+ }
+ return FALSE;
+}