diff options
author | PikalaxALT <pikalaxalt@gmail.com> | 2017-11-23 13:53:51 -0500 |
---|---|---|
committer | PikalaxALT <pikalaxalt@gmail.com> | 2017-11-23 13:53:51 -0500 |
commit | 89d938ea9e10a637563a5b4d0d19ddb4535bcf8e (patch) | |
tree | 9b2db5be6716ab491751012809a7d6a48a6f03c2 /src | |
parent | 1e4f12e6fa9e3b22d4f1a60ca69313b5dec0ca38 (diff) |
Finish decompiling coins
Diffstat (limited to 'src')
-rw-r--r-- | src/coins.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/coins.c b/src/coins.c index e1694b29c..e313a4221 100644 --- a/src/coins.c +++ b/src/coins.c @@ -53,7 +53,6 @@ void SetCoins(u16 coinAmount) gSaveBlock1Ptr->coins = coinAmount ^ gSaveBlock2Ptr->encryptionKey; } -/* Can't match it lol bool8 GiveCoins(u16 toAdd) { u16 newAmount; @@ -67,10 +66,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; +} |