diff options
Diffstat (limited to 'src/bag.c')
-rw-r--r-- | src/bag.c | 272 |
1 files changed, 133 insertions, 139 deletions
@@ -10,17 +10,18 @@ #include "menu.h" #include "money.h" #include "bag.h" +#include "strings.h" -extern const u8 gText_DepositItem[]; +static const u16 sBagWindowPalF[] = INCBIN_U16("data/bag/bag_window_pal.gbapal"); -const u16 gUnknown_8453098[] = INCBIN_U16("data/bag/bag_window_pal.gbapal"); -const u8 gUnknown_84530B8[][3] = { +static const u8 sTextColors[][3] = { {0, 1, 2}, {0, 2, 3}, {0, 3, 2}, {0, 8, 9} }; -const struct WindowTemplate gUnknown_84530C4[] = { + +static const struct WindowTemplate sDefaultBagWindowsStd[] = { { .bg = 0, .tilemapLeft = 0x0b, @@ -47,7 +48,8 @@ const struct WindowTemplate gUnknown_84530C4[] = { .baseBlock = 0x01f8 }, DUMMY_WIN_TEMPLATE }; -const struct WindowTemplate gUnknown_84530E4[] = { + +static const struct WindowTemplate sDefaultBagWindowsDeposit[] = { { .bg = 0, .tilemapLeft = 0x0b, @@ -74,7 +76,8 @@ const struct WindowTemplate gUnknown_84530E4[] = { .baseBlock = 0x01f8 }, DUMMY_WIN_TEMPLATE }; -const struct WindowTemplate gUnknown_8453104[] = { + +static const struct WindowTemplate sWindowTemplates[] = { { .bg = 0, .tilemapLeft = 24, @@ -99,122 +102,114 @@ const struct WindowTemplate gUnknown_8453104[] = { .height = 3, .paletteNum = 0xC, .baseBlock = 0x272 - } -}; - -const struct WindowTemplate gUnknown_845311C = { - .bg = 0, - .tilemapLeft = 23, - .tilemapTop = 15, - .width = 6, - .height = 4, - .paletteNum = 0xF, - .baseBlock = 0x28a -}; - -const struct WindowTemplate gUnknown_8453124 = { - .bg = 0, - .tilemapLeft = 21, - .tilemapTop = 9, - .width = 6, - .height = 4, - .paletteNum = 0xF, - .baseBlock = 0x28a -}; - -const struct WindowTemplate gUnknown_845312C[] = { - { - .bg = 0x00, - .tilemapLeft = 0x02, - .tilemapTop = 0x0f, - .width = 0x1a, - .height = 0x04, - .paletteNum = 0x0f, - .baseBlock = 0x02a2 }, { - .bg = 0x00, - .tilemapLeft = 0x06, - .tilemapTop = 0x0f, - .width = 0x0e, - .height = 0x04, - .paletteNum = 0x0c, - .baseBlock = 0x02a2 + .bg = 0, + .tilemapLeft = 23, + .tilemapTop = 15, + .width = 6, + .height = 4, + .paletteNum = 0xF, + .baseBlock = 0x28a }, { - .bg = 0x00, - .tilemapLeft = 0x06, - .tilemapTop = 0x0f, - .width = 0x0f, - .height = 0x04, - .paletteNum = 0x0c, - .baseBlock = 0x02da + .bg = 0, + .tilemapLeft = 21, + .tilemapTop = 9, + .width = 6, + .height = 4, + .paletteNum = 0xF, + .baseBlock = 0x28a }, { - .bg = 0x00, - .tilemapLeft = 0x06, - .tilemapTop = 0x0f, - .width = 0x10, - .height = 0x04, - .paletteNum = 0x0c, - .baseBlock = 0x0316 + .bg = 0, + .tilemapLeft = 2, + .tilemapTop = 15, + .width = 26, + .height = 4, + .paletteNum = 0xF, + .baseBlock = 0x2a2 }, { - .bg = 0x00, - .tilemapLeft = 0x06, - .tilemapTop = 0x0f, - .width = 0x17, - .height = 0x04, - .paletteNum = 0x0c, - .baseBlock = 0x0356 + .bg = 0, + .tilemapLeft = 6, + .tilemapTop = 15, + .width = 14, + .height = 4, + .paletteNum = 0xC, + .baseBlock = 0x2a2 }, { - .bg = 0x00, - .tilemapLeft = 0x16, - .tilemapTop = 0x11, - .width = 0x07, - .height = 0x02, - .paletteNum = 0x0f, - .baseBlock = 0x020a + .bg = 0, + .tilemapLeft = 6, + .tilemapTop = 15, + .width = 15, + .height = 4, + .paletteNum = 0xC, + .baseBlock = 0x2da }, { - .bg = 0x00, - .tilemapLeft = 0x16, - .tilemapTop = 0x0f, - .width = 0x07, - .height = 0x04, - .paletteNum = 0x0f, - .baseBlock = 0x020a + .bg = 0, + .tilemapLeft = 6, + .tilemapTop = 15, + .width = 16, + .height = 4, + .paletteNum = 0xC, + .baseBlock = 0x316 }, { - .bg = 0x00, - .tilemapLeft = 0x16, - .tilemapTop = 0x0d, - .width = 0x07, - .height = 0x06, - .paletteNum = 0x0f, - .baseBlock = 0x020a + .bg = 0, + .tilemapLeft = 6, + .tilemapTop = 15, + .width = 23, + .height = 4, + .paletteNum = 0xC, + .baseBlock = 0x356 }, { - .bg = 0x00, - .tilemapLeft = 0x16, - .tilemapTop = 0x0b, - .width = 0x07, - .height = 0x08, - .paletteNum = 0x0f, - .baseBlock = 0x020a + .bg = 0, + .tilemapLeft = 22, + .tilemapTop = 17, + .width = 7, + .height = 2, + .paletteNum = 0xF, + .baseBlock = 0x20a + }, { + .bg = 0, + .tilemapLeft = 22, + .tilemapTop = 15, + .width = 7, + .height = 4, + .paletteNum = 0xF, + .baseBlock = 0x20a + }, { + .bg = 0, + .tilemapLeft = 22, + .tilemapTop = 13, + .width = 7, + .height = 6, + .paletteNum = 0xF, + .baseBlock = 0x20a + }, { + .bg = 0, + .tilemapLeft = 22, + .tilemapTop = 11, + .width = 7, + .height = 8, + .paletteNum = 0xF, + .baseBlock = 0x20a } }; -const u8 gUnknown_8453174[] = {16, 8, 4}; +static const u8 sUnused_8453174[] = {16, 8, 4}; -EWRAM_DATA u8 gUnknown_203AD34[11] = {}; +static EWRAM_DATA u8 sOpenWindows[11] = {}; -void sub_810B858(void) +void InitBagWindows(void) { u8 i; - if (gUnknown_203ACFC.location != 3) - InitWindows(gUnknown_84530C4); + if (gBagMenuState.location != 3) + InitWindows(sDefaultBagWindowsStd); else - InitWindows(gUnknown_84530E4); + InitWindows(sDefaultBagWindowsDeposit); DeactivateAllTextPrinters(); TextWindow_SetUserSelectedFrame(0, 0x64, 0xE0); TextWindow_LoadResourcesStdFrame0(0, 0x6D, 0xD0); TextWindow_SetStdFrame0_WithPal(0, 0x81, 0xC0); - LoadPalette(gUnknown_8453098, 0xF0, 0x20); + LoadPalette(sBagWindowPalF, 0xF0, 0x20); for (i = 0; i < 3; i++) { FillWindowPixelBuffer(i, 0x00); @@ -223,22 +218,22 @@ void sub_810B858(void) ScheduleBgCopyTilemapToVram(0); for (i = 0; i < 11; i++) { - gUnknown_203AD34[i] = 0xFF; + sOpenWindows[i] = 0xFF; } } -void sub_810B8F0(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, s8 speed, u8 colorIdx) +void BagPrintTextOnWindow(u8 windowId, u8 fontId, const u8 * str, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorIdx) { - AddTextPrinterParameterized4(windowId, fontId, x, y, letterSpacing, lineSpacing, gUnknown_84530B8[colorIdx], speed, str); + AddTextPrinterParameterized4(windowId, fontId, x, y, letterSpacing, lineSpacing, sTextColors[colorIdx], speed, str); } -void sub_810B958(const u8 * str) +void BagPrintTextOnWin1CenteredColor0(const u8 * str, u8 unused) { u32 x = 0x48 - GetStringWidth(1, str, 0); - AddTextPrinterParameterized3(2, 1, x / 2, 1, gUnknown_84530B8[0], 0, str); + AddTextPrinterParameterized3(2, 1, x / 2, 1, sTextColors[0], 0, str); } -void sub_810B994(void) +void BagDrawDepositItemTextBox(void) { u32 x; DrawStdFrameWithCustomTileAndPalette(2, FALSE, 0x081, 0x0C); @@ -246,77 +241,76 @@ void sub_810B994(void) AddTextPrinterParameterized(2, 0, gText_DepositItem, x / 2, 1, 0, NULL); } -u8 sub_810B9DC(u8 a0, u8 a1) +u8 ShowBagWindow(u8 whichWindow, u8 nItems) { - if (gUnknown_203AD34[a0] == 0xFF) + if (sOpenWindows[whichWindow] == 0xFF) { - gUnknown_203AD34[a0] = AddWindow(&gUnknown_8453104[a0 + a1]); - if (a0 != 6) + sOpenWindows[whichWindow] = AddWindow(&sWindowTemplates[whichWindow + nItems]); + if (whichWindow != 6) { - DrawStdFrameWithCustomTileAndPalette(gUnknown_203AD34[a0], FALSE, 0x064, 0x0E); + DrawStdFrameWithCustomTileAndPalette(sOpenWindows[whichWindow], FALSE, 0x064, 0xE); } else { - DrawStdFrameWithCustomTileAndPalette(gUnknown_203AD34[a0], FALSE, 0x081, 0x0C); + DrawStdFrameWithCustomTileAndPalette(sOpenWindows[whichWindow], FALSE, 0x081, 0xC); } ScheduleBgCopyTilemapToVram(0); } - return gUnknown_203AD34[a0]; + return sOpenWindows[whichWindow]; } -void sub_810BA3C(u8 a0) +void HideBagWindow(u8 whichWindow) { - ClearStdWindowAndFrameToTransparent(gUnknown_203AD34[a0], FALSE); - ClearWindowTilemap(gUnknown_203AD34[a0]); - RemoveWindow(gUnknown_203AD34[a0]); + ClearStdWindowAndFrameToTransparent(sOpenWindows[whichWindow], FALSE); + ClearWindowTilemap(sOpenWindows[whichWindow]); + RemoveWindow(sOpenWindows[whichWindow]); ScheduleBgCopyTilemapToVram(0); - gUnknown_203AD34[a0] = 0xFF; + sOpenWindows[whichWindow] = 0xFF; } -u8 sub_810BA70(u8 a0) +u8 OpenBagWindow(u8 whichWindow) { - if (gUnknown_203AD34[a0] == 0xFF) + if (sOpenWindows[whichWindow] == 0xFF) { - gUnknown_203AD34[a0] = AddWindow(&gUnknown_8453104[a0]); + sOpenWindows[whichWindow] = AddWindow(&sWindowTemplates[whichWindow]); } - return gUnknown_203AD34[a0]; + return sOpenWindows[whichWindow]; } -void sub_810BA9C(u8 a0) +void CloseBagWindow(u8 whichWindow) { - if (gUnknown_203AD34[a0] != 0xFF) + if (sOpenWindows[whichWindow] != 0xFF) { - ClearDialogWindowAndFrameToTransparent(gUnknown_203AD34[a0], FALSE); - ClearWindowTilemap(gUnknown_203AD34[a0]); - RemoveWindow(gUnknown_203AD34[a0]); + ClearDialogWindowAndFrameToTransparent(sOpenWindows[whichWindow], FALSE); + ClearWindowTilemap(sOpenWindows[whichWindow]); + RemoveWindow(sOpenWindows[whichWindow]); PutWindowTilemap(1); ScheduleBgCopyTilemapToVram(0); - gUnknown_203AD34[a0] = 0xFF; - + sOpenWindows[whichWindow] = 0xFF; } } -u8 sub_810BAD8(u8 a0) +u8 GetBagWindow(u8 whichWindow) { - return gUnknown_203AD34[a0]; + return sOpenWindows[whichWindow]; } -void sub_810BAE8(u8 taskId, const struct YesNoFuncTable * ptrs) +void BagCreateYesNoMenuBottomRight(u8 taskId, const struct YesNoFuncTable * ptrs) { - CreateYesNoMenuWithCallbacks(taskId, &gUnknown_845311C, 2, 0, 2, 0x64, 0x0E, ptrs); + CreateYesNoMenuWithCallbacks(taskId, &sWindowTemplates[3], 2, 0, 2, 0x064, 0x0E, ptrs); } -void sub_810BB14(u8 taskId, const struct YesNoFuncTable * ptrs) +void BagCreateYesNoMenuTopRight(u8 taskId, const struct YesNoFuncTable * ptrs) { - CreateYesNoMenuWithCallbacks(taskId, &gUnknown_8453124, 2, 0, 2, 0x064, 0x0E, ptrs); + CreateYesNoMenuWithCallbacks(taskId, &sWindowTemplates[4], 2, 0, 2, 0x064, 0x0E, ptrs); } -void sub_810BB40(void) +void BagPrintMoneyAmount(void) { - PrintMoneyAmountInMoneyBoxWithBorder(sub_810B9DC(2, 0), 0x081, 0x0C, GetMoney(&gSaveBlock1Ptr->money)); + PrintMoneyAmountInMoneyBoxWithBorder(ShowBagWindow(2, 0), 0x081, 0x0C, GetMoney(&gSaveBlock1Ptr->money)); } -void sub_810BB74(u8 windowId) +void BagDrawTextBoxOnWindow(u8 windowId) { DrawTextBorderOuter(windowId, 0x064, 0x0E); } |