diff options
-rw-r--r-- | include/battle_setup.h | 2 | ||||
-rw-r--r-- | include/money.h | 14 | ||||
-rw-r--r-- | src/battle_4.c | 8 | ||||
-rw-r--r-- | src/battle_setup.c | 2 | ||||
-rw-r--r-- | src/item_menu.c | 10 | ||||
-rw-r--r-- | src/money.c | 52 | ||||
-rw-r--r-- | src/scrcmd.c | 20 | ||||
-rw-r--r-- | src/shop.c | 14 |
8 files changed, 55 insertions, 67 deletions
diff --git a/include/battle_setup.h b/include/battle_setup.h index c8c463f6d..1aa195d92 100644 --- a/include/battle_setup.h +++ b/include/battle_setup.h @@ -98,7 +98,7 @@ bool32 GetTrainerFlagFromScriptPointer(u8 *data); u8 trainer_flag_check(u16); void trainer_flag_set(u16); void trainer_flag_clear(u16); -void sub_80825E4(void); +void BattleSetup_StartTrainerBattle(void); void sub_808260C(void); void do_choose_name_or_words_screen(void); //void sub_80826B0(void); diff --git a/include/money.h b/include/money.h index 06ac00e92..5a0acd482 100644 --- a/include/money.h +++ b/include/money.h @@ -2,15 +2,15 @@ #define GUARD_MONEY_H bool8 IsEnoughMoney(u32, u32); -void sub_80B79B8(u32 *, u32); -void sub_80B79E0(u32 *, u32); -void sub_80B79F8(u8 *buffer, u32 arg1, u8 arg2); -void sub_80B7A94(u32 arg0, u8 arg1, u8 x, u8 y); +void AddMoney(u32 *, u32); +void RemoveMoney(u32 *, u32); +void GetMoneyAmountText(u8 *buffer, u32 arg1, u8 arg2); +void PrintMoneyAmount(u32 arg0, u8 arg1, u8 x, u8 y); void sub_80B7AEC(u32, u8 left, u8 top); void sub_80B7B34(u8, u8, int); -void sub_80B7BEC(u32, u8, u8); -void sub_80B7C14(u32, u8, u8); -void RemoveMoneyLabelObject(u8, u8); +void UpdateMoneyWindow(u32, u8, u8); +void OpenMoneyWindow(u32, u8, u8); +void CloseMoneyWindow(u8, u8); bool8 sub_80B7CE8(void); void sub_80B7D0C(void); diff --git a/src/battle_4.c b/src/battle_4.c index d8141bad1..ef8307da2 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -144,7 +144,7 @@ void sub_802BBD4(u8 r0, u8 r1, u8 r2, u8 r3, u8 sp0); void nullsub_6(void); void ReshowBattleScreenAfterMenu(void); void sub_800F808(void); -void sub_80B79B8(u32* moneySaveblock, u32 to_give); +void AddMoney(u32* moneySaveblock, u32 to_give); void sub_80156DC(void); //set sentpokes value bool8 sub_8014AB8(u8 bank); //can run from battle u8 CountAliveMons(u8 caseID); @@ -11717,7 +11717,7 @@ static void atk5D_getmoneyreward(void) money_to_give = 1 * gTrainerMoney[i * 4 + 1] * money_to_give; } - sub_80B79B8(&gSaveBlock1.money, money_to_give); + AddMoney(&gSaveBlock1.money, money_to_give); gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 1; gBattleTextBuff1[2] = 4; @@ -11889,7 +11889,7 @@ _0802413C:\n\ _08024140:\n\ mov r0, r8\n\ adds r1, r4, 0\n\ - bl sub_80B79B8\n\ + bl AddMoney\n\ ldr r1, _0802418C @ =gBattleTextBuff1\n\ movs r0, 0xFD\n\ strb r0, [r1]\n\ @@ -14186,7 +14186,7 @@ static void atk91_givepaydaymoney(void) { if (!(gBattleTypeFlags & BATTLE_TYPE_LINK) && gPaydayMoney) { - sub_80B79B8(&gSaveBlock1.money, gPaydayMoney * BATTLE_STRUCT->moneyMultiplier); + AddMoney(&gSaveBlock1.money, gPaydayMoney * BATTLE_STRUCT->moneyMultiplier); gBattleTextBuff1[0] = 0xFD; gBattleTextBuff1[1] = 1; gBattleTextBuff1[2] = 2; diff --git a/src/battle_setup.c b/src/battle_setup.c index 31c127416..453bd1e6f 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1037,7 +1037,7 @@ void trainer_flag_clear(u16 flag) FlagReset(TRAINER_FLAG_START + flag); } -void sub_80825E4(void) +void BattleSetup_StartTrainerBattle(void) { gBattleTypeFlags = BATTLE_TYPE_TRAINER; gMain.savedCallback = sub_808260C; diff --git a/src/item_menu.c b/src/item_menu.c index 4436bdfbe..6c7c643ab 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -3115,7 +3115,7 @@ static void sub_80A6760(u8 taskId) static void BuyMenuPrintItemQuantityAndPrice(u8 taskId) { sub_80A36B8(gBGTilemapBuffers[1], 0, 0, 31, 31); - RemoveMoneyLabelObject(0, 0); + CloseMoneyWindow(0, 0); MenuZeroFillWindowRect(0, 4, 13, 13); MenuZeroFillWindowRect(0, 14, 29, 19); gTasks[taskId].func = sub_80A6760; @@ -3123,20 +3123,20 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId) static void BuyMenuDisplayMessage(u16 itemId, u16 quantity) { - sub_80B7A94(ItemId_GetPrice(itemId) / 2 * quantity, 6, 6, 11); + PrintMoneyAmount(ItemId_GetPrice(itemId) / 2 * quantity, 6, 6, 11); ConvertIntToDecimalStringN(gStringVar1, ItemId_GetPrice(itemId) / 2 * quantity, STR_CONV_MODE_LEFT_ALIGN, 6); } static void sub_80A683C(void) { - sub_80B7C14(gSaveBlock1.money, 0, 0); + OpenMoneyWindow(gSaveBlock1.money, 0, 0); sub_80A4008(gBGTilemapBuffers[1], 1, 1, 12, 2); } static void sub_80A6870(u16 itemId, u8 quantity) { - sub_80B79B8(&gSaveBlock1.money, ItemId_GetPrice(itemId) / 2 * quantity); - sub_80B7BEC(gSaveBlock1.money, 0, 0); + AddMoney(&gSaveBlock1.money, ItemId_GetPrice(itemId) / 2 * quantity); + UpdateMoneyWindow(gSaveBlock1.money, 0, 0); } static void sub_80A68A4(void) diff --git a/src/money.c b/src/money.c index 67b7eb03f..5d0f0ae8d 100644 --- a/src/money.c +++ b/src/money.c @@ -25,7 +25,7 @@ bool8 IsEnoughMoney(u32 budget, u32 cost) return FALSE; } -void sub_80B79B8(u32 *arg0, u32 arg1) +void AddMoney(u32 *arg0, u32 arg1) { if (*arg0 > *arg0 + arg1) { @@ -40,7 +40,7 @@ void sub_80B79B8(u32 *arg0, u32 arg1) } } -void sub_80B79E0(u32 *arg0, u32 arg1) +void RemoveMoney(u32 *arg0, u32 arg1) { if (*arg0 < arg1) { @@ -52,39 +52,25 @@ void sub_80B79E0(u32 *arg0, u32 arg1) } } -void sub_80B79F8(u8 *buffer, u32 arg1, u8 arg2) +void GetMoneyAmountText(u8 *buffer, u32 amount, u8 arg2) { u8 width; u8 i; - if (arg1 > 999999) - { + if (amount > 999999) width = 7; - } - else if (arg1 > 99999) - { + else if (amount > 99999) width = 6; - } - else if (arg1 > 10000) - { + else if (amount > 10000) width = 5; - } - else if (arg1 > 999) - { + else if (amount > 999) width = 4; - } - else if (arg1 > 99) - { + else if (amount > 99) width = 3; - } - else if (arg1 > 9) - { + else if (amount > 9) width = 2; - } else - { width = 1; - } buffer[0] = EXT_CTRL_CODE_BEGIN; buffer[1] = 0x14; @@ -100,7 +86,7 @@ void sub_80B79F8(u8 *buffer, u32 arg1, u8 arg2) buffer[0] = CHAR_CURRENCY; buffer += 1; - buffer = ConvertIntToDecimalString(buffer, arg1); + buffer = ConvertIntToDecimalString(buffer, amount); buffer[0] = EXT_CTRL_CODE_BEGIN; buffer[1] = 0x14; @@ -108,16 +94,18 @@ void sub_80B79F8(u8 *buffer, u32 arg1, u8 arg2) buffer[3] = EOS; } -void sub_80B7A94(u32 arg0, u8 size, u8 x, u8 y) +void PrintMoneyAmount(u32 amount, u8 size, u8 x, u8 y) { u8 buffer[16]; u8 stringWidth; - sub_80B79F8(buffer, arg0, size); + GetMoneyAmountText(buffer, amount, size); stringWidth = sub_8072CA4(buffer); if (stringWidth >= (size + 1) * 8) + { MenuPrint(buffer, x, y); + } else { int xPlusOne = x + 1; @@ -241,15 +229,15 @@ _080B7BE8: .4byte 0x0600f840\n\ .syntax divided\n"); } -void sub_80B7BEC(u32 arg0, u8 x, u8 y) +void UpdateMoneyWindow(u32 amount, u8 x, u8 y) { - sub_80B7A94(arg0, 6, x + 6, y + 1); + PrintMoneyAmount(amount, 6, x + 6, y + 1); } -void sub_80B7C14(u32 arg0, u8 x, u8 y) +void OpenMoneyWindow(u32 amount, u8 x, u8 y) { MenuDrawTextWindow(x, y, x + 13, y + 3); - sub_80B7BEC(arg0, x, y); + UpdateMoneyWindow(amount, x, y); LoadCompressedObjectPic(&gUnknown_083CF584); LoadCompressedObjectPalette(&gUnknown_083CF58C); @@ -257,7 +245,7 @@ void sub_80B7C14(u32 arg0, u8 x, u8 y) gUnknown_02038734 = CreateSprite(&gSpriteTemplate_83CF56C, x * 8 + 19, y * 8 + 11, 0); } -void RemoveMoneyLabelObject(u8 x, u8 y) +void CloseMoneyWindow(u8 x, u8 y) { DestroySpriteAndFreeResources(&gSprites[gUnknown_02038734]); FreeSpritePaletteByTag(SPRITE_TAG_MONEY); @@ -271,5 +259,5 @@ bool8 sub_80B7CE8(void) void sub_80B7D0C(void) { - sub_80B79E0(&gSaveBlock1.money, gSpecialVar_0x8005); + RemoveMoney(&gSaveBlock1.money, gSpecialVar_0x8005); } diff --git a/src/scrcmd.c b/src/scrcmd.c index 28379d2f2..3cf4b9533 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1500,7 +1500,7 @@ bool8 ScrCmd_givemoney(struct ScriptContext *ctx) u32 amount = ScriptReadWord(ctx); u8 ignore = ScriptReadByte(ctx); if (!ignore) - sub_80B79B8(&gSaveBlock1.money, amount); + AddMoney(&gSaveBlock1.money, amount); return FALSE; } @@ -1509,7 +1509,7 @@ bool8 ScrCmd_paymoney(struct ScriptContext *ctx) u32 amount = ScriptReadWord(ctx); u8 ignore = ScriptReadByte(ctx); if (!ignore) - sub_80B79E0(&gSaveBlock1.money, amount); + RemoveMoney(&gSaveBlock1.money, amount); return FALSE; } @@ -1524,19 +1524,19 @@ bool8 ScrCmd_checkmoney(struct ScriptContext *ctx) bool8 ScrCmd_showmoney(struct ScriptContext *ctx) { - u8 v2 = ScriptReadByte(ctx); - u8 v3 = ScriptReadByte(ctx); + u8 x = ScriptReadByte(ctx); + u8 y = ScriptReadByte(ctx); u8 ignore = ScriptReadByte(ctx); if (!ignore) - sub_80B7C14(gSaveBlock1.money, v2, v3); + OpenMoneyWindow(gSaveBlock1.money, x, y); return FALSE; } bool8 ScrCmd_hidemoney(struct ScriptContext *ctx) { - u8 v2 = ScriptReadByte(ctx); - u8 v3 = ScriptReadByte(ctx); - RemoveMoneyLabelObject(v2, v3); + u8 x = ScriptReadByte(ctx); + u8 y = ScriptReadByte(ctx); + CloseMoneyWindow(x, y); return FALSE; } @@ -1546,7 +1546,7 @@ bool8 ScrCmd_updatemoney(struct ScriptContext *ctx) u8 v3 = ScriptReadByte(ctx); u8 ignore = ScriptReadByte(ctx); if (!ignore) - sub_80B7BEC(gSaveBlock1.money, v2, v3); + UpdateMoneyWindow(gSaveBlock1.money, v2, v3); return FALSE; } @@ -1582,7 +1582,7 @@ bool8 ScrCmd_trainerbattle(struct ScriptContext *ctx) bool8 ScrCmd_reptrainerbattle(struct ScriptContext *ctx) { - sub_80825E4(); + BattleSetup_StartTrainerBattle(); return TRUE; } diff --git a/src/shop.c b/src/shop.c index 6a88f1394..9ec79aef6 100644 --- a/src/shop.c +++ b/src/shop.c @@ -294,7 +294,7 @@ void BuyMenuDrawGraphics(void) gMartInfo.cursor = zero; gMartInfo.choicesAbove = zero2; MenuZeroFillWindowRect(0, 0, 0x20, 0x20); - sub_80B7C14(gSaveBlock1.money, 0, 0); + OpenMoneyWindow(gSaveBlock1.money, 0, 0); sub_80B3764(0, 7); sub_80B37EC(); sub_80B3270(); @@ -530,7 +530,7 @@ void sub_80B37F8(u8 taskId) u16 itemId = gMartInfo.itemList[itemListIndex]; u32 price = (ItemId_GetPrice(itemId) >> GetPriceReduction(1)); - sub_80B7A94(gTasks[taskId].data[1] * price, 6, 6, 11); + PrintMoneyAmount(gTasks[taskId].data[1] * price, 6, 6, 11); gStringVar1[0] = EXT_CTRL_CODE_BEGIN; gStringVar1[1] = 0x14; gStringVar1[2] = 0x6; @@ -559,7 +559,7 @@ void sub_80B389C(u16 itemId, u8 var2, bool32 hasControlCode) if (hasControlCode != FALSE) stringPtr = &gStringVar1[3]; - sub_80B79F8(stringPtr, (ItemId_GetPrice(itemId) >> GetPriceReduction(1)), 0x4); + GetMoneyAmountText(stringPtr, (ItemId_GetPrice(itemId) >> GetPriceReduction(1)), 0x4); MenuPrint_PixelCoords(&gStringVar1[0], 0xCA, var2 << 3, 1); } @@ -588,7 +588,7 @@ void sub_80B3930(u16 itemId, u8 var2, bool32 hasControlCode) } else { - sub_80B79F8(stringPtr, gDecorations[itemId].price, 0x4); + GetMoneyAmountText(stringPtr, gDecorations[itemId].price, 0x4); MenuPrint_PixelCoords(&gStringVar1[0], 0xCA, var2 << 3, 0x1); } } @@ -648,9 +648,9 @@ void sub_80B3AEC(u8 taskId) void sub_80B3B80(u8 taskId) { IncrementGameStat(0x26); - sub_80B79E0(&gSaveBlock1.money, gMartTotalCost); + RemoveMoney(&gSaveBlock1.money, gMartTotalCost); PlaySE(SE_REGI); - sub_80B7BEC(gSaveBlock1.money, 0, 0); + UpdateMoneyWindow(gSaveBlock1.money, 0, 0); gTasks[taskId].func = sub_80B3AEC; } @@ -1165,7 +1165,7 @@ void Task_ExitBuyMenu(u8 taskId) { if (!gPaletteFade.active) { - RemoveMoneyLabelObject(0, 0); + CloseMoneyWindow(0, 0); BuyMenuFreeMemory(); SetMainCallback2(c2_exit_to_overworld_2_switch); DestroyTask(taskId); |