diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2022-10-08 18:41:48 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-08 18:41:48 -0700 |
| commit | c851c7876c13facaaa4df0d01de3457cd0dc82bb (patch) | |
| tree | 261864c07f334c35024033a908b4af8e808caebe /src/menu | |
| parent | 756a8a89da46dade06fad1723de88fa5a82cc2ec (diff) | |
| parent | 67467fd831d2928715835f8a389b4f464a0f9a7a (diff) | |
Merge pull request #574 from octorock/data
Extract some data
Diffstat (limited to 'src/menu')
| -rw-r--r-- | src/menu/figurineMenu.c (renamed from src/menu/figurine_menu.c) | 66 | ||||
| -rw-r--r-- | src/menu/kinstoneMenu.c (renamed from src/menu/kinstone_menu.c) | 32 | ||||
| -rw-r--r-- | src/menu/pauseMenu.c | 1522 | ||||
| -rw-r--r-- | src/menu/pauseMenuScreen6.c | 276 | ||||
| -rw-r--r-- | src/menu/pause_menu.c | 567 |
5 files changed, 1850 insertions, 613 deletions
diff --git a/src/menu/figurine_menu.c b/src/menu/figurineMenu.c index 4a558423..2a19f06d 100644 --- a/src/menu/figurine_menu.c +++ b/src/menu/figurineMenu.c @@ -1,23 +1,27 @@ -#include "global.h" -#include "main.h" -#include "menu.h" -#include "sound.h" +/** + * @file figurineMenu.c + * @ingroup Subtasks + * + * @brief Figurine Menu Subtask + */ +#include "figurineMenu.h" + #include "common.h" -#include "screen.h" -#include "save.h" #include "flags.h" -#include "subtask.h" -#include "object.h" -#include "game.h" #include "functions.h" +#include "game.h" +#include "main.h" +#include "menu.h" #include "message.h" +#include "object.h" +#include "pauseMenu.h" +#include "save.h" +#include "screen.h" +#include "sound.h" +#include "subtask.h" +#include "subtask2.h" #include "ui.h" -extern const struct { - u8 filler[7]; - u8 unk7; -} gUnk_080FC3E4[]; - void sub_080A4DA8(u32); void sub_080A4B44(void); void FigurineMenu_080A4978(void); @@ -47,13 +51,7 @@ const KeyButtonLayout gUnk_0812813C = { }; extern u8 gUnk_020344A0[8]; -typedef struct { - u8 unk0; - u8 unk1; - u16 unk2; - u16 unk4; - u16 unk6; -} struct_08128AD8; + extern const struct_08128AD8 gUnk_08128AD8[]; Subtask FigurineMenu0_Type0; @@ -64,6 +62,7 @@ Subtask FigurineMenu1_Type0; Subtask FigurineMenu1_Type1; Subtask FigurineMenu1_Type2; Subtask FigurineMenu1_Type3; + void Subtask_FigurineMenu(void) { static Subtask* const figurineMenu1_Types[] = { FigurineMenu0_Type0, @@ -135,7 +134,7 @@ void FigurineMenu0_Type0(void) { void FigurineMenu0_Type1(void) { if (gFadeControl.active == 0) { - CreateObject(OBJECT_A2, gUnk_080FC3E4[gFigurineMenu.figure_idx].unk7, 0); + CreateObject(OBJECT_A2, gUnk_080FC3E4[gFigurineMenu.figure_idx].type, 0); SetMenuType(2); } } @@ -444,7 +443,7 @@ const struct_08128184 gUnk_08128184 = { }; extern struct_020227E8 gUnk_020227E8[]; -extern void sub_0805F46C(u32, const struct_0812816C*); +extern void ShowTextBox(u32, const struct_0812816C*); void sub_080A4BA0(u32 arg1, u32 arg2) { int r0, r5, r6; @@ -497,9 +496,9 @@ void sub_080A4BA0(u32 arg1, u32 arg2) { s2.unk9 = r5; s0.unk0 += 0xb; if (gSaveHeader->language == 0) { - sub_0805F46C((u32)&s2, &s0); + ShowTextBox((u32)&s2, &s0); } else { - sub_0805F46C(r5, &s0); + ShowTextBox(r5, &s0); } } gScreen.bg3.updated = 1; @@ -538,7 +537,7 @@ u32 sub_080A4CBC(u32 param_1) { MemCopy(&gBG1Buffer, (void*)0x600e000, sizeof(gBG1Buffer)); iVar1 = sub_080A4948(param_1); if (iVar1 != 0) { - sub_0805F46C(param_1 + 0x900, &gUnk_08128190); + ShowTextBox(param_1 + 0x900, &gUnk_08128190); } gScreen.bg1.updated = 1; } @@ -585,6 +584,7 @@ void sub_080A4DA8(u32 param_1) { sub_080A4DB8(param_1); } +// Render screen? void sub_080A4DB8(u32 param_1) { const struct_08128AD8* ptr; @@ -603,25 +603,25 @@ void sub_080A4DB8(u32 param_1) { gScreen.bg0.updated = 1; gScreen.bg1.xOffset = 0; gScreen.bg1.yOffset = 0; - gScreen.bg1.control = ptr->unk4; + gScreen.bg1.control = ptr->bg1Control; gScreen.bg1.updated = 1; gScreen.bg2.xOffset = 0; gScreen.bg2.yOffset = 0; - gScreen.bg2.control = ptr->unk6; + gScreen.bg2.control = ptr->bg2Control; gScreen.bg2.updated = 1; gScreen.bg3.xOffset = 0; gScreen.bg3.yOffset = 0; gScreen.bg3.control = 0x1e0b; - if (ptr->unk0 != 0) { - LoadPaletteGroup(ptr->unk0); + if (ptr->paletteGroup != 0) { + LoadPaletteGroup(ptr->paletteGroup); } - if (ptr->unk1 != 0) { - LoadGfxGroup(ptr->unk1); + if (ptr->gfxGroup != 0) { + LoadGfxGroup(ptr->gfxGroup); } } void sub_080A4E84(u8 param_1) { - gPauseMenuOptions.unk14 = param_1; + gPauseMenuOptions.screen2 = param_1; } void sub_080A4E90(u8 param_1) { diff --git a/src/menu/kinstone_menu.c b/src/menu/kinstoneMenu.c index 247902e4..e9aaad8e 100644 --- a/src/menu/kinstone_menu.c +++ b/src/menu/kinstoneMenu.c @@ -1,3 +1,9 @@ +/** + * @file kinstoneMenu.c + * @ingroup Subtasks + * + * @brief Kinstone Menu Subtask + */ #include "area.h" #include "common.h" #include "enemy.h" @@ -221,12 +227,12 @@ void KinstoneMenu_Type1(void) { } void KinstoneMenu_Type2(void) { - const struct_080C9CBC* ptr; + const KinstoneWorldEvent* ptr; if (gMenu.column_idx == 6) { gFuseInfo._0 = 6; - ptr = &gUnk_080C9CBC[gFuseInfo._3]; - if (ptr->unk3 != 0) { - MenuFadeIn(ptr->unk3, ptr->evt_type); + ptr = &gKinstoneWorldEvents[gFuseInfo.kinstoneId]; + if (ptr->subtask != 0) { + MenuFadeIn(ptr->subtask, ptr->worldEventId); } else { Subtask_Exit(); } @@ -259,8 +265,8 @@ void KinstoneMenu_Type3_Overlay0(void) { } void KinstoneMenu_Type3_Overlay1(void) { - u32 temp = gUnk_080C9CBC[gKinstoneMenu.unk2a].unk5; - if (temp != gUnk_080C9CBC[gFuseInfo._3].unk5) { + u32 temp = gKinstoneWorldEvents[gKinstoneMenu.unk2a].unk5; + if (temp != gKinstoneWorldEvents[gFuseInfo.kinstoneId].unk5) { SoundReq(SFX_ITEM_SHIELD_BOUNCE); SetMenuType(4); } else { @@ -313,8 +319,8 @@ void KinstoneMenu_Type5(void) { void KinstoneMenu_Type5_Overlay0(void) { gMenu.column_idx = 5; - WriteBit(gSave.unk241, gFuseInfo._3); - if (++gSave.unk117 > 99) { + WriteBit(gSave.fusedKinstones, gFuseInfo.kinstoneId); + if (++gSave.fusedKinstoneCount > 99) { gSave.didAllFusions = 1; } KinstoneMenu_080A4468(); @@ -499,16 +505,16 @@ void KinstoneMenu_080A422C(void) { } gOamCmd.x = t2; - sub_080A42E0(gFuseInfo._3, 0); + sub_080A42E0(gFuseInfo.kinstoneId, 0); } -void sub_080A42E0(u32 param_1, u32 param_2) { +void sub_080A42E0(u32 kinstoneId, u32 param_2) { u8 uVar1; s32 sVar2; s32 sVar3; s32 iVar4; - const struct_080C9CBC* ptr = &gUnk_080C9CBC[param_1]; + const KinstoneWorldEvent* ptr = &gKinstoneWorldEvents[kinstoneId]; if (param_2 == 0xff) { uVar1 = ptr->unk2; @@ -538,7 +544,7 @@ void sub_080A42E0(u32 param_1, u32 param_2) { } { int t; - t = ptr->unk0; + t = ptr->objPalette; t <<= 0xc; t |= 0x800; t |= (iVar4 << 4) + 0x300; @@ -602,7 +608,7 @@ u32 sub_080A4418(u32 param_1, u32 param_2) { void KinstoneMenu_080A4468(void) { gUnk_03003DF0.unk_2 = 0; gUnk_03003DF0.unk_4[3] = 0; - sub_0801E6C8(gFuseInfo._3); + sub_0801E6C8(gFuseInfo.kinstoneId); sub_0801E798(gKinstoneMenu.unk2a); } diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c new file mode 100644 index 00000000..63f22f28 --- /dev/null +++ b/src/menu/pauseMenu.c @@ -0,0 +1,1522 @@ +/** + * @file pauseMenu.c + * @ingroup Subtasks + * + * @brief Pause Menu Subtask + */ +#include "pauseMenu.h" + +#include "common.h" +#include "functions.h" +#include "game.h" +#include "item.h" +#include "itemMetaData.h" +#include "main.h" +#include "menu.h" +#include "message.h" +#include "save.h" +#include "screen.h" +#include "sound.h" +#include "structures.h" +#include "subtask.h" +#include "ui.h" + +extern void sub_080A4DB8(u32); + +void sub_080A5128(void); +void sub_080A51D4(void); +bool32 sub_080A51F4(void); +void sub_080A5F48(u32, u32); + +void Subtask_PauseMenu(void) { + static Subtask* const pauseMenu_Variants[] = { + PauseMenu_Variant0, PauseMenu_Variant1, PauseMenu_Variant2, + PauseMenu_Variant3, PauseMenu_Variant4, PauseMenu_Variant5, + }; + + if (gPauseMenuOptions.unk11 == 6) { + SetBgmVolume(0x100); + Subtask_Exit(); + } else { + FlushSprites(); + pauseMenu_Variants[gPauseMenuOptions.unk11](); + sub_080A5128(); + UpdateUIElements(); + DrawUIElements(); + if (gPauseMenuOptions.unk11 != 4) { + gUnk_08128A38[gPauseMenuOptions.screen].func(); + } + CopyOAM(); + { + u32 t = gPauseMenuOptions.unk16; + u32 t2 = (t != 0) ? 0xe46 : 0; + gScreen.controls.layerFXControl = t2; + gScreen.controls.alphaBlend = (t << 8) | (0x10 - t); + } + } +} + +struct_08127F94* sub_080A6A80(u32, u32); + +extern u8 gUnk_02034492[]; +void sub_0801E8D4(void); +s32 sub_080A50A0(s32); + +void PauseMenu_Variant0(void) { + struct_08127F94* ptr; + int r0, r1; + + sub_0801E8D4(); + sub_080A4D34(); + r1 = 4; + do { + gUnk_02034492[r1] = 0; + r1++; + } while (r1 <= 0xd); + ptr = sub_080A6A80((u16)gRoomTransition.player_status.overworld_map_x, + (u16)gRoomTransition.player_status.overworld_map_y); + gPauseMenuOptions.unk2[4] = ptr->_4; + gPauseMenuOptions.unk2[5] = sub_0801DB94(); + if (IsItemEquipped(ITEM_LANTERN_ON) != EQUIP_SLOT_NONE) { + r1 = 0x10; + } else { + r1 = 0xf; + } + gPauseMenuOptions.unk15 = r1; + r0 = gUnk_08128A38[gPauseMenuOptions.screen].unk1; + r0 = sub_080A50A0(r0); + gPauseMenuOptions.screen = r0; + gPauseMenuOptions.screen2 = r0; + sub_080A4DB8(r0); + SetFade(FADE_INSTANT, 0x20); + sub_080A4E90(1); +} + +void PauseMenu_Variant1(void) { + if (gFadeControl.active == 0) { + sub_080A4E90(2); + } +} + +void PauseMenu_Variant2(void) { + int iVar1; + u32 uVar2; + int iVar4; + s32 bVar5; + + if (sub_080A51F4() && (gMenu.field_0xc != NULL)) { + iVar1 = -1; + switch (gInput.newKeys) { + case START_BUTTON: + iVar1 = 0; + break; + case L_BUTTON: + iVar1 = 1; + break; + case R_BUTTON: + iVar1 = 2; + break; + case B_BUTTON: + iVar1 = 3; + break; + } + if (iVar1 >= 0) { + switch (bVar5 = gMenu.field_0xc[iVar1]) { + case 0: + break; + case 4 ... 6: + case 0xf: + uVar2 = GetInventoryValue(ITEM_MAP); + if (uVar2 == 0) { + iVar4 = 1; + if (iVar1 == 1) { + iVar4 = 2; + } + bVar5 = gMenu.field_0xc[iVar4]; + } + default: + gPauseMenuOptions.screen2 = bVar5; + SoundReq(SFX_TEXTBOX_OPEN); + gMenu.field_0xc = NULL; + break; + } + } + } + bVar5 = sub_080A50A0(gPauseMenuOptions.screen2); + if (gPauseMenuOptions.screen != bVar5) { + gPauseMenuOptions.screen2 = bVar5; + sub_080A51D4(); + if (bVar5 == 0xe) { + sub_080A4E90(6); + } else { + sub_080A4E90(3); + MemClear(&gBG0Buffer, sizeof(gBG0Buffer)); + gScreen.bg0.updated = 1; + } + } +} + +s32 sub_080A50A0(s32 param_1) { + s32 iVar1; + + if (param_1 == 0xf) { + iVar1 = AreaHasMap(); + param_1 = 4; + if (iVar1 != 0) { + param_1 = 5; + } + } + return param_1; +} + +void PauseMenu_Variant3(void) { + s32 iVar1; + + iVar1 = gPauseMenuOptions.unk16 + 2; + if (0x10 < iVar1) { + gScreen.lcd.displayControl &= 0xf8ff; + sub_080A4E90(4); + iVar1 = 0x10; + } + gPauseMenuOptions.unk16 = iVar1; +} + +void PauseMenu_Variant4(void) { + u32 t; + gPauseMenuOptions.unk16 = 0x10; + gPauseMenuOptions.screen = t = gPauseMenuOptions.screen2; + sub_080A4DB8(t); + sub_080A4E90(5); +} + +void PauseMenu_Variant5(void) { + s32 iVar1; + + iVar1 = gPauseMenuOptions.unk16 - 2; + if (iVar1 < 0) { + sub_080A4E90(2); + iVar1 = 0; + } + gPauseMenuOptions.unk16 = iVar1; +} + +void sub_080A5128(void) { + int r5, t; + struct { + int x; + int y; + } p[3]; + + switch (gPauseMenuOptions.screen) { + case PauseMenuScreen_7: + case PauseMenuScreen_8: + p[0].x = 0x60; + p[0].y = 0x18; + p[1].x = -0x10; + p[1].y = 0x48; + p[2].x = 0x100; + p[2].y = 0x48; + break; + case PauseMenuScreen_9: + case PauseMenuScreen_10: + case PauseMenuScreen_11: + return; + default: + p[0].x = 0x40; + p[0].y = 0x10 - (gPauseMenuOptions.unk16 << 1); + t = (gPauseMenuOptions.unk16 / 3); + p[1].x = 0x10 - t; + p[1].y = 0x48; + p[2].x = 0xe0 + t; + p[2].y = 0x48; + break; + } + gOamCmd._4 = 0; + gOamCmd._6 = 0; + gOamCmd._8 = 0x400; + gOamCmd.x = p[0].x; + gOamCmd.y = p[0].y; +#ifdef EU + r5 = 0x1fa; +#else + r5 = 0x1fb; +#endif + DrawDirect(r5, 0); + gOamCmd.x = p[1].x; + gOamCmd.y = p[1].y; + DrawDirect(r5, 1); + gOamCmd.x = p[2].x; + gOamCmd.y = p[2].y; + DrawDirect(r5, 2); +} + +void sub_080A51D4(void) { + u32 i = gPauseMenuOptions.screen; + if (i < 0xe) { + gPauseMenuOptions.unk2[i] = gMenu.field_0x3; // TODO cursor? + } +} + +bool32 sub_080A51F4(void) { + bool32 retval = TRUE; + if (gFadeControl.active != 0) + retval = FALSE; + if (gPauseMenuOptions.unk11 != 2) + retval = FALSE; + return retval; +} + +typedef struct { + u8 up; + u8 down; + u8 left; + u8 right; + u8 type; + u8 unk0; + u8 x; + u8 y; +} ItemMenuTableEntry; + +void PauseMenu_ItemMenu(void) { + static Subtask* const pauseMenu_Types[] = { PauseMenu_ItemMenu_Init, PauseMenu_ItemMenu_Update }; + + pauseMenu_Types[gMenu.menuType](); + PauseMenu_ItemMenu_Draw(); +} + +void PauseMenu_ItemMenu_Init(void) { + static const KeyButtonLayout gUnk_08128B50 = { + 0xd0u, + 0x10u, + 0u, + 0xb8u, + 0x10u, + 0u, + 0xffu, + 0xd8u, + 0u, + { + 0x3u, + 0u, + 0x4u, + 0u, + 0u, + 0u, + 0x1u, + 0u, + 0xffu, + 0u, + 0u, + }, + }; + + u32 uVar1; + u32 i; + u32 item; + + gMenu.field_0xc = NULL; + sub_080A70AC((KeyButtonLayout*)&gUnk_08128B50); + for (item = ITEM_SMITH_SWORD; item < ITEM_BOTTLE_EMPTY; item++) { + uVar1 = GetInventoryValue(item); + if ((uVar1 == 1) && (i = gItemMetaData[item].menuSlot, i <= MENU_SLOT_SAVE_BUTTON_JP)) { + switch (item) { + case ITEM_LANTERN_OFF: + case ITEM_LANTERN_ON: + item = gPauseMenuOptions.unk15; + break; + default: + break; + } + gPauseMenu.items[i] = item; + sub_080A5F48(item, i * 8 + 0x360); + } + } + SetMenuType(1); +} + +const ItemMenuTableEntry gItemMenuTable[] = { + [MENU_SLOT_SWORD] = { MENU_SLOT_BOTTLE0, MENU_SLOT_SHIELD, MENU_SLOT_BOOMERANG, MENU_SLOT_GUST_JAR, 0x01, 0x0c, + 0x42, 0x33 }, + [MENU_SLOT_GUST_JAR] = { MENU_SLOT_BOTTLE1, MENU_SLOT_MOLE_MITTS, MENU_SLOT_SWORD, MENU_SLOT_CANE, 0x01, 0x10, 0x66, + 0x33 }, + [MENU_SLOT_CANE] = { MENU_SLOT_BOTTLE3, MENU_SLOT_LANTERN, MENU_SLOT_GUST_JAR, MENU_SLOT_BOOMERANG, 0x01, 0x14, + 0x8a, 0x33 }, + [MENU_SLOT_BOOMERANG] = { MENU_SLOT_SAVE_BUTTON, MENU_SLOT_BOMBS, MENU_SLOT_CANE, MENU_SLOT_SWORD, 0x01, 0x15, 0xae, + 0x33 }, + [MENU_SLOT_SHIELD] = { MENU_SLOT_SWORD, MENU_SLOT_PEGASUS_BOOTS, MENU_SLOT_BOMBS, MENU_SLOT_MOLE_MITTS, 0x01, 0x16, + 0x42, 0x4b }, + [MENU_SLOT_MOLE_MITTS] = { MENU_SLOT_GUST_JAR, MENU_SLOT_ROCS_CAPE, MENU_SLOT_SHIELD, MENU_SLOT_LANTERN, 0x01, 0x17, + 0x66, 0x4b }, + [MENU_SLOT_LANTERN] = { MENU_SLOT_CANE, MENU_SLOT_OCARINA, MENU_SLOT_MOLE_MITTS, MENU_SLOT_BOMBS, 0x01, 0x00, 0x8a, + 0x4b }, + [MENU_SLOT_BOMBS] = { MENU_SLOT_BOOMERANG, MENU_SLOT_BOW, MENU_SLOT_LANTERN, MENU_SLOT_SHIELD, 0x01, 0x00, 0xae, + 0x4b }, + [MENU_SLOT_PEGASUS_BOOTS] = { MENU_SLOT_SHIELD, MENU_SLOT_BOTTLE0, MENU_SLOT_BOW, MENU_SLOT_ROCS_CAPE, 0x01, 0x00, + 0x42, 0x63 }, + [MENU_SLOT_ROCS_CAPE] = { MENU_SLOT_MOLE_MITTS, MENU_SLOT_BOTTLE1, MENU_SLOT_PEGASUS_BOOTS, MENU_SLOT_OCARINA, 0x01, + 0x00, 0x66, 0x63 }, + [MENU_SLOT_OCARINA] = { MENU_SLOT_LANTERN, MENU_SLOT_BOTTLE3, MENU_SLOT_ROCS_CAPE, MENU_SLOT_BOW, 0x01, 0x00, 0x8a, + 0x63 }, + [MENU_SLOT_BOW] = { MENU_SLOT_BOMBS, MENU_SLOT_SAVE_BUTTON, MENU_SLOT_OCARINA, MENU_SLOT_PEGASUS_BOOTS, 0x01, 0x00, + 0xae, 0x63 }, + [MENU_SLOT_BOTTLE0] = { MENU_SLOT_PEGASUS_BOOTS, MENU_SLOT_SWORD, MENU_SLOT_SAVE_BUTTON, MENU_SLOT_BOTTLE1, 0x01, + 0x00, 0x42, 0x7b }, + [MENU_SLOT_BOTTLE1] = { MENU_SLOT_ROCS_CAPE, MENU_SLOT_GUST_JAR, MENU_SLOT_BOTTLE0, MENU_SLOT_BOTTLE2, 0x01, 0x00, + 0x5a, 0x7b }, + [MENU_SLOT_BOTTLE2] = { MENU_SLOT_ROCS_CAPE, MENU_SLOT_GUST_JAR, MENU_SLOT_BOTTLE1, MENU_SLOT_BOTTLE3, 0x01, 0x00, + 0x72, 0x7b }, + [MENU_SLOT_BOTTLE3] = { MENU_SLOT_OCARINA, MENU_SLOT_CANE, MENU_SLOT_BOTTLE2, MENU_SLOT_SAVE_BUTTON, 0x01, 0x00, + 0x8a, 0x7b }, + [MENU_SLOT_SAVE_BUTTON] = { MENU_SLOT_BOW, MENU_SLOT_BOOMERANG, MENU_SLOT_BOTTLE3, MENU_SLOT_BOTTLE0, 0x03, 0x00, + 0xb5, 0x75 }, + [MENU_SLOT_SAVE_BUTTON_JP] = { MENU_SLOT_BOW, MENU_SLOT_BOOMERANG, MENU_SLOT_BOTTLE3, MENU_SLOT_BOTTLE0, 0x05, 0x00, + 0xb5, 0x75 }, +}; + +void PauseMenu_ItemMenu_Update(void) { + static const u8 gUnk_08128BF4[] = { 14, 15, 2, 0 }; + u32 item; + u32 menuSlot; + const ItemMenuTableEntry* entry; + + if (sub_080A51F4()) { + gMenu.field_0xc = (u8*)gUnk_08128BF4; + menuSlot = gMenu.field_0x3; + + entry = &gItemMenuTable[menuSlot]; + switch (gInput.newKeys) { + case A_BUTTON: + if (menuSlot == MENU_SLOT_SAVE_BUTTON) { +#if defined(DEMO_USA) || defined(DEMO_JP) + SoundReq(SFX_MENU_ERROR); +#else + sub_080A4E84(0xb); + SoundReq(SFX_TEXTBOX_SELECT); +#endif + break; + } + case B_BUTTON: + if (gPauseMenu.items[menuSlot] != 0) { + u32 slot = !!(gInput.newKeys ^ 1); + ForceEquipItem(gPauseMenu.items[menuSlot], slot); + SoundReq(SFX_TEXTBOX_SELECT); + } + break; + default: + switch (gInput.unk4) { + case DPAD_UP: + menuSlot = entry->up; + break; + case DPAD_DOWN: + menuSlot = entry->down; + break; + case DPAD_LEFT: + menuSlot = entry->left; + break; + case DPAD_RIGHT: + menuSlot = entry->right; + break; + } + break; + } + if (gMenu.field_0x3 != menuSlot) { + gMenu.field_0x3 = menuSlot; + SoundReq(SFX_TEXTBOX_CHOICE); + } + item = gPauseMenu.items[menuSlot]; + switch (menuSlot) { + case MENU_SLOT_BOTTLE0: + case MENU_SLOT_BOTTLE1: + case MENU_SLOT_BOTTLE2: + case MENU_SLOT_BOTTLE3: + if (item != 0) { + item = gSave.saved_status.field_0x24[item - 6]; + } + break; + case MENU_SLOT_SAVE_BUTTON: + // ITEM_SKILL_FAST_SPIN, but that does not make any sense at all + // it is just a text index for the text in the message box for the save button + item = 0x73; + break; + default: + break; + } + sub_080A6F6C(TEXT_INDEX(TEXT_ITEMS, 0) + item); + } +} + +u32 GetMenuSlotForItem(u32 item); + +extern Frame* gSpriteAnimations_322[]; + +#ifdef EU +#define sub_080A5384_draw_constant0 0x1fa +#define sub_080A5384_draw_constant1 0x141 +#else +#define sub_080A5384_draw_constant0 0x1fb +#define sub_080A5384_draw_constant1 0x142 +#endif +void PauseMenu_ItemMenu_Draw(void) { + u32 tmp; + u32 i; + s32 color; + const ItemMenuTableEntry* entry; + + gOamCmd._4 = 0x400; + gOamCmd._6 = 0; + gOamCmd._8 = 0; + for (i = 0; i < MENU_SLOT_COUNT; i++) { + u32 item; + if (gPauseMenu.items[i] != 0) { + entry = &gItemMenuTable[i]; + gOamCmd.x = entry->x; + gOamCmd.y = entry->y; + item = gPauseMenu.items[i]; + switch (item) { + case ITEM_BOTTLE1: + case ITEM_BOTTLE2: + case ITEM_BOTTLE3: + case ITEM_BOTTLE4: + item = gSave.stats.bottles[item - ITEM_BOTTLE1]; + break; + default: + break; + } + color = 3; + switch (item) { + case ITEM_BOMBS: + case ITEM_REMOTE_BOMBS: + if (gBombBagSizes[gSave.stats.bombBagType] <= gSave.stats.bombCount) { + color = 4; + } + break; + case ITEM_BOW: + case ITEM_LIGHT_ARROW: + if (gQuiverSizes[gSave.stats.quiverType] <= gSave.stats.arrowCount) { + color = 4; + } + break; + default: + break; + } + gOamCmd._8 = 0x800 | color << 0xc | ((i * 8) + 0x360); + DrawDirect(sub_080A5384_draw_constant1, gSpriteAnimations_322[item]->index); + } + } + gOamCmd._8 = 0x800; + { + u32 slot = gMenu.field_0x3; + if ((slot == MENU_SLOT_SAVE_BUTTON) && (gSaveHeader->language != 0)) { + slot = MENU_SLOT_SAVE_BUTTON_JP; + } + entry = &gItemMenuTable[slot]; + gOamCmd.x = entry->x; + gOamCmd.y = entry->y; + tmp = entry->type + ((gMain.ticks & 0x10) != 0 ? 3 : 4); + DrawDirect(sub_080A5384_draw_constant0, tmp); + } + { + u32 slot; + if (gSaveHeader->language != 0) { + slot = MENU_SLOT_SAVE_BUTTON; + } else { + slot = MENU_SLOT_SAVE_BUTTON_JP; + } + entry = &gItemMenuTable[slot]; + gOamCmd.x = entry->x; + gOamCmd.y = entry->y; + gOamCmd._8 = 0x800; + DrawDirect(sub_080A5384_draw_constant0, 0x22); + } + i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_A]); + if (i < MENU_SLOT_COUNT) { + entry = &gItemMenuTable[i]; + gOamCmd.x = entry->x; + gOamCmd.y = entry->y; + DrawDirect(sub_080A5384_draw_constant0, 3); + } + i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_B]); + if (i < MENU_SLOT_COUNT) { + entry = &gItemMenuTable[i]; + gOamCmd.x = entry->x; + gOamCmd.y = entry->y; + DrawDirect(sub_080A5384_draw_constant0, 3); + } +} + +u32 GetMenuSlotForItem(u32 item) { + u32 i; + + if (item != 0) { + for (i = 0; i < MENU_SLOT_COUNT; i++) { + if (item == gPauseMenu.items[i]) + return i; + } + } + return MENU_SLOT_SAVE_BUTTON_JP; +} + +Subtask sub_080A5594; +Subtask sub_080A56A0; +void PauseMenu2(void) { + static Subtask* const pauseMenu2_Types[] = { + sub_080A5594, + sub_080A56A0, + }; + pauseMenu2_Types[gMenu.menuType](); + sub_080A57F4(); +} + +//// TODO Moved here from subtask2.c +// Probably could split the different screens of the pause menu. +#include "fileselect.h" +#include "flags.h" + +extern u8 gUnk_08128C00[]; +extern u16 gUnk_02017830[]; +extern u8 gUnk_08128D38[]; +extern u8 gUnk_08128D43[]; +extern u16* gMoreSpritePtrs[]; +extern u32 gUnk_085C4620[]; +extern void (*const gUnk_08128D58[])(void); +extern KeyButtonLayout gUnk_08128D60; + +void sub_080A5D1C(); +void sub_080A5CFC(u32, void*, u32); +void sub_080A6FB4(u32, u32); +void DrawDungeonFeatures(u32, void*, u32); +extern void DrawDungeonMap(u32 floor, struct_02019EE0* data, u32 size); +extern void LoadDungeonMap(void); +bool32 sub_080A5F24(void); +extern void sub_080A42E0(u32, u32); +extern void (*const gUnk_08128DB0[])(void); +void sub_080A617C(void); +void sub_080A7040(u32); + +extern u8 gUnk_08128DB8[]; +extern KeyButtonLayout gUnk_08128DBC; + +extern void (*const gUnk_08128DCC[])(void); +void sub_080A6378(void); +void sub_080A6438(); + +typedef struct { + u8 unk0; + u8 unk1; + u8 unk2; + u8 unk3; + u8 unk4; + u8 unk5; + u8 unk6; + u8 unk7; +} struct_gUnk_08128C14; +extern struct_gUnk_08128C14 gUnk_08128C14[]; +extern struct_gUnk_08128C14 gUnk_08128C94[]; + +typedef struct { + u8 unk00 : 5; + u8 unk05 : 5; + u8 unk10 : 6; +} PACKED gUnk_08128DE8_struct_2; + +typedef struct { + gUnk_08128DE8_struct_2 unk0; + gUnk_08128DE8_struct_2 unk2; + u8 unk4; + u8 unk5; + u8 unk6; + u8 unk7; +} gUnk_08128DE8_struct; +extern gUnk_08128DE8_struct gUnk_08128DE8[]; + +void sub_080A5594(void) { + extern KeyButtonLayout gUnk_08128C04; + int iVar1; + u32 uVar2; + u32 skillCount; + u32 item; + int iVar5; + u32 i; + u32 uVar7; + + gMenu.field_0xc = gUnk_08128C00; + sub_080A70AC(&gUnk_08128C04); + uVar7 = 6; + + for (item = ITEM_QST_SWORD; item <= ITEM_FLIPPERS; item++) { + if (GetInventoryValue(item) == 1) { + uVar2 = gItemMetaData[item].menuSlot; + if (uVar2 == 3 && gGenericMenu.unk10.a[3] != 0) { + uVar2 = 99; + } + if (uVar2 != 99) { + if (uVar2 == 1) { + uVar2 = uVar7; + if (uVar2 < 8) { + uVar7 = uVar2 + 1; + } + } + gGenericMenu.unk10.a[uVar2] = item; + sub_080A5F48(item, uVar2 * 8 + 0x380); + } + } + } + if (GetInventoryValue(ITEM_QST_TINGLE_TROPHY) == 0) { + iVar5 = 0; + if (GetInventoryValue(ITEM_KINSTONE_BAG) != 0) { + for (i = 0; i < 0x13; i++) { + iVar5 += gSave.unk12B[i]; + } + + if (iVar5 >= 0x50) { + iVar5 = 4; + } else if (iVar5 >= 0x28) { + iVar5 = 3; + } else if (iVar5 >= 10) { + iVar5 = 2; + } else { + iVar5 = 1; + } + } + gGenericMenu.unk10.a[0] = iVar5; + } + gGenericMenu.unk10.a[1] = gSave.stats.heartPieces + 1; + skillCount = 0; + + for (i = ITEM_SKILL_SPIN_ATTACK; i <= ITEM_SKILL_PERIL_BEAM; i++) { + if (GetInventoryValue(i) != 0) { + skillCount++; + } + } + gGenericMenu.unk10.a[2] = skillCount; + if (GetInventoryValue(ITEM_QST_CARLOV_MEDAL) == 0 && GetInventoryValue(ITEM_SHELLS) != 0) { + gGenericMenu.unk10.a[3] = ITEM_SHELLS; + } + gGenericMenu.unk14 = 1; + gGenericMenu.unk15 = 1; + SetMenuType(1); +} + +void sub_080A56A0(void) { + int iVar1; + u32 uVar2; + u32 item; + struct_gUnk_08128C14* ptr; + + if (!sub_080A51F4()) { + return; + } + gMenu.field_0xc = gUnk_08128C00; + ptr = &gUnk_08128C14[gMenu.field_0x3]; + uVar2 = 0xff; + switch (gInput.unk4) { + case DPAD_UP: + uVar2 = ptr->unk0; + break; + case DPAD_DOWN: + uVar2 = ptr->unk1; + break; + case DPAD_LEFT: + uVar2 = ptr->unk2; + break; + case DPAD_RIGHT: + uVar2 = ptr->unk3; + break; + } + + if (uVar2 != 0xff) { + gMenu.field_0x3 = uVar2; + SoundReq(SFX_TEXTBOX_CHOICE); + } else if (gInput.newKeys == A_BUTTON) { + uVar2 = gMenu.field_0x3; + iVar1 = 0; + switch (uVar2) { + case 0: + case 2: + if (gGenericMenu.unk10.a[uVar2] != 0) { + iVar1 = 8; + if (uVar2 == 0) { + iVar1 = 7; + } + } + break; +#if !defined(DEMO_USA) && !defined(DEMO_JP) + case 4: + iVar1 = 9; + break; + case 5: + iVar1 = 10; + break; +#else + case 4: + SoundReq(SFX_MENU_ERROR); + break; + case 5: + SoundReq(SFX_MENU_ERROR); + break; +#endif + } + if (iVar1 != 0) { + sub_080A4E84(iVar1); + SoundReq(SFX_TEXTBOX_SELECT); + } + } + switch (gMenu.field_0x3) { + case 0: + case 2: + if (gGenericMenu.unk10.a[gMenu.field_0x3] != 0) { + gUnk_0200AF00.buttonY[0] = 0x10; + } else { + gUnk_0200AF00.buttonY[0] = 0xfff0; + } + break; + default: + gUnk_0200AF00.buttonY[0] = 0xfff0; + break; + } + + uVar2 = gMenu.field_0x3; + item = gGenericMenu.unk10.a[uVar2]; + if (item != 0) { + switch (uVar2) { + case 0: + if (item != 0x3d) { + item = 0x67; + } + break; + case 1: + item = 99; + break; + case 2: + item = 0x70; + break; + case 4: + item = 0x74; + break; + case 5: + item = 0x73; + } + } + sub_080A6F6C(TEXT_INDEX(TEXT_ITEMS, 0) + item); +} + +void sub_080A57F4(void) { + u32 bVar1; + u32 spriteIndex; + int frameIndex; + u32 uVar5; + struct_gUnk_08128C14* pbVar6; + u32 index; + int shells; + struct_gUnk_08128C14* puVar8; + struct_gUnk_08128C14* puVar10; + + gOamCmd._4 = 0x400; + gOamCmd._6 = 0; + if (gSaveHeader->language == 0) { + puVar8 = gUnk_08128C14; + } else { + puVar8 = gUnk_08128C94; + } + puVar10 = &puVar8[gMenu.field_0x3]; + gOamCmd._8 = 0x800; + gOamCmd.x = puVar10->unk6; + gOamCmd.y = puVar10->unk7; + frameIndex = puVar10->unk4 + 9; + if ((gMain.ticks & 0x10) == 0) { + frameIndex += 2; + } else { + frameIndex++; + } + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, frameIndex); + + for (index = 0, pbVar6 = (struct_gUnk_08128C14*)((u8*)puVar8 + 5); index < 0x10; pbVar6++, index++) { + uVar5 = gGenericMenu.unk10.a[index]; + if (uVar5 != 0) { + puVar10 = &puVar8[index]; + gOamCmd.x = pbVar6->unk1; + bVar1 = pbVar6->unk2; + gOamCmd.y = bVar1; + gOamCmd._8 = 0xe800; + if (uVar5 < 0x34) { + if (index == 2) { + uVar5 = pbVar6->unk0 + 10; + spriteIndex = DRAW_DIRECT_SPRITE_INDEX; + } else { + uVar5 = gGenericMenu.unk10.a[index] + 9; + uVar5 += puVar10->unk5; + spriteIndex = DRAW_DIRECT_SPRITE_INDEX; + } + } else { + gOamCmd._8 = index * 8 + 0xeb80; + switch (uVar5) { + case 0x3e: + gOamCmd.y = bVar1 + 8; + break; + case 0x3d: + gOamCmd.y = bVar1 + 0xd; + break; + } + + uVar5 = gSpriteAnimations_322[uVar5]->index; +#ifdef EU + spriteIndex = 0x141; +#else + spriteIndex = 0x142; +#endif + } + DrawDirect(spriteIndex, uVar5); + } + } + + if (gGenericMenu.unk10.a[2] != 0) { + gOamCmd._8 = gGenericMenu.unk10.a[2] + 0x800; + puVar10 = puVar8 + 2; + gOamCmd.x = puVar10->unk6 + 9; + gOamCmd.y = puVar10->unk7 + 7; + DrawDirect(0, 1); + } + + if (gGenericMenu.unk10.a[3] == 0x3f) { + puVar10 = puVar8 + 3; + gOamCmd.x = puVar10->unk6 + 8; + gOamCmd.y = puVar10->unk7 + 8; + shells = gSave.stats.shells; + + for (index = 0; index < 3; index++) { + gOamCmd._8 = shells % 10 + 0x800; + DrawDirect(0, 1); + shells /= 10; + gOamCmd.x -= 8; + } + } +} + +void PauseMenu_Screen_10(void) { + extern void (*const gUnk_08128D14[])(void); + gUnk_08128D14[gMenu.menuType](); +} + +void sub_080A59AC(void) { + gMenu.field_0x3 = 0; + SetPopupState(0, 0); + SetMenuType(1); +} + +void sub_080A59C8(void) { + u32 uVar2; + u32 bVar3; + + if (!sub_080A51F4()) { + return; + } + uVar2 = gMenu.field_0x3; + bVar3 = FALSE; + + switch (gInput.newKeys) { + case DPAD_UP: + uVar2 = 0; + break; + case B_BUTTON: + if (gMenu.field_0x3 == 0) { + uVar2 = 1; + } else { + bVar3 = TRUE; + } + break; + case DPAD_DOWN: + uVar2 = 1; + break; + case A_BUTTON: + bVar3 = TRUE; + break; + } + + if (bVar3) { + gMenu.transitionTimer = 255; + if (uVar2 == 0) { + CreateDialogBox(8, 0); + SetMenuType(2); + SoundReq(SFX_TEXTBOX_SELECT); + } else { + SetMenuType(3); + SoundReq(SFX_MENU_CANCEL); + } + } else if (gMenu.field_0x3 != uVar2) { + gMenu.field_0x3 = uVar2; + SetPopupState(0, uVar2); + SoundReq(SFX_TEXTBOX_CHOICE); + } +} + +void sub_080A5A54(void) { + switch (HandleSave(0)) { + case SAVE_ERROR: + CreateDialogBox(9, 0); + gMenu.transitionTimer = 60; + // fallthrough + case SAVE_OK: + SetMenuType(3); + break; + case SAVE_BUSY: + break; + } +} + +void sub_080A5A90(void) { + u32 uVar1; + + switch (gMenu.transitionTimer) { + case 0: + if ((gInput.newKeys & (START_BUTTON | B_BUTTON | A_BUTTON)) != 0) { + gMenu.transitionTimer = 255; + } + break; + case 0xff: + if (gPauseMenuOptions.screen == 10) { + uVar1 = 2; + } else { + uVar1 = 1; + } + sub_080A4E84(uVar1); + break; + default: + gMenu.transitionTimer--; + break; + } +} + +void PauseMenu_Screen_9() { + extern void (*const gUnk_08128D24[])(void); + gUnk_08128D24[gMenu.menuType](); +} + +void sub_080A5AF4(void) { + gMenu.field_0x3 = 0; + SetPopupState(2, 0); +#ifndef EU + if (gSaveHeader->language == 0) { + gScreen.bg1.yOffset = -4; + } else { + gScreen.bg1.yOffset = 0; + } +#endif + SetMenuType(1); +} + +void sub_080A5B34(void) { + bool32 bVar1; + u32 uVar3; + + if (!sub_080A51F4()) { + return; + } + uVar3 = gMenu.field_0x3; + bVar1 = FALSE; + switch (gInput.newKeys) { + case DPAD_LEFT: + uVar3 = 0; + break; + case B_BUTTON: + if (gMenu.field_0x3 != 0) { + bVar1 = TRUE; + } else { + uVar3 = 1; + } + break; + case DPAD_RIGHT: + uVar3 = 1; + break; + case A_BUTTON: + bVar1 = TRUE; + break; + } + if (gMenu.field_0x3 != uVar3) { + gMenu.field_0x3 = uVar3; + SetPopupState(2, uVar3); + SoundReq(SFX_TEXTBOX_CHOICE); + } + if (bVar1) { + if (uVar3 == 0) { + SetFade(FADE_IN_OUT | FADE_BLACK_WHITE | FADE_INSTANT, 0x20); + gMenu.transitionTimer = 60; + SetMenuType(2); + } else { + SoundReq(SFX_MENU_CANCEL); + sub_080A4E84(2); + } + } +} + +void sub_080A5BB8(void) { + Main* m; + if (!gFadeControl.active) { + sub_08050384(); + m = &gMain; + *(vu8*)&m->sleepStatus; // force a read + m->sleepStatus = SLEEP; + SetFade(FADE_BLACK_WHITE | FADE_INSTANT, 8); + sub_080A4E84(2); + gPauseMenuOptions.unk16 = 16; + } +} + +void PauseMenu_Screen_5(void) { + extern void (*const gUnk_08128D30[])(void); + u32 uVar1; + u32 temp; + + gUnk_08128D30[gMenu.menuType](); + sub_080A5D1C(); + temp = gMain.ticks; + if ((temp & 7) == 0) { + uVar1 = *gUnk_02017830; + MemCopy(gUnk_02017830 + 1, gUnk_02017830, 0xe); + gUnk_02017830[7] = uVar1; + gUsedPalettes |= 0x1000; + } +} + +void sub_080A5C44(u32 param_1, u32 param_2, u32 param_3) { + s8* ptr; + gMenu.field_0xc = gUnk_08128D38; + sub_080A5CFC(gMenu.field_0x3, &gMenu, param_3); + LoadGfxGroup(0x81); + sub_080A6FB4(gArea.dungeon_idx, 1); + SetMenuType(1); + ptr = &gUnk_08128D43[(u32)gArea.dungeon_idx * 2]; + gScreen.bg1.xOffset += ptr[0]; + gScreen.bg1.yOffset += ptr[0]; +} + +void sub_080A5C9C(void) { + s32 newChoice; + const struct_080C9C6C* ptr; + + if (sub_080A51F4()) { + ptr = &gUnk_080C9C6C[gArea.dungeon_idx]; + newChoice = gMenu.field_0x3; + switch (gInput.newKeys) { + case DPAD_UP: + if (newChoice > 0) { + newChoice--; + } + break; + case DPAD_DOWN: + if (ptr->unk_0 - 1 > newChoice) { + newChoice++; + } + break; + } + if (gMenu.field_0x3 != newChoice) { + gMenu.field_0x3 = newChoice; + sub_080A5CFC(newChoice, &gMenu, newChoice); + SoundReq(SFX_TEXTBOX_CHOICE); + } + } +} + +void sub_080A5CFC(u32 menuType, void* param_2, u32 param_3) { + DrawDungeonFeatures(menuType, param_2, param_3); + LoadDungeonMap(); + DrawDungeonMap(menuType, &gMapDataBottomSpecial, 0x400); +} + +#ifdef EU +#define SUB_080A5D1C_SPRITE_INDEX 0x143 +#else +#define SUB_080A5D1C_SPRITE_INDEX 0x144 +#endif + +// Actually draw the sprites for the dungeon map. +void sub_080A5D1C(void) { + extern u8 gUnk_08128D3C[]; + u32 bVar1; + int frameIndex; + u32 uVar4; + u32 uVar6; + u32 index; + u8* puVar8; + const struct_080C9C6C* pbVar9; + + pbVar9 = &gUnk_080C9C6C[gArea.dungeon_idx]; + bVar1 = gUnk_08128D3C[pbVar9->unk_0]; + uVar4 = sub_0801DB94(); + gOamCmd._4 = 0x400; + gOamCmd._6 = 0; + gOamCmd._8 = 0; + gOamCmd.x = 0x34; + gOamCmd.y = bVar1 + gMenu.field_0x3 * 0xc; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, (gMain.ticks & 0x10) == 0 ? 0x75 : 0x74); + gOamCmd.x = 0x20; + gOamCmd.y = bVar1 + uVar4 * 0xc; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, (gMain.ticks & 0x20) != 0 ? 0x78 : 0x79); + gOamCmd.y = 0x7e; + gOamCmd._8 = 0x4380; + if (HasDungeonSmallKey()) { + gOamCmd.x = 0x18; + frameIndex = gSpriteAnimations_322[0x50]->index; + DrawDirect(SUB_080A5D1C_SPRITE_INDEX, frameIndex); + } + if (HasDungeonCompass()) { + gOamCmd.x = 0x2e; + frameIndex = gSpriteAnimations_322[0x52]->index; + DrawDirect(SUB_080A5D1C_SPRITE_INDEX, frameIndex); + } + if (HasDungeonBigKey()) { + gOamCmd.x = 0x45; + gOamCmd._8 = 0x380; + frameIndex = gSpriteAnimations_322[0x51]->index; + DrawDirect(SUB_080A5D1C_SPRITE_INDEX, frameIndex); + if (sub_080A5F24()) { + gOamCmd._8 = 0; + gOamCmd.x = 0x46; + gOamCmd.y = bVar1 + (pbVar9->unk_1 - pbVar9->unk_2) * 0xc; + if ((gMain.ticks & 0x20) != 0) { + uVar6 = 0x7a; + } else { + uVar6 = 0x7b; + } + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, uVar6); + } + } + gOamCmd._8 = 0; + gOamCmd.x = 0x34; + gOamCmd.y = bVar1; + frameIndex = pbVar9->unk_1 + 0x82; + + for (index = 0; index < pbVar9->unk_0; index++) { + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, frameIndex); + frameIndex--; + gOamCmd.y = gOamCmd.y + 0xc; + } + + puVar8 = (u8*)&gMapDataBottomSpecial; + while (*puVar8 != 0) { + switch (*puVar8) { + case 1: + frameIndex = 0x7d; + if (uVar4 != gMenu.field_0x3) { + frameIndex = 0x7e; + } + break; + case 2: + frameIndex = 0x80; + break; + case 3: + frameIndex = 0x81; + break; + case 4: + if (sub_080A5F24()) { + frameIndex = 0x7f; + break; + } + default: + frameIndex = 0xff; + break; + } + + gOamCmd.x = puVar8[1] + 0x50 - gScreen.bg1.xOffset; + gOamCmd.y = puVar8[2] + 0x10 - gScreen.bg1.yOffset; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, frameIndex); + puVar8 += 3; + } +} + +bool32 sub_080A5F24(void) { + bool32 result = TRUE; + if ((gArea.dungeon_idx == 6) && CheckLocalFlagByBank(FLAG_BANK_10, 0x7b)) { + result = 0; + } + return result; +} + +void sub_080A5F48(u32 param_1, u32 param_2) { + extern u32 gSprite_082E68F4[]; + u32 ammoCount; + u32 tensDigit; + u8* puVar2; + u32 temp1; + u16* temp2; + u32 temp3; + register u32 rem asm("r1"); + + switch (param_1) { + case 0x1c ... 0x1f: + param_1 = (u32)gSave.saved_status.field_0x24[param_1 - 6]; + break; + } + + temp1 = param_2 * 0x20 + 0x6010000; + temp3 = gSpriteAnimations_322[param_1]->index; + temp2 = &gMoreSpritePtrs[1][temp3 * 2]; + DmaCopy32(3, &gMoreSpritePtrs[2][temp2[1] * 0x10], temp1, 0x40 * 4); + ammoCount = -1; + + switch (param_1) { + case 7: + case 8: + ammoCount = gSave.stats.bombCount; + break; + case 9: + case 10: + ammoCount = gSave.stats.arrowCount; + break; + } + + if (-1 < (int)ammoCount) { + tensDigit = Div(ammoCount, 10); + param_1 = rem; + if ((int)tensDigit >= 10) { + tensDigit = 9; + } + DmaCopy32(3, gUnk_085C4620 + tensDigit * 0x8, temp1, 0x8 * 4); + DmaCopy32(3, gUnk_085C4620 + (param_1 + 10) * 0x8, temp1 + 0x20, 0x8 * 4); + } +} + +void PauseMenu_Screen_7(void) { + gUnk_08128D58[gMenu.menuType](); +} + +void sub_080A6024(void) { + sub_080A70AC((KeyButtonLayout*)&gUnk_08128D60); + sub_0801E738(0); + sub_080A4398(); + SetMenuType(1); +} + +void sub_080A6044(void) { + extern u8 gUnk_08128D51[]; + u32 uVar1; + u32 uVar2; + u32 uVar4; + u32 uVar3; + + if (sub_080A51F4() != 0) { + gMenu.field_0xc = gUnk_08128D51; + gOamCmd._4 = 0; + gOamCmd._6 = 0; + uVar4 = 0; + uVar2 = 0; + uVar1 = gSave.unk118[0]; + while (uVar1 != 0) { + gOamCmd.x = (uVar4 & 3) * 0x30 + 0x2b; + gOamCmd.y = (uVar4 >> 2) * 0x24 + 0x34; + uVar3 = gSave.unk12B[uVar2]; + gMenu.column_idx = 0; + sub_080A42E0(uVar1, uVar3); + uVar4++; + if (10 < uVar4) { + return; + } + uVar2++; + if (0x11 < uVar2) { + return; + } + uVar1 = gSave.unk118[uVar2]; + } + } +} + +void PauseMenu_Screen_8(void) { + gUnk_08128DB0[gMenu.menuType](); + sub_080A617C(); + sub_080A7040(gMenu.field_0x3); +} + +void sub_080A6108(void) { + gMenu.field_0xc = (u8*)gUnk_08128DB8; + sub_080A70AC((KeyButtonLayout*)&gUnk_08128DBC); + SetMenuType(1); +} + +void sub_080A612C(void) { + u32 newChoice; + int iVar3; + + if (sub_080A51F4()) { + newChoice = gMenu.field_0x3; + switch (gInput.newKeys) { + case DPAD_LEFT: + newChoice--; + break; + case DPAD_RIGHT: + newChoice++; + break; + } + iVar3 = newChoice + 8; + newChoice = iVar3 / 8; + newChoice = iVar3 - newChoice * 8; + if (gMenu.field_0x3 != newChoice) { + gMenu.field_0x3 = newChoice; + SoundReq(SFX_TEXTBOX_CHOICE); + } + } +} + +void sub_080A617C(void) { + u32 frameIndex; + u32 i; + const struct_gUnk_08128D70* ptr; + + gOamCmd._4 = 0; + gOamCmd._6 = 0; + gOamCmd._8 = 0xc00; + gOamCmd.y = 0x2f; + gOamCmd.x = gMenu.field_0x3 * 0x1b + 0x1a; + if ((gMain.ticks & 0x20) != 0) { + frameIndex = 8; + } else { + frameIndex = 9; + } + DrawDirect(DRAW_DIRECT_SPRITE_INDEX + 1, frameIndex); + ptr = &gUnk_08128D70[gMenu.field_0x3]; + if (GetInventoryValue(ptr->item) != 0) { + gOamCmd._8 = 0xc00; + gOamCmd.x = 0xcc; + gOamCmd.y = 0x88; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX + 1, 0xb); + gOamCmd.x = 0x30; + gOamCmd.y = 0x6c; + gOamCmd._8 = ptr->unk1 << 0xc | 0xd80; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX + 1, ptr->frameIndex); + gOamCmd._8 = ptr->unk1 << 0xc | 0xc00; + gOamCmd.x = 0x78; + gOamCmd.y = 0x68; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX + 1, 0xc); + } + gOamCmd.y = 0x2f; + + for (i = 0; i < 8; i++) { + ptr = &gUnk_08128D70[i]; + if (GetInventoryValue(ptr->item) != 0) { + gOamCmd._8 = ptr->unk1 << 0xc | 0xc00; + gOamCmd.x = 0x18 + 0x1b * i; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX + 1, 10); + } + } +} + +void PauseMenu_Screen_4(void) { + gUnk_08128DCC[gMenu.menuType](); + sub_080A6378(); +} + +extern u8 gUnk_08128DD8[]; +extern u8 gUnk_08128DD4[]; + +void sub_080A6290(void) { + sub_080A70AC((KeyButtonLayout*)gUnk_08128DD8); + gMenu.field_0xc = gUnk_08128DD4; + LoadGfxGroup(0x81); + gScreen.bg1.yOffset = -4; + gScreen.bg2.yOffset = -4; + gSave.windcrests = gSave.windcrests | 0x10780; + gGenericMenu.unk10.h[0] = sub_080A6F40(); + gMenu.menuType = 1; +} + +void sub_080A62E0(void) { + u32 uVar1; + int windcrest; + gUnk_08128DE8_struct* ptr; + + if (!sub_080A51F4()) { + return; + } + ptr = &gUnk_08128DE8[gMenu.field_0x3]; + windcrest = -1; + + switch (gInput.newKeys) { + case A_BUTTON: + if ((gSave.windcrests & (1 << gMenu.field_0x3)) != 0) { + SoundReq(SFX_TEXTBOX_SELECT); + sub_080A4E84(6); + windcrest = -1; + } + break; + case DPAD_UP: + windcrest = ptr->unk0.unk00; + break; + case DPAD_DOWN: + windcrest = ptr->unk0.unk05; + break; + case DPAD_LEFT: + windcrest = ptr->unk2.unk00; + break; + case DPAD_RIGHT: + windcrest = ptr->unk2.unk05; + break; + } + + if (-1 < windcrest) { + gMenu.field_0x3 = windcrest; + SoundReq(SFX_TEXTBOX_CHOICE); + } + sub_080A6FB4(gMenu.field_0x3, 0); +} + +void sub_080A6378(void) { + u32 frameIndex; + gUnk_08128DE8_struct* ptr; + + gGenericMenu.unk2c++; + if ((gGenericMenu.unk2c & 0x20) != 0) { + sub_080A6438(); + } + gOamCmd._4 = 0x400; + gOamCmd._6 = 0; + gOamCmd._8 = 0x7000; + if ((gGenericMenu.unk2c & 0x20) == 0) { + gOamCmd.x = gRoomTransition.player_status.overworld_map_x * DISPLAY_HEIGHT / 0xf90 + 0x28; + gOamCmd.y = (gRoomTransition.player_status.overworld_map_y << 7) / 0xc60 + 0xc; + if ((gPlayerState.flags & PL_NO_CAP) != 0) { + frameIndex = 0x5a; + } else { + frameIndex = 0x59; + } + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, frameIndex); + } + ptr = &gUnk_08128DE8[gMenu.field_0x3]; + gOamCmd.x = ptr->unk6; + gOamCmd.y = ptr->unk7; + frameIndex = gMenu.field_0x3 * 3 + 0x26 + (((gGenericMenu.unk2c >> 4) & 1) == 0); + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, frameIndex); + sub_080A6498(); +} + +void sub_080A6438(void) { + u32 uVar1; + struct_gUnk_08128F58* pcVar2; + u32 uVar3; + + gOamCmd._4 = 0x400; + gOamCmd._6 = 0; + gOamCmd._8 = 0; + uVar1 = gSave.field_0x20 & gGenericMenu.unk10.h[0]; + for (pcVar2 = gUnk_08128F58, uVar3 = 0; pcVar2->frameIndex != 0; uVar3++, pcVar2++) { + if ((1 << uVar3 & uVar1) != 0) { + gOamCmd.x = pcVar2->unk1; + gOamCmd.y = pcVar2->unk2; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, pcVar2->frameIndex); + } + } +} + +void sub_080A6498(void) { + u32 i; + + gOamCmd._4 = 0x800; + gOamCmd._6 = 0; + gOamCmd._8 = 0; + for (i = 0; i <= 0x10; i++) { + if ((gSave.windcrests & (1 << i)) == 0) { + gUnk_08128DE8_struct* ptr = &gUnk_08128DE8[i]; + gOamCmd.x = ptr->unk6; + gOamCmd.y = ptr->unk7; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, 0x28 + 3 * i); + } + } + gScreen.controls.windowOutsideControl = 0x3d3f; +} diff --git a/src/menu/pauseMenuScreen6.c b/src/menu/pauseMenuScreen6.c new file mode 100644 index 00000000..4bfcd17a --- /dev/null +++ b/src/menu/pauseMenuScreen6.c @@ -0,0 +1,276 @@ +/** + * @file pauseMenuScreen6.c + * + * @brief Pause Menu Screen 6 + */ +#include "common.h" +#include "fileselect.h" +#include "flags.h" +#include "functions.h" +#include "kinstone.h" +#include "main.h" +#include "menu.h" +#include "pauseMenu.h" +#include "save.h" +#include "screen.h" + +typedef struct { + u8 unk0; + u8 unk1; + u16 unk2; + u16 unk4; + u16 unk6; +} struct_sub_080A698C; + +extern u8 gUnk_08128E80[]; + +extern u16 gUnk_02017AA0[]; + +void sub_080A68D4(); + +void PauseMenu_Screen_6(void) { + extern void (*const gUnk_08128E78[])(void); + const struct_gUnk_08128E94* ptr; + gUnk_08128E78[gMenu.menuType](); + ptr = &gUnk_08128E94[gMenu.field_0x3]; + gScreen.bg1.yOffset = -ptr->unk5; + gScreen.bg2.yOffset = gMenu.field_0xa - (s8)ptr->unk6; + sub_080A66D0(); +} + +void sub_080A6650(void) { + extern u8 gUnk_08128E84[]; + u32 temp; + sub_080A70AC((KeyButtonLayout*)gUnk_08128E84); + temp = gPauseMenuOptions.unk2[4]; + gMenu.field_0x3 = temp; + sub_080A67C4(temp); + sub_080A68D4(); + SetMenuType(1); +} + +void sub_080A667C(void) { + u32 uVar1; + u32 uVar2; + const struct_gUnk_08128E94* ptr; + + gMenu.field_0xc = gUnk_08128E80; + ptr = &gUnk_08128E94[gMenu.field_0x3]; + uVar2 = gMenu.field_0xa; + switch (gInput.heldKeys) { + case DPAD_UP: + if (uVar2 != 0) { + uVar2 -= 2; + } + break; + case DPAD_DOWN: + uVar1 = ptr->unk2; + if (uVar1 > uVar2) { + uVar2 += 2; + } + if (uVar1 < uVar2) { + uVar2 = uVar1; + } + break; + } + + gMenu.field_0xa = uVar2; + sub_080A6FB4(gMenu.field_0x3, 0); +} + +void sub_080A66D0(void) { + u32 bVar2; + u32 bVar3; + u8 bVar4; + u32 uVar5; + u32 uVar8; + struct_sub_080A698C* ptr; + const struct_gUnk_08128E94* ptr2; + + gOamCmd._4 = 0; + gOamCmd._6 = 0; + gOamCmd.x = 0x78; + ptr2 = &gUnk_08128E94[gMenu.field_0x3]; + gGenericMenu.unk2c++; + if (gGenericMenu.unk2b != 1 && ((gGenericMenu.unk2c & 0x10) != 0)) { + gOamCmd._8 = 0x800; + if (gMenu.field_0xa != 0) { + gOamCmd.y = 0xc; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, 0x71); + } + if (ptr2->unk2 > gMenu.field_0xa) { + gOamCmd.y = 0x84; + DrawDirect(DRAW_DIRECT_SPRITE_INDEX, 0x72); + } + } + bVar2 = ptr2->unk7; + bVar3 = ptr2->unk3; + uVar5 = gMenu.field_0xa; + gOamCmd._4 = 0; + gOamCmd._6 = 0; + gOamCmd._8 = 0xc00; + bVar4 = gGenericMenu.unk2c & 0x20; + + for (ptr = (struct_sub_080A698C*)&gMapDataBottomSpecial; ptr->unk2 != 0; ptr++) { + uVar8 = 0; + if (ptr->unk0 == 1) { + if (bVar4 != 0) { + uVar8 = 1; + } + } else if (bVar4 == 0) { + uVar8 = 1; + } + + if (uVar8 != 0) { + gOamCmd.x = ptr->unk4 + bVar2; + gOamCmd.y = ptr->unk6 + bVar3 - uVar5; + DrawDirect(ptr->unk2, ptr->unk1); + } + } +} + +void sub_080A67C4(u32 param_1) { + u16* puVar2; + int i; + int iVar4; + s32 room; + const struct_gUnk_08128E94* ptr; + + LoadPaletteGroup(param_1 + 0xba); + iVar4 = param_1 + 0x5f; + switch (param_1) { + case 0x9: + if (CheckGlobalFlag(TATEKAKE_HOUSE)) { + iVar4 = 0x70; + } + break; + case 0xb: + if (CheckKinstoneFused(KINSTONE_E)) { + iVar4 = 0x71; + } + break; + case 0xe: + if (gUI.roomControls.area == 8) { + room = gUI.roomControls.room; + iVar4 = (u8)(room % 3) + 0x72; + } + break; + } + + LoadGfxGroup(iVar4); + ptr = &gUnk_08128E94[param_1]; + puVar2 = &gUnk_02017AA0[gUnk_03003DE4[0] * 0x500]; + + for (i = 0; i <= 7; puVar2++, i++) { + *puVar2 = 0x1e0a; + } + + for (i = 8; i < (int)(ptr->unk5 + ptr->unk4); puVar2++, i++) { + *puVar2 = 0x1e0b; + } + + for (; i < 0xa0; puVar2++, i++) { + *puVar2 = 0x1e0a; + } + + SetVBlankDMA((u16*)&gUnk_02017AA0[gUnk_03003DE4[0] * 0x500], (u16*)REG_ADDR_BG3CNT, + ((DMA_ENABLE | DMA_START_HBLANK | DMA_16BIT | DMA_REPEAT | DMA_SRC_INC | DMA_DEST_RELOAD) << 16) + + 0x1); + gMenu.field_0xa = ptr->unk2 >> 1; + MemClear(&gMapDataBottomSpecial, 0x400); +} + +void sub_080A68D4(void) { + u32 uVar1; + int iVar6; + struct_gUnk_08128F58* pcVar4; + u32 i; + u32 uVar4; + const WorldEvent* ptr; + + if ((gPlayerState.flags & PL_NO_CAP) != 0) { + iVar6 = 101; + } else { + iVar6 = 100; + } + sub_080A698C(gRoomTransition.player_status.overworld_map_x, gRoomTransition.player_status.overworld_map_y, + DRAW_DIRECT_SPRITE_INDEX, iVar6 + 0x100); + uVar1 = sub_080A6F40(); + uVar1 &= gSave.field_0x20; + + for (pcVar4 = gUnk_08128F58, i = 0; pcVar4->frameIndex != 0; i++, pcVar4++) { + if (((1 << i) & uVar1) != 0) { + sub_080A698C(pcVar4->unk4, pcVar4->unk6, DRAW_DIRECT_SPRITE_INDEX, pcVar4->unk3); + } + } + + for (i = 10; i <= 100; i++) { + if (CheckKinstoneFused(i) && !sub_0801E810(i)) { + uVar4 = gKinstoneWorldEvents[i].unk7; + ptr = &gWorldEvents[gKinstoneWorldEvents[i].worldEventId]; + sub_080A698C(ptr->_c, ptr->_e, DRAW_DIRECT_SPRITE_INDEX, uVar4 + 100); + } + } +} + +void sub_080A698C(u32 param_1, u32 param_2, u32 param_3, u32 param_4) { + int iVar1; + + iVar1 = sub_080A69E0(param_1, param_2); + if (0 < iVar1) { + ((struct_sub_080A698C*)&gMapDataBottomSpecial)[gGenericMenu.unk2d].unk0 = param_4 >> 8; + ((struct_sub_080A698C*)&gMapDataBottomSpecial)[gGenericMenu.unk2d].unk1 = param_4; + ((struct_sub_080A698C*)&gMapDataBottomSpecial)[gGenericMenu.unk2d].unk2 = param_3; + ((struct_sub_080A698C*)&gMapDataBottomSpecial)[gGenericMenu.unk2d].unk4 = iVar1; + ((struct_sub_080A698C*)&gMapDataBottomSpecial)[gGenericMenu.unk2d].unk6 = iVar1 >> 0x10; + gGenericMenu.unk2d++; + } +} + +s32 sub_080A69E0(u32 param_1, u32 param_2) { + const struct_08127F94* pbVar1; + int iVar3; + + if ((param_1 | param_2) == 0) + return -1; + + pbVar1 = sub_080A6A80(param_1, param_2); + if (pbVar1 == NULL) + return -1; + + if (gMenu.field_0x3 != pbVar1->_4) + return -1; + + switch (gMenu.field_0x3) { + case 4: + case 7: + if (gMenu.field_0x3 == 4) { + iVar3 = 9; + } else { + iVar3 = 7; + } + param_2 -= gAreaRoomHeaders[iVar3]->map_y; + break; + break; + case 15: + param_1 -= 0x108; + break; + } + + param_1 = (s32)((param_1 - pbVar1->_0 * 0x10) * 100) / 0x23a; + param_2 = (s32)((param_2 - pbVar1->_1 * 0x10) * 100) / 0x23a; + return (param_2 << 0x10) | param_1; +} + +struct_08127F94* sub_080A6A80(u32 param_1, u32 param_2) { + struct_08127F94* pbVar1; + param_1 >>= 4; + param_2 >>= 4; + + for (pbVar1 = gUnk_08127F94; pbVar1->_0 != 0xff; pbVar1++) { + if (pbVar1->_0 <= param_1 && pbVar1->_2 >= param_1 && pbVar1->_1 <= param_2 && pbVar1->_3 >= param_2) { + return pbVar1; + } + } + return NULL; +} diff --git a/src/menu/pause_menu.c b/src/menu/pause_menu.c deleted file mode 100644 index 957dc751..00000000 --- a/src/menu/pause_menu.c +++ /dev/null @@ -1,567 +0,0 @@ -#include "global.h" -#include "menu.h" -#include "sound.h" -#include "subtask.h" -#include "screen.h" -#include "item.h" -#include "common.h" -#include "game.h" -#include "main.h" -#include "save.h" -#include "itemMetaData.h" -#include "structures.h" -#include "functions.h" -#include "ui.h" - -extern void sub_080A4DB8(u32); - -void sub_080A5128(void); -void sub_080A51D4(void); -bool32 sub_080A51F4(void); -void sub_080A5F48(u32, u32); - -Subtask PauseMenu_Variant0; -Subtask PauseMenu_Variant1; -Subtask PauseMenu_Variant2; -Subtask PauseMenu_Variant3; -Subtask PauseMenu_Variant4; -Subtask PauseMenu_Variant5; -void Subtask_PauseMenu(void) { - static Subtask* const pauseMenu_Variants[] = { - PauseMenu_Variant0, PauseMenu_Variant1, PauseMenu_Variant2, - PauseMenu_Variant3, PauseMenu_Variant4, PauseMenu_Variant5, - }; - - if (gPauseMenuOptions.unk11 == 6) { - SetBgmVolume(0x100); - Subtask_Exit(); - } else { - FlushSprites(); - pauseMenu_Variants[gPauseMenuOptions.unk11](); - sub_080A5128(); - UpdateUIElements(); - DrawUIElements(); - if (gPauseMenuOptions.unk11 != 4) { - gUnk_08128A38[gPauseMenuOptions.unk1].func(); - } - CopyOAM(); - { - u32 t = gPauseMenuOptions.unk16; - u32 t2 = (t != 0) ? 0xe46 : 0; - gScreen.controls.layerFXControl = t2; - gScreen.controls.alphaBlend = (t << 8) | (0x10 - t); - } - } -} - -struct_08127F94* sub_080A6A80(u32, u32); - -extern u8 gUnk_02034492[]; -void sub_0801E8D4(void); -s32 sub_080A50A0(s32); - -void PauseMenu_Variant0(void) { - struct_08127F94* ptr; - int r0, r1; - - sub_0801E8D4(); - sub_080A4D34(); - r1 = 4; - do { - gUnk_02034492[r1] = 0; - r1++; - } while (r1 <= 0xd); - ptr = sub_080A6A80((u16)gRoomTransition.player_status.overworld_map_x, - (u16)gRoomTransition.player_status.overworld_map_y); - gPauseMenuOptions.unk2[4] = ptr->_4; - gPauseMenuOptions.unk2[5] = sub_0801DB94(); - if (IsItemEquipped(ITEM_LANTERN_ON) != EQUIP_SLOT_NONE) { - r1 = 0x10; - } else { - r1 = 0xf; - } - gPauseMenuOptions.unk15 = r1; - r0 = gUnk_08128A38[gPauseMenuOptions.unk1].unk1; - r0 = sub_080A50A0(r0); - gPauseMenuOptions.unk1 = r0; - gPauseMenuOptions.unk14 = r0; - sub_080A4DB8(r0); - SetFade(FADE_INSTANT, 0x20); - sub_080A4E90(1); -} - -void PauseMenu_Variant1(void) { - if (gFadeControl.active == 0) { - sub_080A4E90(2); - } -} - -void PauseMenu_Variant2(void) { - int iVar1; - u32 uVar2; - int iVar4; - s32 bVar5; - - if (sub_080A51F4() && (gMenu.field_0xc != NULL)) { - iVar1 = -1; - switch (gInput.newKeys) { - case START_BUTTON: - iVar1 = 0; - break; - case L_BUTTON: - iVar1 = 1; - break; - case R_BUTTON: - iVar1 = 2; - break; - case B_BUTTON: - iVar1 = 3; - break; - } - if (iVar1 >= 0) { - switch (bVar5 = gMenu.field_0xc[iVar1]) { - case 0: - break; - case 4 ... 6: - case 0xf: - uVar2 = GetInventoryValue(ITEM_MAP); - if (uVar2 == 0) { - iVar4 = 1; - if (iVar1 == 1) { - iVar4 = 2; - } - bVar5 = gMenu.field_0xc[iVar4]; - } - default: - gPauseMenuOptions.unk14 = bVar5; - SoundReq(SFX_TEXTBOX_OPEN); - gMenu.field_0xc = NULL; - break; - } - } - } - bVar5 = sub_080A50A0(gPauseMenuOptions.unk14); - if (gPauseMenuOptions.unk1 != bVar5) { - gPauseMenuOptions.unk14 = bVar5; - sub_080A51D4(); - if (bVar5 == 0xe) { - sub_080A4E90(6); - } else { - sub_080A4E90(3); - MemClear(&gBG0Buffer, sizeof(gBG0Buffer)); - gScreen.bg0.updated = 1; - } - } -} - -s32 sub_080A50A0(s32 param_1) { - s32 iVar1; - - if (param_1 == 0xf) { - iVar1 = AreaHasMap(); - param_1 = 4; - if (iVar1 != 0) { - param_1 = 5; - } - } - return param_1; -} - -void PauseMenu_Variant3(void) { - s32 iVar1; - - iVar1 = gPauseMenuOptions.unk16 + 2; - if (0x10 < iVar1) { - gScreen.lcd.displayControl &= 0xf8ff; - sub_080A4E90(4); - iVar1 = 0x10; - } - gPauseMenuOptions.unk16 = iVar1; -} - -void PauseMenu_Variant4(void) { - u32 t; - gPauseMenuOptions.unk16 = 0x10; - gPauseMenuOptions.unk1 = t = gPauseMenuOptions.unk14; - sub_080A4DB8(t); - sub_080A4E90(5); -} - -void PauseMenu_Variant5(void) { - s32 iVar1; - - iVar1 = gPauseMenuOptions.unk16 - 2; - if (iVar1 < 0) { - sub_080A4E90(2); - iVar1 = 0; - } - gPauseMenuOptions.unk16 = iVar1; -} - -void sub_080A5128(void) { - int r5, t; - struct { - int x; - int y; - } p[3]; - - switch (gPauseMenuOptions.unk1) { - case 7: - case 8: - p[0].x = 0x60; - p[0].y = 0x18; - p[1].x = -0x10; - p[1].y = 0x48; - p[2].x = 0x100; - p[2].y = 0x48; - break; - case 9: - case 10: - case 11: - return; - default: - p[0].x = 0x40; - p[0].y = 0x10 - (gPauseMenuOptions.unk16 << 1); - t = (gPauseMenuOptions.unk16 / 3); - p[1].x = 0x10 - t; - p[1].y = 0x48; - p[2].x = 0xe0 + t; - p[2].y = 0x48; - break; - } - gOamCmd._4 = 0; - gOamCmd._6 = 0; - gOamCmd._8 = 0x400; - gOamCmd.x = p[0].x; - gOamCmd.y = p[0].y; -#ifdef EU - r5 = 0x1fa; -#else - r5 = 0x1fb; -#endif - DrawDirect(r5, 0); - gOamCmd.x = p[1].x; - gOamCmd.y = p[1].y; - DrawDirect(r5, 1); - gOamCmd.x = p[2].x; - gOamCmd.y = p[2].y; - DrawDirect(r5, 2); -} - -void sub_080A51D4(void) { - u32 i = gPauseMenuOptions.unk1; - if (i < 0xe) { - gPauseMenuOptions.unk2[i] = gMenu.field_0x3; - } -} - -bool32 sub_080A51F4(void) { - bool32 retval = TRUE; - if (gFadeControl.active != 0) - retval = FALSE; - if (gPauseMenuOptions.unk11 != 2) - retval = FALSE; - return retval; -} - -typedef struct { - u8 up; - u8 down; - u8 left; - u8 right; - u8 type; - u8 unk0; - u8 x; - u8 y; -} ItemMenuTableEntry; - -Subtask PauseMenu_ItemMenu_Draw; -Subtask PauseMenu_ItemMenu_Init; -Subtask PauseMenu_ItemMenu_Update; -void PauseMenu_ItemMenu(void) { - static Subtask* const pauseMenu_Types[] = { PauseMenu_ItemMenu_Init, PauseMenu_ItemMenu_Update }; - - pauseMenu_Types[gMenu.menuType](); - PauseMenu_ItemMenu_Draw(); -} - -void PauseMenu_ItemMenu_Init(void) { - static const KeyButtonLayout gUnk_08128B50 = { - 0xd0u, - 0x10u, - 0u, - 0xb8u, - 0x10u, - 0u, - 0xffu, - 0xd8u, - 0u, - { - 0x3u, - 0u, - 0x4u, - 0u, - 0u, - 0u, - 0x1u, - 0u, - 0xffu, - 0u, - 0u, - }, - }; - - u32 uVar1; - u32 i; - u32 item; - - gMenu.field_0xc = NULL; - sub_080A70AC((KeyButtonLayout*)&gUnk_08128B50); - for (item = ITEM_SMITH_SWORD; item < ITEM_BOTTLE_EMPTY; item++) { - uVar1 = GetInventoryValue(item); - if ((uVar1 == 1) && (i = gItemMetaData[item].menuSlot, i <= MENU_SLOT_SAVE_BUTTON_JP)) { - switch (item) { - case ITEM_LANTERN_OFF: - case ITEM_LANTERN_ON: - item = gPauseMenuOptions.unk15; - break; - default: - break; - } - gPauseMenu.items[i] = item; - sub_080A5F48(item, i * 8 + 0x360); - } - } - SetMenuType(1); -} - -const ItemMenuTableEntry gItemMenuTable[] = { - [MENU_SLOT_SWORD] = { MENU_SLOT_BOTTLE0, MENU_SLOT_SHIELD, MENU_SLOT_BOOMERANG, MENU_SLOT_GUST_JAR, 0x01, 0x0c, - 0x42, 0x33 }, - [MENU_SLOT_GUST_JAR] = { MENU_SLOT_BOTTLE1, MENU_SLOT_MOLE_MITTS, MENU_SLOT_SWORD, MENU_SLOT_CANE, 0x01, 0x10, 0x66, - 0x33 }, - [MENU_SLOT_CANE] = { MENU_SLOT_BOTTLE3, MENU_SLOT_LANTERN, MENU_SLOT_GUST_JAR, MENU_SLOT_BOOMERANG, 0x01, 0x14, - 0x8a, 0x33 }, - [MENU_SLOT_BOOMERANG] = { MENU_SLOT_SAVE_BUTTON, MENU_SLOT_BOMBS, MENU_SLOT_CANE, MENU_SLOT_SWORD, 0x01, 0x15, 0xae, - 0x33 }, - [MENU_SLOT_SHIELD] = { MENU_SLOT_SWORD, MENU_SLOT_PEGASUS_BOOTS, MENU_SLOT_BOMBS, MENU_SLOT_MOLE_MITTS, 0x01, 0x16, - 0x42, 0x4b }, - [MENU_SLOT_MOLE_MITTS] = { MENU_SLOT_GUST_JAR, MENU_SLOT_ROCS_CAPE, MENU_SLOT_SHIELD, MENU_SLOT_LANTERN, 0x01, 0x17, - 0x66, 0x4b }, - [MENU_SLOT_LANTERN] = { MENU_SLOT_CANE, MENU_SLOT_OCARINA, MENU_SLOT_MOLE_MITTS, MENU_SLOT_BOMBS, 0x01, 0x00, 0x8a, - 0x4b }, - [MENU_SLOT_BOMBS] = { MENU_SLOT_BOOMERANG, MENU_SLOT_BOW, MENU_SLOT_LANTERN, MENU_SLOT_SHIELD, 0x01, 0x00, 0xae, - 0x4b }, - [MENU_SLOT_PEGASUS_BOOTS] = { MENU_SLOT_SHIELD, MENU_SLOT_BOTTLE0, MENU_SLOT_BOW, MENU_SLOT_ROCS_CAPE, 0x01, 0x00, - 0x42, 0x63 }, - [MENU_SLOT_ROCS_CAPE] = { MENU_SLOT_MOLE_MITTS, MENU_SLOT_BOTTLE1, MENU_SLOT_PEGASUS_BOOTS, MENU_SLOT_OCARINA, 0x01, - 0x00, 0x66, 0x63 }, - [MENU_SLOT_OCARINA] = { MENU_SLOT_LANTERN, MENU_SLOT_BOTTLE3, MENU_SLOT_ROCS_CAPE, MENU_SLOT_BOW, 0x01, 0x00, 0x8a, - 0x63 }, - [MENU_SLOT_BOW] = { MENU_SLOT_BOMBS, MENU_SLOT_SAVE_BUTTON, MENU_SLOT_OCARINA, MENU_SLOT_PEGASUS_BOOTS, 0x01, 0x00, - 0xae, 0x63 }, - [MENU_SLOT_BOTTLE0] = { MENU_SLOT_PEGASUS_BOOTS, MENU_SLOT_SWORD, MENU_SLOT_SAVE_BUTTON, MENU_SLOT_BOTTLE1, 0x01, - 0x00, 0x42, 0x7b }, - [MENU_SLOT_BOTTLE1] = { MENU_SLOT_ROCS_CAPE, MENU_SLOT_GUST_JAR, MENU_SLOT_BOTTLE0, MENU_SLOT_BOTTLE2, 0x01, 0x00, - 0x5a, 0x7b }, - [MENU_SLOT_BOTTLE2] = { MENU_SLOT_ROCS_CAPE, MENU_SLOT_GUST_JAR, MENU_SLOT_BOTTLE1, MENU_SLOT_BOTTLE3, 0x01, 0x00, - 0x72, 0x7b }, - [MENU_SLOT_BOTTLE3] = { MENU_SLOT_OCARINA, MENU_SLOT_CANE, MENU_SLOT_BOTTLE2, MENU_SLOT_SAVE_BUTTON, 0x01, 0x00, - 0x8a, 0x7b }, - [MENU_SLOT_SAVE_BUTTON] = { MENU_SLOT_BOW, MENU_SLOT_BOOMERANG, MENU_SLOT_BOTTLE3, MENU_SLOT_BOTTLE0, 0x03, 0x00, - 0xb5, 0x75 }, - [MENU_SLOT_SAVE_BUTTON_JP] = { MENU_SLOT_BOW, MENU_SLOT_BOOMERANG, MENU_SLOT_BOTTLE3, MENU_SLOT_BOTTLE0, 0x05, 0x00, - 0xb5, 0x75 }, -}; - -void sub_080A6F6C(u32); -void PauseMenu_ItemMenu_Update(void) { - static const u8 gUnk_08128BF4[] = { 14, 15, 2, 0 }; - u32 item; - u32 menuSlot; - const ItemMenuTableEntry* entry; - - if (sub_080A51F4()) { - gMenu.field_0xc = (u8*)gUnk_08128BF4; - menuSlot = gMenu.field_0x3; - - entry = &gItemMenuTable[menuSlot]; - switch (gInput.newKeys) { - case A_BUTTON: - if (menuSlot == MENU_SLOT_SAVE_BUTTON) { -#if defined(DEMO_USA) || defined(DEMO_JP) - SoundReq(SFX_MENU_ERROR); -#else - sub_080A4E84(0xb); - SoundReq(SFX_TEXTBOX_SELECT); -#endif - break; - } - case B_BUTTON: - if (gPauseMenu.items[menuSlot] != 0) { - u32 slot = !!(gInput.newKeys ^ 1); - ForceEquipItem(gPauseMenu.items[menuSlot], slot); - SoundReq(SFX_TEXTBOX_SELECT); - } - break; - default: - switch (gInput.unk4) { - case DPAD_UP: - menuSlot = entry->up; - break; - case DPAD_DOWN: - menuSlot = entry->down; - break; - case DPAD_LEFT: - menuSlot = entry->left; - break; - case DPAD_RIGHT: - menuSlot = entry->right; - break; - } - break; - } - if (gMenu.field_0x3 != menuSlot) { - gMenu.field_0x3 = menuSlot; - SoundReq(SFX_TEXTBOX_CHOICE); - } - item = gPauseMenu.items[menuSlot]; - switch (menuSlot) { - case MENU_SLOT_BOTTLE0: - case MENU_SLOT_BOTTLE1: - case MENU_SLOT_BOTTLE2: - case MENU_SLOT_BOTTLE3: - if (item != 0) { - item = gSave.saved_status.field_0x24[item - 6]; - } - break; - case MENU_SLOT_SAVE_BUTTON: - // ITEM_SKILL_FAST_SPIN, but that does not make any sense at all - item = 0x73; - break; - default: - break; - } - sub_080A6F6C(item + 0x400); - } -} - -u32 GetMenuSlotForItem(u32 item); -extern u8* gSpriteAnimations_322[]; -#ifdef EU -#define sub_080A5384_draw_constant0 0x1fa -#define sub_080A5384_draw_constant1 0x141 -#else -#define sub_080A5384_draw_constant0 0x1fb -#define sub_080A5384_draw_constant1 0x142 -#endif -void PauseMenu_ItemMenu_Draw(void) { - u32 tmp; - u32 i; - s32 color; - const ItemMenuTableEntry* entry; - - gOamCmd._4 = 0x400; - gOamCmd._6 = 0; - gOamCmd._8 = 0; - for (i = 0; i < MENU_SLOT_COUNT; i++) { - u32 item; - if (gPauseMenu.items[i] != 0) { - entry = &gItemMenuTable[i]; - gOamCmd.x = entry->x; - gOamCmd.y = entry->y; - item = gPauseMenu.items[i]; - switch (item) { - case ITEM_BOTTLE1: - case ITEM_BOTTLE2: - case ITEM_BOTTLE3: - case ITEM_BOTTLE4: - item = gSave.stats.bottles[item - ITEM_BOTTLE1]; - break; - default: - break; - } - color = 3; - switch (item) { - case ITEM_BOMBS: - case ITEM_REMOTE_BOMBS: - if (gBombBagSizes[gSave.stats.bombBagType] <= gSave.stats.bombCount) { - color = 4; - } - break; - case ITEM_BOW: - case ITEM_LIGHT_ARROW: - if (gQuiverSizes[gSave.stats.quiverType] <= gSave.stats.arrowCount) { - color = 4; - } - break; - default: - break; - } - gOamCmd._8 = 0x800 | color << 0xc | ((i * 8) + 0x360); - DrawDirect(sub_080A5384_draw_constant1, *gSpriteAnimations_322[item]); - } - } - gOamCmd._8 = 0x800; - { - u32 slot = gMenu.field_0x3; - if ((slot == MENU_SLOT_SAVE_BUTTON) && (gSaveHeader->language != 0)) { - slot = MENU_SLOT_SAVE_BUTTON_JP; - } - entry = &gItemMenuTable[slot]; - gOamCmd.x = entry->x; - gOamCmd.y = entry->y; - tmp = entry->type + ((gMain.ticks & 0x10) != 0 ? 3 : 4); - DrawDirect(sub_080A5384_draw_constant0, tmp); - } - { - u32 slot; - if (gSaveHeader->language != 0) { - slot = MENU_SLOT_SAVE_BUTTON; - } else { - slot = MENU_SLOT_SAVE_BUTTON_JP; - } - entry = &gItemMenuTable[slot]; - gOamCmd.x = entry->x; - gOamCmd.y = entry->y; - gOamCmd._8 = 0x800; - DrawDirect(sub_080A5384_draw_constant0, 0x22); - } - i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_A]); - if (i < MENU_SLOT_COUNT) { - entry = &gItemMenuTable[i]; - gOamCmd.x = entry->x; - gOamCmd.y = entry->y; - DrawDirect(sub_080A5384_draw_constant0, 3); - } - i = GetMenuSlotForItem(gSave.stats.itemButtons[SLOT_B]); - if (i < MENU_SLOT_COUNT) { - entry = &gItemMenuTable[i]; - gOamCmd.x = entry->x; - gOamCmd.y = entry->y; - DrawDirect(sub_080A5384_draw_constant0, 3); - } -} - -u32 GetMenuSlotForItem(u32 item) { - u32 i; - - if (item != 0) { - for (i = 0; i < MENU_SLOT_COUNT; i++) { - if (item == gPauseMenu.items[i]) - return i; - } - } - return MENU_SLOT_SAVE_BUTTON_JP; -} - -Subtask sub_080A5594; -Subtask sub_080A56A0; -void PauseMenu2(void) { - static Subtask* const pauseMenu2_Types[] = { - sub_080A5594, - sub_080A56A0, - }; - pauseMenu2_Types[gMenu.menuType](); - sub_080A57F4(); -} |
