diff options
author | Diegoisawesome <diego@domoreaweso.me> | 2017-11-29 00:52:32 -0600 |
---|---|---|
committer | Diegoisawesome <diego@domoreaweso.me> | 2017-11-29 00:52:32 -0600 |
commit | 70743f4b951bb84ca33fd2151e55b2f5018eb6c5 (patch) | |
tree | 7298959f4e81c88adeac0c26b9016b9d197da1fd /src/coins.c | |
parent | 52624c4fb7c145c33a2d0edc1d64b2d6e09c1336 (diff) | |
parent | 54da96309186b98263b4434911e1c5b8d4b4e3ec (diff) |
Merge branch 'master' of https://github.com/pret/pokeemerald
Diffstat (limited to 'src/coins.c')
-rw-r--r-- | src/coins.c | 28 |
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; +} |