From 89d938ea9e10a637563a5b4d0d19ddb4535bcf8e Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 23 Nov 2017 13:53:51 -0500 Subject: Finish decompiling coins --- src/coins.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src') 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; +} -- cgit v1.2.3 From c5dcbb78ce0a2fc423190aa743907164b72997a7 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 23 Nov 2017 21:04:15 -0500 Subject: unk_81BAD84 --- src/unk_81BAD84.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/unk_81BAD84.c (limited to 'src') diff --git a/src/unk_81BAD84.c b/src/unk_81BAD84.c new file mode 100644 index 000000000..43cb9a4b0 --- /dev/null +++ b/src/unk_81BAD84.c @@ -0,0 +1,20 @@ +#include "global.h" + +extern const struct { + const u8 *unk_0; + const u8 *unk_4; + const u8 *unk_8; +} gUnknown_08617128[]; + +void sub_81BAD84(u32 idx) +{ + REG_DISPCNT = 0x0000; + REG_BG0HOFS = 0x0000; + REG_BG0VOFS = 0x0000; + REG_BLDCNT = 0x0000; + LZ77UnCompVram(gUnknown_08617128[idx].unk_0, (void *)BG_CHAR_ADDR(0)); + LZ77UnCompVram(gUnknown_08617128[idx].unk_4, (void *)BG_SCREEN_ADDR(31)); + CpuCopy16(gUnknown_08617128[idx].unk_8, (void *)PLTT, 0x200); + REG_BG0CNT = 0x1f00; + REG_DISPCNT = DISPCNT_BG0_ON; +} -- cgit v1.2.3 From 772da493f9ea0dcd8838dd927f1b70ff63228c21 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 23 Nov 2017 21:15:57 -0500 Subject: data/unk_81BAD84 --- src/unk_81BAD84.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/unk_81BAD84.c b/src/unk_81BAD84.c index 43cb9a4b0..9ba98dd87 100644 --- a/src/unk_81BAD84.c +++ b/src/unk_81BAD84.c @@ -1,10 +1,37 @@ #include "global.h" +#include "graphics.h" -extern const struct { - const u8 *unk_0; - const u8 *unk_4; - const u8 *unk_8; -} gUnknown_08617128[]; +const struct { + const u8 *gfx; + const u8 *tileMap; + const u16 *pltt; +} gUnknown_08617128[] = { + { + gUnknown_08DD87C0, + gUnknown_08DD8EE0, + gUnknown_08DD8780 + }, { + gUnknown_08DD90E0, + gUnknown_08DD9718, + gUnknown_08DD9080 + }, { + gUnknown_08DD98B4, + gUnknown_08DD9E58, + gUnknown_08DD9874 + }, { + gUnknown_08DDA02C, + gUnknown_08DDA63C, + gUnknown_08DD9FEC + }, { + gUnknown_08DDA840, + gUnknown_08DDAE40, + gUnknown_08DDA800 + }, { + gUnknown_08DDB020, + gUnknown_08DDB2C4, + gUnknown_08DDAFE0 + } +}; void sub_81BAD84(u32 idx) { @@ -12,9 +39,9 @@ void sub_81BAD84(u32 idx) REG_BG0HOFS = 0x0000; REG_BG0VOFS = 0x0000; REG_BLDCNT = 0x0000; - LZ77UnCompVram(gUnknown_08617128[idx].unk_0, (void *)BG_CHAR_ADDR(0)); - LZ77UnCompVram(gUnknown_08617128[idx].unk_4, (void *)BG_SCREEN_ADDR(31)); - CpuCopy16(gUnknown_08617128[idx].unk_8, (void *)PLTT, 0x200); + LZ77UnCompVram(gUnknown_08617128[idx].gfx, (void *)BG_CHAR_ADDR(0)); + LZ77UnCompVram(gUnknown_08617128[idx].tileMap, (void *)BG_SCREEN_ADDR(31)); + CpuCopy16(gUnknown_08617128[idx].pltt, (void *)PLTT, 0x200); REG_BG0CNT = 0x1f00; REG_DISPCNT = DISPCNT_BG0_ON; } -- cgit v1.2.3 From da04898840083653835db7ca997b6d57f1d3c353 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 23 Nov 2017 23:10:51 -0500 Subject: Clean up includes --- src/coins.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/coins.c b/src/coins.c index e313a4221..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; -- cgit v1.2.3