diff --git a/include/dungeon_menu_items.h b/include/dungeon_menu_items.h new file mode 100644 index 000000000..ee8424def --- /dev/null +++ b/include/dungeon_menu_items.h @@ -0,0 +1,11 @@ +#ifndef GUARD_DUNGEON_MENU_ITEMS_H +#define GUARD_DUNGEON_MENU_ITEMS_H + +#include "dungeon_main.h" +#include "structs/dungeon_entity.h" + +bool8 sub_805FD3C(struct UnkMenuBitsStruct *a0); +bool8 ShowDungeonItemsMenu(Entity * a0, struct UnkMenuBitsStruct *a1); +void sub_8060D24(UNUSED ActionContainer *a0); + +#endif diff --git a/ld_script.txt b/ld_script.txt index 948551853..00d58f768 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -228,8 +228,9 @@ SECTIONS { src/move_checks.o(.text); src/dungeon_main.o(.text); src/dungeon_submenu.o(.text); - src/code_805D8C8_2.o(.text); + src/dungeon_menu_items.o(.text); src/code_805D8C8_3.o(.text); + src/dungeon_menu_moves.o(.text); asm/code_805D8C8.o(.text); src/code_8066D04.o(.text); src/code_805D8C8.o(.text); @@ -546,7 +547,7 @@ SECTIONS { data/data_8106A4C_0.o(.rodata); src/dungeon_main.o(.rodata); src/dungeon_submenu.o(.rodata); - src/code_805D8C8_2.o(.rodata); + src/dungeon_menu_items.o(.rodata); src/code_805D8C8_3.o(.rodata); data/data_8106A4C.o(.rodata); src/code_8066D04.o(.rodata); diff --git a/src/code_805D8C8_3.c b/src/code_805D8C8_3.c index a5dfa4b40..3942d0f6d 100644 --- a/src/code_805D8C8_3.c +++ b/src/code_805D8C8_3.c @@ -90,7 +90,6 @@ bool8 sub_8044B28(void); bool8 IsNotAttacking(Entity *param_1, bool8 param_2); void ShowMainMenu(bool8 fromBPress, bool8 a1); bool8 sub_805EF60(Entity *a0, EntityInfo *a1); -s32 GetTeamMemberEntityIndex(Entity *pokemon); bool8 sub_8070F80(Entity * pokemon, s32 direction); void PrintOnMainMenu(bool8 printAll); bool8 ShowDungeonItemsMenu(Entity * a0, struct UnkMenuBitsStruct *a1); @@ -179,16 +178,13 @@ extern WindowHeader gUnknown_202F270; s32 sub_8060D64(s16 *a0, bool8 a1, bool8 a2, bool8 a3, Entity *a4); -void sub_8060890(DungeonPos *a0); -bool8 sub_8060860(s32 a0); void sub_8060900(Entity *a0); s32 sub_8060800(WindowHeader *a0, s32 a1); void ChosenSubMenuToAction(ActionContainer *a0); Entity *DrawFieldGiveItemMenu(s32 *teamId, s32 a1); -static UNUSED EWRAM_DATA u8 sUnused3[4] = {0}; EWRAM_DATA s32 gTeamMenuChosenId = 0; -static UNUSED EWRAM_DATA u8 sUnused4[4] = {0}; +static UNUSED EWRAM_DATA u8 sUnused[4] = {0}; EWRAM_INIT u8 gUnknown_203B43C[4] = {2, 0, 0xD, 0}; // TODO: Move to a better file and figure out the array count. Apparently it's only written to. @@ -1355,7 +1351,6 @@ void sub_80625A4(s32 count, struct subStruct_203B240 **strings) #include "code_8097DD0.h" #include "move_util.h" -#include "move_util.h" extern const u8 *const gUnknown_80FE95C; extern const u8 *const gUnknown_80FE960; @@ -1810,444 +1805,3 @@ void sub_8062D8C(ActionContainer *a0) sub_806A2BC(entityOrg, 0); ChangeDungeonCameraPos(&entityOrg->pos, 0, 1, 1); } - -extern s32 gUnknown_202F2D8; -extern s32 sub_8044FB4(u16 param_1); - -void sub_80633E4(Entity *entity, EntityInfo *entInfo, u8 a2, Windows *windows, WindowHeader *header, u8 *arg5, s32 arg6, s32 arg7); -void sub_8063698(Entity *entity, u8 a1, u8 a2); -void sub_80637BC(ActionContainer *a0, s32 a1, s32 a2); -void sub_80637A4(ActionContainer *a0, s32 a1); - -bool8 ShowDungeonMovesMenu(Entity * entity, u8 a1, u8 a2, s32 a3, s32 a4) -{ - s32 i; - bool8 ret; - EntityInfo *entInfo = GetEntInfo(entity); - bool8 unkBool = TRUE; - EntityInfo *leaderInfo = GetEntInfo(GetLeader()); - WindowHeader header; - Windows windows = { - .id = { - [0] = { - .type = WINDOW_TYPE_WITH_HEADER, - .pos = {2, 2}, - .width = 18, - .height = 16, - .unk10 = 16, - .unk12 = 0, - .unk14 = &header, - }, - [1] = WINDOW_DUMMY, - [2] = WINDOW_DUMMY, - [3] = WINDOW_DUMMY, - } - }; - u8 unk[4]; - bool8 r10; - s32 r5; - bool8 bPress; - - gUnknown_202F2D8 = 0; - for (i = 0; i < MAX_MON_MOVES; i++) { - Move *move = &entInfo->moves.moves[i]; - - if (MoveFlagExists(move) && move->moveFlags2 & 2) { - move->moveFlags2 &= ~(2); - gUnknown_202F2D8 = i; - } - } - - while (1) { - r5 = 0; - ret = FALSE; - r10 = FALSE; - sub_80633E4(entity, entInfo, a1, &windows, &header, unk, a3, a4); - while (1) { - AddMenuCursorSprite_(&gDungeonMenu, unk); - DungeonRunFrameActions(0x1E); - if (gRealInputs.repeated & DPAD_DOWN) { - bool8 rHeld = (gRealInputs.held & R_BUTTON) != 0; - s32 id = gDungeonMenu.menuIndex; - - if (rHeld) { - gUnknown_202F2D8 = unk_SetMoveToLastInLinkedSequence4(entInfo->moves.moves, id); - if (id != gUnknown_202F2D8) { - PlayDungeonCursorSE(0); - } - else { - PlayDungeonCancelSE(); - } - r10 = TRUE; - break; - } - else { - sub_8013780(&gDungeonMenu, unk_FindMoveEnabledForAIAfter4(entInfo->moves.moves, id)); - if (id != gDungeonMenu.menuIndex) { - PlayDungeonCursorSE(0); - } - } - } - if (gRealInputs.repeated & DPAD_UP) { - bool8 rHeld = (gRealInputs.held & R_BUTTON) != 0; - s32 id = gDungeonMenu.menuIndex; - - if (rHeld) { - gUnknown_202F2D8 = unk_SetMoveToFirstInLinkedSequence4(entInfo->moves.moves, id); - if (id != gUnknown_202F2D8) { - PlayDungeonCursorSE(0); - } - else { - PlayDungeonCancelSE(); - } - r10 = TRUE; - break; - } - else { - sub_8013780(&gDungeonMenu, sub_8092DB8(entInfo->moves.moves, id)); - if (id != gDungeonMenu.menuIndex) { - PlayDungeonCursorSE(0); - } - } - } - - if ((gRealInputs.repeated & DPAD_RIGHT) || gDungeonMenu.unk28.dpad_right) { - SetMonsterActionFields(&leaderInfo->action, 6); - break; - } - if ((gRealInputs.repeated & DPAD_LEFT) || gDungeonMenu.unk28.dpad_left) { - SetMonsterActionFields(&leaderInfo->action, 7); - break; - } - - if ((gRealInputs.pressed & sub_8062D88()) || gDungeonMenu.unk28.a_button) { - if (a1) { - bool8 rHeld = (gRealInputs.held & R_BUTTON) != 0; - if (rHeld) { - r5 = 3; - } - } - PlayDungeonConfirmationSE(); - break; - } - - if (gRealInputs.pressed & START_BUTTON) { - r5 = 1; - PlayDungeonStartButtonSE(); - break; - } - if (gRealInputs.pressed & SELECT_BUTTON) { - r5 = 2; - PlayDungeonStartButtonSE(); - break; - } - // Fixme: r0/r1 regswap... - { - u32 bPressed = B_BUTTON; - bPressed &= gRealInputs.pressed; - if ((bPressed) || gDungeonMenu.unk28.b_button) { - PlayDungeonCancelSE(); - ret = TRUE; - break; - } - } - } - - AddMenuCursorSprite(&gDungeonMenu); - DungeonRunFrameActions(0x1E); - if (leaderInfo->action.action == 6 || leaderInfo->action.action == 7) { - unkBool = FALSE; - break; - } - - if (r10) - continue; - if (ret) - break; - - gUnknown_202F2D8 = gDungeonMenu.menuIndex; - if (r5 == 1) { - SetMonsterActionFields(&leaderInfo->action, 0x1D); - leaderInfo->action.actionParameters[0].actionUseIndex = entity->unk24; - leaderInfo->action.actionParameters[1].actionUseIndex = gUnknown_202F2D8; - sub_803EAF0(0, NULL); - sub_803E708(8, 0x1B); - ret = FALSE; - break; - } - - sub_8063698(entity, a1, a2); - if (r5 == 3) { - s32 r6 = sub_8044FB4(0x20); - if (!CanSubMenuItemBeChosen(r6)) { - r6 = sub_8044FB4(0x21); - if (CanSubMenuItemBeChosen(r6)) { - sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); - break; - } - } - else { - sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); - break; - } - } - else if (r5 == 2) { - if (entInfo->isTeamLeader) { - s32 r6 = sub_8044FB4(0x1E); - if (!CanSubMenuItemBeChosen(r6)) { - r6 = sub_8044FB4(0x33); - if (CanSubMenuItemBeChosen(r6)) { - sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); - break; - } - } - else { - sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); - break; - } - } - else { - s32 r6 = sub_8044FB4(0x1F); - if (CanSubMenuItemBeChosen(r6)) { - sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); - break; - } - } - } - - sub_8009524(2); - CreateDungeonMenuSubWindow(&windows.id[0], 0x16); - while (1) { - AddMenuCursorSprite(&gDungeonMenu); - DungeonRunFrameActions(0x1B); - if (gRealInputs.repeated & DPAD_DOWN) { - PlayDungeonCursorSE(1); - MoveMenuCursorDownWrapAround(&gDungeonMenu, TRUE); - } - if (gRealInputs.repeated & DPAD_UP) { - PlayDungeonCursorSE(1); - MoveMenuCursorUpWrapAround(&gDungeonMenu, TRUE); - } - - if ((gRealInputs.pressed & sub_8062D88()) || gDungeonMenu.unk28.a_button) { - if (CanSubMenuItemBeChosen(gDungeonMenu.menuIndex)) { - sub_80637A4(&leaderInfo->action, GetTeamMemberEntityIndex(entity)); - if (leaderInfo->action.action != 20 && leaderInfo->action.action != 21) { - PlayDungeonConfirmationSE(); - } - bPress = FALSE; - break; - } - PlayDungeonCancelSE(); - } - if ((gRealInputs.pressed & B_BUTTON) || gDungeonMenu.unk28.b_button) { - PlayDungeonCancelSE(); - bPress = TRUE; - break; - } - } - - AddMenuCursorSprite(&gDungeonMenu); - DungeonRunFrameActions(0x1B); - if (bPress != TRUE) { - ret = 0; - break; - } - } - - if (unkBool) { - sub_803EAF0(0, NULL); - sub_803E708(8, 0x1E); - } - - return ret; -} - -extern const Window gUnknown_8106CAC; -void sub_8063578(s32 a0, Entity *entity, Moves *moves, s32 a3, u8 a4, s32 a5); -extern const u8 *const gUnknown_80FDFE8; - -void sub_80633E4(Entity *entity, EntityInfo *entInfo, u8 a2, Windows *windows, WindowHeader *header, u8 *arg5, s32 arg6, s32 arg7) -{ - s32 i, movesCount; - Window windowNew = gUnknown_8106CAC; - - header->f0 = arg7; - header->f1 = arg6; - header->f3 = 0; - - movesCount = 0; - for (i = 0; i < MAX_MON_MOVES; i++) { - Move *move = &entInfo->moves.moves[i]; - if (MoveFlagExists(move)) { - movesCount++; - } - } - - gDungeonMenu.menuIndex = gUnknown_202F2D8; - gDungeonMenu.unk1A = movesCount; - gDungeonMenu.unk1C = 4; - gDungeonMenu.unk1E = arg6; - gDungeonMenu.unk20 = arg7; - gDungeonMenu.unk4 = 0; - gDungeonMenu.firstEntryY = 16; - gDungeonMenu.unk14.x = 0; - gDungeonMenu.unk0 = 0; - sub_801317C(&gDungeonMenu.unk28); - - windows->id[0].height = windows->id[0].unk10 = sub_80095E4(4, 0xC) + 2; - header->f2 = 13; - windows->id[0].pos.x = 2; - windows->id[1] = windows->id[3]; - windows->id[2] = windowNew; - DungeonShowWindows(windows, TRUE); - sub_80137B0(&gDungeonMenu, 0); - gDungeonMenu.unkC = (gUnknown_2027370[0].unk0 + 16) * 8; - gDungeonMenu.unkE = ((gUnknown_2027370[0].unk2 + 1) * 8) - 2; - SetMessageArgument_2(gFormatBuffer_Monsters[0], entInfo, 0); - for (i = 0; i < MAX_MON_MOVES; i++) { - Move *move = &entInfo->moves.moves[i]; - - arg5[i] = 0; - if (!MoveFlagExists(move)) { - if (gDungeonMenu.menuIndex == i) { - gDungeonMenu.menuIndex = 0; - } - } - else if (MoveFlagLinkChain(move)) { - arg5[i] = 1; - } - } - - sub_8063578(4, entity, &entInfo->moves, 0, a2, arg6); - sub_80073B8(2); - PrintFormattedStringOnWindow(4, 0, gUnknown_80FDFE8, 2, '\0'); - sub_80073E0(2); -} - -extern const u8 gUnknown_8106CC4[]; - -void sub_8063578(s32 count, Entity *entity, Moves *moves, s32 windowId, u8 a4, s32 a5) -{ - s32 i; - EntityInfo *entInfo = GetEntInfo(entity); - - sub_80073B8(windowId); - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], entity, 0); - PrintFormattedStringOnWindow((a5 * 8) + 10, 0, gUnknown_80FE978, windowId, '\0'); - for (i = 0; i < count; i++) { - s32 x, y; - unkStruct_80928C0 movStruct = {0, 106, 0, a4}; - Move *move = &moves->moves[i]; - - if (MoveFlagExists(move)) { - if (entInfo->isTeamLeader) { - movStruct.unk0 = 2; - } - else { - movStruct.unk0 = 4; - } - - movStruct.unk8 = (CanMonsterUseMove(entity, move, TRUE) == FALSE); - BufferMoveName(gFormatBuffer_Items[0], move, &movStruct); - y = GetMenuEntryYCoord(&gDungeonMenu, i); - if (MoveFlagLinkChain(move)) { - x = 13; - } - else { - x = 8; - if (i != 0) { - sub_80078A4(windowId, 12, y - 2, 120, 7); - } - } - PrintFormattedStringOnWindow(x, y, gUnknown_8106CC4, windowId, '\0'); - } - } - - sub_80073E0(windowId); -} - -bool8 sub_8063C88(EntityInfo *entInfo, s32 a1); -bool8 sub_8063DD4(EntityInfo *entInfo, s32 a1); - -void sub_8063698(Entity *entity, u8 a1, u8 a2) -{ - EntityInfo *entInfo = GetEntInfo(entity); - Move *move = &entInfo->moves.moves[gUnknown_202F2D8]; - - gDungeonSubMenuItemsCount = 0; - if (entInfo->isTeamLeader) { - if (a2) { - sub_8044F5C(0x14, 0); - } - if (MoveFlagExists(move)) { - if (MoveFlagSet(move)) { - sub_8044F5C(0x33, 0); - } - else { - sub_8044F5C(0x1E, 0); - } - } - } - else { - sub_8044F5C(0x1F, 0); - } - - if (a1) { - sub_8044F5C(0x20, 0); - sub_8044F5C(0x21, 0); - } - sub_8044F5C(0x1D, 0); - if (!a1) { - sub_8044FF0(0x20); - } - else { - if (!sub_8063C88(entInfo, gUnknown_202F2D8)) { - sub_8044FF0(0x20); - } - if (!sub_8063DD4(entInfo, gUnknown_202F2D8)) { - sub_8044FF0(0x21); - } - } - - if (!sub_8063DD4(entInfo, gUnknown_202F2D8)) { - sub_8044FF0(0x21); - } - - if (a2) { - bool8 unkBool = FALSE; - if (gUnknown_202F2D8 < MAX_MON_MOVES) { - unkBool = CanAIUseMove(entity, gUnknown_202F2D8, TRUE) != FALSE; - } - if (!unkBool) { - sub_8044FF0(0x14); - } - } - - sub_8045064(); -} - -void sub_80637A4(ActionContainer *a0, s32 a1) -{ - sub_80637BC(a0, gDungeonMenu.menuIndex, a1); -} - -void sub_80637BC(ActionContainer *a0, s32 a1, s32 a2) -{ - SetMonsterActionFields(a0, gUnknown_202EE44[a1].unk0); - a0->actionParameters[0].actionUseIndex = a2; - a0->actionParameters[1].actionUseIndex = gUnknown_202F2D8; -} - -void sub_8063834(Move *moves, s32 a1, s32 a2); - -void sub_80637E8(ActionContainer *a0) -{ - Entity *mon = gDungeon->teamPokemon[a0->actionParameters[0].actionUseIndex]; - EntityInfo *monInfo = GetEntInfo(mon); - - monInfo->moves.moves[a0->actionParameters[1].actionUseIndex].moveFlags2 |= 2; - sub_8063834(monInfo->moves.moves, a0->actionParameters[1].actionUseIndex, 4); -} - -// diff --git a/src/dungeon_main.c b/src/dungeon_main.c index d40f0799b..087d0b500 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -43,6 +43,7 @@ #include "code_8044CC8.h" #include "code_801B3C0.h" #include "dungeon_capabilities.h" +#include "dungeon_menu_items.h" #include "constants/dungeon.h" #include "constants/status.h" #include "constants/tactic.h" @@ -84,12 +85,9 @@ bool8 sub_8094C48(void); void sub_803E724(s32 a0); void HandleTalkFieldAction(Entity *); bool8 sub_8044B28(void); -bool8 sub_805FD3C(struct UnkMenuBitsStruct *a0); bool8 IsNotAttacking(Entity *param_1, bool8 param_2); s32 GetTeamMemberEntityIndex(Entity *pokemon); bool8 sub_8070F80(Entity * pokemon, s32 direction); -bool8 ShowDungeonItemsMenu(Entity * a0, struct UnkMenuBitsStruct *a1); -void sub_8060D24(UNUSED ActionContainer *a0); bool8 ShowDungeonTeamMenu(Entity *a0); void sub_8062D8C(ActionContainer *a0); void sub_80637E8(ActionContainer *a0); @@ -105,6 +103,17 @@ void ChangeDungeonCameraPos(DungeonPos *pos, s32 a1, u8 a2, u8 a3); extern bool8 sub_8071A8C(Entity *pokemon); extern void sub_80643AC(Entity *pokemon); extern bool8 ShowDungeonMovesMenu(Entity * entity, u8 a1, u8 a2, s32 a3, s32 a4); +extern void GetWeatherName(u8 *dst, u8 weatherId); +extern bool8 sub_8070F14(Entity * pokemon, s32 direction); +extern Entity *sub_80696A8(Entity *a0); +extern u8 sub_806A538(s32); +extern void sub_803EAF0(u32, u8 *); +extern void sub_803F508(Entity *); +extern void sub_8041AD0(Entity *pokemon); +extern void sub_8041AE0(Entity *pokemon); +extern void sub_807EC28(bool8); +extern void PlayDungeonCursorSE(u8 param_1); +extern const u8 *GetCurrentDungeonName(void); extern u8 gUnknown_202EE00; extern Entity *gLeaderPointer; @@ -129,7 +138,6 @@ extern const u8 *gTeamToolboxBPtr; extern const u8 *gFieldItemMenuGroundTextPtr; extern const u8 *gUnknown_80FE940; extern const u8 *gWhichTextPtr1; - extern const u8 *const gFieldMenuMovesPtr; extern const u8 *const gFieldMenuItemsPtr; extern const u8 *const gFieldMenuTeamPtr; @@ -142,19 +150,6 @@ extern const u8 *const gUnknown_80F91E0; extern const u8 *const gUnknown_80F91A8; extern const u8 *const gUnknown_80FE954; -const u8 *GetCurrentDungeonName(void); -void GetWeatherName(u8 *dst, u8 weatherId); - -extern bool8 sub_8070F14(Entity * pokemon, s32 direction); -extern Entity *sub_80696A8(Entity *a0); -extern u8 sub_806A538(s32); -extern void sub_803EAF0(u32, u8 *); -extern void sub_803F508(Entity *); -extern void sub_8041AD0(Entity *pokemon); -extern void sub_8041AE0(Entity *pokemon); -extern void sub_807EC28(bool8); -extern void PlayDungeonCursorSE(u8 param_1); - extern MenuInputStruct gDungeonMenu; extern s32 gTeamMenuChosenId; @@ -1675,5 +1670,3 @@ bool8 DungeonGiveNameToRecruitedMon(u8 *a0) return FALSE; } - - diff --git a/src/code_805D8C8_2.c b/src/dungeon_menu_items.c similarity index 85% rename from src/code_805D8C8_2.c rename to src/dungeon_menu_items.c index 133e5f7fc..4dbfae777 100644 --- a/src/code_805D8C8_2.c +++ b/src/dungeon_menu_items.c @@ -1,151 +1,41 @@ #include "global.h" #include "globaldata.h" +#include "dungeon_menu_items.h" #include "structs/str_dungeon.h" -#include "number_util.h" #include "input.h" #include "structs/map.h" #include "dungeon_main.h" #include "dungeon_message.h" #include "dungeon_action.h" -#include "dungeon_ai_targeting.h" #include "dungeon_pokemon_attributes.h" -#include "dungeon_random.h" #include "dungeon_util.h" #include "pokemon.h" -#include "moves.h" #include "items.h" #include "dungeon_music.h" #include "dungeon_ai_movement.h" #include "code_8045A00.h" #include "string_format.h" #include "code_803E46C.h" -#include "code_801602C.h" -#include "code_800D090.h" #include "trap.h" -#include "charge_move.h" #include "dungeon_map_access.h" #include "status_checks_1.h" -#include "game_options.h" -#include "weather.h" #include "dungeon_items.h" #include "dungeon_leader.h" #include "tile_types.h" -#include "dungeon_visibility.h" -#include "dungeon_movement.h" -#include "bg_control.h" #include "menu_input.h" -#include "music.h" -#include "items.h" -#include "play_time.h" -#include "pokemon_3.h" #include "text.h" -#include "code_806CD90.h" #include "code_8044CC8.h" #include "code_801B3C0.h" #include "dungeon_capabilities.h" -#include "constants/dungeon.h" -#include "constants/status.h" -#include "constants/tactic.h" -#include "constants/iq_skill.h" -#include "constants/dungeon_action.h" -#include "structs/struct_sub80095e4.h" -#include "structs/str_text.h" -extern void HandleSetItemAction(Entity *,bool8); -extern void HandleUnsetItemAction(Entity *,bool8); -extern bool8 sub_8048A68(Entity *param_1,Item *item); -extern bool8 sub_8048950(Entity *param_1,Item *item); -extern bool8 sub_8048B9C(Entity *param_1,Item *item); -extern Item *sub_8044D90(Entity *, s32, u32); extern void PlayDungeonStartButtonSE(void); extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); -extern void sub_806A6E8(Entity *); -extern bool8 sub_8047084(s32 itemFlag); -extern void HandleTrap(Entity *pokemon, DungeonPos *pos, int param_3, char param_4); -extern void sub_8045DB4(DungeonPos *, u32); -bool8 sub_807EF48(void); -void sub_806A2BC(Entity *a0, u8 a1); -bool8 sub_805E874(void); -bool8 sub_80701A4(Entity *a0); -void ShowDungeonStairsMenu(Entity *a0); -void sub_805E738(Entity *a0); -void sub_803E708(s32 a0, s32 a1); -void sub_8040A78(void); -void sub_805E804(void); -void ShowDungeonOthersMenu(void); -void sub_8075680(u32); -void sub_8094C88(void); -void sub_8040A84(void); -void sub_8047158(void); -void sub_806A914(u8 a0, u8 a1, u8 a2); -void SetLeaderActionToNothing(u8 a0); -u16 GetLeaderActionId(void); -void sub_80978C8(s16 a0); -bool8 sub_8094C48(void); -bool8 sub_805EC4C(Entity *a0, u8 a1); -void sub_803E724(s32 a0); -void HandleTalkFieldAction(Entity *); -bool8 sub_8044B28(void); -bool8 IsNotAttacking(Entity *param_1, bool8 param_2); -void ShowMainMenu(bool8 fromBPress, bool8 a1); -bool8 sub_805EF60(Entity *a0, EntityInfo *a1); -s32 GetTeamMemberEntityIndex(Entity *pokemon); -bool8 sub_8070F80(Entity * pokemon, s32 direction); -void PrintOnMainMenu(bool8 printAll); -bool8 ShowDungeonItemsMenu(Entity * a0, struct UnkMenuBitsStruct *a1); -void sub_8060D24(UNUSED ActionContainer *a0); -bool8 ShowDungeonTeamMenu(Entity *a0); -void sub_8062D8C(ActionContainer *a0); -void sub_80637E8(ActionContainer *a0); -void sub_8063B54(ActionContainer *a0); -void sub_8063BB4(ActionContainer *a0); -void sub_806752C(ActionContainer *a0); -void sub_8061A38(ActionContainer *a0, bool8 a1); -void sub_8063A70(ActionContainer *a0, bool8 a1); -void sub_8063CF0(ActionContainer *a0, bool8 a1); -void sub_8067768(ActionContainer *a0); -void ShowTacticsMenu(ActionContainer *a0); -void ChangeDungeonCameraPos(DungeonPos *pos, s32 a1, u8 a2, u8 a3); -extern bool8 sub_8071A8C(Entity *pokemon); -extern void sub_80643AC(Entity *pokemon); -extern bool8 ShowDungeonMovesMenu(Entity * entity, u8 a1, u8 a2, s32 a3, s32 a4); - -extern u8 gUnknown_202EE00; -extern Entity *gLeaderPointer; - -extern const u8 *gUnknown_80F8A84; -extern const u8 *gUnknown_80F8A6C; -extern const u8 *gUnknown_80F8ADC; -extern const u8 *gUnknown_80F8AB0; -extern const u8 *gUnknown_80F8B0C; -extern const u8 *gUnknown_80FD4B0; -extern const u8 *gUnknown_80F8A4C; -extern const u8 *gUnknown_80F8A28; -extern const u8 *gUnknown_8100208; -extern const u8 *gUnknown_80F9BD8; -extern const u8 *gUnknown_80F9C08; -extern const u8 *gUnknown_80F9C2C; -extern const u8 *gUnknown_80F9BB0; -extern const u8 *gUnknown_80FDE18; -extern const u8 *gUnknown_80F8B24; -extern const u8 *gTeamToolboxAPtr; -extern const u8 *gTeamToolboxBPtr; -extern const u8 *gFieldItemMenuGroundTextPtr; -extern const u8 *gUnknown_80FE940; -extern const u8 *gWhichTextPtr1; -extern const u8 *const gFieldMenuMovesPtr; -extern const u8 *const gFieldMenuItemsPtr; -extern const u8 *const gFieldMenuTeamPtr; -extern const u8 *const gFieldMenuOthersPtr; -extern const u8 *const gFieldMenuGroundPtr; -extern const u8 *const gUnknown_80F9174; -extern const u8 *const gUnknown_80F9190; -extern const u8 *const gUnknown_80F91C8; -extern const u8 *const gUnknown_80F91E0; -extern const u8 *const gUnknown_80F91A8; -extern const u8 *const gUnknown_80FE954; - +extern void sub_806A2BC(Entity *a0, u8 a1); +extern void SetLeaderActionToNothing(u8 a0); +extern void sub_803E708(s32 a0, s32 a1); +extern void sub_8047158(void); +extern Item *sub_8044D90(Entity *, s32, u32); extern bool8 sub_8070F14(Entity * pokemon, s32 direction); bool8 sub_805EC2C(Entity *a0, s32 x, s32 y); extern Entity *sub_80696A8(Entity *a0); @@ -161,27 +51,40 @@ extern bool8 CanSubMenuItemBeChosen(s32 param_1); extern s32 gDungeonSubMenuItemsCount; extern const u8 gUnknown_8106B50[]; extern void DungeonShowWindows(Windows *a0, u8 a1); +extern Item * sub_8044CC8(Entity *param_1, ActionParameter *param_2, UNUSED s32 a3); +extern void sub_8044F5C(u16 param_1, u8 param_2); +extern void sub_8044FF0(u16 param_1); +extern u16 sub_8044DC8(Item *param_1); +extern bool8 sub_8046F00(Item *item); +extern void sub_8045064(void); +extern bool8 PosHasItem(DungeonPos *pos); +Entity *DrawFieldGiveItemMenu(s32 *teamId, s32 a1); + +extern u8 gUnknown_202EE00; +extern Entity *gLeaderPointer; extern MenuInputStruct gDungeonMenu; -s32 sub_8060D64(s16 *a0, bool8 a1, bool8 a2, bool8 a3, Entity *a4); +extern const u8 *gUnknown_80F8B24; +extern const u8 *gTeamToolboxAPtr; +extern const u8 *gTeamToolboxBPtr; +extern const u8 *gFieldItemMenuGroundTextPtr; +extern const u8 *gUnknown_80FE940; +extern const u8 *gWhichTextPtr1; -void sub_8060890(DungeonPos *a0); -bool8 sub_8060860(s32 a0); -void sub_8060900(Entity *a0); -s32 sub_8060800(WindowHeader *a0, s32 a1); -void ChosenSubMenuToAction(ActionContainer *a0); -Entity *DrawFieldGiveItemMenu(s32 *teamId, s32 a1); - -// Could this be a start of a new file? -static UNUSED EWRAM_DATA u8 sUnused[4] = {0}; static EWRAM_DATA ActionParameter sUnknownActionUnk4 = {0}; static EWRAM_DATA s32 sUnknown_202F240 = 0; -static UNUSED EWRAM_DATA u8 sUnused2[4] = {0}; +static UNUSED EWRAM_DATA u8 sUnused[4] = {0}; static EWRAM_DATA s16 sUnknown_202F248[8] = {0}; static EWRAM_DATA s32 sUnknown_202F258 = 0; static void PrintOnDungeonItemsMenu(s32 a0, Entity *a1, bool8 a2, bool8 a3, Windows *a4, WindowHeader *a5); +static s32 sub_8060800(WindowHeader *a0, s32 a1); +static bool8 sub_8060860(s32 a0); +static void sub_8060890(DungeonPos *a0); +static void sub_8060900(Entity *a0); +static void ChosenSubMenuToAction(ActionContainer *a0); +static s32 sub_8060D64(s16 *a0, bool8 a1, bool8 a2, bool8 a3, Entity *a4); bool8 sub_805FD3C(struct UnkMenuBitsStruct *a0) { @@ -635,7 +538,7 @@ static void PrintOnDungeonItemsMenu(s32 a0, Entity *a1, bool8 showWhichWindow, b } } -s32 sub_8060800(WindowHeader *a0, s32 a1) +static s32 sub_8060800(WindowHeader *a0, s32 a1) { s32 i, r1, r2, r3; @@ -665,7 +568,7 @@ s32 sub_8060800(WindowHeader *a0, s32 a1) return r1; } -bool8 sub_8060860(s32 a0) +static bool8 sub_8060860(s32 a0) { if (gDungeonMenu.unk1A <= 1 || sUnknown_202F248[a0] > 1) return FALSE; @@ -673,7 +576,7 @@ bool8 sub_8060860(s32 a0) return TRUE; } -void sub_8060890(DungeonPos *a0) +static void sub_8060890(DungeonPos *a0) { s32 var = sUnknown_202F248[gDungeonMenu.unk1E]; switch (var) @@ -696,14 +599,7 @@ void sub_8060890(DungeonPos *a0) sUnknownActionUnk4.itemPos.y = a0->y; } -extern Item * sub_8044CC8(Entity *param_1, ActionParameter *param_2, UNUSED s32 a3); -extern void sub_8044F5C(u16 param_1, u8 param_2); -extern void sub_8044FF0(u16 param_1); -extern u16 sub_8044DC8(Item *param_1); -extern bool8 sub_8046F00(Item *item); -extern void sub_8045064(void); - -void sub_8060900(Entity *a0) +static void sub_8060900(Entity *a0) { u16 val_sub8044DC8; Item *item = sub_8044CC8(a0, &sUnknownActionUnk4, 0xA); @@ -889,7 +785,7 @@ void sub_8060900(Entity *a0) sub_8045064(); } -void ChosenSubMenuToAction(ActionContainer *a0) +static void ChosenSubMenuToAction(ActionContainer *a0) { SetMonsterActionFields(a0, gUnknown_202EE44[gDungeonMenu.menuIndex].unk0); a0->actionParameters[0] = sUnknownActionUnk4; @@ -912,9 +808,7 @@ void sub_8060D24(UNUSED ActionContainer *a0) sub_803EAF0(0, NULL); } -extern bool8 PosHasItem(DungeonPos *pos); - -s32 sub_8060D64(s16 *a0, bool8 a1, bool8 a2, bool8 a3, Entity *a4) +static s32 sub_8060D64(s16 *a0, bool8 a1, bool8 a2, bool8 a3, Entity *a4) { s32 i; s32 count = 0; @@ -943,6 +837,3 @@ s32 sub_8060D64(s16 *a0, bool8 a1, bool8 a2, bool8 a3, Entity *a4) return count; } - - - diff --git a/src/dungeon_menu_moves.c b/src/dungeon_menu_moves.c new file mode 100644 index 000000000..128fbc91c --- /dev/null +++ b/src/dungeon_menu_moves.c @@ -0,0 +1,515 @@ +#include "global.h" +#include "globaldata.h" +#include "structs/str_dungeon.h" +#include "number_util.h" +#include "input.h" +#include "structs/map.h" +#include "dungeon_main.h" +#include "dungeon_message.h" +#include "dungeon_action.h" +#include "dungeon_ai_targeting.h" +#include "dungeon_pokemon_attributes.h" +#include "dungeon_random.h" +#include "dungeon_util.h" +#include "pokemon.h" +#include "moves.h" +#include "items.h" +#include "dungeon_music.h" +#include "dungeon_ai_movement.h" +#include "code_8045A00.h" +#include "string_format.h" +#include "code_803E46C.h" +#include "code_801602C.h" +#include "code_800D090.h" +#include "trap.h" +#include "charge_move.h" +#include "dungeon_map_access.h" +#include "status_checks_1.h" +#include "game_options.h" +#include "weather.h" +#include "dungeon_items.h" +#include "dungeon_leader.h" +#include "tile_types.h" +#include "dungeon_visibility.h" +#include "dungeon_movement.h" +#include "bg_control.h" +#include "menu_input.h" +#include "music.h" +#include "items.h" +#include "play_time.h" +#include "pokemon_3.h" +#include "text.h" +#include "code_806CD90.h" +#include "code_8044CC8.h" +#include "code_801B3C0.h" +#include "move_util.h" +#include "dungeon_capabilities.h" +#include "constants/dungeon.h" +#include "constants/status.h" +#include "constants/tactic.h" +#include "constants/iq_skill.h" +#include "constants/dungeon_action.h" +#include "structs/struct_sub80095e4.h" +#include "structs/str_text.h" + +extern bool8 ShowDungeonMovesMenu(Entity * entity, u8 a1, u8 a2, s32 a3, s32 a4); +extern void PlayDungeonStartButtonSE(void); +extern void PlayDungeonCancelSE(void); +extern void PlayDungeonConfirmationSE(void); +extern void PlayDungeonCursorSE(u8 param_1); +extern u8 *GetDungeonSubMenuItemString(s32 param_1); +extern bool8 CanSubMenuItemBeChosen(s32 param_1); +extern void sub_8045064(void); +extern void sub_803EAF0(u32, u8 *); +extern void sub_803E708(s32 a0, s32 a1); +extern void sub_8044F5C(u16 param_1, u8 param_2); +extern void sub_8044FF0(u16 param_1); +extern void DungeonShowWindows(Windows *a0, u8 a1); +extern s32 GetTeamMemberEntityIndex(Entity *pokemon); +extern u32 sub_8062D88(void); + +extern s32 gDungeonSubMenuItemsCount; +extern MenuInputStruct gDungeonMenu; +extern WindowHeader gUnknown_202F270; +extern s32 gUnknown_202F2D8; +extern s32 sub_8044FB4(u16 param_1); + +extern const u8 *const gUnknown_80FE978; + +void sub_80633E4(Entity *entity, EntityInfo *entInfo, u8 a2, Windows *windows, WindowHeader *header, u8 *arg5, s32 arg6, s32 arg7); +void sub_8063698(Entity *entity, u8 a1, u8 a2); +void sub_80637BC(ActionContainer *a0, s32 a1, s32 a2); +void sub_80637A4(ActionContainer *a0, s32 a1); + +bool8 ShowDungeonMovesMenu(Entity * entity, u8 a1, u8 a2, s32 a3, s32 a4) +{ + s32 i; + bool8 ret; + EntityInfo *entInfo = GetEntInfo(entity); + bool8 unkBool = TRUE; + EntityInfo *leaderInfo = GetEntInfo(GetLeader()); + WindowHeader header; + Windows windows = { + .id = { + [0] = { + .type = WINDOW_TYPE_WITH_HEADER, + .pos = {2, 2}, + .width = 18, + .height = 16, + .unk10 = 16, + .unk12 = 0, + .unk14 = &header, + }, + [1] = WINDOW_DUMMY, + [2] = WINDOW_DUMMY, + [3] = WINDOW_DUMMY, + } + }; + u8 unk[4]; + bool8 r10; + s32 r5; + bool8 bPress; + + gUnknown_202F2D8 = 0; + for (i = 0; i < MAX_MON_MOVES; i++) { + Move *move = &entInfo->moves.moves[i]; + + if (MoveFlagExists(move) && move->moveFlags2 & 2) { + move->moveFlags2 &= ~(2); + gUnknown_202F2D8 = i; + } + } + + while (1) { + r5 = 0; + ret = FALSE; + r10 = FALSE; + sub_80633E4(entity, entInfo, a1, &windows, &header, unk, a3, a4); + while (1) { + AddMenuCursorSprite_(&gDungeonMenu, unk); + DungeonRunFrameActions(0x1E); + if (gRealInputs.repeated & DPAD_DOWN) { + bool8 rHeld = (gRealInputs.held & R_BUTTON) != 0; + s32 id = gDungeonMenu.menuIndex; + + if (rHeld) { + gUnknown_202F2D8 = unk_SetMoveToLastInLinkedSequence4(entInfo->moves.moves, id); + if (id != gUnknown_202F2D8) { + PlayDungeonCursorSE(0); + } + else { + PlayDungeonCancelSE(); + } + r10 = TRUE; + break; + } + else { + sub_8013780(&gDungeonMenu, unk_FindMoveEnabledForAIAfter4(entInfo->moves.moves, id)); + if (id != gDungeonMenu.menuIndex) { + PlayDungeonCursorSE(0); + } + } + } + if (gRealInputs.repeated & DPAD_UP) { + bool8 rHeld = (gRealInputs.held & R_BUTTON) != 0; + s32 id = gDungeonMenu.menuIndex; + + if (rHeld) { + gUnknown_202F2D8 = unk_SetMoveToFirstInLinkedSequence4(entInfo->moves.moves, id); + if (id != gUnknown_202F2D8) { + PlayDungeonCursorSE(0); + } + else { + PlayDungeonCancelSE(); + } + r10 = TRUE; + break; + } + else { + sub_8013780(&gDungeonMenu, sub_8092DB8(entInfo->moves.moves, id)); + if (id != gDungeonMenu.menuIndex) { + PlayDungeonCursorSE(0); + } + } + } + + if ((gRealInputs.repeated & DPAD_RIGHT) || gDungeonMenu.unk28.dpad_right) { + SetMonsterActionFields(&leaderInfo->action, 6); + break; + } + if ((gRealInputs.repeated & DPAD_LEFT) || gDungeonMenu.unk28.dpad_left) { + SetMonsterActionFields(&leaderInfo->action, 7); + break; + } + + if ((gRealInputs.pressed & sub_8062D88()) || gDungeonMenu.unk28.a_button) { + if (a1) { + bool8 rHeld = (gRealInputs.held & R_BUTTON) != 0; + if (rHeld) { + r5 = 3; + } + } + PlayDungeonConfirmationSE(); + break; + } + + if (gRealInputs.pressed & START_BUTTON) { + r5 = 1; + PlayDungeonStartButtonSE(); + break; + } + if (gRealInputs.pressed & SELECT_BUTTON) { + r5 = 2; + PlayDungeonStartButtonSE(); + break; + } + // Fixme: r0/r1 regswap... + { + u32 bPressed = B_BUTTON; + bPressed &= gRealInputs.pressed; + if ((bPressed) || gDungeonMenu.unk28.b_button) { + PlayDungeonCancelSE(); + ret = TRUE; + break; + } + } + } + + AddMenuCursorSprite(&gDungeonMenu); + DungeonRunFrameActions(0x1E); + if (leaderInfo->action.action == 6 || leaderInfo->action.action == 7) { + unkBool = FALSE; + break; + } + + if (r10) + continue; + if (ret) + break; + + gUnknown_202F2D8 = gDungeonMenu.menuIndex; + if (r5 == 1) { + SetMonsterActionFields(&leaderInfo->action, 0x1D); + leaderInfo->action.actionParameters[0].actionUseIndex = entity->unk24; + leaderInfo->action.actionParameters[1].actionUseIndex = gUnknown_202F2D8; + sub_803EAF0(0, NULL); + sub_803E708(8, 0x1B); + ret = FALSE; + break; + } + + sub_8063698(entity, a1, a2); + if (r5 == 3) { + s32 r6 = sub_8044FB4(0x20); + if (!CanSubMenuItemBeChosen(r6)) { + r6 = sub_8044FB4(0x21); + if (CanSubMenuItemBeChosen(r6)) { + sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); + break; + } + } + else { + sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); + break; + } + } + else if (r5 == 2) { + if (entInfo->isTeamLeader) { + s32 r6 = sub_8044FB4(0x1E); + if (!CanSubMenuItemBeChosen(r6)) { + r6 = sub_8044FB4(0x33); + if (CanSubMenuItemBeChosen(r6)) { + sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); + break; + } + } + else { + sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); + break; + } + } + else { + s32 r6 = sub_8044FB4(0x1F); + if (CanSubMenuItemBeChosen(r6)) { + sub_80637BC(&leaderInfo->action, r6, GetTeamMemberEntityIndex(entity)); + break; + } + } + } + + sub_8009524(2); + CreateDungeonMenuSubWindow(&windows.id[0], 0x16); + while (1) { + AddMenuCursorSprite(&gDungeonMenu); + DungeonRunFrameActions(0x1B); + if (gRealInputs.repeated & DPAD_DOWN) { + PlayDungeonCursorSE(1); + MoveMenuCursorDownWrapAround(&gDungeonMenu, TRUE); + } + if (gRealInputs.repeated & DPAD_UP) { + PlayDungeonCursorSE(1); + MoveMenuCursorUpWrapAround(&gDungeonMenu, TRUE); + } + + if ((gRealInputs.pressed & sub_8062D88()) || gDungeonMenu.unk28.a_button) { + if (CanSubMenuItemBeChosen(gDungeonMenu.menuIndex)) { + sub_80637A4(&leaderInfo->action, GetTeamMemberEntityIndex(entity)); + if (leaderInfo->action.action != 20 && leaderInfo->action.action != 21) { + PlayDungeonConfirmationSE(); + } + bPress = FALSE; + break; + } + PlayDungeonCancelSE(); + } + if ((gRealInputs.pressed & B_BUTTON) || gDungeonMenu.unk28.b_button) { + PlayDungeonCancelSE(); + bPress = TRUE; + break; + } + } + + AddMenuCursorSprite(&gDungeonMenu); + DungeonRunFrameActions(0x1B); + if (bPress != TRUE) { + ret = 0; + break; + } + } + + if (unkBool) { + sub_803EAF0(0, NULL); + sub_803E708(8, 0x1E); + } + + return ret; +} + +extern const Window gUnknown_8106CAC; +void sub_8063578(s32 a0, Entity *entity, Moves *moves, s32 a3, u8 a4, s32 a5); +extern const u8 *const gUnknown_80FDFE8; + +void sub_80633E4(Entity *entity, EntityInfo *entInfo, u8 a2, Windows *windows, WindowHeader *header, u8 *arg5, s32 arg6, s32 arg7) +{ + s32 i, movesCount; + Window windowNew = gUnknown_8106CAC; + + header->f0 = arg7; + header->f1 = arg6; + header->f3 = 0; + + movesCount = 0; + for (i = 0; i < MAX_MON_MOVES; i++) { + Move *move = &entInfo->moves.moves[i]; + if (MoveFlagExists(move)) { + movesCount++; + } + } + + gDungeonMenu.menuIndex = gUnknown_202F2D8; + gDungeonMenu.unk1A = movesCount; + gDungeonMenu.unk1C = 4; + gDungeonMenu.unk1E = arg6; + gDungeonMenu.unk20 = arg7; + gDungeonMenu.unk4 = 0; + gDungeonMenu.firstEntryY = 16; + gDungeonMenu.unk14.x = 0; + gDungeonMenu.unk0 = 0; + sub_801317C(&gDungeonMenu.unk28); + + windows->id[0].height = windows->id[0].unk10 = sub_80095E4(4, 0xC) + 2; + header->f2 = 13; + windows->id[0].pos.x = 2; + windows->id[1] = windows->id[3]; + windows->id[2] = windowNew; + DungeonShowWindows(windows, TRUE); + sub_80137B0(&gDungeonMenu, 0); + gDungeonMenu.unkC = (gUnknown_2027370[0].unk0 + 16) * 8; + gDungeonMenu.unkE = ((gUnknown_2027370[0].unk2 + 1) * 8) - 2; + SetMessageArgument_2(gFormatBuffer_Monsters[0], entInfo, 0); + for (i = 0; i < MAX_MON_MOVES; i++) { + Move *move = &entInfo->moves.moves[i]; + + arg5[i] = 0; + if (!MoveFlagExists(move)) { + if (gDungeonMenu.menuIndex == i) { + gDungeonMenu.menuIndex = 0; + } + } + else if (MoveFlagLinkChain(move)) { + arg5[i] = 1; + } + } + + sub_8063578(4, entity, &entInfo->moves, 0, a2, arg6); + sub_80073B8(2); + PrintFormattedStringOnWindow(4, 0, gUnknown_80FDFE8, 2, '\0'); + sub_80073E0(2); +} + +extern const u8 gUnknown_8106CC4[]; + +void sub_8063578(s32 count, Entity *entity, Moves *moves, s32 windowId, u8 a4, s32 a5) +{ + s32 i; + EntityInfo *entInfo = GetEntInfo(entity); + + sub_80073B8(windowId); + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], entity, 0); + PrintFormattedStringOnWindow((a5 * 8) + 10, 0, gUnknown_80FE978, windowId, '\0'); + for (i = 0; i < count; i++) { + s32 x, y; + unkStruct_80928C0 movStruct = {0, 106, 0, a4}; + Move *move = &moves->moves[i]; + + if (MoveFlagExists(move)) { + if (entInfo->isTeamLeader) { + movStruct.unk0 = 2; + } + else { + movStruct.unk0 = 4; + } + + movStruct.unk8 = (CanMonsterUseMove(entity, move, TRUE) == FALSE); + BufferMoveName(gFormatBuffer_Items[0], move, &movStruct); + y = GetMenuEntryYCoord(&gDungeonMenu, i); + if (MoveFlagLinkChain(move)) { + x = 13; + } + else { + x = 8; + if (i != 0) { + sub_80078A4(windowId, 12, y - 2, 120, 7); + } + } + PrintFormattedStringOnWindow(x, y, gUnknown_8106CC4, windowId, '\0'); + } + } + + sub_80073E0(windowId); +} + +bool8 sub_8063C88(EntityInfo *entInfo, s32 a1); +bool8 sub_8063DD4(EntityInfo *entInfo, s32 a1); + +void sub_8063698(Entity *entity, u8 a1, u8 a2) +{ + EntityInfo *entInfo = GetEntInfo(entity); + Move *move = &entInfo->moves.moves[gUnknown_202F2D8]; + + gDungeonSubMenuItemsCount = 0; + if (entInfo->isTeamLeader) { + if (a2) { + sub_8044F5C(0x14, 0); + } + if (MoveFlagExists(move)) { + if (MoveFlagSet(move)) { + sub_8044F5C(0x33, 0); + } + else { + sub_8044F5C(0x1E, 0); + } + } + } + else { + sub_8044F5C(0x1F, 0); + } + + if (a1) { + sub_8044F5C(0x20, 0); + sub_8044F5C(0x21, 0); + } + sub_8044F5C(0x1D, 0); + if (!a1) { + sub_8044FF0(0x20); + } + else { + if (!sub_8063C88(entInfo, gUnknown_202F2D8)) { + sub_8044FF0(0x20); + } + if (!sub_8063DD4(entInfo, gUnknown_202F2D8)) { + sub_8044FF0(0x21); + } + } + + if (!sub_8063DD4(entInfo, gUnknown_202F2D8)) { + sub_8044FF0(0x21); + } + + if (a2) { + bool8 unkBool = FALSE; + if (gUnknown_202F2D8 < MAX_MON_MOVES) { + unkBool = CanAIUseMove(entity, gUnknown_202F2D8, TRUE) != FALSE; + } + if (!unkBool) { + sub_8044FF0(0x14); + } + } + + sub_8045064(); +} + +void sub_80637A4(ActionContainer *a0, s32 a1) +{ + sub_80637BC(a0, gDungeonMenu.menuIndex, a1); +} + +void sub_80637BC(ActionContainer *a0, s32 a1, s32 a2) +{ + SetMonsterActionFields(a0, gUnknown_202EE44[a1].unk0); + a0->actionParameters[0].actionUseIndex = a2; + a0->actionParameters[1].actionUseIndex = gUnknown_202F2D8; +} + +void sub_8063834(Move *moves, s32 a1, s32 a2); + +void sub_80637E8(ActionContainer *a0) +{ + Entity *mon = gDungeon->teamPokemon[a0->actionParameters[0].actionUseIndex]; + EntityInfo *monInfo = GetEntInfo(mon); + + monInfo->moves.moves[a0->actionParameters[1].actionUseIndex].moveFlags2 |= 2; + sub_8063834(monInfo->moves.moves, a0->actionParameters[1].actionUseIndex, 4); +} + +// diff --git a/sym_ewram.txt b/sym_ewram.txt index 0e53d74a9..e569ad142 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -149,7 +149,9 @@ gUnknown_202EE76: /* 202EE76 (sub_804513C - sub_8082A08) */ .include "src/dungeon_message.o" .include "src/dungeon_move.o" .include "src/dungeon_main.o" - .include "src/code_805D8C8_2.o" + .space 0x4 + .include "src/dungeon_menu_items.o" + .space 0x4 .include "src/code_805D8C8_3.o" gUnknown_202F268: /* 202F268 (sub_8062500) */