diff --git a/asm/code_805D8C8.s b/asm/code_805D8C8.s index 145046781..1895ce031 100644 --- a/asm/code_805D8C8.s +++ b/asm/code_805D8C8.s @@ -6,535 +6,6 @@ .text - - - thumb_func_start sub_80643AC -sub_80643AC: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xE4 - adds r7, r0, 0 - add r0, sp, 0x68 - mov r9, r0 - mov r1, sp - adds r1, 0x6C - str r1, [sp, 0xD0] - mov r2, sp - adds r2, 0x6E - str r2, [sp, 0xD4] - mov r0, sp - adds r0, 0x70 - str r0, [sp, 0xD8] - adds r1, 0xC - str r1, [sp, 0xDC] - adds r2, 0x22 - str r2, [sp, 0xE0] - adds r0, 0x38 - str r0, [sp, 0xC8] - subs r1, 0x18 - str r1, [sp, 0xC4] - add r2, sp, 0xC0 - mov r10, r2 - ldr r5, _080644C8 - adds r0, r7, 0x4 - str r0, [sp, 0xCC] - ldr r1, _080644CC - mov r8, r1 - movs r6, 0 -_080643F0: - movs r4, 0 - ldr r0, [sp, 0xC4] - movs r1, 0 - movs r2, 0x60 - bl memset - movs r0, 0x6 - str r0, [sp, 0x64] - movs r0, 0x2 - mov r2, r9 - strh r0, [r2] - strh r0, [r2, 0x2] - movs r0, 0x12 - ldr r1, [sp, 0xD0] - strh r0, [r1] - movs r0, 0x4 - ldr r2, [sp, 0xD4] - strh r0, [r2] - movs r0, 0x10 - ldr r1, [sp, 0xD8] - strh r0, [r1] - mov r2, r10 - str r2, [sp, 0x74] - movs r0, 0x3 - ldr r1, [sp, 0xDC] - str r0, [r1, 0x4] - ldr r2, [sp, 0xE0] - str r0, [r2, 0x4] - ldr r1, [sp, 0xC8] - str r0, [r1, 0x4] - mov r0, sp - ldr r1, [sp, 0xC4] - movs r2, 0x60 - bl memcpy - bl PlayDungeonStartButtonSE - adds r0, r7, 0x4 - mov r1, sp - mov r2, r10 - bl sub_806455C - movs r0, 0x2D - bl DungeonRunFrameActions - adds r0, r7, 0 - bl sub_80645D4 - strh r4, [r5, 0x8] - strh r4, [r5, 0xA] - mov r0, sp - movs r1, 0x16 - bl CreateDungeonMenuSubWindow -_0806445C: - adds r0, r5, 0 - bl AddMenuCursorSprite - movs r0, 0x2D - bl DungeonRunFrameActions - mov r2, r8 - ldrh r1, [r2, 0x4] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _08064482 - movs r0, 0x1 - bl PlayDungeonCursorSE - adds r0, r5, 0 - movs r1, 0x1 - bl MoveMenuCursorDownWrapAround -_08064482: - mov r0, r8 - ldrh r1, [r0, 0x4] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _0806449C - movs r0, 0x1 - bl PlayDungeonCursorSE - adds r0, r5, 0 - movs r1, 0x1 - bl MoveMenuCursorUpWrapAround -_0806449C: - mov r2, r8 - ldrh r1, [r2, 0x2] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080644B2 - adds r0, r5, 0 - adds r0, 0x29 - ldrb r0, [r0] - cmp r0, 0 - beq _08064510 -_080644B2: - movs r1, 0x18 - ldrsh r0, [r5, r1] - cmp r0, 0x1 - bne _080644D0 - bl PlayDungeonConfirmationSE - ldr r0, [sp, 0xCC] - bl sub_80645F8 - movs r4, 0x2 - b _0806452A - .align 2, 0 -_080644C8: .4byte gDungeonMenu -_080644CC: .4byte gRealInputs -_080644D0: - movs r2, 0x18 - ldrsh r0, [r5, r2] - bl CanSubMenuItemBeChosen - lsls r0, 24 - cmp r0, 0 - beq _0806450C - ldr r4, [r7, 0x70] - adds r4, 0x44 - ldr r1, _08064508 - movs r2, 0x18 - ldrsh r0, [r5, r2] - lsls r0, 2 - adds r0, r1 - ldrh r1, [r0] - adds r0, r4, 0 - bl SetMonsterActionFields - bl PlayDungeonConfirmationSE - strb r6, [r4, 0x4] - strh r6, [r4, 0x8] - strh r6, [r4, 0xA] - strb r6, [r4, 0xC] - strh r6, [r4, 0x10] - strh r6, [r4, 0x12] - movs r4, 0 - b _0806452A - .align 2, 0 -_08064508: .4byte gDungeonSubMenu -_0806450C: - bl PlayDungeonCancelSE -_08064510: - mov r0, r8 - ldrh r1, [r0, 0x2] - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08064524 - ldr r1, _08064554 - ldrb r0, [r1] - cmp r0, 0 - beq _0806445C -_08064524: - bl PlayDungeonCancelSE - movs r4, 0x1 -_0806452A: - ldr r0, _08064558 - bl AddMenuCursorSprite - movs r0, 0x2D - bl DungeonRunFrameActions - cmp r4, 0x2 - bne _0806453C - b _080643F0 -_0806453C: - movs r0, 0 - movs r1, 0 - bl sub_803EAF0 - add sp, 0xE4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .align 2, 0 -_08064554: .4byte gUnknown_202EE3A -_08064558: .4byte gDungeonMenu - thumb_func_end sub_80643AC - - thumb_func_start sub_806455C -sub_806455C: - push {r4,r5,lr} - sub sp, 0x54 - adds r4, r0, 0 - adds r0, r1, 0 - movs r5, 0 - movs r1, 0x1 - strb r1, [r2] - strb r5, [r2, 0x1] - movs r1, 0xC - strb r1, [r2, 0x2] - strb r5, [r2, 0x3] - movs r1, 0x1 - bl DungeonShowWindows - movs r0, 0 - bl sub_80073B8 - movs r1, 0 - ldrsh r0, [r4, r1] - movs r2, 0x2 - ldrsh r1, [r4, r2] - bl GetTile - adds r4, r0, 0 - ldr r0, _080645D0 - ldr r2, [r0] - str r5, [sp] - movs r0, 0xC - movs r1, 0 - movs r3, 0 - bl PrintStringOnWindow - ldr r0, [r4, 0x14] - bl EntityIsValid - lsls r0, 24 - cmp r0, 0 - beq _080645C0 - ldr r1, [r4, 0x14] - add r0, sp, 0x4 - movs r2, 0 - bl SubstitutePlaceholderStringTags - str r5, [sp] - movs r0, 0x8 - movs r1, 0x12 - add r2, sp, 0x4 - movs r3, 0 - bl PrintStringOnWindow -_080645C0: - movs r0, 0 - bl sub_80073E0 - add sp, 0x54 - pop {r4,r5} - pop {r0} - bx r0 - .align 2, 0 -_080645D0: .4byte gUnknown_80FE708 - thumb_func_end sub_806455C - - thumb_func_start sub_80645D4 -sub_80645D4: - push {lr} - ldr r1, _080645F4 - movs r0, 0 - str r0, [r1] - movs r0, 0x25 - movs r1, 0 - bl AddActionToDungeonSubMenu - movs r0, 0xC - movs r1, 0 - bl AddActionToDungeonSubMenu - bl sub_8045064 - pop {r0} - bx r0 - .align 2, 0 -_080645F4: .4byte gDungeonSubMenuItemsCount - thumb_func_end sub_80645D4 - - thumb_func_start sub_80645F8 -sub_80645F8: - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x110 - str r0, [sp, 0xE4] - mov r0, sp - adds r0, 0x84 - str r0, [sp, 0xF4] - mov r1, sp - adds r1, 0x88 - str r1, [sp, 0xF8] - mov r2, sp - adds r2, 0x8C - str r2, [sp, 0xFC] - mov r3, sp - adds r3, 0x8E - str r3, [sp, 0x100] - adds r0, 0xC - str r0, [sp, 0x104] - adds r1, 0xC - str r1, [sp, 0x108] - adds r2, 0xC - str r2, [sp, 0x10C] - adds r3, 0x22 - str r3, [sp, 0xEC] - adds r0, 0x38 - str r0, [sp, 0xF0] - add r6, sp, 0x14 - subs r1, 0x74 - str r1, [sp, 0xE8] - add r2, sp, 0x80 - mov r10, r2 - add r3, sp, 0xE0 - mov r9, r3 -_08064640: - movs r7, 0 - mov r0, r10 - movs r1, 0 - movs r2, 0x60 - bl memset - movs r0, 0x6 - ldr r1, [sp, 0xF4] - str r0, [r1] - movs r0, 0x2 - ldr r2, [sp, 0xF8] - strh r0, [r2] - strh r0, [r2, 0x2] - movs r0, 0x1A - ldr r3, [sp, 0xFC] - strh r0, [r3] - movs r0, 0xC - ldr r1, [sp, 0x100] - strh r0, [r1] - ldr r2, [sp, 0x104] - strh r0, [r2] - mov r3, r9 - ldr r0, [sp, 0x108] - str r3, [r0] - movs r0, 0x3 - ldr r1, [sp, 0x10C] - str r0, [r1, 0x4] - ldr r2, [sp, 0xEC] - str r0, [r2, 0x4] - ldr r3, [sp, 0xF0] - str r0, [r3, 0x4] - ldr r0, [sp, 0xE8] - mov r1, r10 - movs r2, 0x60 - bl memcpy - adds r0, r6, 0 - bl sub_801317C - movs r1, 0x1 - add r0, sp, 0xE0 - strb r1, [r0] - movs r1, 0 - mov r0, r9 - strb r1, [r0, 0x1] - movs r0, 0x10 - mov r2, r9 - strb r0, [r2, 0x2] - strb r1, [r2, 0x3] - ldr r3, [sp, 0xE4] - movs r1, 0 - ldrsh r0, [r3, r1] - movs r2, 0x2 - ldrsh r1, [r3, r2] - bl GetTile - ldr r4, [r0, 0x14] - cmp r4, 0 - bne _080646B8 - b _080647D8 -_080646B8: - adds r0, r4, 0 - bl GetEntityType - cmp r0, 0x2 - beq _080646C4 - b _080647D8 -_080646C4: - ldr r0, [sp, 0xE8] - movs r1, 0 - bl DungeonShowWindows - adds r0, r4, 0 - bl GetTrapData - adds r4, r0, 0 - ldrb r1, [r4] - mov r0, r10 - bl GetTrapName - movs r0, 0 - bl sub_80073B8 - str r7, [sp] - movs r0, 0x10 - movs r1, 0 - mov r2, r10 - movs r3, 0 - bl PrintStringOnWindow - ldr r5, _08064720 - ldrb r0, [r4] - lsls r0, 2 - adds r0, r5 - ldr r2, [r0] - str r7, [sp] - movs r0, 0x8 - movs r1, 0x18 - movs r3, 0 - bl PrintStringOnWindow - movs r0, 0 - bl sub_80073E0 - ldrb r0, [r4] - lsls r0, 2 - adds r0, r5 - ldr r0, [r0] - add r1, sp, 0x4 - bl sub_8097DF0 - adds r5, r0, 0 - b _08064738 - .align 2, 0 -_08064720: .4byte gTrapDescriptions -_08064724: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _08064732 - ldrb r0, [r6, 0x2] - cmp r0, 0 - beq _08064738 -_08064732: - bl PlayDungeonCancelSE - b _080647D8 -_08064738: - cmp r5, 0 - beq _08064740 - bl ShowStatusDescriptionMenuArrow -_08064740: - adds r0, r6, 0 - movs r1, 0 - bl nullsub_34 - movs r0, 0x16 - bl DungeonRunFrameActions - ldr r0, _08064788 - ldrh r1, [r0, 0x2] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _08064760 - ldrb r0, [r6, 0x1] - cmp r0, 0 - beq _08064724 -_08064760: - bl PlayDungeonConfirmationSE - cmp r5, 0 - beq _080647D8 - movs r4, 0 - cmp r4, r5 - blt _08064770 - b _08064640 -_08064770: - subs r3, r5, 0x1 - mov r8, r3 -_08064774: - lsls r0, r4, 2 - add r0, sp - adds r0, 0x4 - ldr r0, [r0] - adds r1, r6, 0 - bl ShowStatusDescriptionMenu - adds r7, r4, 0x1 - b _080647A0 - .align 2, 0 -_08064788: .4byte gRealInputs -_0806478C: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - bne _0806479A - ldrb r0, [r6, 0x2] - cmp r0, 0 - beq _080647A0 -_0806479A: - bl PlayDungeonCancelSE - b _080647CC -_080647A0: - cmp r4, r8 - bge _080647A8 - bl ShowStatusDescriptionMenuArrow -_080647A8: - adds r0, r6, 0 - movs r1, 0 - bl nullsub_34 - movs r0, 0x16 - bl DungeonRunFrameActions - ldr r0, _080647D4 - ldrh r1, [r0, 0x2] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _080647C8 - ldrb r0, [r6, 0x1] - cmp r0, 0 - beq _0806478C -_080647C8: - bl PlayDungeonConfirmationSE -_080647CC: - adds r4, r7, 0 - cmp r4, r5 - blt _08064774 - b _08064640 - .align 2, 0 -_080647D4: .4byte gRealInputs -_080647D8: - movs r0, 0 - movs r1, 0 - bl sub_803EAF0 - add sp, 0x110 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80645F8 - thumb_func_start ShowDungeonStairsMenu ShowDungeonStairsMenu: push {r4-r7,lr} diff --git a/data/data_8106A4C.s b/data/data_8106A4C.s index 413077a14..e6531f822 100644 --- a/data/data_8106A4C.s +++ b/data/data_8106A4C.s @@ -4,10 +4,6 @@ @ CreateFieldItemMenu - sub_8062CA8 -@ ??? - .align 2,0 - .string "pksdir0\0" - @ ??? .align 2,0 .string "pksdir0\0" diff --git a/include/code_8097DD0.h b/include/code_8097DD0.h index 6a8ae9003..2a083c681 100644 --- a/include/code_8097DD0.h +++ b/include/code_8097DD0.h @@ -3,6 +3,6 @@ #include "structs/subStruct_203B240.h" -extern u32 sub_8097DF0(u8 *, struct subStruct_203B240 **); +extern u32 sub_8097DF0(const u8 *, struct subStruct_203B240 **); -#endif // GUARD_CODE_8097DD0_H \ No newline at end of file +#endif // GUARD_CODE_8097DD0_H diff --git a/include/constants/dungeon_action.h b/include/constants/dungeon_action.h index ccd4e8b64..6c47cbb75 100644 --- a/include/constants/dungeon_action.h +++ b/include/constants/dungeon_action.h @@ -14,6 +14,7 @@ enum DungeonAction // Some actions are different between the leader and AI-controlled Pokémon. ACTION_PICK_UP_PLAYER = 0x9, // Picking up an item underfoot. ACTION_THROW_ITEM_PLAYER = 0xB, + ACTION_SHOW_TRAP_INFO = 0xC, ACTION_EAT_BERRY_SEED_DRINK = 0xD, ACTION_USE_TM = 0x12, ACTION_TALK_FIELD = 0x13, // Talking to another Pokémon by facing them and interacting. diff --git a/include/dungeon_menu_tile.h b/include/dungeon_menu_tile.h new file mode 100644 index 000000000..ba619f876 --- /dev/null +++ b/include/dungeon_menu_tile.h @@ -0,0 +1,8 @@ +#ifndef GUARD_DUNGEON_MENU_TRAP_H +#define GUARD_DUNGEON_MENU_TRAP_H + +#include "structs/dungeon_entity.h" + +void ShowDungeonTileMenu(Entity *mon); + +#endif diff --git a/ld_script.txt b/ld_script.txt index 3718d7a2b..b10957d0e 100755 --- a/ld_script.txt +++ b/ld_script.txt @@ -231,6 +231,7 @@ SECTIONS { src/dungeon_menu_items.o(.text); src/dungeon_menu_team.o(.text); src/dungeon_menu_moves.o(.text); + src/dungeon_menu_tile.o(.text); asm/code_805D8C8.o(.text); src/code_8066D04.o(.text); src/code_805D8C8.o(.text); @@ -550,6 +551,7 @@ SECTIONS { src/dungeon_menu_items.o(.rodata); src/dungeon_menu_team.o(.rodata); src/dungeon_menu_moves.o(.rodata); + src/dungeon_menu_tile.o(.rodata); data/data_8106A4C.o(.rodata); src/code_8066D04.o(.rodata); data/data_8106A4C_2.o(.rodata); diff --git a/src/dungeon_main.c b/src/dungeon_main.c index 0c2681dee..e87ddad6a 100644 --- a/src/dungeon_main.c +++ b/src/dungeon_main.c @@ -46,6 +46,7 @@ #include "dungeon_menu_items.h" #include "dungeon_menu_team.h" #include "dungeon_menu_moves.h" +#include "dungeon_menu_tile.h" #include "constants/dungeon.h" #include "constants/status.h" #include "constants/tactic.h" @@ -94,7 +95,6 @@ void sub_806752C(ActionContainer *a0); void sub_8067768(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 void GetWeatherName(u8 *dst, u8 weatherId); extern bool8 sub_8070F14(Entity * pokemon, s32 direction); extern Entity *sub_80696A8(Entity *a0); @@ -1496,24 +1496,22 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1) } else if (GetEntityType(tileObject) == ENTITY_TRAP) { SetLeaderActionToNothing(1); - sub_80643AC(GetLeader()); + ShowDungeonTileMenu(GetLeader()); if (GetLeaderActionId() != 0) break; } } - else - { - if (tile->terrainType & TERRAIN_TYPE_STAIRS) { - SetLeaderActionToNothing(1); - ShowDungeonStairsMenu(GetLeader()); - if (GetLeaderActionId() != 0) - break; - } - else { - SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], GetLeader(), 0); - DisplayDungeonMessage(0, gUnknown_80FDE18, 1); - } + else if (tile->terrainType & TERRAIN_TYPE_STAIRS) { + SetLeaderActionToNothing(1); + ShowDungeonStairsMenu(GetLeader()); + if (GetLeaderActionId() != 0) + break; } + else { + SubstitutePlaceholderStringTags(gFormatBuffer_Monsters[0], GetLeader(), 0); + DisplayDungeonMessage(0, gUnknown_80FDE18, 1); + } + r10 = -1; } else if (chosenOption == MAIN_MENU_OTHERS) { diff --git a/src/dungeon_menu_moves.c b/src/dungeon_menu_moves.c index 451a7192e..0b6f06b44 100644 --- a/src/dungeon_menu_moves.c +++ b/src/dungeon_menu_moves.c @@ -28,7 +28,6 @@ #include "code_8044CC8.h" #include "move_util.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); @@ -50,10 +49,10 @@ extern void sub_8067768(ActionContainer *a0); extern void sub_806A2BC(Entity *a0, u8 a1); extern bool8 sub_8071A8C(Entity *pokemon); extern void sub_8083D1C(void); +extern s32 ActionToDungeonSubMenuId(u16 param_1); extern s32 gDungeonSubMenuItemsCount; extern MenuInputStruct gDungeonMenu; -extern s32 ActionToDungeonSubMenuId(u16 param_1); extern const u8 *const gUnknown_80FE978; extern const u8 *const gUnknown_80FDFE8; @@ -65,7 +64,7 @@ extern const u8 *const gUnknown_80FDF70; extern const u8 *const gUnknown_80FDF00; static void ShowMovesMenuWindows(Entity *entity, EntityInfo *entInfo, u8 a2, WindowTemplates *windows, WindowHeader *header, u8 *arg5, s32 arg6, s32 arg7); -static void AddSubMenuOptions(Entity *entity, bool8 addLinkOptions, bool8 addUseMove); +static void AddMovesSubMenuOptions(Entity *entity, bool8 addLinkOptions, bool8 addUseMove); static void SetSubMenuOptionAction(ActionContainer *a0, s32 a1, s32 a2); static void MenuChosenOptionToAction(ActionContainer *a0, s32 a1); static void PrintMoveNamesOnWindow(s32 count, Entity *entity, Move *moves, s32 windowId, u8 a4, s32 a5); @@ -343,7 +342,7 @@ bool8 ShowDungeonMovesMenu(Entity * entity, bool8 addLinkOptions, bool8 addUseMo break; } - AddSubMenuOptions(entity, addLinkOptions, addUseMove); + AddMovesSubMenuOptions(entity, addLinkOptions, addUseMove); if (r5 == 3) { s32 subMenuId = ActionToDungeonSubMenuId(ACTION_LINK_MOVES); if (!CanSubMenuItemBeChosen(subMenuId)) { @@ -536,7 +535,7 @@ static void PrintMoveNamesOnWindow(s32 count, Entity *entity, Move *moves, s32 w sub_80073E0(windowId); } -static void AddSubMenuOptions(Entity *entity, bool8 addLinkOptions, bool8 addUseMove) +static void AddMovesSubMenuOptions(Entity *entity, bool8 addLinkOptions, bool8 addUseMove) { EntityInfo *entInfo = GetEntInfo(entity); Move *move = &entInfo->moves.moves[sChosenMoveSlotId]; diff --git a/src/dungeon_menu_team.c b/src/dungeon_menu_team.c index db01beb27..d19d678a0 100644 --- a/src/dungeon_menu_team.c +++ b/src/dungeon_menu_team.c @@ -53,6 +53,7 @@ extern Item *sub_8044D90(Entity *, s32, u32); extern void PlayDungeonStartButtonSE(void); extern void PlayDungeonCancelSE(void); extern void PlayDungeonConfirmationSE(void); +extern void PlayDungeonCursorSE(u8 param_1); extern void sub_806A6E8(Entity *); extern bool8 sub_8047084(s32 itemFlag); extern void HandleTrap(Entity *pokemon, DungeonPos *pos, int param_3, char param_4); @@ -106,14 +107,13 @@ 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 u8 *GetDungeonSubMenuItemString(s32 param_1); extern bool8 CanSubMenuItemBeChosen(s32 param_1); extern s32 gDungeonSubMenuItemsCount; extern const u8 gUnknown_8106B50[]; extern void DungeonShowWindows(WindowTemplates *a0, u8 a1); extern Item * sub_8044CC8(Entity *param_1, ActionParameter *param_2, UNUSED s32 a3); -extern void AddActionToDungeonSubMenu(u16 param_1, u8 param_2); +extern void AddActionToDungeonSubMenu(u16 actionId, u8 param_2); extern void SetActionUnusableInDungeonSubMenu(u16 param_1); extern u16 sub_8044DC8(Item *param_1); extern bool8 sub_8046F00(Item *item); @@ -159,7 +159,7 @@ struct UnkFieldTeamMenuStruct }; static void PrintOnDungeonTeamMenu(struct UnkFieldTeamMenuStruct *a0, WindowTemplates *windows, bool8 a2); -static void sub_806145C(struct UnkFieldTeamMenuStruct *a0); +static void AddTeamSubMenuOptions(struct UnkFieldTeamMenuStruct *a0); static void ChosenSubMenuToAction(ActionContainer *a0, struct UnkFieldTeamMenuStruct *a1); static void PrintMonTactics(s32 firstId, u8 *tacticIds, EntityInfo *mon, s32 windowId); static void ShowUpArrowSprite(void); @@ -272,7 +272,7 @@ bool8 ShowDungeonTeamMenu(Entity *a0) sp.unk0 = gDungeonMenu.menuIndex; gTeamMenuChosenId = gDungeonMenu.menuIndex; - sub_806145C(&sp); + AddTeamSubMenuOptions(&sp); if (r10) { EntityInfo *info = GetEntInfo(a0); SetMonsterActionFields(&info->action, 0x1B); @@ -449,7 +449,7 @@ static void PrintOnDungeonTeamMenu(struct UnkFieldTeamMenuStruct *a0, WindowTemp sub_80073E0(0); } -static void sub_806145C(struct UnkFieldTeamMenuStruct *a0) +static void AddTeamSubMenuOptions(struct UnkFieldTeamMenuStruct *a0) { Entity *teamMon; EntityInfo *monInfo; @@ -457,17 +457,17 @@ static void sub_806145C(struct UnkFieldTeamMenuStruct *a0) gDungeonSubMenuItemsCount = 0; teamMon = gDungeon->teamPokemon[a0->unk4[gDungeonMenu.menuIndex]]; monInfo = GetEntInfo(teamMon); - AddActionToDungeonSubMenu(0x1B, 0); - AddActionToDungeonSubMenu(0x19, 0); + AddActionToDungeonSubMenu(ACTION_CHECK_SUMMARY, 0); + AddActionToDungeonSubMenu(ACTION_CHECK_MOVES, 0); if (!monInfo->isTeamLeader) { if (!gDungeon->unk644.unk19 && (monInfo->joinedAt.id != DUNGEON_JOIN_LOCATION_PARTNER || gDungeon->unk644.unk18)) { AddActionToDungeonSubMenu(0x34, 0); } - AddActionToDungeonSubMenu(0x1C, 0); + AddActionToDungeonSubMenu(ACTION_TALK_MENU, 0); } AddActionToDungeonSubMenu(0x30, 0); if (!monInfo->isTeamLeader) { - AddActionToDungeonSubMenu(0x1A, 0); + AddActionToDungeonSubMenu(ACTION_CHANGE_TACTICS, 0); } if (!monInfo->isTeamLeader && gDungeon->unk644.unk18 && CanLeaderSwitch(gDungeon->unk644.dungeonLocation.id)) { bool32 r5; @@ -493,10 +493,10 @@ static void sub_806145C(struct UnkFieldTeamMenuStruct *a0) } if (IsExperienceLocked(monInfo->joinedAt.id)) { - SetActionUnusableInDungeonSubMenu(0x19); + SetActionUnusableInDungeonSubMenu(ACTION_CHECK_MOVES); SetActionUnusableInDungeonSubMenu(0x3B); - SetActionUnusableInDungeonSubMenu(0x1A); - SetActionUnusableInDungeonSubMenu(0x30); + SetActionUnusableInDungeonSubMenu(ACTION_CHANGE_TACTICS); + SetActionUnusableInDungeonSubMenu(ACTION_VIEW_IQ); SetActionUnusableInDungeonSubMenu(0x34); } diff --git a/src/dungeon_menu_tile.c b/src/dungeon_menu_tile.c new file mode 100644 index 000000000..dce1e0a7b --- /dev/null +++ b/src/dungeon_menu_tile.c @@ -0,0 +1,241 @@ +#include "global.h" +#include "globaldata.h" +#include "dungeon_menu_tile.h" +#include "dungeon_menu_team.h" +#include "dungeon_menu_moves.h" +#include "dungeon_submenu.h" +#include "dungeon.h" +#include "text.h" +#include "menu_input.h" +#include "input.h" +#include "code_8044CC8.h" +#include "dungeon_action.h" +#include "dungeon_util.h" +#include "dungeon_map_access.h" +#include "code_8045A00.h" +#include "trap.h" +#include "code_8097DD0.h" + +extern void PlayDungeonStartButtonSE(void); +extern void PlayDungeonCancelSE(void); +extern void PlayDungeonConfirmationSE(void); +extern void PlayDungeonCursorSE(u8 param_1); +extern void sub_803EAF0(u32, u8 *); +extern bool8 CanSubMenuItemBeChosen(s32 param_1); +extern void DungeonRunFrameActions(u32 a0); +extern void DungeonShowWindows(WindowTemplates *a0, bool8 a1); +extern void AddActionToDungeonSubMenu(u16 actionId, u8 param_2); +extern void sub_8045064(void); + +extern MenuInputStruct gDungeonMenu; +extern s32 gDungeonSubMenuItemsCount; + +extern const u8 *const gUnknown_80FE708; +extern const u8 *const gTrapDescriptions[]; + +static void ShowAndPrintOnTileMenu(DungeonPos *pos, WindowTemplates *windows, WindowHeader *header); +static void AddTileSubMenuOptions(Entity *mon); +static void ShowTileDescription(DungeonPos *pos); + +void ShowDungeonTileMenu(Entity *mon) +{ + while (1) { + s32 inputAction = 0; + WindowHeader header; + WindowTemplates windows = { + .id = { + [0] = { + .type = WINDOW_TYPE_WITH_HEADER, + .pos = {2, 2}, + .width = 18, + .height = 4, + .unk10 = 16, + .unk12 = 0, + .header = &header, + }, + [1] = WINDOW_DUMMY, + [2] = WINDOW_DUMMY, + [3] = WINDOW_DUMMY, + } + }; + + PlayDungeonStartButtonSE(); + ShowAndPrintOnTileMenu(&mon->pos, &windows, &header); + DungeonRunFrameActions(0x2D); + AddTileSubMenuOptions(mon); + gDungeonMenu.unk8.x = 0; + gDungeonMenu.unk8.y = 0; + CreateDungeonMenuSubWindow(&windows.id[0], 22); + + while (1) { + AddMenuCursorSprite(&gDungeonMenu); + DungeonRunFrameActions(0x2D); + if (gRealInputs.repeated & DPAD_DOWN) { + PlayDungeonCursorSE(TRUE); + MoveMenuCursorDownWrapAround(&gDungeonMenu, TRUE); + } + if (gRealInputs.repeated & DPAD_UP) { + PlayDungeonCursorSE(TRUE); + MoveMenuCursorUpWrapAround(&gDungeonMenu, TRUE); + } + + if ((gRealInputs.pressed & A_BUTTON) || gDungeonMenu.unk28.a_button) { + if (gDungeonMenu.menuIndex == 1) { + PlayDungeonConfirmationSE(); + ShowTileDescription(&mon->pos); + inputAction = 2; + break; + } + else if (CanSubMenuItemBeChosen(gDungeonMenu.menuIndex)) { + ActionContainer *action = &GetEntInfo(mon)->action; + + SetMonsterActionFields(action, gDungeonSubMenu[gDungeonMenu.menuIndex].actionId); + PlayDungeonConfirmationSE(); + action->actionParameters[0].actionUseIndex = 0; + action->actionParameters[0].itemPos.x = 0; + action->actionParameters[0].itemPos.y = 0; + action->actionParameters[1].actionUseIndex = 0; + action->actionParameters[1].itemPos.x = 0; + action->actionParameters[1].itemPos.y = 0; + inputAction = 0; + break; + } + PlayDungeonCancelSE(); + } + if ((gRealInputs.pressed & B_BUTTON) || gDungeonMenu.unk28.b_button) { + PlayDungeonCancelSE(); + inputAction = 1; + break; + } + } + + AddMenuCursorSprite(&gDungeonMenu); + DungeonRunFrameActions(0x2D); + if (inputAction != 2) + break; + } + + sub_803EAF0(0, 0); +} + +static void ShowAndPrintOnTileMenu(DungeonPos *pos, WindowTemplates *windows, WindowHeader *header) +{ + u8 text[80]; + const Tile *tile; + + header->count = 1; + header->currId = 0; + header->width = 12; + header->f3 = 0; + DungeonShowWindows(windows, TRUE); + sub_80073B8(0); + tile = GetTile(pos->x, pos->y); + + PrintStringOnWindow(12, 0, gUnknown_80FE708, 0, '\0'); + if (EntityIsValid(tile->object)) { + SubstitutePlaceholderStringTags(text, tile->object, 0); + PrintStringOnWindow(8, 18, text, 0, '\0'); + } + sub_80073E0(0); +} + +static void AddTileSubMenuOptions(Entity *mon) +{ + gDungeonSubMenuItemsCount = 0; + AddActionToDungeonSubMenu(ACTION_STEPPED_ON_TRAP, 0); + AddActionToDungeonSubMenu(ACTION_SHOW_TRAP_INFO, 0); + sub_8045064(); +} + +static void ShowTileDescription(DungeonPos *pos) +{ + while (1) { + const Tile *tile; + Entity *object; + Trap *trap; + bool8 bPress = FALSE; + struct subStruct_203B240 *statuses[4]; + MenuInputStructSub menuSub; + WindowHeader header; + WindowTemplates windows = { + .id = { + [0] = { + .type = WINDOW_TYPE_WITH_HEADER, + .pos = {2, 2}, + .width = 26, + .height = 12, + .unk10 = 12, + .unk12 = 0, + .header = &header, + }, + [1] = WINDOW_DUMMY, + [2] = WINDOW_DUMMY, + [3] = WINDOW_DUMMY, + } + }; + u8 trapName[0x60]; + s32 i, statusesCount; + + sub_801317C(&menuSub); + header.count = 1; + header.currId = 0; + header.width = 16; + header.f3 = 0; + + tile = GetTile(pos->x, pos->y); + object = tile->object; + if (object == NULL) + break; + if (GetEntityType(object) != ENTITY_TRAP) + break; + + DungeonShowWindows(&windows, FALSE); + trap = GetTrapData(object); + GetTrapName(trapName, trap->id); + sub_80073B8(0); + PrintStringOnWindow(16, 0, trapName, 0, '\0'); + PrintStringOnWindow(8, 24, gTrapDescriptions[trap->id], 0, '\0'); + sub_80073E0(0); + statusesCount = sub_8097DF0(gTrapDescriptions[trap->id], statuses); + while (1) { + if (statusesCount != 0) { + ShowStatusDescriptionMenuArrow(); + } + nullsub_34(&menuSub, 0); + DungeonRunFrameActions(0x16); + if ((gRealInputs.pressed & A_BUTTON) || menuSub.a_button) { + PlayDungeonConfirmationSE(); + bPress = FALSE; + break; + } + if ((gRealInputs.pressed & B_BUTTON) || menuSub.b_button) { + PlayDungeonCancelSE(); + bPress = TRUE; + break; + } + } + if (bPress || statusesCount == 0) + break; + + for (i = 0; i < statusesCount; i++) { + ShowStatusDescriptionMenu(statuses[i], &menuSub); + while (1) { + if (i < statusesCount - 1) { + ShowStatusDescriptionMenuArrow(); + } + nullsub_34(&menuSub, 0); + DungeonRunFrameActions(0x16); + if ((gRealInputs.pressed & A_BUTTON) || menuSub.a_button) { + PlayDungeonConfirmationSE(); + break; + } + if ((gRealInputs.pressed & B_BUTTON) || menuSub.b_button) { + PlayDungeonCancelSE(); + break; + } + } + } + } + + sub_803EAF0(0, 0); +}