From 9f902df79bc3ad6c272439104d3c0427bfb30a09 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Tue, 30 Jan 2018 13:19:37 -0500 Subject: [PATCH 01/12] decompiled up to sub_81ABCC0 --- asm/item_menu.s | 2046 ----------------------------------------------- src/item_menu.c | 831 +++++++++++++++++++ 2 files changed, 831 insertions(+), 2046 deletions(-) create mode 100755 src/item_menu.c diff --git a/asm/item_menu.s b/asm/item_menu.s index 591b91775..fe0a8167e 100644 --- a/asm/item_menu.s +++ b/asm/item_menu.s @@ -5,2052 +5,6 @@ .text - thumb_func_start ResetBagScrollPositions -ResetBagScrollPositions: @ 81AAB70 - push {r4,lr} - ldr r4, =gUnknown_0203CE58 - movs r0, 0 - strb r0, [r4, 0x5] - adds r0, r4, 0 - adds r0, 0x8 - movs r1, 0 - movs r2, 0xA - bl memset - adds r4, 0x12 - adds r0, r4, 0 - movs r1, 0 - movs r2, 0xA - bl memset - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end ResetBagScrollPositions - - thumb_func_start CB2_BagMenuFromStartMenu -@ void CB2_BagMenuFromStartMenu() -CB2_BagMenuFromStartMenu: @ 81AAB9C - push {lr} - ldr r2, =sub_8086194 - movs r0, 0 - movs r1, 0x5 - bl GoToBagMenu - pop {r0} - bx r0 - .pool - thumb_func_end CB2_BagMenuFromStartMenu - - thumb_func_start sub_81AABB0 -sub_81AABB0: @ 81AABB0 - push {lr} - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - bne _081AABCC - ldr r2, =SetCB2ToReshowScreenAfterMenu2 - movs r0, 0x1 - movs r1, 0x5 - bl GoToBagMenu - b _081AABD4 - .pool -_081AABCC: - ldr r1, =SetCB2ToReshowScreenAfterMenu2 - movs r0, 0x1 - bl sub_81C4F98 -_081AABD4: - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AABB0 - - thumb_func_start CB2_ChooseBerry -CB2_ChooseBerry: @ 81AABDC - push {lr} - ldr r2, =sub_80861B0 - movs r0, 0x4 - movs r1, 0x3 - bl GoToBagMenu - pop {r0} - bx r0 - .pool - thumb_func_end CB2_ChooseBerry - - thumb_func_start sub_81AABF0 -sub_81AABF0: @ 81AABF0 - push {lr} - adds r2, r0, 0 - movs r0, 0x5 - movs r1, 0x3 - bl GoToBagMenu - pop {r0} - bx r0 - thumb_func_end sub_81AABF0 - - thumb_func_start CB2_GoToSellMenu -@ void CB2_GoToSellMenu() -CB2_GoToSellMenu: @ 81AAC00 - push {lr} - ldr r2, =CB2_ExitSellMenu - movs r0, 0x3 - movs r1, 0x5 - bl GoToBagMenu - pop {r0} - bx r0 - .pool - thumb_func_end CB2_GoToSellMenu - - thumb_func_start sub_81AAC14 -sub_81AAC14: @ 81AAC14 - push {lr} - ldr r2, =sub_816B31C - movs r0, 0x6 - movs r1, 0x5 - bl GoToBagMenu - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AAC14 - - thumb_func_start sub_81AAC28 -sub_81AAC28: @ 81AAC28 - push {lr} - ldr r2, =bag_menu_leave_maybe_3 - movs r0, 0x9 - movs r1, 0x5 - bl GoToBagMenu - ldr r0, =gSpecialVar_0x8005 - movs r1, 0 - strh r1, [r0] - ldr r0, =gSpecialVar_Result - strh r1, [r0] - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AAC28 - - thumb_func_start sub_81AAC50 -sub_81AAC50: @ 81AAC50 - push {lr} - ldr r2, =bag_menu_leave_maybe_2 - movs r0, 0x7 - movs r1, 0x5 - bl GoToBagMenu - ldr r1, =gSpecialVar_Result - movs r0, 0 - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AAC50 - - thumb_func_start sub_81AAC70 -sub_81AAC70: @ 81AAC70 - push {lr} - ldr r2, =bag_menu_leave_maybe - movs r0, 0x8 - movs r1, 0x5 - bl GoToBagMenu - ldr r1, =gSpecialVar_Result - movs r0, 0 - strh r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AAC70 - - thumb_func_start GoToBagMenu -@ void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()) -GoToBagMenu: @ 81AAC90 - push {r4-r7,lr} - adds r4, r2, 0 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 24 - lsrs r7, r1, 24 - ldr r6, =gUnknown_0203CE54 - ldr r0, =0x00000c48 - bl AllocZeroed - str r0, [r6] - cmp r0, 0 - bne _081AACBC - adds r0, r4, 0 - bl SetMainCallback2 - b _081AAD3A - .pool -_081AACBC: - ldr r0, =gUnknown_0203CE58 - cmp r5, 0xC - beq _081AACC4 - strb r5, [r0, 0x4] -_081AACC4: - cmp r4, 0 - beq _081AACCA - str r4, [r0] -_081AACCA: - cmp r7, 0x4 - bhi _081AACD0 - strb r7, [r0, 0x5] -_081AACD0: - ldrb r0, [r0, 0x4] - subs r0, 0x4 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bhi _081AACF0 - ldr r2, [r6] - ldr r0, =0x0000081b - adds r2, r0 - ldrb r1, [r2] - movs r0, 0x10 - negs r0, r0 - ands r0, r1 - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] -_081AACF0: - ldr r0, [r6] - movs r1, 0 - str r1, [r0] - ldr r1, =0x0000081a - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldr r0, [r6] - ldr r1, =0x0000081e - adds r0, r1 - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - ldr r0, [r6] - ldr r1, =0x0000081f - adds r0, r1 - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - ldr r0, [r6] - ldr r1, =0x00000804 - adds r0, r1 - movs r1, 0xFF - movs r2, 0xC - bl memset - ldr r0, [r6] - movs r1, 0x81 - lsls r1, 4 - adds r0, r1 - movs r1, 0xFF - movs r2, 0xA - bl memset - ldr r0, =CB2_Bag - bl SetMainCallback2 -_081AAD3A: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end GoToBagMenu - - thumb_func_start c2_bag_3 -c2_bag_3: @ 81AAD5C - push {lr} - bl RunTasks - bl AnimateSprites - bl BuildOamBuffer - bl do_scheduled_bg_tilemap_copies_to_vram - bl UpdatePaletteFade - pop {r0} - bx r0 - thumb_func_end c2_bag_3 - - thumb_func_start vblank_cb_bag_menu -vblank_cb_bag_menu: @ 81AAD78 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end vblank_cb_bag_menu - - thumb_func_start CB2_Bag -CB2_Bag: @ 81AAD8C - push {lr} -_081AAD8E: - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081AADB2 - bl setup_bag_menu - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081AADB2 - bl sub_81221AC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081AAD8E -_081AADB2: - pop {r0} - bx r0 - thumb_func_end CB2_Bag - - thumb_func_start setup_bag_menu -setup_bag_menu: @ 81AADB8 - push {r4,r5,lr} - sub sp, 0x4 - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r0, r1, r2 - ldrb r0, [r0] - adds r2, r1, 0 - cmp r0, 0x14 - bls _081AADCE - b _081AB02C -_081AADCE: - lsls r0, 2 - ldr r1, =_081AADE0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081AADE0: - .4byte _081AAE34 - .4byte _081AAE3E - .4byte _081AAE50 - .4byte _081AAE56 - .4byte _081AAE78 - .4byte _081AAE7E - .4byte _081AAE86 - .4byte _081AAEA4 - .4byte _081AAECC - .4byte _081AAEDA - .4byte _081AAEEC - .4byte _081AAEFA - .4byte _081AAF0C - .4byte _081AAF1C - .4byte _081AAF54 - .4byte _081AAFA0 - .4byte _081AAFBC - .4byte _081AAFC2 - .4byte _081AAFD8 - .4byte _081AAFDE - .4byte _081AAFF8 -_081AAE34: - bl SetVBlankHBlankCallbacksToNull - bl clear_scheduled_bg_copies_to_vram - b _081AB012 -_081AAE3E: - bl ScanlineEffect_Stop - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAE50: - bl FreeAllSpritePalettes - b _081AB012 -_081AAE56: - bl ResetPaletteFade - ldr r2, =gPaletteFade - ldrb r0, [r2, 0x8] - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2, 0x8] - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAE78: - bl ResetSpriteData - b _081AB012 -_081AAE7E: - movs r0, 0x87 - lsls r0, 3 - adds r1, r2, r0 - b _081AB01A -_081AAE86: - bl sub_81221AC - lsls r0, 24 - cmp r0, 0 - bne _081AAE94 - bl ResetTasks -_081AAE94: - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAEA4: - bl bag_menu_init_bgs - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000834 - adds r0, r1 - movs r1, 0 - strh r1, [r0] - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAECC: - bl load_bag_menu_graphics - lsls r0, 24 - cmp r0, 0 - bne _081AAED8 - b _081AB044 -_081AAED8: - b _081AB012 -_081AAEDA: - bl setup_bag_menu_textboxes - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAEEC: - bl sub_81ABA6C - bl sub_81ABAC4 - bl sub_81ABAE0 - b _081AB012 -_081AAEFA: - bl allocate_bag_item_list_buffers - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAF0C: - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - bl load_bag_item_list_buffers - b _081AB012 - .pool -_081AAF1C: - ldr r1, =gPocketNamesStringsTable - ldr r4, =gUnknown_0203CE58 - ldrb r0, [r4, 0x5] - lsls r0, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0 - bl bag_menu_print_pocket_names - movs r0, 0 - bl bag_menu_copy_pocket_name_to_window - ldrb r0, [r4, 0x5] - movs r1, 0x1 - bl bag_menu_draw_pocket_indicator_square - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAF54: - ldr r4, =gUnknown_0203CE58 - ldrb r0, [r4, 0x4] - bl sub_81AB1F0 - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gMultiuseListMenuTemplate - ldrb r2, [r4, 0x5] - lsls r2, 1 - adds r1, r4, 0 - adds r1, 0x12 - adds r1, r2, r1 - ldrh r1, [r1] - adds r4, 0x8 - adds r2, r4 - ldrh r2, [r2] - bl ListMenuInit - ldr r2, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r2 - lsls r0, 24 - lsrs r0, 24 - movs r2, 0 - strh r0, [r1, 0x8] - strh r2, [r1, 0xE] - strh r2, [r1, 0x18] - b _081AB012 - .pool -_081AAFA0: - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - bl AddBagVisualObject - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAFBC: - bl sub_80D4FAC - b _081AB012 -_081AAFC2: - bl bag_menu_add_pocket_scroll_arrow_indicators_maybe - bl bag_menu_add_list_scroll_arrow_indicators_maybe - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAFD8: - bl bag_menu_prepare_tmhm_move_window - b _081AB012 -_081AAFDE: - movs r0, 0x1 - negs r0, r0 - movs r1, 0x10 - movs r2, 0 - bl BlendPalettes - ldr r1, =gMain - movs r2, 0x87 - lsls r2, 3 - adds r1, r2 - b _081AB01A - .pool -_081AAFF8: - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0x10 - movs r3, 0 - bl BeginNormalPaletteFade - ldr r2, =gPaletteFade - ldrb r1, [r2, 0x8] - movs r0, 0x7F - ands r0, r1 - strb r0, [r2, 0x8] -_081AB012: - ldr r1, =gMain - movs r0, 0x87 - lsls r0, 3 - adds r1, r0 -_081AB01A: - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] - b _081AB044 - .pool -_081AB02C: - ldr r0, =vblank_cb_bag_menu - bl SetVBlankCallback - ldr r0, =c2_bag_3 - bl SetMainCallback2 - movs r0, 0x1 - b _081AB046 - .pool -_081AB044: - movs r0, 0 -_081AB046: - add sp, 0x4 - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end setup_bag_menu - - thumb_func_start bag_menu_init_bgs -bag_menu_init_bgs: @ 81AB050 - push {r4,lr} - bl ResetVramOamAndBgCntRegs - ldr r4, =gUnknown_0203CE54 - ldr r0, [r4] - adds r0, 0x4 - movs r2, 0x80 - lsls r2, 4 - movs r1, 0 - bl memset - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - ldr r1, =gUnknown_08613F90 - movs r0, 0 - movs r2, 0x3 - bl InitBgsFromTemplates - ldr r1, [r4] - adds r1, 0x4 - movs r0, 0x2 - bl SetBgTilemapBuffer - bl ResetAllBgsCoordinates - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - movs r1, 0x82 - lsls r1, 5 - movs r0, 0 - bl SetGpuReg - movs r0, 0 - bl ShowBg - movs r0, 0x1 - bl ShowBg - movs r0, 0x2 - bl ShowBg - movs r0, 0x50 - movs r1, 0 - bl SetGpuReg - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_init_bgs - - thumb_func_start load_bag_menu_graphics -load_bag_menu_graphics: @ 81AB0BC - push {r4,lr} - sub sp, 0x4 - ldr r4, =gUnknown_0203CE54 - ldr r0, [r4] - ldr r1, =0x00000834 - adds r0, r1 - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x4 - bls _081AB0D2 - b _081AB1CC -_081AB0D2: - lsls r0, 2 - ldr r1, =_081AB0E8 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081AB0E8: - .4byte _081AB0FC - .4byte _081AB118 - .4byte _081AB13C - .4byte _081AB174 - .4byte _081AB1A8 -_081AB0FC: - bl reset_temp_tile_data_buffers - ldr r1, =gBagScreen_Gfx - movs r0, 0 - str r0, [sp] - movs r0, 0x2 - movs r2, 0 - movs r3, 0 - bl decompress_and_copy_tile_data_to_vram - b _081AB1AE - .pool -_081AB118: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081AB1E4 - ldr r0, =gUnknown_08D9A88C - ldr r4, =gUnknown_0203CE54 - ldr r1, [r4] - adds r1, 0x4 - bl LZDecompressWram - ldr r1, [r4] - b _081AB1B2 - .pool -_081AB13C: - bl IsWallysBag - lsls r0, 24 - cmp r0, 0 - bne _081AB164 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x8] - cmp r0, 0 - beq _081AB164 - ldr r0, =gBagScreenFemale_Pal - movs r1, 0 - movs r2, 0x40 - bl LoadCompressedPalette - b _081AB1AE - .pool -_081AB164: - ldr r0, =gBagScreenMale_Pal - movs r1, 0 - movs r2, 0x40 - bl LoadCompressedPalette - b _081AB1AE - .pool -_081AB174: - bl IsWallysBag - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081AB18A - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x8] - cmp r0, 0 - bne _081AB19C -_081AB18A: - ldr r0, =gUnknown_0857FB34 - bl LoadCompressedObjectPic - b _081AB1AE - .pool -_081AB19C: - ldr r0, =gUnknown_0857FB3C - bl LoadCompressedObjectPic - b _081AB1AE - .pool -_081AB1A8: - ldr r0, =gUnknown_0857FB44 - bl LoadCompressedObjectPalette -_081AB1AE: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] -_081AB1B2: - ldr r0, =0x00000834 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - b _081AB1E4 - .pool -_081AB1CC: - bl LoadListMenuArrowsGfx - ldr r0, [r4] - ldr r1, =0x00000834 - adds r0, r1 - movs r1, 0 - strh r1, [r0] - movs r0, 0x1 - b _081AB1E6 - .pool -_081AB1E4: - movs r0, 0 -_081AB1E6: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end load_bag_menu_graphics - - thumb_func_start sub_81AB1F0 -sub_81AB1F0: @ 81AB1F0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0xA - bne _081AB204 - ldr r0, =Task_WallyTutorialBagMenu - b _081AB206 - .pool -_081AB204: - ldr r0, =Task_BagMenu -_081AB206: - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - pop {r1} - bx r1 - .pool - thumb_func_end sub_81AB1F0 - - thumb_func_start allocate_bag_item_list_buffers -allocate_bag_item_list_buffers: @ 81AB218 - push {r4,lr} - ldr r4, =gUnknown_0203CE74 - movs r0, 0x82 - lsls r0, 2 - bl Alloc - str r0, [r4] - ldr r4, =gUnknown_0203CE78 - movs r0, 0xC3 - lsls r0, 3 - bl Alloc - str r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end allocate_bag_item_list_buffers - - thumb_func_start load_bag_item_list_buffers -@ void load_bag_item_list_buffers(int pocket_id) -load_bag_item_list_buffers: @ 81AB240 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r7, r0, 24 - lsls r1, r7, 3 - ldr r0, =gBagPockets - adds r1, r0 - mov r8, r1 - ldr r0, =gUnknown_0203CE54 - ldr r2, [r0] - ldr r1, =0x0000081b - adds r0, r2, r1 - ldrb r1, [r0] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081AB2FC - movs r6, 0 - ldr r3, =0x00000829 - adds r0, r2, r3 - adds r0, r7 - ldrb r0, [r0] - subs r0, 0x1 - cmp r6, r0 - bge _081AB2B6 - ldr r5, =gUnknown_0203CE78 -_081AB276: - lsls r4, r6, 1 - adds r4, r6 - lsls r4, 3 - ldr r0, [r5] - adds r0, r4 - mov r1, r8 - ldr r2, [r1] - lsls r1, r6, 2 - adds r1, r2 - ldrh r1, [r1] - bl get_name - ldr r0, =gUnknown_0203CE74 - ldr r0, [r0] - lsls r1, r6, 3 - adds r1, r0 - ldr r0, [r5] - adds r0, r4 - str r0, [r1] - str r6, [r1, 0x4] - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r3, =0x00000829 - adds r0, r3 - adds r0, r7 - ldrb r0, [r0] - subs r0, 0x1 - cmp r6, r0 - blt _081AB276 -_081AB2B6: - ldr r5, =gUnknown_0203CE78 - lsls r4, r6, 1 - adds r4, r6 - lsls r4, 3 - ldr r0, [r5] - adds r0, r4 - ldr r1, =gText_CloseBag - bl StringCopy - ldr r0, =gUnknown_0203CE74 - ldr r0, [r0] - lsls r1, r6, 3 - adds r1, r0 - ldr r0, [r5] - adds r0, r4 - str r0, [r1] - movs r0, 0x2 - negs r0, r0 - str r0, [r1, 0x4] - b _081AB34A - .pool -_081AB2FC: - movs r6, 0 - ldr r4, =0x00000829 - adds r0, r2, r4 - adds r0, r7 - ldrb r0, [r0] - cmp r6, r0 - bcs _081AB34A - ldr r5, =gUnknown_0203CE78 -_081AB30C: - lsls r4, r6, 1 - adds r4, r6 - lsls r4, 3 - ldr r0, [r5] - adds r0, r4 - mov r1, r8 - ldr r2, [r1] - lsls r1, r6, 2 - adds r1, r2 - ldrh r1, [r1] - bl get_name - ldr r0, =gUnknown_0203CE74 - ldr r0, [r0] - lsls r1, r6, 3 - adds r1, r0 - ldr r0, [r5] - adds r0, r4 - str r0, [r1] - str r6, [r1, 0x4] - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r3, =0x00000829 - adds r0, r3 - adds r0, r7 - ldrb r0, [r0] - cmp r6, r0 - bcc _081AB30C -_081AB34A: - ldr r2, =gMultiuseListMenuTemplate - adds r1, r2, 0 - ldr r0, =gUnknown_08613F9C - ldm r0!, {r3-r5} - stm r1!, {r3-r5} - ldm r0!, {r3-r5} - stm r1!, {r3-r5} - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - ldr r4, =0x00000829 - adds r0, r1, r4 - adds r0, r7 - ldrb r0, [r0] - strh r0, [r2, 0xC] - ldr r0, =gUnknown_0203CE74 - ldr r0, [r0] - str r0, [r2] - ldr r5, =0x0000082e - adds r1, r5 - adds r1, r7 - ldrb r0, [r1] - strh r0, [r2, 0xE] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end load_bag_item_list_buffers - - thumb_func_start get_name -@ void get_name(char *dest, int name_id) -get_name: @ 81AB39C - push {r4-r6,lr} - adds r6, r0, 0 - lsls r1, 16 - lsrs r5, r1, 16 - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - cmp r0, 0x2 - beq _081AB3C0 - cmp r0, 0x3 - beq _081AB420 - adds r0, r5, 0 - adds r1, r6, 0 - bl CopyItemName - b _081AB43E - .pool -_081AB3C0: - ldr r4, =gStringVar2 - adds r0, r5, 0 - bl ItemIdToBattleMoveId - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xD - muls r1, r0 - ldr r0, =gMoveNames - adds r1, r0 - adds r0, r4, 0 - bl StringCopy - movs r0, 0xA9 - lsls r0, 1 - cmp r5, r0 - bls _081AB408 - ldr r0, =gStringVar1 - ldr r2, =0xfffffeae - adds r1, r5, r2 - movs r2, 0x2 - movs r3, 0x1 - bl ConvertIntToDecimalStringN - ldr r1, =gText_ClearTo11Var1Clear5Var2 - b _081AB438 - .pool -_081AB408: - ldr r0, =gStringVar1 - ldr r2, =0xfffffee0 - adds r1, r5, r2 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - b _081AB436 - .pool -_081AB420: - ldr r0, =gStringVar1 - adds r1, r5, 0 - subs r1, 0x84 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r1, =gStringVar2 - adds r0, r5, 0 - bl CopyItemName -_081AB436: - ldr r1, =gText_UnkF908Var1Clear7Var2 -_081AB438: - adds r0, r6, 0 - bl StringExpandPlaceholders -_081AB43E: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end get_name - - thumb_func_start bag_menu_change_item_callback -bag_menu_change_item_callback: @ 81AB450 - push {r4-r6,lr} - adds r6, r0, 0 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0x1 - beq _081AB466 - movs r0, 0x5 - bl PlaySE - bl ShakeBagVisual -_081AB466: - ldr r4, =gUnknown_0203CE54 - ldr r1, [r4] - ldr r2, =0x0000081a - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0xFF - bne _081AB50C - adds r2, 0x1 - adds r0, r1, r2 - ldrb r1, [r0] - lsls r1, 26 - lsrs r1, 30 - movs r0, 0x1 - eors r0, r1 - bl RemoveBagItemIconObject - movs r0, 0x2 - negs r0, r0 - cmp r6, r0 - beq _081AB4C8 - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r6, 16 - lsrs r1, 16 - bl BagGetItemIdByPocketPosition - lsls r0, 16 - lsrs r0, 16 - ldr r1, [r4] - ldr r2, =0x0000081b - adds r1, r2 - ldrb r1, [r1] - lsls r1, 26 - lsrs r1, 30 - bl AddBagItemIconObject - b _081AB4DA - .pool -_081AB4C8: - ldr r0, =0x0000ffff - ldr r1, [r4] - ldr r2, =0x0000081b - adds r1, r2 - ldrb r1, [r1] - lsls r1, 26 - lsrs r1, 30 - bl AddBagItemIconObject -_081AB4DA: - ldr r5, =gUnknown_0203CE54 - ldr r2, [r5] - ldr r4, =0x0000081b - adds r2, r4 - ldrb r3, [r2] - lsls r0, r3, 26 - lsrs r0, 30 - movs r1, 0x1 - eors r1, r0 - lsls r1, 4 - movs r0, 0x31 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2] - ldr r0, [r5] - adds r0, r4 - ldrb r1, [r0] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - bne _081AB50C - adds r0, r6, 0 - bl bag_menu_print_description_box_text -_081AB50C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_change_item_callback - - thumb_func_start sub_81AB520 -@ void sub_81AB520(u8 rbox_id, int item_index_in_pocket, int a3) -sub_81AB520: @ 81AB520 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x14 - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - lsls r2, 24 - lsrs r7, r2, 24 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - bne _081AB540 - b _081AB696 -_081AB540: - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x0000081a - adds r0, r1 - ldrb r1, [r0] - cmp r1, 0xFF - beq _081AB570 - lsls r0, r4, 24 - lsrs r0, 24 - cmp r1, r0 - bne _081AB568 - adds r0, r7, 0 - movs r1, 0x2 - bl bag_menu_print_cursor - b _081AB570 - .pool -_081AB568: - adds r0, r7, 0 - movs r1, 0xFF - bl bag_menu_print_cursor -_081AB570: - ldr r5, =gUnknown_0203CE58 - ldrb r0, [r5, 0x5] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - lsls r4, 16 - lsrs r4, 16 - adds r1, r4, 0 - bl BagGetItemIdByPocketPosition - lsls r0, 16 - lsrs r6, r0, 16 - ldrb r0, [r5, 0x5] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - bl BagGetQuantityByPocketPosition - lsls r0, 16 - lsrs r4, r0, 16 - mov r9, r4 - ldr r1, =0xfffffead - adds r0, r6, r1 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x7 - bhi _081AB5BE - ldr r1, =gBagMenuHMIcon_Gfx - subs r3, r7, 0x1 - lsls r3, 16 - lsrs r3, 16 - movs r0, 0x10 - str r0, [sp] - str r0, [sp, 0x4] - mov r0, r8 - movs r2, 0x8 - bl BlitBitmapToWindow -_081AB5BE: - ldrb r0, [r5, 0x5] - cmp r0, 0x3 - bne _081AB610 - ldr r0, =gStringVar1 - adds r1, r4, 0 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_xVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x7 - adds r1, r4, 0 - movs r2, 0x77 - bl GetStringRightAlignXOffset - lsls r3, r0, 24 - lsrs r3, 24 - str r7, [sp] - movs r1, 0 - str r1, [sp, 0x4] - str r1, [sp, 0x8] - movs r0, 0xFF - str r0, [sp, 0xC] - str r1, [sp, 0x10] - b _081AB652 - .pool -_081AB610: - cmp r0, 0x4 - beq _081AB66C - adds r0, r6, 0 - bl itemid_is_unique - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - bne _081AB66C - ldr r0, =gStringVar1 - mov r1, r9 - movs r2, 0x1 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_xVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x7 - adds r1, r4, 0 - movs r2, 0x77 - bl GetStringRightAlignXOffset - lsls r3, r0, 24 - lsrs r3, 24 - str r7, [sp] - str r5, [sp, 0x4] - str r5, [sp, 0x8] - movs r0, 0xFF - str r0, [sp, 0xC] - str r5, [sp, 0x10] -_081AB652: - mov r0, r8 - movs r1, 0x7 - adds r2, r4, 0 - bl bag_menu_print - b _081AB696 - .pool -_081AB66C: - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00000496 - adds r0, r1 - ldrh r0, [r0] - cmp r0, 0 - beq _081AB696 - cmp r0, r6 - bne _081AB696 - ldr r1, =gUnknown_086140A4 - subs r3, r7, 0x1 - lsls r3, 16 - lsrs r3, 16 - movs r0, 0x18 - str r0, [sp] - movs r0, 0x10 - str r0, [sp, 0x4] - mov r0, r8 - movs r2, 0x60 - bl BlitBitmapToWindow -_081AB696: - add sp, 0x14 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AB520 - - thumb_func_start bag_menu_print_description_box_text -@ void bag_menu_print_description_box_text(int a1) -bag_menu_print_description_box_text: @ 81AB6B0 - push {r4,lr} - sub sp, 0x14 - adds r1, r0, 0 - movs r0, 0x2 - negs r0, r0 - cmp r1, r0 - beq _081AB6E0 - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 16 - lsrs r1, 16 - bl BagGetItemIdByPocketPosition - lsls r0, 16 - lsrs r0, 16 - bl ItemId_GetDescription - adds r4, r0, 0 - b _081AB6FC - .pool -_081AB6E0: - ldr r0, =gStringVar1 - ldr r2, =gReturnToXStringsTable - ldr r1, =gUnknown_0203CE58 - ldrb r1, [r1, 0x4] - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - bl StringCopy - ldr r4, =gStringVar4 - ldr r1, =gText_ReturnToVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders -_081AB6FC: - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - str r0, [sp, 0x10] - movs r0, 0x1 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x3 - bl bag_menu_print - add sp, 0x14 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_print_description_box_text - - thumb_func_start bag_menu_print_cursor_ -bag_menu_print_cursor_: @ 81AB73C - push {r4,lr} - adds r4, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r4, 24 - lsrs r4, 24 - bl ListMenuGetYCoordForPrintingArrowCursor - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - bl bag_menu_print_cursor - pop {r4} - pop {r0} - bx r0 - thumb_func_end bag_menu_print_cursor_ - - thumb_func_start bag_menu_print_cursor -bag_menu_print_cursor: @ 81AB75C - push {r4,r5,lr} - sub sp, 0x14 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0xFF - bne _081AB798 - movs r0, 0x1 - movs r1, 0 - bl GetMenuCursorDimensionByFont - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - movs r1, 0x1 - bl GetMenuCursorDimensionByFont - lsls r0, 24 - lsrs r0, 24 - str r4, [sp] - str r0, [sp, 0x4] - movs r0, 0 - movs r1, 0 - movs r2, 0 - adds r3, r5, 0 - bl FillWindowPixelRect - b _081AB7AE -_081AB798: - ldr r2, =gText_SelectorArrow2 - str r5, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - str r1, [sp, 0x10] - movs r1, 0x1 - movs r3, 0 - bl bag_menu_print -_081AB7AE: - add sp, 0x14 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_print_cursor - - thumb_func_start bag_menu_add_pocket_scroll_arrow_indicators_maybe -bag_menu_add_pocket_scroll_arrow_indicators_maybe: @ 81AB7BC - push {r4-r6,lr} - sub sp, 0x10 - ldr r5, =gUnknown_0203CE54 - ldr r4, [r5] - ldr r1, =0x0000081e - adds r0, r4, r1 - ldrb r0, [r0] - cmp r0, 0xFF - bne _081AB80A - ldr r2, =gUnknown_0203CE58 - ldrb r3, [r2, 0x5] - ldr r6, =0x00000829 - adds r0, r4, r6 - adds r0, r3 - ldrb r1, [r0] - adds r6, 0x5 - adds r0, r4, r6 - adds r0, r3 - ldrb r0, [r0] - subs r1, r0 - str r1, [sp] - movs r0, 0x6E - str r0, [sp, 0x4] - str r0, [sp, 0x8] - ldrb r0, [r2, 0x5] - lsls r0, 1 - adds r2, 0x12 - adds r0, r2 - str r0, [sp, 0xC] - movs r0, 0x2 - movs r1, 0xAC - movs r2, 0xC - movs r3, 0x94 - bl AddScrollIndicatorArrowPairParametrized - ldr r1, [r5] - ldr r2, =0x0000081e - adds r1, r2 - strb r0, [r1] -_081AB80A: - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_add_pocket_scroll_arrow_indicators_maybe - - thumb_func_start sub_81AB824 -sub_81AB824: @ 81AB824 - push {r4,lr} - ldr r4, =gUnknown_0203CE54 - ldr r0, [r4] - ldr r2, =0x0000081e - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0xFF - beq _081AB842 - bl RemoveScrollIndicatorArrowPair - ldr r0, [r4] - ldr r1, =0x0000081e - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] -_081AB842: - bl sub_81AB89C - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AB824 - - thumb_func_start bag_menu_add_list_scroll_arrow_indicators_maybe -bag_menu_add_list_scroll_arrow_indicators_maybe: @ 81AB854 - push {r4,lr} - ldr r4, =gUnknown_0203CE54 - ldr r2, [r4] - ldr r1, =0x0000081b - adds r0, r2, r1 - ldrb r1, [r0] - movs r0, 0xF - ands r0, r1 - cmp r0, 0x1 - beq _081AB882 - ldr r1, =0x0000081f - adds r0, r2, r1 - ldrb r0, [r0] - cmp r0, 0xFF - bne _081AB882 - ldr r0, =gUnknown_08614094 - ldr r1, =gUnknown_0203CE5E - bl AddScrollIndicatorArrowPair - ldr r1, [r4] - ldr r2, =0x0000081f - adds r1, r2 - strb r0, [r1] -_081AB882: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_add_list_scroll_arrow_indicators_maybe - - thumb_func_start sub_81AB89C -sub_81AB89C: @ 81AB89C - push {r4,lr} - ldr r4, =gUnknown_0203CE54 - ldr r0, [r4] - ldr r2, =0x0000081f - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0xFF - beq _081AB8BA - bl RemoveScrollIndicatorArrowPair - ldr r0, [r4] - ldr r1, =0x0000081f - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] -_081AB8BA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AB89C - - thumb_func_start free_bag_item_list_buffers -free_bag_item_list_buffers: @ 81AB8C8 - push {lr} - ldr r0, =gUnknown_0203CE78 - ldr r0, [r0] - bl Free - ldr r0, =gUnknown_0203CE74 - ldr r0, [r0] - bl Free - bl FreeAllWindowBuffers - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - bl Free - pop {r0} - bx r0 - .pool - thumb_func_end free_bag_item_list_buffers - - thumb_func_start unknown_ItemMenu_Confirm -unknown_ItemMenu_Confirm: @ 81AB8F8 - push {r4,lr} - sub sp, 0x4 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =task_close_bag_menu_2 - str r1, [r0] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end unknown_ItemMenu_Confirm - - thumb_func_start task_close_bag_menu_2 -task_close_bag_menu_2: @ 81AB930 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r2, r0, r1 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081AB9A0 - ldrb r0, [r2] - ldr r4, =gUnknown_0203CE58 - ldrb r2, [r4, 0x5] - lsls r2, 1 - adds r1, r4, 0 - adds r1, 0x12 - adds r1, r2, r1 - adds r3, r4, 0 - adds r3, 0x8 - adds r2, r3 - bl sub_81AE6C8 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r0, [r0] - cmp r0, 0 - beq _081AB984 - bl SetMainCallback2 - b _081AB98A - .pool -_081AB984: - ldr r0, [r4] - bl SetMainCallback2 -_081AB98A: - bl sub_81AB824 - bl ResetSpriteData - bl FreeAllSpritePalettes - bl free_bag_item_list_buffers - adds r0, r5, 0 - bl DestroyTask -_081AB9A0: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end task_close_bag_menu_2 - - thumb_func_start sub_81AB9A8 -sub_81AB9A8: @ 81AB9A8 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, r5, 3 - ldr r0, =gBagPockets - adds r4, r1, r0 - cmp r5, 0x3 - bgt _081AB9C8 - cmp r5, 0x2 - blt _081AB9C8 - adds r0, r4, 0 - bl sub_80D6FB4 - b _081AB9CE - .pool -_081AB9C8: - adds r0, r4, 0 - bl sub_80D6F64 -_081AB9CE: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - ldr r6, =0x00000829 - adds r1, r6 - adds r1, r5 - movs r2, 0 - strb r2, [r1] - adds r3, r0, 0 - ldrb r0, [r4, 0x4] - cmp r2, r0 - bcs _081ABA12 - ldr r0, [r4] - ldrh r0, [r0] - cmp r0, 0 - beq _081ABA12 - adds r7, r3, 0 -_081AB9EE: - ldr r0, [r7] - adds r0, r6 - adds r0, r5 - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - adds r0, r2, 0x1 - lsls r0, 16 - lsrs r2, r0, 16 - ldrb r1, [r4, 0x4] - cmp r2, r1 - bcs _081ABA12 - ldr r0, [r4] - lsls r1, r2, 2 - adds r1, r0 - ldrh r0, [r1] - cmp r0, 0 - bne _081AB9EE -_081ABA12: - ldr r2, [r3] - ldr r1, =0x0000081b - adds r0, r2, r1 - ldrb r1, [r0] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081ABA2E - ldr r0, =0x00000829 - adds r1, r2, r0 - adds r1, r5 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_081ABA2E: - ldr r1, [r3] - ldr r2, =0x00000829 - adds r0, r1, r2 - adds r0, r5 - ldrb r2, [r0] - cmp r2, 0x8 - bls _081ABA58 - ldr r3, =0x0000082e - adds r0, r1, r3 - adds r0, r5 - movs r1, 0x8 - strb r1, [r0] - b _081ABA60 - .pool -_081ABA58: - ldr r3, =0x0000082e - adds r0, r1, r3 - adds r0, r5 - strb r2, [r0] -_081ABA60: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AB9A8 - - thumb_func_start sub_81ABA6C -sub_81ABA6C: @ 81ABA6C - push {r4,lr} - movs r4, 0 -_081ABA70: - adds r0, r4, 0 - bl sub_81AB9A8 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x4 - bls _081ABA70 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81ABA6C - - thumb_func_start sub_81ABA88 -sub_81ABA88: @ 81ABA88 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 1 - ldr r2, =gUnknown_0203CE6A - adds r4, r1, r2 - subs r2, 0xA - adds r1, r2 - ldr r2, =gUnknown_0203CE54 - ldr r3, [r2] - ldr r5, =0x0000082e - adds r2, r3, r5 - adds r2, r0 - ldrb r2, [r2] - subs r5, 0x5 - adds r3, r5 - adds r3, r0 - ldrb r3, [r3] - adds r0, r4, 0 - bl sub_812225C - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81ABA88 - - thumb_func_start sub_81ABAC4 -sub_81ABAC4: @ 81ABAC4 - push {r4,lr} - movs r4, 0 -_081ABAC8: - adds r0, r4, 0 - bl sub_81ABA88 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x4 - bls _081ABAC8 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81ABAC4 - - thumb_func_start sub_81ABAE0 -sub_81ABAE0: @ 81ABAE0 - push {r4-r7,lr} - sub sp, 0x4 - movs r5, 0 - ldr r6, =gUnknown_0203CE6A - adds r7, r6, 0 - subs r7, 0xA -_081ABAEC: - lsls r1, r5, 1 - adds r0, r1, r6 - adds r1, r7 - ldr r2, =gUnknown_0203CE54 - ldr r3, [r2] - ldr r4, =0x0000082e - adds r2, r3, r4 - adds r2, r5 - ldrb r2, [r2] - subs r4, 0x5 - adds r3, r4 - adds r3, r5 - ldrb r3, [r3] - movs r4, 0x8 - str r4, [sp] - bl sub_8122298 - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x4 - bls _081ABAEC - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81ABAE0 - - thumb_func_start sub_81ABB2C -sub_81ABB2C: @ 81ABB2C - lsls r0, 24 - ldr r1, =gUnknown_0203CE58 - lsrs r0, 23 - adds r2, r1, 0 - adds r2, 0x12 - adds r2, r0, r2 - adds r1, 0x8 - adds r0, r1 - ldrb r0, [r0] - ldrb r2, [r2] - adds r0, r2 - lsls r0, 24 - lsrs r0, 24 - bx lr - .pool - thumb_func_end sub_81ABB2C - - thumb_func_start DisplayItemMessage -@ void DisplayItemMessage(u8 taskId, u8 fontId, u8 *str, void ( *callback)(u8 taskId)) -DisplayItemMessage: @ 81ABB4C - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x10 - adds r5, r0, 0 - adds r6, r1, 0 - mov r8, r2 - mov r9, r3 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - movs r0, 0x4 - bl AddItemMessageWindow - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x14] - movs r1, 0x11 - bl FillWindowPixelBuffer - bl GetPlayerTextSpeed - lsls r0, 24 - lsrs r0, 24 - ldrb r1, [r4, 0x14] - str r6, [sp] - str r0, [sp, 0x4] - mov r0, r8 - str r0, [sp, 0x8] - mov r0, r9 - str r0, [sp, 0xC] - adds r0, r5, 0 - movs r2, 0xA - movs r3, 0xD - bl DisplayMessageAndContinueTask - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end DisplayItemMessage - - thumb_func_start bag_menu_inits_lists_menu -bag_menu_inits_lists_menu: @ 81ABBBC - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - lsls r6, 24 - lsrs r6, 24 - lsls r5, r6, 2 - adds r5, r6 - lsls r5, 3 - ldr r0, =gTasks + 0x8 - adds r5, r0 - ldr r7, =gUnknown_0203CE58 - ldrb r4, [r7, 0x5] - lsls r4, 1 - movs r0, 0x12 - adds r0, r7 - mov r8, r0 - add r8, r4 - adds r0, r7, 0 - adds r0, 0x8 - adds r4, r0 - movs r0, 0x4 - bl bag_menu_RemoveBagItem_message_window - ldrb r0, [r5] - mov r1, r8 - adds r2, r4, 0 - bl sub_81AE6C8 - ldrb r0, [r7, 0x5] - bl sub_81AB9A8 - ldrb r0, [r7, 0x5] - bl sub_81ABA88 - ldrb r0, [r7, 0x5] - bl load_bag_item_list_buffers - ldr r0, =gMultiuseListMenuTemplate - mov r2, r8 - ldrh r1, [r2] - ldrh r2, [r4] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5] - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - adds r0, r6, 0 - bl set_callback3_to_bag - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_inits_lists_menu - - thumb_func_start sub_81ABC3C -sub_81ABC3C: @ 81ABC3C - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl bag_menu_add_window - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - bl sub_81ABC54 - pop {r0} - bx r0 - thumb_func_end sub_81ABC3C - - thumb_func_start sub_81ABC54 -sub_81ABC54: @ 81ABC54 - push {r4,r5,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 16 - lsrs r1, 16 - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - movs r3, 0x2 - cmp r0, 0x3 - bne _081ABC6C - movs r3, 0x3 -_081ABC6C: - ldr r0, =gStringVar1 - lsls r1, 16 - asrs r1, 16 - movs r2, 0x2 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_xVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0x28 - bl GetStringCenterAlignXOffset - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x2 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl PrintTextOnWindow - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81ABC54 - - thumb_func_start sub_81ABCC0 -sub_81ABCC0: @ 81ABCC0 - push {r4-r7,lr} - sub sp, 0xC - adds r4, r0, 0 - adds r7, r2, 0 - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - movs r3, 0x2 - cmp r0, 0x3 - bne _081ABCD4 - movs r3, 0x3 -_081ABCD4: - ldr r0, =gStringVar1 - movs r2, 0x2 - bl ConvertIntToDecimalStringN - ldr r6, =gStringVar4 - ldr r1, =gText_xVar1 - adds r0, r6, 0 - bl StringExpandPlaceholders - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - str r0, [sp] - movs r0, 0xFF - str r0, [sp, 0x4] - movs r5, 0 - str r5, [sp, 0x8] - adds r0, r4, 0 - movs r1, 0x1 - adds r2, r6, 0 - movs r3, 0 - bl PrintTextOnWindow - str r5, [sp] - adds r0, r4, 0 - movs r1, 0x26 - movs r2, 0x1 - adds r3, r7, 0 - bl PrintMoneyAmount - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81ABCC0 - thumb_func_start Task_BagMenu Task_BagMenu: @ 81ABD28 push {r4-r7,lr} diff --git a/src/item_menu.c b/src/item_menu.c new file mode 100755 index 000000000..9d7afbb24 --- /dev/null +++ b/src/item_menu.c @@ -0,0 +1,831 @@ +#include "global.h" +#include "bg.h" +#include "constants/items.h" +#include "constants/songs.h" +#include "decompress.h" +#include "event_data.h" +#include "gpu_regs.h" +#include "international_string_util.h" +#include "item.h" +#include "list_menu.h" +#include "main.h" +#include "malloc.h" +#include "menu.h" +#include "menu_indicators.h" +#include "money.h" +#include "new_menu_helpers.h" +#include "palette.h" +#include "rom_818CFC8.h" +#include "sound.h" +#include "sprite.h" +#include "string.h" +#include "string_util.h" +#include "task.h" +#include "menu_helpers.h" +#include "unknown_task.h" +#include "window.h" + +struct bagStruct { + void *func; + u8 unk4; + u8 pocket; + u8 unk6[2]; + u16 unk8[5]; + u16 unk12[5]; + void *unk1C; +}; + +struct unkBagStruct { + void* unk0; + u8 unk4[0x800]; + u8 unk804; + u8 filler4[11]; + u8 unk810[10]; + u8 unk81A; + u8 unk81B:4; + u8 unk81B_1:2; + u8 unk81B_3:1; + u8 unk81B_2:1; + u8 filler3[2]; + u8 unk81E; + u8 unk81F; + u8 filler5[9]; + u8 unk829[5]; + u8 unk82E[6]; + s16 unk834; + u8 filler2[0x412]; +}; + +struct listBuffer1 { + struct ListMenuItem subBuffers[65]; +}; + +struct listBuffer2 { + s8 name[65][24]; +}; + +extern struct bagStruct gUnknown_0203CE58; +extern struct unkBagStruct *gUnknown_0203CE54; +extern struct listBuffer1 *gUnknown_0203CE74; +extern struct listBuffer2 *gUnknown_0203CE78; +extern u16 gUnknown_0203CE6A[]; +extern u16 gUnknown_0203CE60[]; +extern void sub_8086194(void); +extern void sub_80861B0(void); +extern void sub_816B31C(void); +extern void bag_menu_leave_maybe_3(void); +extern void bag_menu_leave_maybe_2(void); +extern void bag_menu_leave_maybe(void); +extern void CB2_ExitSellMenu(void); +extern void SetCB2ToReshowScreenAfterMenu2(void); +extern void sub_81C4F98(u8, void(*)(void)); +extern bool8 sub_81221EC(void); +extern bool8 sub_81221AC(void); +extern void sub_81ABA6C(void); +extern void sub_81ABAC4(void); +extern void sub_81ABAE0(void); +extern u8 sub_81AB1F0(u8); +extern void sub_80D4FAC(void); +extern void RemoveBagItemIconObject(u8); +extern u8 ListMenuGetYCoordForPrintingArrowCursor(u8); +extern u8 GetMenuCursorDimensionByFont(u8, u8); +extern u8 AddScrollIndicatorArrowPair(void*, void*); +extern void sub_80D6FB4(struct BagPocket*); +extern void sub_80D6F64(struct BagPocket*); + +void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()); +void CB2_Bag(void); +bool8 setup_bag_menu(void); +void bag_menu_init_bgs(void); +bool8 load_bag_menu_graphics(void); +void setup_bag_menu_textboxes(void); +void allocate_bag_item_list_buffers(void); +void load_bag_item_list_buffers(u8); +void bag_menu_print_pocket_names(u8*, u8); +void bag_menu_copy_pocket_name_to_window(u8); +void bag_menu_draw_pocket_indicator_square(u8, u8); +void AddBagVisualObject(u8); +void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void); +void bag_menu_add_list_scroll_arrow_indicators_maybe(void); +void bag_menu_prepare_tmhm_move_window(void); +bool8 IsWallysBag(void); +void Task_WallyTutorialBagMenu(u8); +void Task_BagMenu(u8); +void get_name(s8*, u16); +u16 ItemIdToBattleMoveId(u16); +void ShakeBagVisual(void); +u16 BagGetItemIdByPocketPosition(u8, u16); +void AddBagItemIconObject(u16, u8); +void bag_menu_print_description_box_text(int); +void bag_menu_print_cursor(u8, u8); +void bag_menu_print(u8, u8, u8*, u8, u8, u8, u8, u8, u8); +bool8 itemid_is_unique(u16); +u16 BagGetQuantityByPocketPosition(u8, u16); +void sub_81AB89C(void); +void task_close_bag_menu_2(u8); +u8 AddItemMessageWindow(u8); +void bag_menu_RemoveBagItem_message_window(u8); +void set_callback3_to_bag(u8); +void sub_81ABC54(u8, s16); +u8 bag_menu_add_window(u8); +u8 GetSwitchBagPocketDirection(void); +void SwitchBagPocket(u8, s8, u8); +bool8 sub_81AC2C0(void); +void bag_menu_swap_items(u8); + +extern u8 *gPocketNamesStringsTable[]; +extern struct BgTemplate gUnknown_08613F90[]; +extern u8 gBagScreen_Gfx[]; +extern u8 gUnknown_08D9A88C[]; +extern u16 gBagScreenFemale_Pal[]; +extern u16 gBagScreenMale_Pal[]; +extern struct CompressedSpriteSheet gUnknown_0857FB34; +extern struct CompressedSpriteSheet gUnknown_0857FB3C; +extern struct CompressedSpritePalette gUnknown_0857FB44; +extern u8 gText_CloseBag[]; +extern struct ListMenuTemplate gUnknown_08613F9C; +extern u8 gText_ClearTo11Var1Clear5Var2[]; +extern u8 gText_UnkF908Var1Clear7Var2[]; +extern u8 gMoveNames[][0xD]; +extern u8 gBagMenuHMIcon_Gfx[]; +extern u8 gUnknown_086140A4[]; +extern u8 gText_xVar1[]; +extern u8* gReturnToXStringsTable[]; +extern u8 gText_ReturnToVar1[]; +extern u8 gText_SelectorArrow2[]; +extern u32 gUnknown_08614094[]; +extern u32 gUnknown_0203CE5E[]; +extern u16 gSpecialVar_ItemId; +extern TaskFunc gUnknown_08614054[]; + +void ResetBagScrollPositions(void) +{ + gUnknown_0203CE58.pocket = 0; + memset(gUnknown_0203CE58.unk8, 0, 10); + memset(gUnknown_0203CE58.unk12, 0, 10); +} + +void CB2_BagMenuFromStartMenu(void) +{ + GoToBagMenu(0, 5, sub_8086194); +} + +void sub_81AABB0(void) +{ + if (!InBattlePyramid()) + GoToBagMenu(1, 5, SetCB2ToReshowScreenAfterMenu2); + else + sub_81C4F98(1, SetCB2ToReshowScreenAfterMenu2); +} + +void CB2_ChooseBerry(void) +{ + GoToBagMenu(4, 3, sub_80861B0); +} + +void sub_81AABF0(void(*callback)(void)) +{ + GoToBagMenu(5, 3, callback); +} + +void CB2_GoToSellMenu(void) +{ + GoToBagMenu(3, 5, CB2_ExitSellMenu); +} + +void sub_81AAC14(void) +{ + GoToBagMenu(6, 5, sub_816B31C); +} + +void sub_81AAC28(void) +{ + GoToBagMenu(9, 5, bag_menu_leave_maybe_3); + gSpecialVar_0x8005 = 0; + gSpecialVar_Result = 0; +} + +void sub_81AAC50(void) +{ + GoToBagMenu(7, 5, bag_menu_leave_maybe_2); + gSpecialVar_Result = 0; +} + +void sub_81AAC70(void) +{ + GoToBagMenu(8, 5, bag_menu_leave_maybe); + gSpecialVar_Result = 0; +} + +void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()) +{ + u8 temp; + gUnknown_0203CE54 = AllocZeroed(sizeof(struct unkBagStruct)); + if (gUnknown_0203CE54 == 0) + SetMainCallback2(postExitMenuMainCallback2); + else + { + if (bagMenuType != 12) + gUnknown_0203CE58.unk4 = bagMenuType; + if (postExitMenuMainCallback2) + gUnknown_0203CE58.func = postExitMenuMainCallback2; + if (pocketId <= 4) + gUnknown_0203CE58.pocket = pocketId; + temp = gUnknown_0203CE58.unk4 - 4; + if (temp <= 1) + gUnknown_0203CE54->unk81B = 1; + gUnknown_0203CE54->unk0 = 0; + gUnknown_0203CE54->unk81A = 0xFF; + gUnknown_0203CE54->unk81E = -1; + gUnknown_0203CE54->unk81F = -1; + memset(&gUnknown_0203CE54->unk804, 0xFF, 12); + memset(gUnknown_0203CE54->unk810, 0xFF, 10); + SetMainCallback2(CB2_Bag); + } +} + +void c2_bag_3(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + do_scheduled_bg_tilemap_copies_to_vram(); + UpdatePaletteFade(); +} + +void vblank_cb_bag_menu(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +void CB2_Bag(void) +{ + while(sub_81221EC() != TRUE && setup_bag_menu() != TRUE && sub_81221AC() != TRUE) {}; +} + +bool8 setup_bag_menu(void) +{ + u32 index; + u8 taskId; + + switch (gMain.state) + { + case 0: + SetVBlankHBlankCallbacksToNull(); + clear_scheduled_bg_copies_to_vram(); + gMain.state++; + break; + case 1: + ScanlineEffect_Stop(); + gMain.state++; + break; + case 2: + FreeAllSpritePalettes(); + gMain.state++; + break; + case 3: + ResetPaletteFade(); + gPaletteFade.bufferTransferDisabled = TRUE; + gMain.state++; + break; + case 4: + ResetSpriteData(); + gMain.state++; + break; + case 5: + gMain.state++; + break; + case 6: + if (sub_81221AC() == FALSE) + ResetTasks(); + gMain.state++; + break; + case 7: + bag_menu_init_bgs(); + gUnknown_0203CE54->unk834 = 0; + gMain.state++; + break; + case 8: + if (!load_bag_menu_graphics()) + break; + gMain.state++; + break; + case 9: + setup_bag_menu_textboxes(); + gMain.state++; + break; + case 10: + sub_81ABA6C(); + sub_81ABAC4(); + sub_81ABAE0(); + gMain.state++; + break; + case 11: + allocate_bag_item_list_buffers(); + gMain.state++; + break; + case 12: + load_bag_item_list_buffers(gUnknown_0203CE58.pocket); + gMain.state++; + break; + case 13: + bag_menu_print_pocket_names(gPocketNamesStringsTable[gUnknown_0203CE58.pocket], 0); + bag_menu_copy_pocket_name_to_window(0); + bag_menu_draw_pocket_indicator_square(gUnknown_0203CE58.pocket, 1); + gMain.state++; + break; + case 14: + taskId = sub_81AB1F0(gUnknown_0203CE58.unk4); + gTasks[taskId].data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]); + gTasks[taskId].data[3] = 0; + gTasks[taskId].data[8] = 0; + gMain.state++; + break; + case 15: + AddBagVisualObject(gUnknown_0203CE58.pocket); + gMain.state++; + break; + case 16: + sub_80D4FAC(); + gMain.state++; + break; + case 17: + bag_menu_add_pocket_scroll_arrow_indicators_maybe(); + bag_menu_add_list_scroll_arrow_indicators_maybe(); + gMain.state++; + break; + case 18: + bag_menu_prepare_tmhm_move_window(); + gMain.state++; + break; + case 19: + BlendPalettes(-1, 16, 0); + gMain.state++; + break; + case 20: + BeginNormalPaletteFade(-1, 0, 16, 0, 0); + gPaletteFade.bufferTransferDisabled = FALSE; + gMain.state++; + break; + default: + SetVBlankCallback(vblank_cb_bag_menu); + SetMainCallback2(c2_bag_3); + return TRUE; + } + return FALSE; +} + +void bag_menu_init_bgs(void) +{ + ResetVramOamAndBgCntRegs(); + memset(gUnknown_0203CE54->unk4, 0, 0x800); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_08613F90, 3); + SetBgTilemapBuffer(2, gUnknown_0203CE54->unk4); + ResetAllBgsCoordinates(); + schedule_bg_copy_tilemap_to_vram(2); + SetGpuReg(REG_OFFSET_DISPCNT, 0x1040); + ShowBg(0); + ShowBg(1); + ShowBg(2); + SetGpuReg(REG_OFFSET_BLDCNT, 0); +} + +bool8 load_bag_menu_graphics(void) +{ + switch (gUnknown_0203CE54->unk834) + { + case 0: + reset_temp_tile_data_buffers(); + decompress_and_copy_tile_data_to_vram(2, gBagScreen_Gfx, 0, 0, 0); + gUnknown_0203CE54->unk834++; + break; + case 1: + if (free_temp_tile_data_buffers_if_possible() != TRUE) + { + LZDecompressWram(gUnknown_08D9A88C, gUnknown_0203CE54->unk4); + gUnknown_0203CE54->unk834++; + } + break; + case 2: + if (!IsWallysBag() && gSaveBlock2Ptr->playerGender != MALE) + LoadCompressedPalette(gBagScreenFemale_Pal, 0, 0x40); + else + LoadCompressedPalette(gBagScreenMale_Pal, 0, 0x40); + gUnknown_0203CE54->unk834++; + break; + case 3: + if (IsWallysBag() == TRUE || gSaveBlock2Ptr->playerGender == MALE) + LoadCompressedObjectPic(&gUnknown_0857FB34); + else + LoadCompressedObjectPic(&gUnknown_0857FB3C); + gUnknown_0203CE54->unk834++; + break; + case 4: + LoadCompressedObjectPalette(&gUnknown_0857FB44); + gUnknown_0203CE54->unk834++; + break; + default: + LoadListMenuArrowsGfx(); + gUnknown_0203CE54->unk834 = 0; + return TRUE; + } + return FALSE; +} + +u8 sub_81AB1F0(u8 a) +{ + u8 taskId; + if (a == 10) + taskId = CreateTask(Task_WallyTutorialBagMenu, 0); + else + taskId = CreateTask(Task_BagMenu, 0); + return taskId; +} + +void allocate_bag_item_list_buffers(void) +{ + gUnknown_0203CE74 = Alloc(sizeof(struct listBuffer1)); + gUnknown_0203CE78 = Alloc(sizeof(struct listBuffer2)); +} + +void load_bag_item_list_buffers(u8 pocketId) +{ + u16 i; + struct BagPocket *pocket = &gBagPockets[pocketId]; + struct ListMenuItem *subBuffer; + + if (!gUnknown_0203CE54->unk81B_2) + { + for (i = 0;i < gUnknown_0203CE54->unk829[pocketId] - 1; i++) + { + get_name(gUnknown_0203CE78->name[i], pocket->itemSlots[i].itemId); + subBuffer = gUnknown_0203CE74->subBuffers; + subBuffer[i].name = gUnknown_0203CE78->name[i]; + subBuffer[i].id = i; + } + StringCopy(gUnknown_0203CE78->name[i], gText_CloseBag); + subBuffer = gUnknown_0203CE74->subBuffers; + subBuffer[i].name = gUnknown_0203CE78->name[i]; + subBuffer[i].id = -2; + } + else + { + for (i = 0;i < gUnknown_0203CE54->unk829[pocketId]; i++) + { + get_name(gUnknown_0203CE78->name[i], pocket->itemSlots[i].itemId); + subBuffer = gUnknown_0203CE74->subBuffers; + subBuffer[i].name = gUnknown_0203CE78->name[i]; + subBuffer[i].id = i; + } + } + gMultiuseListMenuTemplate = gUnknown_08613F9C; + gMultiuseListMenuTemplate.totalItems = gUnknown_0203CE54->unk829[pocketId]; + gMultiuseListMenuTemplate.items = gUnknown_0203CE74->subBuffers; + gMultiuseListMenuTemplate.maxShowed = gUnknown_0203CE54->unk82E[pocketId]; +} + +void get_name(s8 *dest, u16 itemId) +{ + switch (gUnknown_0203CE58.pocket) + { + case 2: + StringCopy(gStringVar2, gMoveNames[ItemIdToBattleMoveId(itemId)]); + if (itemId >= ITEM_HM01) + { + ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_HM01 + 1, 2, 1); + StringExpandPlaceholders(dest, gText_ClearTo11Var1Clear5Var2); + } + else + { + ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_TM01 + 1, 2, 2); + StringExpandPlaceholders(dest, gText_UnkF908Var1Clear7Var2); + } + break; + case 3: + ConvertIntToDecimalStringN(gStringVar1, itemId - ITEM_CHERI_BERRY + 1, 2, 2); + CopyItemName(itemId, gStringVar2); + StringExpandPlaceholders(dest, gText_UnkF908Var1Clear7Var2); + break; + default: + CopyItemName(itemId, dest); + break; + } +} + +void bag_menu_change_item_callback(u32 a, u8 b) +{ + if (b != 1) + { + PlaySE(SE_SELECT); + ShakeBagVisual(); + } + if (gUnknown_0203CE54->unk81A == 0xFF) + { + RemoveBagItemIconObject(1 ^ gUnknown_0203CE54->unk81B_1); + if (a != -2) + AddBagItemIconObject(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, a), gUnknown_0203CE54->unk81B_1); + else + AddBagItemIconObject(-1, gUnknown_0203CE54->unk81B_1); + gUnknown_0203CE54->unk81B_1 ^= 1; + if (!gUnknown_0203CE54->unk81B_3) + bag_menu_print_description_box_text(a); + } +} + +void sub_81AB520(u8 rboxId, int item_index_in_pocket, u8 a) +{ + u16 itemId; + u16 itemQuantity; + bool8 unique; + int offset; + if (item_index_in_pocket != -2) + { + if (gUnknown_0203CE54->unk81A != 0xFF) + { + if (gUnknown_0203CE54->unk81A == (u8)item_index_in_pocket) + bag_menu_print_cursor(a, 2); + else + bag_menu_print_cursor(a, -1); + } + itemId = BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, item_index_in_pocket); + itemQuantity = BagGetQuantityByPocketPosition(gUnknown_0203CE58.pocket + 1, item_index_in_pocket); + if ((u16)(itemId - ITEM_HM01) <= 7) + BlitBitmapToWindow(rboxId, gBagMenuHMIcon_Gfx, 8, a - 1, 16, 16); + if (gUnknown_0203CE58.pocket == 3) + { + ConvertIntToDecimalStringN(gStringVar1, itemQuantity, 1, 3); + StringExpandPlaceholders(gStringVar4, gText_xVar1); + offset = GetStringRightAlignXOffset(7, gStringVar4, 0x77); + bag_menu_print(rboxId, 7, gStringVar4, offset, a, 0, 0, -1, 0); + } + else if (gUnknown_0203CE58.pocket != 4 && (unique = itemid_is_unique(itemId)) == FALSE) + { + ConvertIntToDecimalStringN(gStringVar1, itemQuantity, 1, 2); + StringExpandPlaceholders(gStringVar4, gText_xVar1); + offset = GetStringRightAlignXOffset(7, gStringVar4, 0x77); + bag_menu_print(rboxId, 7, gStringVar4, offset, a, unique, unique, -1, unique); + } + else + { + if (gSaveBlock1Ptr->registeredItem && gSaveBlock1Ptr->registeredItem == itemId) + BlitBitmapToWindow(rboxId, gUnknown_086140A4, 0x60, a - 1, 0x18, 16); + } + } +} + +void bag_menu_print_description_box_text(int a) +{ + u8* str; + if (a != -2) + str = (u8*)ItemId_GetDescription(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, a)); + else + { + StringCopy(gStringVar1, gReturnToXStringsTable[gUnknown_0203CE58.unk4]); + str = gStringVar4; + StringExpandPlaceholders(str, gText_ReturnToVar1); + } + FillWindowPixelBuffer(1, 0); + bag_menu_print(1, 1, str, 3, 1, 0, 0, 0, 0); +} + +void bag_menu_print_cursor_(u8 a, u8 b) +{ + bag_menu_print_cursor(ListMenuGetYCoordForPrintingArrowCursor(a), b); +} + +void bag_menu_print_cursor(u8 a, u8 b) +{ + if (b == 0xFF) + FillWindowPixelRect(0, 0, 0, a, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); + else + bag_menu_print(0, 1, gText_SelectorArrow2, 0, a, 0, 0, 0, b); + +} + +void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void) +{ + if (gUnknown_0203CE54->unk81E == 0xFF) + gUnknown_0203CE54->unk81E = AddScrollIndicatorArrowPairParametrized(2, 0xAC, 12, 0x94, gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - gUnknown_0203CE54->unk82E[gUnknown_0203CE58.pocket], 0x6E, 0x6E, &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket]); +} + +void sub_81AB824(void) +{ + if (gUnknown_0203CE54->unk81E != 0xFF) + { + RemoveScrollIndicatorArrowPair(gUnknown_0203CE54->unk81E); + gUnknown_0203CE54->unk81E = 0xFF; + } + sub_81AB89C(); +} + +void bag_menu_add_list_scroll_arrow_indicators_maybe(void) +{ + if (gUnknown_0203CE54->unk81B != 1 && gUnknown_0203CE54->unk81F == 0xFF) + gUnknown_0203CE54->unk81F = AddScrollIndicatorArrowPair(&gUnknown_08614094, &gUnknown_0203CE5E); +} + +void sub_81AB89C(void) +{ + if (gUnknown_0203CE54->unk81F != 0xFF) + { + RemoveScrollIndicatorArrowPair(gUnknown_0203CE54->unk81F); + gUnknown_0203CE54->unk81F = 0xFF; + } +} + +void free_bag_item_list_buffers(void) +{ + Free(gUnknown_0203CE78); + Free(gUnknown_0203CE74); + FreeAllWindowBuffers(); + Free(gUnknown_0203CE54); +} + +void unknown_ItemMenu_Confirm(u8 taskId) +{ + BeginNormalPaletteFade(-1, 0, 0, 16, 0); + gTasks[taskId].func = task_close_bag_menu_2; +} + +void task_close_bag_menu_2(u8 taskId) +{ + s16* data = gTasks[taskId].data; + if (!gPaletteFade.active) + { + sub_81AE6C8(data[0], &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]); + if (gUnknown_0203CE54->unk0 != 0) + SetMainCallback2(gUnknown_0203CE54->unk0); + else + SetMainCallback2(gUnknown_0203CE58.func); + sub_81AB824(); + ResetSpriteData(); + FreeAllSpritePalettes(); + free_bag_item_list_buffers(); + DestroyTask(taskId); + } +} + +void sub_81AB9A8(u8 pocketId) +{ + u16 i; + struct BagPocket *pocket = &gBagPockets[pocketId]; + switch (pocketId) + { + case 2: + case 3: + sub_80D6FB4(pocket); + break; + default: + sub_80D6F64(pocket); + break; + } + gUnknown_0203CE54->unk829[pocketId] = 0; + for (i = 0; i < pocket->capacity && pocket->itemSlots[i].itemId; i++) + gUnknown_0203CE54->unk829[pocketId]++; + if (!gUnknown_0203CE54->unk81B_2) + gUnknown_0203CE54->unk829[pocketId]++; + if (gUnknown_0203CE54->unk829[pocketId] > 8) + gUnknown_0203CE54->unk82E[pocketId] = 8; + else + gUnknown_0203CE54->unk82E[pocketId] = gUnknown_0203CE54->unk829[pocketId]; +} + +void sub_81ABA6C(void) +{ + u8 i; + for (i = 0;i < 5;i++) + sub_81AB9A8(i); +} + +void sub_81ABA88(u8 a) +{ + sub_812225C(&gUnknown_0203CE58.unk12[a], &gUnknown_0203CE58.unk8[a], gUnknown_0203CE54->unk82E[a], gUnknown_0203CE54->unk829[a]); +} + +void sub_81ABAC4(void) +{ + u8 i; + for (i = 0;i < 5;i++) + sub_81ABA88(i); +} + +void sub_81ABAE0(void) +{ + u8 i; + for (i = 0;i < 5;i++) + sub_8122298(&gUnknown_0203CE58.unk12[i], &gUnknown_0203CE58.unk8[i], gUnknown_0203CE54->unk82E[i], gUnknown_0203CE54->unk829[i], 8); +} + +u8 sub_81ABB2C(u8 a) +{ + return gUnknown_0203CE58.unk12[a] + gUnknown_0203CE58.unk8[a]; +} + +void DisplayItemMessage(u8 taskId, u8 fontId, u8 *str, void ( *callback)(u8 taskId)) +{ + s16* data = gTasks[taskId].data; + + data[10] = AddItemMessageWindow(4); + FillWindowPixelBuffer(data[10], 17); + DisplayMessageAndContinueTask(taskId, data[10], 10, 13, fontId, GetPlayerTextSpeed(), str, callback); + schedule_bg_copy_tilemap_to_vram(1); +} + +void bag_menu_inits_lists_menu(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u16* ScrollPos = &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket]; + u16* CursorPos = &gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]; + bag_menu_RemoveBagItem_message_window(4); + sub_81AE6C8(data[0], ScrollPos, CursorPos); + sub_81AB9A8(gUnknown_0203CE58.pocket); + sub_81ABA88(gUnknown_0203CE58.pocket); + load_bag_item_list_buffers(gUnknown_0203CE58.pocket); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *ScrollPos, *CursorPos); + schedule_bg_copy_tilemap_to_vram(0); + set_callback3_to_bag(taskId); +} + +void sub_81ABC3C(u8 a) +{ + sub_81ABC54(bag_menu_add_window(a), 1); +} + +void sub_81ABC54(u8 a, s16 b) +{ + u8 r3 = (gUnknown_0203CE58.pocket == 3) ? 3 : 2; + ConvertIntToDecimalStringN(gStringVar1, b, 2, r3); + StringExpandPlaceholders(gStringVar4, gText_xVar1); + PrintTextOnWindow(a, 1, gStringVar4, GetStringCenterAlignXOffset(1, gStringVar4, 0x28), 2, 0, 0); +} + +void sub_81ABCC0(int a, int b, int c) +{ + u8 r3 = (gUnknown_0203CE58.pocket == 3) ? 3 : 2; + ConvertIntToDecimalStringN(gStringVar1, b, 2, r3); + StringExpandPlaceholders(gStringVar4, gText_xVar1); + PrintTextOnWindow(a, 1, gStringVar4, 0, 1, -1, 0); + PrintMoneyAmount(a, 0x26, 1, c, 0); +} + +/* void Task_BagMenu(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u16* ScrollPos = &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket]; + u16* CursorPos = &gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]; + u16 select; + if (sub_81221EC() != TRUE && !gPaletteFade.active) + { + switch (GetSwitchBagPocketDirection()) + { + case 1: + SwitchBagPocket(taskId, -1, 0); + return; + case 2: + SwitchBagPocket(taskId, 1, 0); + return; + } + if ((select = (gMain.newKeys & SELECT_BUTTON))) + { + if (sub_81AC2C0()) + { + sub_81AE860(data[0], ScrollPos, CursorPos); + if ((*ScrollPos + *CursorPos) != gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - 1) + { + PlaySE(SE_SELECT); + bag_menu_swap_items(taskId); + } + } + return; + } + else + { + int r4 = ListMenuHandleInputGetItemId(data[0]); + sub_81AE860(data[0], ScrollPos, CursorPos); + if (r4 != -2) + { + if (r4 != -1) + { + PlaySE(SE_SELECT); + sub_81AB824(); + bag_menu_print_cursor_(data[0], 2); + data[1] = r4; + data[2] = BagGetQuantityByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); + gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); + gUnknown_08614054[gUnknown_0203CE58.unk4](taskId); + } + } + else if (gUnknown_0203CE58.unk4 == 5) + PlaySE(SE_HAZURE); + else + { + PlaySE(SE_SELECT); + gSpecialVar_ItemId = select; + gTasks[taskId].func = unknown_ItemMenu_Confirm; + } + } + } +} */ From 59b0e698204e7c772325afb9bb996202c2bd5c3e Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Tue, 30 Jan 2018 13:22:59 -0500 Subject: [PATCH 02/12] adding ld_script --- ld_script.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ld_script.txt b/ld_script.txt index f2a9d8196..4966fadc2 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -250,6 +250,7 @@ SECTIONS { asm/new_menu_helpers.o(.text); asm/menu.o(.text); asm/battle_frontier_2.o(.text); + src/item_menu.o(.text); asm/item_menu.o(.text); asm/list_menu.o(.text); asm/menu_indicators.o(.text); From f220ac971c72aeeef1b2affaf149f4c5aa7d0058 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Tue, 30 Jan 2018 15:26:46 -0500 Subject: [PATCH 03/12] got Task_BagMenu closer --- src/item_menu.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/item_menu.c b/src/item_menu.c index 9d7afbb24..f623753dc 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -790,7 +790,7 @@ void sub_81ABCC0(int a, int b, int c) } if ((select = (gMain.newKeys & SELECT_BUTTON))) { - if (sub_81AC2C0()) + if (sub_81AC2C0() == 1) { sub_81AE860(data[0], ScrollPos, CursorPos); if ((*ScrollPos + *CursorPos) != gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - 1) @@ -805,10 +805,19 @@ void sub_81ABCC0(int a, int b, int c) { int r4 = ListMenuHandleInputGetItemId(data[0]); sub_81AE860(data[0], ScrollPos, CursorPos); - if (r4 != -2) + switch (r4) { - if (r4 != -1) - { + default: + if (gUnknown_0203CE58.unk4 == 5) + { + PlaySE(SE_HAZURE); + return; + } + PlaySE(SE_SELECT); + gSpecialVar_ItemId = select; + gTasks[taskId].func = unknown_ItemMenu_Confirm; + return; + case -2: PlaySE(SE_SELECT); sub_81AB824(); bag_menu_print_cursor_(data[0], 2); @@ -816,16 +825,13 @@ void sub_81ABCC0(int a, int b, int c) data[2] = BagGetQuantityByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); gUnknown_08614054[gUnknown_0203CE58.unk4](taskId); - } - } - else if (gUnknown_0203CE58.unk4 == 5) - PlaySE(SE_HAZURE); - else - { - PlaySE(SE_SELECT); - gSpecialVar_ItemId = select; - gTasks[taskId].func = unknown_ItemMenu_Confirm; + case -1: + break; + + + } + } } } */ From 092da42723713105c4a4ecc42f230a9a364bd0a4 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Tue, 30 Jan 2018 16:12:40 -0500 Subject: [PATCH 04/12] decompiled up to set_callback3_to_bag --- asm/item_menu.s | 185 ------------------------------------------------ src/item_menu.c | 37 ++++++---- 2 files changed, 22 insertions(+), 200 deletions(-) diff --git a/asm/item_menu.s b/asm/item_menu.s index fe0a8167e..1da71d466 100644 --- a/asm/item_menu.s +++ b/asm/item_menu.s @@ -5,191 +5,6 @@ .text - thumb_func_start Task_BagMenu -Task_BagMenu: @ 81ABD28 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - mov r9, r0 - lsls r0, 2 - add r0, r9 - lsls r0, 3 - str r0, [sp] - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - ldr r5, =gUnknown_0203CE58 - ldrb r0, [r5, 0x5] - lsls r0, 1 - adds r1, r5, 0 - adds r1, 0x12 - adds r7, r0, r1 - subs r1, 0xA - adds r0, r1 - mov r8, r0 - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081ABD66 - b _081ABEB2 -_081ABD66: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _081ABD74 - b _081ABEB2 -_081ABD74: - bl GetSwitchBagPocketDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081ABDB8 - cmp r0, 0x2 - beq _081ABDC0 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x4 - ands r0, r1 - lsls r0, 16 - lsrs r0, 16 - mov r10, r0 - cmp r0, 0 - beq _081ABE10 - bl sub_81AC2C0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081ABDA4 - b _081ABEB2 -_081ABDA4: - b _081ABDCC - .pool -_081ABDB8: - movs r1, 0x1 - negs r1, r1 - mov r0, r9 - b _081ABDC4 -_081ABDC0: - mov r0, r9 - movs r1, 0x1 -_081ABDC4: - movs r2, 0 - bl SwitchBagPocket - b _081ABEB2 -_081ABDCC: - ldrb r0, [r6] - adds r1, r7, 0 - mov r2, r8 - bl sub_81AE860 - ldrh r2, [r7] - mov r3, r8 - ldrh r0, [r3] - adds r2, r0 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =gUnknown_0203CE58 - ldr r3, =0x00000829 - adds r0, r3 - ldrb r1, [r1, 0x5] - adds r0, r1 - ldrb r0, [r0] - subs r0, 0x1 - cmp r2, r0 - beq _081ABEB2 - movs r0, 0x5 - bl PlaySE - mov r0, r9 - bl bag_menu_swap_items - b _081ABEB2 - .pool -_081ABE10: - ldrb r0, [r6] - bl ListMenuHandleInputGetItemId - adds r4, r0, 0 - ldrb r0, [r6] - adds r1, r7, 0 - mov r2, r8 - bl sub_81AE860 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _081ABE32 - adds r0, 0x1 - cmp r4, r0 - bne _081ABE68 - b _081ABEB2 -_081ABE32: - ldrb r0, [r5, 0x4] - cmp r0, 0x5 - bne _081ABE40 - movs r0, 0x20 - bl PlaySE - b _081ABEB2 -_081ABE40: - movs r0, 0x5 - bl PlaySE - ldr r0, =gSpecialVar_ItemId - mov r1, r10 - strh r1, [r0] - ldr r0, =gTasks + 0x8 - subs r0, 0x8 - ldr r3, [sp] - adds r0, r3, r0 - ldr r1, =unknown_ItemMenu_Confirm - str r1, [r0] - b _081ABEB2 - .pool -_081ABE68: - movs r0, 0x5 - bl PlaySE - bl sub_81AB824 - ldrb r0, [r6] - movs r1, 0x2 - bl bag_menu_print_cursor_ - strh r4, [r6, 0x2] - ldrb r0, [r5, 0x5] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - lsls r4, 16 - lsrs r4, 16 - adds r1, r4, 0 - bl BagGetQuantityByPocketPosition - strh r0, [r6, 0x4] - ldrb r0, [r5, 0x5] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - bl BagGetItemIdByPocketPosition - ldr r1, =gSpecialVar_ItemId - strh r0, [r1] - ldr r1, =gUnknown_08614054 - ldrb r0, [r5, 0x4] - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - mov r0, r9 - bl _call_via_r1 -_081ABEB2: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end Task_BagMenu - thumb_func_start set_callback3_to_bag set_callback3_to_bag: @ 81ABECC push {r4,lr} diff --git a/src/item_menu.c b/src/item_menu.c index f623753dc..2ee586ce5 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -771,7 +771,7 @@ void sub_81ABCC0(int a, int b, int c) PrintMoneyAmount(a, 0x26, 1, c, 0); } -/* void Task_BagMenu(u8 taskId) +void Task_BagMenu(u8 taskId) { s16* data = gTasks[taskId].data; u16* ScrollPos = &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket]; @@ -807,17 +807,19 @@ void sub_81ABCC0(int a, int b, int c) sub_81AE860(data[0], ScrollPos, CursorPos); switch (r4) { - default: + case -1: + break; + case -2: if (gUnknown_0203CE58.unk4 == 5) { PlaySE(SE_HAZURE); - return; + break; } - PlaySE(SE_SELECT); - gSpecialVar_ItemId = select; - gTasks[taskId].func = unknown_ItemMenu_Confirm; - return; - case -2: + PlaySE(SE_SELECT); + gSpecialVar_ItemId = select; + gTasks[taskId].func = unknown_ItemMenu_Confirm; + break; + default: PlaySE(SE_SELECT); sub_81AB824(); bag_menu_print_cursor_(data[0], 2); @@ -825,13 +827,18 @@ void sub_81ABCC0(int a, int b, int c) data[2] = BagGetQuantityByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); gUnknown_08614054[gUnknown_0203CE58.unk4](taskId); - case -1: - break; - - - } - } } -} */ +} + +void set_callback3_to_bag(u8 taskId) +{ + bag_menu_add_pocket_scroll_arrow_indicators_maybe(); + bag_menu_add_list_scroll_arrow_indicators_maybe(); + ClearWindowTilemap(3); + ClearWindowTilemap(4); + PutWindowTilemap(1); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].func = Task_BagMenu; +} From 821ede4674a7f5271ea06b97a5555312bbb1f6a0 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Tue, 30 Jan 2018 23:54:58 -0500 Subject: [PATCH 05/12] remove set_callback3_to_bag from asm --- asm/item_menu.s | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/asm/item_menu.s b/asm/item_menu.s index 1da71d466..eef202b22 100644 --- a/asm/item_menu.s +++ b/asm/item_menu.s @@ -5,35 +5,6 @@ .text - thumb_func_start set_callback3_to_bag -set_callback3_to_bag: @ 81ABECC - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl bag_menu_add_pocket_scroll_arrow_indicators_maybe - bl bag_menu_add_list_scroll_arrow_indicators_maybe - movs r0, 0x3 - bl ClearWindowTilemap - movs r0, 0x4 - bl ClearWindowTilemap - movs r0, 0x1 - bl PutWindowTilemap - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =Task_BagMenu - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end set_callback3_to_bag - thumb_func_start GetSwitchBagPocketDirection GetSwitchBagPocketDirection: @ 81ABF10 push {lr} From 155a3710640a9814686c9c3a261d5dc5575cc6d1 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 31 Jan 2018 00:03:52 -0500 Subject: [PATCH 06/12] decompile set_callback3_to_bag --- src/item_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item_menu.c b/src/item_menu.c index 2ee586ce5..3e2282583 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -16,13 +16,13 @@ #include "new_menu_helpers.h" #include "palette.h" #include "rom_818CFC8.h" +#include "scanline_effect.h" #include "sound.h" #include "sprite.h" #include "string.h" #include "string_util.h" #include "task.h" #include "menu_helpers.h" -#include "unknown_task.h" #include "window.h" struct bagStruct { From 0a67b1d80ca5b80546058878130f26746c6e3f7f Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 31 Jan 2018 20:22:51 -0500 Subject: [PATCH 07/12] decompiled up to sub_81AC10C --- asm/item_menu.s | 369 ------------------------------------------------ src/item_menu.c | 283 ++++++++++++++++++++++++++++++++++++- 2 files changed, 280 insertions(+), 372 deletions(-) diff --git a/asm/item_menu.s b/asm/item_menu.s index eef202b22..5ae0f9973 100644 --- a/asm/item_menu.s +++ b/asm/item_menu.s @@ -5,375 +5,6 @@ .text - thumb_func_start GetSwitchBagPocketDirection -GetSwitchBagPocketDirection: @ 81ABF10 - push {lr} - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x0000081b - adds r0, r1 - ldrb r1, [r0] - movs r0, 0xF - ands r0, r1 - cmp r0, 0 - bne _081ABF6A - bl GetLRKeysState - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - bne _081ABF3C - cmp r2, 0x1 - bne _081ABF54 -_081ABF3C: - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - b _081ABF6C - .pool -_081ABF54: - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _081ABF60 - cmp r2, 0x2 - bne _081ABF6A -_081ABF60: - movs r0, 0x5 - bl PlaySE - movs r0, 0x2 - b _081ABF6C -_081ABF6A: - movs r0, 0 -_081ABF6C: - pop {r1} - bx r1 - thumb_func_end GetSwitchBagPocketDirection - - thumb_func_start ChangeBagPocketId -@ void ChangeBagPocketId(u8 *bagPocketId, u8 deltaBagPocketId) -ChangeBagPocketId: @ 81ABF70 - push {r4,lr} - adds r2, r0, 0 - lsls r1, 24 - lsrs r4, r1, 24 - asrs r1, 24 - cmp r1, 0x1 - bne _081ABF88 - ldrb r0, [r2] - cmp r0, 0x4 - bne _081ABF88 - movs r0, 0 - b _081ABFA0 -_081ABF88: - lsls r0, r4, 24 - asrs r0, 24 - movs r1, 0x1 - negs r1, r1 - ldrb r3, [r2] - cmp r0, r1 - bne _081ABF9E - cmp r3, 0 - bne _081ABF9E - movs r0, 0x4 - b _081ABFA0 -_081ABF9E: - adds r0, r3, r4 -_081ABFA0: - strb r0, [r2] - pop {r4} - pop {r0} - bx r0 - thumb_func_end ChangeBagPocketId - - thumb_func_start SwitchBagPocket -@ void SwitchBagPocket(u8 taskId, u16 deltaBagPocketId, u16 a3) -SwitchBagPocket: @ 81ABFA8 - push {r4-r6,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 16 - lsrs r5, r1, 16 - lsls r2, 16 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - movs r0, 0 - strh r0, [r4, 0x1A] - strh r0, [r4, 0x18] - strh r5, [r4, 0x16] - cmp r2, 0 - bne _081AC026 - movs r0, 0 - bl ClearWindowTilemap - movs r0, 0x1 - bl ClearWindowTilemap - ldrb r0, [r4] - ldr r3, =gUnknown_0203CE58 - ldrb r2, [r3, 0x5] - lsls r2, 1 - adds r1, r3, 0 - adds r1, 0x12 - adds r1, r2, r1 - adds r3, 0x8 - adds r2, r3 - bl sub_81AE6C8 - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r3, =gSprites - ldr r0, =gUnknown_0203CE54 - ldr r2, [r0] - ldr r1, =0x0000081b - adds r0, r2, r1 - ldrb r1, [r0] - lsls r1, 26 - lsrs r1, 30 - movs r0, 0x1 - eors r0, r1 - adds r2, r0 - ldr r0, =0x00000806 - adds r2, r0 - ldrb r1, [r2] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r3 - adds r0, 0x3E - ldrb r1, [r0] - movs r2, 0x4 - orrs r1, r2 - strb r1, [r0] - bl sub_81AB824 -_081AC026: - ldr r4, =gUnknown_0203CE58 - ldrb r1, [r4, 0x5] - add r0, sp, 0x8 - strb r1, [r0] - lsls r1, r5, 24 - asrs r1, 24 - bl ChangeBagPocketId - lsls r0, r5, 16 - asrs r1, r0, 16 - adds r5, r0, 0 - cmp r1, 0x1 - bne _081AC07C - ldr r2, =gPocketNamesStringsTable - ldrb r0, [r4, 0x5] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - add r1, sp, 0x8 - ldrb r1, [r1] - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - bl bag_menu_print_pocket_names - movs r0, 0 - bl bag_menu_copy_pocket_name_to_window - b _081AC09A - .pool -_081AC07C: - ldr r2, =gPocketNamesStringsTable - add r0, sp, 0x8 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r2 - ldr r0, [r0] - ldrb r1, [r4, 0x5] - lsls r1, 2 - adds r1, r2 - ldr r1, [r1] - bl bag_menu_print_pocket_names - movs r0, 0x8 - bl bag_menu_copy_pocket_name_to_window -_081AC09A: - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - movs r1, 0 - bl bag_menu_draw_pocket_indicator_square - add r0, sp, 0x8 - ldrb r0, [r0] - movs r1, 0x1 - bl bag_menu_draw_pocket_indicator_square - movs r0, 0xF - str r0, [sp] - movs r0, 0x10 - str r0, [sp, 0x4] - movs r0, 0x2 - movs r1, 0xB - movs r2, 0xE - movs r3, 0x2 - bl FillBgTilemapBufferRect_Palette0 - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - add r0, sp, 0x8 - ldrb r0, [r0] - movs r1, 0x1 - bl SetBagVisualPocketId - movs r0, 0x1 - bl RemoveBagObject - asrs r0, r5, 16 - bl AddSwitchPocketRotatingBallObject - ldr r1, =sub_81AC10C - ldr r2, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r2 - ldr r2, [r0] - adds r0, r6, 0 - bl SetTaskFuncWithFollowupFunc - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end SwitchBagPocket - - thumb_func_start sub_81AC10C -sub_81AC10C: @ 81AC10C - push {r4-r7,lr} - lsls r0, 24 - lsrs r7, r0, 24 - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - bl sub_81221AC - lsls r0, 24 - cmp r0, 0 - bne _081AC184 - bl IsWallysBag - lsls r0, 24 - cmp r0, 0 - bne _081AC184 - bl GetSwitchBagPocketDirection - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081AC148 - cmp r0, 0x2 - beq _081AC164 - b _081AC184 - .pool -_081AC148: - ldr r0, =gUnknown_0203CE5D - movs r1, 0x16 - ldrsb r1, [r6, r1] - bl ChangeBagPocketId - adds r0, r7, 0 - bl SwitchTaskToFollowupFunc - movs r1, 0x1 - negs r1, r1 - adds r0, r7, 0 - b _081AC178 - .pool -_081AC164: - ldr r0, =gUnknown_0203CE5D - movs r1, 0x16 - ldrsb r1, [r6, r1] - bl ChangeBagPocketId - adds r0, r7, 0 - bl SwitchTaskToFollowupFunc - adds r0, r7, 0 - movs r1, 0x1 -_081AC178: - movs r2, 0x1 - bl SwitchBagPocket - b _081AC22E - .pool -_081AC184: - movs r1, 0x1A - ldrsh r0, [r6, r1] - cmp r0, 0 - beq _081AC192 - cmp r0, 0x1 - beq _081AC1DC - b _081AC22E -_081AC192: - ldrb r0, [r6, 0x18] - bl sub_81AC23C - ldrh r0, [r6, 0x18] - adds r1, r0, 0x1 - strh r1, [r6, 0x18] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _081AC1CC - movs r2, 0x16 - ldrsh r0, [r6, r2] - cmp r0, 0x1 - bne _081AC1BC - lsls r0, r1, 16 - asrs r0, 17 - lsls r0, 24 - lsrs r0, 24 - bl bag_menu_copy_pocket_name_to_window - b _081AC1CC -_081AC1BC: - lsls r1, 16 - asrs r1, 17 - movs r0, 0x8 - subs r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl bag_menu_copy_pocket_name_to_window -_081AC1CC: - movs r1, 0x18 - ldrsh r0, [r6, r1] - cmp r0, 0x10 - bne _081AC22E - ldrh r0, [r6, 0x1A] - adds r0, 0x1 - strh r0, [r6, 0x1A] - b _081AC22E -_081AC1DC: - ldr r4, =gUnknown_0203CE5D - movs r1, 0x16 - ldrsb r1, [r6, r1] - adds r0, r4, 0 - bl ChangeBagPocketId - subs r5, r4, 0x5 - ldrb r0, [r5, 0x5] - bl load_bag_item_list_buffers - ldr r0, =gMultiuseListMenuTemplate - ldrb r2, [r5, 0x5] - lsls r2, 1 - adds r1, r4, 0 - adds r1, 0xD - adds r1, r2, r1 - ldrh r1, [r1] - adds r4, 0x3 - adds r2, r4 - ldrh r2, [r2] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r6] - movs r0, 0x1 - bl PutWindowTilemap - movs r0, 0x2 - bl PutWindowTilemap - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - bl bag_menu_add_pocket_scroll_arrow_indicators_maybe - bl bag_menu_add_list_scroll_arrow_indicators_maybe - adds r0, r7, 0 - bl SwitchTaskToFollowupFunc -_081AC22E: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AC10C - thumb_func_start sub_81AC23C sub_81AC23C: @ 81AC23C push {lr} diff --git a/src/item_menu.c b/src/item_menu.c index 3e2282583..00ba284bd 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -39,7 +39,8 @@ struct unkBagStruct { void* unk0; u8 unk4[0x800]; u8 unk804; - u8 filler4[11]; + u8 filler4; + u8 unk806[10]; u8 unk810[10]; u8 unk81A; u8 unk81B:4; @@ -92,6 +93,8 @@ extern u8 GetMenuCursorDimensionByFont(u8, u8); extern u8 AddScrollIndicatorArrowPair(void*, void*); extern void sub_80D6FB4(struct BagPocket*); extern void sub_80D6F64(struct BagPocket*); +extern u8 GetLRKeysState(void); +extern void sub_81AC23C(u8); void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()); void CB2_Bag(void); @@ -101,7 +104,7 @@ bool8 load_bag_menu_graphics(void); void setup_bag_menu_textboxes(void); void allocate_bag_item_list_buffers(void); void load_bag_item_list_buffers(u8); -void bag_menu_print_pocket_names(u8*, u8); +void bag_menu_print_pocket_names(u8*, u8*); void bag_menu_copy_pocket_name_to_window(u8); void bag_menu_draw_pocket_indicator_square(u8, u8); void AddBagVisualObject(u8); @@ -129,9 +132,13 @@ void set_callback3_to_bag(u8); void sub_81ABC54(u8, s16); u8 bag_menu_add_window(u8); u8 GetSwitchBagPocketDirection(void); -void SwitchBagPocket(u8, s8, u8); +void SwitchBagPocket(u8, s16, u16); bool8 sub_81AC2C0(void); void bag_menu_swap_items(u8); +void SetBagVisualPocketId(u8, u8); +void RemoveBagObject(u8); +void AddSwitchPocketRotatingBallObject(s16); +void sub_81AC10C(u8); extern u8 *gPocketNamesStringsTable[]; extern struct BgTemplate gUnknown_08613F90[]; @@ -842,3 +849,273 @@ void set_callback3_to_bag(u8 taskId) schedule_bg_copy_tilemap_to_vram(0); gTasks[taskId].func = Task_BagMenu; } + +u8 GetSwitchBagPocketDirection(void) +{ + u8 LRKeys; + if (gUnknown_0203CE54->unk81B != 0) + return 0; + LRKeys = GetLRKeysState(); + if ((gMain.newKeys & DPAD_LEFT) || LRKeys == 1) + { + PlaySE(SE_SELECT); + return 1; + } + if ((gMain.newKeys & DPAD_RIGHT) || LRKeys == 2) + { + PlaySE(SE_SELECT); + return 2; + } + return 0; +} + + +void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId) +{ + if (deltaBagPocketId == 1 && *bagPocketId == 4) + *bagPocketId = 0; + else if (deltaBagPocketId == -1 && *bagPocketId == 0) + { + *bagPocketId = 4; + } + else + *bagPocketId += deltaBagPocketId; +} + +#ifdef NONMATCHING +void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) +{ + s16* data = gTasks[taskId].data; + u8 pocketId; + + + data[13] = 0; + data[12] = 0; + data[11] = deltaBagPocketId; + if (a3 == 0) + { + ClearWindowTilemap(0); + ClearWindowTilemap(1); + sub_81AE6C8(data[0], &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]); + schedule_bg_copy_tilemap_to_vram(0); + gSprites[gUnknown_0203CE54->unk806[gUnknown_0203CE54->unk81B_1 ^ 1]].invisible = 1; + sub_81AB824(); + } + pocketId = gUnknown_0203CE58.pocket; + ChangeBagPocketId(&pocketId, deltaBagPocketId); + if (deltaBagPocketId == 1) + { + bag_menu_print_pocket_names(gPocketNamesStringsTable[gUnknown_0203CE58.pocket], gPocketNamesStringsTable[pocketId]); + bag_menu_copy_pocket_name_to_window(0); + } + else + { + bag_menu_print_pocket_names(gPocketNamesStringsTable[pocketId], gPocketNamesStringsTable[gUnknown_0203CE58.pocket]); + bag_menu_copy_pocket_name_to_window(8); + } + bag_menu_draw_pocket_indicator_square(gUnknown_0203CE58.pocket, 0); + bag_menu_draw_pocket_indicator_square(pocketId, 1); + FillBgTilemapBufferRect_Palette0(2, 11, 14, 2, 15, 16); + schedule_bg_copy_tilemap_to_vram(2); + SetBagVisualPocketId(pocketId, 1); + RemoveBagObject(1); + AddSwitchPocketRotatingBallObject(deltaBagPocketId); + SetTaskFuncWithFollowupFunc(taskId, sub_81AC10C, gTasks[taskId].func); +} +#else +__attribute__((naked)) +void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) +{ + asm(".syntax unified\n\ + push {r4-r6,lr}\n\ + sub sp, 0xC\n\ + lsls r0, 24\n\ + lsrs r6, r0, 24\n\ + lsls r1, 16\n\ + lsrs r5, r1, 16\n\ + lsls r2, 16\n\ + lsls r0, r6, 2\n\ + adds r0, r6\n\ + lsls r0, 3\n\ + ldr r1, =gTasks + 0x8\n\ + adds r4, r0, r1\n\ + movs r0, 0\n\ + strh r0, [r4, 0x1A]\n\ + strh r0, [r4, 0x18]\n\ + strh r5, [r4, 0x16]\n\ + cmp r2, 0\n\ + bne _081AC026\n\ + movs r0, 0\n\ + bl ClearWindowTilemap\n\ + movs r0, 0x1\n\ + bl ClearWindowTilemap\n\ + ldrb r0, [r4]\n\ + ldr r3, =gUnknown_0203CE58\n\ + ldrb r2, [r3, 0x5]\n\ + lsls r2, 1\n\ + adds r1, r3, 0\n\ + adds r1, 0x12\n\ + adds r1, r2, r1\n\ + adds r3, 0x8\n\ + adds r2, r3\n\ + bl sub_81AE6C8\n\ + movs r0, 0\n\ + bl schedule_bg_copy_tilemap_to_vram\n\ + ldr r3, =gSprites\n\ + ldr r0, =gUnknown_0203CE54\n\ + ldr r2, [r0]\n\ + ldr r1, =0x0000081b\n\ + adds r0, r2, r1\n\ + ldrb r1, [r0]\n\ + lsls r1, 26\n\ + lsrs r1, 30\n\ + movs r0, 0x1\n\ + eors r0, r1\n\ + adds r2, r0\n\ + ldr r0, =0x00000806\n\ + adds r2, r0\n\ + ldrb r1, [r2]\n\ + lsls r0, r1, 4\n\ + adds r0, r1\n\ + lsls r0, 2\n\ + adds r0, r3\n\ + adds r0, 0x3E\n\ + ldrb r1, [r0]\n\ + movs r2, 0x4\n\ + orrs r1, r2\n\ + strb r1, [r0]\n\ + bl sub_81AB824\n\ +_081AC026:\n\ + ldr r4, =gUnknown_0203CE58\n\ + ldrb r1, [r4, 0x5]\n\ + add r0, sp, 0x8\n\ + strb r1, [r0]\n\ + lsls r1, r5, 24\n\ + asrs r1, 24\n\ + bl ChangeBagPocketId\n\ + lsls r0, r5, 16\n\ + asrs r1, r0, 16\n\ + adds r5, r0, 0\n\ + cmp r1, 0x1\n\ + bne _081AC07C\n\ + ldr r2, =gPocketNamesStringsTable\n\ + ldrb r0, [r4, 0x5]\n\ + lsls r0, 2\n\ + adds r0, r2\n\ + ldr r0, [r0]\n\ + add r1, sp, 0x8\n\ + ldrb r1, [r1]\n\ + lsls r1, 2\n\ + adds r1, r2\n\ + ldr r1, [r1]\n\ + bl bag_menu_print_pocket_names\n\ + movs r0, 0\n\ + bl bag_menu_copy_pocket_name_to_window\n\ + b _081AC09A\n\ + .pool\n\ +_081AC07C:\n\ + ldr r2, =gPocketNamesStringsTable\n\ + add r0, sp, 0x8\n\ + ldrb r0, [r0]\n\ + lsls r0, 2\n\ + adds r0, r2\n\ + ldr r0, [r0]\n\ + ldrb r1, [r4, 0x5]\n\ + lsls r1, 2\n\ + adds r1, r2\n\ + ldr r1, [r1]\n\ + bl bag_menu_print_pocket_names\n\ + movs r0, 0x8\n\ + bl bag_menu_copy_pocket_name_to_window\n\ +_081AC09A:\n\ + ldr r0, =gUnknown_0203CE58\n\ + ldrb r0, [r0, 0x5]\n\ + movs r1, 0\n\ + bl bag_menu_draw_pocket_indicator_square\n\ + add r0, sp, 0x8\n\ + ldrb r0, [r0]\n\ + movs r1, 0x1\n\ + bl bag_menu_draw_pocket_indicator_square\n\ + movs r0, 0xF\n\ + str r0, [sp]\n\ + movs r0, 0x10\n\ + str r0, [sp, 0x4]\n\ + movs r0, 0x2\n\ + movs r1, 0xB\n\ + movs r2, 0xE\n\ + movs r3, 0x2\n\ + bl FillBgTilemapBufferRect_Palette0\n\ + movs r0, 0x2\n\ + bl schedule_bg_copy_tilemap_to_vram\n\ + add r0, sp, 0x8\n\ + ldrb r0, [r0]\n\ + movs r1, 0x1\n\ + bl SetBagVisualPocketId\n\ + movs r0, 0x1\n\ + bl RemoveBagObject\n\ + asrs r0, r5, 16\n\ + bl AddSwitchPocketRotatingBallObject\n\ + ldr r1, =sub_81AC10C\n\ + ldr r2, =gTasks\n\ + lsls r0, r6, 2\n\ + adds r0, r6\n\ + lsls r0, 3\n\ + adds r0, r2\n\ + ldr r2, [r0]\n\ + adds r0, r6, 0\n\ + bl SetTaskFuncWithFollowupFunc\n\ + add sp, 0xC\n\ + pop {r4-r6}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided\n"); +} +#endif + +void sub_81AC10C(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + if (!sub_81221AC() && !IsWallysBag()) + { + switch (GetSwitchBagPocketDirection()) + { + case 1: + ChangeBagPocketId(&gUnknown_0203CE58.pocket, data[11]); + SwitchTaskToFollowupFunc(taskId); + SwitchBagPocket(taskId, -1, 1); + return; + case 2: + ChangeBagPocketId(&gUnknown_0203CE58.pocket, data[11]); + SwitchTaskToFollowupFunc(taskId); + SwitchBagPocket(taskId, 1, 1); + return; + } + } + switch (data[13]) + { + case 0: + sub_81AC23C(data[12]); + if (!(++data[12] & 1)) + { + if (data[11] == 1) + bag_menu_copy_pocket_name_to_window(data[12] >> 1); + else + bag_menu_copy_pocket_name_to_window(8 - (data[12] >> 1)); + } + if (data[12] == 16) + data[13]++; + break; + case 1: + ChangeBagPocketId(&gUnknown_0203CE58.pocket, data[11]); + load_bag_item_list_buffers(gUnknown_0203CE58.pocket); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]); + PutWindowTilemap(1); + PutWindowTilemap(2); + schedule_bg_copy_tilemap_to_vram(0); + bag_menu_add_pocket_scroll_arrow_indicators_maybe(); + bag_menu_add_list_scroll_arrow_indicators_maybe(); + SwitchTaskToFollowupFunc(taskId); + } +} From 5f7709dc8bf1bf4eb75d9481e285980f347d5dd7 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Sun, 4 Feb 2018 23:47:47 -0500 Subject: [PATCH 08/12] decompile item_menu --- asm/item_menu.s | 3823 ----------------------------------------------- ld_script.txt | 1 - src/item_menu.c | 1353 ++++++++++++++++- 3 files changed, 1313 insertions(+), 3864 deletions(-) delete mode 100644 asm/item_menu.s diff --git a/asm/item_menu.s b/asm/item_menu.s deleted file mode 100644 index 5ae0f9973..000000000 --- a/asm/item_menu.s +++ /dev/null @@ -1,3823 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_81AC23C -sub_81AC23C: @ 81AC23C - push {lr} - sub sp, 0x8 - adds r3, r0, 0 - lsls r3, 24 - movs r0, 0x80 - lsls r0, 18 - adds r3, r0 - lsrs r3, 24 - movs r0, 0xF - str r0, [sp] - movs r0, 0x1 - str r0, [sp, 0x4] - movs r0, 0x2 - movs r1, 0x11 - movs r2, 0xE - bl FillBgTilemapBufferRect_Palette0 - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - add sp, 0x8 - pop {r0} - bx r0 - thumb_func_end sub_81AC23C - - thumb_func_start bag_menu_draw_pocket_indicator_square -@ void bag_menu_draw_pocket_indicator_square(char x, int is_current_bag) -bag_menu_draw_pocket_indicator_square: @ 81AC26C - push {lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - cmp r1, 0 - bne _081AC298 - ldr r1, =0x00001017 - adds r2, r0, 0x5 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x1 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0x2 - movs r3, 0x3 - bl FillBgTilemapBufferRect_Palette0 - b _081AC2AE - .pool -_081AC298: - ldr r1, =0x0000102b - adds r2, r0, 0x5 - lsls r2, 24 - lsrs r2, 24 - movs r0, 0x1 - str r0, [sp] - str r0, [sp, 0x4] - movs r0, 0x2 - movs r3, 0x3 - bl FillBgTilemapBufferRect_Palette0 -_081AC2AE: - movs r0, 0x2 - bl schedule_bg_copy_tilemap_to_vram - add sp, 0x8 - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_draw_pocket_indicator_square - - thumb_func_start sub_81AC2C0 -sub_81AC2C0: @ 81AC2C0 - push {lr} - ldr r1, =gUnknown_0203CE58 - ldrb r0, [r1, 0x4] - cmp r0, 0x1 - bhi _081AC2E0 - ldrb r0, [r1, 0x5] - subs r0, 0x2 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bls _081AC2E0 - movs r0, 0x1 - b _081AC2E2 - .pool -_081AC2E0: - movs r0, 0 -_081AC2E2: - pop {r1} - bx r1 - thumb_func_end sub_81AC2C0 - - thumb_func_start bag_menu_swap_items -bag_menu_swap_items: @ 81AC2E8 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - mov r9, r0 - adds r6, r4, r0 - ldrb r0, [r6] - movs r1, 0x10 - movs r2, 0x1 - bl sub_81AF15C - ldr r3, =gUnknown_0203CE58 - ldrb r0, [r3, 0x5] - lsls r0, 1 - adds r2, r3, 0 - adds r2, 0x12 - adds r2, r0, r2 - adds r1, r3, 0 - adds r1, 0x8 - adds r0, r1 - ldrh r1, [r0] - ldrh r2, [r2] - adds r1, r2 - strh r1, [r6, 0x2] - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r2, =0x0000081a - adds r0, r2 - movs r5, 0 - strb r1, [r0] - ldrb r0, [r3, 0x5] - adds r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r6, 0x2] - bl BagGetItemIdByPocketPosition - lsls r0, 16 - lsrs r0, 16 - ldr r1, =gStringVar1 - bl CopyItemName - ldr r0, =gStringVar4 - mov r8, r0 - ldr r1, =gText_MoveVar1Where - bl StringExpandPlaceholders - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x1 - str r0, [sp] - str r5, [sp, 0x4] - str r5, [sp, 0x8] - str r5, [sp, 0xC] - str r5, [sp, 0x10] - movs r1, 0x1 - mov r2, r8 - movs r3, 0x3 - bl bag_menu_print - ldrb r0, [r6, 0x2] - bl sub_80D4FEC - bl sub_81AB89C - ldrb r0, [r6] - movs r1, 0x2 - bl bag_menu_print_cursor_ - movs r2, 0x8 - negs r2, r2 - add r9, r2 - add r4, r9 - ldr r0, =sub_81AC3C0 - str r0, [r4] - add sp, 0x14 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_swap_items - - thumb_func_start sub_81AC3C0 -@ void sub_81AC3C0(u8 taskId) -sub_81AC3C0: @ 81AC3C0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081AC48E - ldr r0, =gMain - mov r8, r0 - ldrh r1, [r0, 0x2E] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _081AC418 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4] - ldr r3, =gUnknown_0203CE58 - ldrb r2, [r3, 0x5] - lsls r2, 1 - adds r1, r3, 0 - adds r1, 0x12 - adds r1, r2, r1 - adds r3, 0x8 - adds r2, r3 - bl sub_81AE860 - b _081AC472 - .pool -_081AC418: - ldrb r0, [r4] - bl ListMenuHandleInputGetItemId - adds r7, r0, 0 - ldrb r0, [r4] - ldr r5, =gUnknown_0203CE58 - ldrb r2, [r5, 0x5] - lsls r2, 1 - adds r1, r5, 0 - adds r1, 0x12 - adds r1, r2, r1 - adds r4, r5, 0 - adds r4, 0x8 - adds r2, r4 - bl sub_81AE860 - movs r0, 0 - bl sub_80D4FC8 - ldrb r0, [r5, 0x5] - lsls r0, 1 - adds r0, r4 - ldrb r0, [r0] - bl sub_80D4FEC - movs r0, 0x2 - negs r0, r0 - cmp r7, r0 - beq _081AC460 - adds r0, 0x1 - cmp r7, r0 - bne _081AC482 - b _081AC48E - .pool -_081AC460: - movs r0, 0x5 - bl PlaySE - mov r0, r8 - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081AC47A -_081AC472: - adds r0, r6, 0 - bl sub_81AC498 - b _081AC48E -_081AC47A: - adds r0, r6, 0 - bl sub_81AC590 - b _081AC48E -_081AC482: - movs r0, 0x5 - bl PlaySE - adds r0, r6, 0 - bl sub_81AC498 -_081AC48E: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81AC3C0 - - thumb_func_start sub_81AC498 -sub_81AC498: @ 81AC498 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r3, r0, 24 - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 3 - mov r10, r0 - ldr r0, =gTasks + 0x8 - add r0, r10 - mov r9, r0 - ldr r5, =gUnknown_0203CE58 - ldrb r6, [r5, 0x5] - lsls r1, r6, 1 - adds r0, r5, 0 - adds r0, 0x12 - adds r0, r1 - mov r8, r0 - ldr r2, =gUnknown_0203CE60 - adds r7, r1, r2 - ldrh r0, [r7] - mov r1, r8 - ldrh r1, [r1] - adds r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - mov r0, r9 - movs r1, 0x2 - ldrsh r2, [r0, r1] - cmp r2, r4 - beq _081AC4E2 - subs r0, r4, 0x1 - cmp r2, r0 - bne _081AC4F8 -_081AC4E2: - adds r0, r3, 0 - bl sub_81AC590 - b _081AC566 - .pool -_081AC4F8: - ldr r1, =gBagPockets - lsls r0, r6, 3 - adds r0, r1 - ldr r0, [r0] - adds r1, r2, 0 - adds r2, r4, 0 - bl sub_80D702C - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r2, =0x0000081a - adds r0, r2 - movs r1, 0xFF - strb r1, [r0] - mov r1, r9 - ldrb r0, [r1] - mov r1, r8 - adds r2, r7, 0 - bl sub_81AE6C8 - mov r2, r9 - movs r1, 0x2 - ldrsh r0, [r2, r1] - cmp r0, r4 - bge _081AC538 - ldrb r1, [r5, 0x5] - lsls r1, 1 - ldr r2, =gUnknown_0203CE60 - adds r1, r2 - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] -_081AC538: - ldrb r0, [r5, 0x5] - bl load_bag_item_list_buffers - ldr r0, =gMultiuseListMenuTemplate - mov r2, r8 - ldrh r1, [r2] - ldrh r2, [r7] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - mov r1, r9 - strh r0, [r1] - movs r0, 0x1 - bl sub_80D4FC8 - bl bag_menu_add_list_scroll_arrow_indicators_maybe - ldr r0, =gTasks + 0x8 - subs r0, 0x8 - add r0, r10 - ldr r1, =Task_BagMenu - str r1, [r0] -_081AC566: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AC498 - - thumb_func_start sub_81AC590 -sub_81AC590: @ 81AC590 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - mov r9, r1 - ldr r0, =gTasks + 0x8 - mov r10, r0 - mov r7, r9 - add r7, r10 - ldr r4, =gUnknown_0203CE58 - ldrb r0, [r4, 0x5] - lsls r0, 1 - adds r1, r4, 0 - adds r1, 0x12 - adds r6, r0, r1 - movs r1, 0x8 - adds r1, r4 - mov r8, r1 - adds r5, r0, r1 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x0000081a - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldrb r0, [r7] - adds r1, r6, 0 - adds r2, r5, 0 - bl sub_81AE6C8 - movs r0, 0x2 - ldrsh r2, [r7, r0] - ldrh r0, [r6] - ldrh r1, [r5] - adds r0, r1 - cmp r2, r0 - bge _081AC5F2 - ldrb r1, [r4, 0x5] - lsls r1, 1 - add r1, r8 - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] -_081AC5F2: - ldrb r0, [r4, 0x5] - bl load_bag_item_list_buffers - ldr r0, =gMultiuseListMenuTemplate - ldrh r1, [r6] - ldrh r2, [r5] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7] - movs r0, 0x1 - bl sub_80D4FC8 - bl bag_menu_add_list_scroll_arrow_indicators_maybe - mov r0, r10 - subs r0, 0x8 - add r0, r9 - ldr r1, =Task_BagMenu - str r1, [r0] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AC590 - - thumb_func_start sub_81AC644 -sub_81AC644: @ 81AC644 - push {r4,r5,lr} - sub sp, 0x14 - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x4] - subs r0, 0x1 - cmp r0, 0x9 - bls _081AC654 - b _081AC82C -_081AC654: - lsls r0, 2 - ldr r1, =_081AC668 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081AC668: - .4byte _081AC690 - .4byte _081AC82C - .4byte _081AC82C - .4byte _081AC82C - .4byte _081AC6E8 - .4byte _081AC82C - .4byte _081AC76C - .4byte _081AC7CC - .4byte _081AC70C - .4byte _081AC690 -_081AC690: - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - bl ItemId_GetBattleUsage - lsls r0, 24 - cmp r0, 0 - beq _081AC6C4 - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614042 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x2 - b _081ACA10 - .pool -_081AC6C4: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614046 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x1 - b _081ACA10 - .pool -_081AC6E8: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614047 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x4 - b _081ACA10 - .pool -_081AC70C: - ldr r4, =gSpecialVar_ItemId - ldrh r0, [r4] - bl itemid_is_unique - lsls r0, 24 - cmp r0, 0 - bne _081AC748 - ldrh r0, [r4] - cmp r0, 0xAF - beq _081AC748 - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_0861404B - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x2 - b _081ACA10 - .pool -_081AC748: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614046 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x1 - b _081ACA10 - .pool -_081AC76C: - ldr r4, =gSpecialVar_ItemId - ldrh r0, [r4] - bl itemid_is_unique - lsls r0, 24 - cmp r0, 0 - bne _081AC7A8 - ldrh r0, [r4] - cmp r0, 0xAF - beq _081AC7A8 - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_0861404D - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x2 - b _081ACA10 - .pool -_081AC7A8: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614046 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x1 - b _081ACA10 - .pool -_081AC7CC: - ldr r4, =gSpecialVar_ItemId - ldrh r0, [r4] - bl itemid_is_unique - lsls r0, 24 - cmp r0, 0 - bne _081AC808 - ldrh r0, [r4] - cmp r0, 0xAF - beq _081AC808 - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_0861404F - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x2 - b _081ACA10 - .pool -_081AC808: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614046 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x1 - b _081ACA10 - .pool -_081AC82C: - bl sub_81221AC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081AC840 - bl InUnionRoom - cmp r0, 0x1 - bne _081AC8A4 -_081AC840: - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - cmp r0, 0x4 - beq _081AC856 - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - bl sub_8122148 - lsls r0, 24 - cmp r0, 0 - bne _081AC880 -_081AC856: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614046 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x1 - b _081ACA10 - .pool -_081AC880: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614044 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x2 - b _081ACA10 - .pool -_081AC8A4: - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - cmp r0, 0x4 - bls _081AC8AE - b _081ACA12 -_081AC8AE: - lsls r0, 2 - ldr r1, =_081AC8C0 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081AC8C0: - .4byte _081AC8D4 - .4byte _081AC9B4 - .4byte _081AC9D8 - .4byte _081AC9FC - .4byte _081AC92C -_081AC8D4: - ldr r4, =gUnknown_0203CE54 - ldr r1, [r4] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r3, =0x00000824 - adds r0, r1, r3 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x4 - strb r0, [r1] - ldr r0, [r4] - adds r0, r3 - ldr r1, =gUnknown_0861402C - movs r2, 0x4 - bl memcpy - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - bl ItemIsMail - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081AC90A - b _081ACA12 -_081AC90A: - ldr r0, [r4] - ldr r1, =0x00000824 - adds r0, r1 - movs r1, 0x6 - strb r1, [r0] - b _081ACA12 - .pool -_081AC92C: - ldr r4, =gUnknown_0203CE54 - ldr r1, [r4] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r5, =0x00000824 - adds r0, r1, r5 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x4 - strb r0, [r1] - ldr r0, [r4] - adds r0, r5 - ldr r1, =gUnknown_08614030 - movs r2, 0x4 - bl memcpy - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00000496 - adds r0, r1 - ldr r2, =gSpecialVar_ItemId - ldrh r0, [r0] - ldrh r1, [r2] - cmp r0, r1 - bne _081AC96C - ldr r0, [r4] - ldr r1, =0x00000825 - adds r0, r1 - movs r1, 0x8 - strb r1, [r0] -_081AC96C: - ldrh r1, [r2] - ldr r0, =0x00000103 - cmp r1, r0 - beq _081AC97A - adds r0, 0xD - cmp r1, r0 - bne _081ACA12 -_081AC97A: - movs r0, 0x6 - bl TestPlayerAvatarFlags - lsls r0, 24 - cmp r0, 0 - beq _081ACA12 - ldr r0, [r4] - adds r0, r5 - movs r1, 0x7 - strb r1, [r0] - b _081ACA12 - .pool -_081AC9B4: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614034 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x4 - b _081ACA10 - .pool -_081AC9D8: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_08614038 - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x4 - b _081ACA10 - .pool -_081AC9FC: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - movs r0, 0x82 - lsls r0, 4 - adds r2, r1, r0 - ldr r0, =gUnknown_0861403C - str r0, [r2] - ldr r0, =0x00000828 - adds r1, r0 - movs r0, 0x6 -_081ACA10: - strb r0, [r1] -_081ACA12: - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - cmp r0, 0x2 - bne _081ACA50 - movs r0, 0x1 - bl ClearWindowTilemap - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - bl PrintTMHMMoveData - movs r0, 0x3 - bl PutWindowTilemap - movs r0, 0x4 - bl PutWindowTilemap - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - b _081ACA86 - .pool -_081ACA50: - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r4, =gStringVar4 - ldr r1, =gText_Var1IsSelected - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - str r0, [sp, 0x10] - movs r0, 0x1 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x3 - bl bag_menu_print -_081ACA86: - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000828 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x1 - bne _081ACAB0 - movs r0, 0 - b _081ACAB6 - .pool -_081ACAB0: - cmp r0, 0x2 - bne _081ACAC4 - movs r0, 0x1 -_081ACAB6: - bl bag_menu_add_window - lsls r0, 24 - lsrs r0, 24 - bl sub_81ACAF8 - b _081ACAEE -_081ACAC4: - cmp r0, 0x4 - bne _081ACADC - movs r0, 0x2 - bl bag_menu_add_window - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x2 - movs r2, 0x2 - bl sub_81ACB54 - b _081ACAEE -_081ACADC: - movs r0, 0x3 - bl bag_menu_add_window - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x2 - movs r2, 0x3 - bl sub_81ACB54 -_081ACAEE: - add sp, 0x14 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81AC644 - - thumb_func_start sub_81ACAF8 -sub_81ACAF8: @ 81ACAF8 - push {r4-r6,lr} - sub sp, 0x14 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0 - str r0, [sp] - movs r0, 0x10 - str r0, [sp, 0x4] - ldr r6, =gUnknown_0203CE54 - ldr r1, [r6] - ldr r5, =0x00000828 - adds r0, r1, r5 - ldrb r0, [r0] - str r0, [sp, 0x8] - ldr r0, =gUnknown_08613FB4 - str r0, [sp, 0xC] - movs r0, 0x82 - lsls r0, 4 - adds r1, r0 - ldr r0, [r1] - str r0, [sp, 0x10] - adds r0, r4, 0 - movs r1, 0x7 - movs r2, 0x8 - movs r3, 0x1 - bl AddItemMenuActionTextPrinters - ldr r0, [r6] - adds r0, r5 - ldrb r1, [r0] - adds r0, r4, 0 - movs r2, 0 - bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed - add sp, 0x14 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81ACAF8 - - thumb_func_start sub_81ACB54 -sub_81ACB54: @ 81ACB54 - push {r4-r6,lr} - sub sp, 0x14 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - movs r0, 0x38 - str r0, [sp] - str r5, [sp, 0x4] - str r6, [sp, 0x8] - ldr r0, =gUnknown_08613FB4 - str r0, [sp, 0xC] - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - movs r1, 0x82 - lsls r1, 4 - adds r0, r1 - ldr r0, [r0] - str r0, [sp, 0x10] - adds r0, r4, 0 - movs r1, 0x7 - movs r2, 0x8 - movs r3, 0x1 - bl sub_8198DBC - movs r0, 0 - str r0, [sp] - adds r0, r4, 0 - movs r1, 0x38 - adds r2, r5, 0 - adds r3, r6, 0 - bl sub_8199944 - add sp, 0x14 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81ACB54 - - thumb_func_start unknown_item_menu_type -unknown_item_menu_type: @ 81ACBB0 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - bl sub_81AC644 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000828 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x2 - bhi _081ACBE8 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =Task_HandleInBattleItemMenuInput - b _081ACBF4 - .pool -_081ACBE8: - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =Task_HandleOutOfBattleItemMenuInput -_081ACBF4: - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end unknown_item_menu_type - - thumb_func_start Task_HandleInBattleItemMenuInput -Task_HandleInBattleItemMenuInput: @ 81ACC04 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r6, r5, 0 - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081ACC6A - bl ProcessMenuInputNoWrapAround - lsls r0, 24 - asrs r4, r0, 24 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _081ACC6A - adds r0, 0x1 - cmp r4, r0 - bne _081ACC44 - movs r0, 0x5 - bl PlaySE - ldr r0, =gUnknown_08613FB4 - ldr r1, [r0, 0x24] - adds r0, r5, 0 - bl _call_via_r1 - b _081ACC6A - .pool -_081ACC44: - movs r0, 0x5 - bl PlaySE - ldr r1, =gUnknown_08613FB4 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - movs r2, 0x82 - lsls r2, 4 - adds r0, r2 - ldr r0, [r0] - adds r0, r4 - ldrb r0, [r0] - lsls r0, 3 - adds r1, 0x4 - adds r0, r1 - ldr r1, [r0] - adds r0, r6, 0 - bl _call_via_r1 -_081ACC6A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end Task_HandleInBattleItemMenuInput - - thumb_func_start Task_HandleOutOfBattleItemMenuInput -Task_HandleOutOfBattleItemMenuInput: @ 81ACC78 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081ACC8C - b _081ACDF0 -_081ACC8C: - bl GetMenuCursorPos - lsls r0, 24 - lsrs r4, r0, 24 - ldr r5, =gMain - ldrh r1, [r5, 0x2E] - movs r0, 0x40 - ands r0, r1 - cmp r0, 0 - beq _081ACCD4 - lsls r0, r4, 24 - asrs r0, 24 - cmp r0, 0 - bgt _081ACCAA - b _081ACDF0 -_081ACCAA: - subs r0, 0x2 - lsls r0, 24 - asrs r0, 24 - bl sub_81ACDFC - lsls r0, 24 - cmp r0, 0 - bne _081ACCBC - b _081ACDF0 -_081ACCBC: - movs r0, 0x5 - bl PlaySE - movs r1, 0x1 - negs r1, r1 - movs r0, 0 - bl sub_8199134 - b _081ACDF0 - .pool -_081ACCD4: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _081ACD1C - lsls r0, r4, 24 - asrs r1, r0, 24 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r2, =0x00000828 - adds r0, r2 - ldrb r0, [r0] - subs r0, 0x2 - cmp r1, r0 - blt _081ACCF2 - b _081ACDF0 -_081ACCF2: - adds r0, r1, 0x2 - lsls r0, 24 - asrs r0, 24 - bl sub_81ACDFC - lsls r0, 24 - cmp r0, 0 - beq _081ACDF0 - movs r0, 0x5 - bl PlaySE - movs r0, 0 - movs r1, 0x1 - bl sub_8199134 - b _081ACDF0 - .pool -_081ACD1C: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - bne _081ACD30 - bl GetLRKeysState - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081ACD58 -_081ACD30: - lsls r0, r4, 24 - asrs r1, r0, 24 - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081ACDF0 - subs r0, r1, 0x1 - lsls r0, 24 - asrs r0, 24 - bl sub_81ACDFC - lsls r0, 24 - cmp r0, 0 - beq _081ACDF0 - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - negs r0, r0 - b _081ACD92 -_081ACD58: - ldrh r1, [r5, 0x2E] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _081ACD6E - bl GetLRKeysState - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _081ACD9A -_081ACD6E: - lsls r0, r4, 24 - asrs r1, r0, 24 - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _081ACDF0 - adds r0, r1, 0x1 - lsls r0, 24 - asrs r0, 24 - bl sub_81ACDFC - lsls r0, 24 - cmp r0, 0 - beq _081ACDF0 - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 -_081ACD92: - movs r1, 0 - bl sub_8199134 - b _081ACDF0 -_081ACD9A: - ldrh r1, [r5, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081ACDD8 - movs r0, 0x5 - bl PlaySE - ldr r2, =gUnknown_08613FB4 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - lsls r1, r4, 24 - asrs r1, 24 - movs r3, 0x82 - lsls r3, 4 - adds r0, r3 - ldr r0, [r0] - adds r0, r1 - ldrb r0, [r0] - lsls r0, 3 - adds r2, 0x4 - adds r0, r2 - ldr r1, [r0] - adds r0, r6, 0 - bl _call_via_r1 - b _081ACDF0 - .pool -_081ACDD8: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081ACDF0 - movs r0, 0x5 - bl PlaySE - ldr r0, =gUnknown_08613FB4 - ldr r1, [r0, 0x24] - adds r0, r6, 0 - bl _call_via_r1 -_081ACDF0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end Task_HandleOutOfBattleItemMenuInput - - thumb_func_start sub_81ACDFC -sub_81ACDFC: @ 81ACDFC - push {lr} - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - blt _081ACE30 - ldr r0, =gUnknown_0203CE54 - ldr r2, [r0] - ldr r3, =0x00000828 - adds r0, r2, r3 - ldrb r0, [r0] - cmp r1, r0 - bgt _081ACE30 - movs r3, 0x82 - lsls r3, 4 - adds r0, r2, r3 - ldr r0, [r0] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0xE - beq _081ACE30 - movs r0, 0x1 - b _081ACE32 - .pool -_081ACE30: - movs r0, 0 -_081ACE32: - pop {r1} - bx r1 - thumb_func_end sub_81ACDFC - - thumb_func_start bag_menu_remove_some_window -bag_menu_remove_some_window: @ 81ACE38 - push {lr} - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000828 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x1 - bne _081ACE58 - movs r0, 0 - bl bag_menu_remove_window - b _081ACE76 - .pool -_081ACE58: - cmp r0, 0x2 - bne _081ACE64 - movs r0, 0x1 - bl bag_menu_remove_window - b _081ACE76 -_081ACE64: - cmp r0, 0x4 - bne _081ACE70 - movs r0, 0x2 - bl bag_menu_remove_window - b _081ACE76 -_081ACE70: - movs r0, 0x3 - bl bag_menu_remove_window -_081ACE76: - pop {r0} - bx r0 - thumb_func_end bag_menu_remove_some_window - - thumb_func_start ItemMenu_UseOutOfBattle -@ void ItemMenu_UseOutOfBattle(u8 taskId) -ItemMenu_UseOutOfBattle: @ 81ACE7C - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r5, =gSpecialVar_ItemId - ldrh r0, [r5] - bl ItemId_GetFieldFunc - cmp r0, 0 - beq _081ACEEE - bl bag_menu_remove_some_window - bl CalculatePlayerPartyCount - lsls r0, 24 - cmp r0, 0 - bne _081ACEB8 - ldrh r0, [r5] - bl ItemId_GetType - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081ACEB8 - adds r0, r4, 0 - bl bag_menu_print_there_is_no_pokemon - b _081ACEEE - .pool -_081ACEB8: - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - cmp r0, 0x3 - beq _081ACEE8 - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - bl ItemId_GetFieldFunc - adds r1, r0, 0 - adds r0, r4, 0 - bl _call_via_r1 - b _081ACEEE - .pool -_081ACEE8: - adds r0, r4, 0 - bl sub_80FDD10 -_081ACEEE: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end ItemMenu_UseOutOfBattle - - thumb_func_start ItemMenu_Toss -ItemMenu_Toss: @ 81ACEF4 - push {r4-r7,lr} - sub sp, 0x14 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r6, r0, 3 - ldr r7, =gTasks + 0x8 - adds r4, r6, r7 - bl bag_menu_remove_some_window - movs r0, 0x1 - strh r0, [r4, 0x10] - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _081ACF24 - adds r0, r5, 0 - bl BagMenuConfirmToss - b _081ACF6A - .pool -_081ACF24: - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r4, =gStringVar4 - ldr r1, =gText_TossHowManyVar1s - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - str r0, [sp, 0x10] - movs r0, 0x1 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x3 - bl bag_menu_print - movs r0, 0x7 - bl sub_81ABC3C - adds r0, r7, 0 - subs r0, 0x8 - adds r0, r6, r0 - ldr r1, =Task_ChooseHowManyToToss - str r1, [r0] -_081ACF6A: - add sp, 0x14 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end ItemMenu_Toss - - thumb_func_start BagMenuConfirmToss -BagMenuConfirmToss: @ 81ACF88 - push {r4,r5,lr} - sub sp, 0x14 - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r0, =gStringVar2 - movs r2, 0x10 - ldrsh r1, [r4, r2] - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_ConfirmTossItems - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - str r0, [sp, 0x10] - movs r0, 0x1 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x3 - bl bag_menu_print - ldr r2, =gUnknown_08614084 - adds r0, r5, 0 - movs r1, 0x5 - bl bag_menu_yes_no - add sp, 0x14 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end BagMenuConfirmToss - - thumb_func_start BagMenuCancelToss -BagMenuCancelToss: @ 81AD010 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - movs r1, 0x2 - ldrsh r0, [r4, r1] - bl bag_menu_print_description_box_text - ldrb r0, [r4] - movs r1, 0 - bl bag_menu_print_cursor_ - adds r0, r5, 0 - bl set_callback3_to_bag - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end BagMenuCancelToss - - thumb_func_start Task_ChooseHowManyToToss -Task_ChooseHowManyToToss: @ 81AD044 - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r6, r5, 0 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - adds r0, r4, 0 - adds r0, 0x10 - ldrh r1, [r4, 0x4] - bl AdjustQuantityAccordingToDPadInput - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081AD088 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000817 - adds r0, r1 - ldrb r0, [r0] - movs r2, 0x10 - ldrsh r1, [r4, r2] - bl sub_81ABC54 - b _081AD0C6 - .pool -_081AD088: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081AD0AC - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - bl bag_menu_remove_window - adds r0, r5, 0 - bl BagMenuConfirmToss - b _081AD0C6 - .pool -_081AD0AC: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081AD0C6 - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - bl bag_menu_remove_window - adds r0, r6, 0 - bl BagMenuCancelToss -_081AD0C6: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end Task_ChooseHowManyToToss - - thumb_func_start BagMenuActuallyToss -BagMenuActuallyToss: @ 81AD0CC - push {r4-r6,lr} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r5, =gTasks + 0x8 - adds r6, r4, r5 - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r0, =gStringVar2 - movs r2, 0x10 - ldrsh r1, [r6, r2] - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r6, =gStringVar4 - ldr r1, =gText_ThrewAwayVar2Var1s - adds r0, r6, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - str r0, [sp, 0x10] - movs r0, 0x1 - movs r1, 0x1 - adds r2, r6, 0 - movs r3, 0x3 - bl bag_menu_print - subs r5, 0x8 - adds r4, r5 - ldr r0, =Task_ActuallyToss - str r0, [r4] - add sp, 0x14 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end BagMenuActuallyToss - - thumb_func_start Task_ActuallyToss -Task_ActuallyToss: @ 81AD150 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - ldr r4, =gUnknown_0203CE58 - ldrb r0, [r4, 0x5] - lsls r0, 1 - adds r1, r4, 0 - adds r1, 0x12 - adds r1, r0 - mov r8, r1 - adds r1, r4, 0 - adds r1, 0x8 - adds r7, r0, r1 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _081AD1CE - movs r0, 0x5 - bl PlaySE - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - ldrh r1, [r5, 0x10] - bl RemoveBagItem - ldrb r0, [r5] - mov r1, r8 - adds r2, r7, 0 - bl sub_81AE6C8 - ldrb r0, [r4, 0x5] - bl sub_81AB9A8 - ldrb r0, [r4, 0x5] - bl sub_81ABA88 - ldrb r0, [r4, 0x5] - bl load_bag_item_list_buffers - ldr r0, =gMultiuseListMenuTemplate - mov r2, r8 - ldrh r1, [r2] - ldrh r2, [r7] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5] - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - adds r0, r6, 0 - bl set_callback3_to_bag -_081AD1CE: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end Task_ActuallyToss - - thumb_func_start ItemMenu_Register -ItemMenu_Register: @ 81AD1EC - push {r4-r7,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r7, r0, r1 - ldr r0, =gUnknown_0203CE58 - ldrb r1, [r0, 0x5] - lsls r1, 1 - adds r2, r0, 0 - adds r2, 0x12 - adds r6, r1, r2 - adds r0, 0x8 - adds r5, r1, r0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r2, =0x00000496 - adds r1, r0, r2 - ldr r0, =gSpecialVar_ItemId - ldrh r2, [r0] - ldrh r0, [r1] - cmp r0, r2 - bne _081AD238 - movs r0, 0 - strh r0, [r1] - b _081AD23A - .pool -_081AD238: - strh r2, [r1] -_081AD23A: - ldrb r0, [r7] - adds r1, r6, 0 - adds r2, r5, 0 - bl sub_81AE6C8 - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - bl load_bag_item_list_buffers - ldr r0, =gMultiuseListMenuTemplate - ldrh r1, [r6] - ldrh r2, [r5] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7] - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - adds r0, r4, 0 - bl ItemMenu_Cancel - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end ItemMenu_Register - - thumb_func_start ItemMenu_Give -ItemMenu_Give: @ 81AD278 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - bl bag_menu_remove_some_window - ldr r5, =gSpecialVar_ItemId - ldrh r0, [r5] - bl itemid_80BF6D8_mail_related - lsls r0, 24 - cmp r0, 0 - bne _081AD2AC - ldr r2, =gText_CantWriteMail - ldr r3, =sub_81AD350 - adds r0, r4, 0 - movs r1, 0x1 - bl DisplayItemMessage - b _081AD2EA - .pool -_081AD2AC: - ldrh r0, [r5] - bl itemid_is_unique - lsls r0, 24 - cmp r0, 0 - bne _081AD2E4 - bl CalculatePlayerPartyCount - lsls r0, 24 - cmp r0, 0 - bne _081AD2CA - adds r0, r4, 0 - bl bag_menu_print_there_is_no_pokemon - b _081AD2EA -_081AD2CA: - ldr r0, =gUnknown_0203CE54 - ldr r1, [r0] - ldr r0, =sub_81B7F60 - str r0, [r1] - adds r0, r4, 0 - bl unknown_ItemMenu_Confirm - b _081AD2EA - .pool -_081AD2E4: - adds r0, r6, 0 - bl bag_menu_print_cant_be_held_msg -_081AD2EA: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end ItemMenu_Give - - thumb_func_start bag_menu_print_there_is_no_pokemon -bag_menu_print_there_is_no_pokemon: @ 81AD2F0 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gText_NoPokemon - ldr r3, =sub_81AD350 - movs r1, 0x1 - bl DisplayItemMessage - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_print_there_is_no_pokemon - - thumb_func_start bag_menu_print_cant_be_held_msg -bag_menu_print_cant_be_held_msg: @ 81AD30C - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r5, =gStringVar4 - ldr r1, =gText_Var1CantBeHeld - adds r0, r5, 0 - bl StringExpandPlaceholders - ldr r3, =sub_81AD350 - adds r0, r4, 0 - movs r1, 0x1 - adds r2, r5, 0 - bl DisplayItemMessage - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_print_cant_be_held_msg - - thumb_func_start sub_81AD350 -sub_81AD350: @ 81AD350 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081AD36E - movs r0, 0x5 - bl PlaySE - adds r0, r4, 0 - bl bag_menu_inits_lists_menu -_081AD36E: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AD350 - - thumb_func_start ItemMenu_CheckTag -ItemMenu_CheckTag: @ 81AD378 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203CE54 - ldr r2, [r1] - ldr r1, =sub_8177C14 - str r1, [r2] - bl unknown_ItemMenu_Confirm - pop {r0} - bx r0 - .pool - thumb_func_end ItemMenu_CheckTag - - thumb_func_start ItemMenu_Cancel -ItemMenu_Cancel: @ 81AD398 - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - bl bag_menu_remove_some_window - movs r1, 0x2 - ldrsh r0, [r4, r1] - bl bag_menu_print_description_box_text - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - ldrb r0, [r4] - movs r1, 0 - bl bag_menu_print_cursor_ - adds r0, r5, 0 - bl set_callback3_to_bag - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end ItemMenu_Cancel - - thumb_func_start ItemMenu_UseInBattle -ItemMenu_UseInBattle: @ 81AD3DC - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gSpecialVar_ItemId - ldrh r0, [r4] - bl ItemId_GetBattleFunc - cmp r0, 0 - beq _081AD400 - bl bag_menu_remove_some_window - ldrh r0, [r4] - bl ItemId_GetBattleFunc - adds r1, r0, 0 - adds r0, r5, 0 - bl _call_via_r1 -_081AD400: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end ItemMenu_UseInBattle - - thumb_func_start bag_menu_mail_related -bag_menu_mail_related: @ 81AD40C - push {lr} - movs r0, 0xC - movs r1, 0x5 - movs r2, 0 - bl GoToBagMenu - pop {r0} - bx r0 - thumb_func_end bag_menu_mail_related - - thumb_func_start item_menu_type_2 -item_menu_type_2: @ 81AD41C - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gSpecialVar_ItemId - ldrh r0, [r4] - bl itemid_80BF6D8_mail_related - lsls r0, 24 - cmp r0, 0 - bne _081AD44C - ldr r2, =gText_CantWriteMail - ldr r3, =sub_81AD350 - adds r0, r5, 0 - movs r1, 0x1 - bl DisplayItemMessage - b _081AD4AE - .pool -_081AD44C: - ldrh r0, [r4] - bl sub_8122148 - lsls r0, 24 - cmp r0, 0 - bne _081AD488 - ldrh r0, [r4] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r4, =gStringVar4 - ldr r1, =gText_Var1CantBeHeldHere - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r3, =sub_81AD350 - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl DisplayItemMessage - b _081AD4AE - .pool -_081AD488: - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - cmp r0, 0x4 - beq _081AD4A8 - ldrh r0, [r4] - bl itemid_is_unique - lsls r0, 24 - cmp r0, 0 - bne _081AD4A8 - adds r0, r5, 0 - bl unknown_ItemMenu_Confirm - b _081AD4AE - .pool -_081AD4A8: - adds r0, r5, 0 - bl bag_menu_print_cant_be_held_msg -_081AD4AE: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end item_menu_type_2 - - thumb_func_start item_menu_type_b -item_menu_type_b: @ 81AD4B4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r5, =gSpecialVar_ItemId - ldrh r0, [r5] - bl ItemIsMail - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081AD4E4 - ldr r2, =gText_CantWriteMail - ldr r3, =sub_81AD350 - adds r0, r4, 0 - movs r1, 0x1 - bl DisplayItemMessage - b _081AD51A - .pool -_081AD4E4: - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x5] - cmp r0, 0x4 - beq _081AD514 - ldrh r0, [r5] - bl itemid_is_unique - lsls r0, 24 - cmp r0, 0 - bne _081AD514 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =unknown_ItemMenu_Confirm - str r0, [r1] - b _081AD51A - .pool -_081AD514: - adds r0, r4, 0 - bl bag_menu_print_cant_be_held_msg -_081AD51A: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end item_menu_type_b - - thumb_func_start UseRegisteredKeyItemOnField -@ bool8 UseRegisteredKeyItemOnField() -UseRegisteredKeyItemOnField: @ 81AD520 - push {r4-r7,lr} - bl InUnionRoom - cmp r0, 0x1 - beq _081AD54C - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - bne _081AD54C - bl InBattlePike - lsls r0, 24 - lsrs r7, r0, 24 - cmp r7, 0 - bne _081AD54C - bl InMultiBattleRoom - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081AD550 -_081AD54C: - movs r0, 0 - b _081AD5D2 -_081AD550: - bl HideMapNamePopUpWindow - movs r0, 0 - movs r1, 0 - movs r2, 0 - bl ChangeBgY_ScreenOff - ldr r4, =gSaveBlock1Ptr - ldr r0, [r4] - ldr r5, =0x00000496 - adds r1, r0, r5 - ldrh r0, [r1] - cmp r0, 0 - beq _081AD5CA - movs r1, 0x1 - bl CheckBagHasItem - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x1 - bne _081AD5C4 - bl ScriptContext2_Enable - bl FreezeMapObjects - bl sub_808B864 - bl sub_808BCF4 - ldr r2, =gSpecialVar_ItemId - ldr r0, [r4] - adds r0, r5 - ldrh r1, [r0] - strh r1, [r2] - ldrh r0, [r0] - bl ItemId_GetFieldFunc - movs r1, 0x8 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - strh r6, [r1, 0xE] - b _081AD5D0 - .pool -_081AD5C4: - ldr r0, [r4] - adds r0, r5 - strh r7, [r0] -_081AD5CA: - ldr r0, =EventScript_2736B3 - bl ScriptContext1_SetupScript -_081AD5D0: - movs r0, 0x1 -_081AD5D2: - pop {r4-r7} - pop {r1} - bx r1 - .pool - thumb_func_end UseRegisteredKeyItemOnField - - thumb_func_start display_sell_item_ask_str -@ void display_sell_item_ask_str(int a1) -display_sell_item_ask_str: @ 81AD5DC - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r7, r5, 0 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - ldr r6, =gSpecialVar_ItemId - ldrh r0, [r6] - bl itemid_get_market_price - lsls r0, 16 - cmp r0, 0 - bne _081AD634 - ldrh r0, [r6] - ldr r1, =gStringVar2 - bl CopyItemName - ldr r4, =gStringVar4 - ldr r1, =gText_CantBuyKeyItem - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r3, =bag_menu_inits_lists_menu - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl DisplayItemMessage - b _081AD66A - .pool -_081AD634: - movs r0, 0x1 - strh r0, [r4, 0x10] - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _081AD64C - bl bag_menu_AddMoney_window - adds r0, r5, 0 - bl sub_81AD680 - b _081AD66A -_081AD64C: - ldrh r0, [r6] - ldr r1, =gStringVar2 - bl CopyItemName - ldr r4, =gStringVar4 - ldr r1, =gText_HowManyToSell - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r3, =sub_81AD730 - adds r0, r7, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl DisplayItemMessage -_081AD66A: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end display_sell_item_ask_str - - thumb_func_start sub_81AD680 -sub_81AD680: @ 81AD680 - push {r4-r6,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldr r6, =gStringVar1 - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - bl itemid_get_market_price - lsls r0, 16 - lsrs r0, 17 - movs r2, 0x10 - ldrsh r1, [r4, r2] - muls r1, r0 - adds r0, r6, 0 - movs r2, 0 - movs r3, 0x6 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_ICanPayVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r3, =sub_81AD6E4 - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl DisplayItemMessage - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AD680 - - thumb_func_start sub_81AD6E4 -sub_81AD6E4: @ 81AD6E4 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gUnknown_0861408C - movs r1, 0x6 - bl bag_menu_yes_no - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AD6E4 - - thumb_func_start sub_81AD6FC -sub_81AD6FC: @ 81AD6FC - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - bl bag_menu_remove_money_window - movs r0, 0x4 - bl bag_menu_RemoveBagItem_message_window - ldrb r0, [r4] - movs r1, 0 - bl bag_menu_print_cursor_ - adds r0, r5, 0 - bl set_callback3_to_bag - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AD6FC - - thumb_func_start sub_81AD730 -sub_81AD730: @ 81AD730 - push {r4-r6,lr} - mov r6, r8 - push {r6} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r6, =gTasks + 0x8 - adds r0, r4, r6 - mov r8, r0 - movs r0, 0x8 - bl bag_menu_add_window - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - bl itemid_get_market_price - lsls r0, 16 - lsrs r0, 17 - mov r2, r8 - movs r3, 0x10 - ldrsh r1, [r2, r3] - adds r2, r0, 0 - muls r2, r1 - adds r0, r5, 0 - movs r1, 0x1 - bl sub_81ABCC0 - bl bag_menu_AddMoney_window - subs r6, 0x8 - adds r4, r6 - ldr r0, =sub_81AD794 - str r0, [r4] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AD730 - - thumb_func_start sub_81AD794 -sub_81AD794: @ 81AD794 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r5, r4, 0 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - adds r0, r6, 0 - adds r0, 0x10 - ldrh r1, [r6, 0x4] - bl AdjustQuantityAccordingToDPadInput - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081AD7F4 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000818 - adds r0, r1 - ldrb r4, [r0] - movs r2, 0x10 - ldrsh r5, [r6, r2] - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - bl itemid_get_market_price - lsls r0, 16 - lsrs r0, 17 - movs r2, 0x10 - ldrsh r1, [r6, r2] - adds r2, r0, 0 - muls r2, r1 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_81ABCC0 - b _081AD844 - .pool -_081AD7F4: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081AD818 - movs r0, 0x5 - bl PlaySE - movs r0, 0x8 - bl bag_menu_remove_window - adds r0, r4, 0 - bl sub_81AD680 - b _081AD844 - .pool -_081AD818: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081AD844 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r6] - movs r1, 0 - bl bag_menu_print_cursor_ - bl bag_menu_remove_money_window - movs r0, 0x8 - bl bag_menu_remove_window - movs r0, 0x4 - bl bag_menu_RemoveBagItem_message_window - adds r0, r5, 0 - bl set_callback3_to_bag -_081AD844: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81AD794 - - thumb_func_start sub_81AD84C -sub_81AD84C: @ 81AD84C - push {r4-r6,lr} - mov r6, r8 - push {r6} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldr r6, =gSpecialVar_ItemId - ldrh r0, [r6] - ldr r1, =gStringVar2 - bl CopyItemName - ldr r0, =gStringVar1 - mov r8, r0 - ldrh r0, [r6] - bl itemid_get_market_price - lsls r0, 16 - lsrs r0, 17 - movs r2, 0x10 - ldrsh r1, [r4, r2] - muls r1, r0 - mov r0, r8 - movs r2, 0 - movs r3, 0x6 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_TurnedOverVar1ForVar2 - adds r0, r4, 0 - bl StringExpandPlaceholders - ldr r3, =sub_81AD8C8 - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl DisplayItemMessage - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AD84C - - thumb_func_start sub_81AD8C8 -sub_81AD8C8: @ 81AD8C8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r0, 24 - lsls r6, r0, 2 - adds r6, r0 - lsls r6, 3 - ldr r0, =gTasks + 0x8 - adds r0, r6 - mov r10, r0 - ldr r7, =gUnknown_0203CE58 - ldrb r5, [r7, 0x5] - lsls r5, 1 - movs r1, 0x12 - adds r1, r7 - mov r9, r1 - add r9, r5 - adds r0, r7, 0 - adds r0, 0x8 - adds r5, r0 - movs r0, 0x5F - bl PlaySE - ldr r2, =gSpecialVar_ItemId - mov r8, r2 - ldrh r0, [r2] - mov r3, r10 - ldrh r1, [r3, 0x10] - bl RemoveBagItem - ldr r0, =gSaveBlock1Ptr - ldr r4, [r0] - movs r1, 0x92 - lsls r1, 3 - adds r4, r1 - mov r2, r8 - ldrh r0, [r2] - bl itemid_get_market_price - lsls r0, 16 - lsrs r0, 17 - mov r3, r10 - movs r2, 0x10 - ldrsh r1, [r3, r2] - muls r1, r0 - adds r0, r4, 0 - bl AddMoney - mov r3, r10 - ldrb r0, [r3] - mov r1, r9 - adds r2, r5, 0 - bl sub_81AE6C8 - ldrb r0, [r7, 0x5] - bl sub_81AB9A8 - ldrb r0, [r7, 0x5] - bl sub_81ABA88 - ldrb r0, [r7, 0x5] - bl load_bag_item_list_buffers - ldr r0, =gMultiuseListMenuTemplate - mov r2, r9 - ldrh r1, [r2] - ldrh r2, [r5] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - mov r3, r10 - strh r0, [r3] - movs r1, 0x2 - bl bag_menu_print_cursor_ - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000819 - adds r0, r1 - ldrb r4, [r0] - ldr r2, =gSaveBlock1Ptr - ldr r0, [r2] - movs r3, 0x92 - lsls r3, 3 - adds r0, r3 - bl GetMoney - adds r1, r0, 0 - adds r0, r4, 0 - movs r2, 0 - bl PrintMoneyAmountInMoneyBox - ldr r0, =gTasks + 0x8 - subs r0, 0x8 - adds r6, r0 - ldr r0, =sub_81AD9C0 - str r0, [r6] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AD8C8 - - thumb_func_start sub_81AD9C0 -sub_81AD9C0: @ 81AD9C0 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _081AD9E2 - movs r0, 0x5 - bl PlaySE - bl bag_menu_remove_money_window - adds r0, r4, 0 - bl bag_menu_inits_lists_menu -_081AD9E2: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81AD9C0 - - thumb_func_start display_deposit_item_ask_str -display_deposit_item_ask_str: @ 81AD9EC - push {r4-r6,lr} - sub sp, 0x14 - lsls r0, 24 - lsrs r2, r0, 24 - lsls r0, r2, 2 - adds r0, r2 - lsls r5, r0, 3 - ldr r6, =gTasks + 0x8 - adds r1, r5, r6 - movs r0, 0x1 - strh r0, [r1, 0x10] - movs r3, 0x4 - ldrsh r0, [r1, r3] - cmp r0, 0x1 - bne _081ADA18 - adds r0, r2, 0 - bl sub_81ADB14 - b _081ADA5E - .pool -_081ADA18: - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r4, =gStringVar4 - ldr r1, =gText_DepositHowManyVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - str r0, [sp, 0x10] - movs r0, 0x1 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x3 - bl bag_menu_print - movs r0, 0x7 - bl sub_81ABC3C - adds r0, r6, 0 - subs r0, 0x8 - adds r0, r5, r0 - ldr r1, =sub_81ADA7C - str r1, [r0] -_081ADA5E: - add sp, 0x14 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end display_deposit_item_ask_str - - thumb_func_start sub_81ADA7C -sub_81ADA7C: @ 81ADA7C - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - adds r0, r5, 0 - adds r0, 0x10 - ldrh r1, [r5, 0x4] - bl AdjustQuantityAccordingToDPadInput - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081ADAC0 - ldr r0, =gUnknown_0203CE54 - ldr r0, [r0] - ldr r1, =0x00000817 - adds r0, r1 - ldrb r0, [r0] - movs r2, 0x10 - ldrsh r1, [r5, r2] - bl sub_81ABC54 - b _081ADB0E - .pool -_081ADAC0: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081ADAE4 - movs r0, 0x5 - bl PlaySE - movs r0, 0x7 - bl bag_menu_remove_window - adds r0, r4, 0 - bl sub_81ADB14 - b _081ADB0E - .pool -_081ADAE4: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081ADB0E - movs r0, 0x5 - bl PlaySE - movs r1, 0x2 - ldrsh r0, [r5, r1] - bl bag_menu_print_description_box_text - ldrb r0, [r5] - movs r1, 0 - bl bag_menu_print_cursor_ - movs r0, 0x7 - bl bag_menu_remove_window - adds r0, r6, 0 - bl set_callback3_to_bag -_081ADB0E: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81ADA7C - - thumb_func_start sub_81ADB14 -sub_81ADB14: @ 81ADB14 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x14 - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r7, r1, 3 - ldr r0, =gTasks + 0x8 - mov r9, r0 - adds r2, r7, 0 - add r2, r9 - mov r8, r2 - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - ldr r4, =gSpecialVar_ItemId - ldrh r0, [r4] - bl itemid_is_unique - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0 - beq _081ADB6C - ldr r2, =gText_CantStoreImportantItems - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r0, [sp, 0xC] - str r0, [sp, 0x10] - movs r0, 0x1 - b _081ADBE2 - .pool -_081ADB6C: - ldrh r0, [r4] - mov r3, r8 - ldrh r1, [r3, 0x10] - bl AddPCItem - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x1 - bne _081ADBD4 - ldrh r0, [r4] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r0, =gStringVar2 - mov r2, r8 - movs r3, 0x10 - ldrsh r1, [r2, r3] - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_DepositedVar2Var1s - adds r0, r4, 0 - bl StringExpandPlaceholders - str r6, [sp] - str r5, [sp, 0x4] - str r5, [sp, 0x8] - str r5, [sp, 0xC] - str r5, [sp, 0x10] - movs r0, 0x1 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0x3 - bl bag_menu_print - mov r0, r9 - subs r0, 0x8 - adds r0, r7, r0 - ldr r1, =Task_ActuallyToss - b _081ADBF2 - .pool -_081ADBD4: - ldr r2, =gText_NoRoomForItems - movs r0, 0x1 - str r0, [sp] - str r5, [sp, 0x4] - str r5, [sp, 0x8] - str r5, [sp, 0xC] - str r5, [sp, 0x10] -_081ADBE2: - movs r1, 0x1 - movs r3, 0x3 - bl bag_menu_print - mov r0, r9 - subs r0, 0x8 - adds r0, r7, r0 - ldr r1, =sub_81ADC0C -_081ADBF2: - str r1, [r0] - add sp, 0x14 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81ADB14 - - thumb_func_start sub_81ADC0C -sub_81ADC0C: @ 81ADC0C - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _081ADC44 - movs r0, 0x5 - bl PlaySE - movs r1, 0x2 - ldrsh r0, [r5, r1] - bl bag_menu_print_description_box_text - ldrb r0, [r5] - movs r1, 0 - bl bag_menu_print_cursor_ - adds r0, r4, 0 - bl set_callback3_to_bag -_081ADC44: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81ADC0C - - thumb_func_start IsWallysBag -@ bool8 IsWallysBag() -IsWallysBag: @ 81ADC54 - push {lr} - ldr r0, =gUnknown_0203CE58 - ldrb r0, [r0, 0x4] - cmp r0, 0xA - beq _081ADC68 - movs r0, 0 - b _081ADC6A - .pool -_081ADC68: - movs r0, 0x1 -_081ADC6A: - pop {r1} - bx r1 - thumb_func_end IsWallysBag - - thumb_func_start PrepareBagForWallyTutorial -@ void PrepareBagForWallyTutorial() -PrepareBagForWallyTutorial: @ 81ADC70 - push {r4-r6,lr} - ldr r4, =gUnknown_0203CE80 - movs r0, 0xD0 - bl AllocZeroed - str r0, [r4] - ldr r5, =gSaveBlock1Ptr - ldr r1, [r5] - movs r2, 0xAC - lsls r2, 3 - adds r1, r2 - movs r2, 0x78 - bl memcpy - ldr r0, [r4] - ldr r1, [r5] - movs r2, 0xCA - lsls r2, 3 - adds r1, r2 - adds r0, 0x78 - movs r2, 0x40 - bl memcpy - ldr r0, [r4] - ldr r2, =gUnknown_0203CE58 - ldrb r1, [r2, 0x5] - adds r0, 0xCE - strh r1, [r0] - movs r6, 0 - adds r5, r2, 0 - adds r5, 0x8 -_081ADCAE: - ldr r2, [r4] - lsls r3, r6, 1 - adds r0, r2, 0 - adds r0, 0xB8 - adds r0, r3 - ldrh r1, [r5] - strh r1, [r0] - adds r2, 0xC2 - adds r2, r3 - ldrh r0, [r5, 0xA] - strh r0, [r2] - adds r5, 0x2 - adds r6, 0x1 - cmp r6, 0x4 - bls _081ADCAE - ldr r4, =gSaveBlock1Ptr - ldr r0, [r4] - movs r1, 0xAC - lsls r1, 3 - adds r0, r1 - movs r1, 0x1E - bl ClearItemSlots - ldr r0, [r4] - movs r2, 0xCA - lsls r2, 3 - adds r0, r2 - movs r1, 0x10 - bl ClearItemSlots - bl ResetBagScrollPositions - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end PrepareBagForWallyTutorial - - thumb_func_start RestoreBagAfterWallyTutorial -@ void RestoreBagAfterWallyTutorial() -RestoreBagAfterWallyTutorial: @ 81ADD00 - push {r4-r6,lr} - ldr r5, =gSaveBlock1Ptr - ldr r0, [r5] - movs r1, 0xAC - lsls r1, 3 - adds r0, r1 - ldr r4, =gUnknown_0203CE80 - ldr r1, [r4] - movs r2, 0x78 - bl memcpy - ldr r0, [r5] - movs r1, 0xCA - lsls r1, 3 - adds r0, r1 - ldr r1, [r4] - adds r1, 0x78 - movs r2, 0x40 - bl memcpy - ldr r1, =gUnknown_0203CE58 - ldr r0, [r4] - adds r0, 0xCE - ldrh r0, [r0] - strb r0, [r1, 0x5] - movs r5, 0 - adds r6, r4, 0 - adds r3, r1, 0 - adds r3, 0x8 -_081ADD3A: - lsls r2, r5, 1 - ldr r1, [r4] - adds r0, r1, 0 - adds r0, 0xB8 - adds r0, r2 - ldrh r0, [r0] - strh r0, [r3] - adds r1, 0xC2 - adds r1, r2 - ldrh r0, [r1] - strh r0, [r3, 0xA] - adds r3, 0x2 - adds r5, 0x1 - cmp r5, 0x4 - bls _081ADD3A - ldr r0, [r6] - bl Free - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end RestoreBagAfterWallyTutorial - - thumb_func_start DoWallyTutorialBagMenu -@ void DoWallyTutorialBagMenu() -DoWallyTutorialBagMenu: @ 81ADD70 - push {lr} - bl PrepareBagForWallyTutorial - movs r0, 0xD - movs r1, 0x1 - bl AddBagItem - movs r0, 0x4 - movs r1, 0x1 - bl AddBagItem - ldr r2, =SetCB2ToReshowScreenAfterMenu2 - movs r0, 0xA - movs r1, 0 - bl GoToBagMenu - pop {r0} - bx r0 - .pool - thumb_func_end DoWallyTutorialBagMenu - - thumb_func_start Task_WallyTutorialBagMenu -@ void Task_WallyTutorialBagMenu(u8 taskId) -Task_WallyTutorialBagMenu: @ 81ADD98 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _081ADE32 - movs r0, 0x10 - ldrsh r1, [r4, r0] - cmp r1, 0xCC - beq _081ADDEC - cmp r1, 0xCC - bgt _081ADDD0 - cmp r1, 0x66 - beq _081ADDDA - b _081ADE2C - .pool -_081ADDD0: - movs r0, 0x99 - lsls r0, 1 - cmp r1, r0 - beq _081ADE0C - b _081ADE2C -_081ADDDA: - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - movs r1, 0x1 - movs r2, 0 - bl SwitchBagPocket - b _081ADE2C -_081ADDEC: - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4] - movs r1, 0x2 - bl bag_menu_print_cursor_ - ldr r1, =gSpecialVar_ItemId - movs r0, 0x4 - strh r0, [r1] - adds r0, r5, 0 - bl sub_81AC644 - b _081ADE2C - .pool -_081ADE0C: - movs r0, 0x5 - bl PlaySE - bl bag_menu_remove_some_window - ldrb r0, [r4] - movs r1, 0 - movs r2, 0 - bl sub_81AE6C8 - bl RestoreBagAfterWallyTutorial - adds r0, r5, 0 - bl unknown_ItemMenu_Confirm - b _081ADE32 -_081ADE2C: - ldrh r0, [r4, 0x10] - adds r0, 0x1 - strh r0, [r4, 0x10] -_081ADE32: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end Task_WallyTutorialBagMenu - - thumb_func_start unknown_ItemMenu_Show -unknown_ItemMenu_Show: @ 81ADE38 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =gSpecialVar_0x8005 - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - strh r0, [r1] - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - strh r0, [r1] - bl bag_menu_remove_some_window - adds r0, r4, 0 - bl unknown_ItemMenu_Confirm - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end unknown_ItemMenu_Show - - thumb_func_start bag_menu_leave_maybe_3 -bag_menu_leave_maybe_3: @ 81ADE6C - push {lr} - ldr r0, =gFieldCallback - ldr r1, =sub_819FA50 - str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_leave_maybe_3 - - thumb_func_start unknown_ItemMenu_Give2 -unknown_ItemMenu_Give2: @ 81ADE8C - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - movs r1, 0x1 - bl RemoveBagItem - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - strh r0, [r1] - bl bag_menu_remove_some_window - adds r0, r4, 0 - bl unknown_ItemMenu_Confirm - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end unknown_ItemMenu_Give2 - - thumb_func_start bag_menu_leave_maybe_2 -bag_menu_leave_maybe_2: @ 81ADEBC - push {lr} - ldr r0, =gFieldCallback - ldr r1, =sub_818DEF4 - str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_leave_maybe_2 - - thumb_func_start unknown_ItemMenu_Confirm2 -unknown_ItemMenu_Confirm2: @ 81ADEDC - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - strh r0, [r1] - bl bag_menu_remove_some_window - adds r0, r4, 0 - bl unknown_ItemMenu_Confirm - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end unknown_ItemMenu_Confirm2 - - thumb_func_start bag_menu_leave_maybe -bag_menu_leave_maybe: @ 81ADF00 - push {lr} - ldr r0, =gFieldCallback - ldr r1, =sub_818E564 - str r1, [r0] - ldr r0, =c2_exit_to_overworld_2_switch - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_leave_maybe - - thumb_func_start bag_menu_print_pocket_names -bag_menu_print_pocket_names: @ 81ADF20 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x1C - adds r4, r0, 0 - mov r8, r1 - movs r0, 0 - movs r1, 0 - str r0, [sp, 0x14] - str r1, [sp, 0x18] - ldr r1, =0x00ffffff - ldr r0, [sp, 0x14] - ands r0, r1 - movs r1, 0x80 - lsls r1, 21 - orrs r0, r1 - str r0, [sp, 0x14] - ldr r1, =0xffffff00 - ldr r0, [sp, 0x18] - ands r0, r1 - movs r1, 0x2 - orrs r0, r1 - str r0, [sp, 0x18] - add r0, sp, 0x14 - bl AddWindow - lsls r0, 24 - lsrs r6, r0, 24 - adds r0, r6, 0 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0x40 - bl GetStringCenterAlignXOffset - lsls r3, r0, 24 - lsrs r3, 24 - movs r7, 0x1 - str r7, [sp] - movs r5, 0 - str r5, [sp, 0x4] - str r5, [sp, 0x8] - movs r0, 0xFF - mov r9, r0 - str r0, [sp, 0xC] - str r7, [sp, 0x10] - adds r0, r6, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl bag_menu_print - mov r2, r8 - cmp r2, 0 - beq _081ADFBA - movs r0, 0x1 - mov r1, r8 - movs r2, 0x40 - bl GetStringCenterAlignXOffset - adds r3, r0, 0 - adds r3, 0x40 - lsls r3, 24 - lsrs r3, 24 - str r7, [sp] - str r5, [sp, 0x4] - str r5, [sp, 0x8] - mov r0, r9 - str r0, [sp, 0xC] - str r7, [sp, 0x10] - adds r0, r6, 0 - movs r1, 0x1 - mov r2, r8 - bl bag_menu_print -_081ADFBA: - adds r0, r6, 0 - movs r1, 0x7 - bl GetWindowAttribute - ldr r1, =gUnknown_0203CE54 - ldr r1, [r1] - ldr r2, =0x00000844 - adds r1, r2 - ldr r2, =0x04000100 - bl CpuSet - adds r0, r6, 0 - bl RemoveWindow - add sp, 0x1C - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_print_pocket_names - - thumb_func_start bag_menu_copy_pocket_name_to_window -bag_menu_copy_pocket_name_to_window: @ 81ADFF8 - push {r4-r7,lr} - adds r7, r0, 0 - cmp r7, 0x8 - bls _081AE002 - movs r7, 0x8 -_081AE002: - ldr r0, =gUnknown_0203CE54 - ldr r4, [r0] - ldr r0, =0x00000844 - adds r4, r0 - movs r0, 0x2 - movs r1, 0x7 - bl GetWindowAttribute - adds r5, r0, 0 - lsls r0, r7, 5 - adds r0, r4, r0 - ldr r6, =0x04000040 - adds r1, r5, 0 - adds r2, r6, 0 - bl CpuSet - adds r0, r7, 0 - adds r0, 0x10 - lsls r0, 5 - adds r4, r0 - movs r0, 0x80 - lsls r0, 1 - adds r5, r0 - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - bl CpuSet - movs r0, 0x2 - movs r1, 0x2 - bl CopyWindowToVram - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_copy_pocket_name_to_window - - thumb_func_start setup_bag_menu_textboxes -setup_bag_menu_textboxes: @ 81AE054 - push {r4,lr} - ldr r0, =gUnknown_08614174 - bl InitWindows - bl DeactivateAllTextPrinters - movs r0, 0 - movs r1, 0x1 - movs r2, 0xE0 - bl sub_809882C - movs r0, 0 - movs r1, 0xA - movs r2, 0xD0 - bl copy_textbox_border_tile_patterns_to_vram - movs r0, 0xC0 - movs r1, 0x1 - bl sub_819A2BC - ldr r0, =gUnknown_0860F074 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - movs r4, 0 -_081AE088: - adds r0, r4, 0 - movs r1, 0 - bl FillWindowPixelBuffer - adds r0, r4, 0 - bl PutWindowTilemap - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x2 - bls _081AE088 - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end setup_bag_menu_textboxes - - thumb_func_start bag_menu_print -bag_menu_print: @ 81AE0BC - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x14 - mov r9, r3 - ldr r3, [sp, 0x30] - ldr r4, [sp, 0x34] - ldr r6, [sp, 0x38] - ldr r5, [sp, 0x3C] - mov r8, r5 - ldr r5, [sp, 0x40] - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - mov r7, r9 - lsls r7, 24 - lsrs r7, 24 - mov r9, r7 - lsls r3, 24 - lsrs r3, 24 - lsls r4, 24 - lsrs r4, 24 - lsls r6, 24 - lsrs r6, 24 - lsls r5, 24 - lsrs r5, 24 - str r4, [sp] - str r6, [sp, 0x4] - lsls r4, r5, 1 - adds r4, r5 - ldr r5, =gUnknown_08614164 - adds r4, r5 - str r4, [sp, 0x8] - mov r4, r8 - lsls r4, 24 - asrs r4, 24 - str r4, [sp, 0xC] - str r2, [sp, 0x10] - mov r2, r9 - bl AddTextPrinterParameterized2 - add sp, 0x14 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_print - - thumb_func_start sub_81AE124 -sub_81AE124: @ 81AE124 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203CE54 - ldr r1, [r1] - movs r2, 0x81 - lsls r2, 4 - adds r1, r2 - adds r1, r0 - ldrb r0, [r1] - bx lr - .pool - thumb_func_end sub_81AE124 - - thumb_func_start bag_menu_add_window -bag_menu_add_window: @ 81AE13C - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0203CE54 - movs r3, 0x81 - lsls r3, 4 - adds r1, r2, r3 - ldr r0, [r0] - adds r4, r0, r1 - ldrb r0, [r4] - cmp r0, 0xFF - bne _081AE172 - lsls r0, r2, 3 - ldr r1, =gUnknown_086141AC - adds r0, r1 - bl AddWindow - strb r0, [r4] - ldrb r0, [r4] - movs r1, 0 - movs r2, 0x1 - movs r3, 0xE - bl SetWindowBorderStyle - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram -_081AE172: - ldrb r0, [r4] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end bag_menu_add_window - - thumb_func_start bag_menu_remove_window -bag_menu_remove_window: @ 81AE184 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203CE54 - movs r2, 0x81 - lsls r2, 4 - adds r0, r2 - ldr r1, [r1] - adds r4, r1, r0 - ldrb r0, [r4] - cmp r0, 0xFF - beq _081AE1B8 - movs r1, 0 - bl sub_8198070 - ldrb r0, [r4] - bl ClearWindowTilemap - ldrb r0, [r4] - bl RemoveWindow - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0xFF - strb r0, [r4] -_081AE1B8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_remove_window - - thumb_func_start AddItemMessageWindow -@ u8 AddItemMessageWindow(u8 a1) -AddItemMessageWindow: @ 81AE1C4 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0203CE54 - movs r3, 0x81 - lsls r3, 4 - adds r1, r2, r3 - ldr r0, [r0] - adds r4, r0, r1 - ldrb r0, [r4] - cmp r0, 0xFF - bne _081AE1E8 - lsls r0, r2, 3 - ldr r1, =gUnknown_086141AC - adds r0, r1 - bl AddWindow - strb r0, [r4] -_081AE1E8: - ldrb r0, [r4] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end AddItemMessageWindow - - thumb_func_start bag_menu_RemoveBagItem_message_window -bag_menu_RemoveBagItem_message_window: @ 81AE1F8 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203CE54 - movs r2, 0x81 - lsls r2, 4 - adds r0, r2 - ldr r1, [r1] - adds r4, r1, r0 - ldrb r0, [r4] - cmp r0, 0xFF - beq _081AE22C - movs r1, 0 - bl sub_8197DF8 - ldrb r0, [r4] - bl ClearWindowTilemap - ldrb r0, [r4] - bl RemoveWindow - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - movs r0, 0xFF - strb r0, [r4] -_081AE22C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_RemoveBagItem_message_window - - thumb_func_start bag_menu_yes_no -bag_menu_yes_no: @ 81AE238 - push {lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 21 - ldr r3, =gUnknown_086141AC - adds r1, r3 - movs r3, 0x2 - str r3, [sp] - movs r3, 0x1 - str r3, [sp, 0x4] - movs r3, 0xE - str r3, [sp, 0x8] - str r2, [sp, 0xC] - movs r2, 0x1 - movs r3, 0 - bl CreateYesNoMenuWithCallbacks - add sp, 0x10 - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_yes_no - - thumb_func_start bag_menu_AddMoney_window -bag_menu_AddMoney_window: @ 81AE268 - push {r4,lr} - movs r0, 0x9 - bl bag_menu_add_window - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x92 - lsls r1, 3 - adds r0, r1 - bl GetMoney - adds r3, r0, 0 - adds r0, r4, 0 - movs r1, 0x1 - movs r2, 0xE - bl PrintMoneyAmountInMoneyBoxWithBorder - movs r0, 0x13 - movs r1, 0xB - bl AddMoneyLabelObject - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end bag_menu_AddMoney_window - - thumb_func_start bag_menu_remove_money_window -bag_menu_remove_money_window: @ 81AE2A4 - push {lr} - movs r0, 0x9 - bl bag_menu_remove_window - bl RemoveMoneyLabelObject - pop {r0} - bx r0 - thumb_func_end bag_menu_remove_money_window - - thumb_func_start bag_menu_prepare_tmhm_move_window -bag_menu_prepare_tmhm_move_window: @ 81AE2B4 - push {lr} - movs r0, 0x3 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0x3 - movs r1, 0x13 - movs r2, 0 - movs r3, 0 - bl blit_move_info_icon - movs r0, 0x3 - movs r1, 0x14 - movs r2, 0 - movs r3, 0xC - bl blit_move_info_icon - movs r0, 0x3 - movs r1, 0x15 - movs r2, 0 - movs r3, 0x18 - bl blit_move_info_icon - movs r0, 0x3 - movs r1, 0x16 - movs r2, 0 - movs r3, 0x24 - bl blit_move_info_icon - movs r0, 0x3 - movs r1, 0x2 - bl CopyWindowToVram - pop {r0} - bx r0 - thumb_func_end bag_menu_prepare_tmhm_move_window - - thumb_func_start PrintTMHMMoveData -PrintTMHMMoveData: @ 81AE2FC - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x14 - lsls r0, 16 - lsrs r4, r0, 16 - movs r0, 0x4 - movs r1, 0 - bl FillWindowPixelBuffer - cmp r4, 0 - bne _081AE354 - movs r4, 0 - movs r5, 0 -_081AE31A: - lsls r0, r4, 1 - adds r0, r4 - lsls r0, 26 - lsrs r0, 24 - str r0, [sp] - str r5, [sp, 0x4] - str r5, [sp, 0x8] - movs r0, 0xFF - str r0, [sp, 0xC] - movs r0, 0x4 - str r0, [sp, 0x10] - movs r1, 0x1 - ldr r2, =gText_ThreeDashes - movs r3, 0x7 - bl bag_menu_print - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x3 - bls _081AE31A - movs r0, 0x4 - movs r1, 0x2 - bl CopyWindowToVram - b _081AE440 - .pool -_081AE354: - adds r0, r4, 0 - bl ItemIdToBattleMoveId - lsls r0, 16 - lsrs r7, r0, 16 - ldr r1, =gBattleMoves - lsls r0, r7, 1 - adds r0, r7 - lsls r0, 2 - adds r5, r0, r1 - ldrb r1, [r5, 0x2] - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - movs r0, 0x4 - movs r2, 0 - movs r3, 0 - bl blit_move_info_icon - ldrb r0, [r5, 0x1] - cmp r0, 0x1 - bhi _081AE38C - ldr r2, =gText_ThreeDashes - b _081AE39C - .pool -_081AE38C: - ldr r4, =gStringVar1 - ldrb r1, [r5, 0x1] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - adds r2, r4, 0 -_081AE39C: - movs r0, 0xC - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r0, 0xFF - str r0, [sp, 0xC] - movs r0, 0x4 - str r0, [sp, 0x10] - movs r1, 0x1 - movs r3, 0x7 - bl bag_menu_print - ldr r2, =gBattleMoves - lsls r1, r7, 1 - adds r0, r1, r7 - lsls r0, 2 - adds r2, r0, r2 - ldrb r0, [r2, 0x3] - adds r6, r1, 0 - cmp r0, 0 - bne _081AE3D8 - ldr r2, =gText_ThreeDashes - b _081AE3E8 - .pool -_081AE3D8: - ldr r4, =gStringVar1 - ldrb r1, [r2, 0x3] - adds r0, r4, 0 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - adds r2, r4, 0 -_081AE3E8: - movs r0, 0x18 - str r0, [sp] - movs r4, 0 - str r4, [sp, 0x4] - str r4, [sp, 0x8] - movs r0, 0xFF - mov r8, r0 - str r0, [sp, 0xC] - movs r0, 0x4 - mov r9, r0 - str r0, [sp, 0x10] - movs r1, 0x1 - movs r3, 0x7 - bl bag_menu_print - ldr r5, =gStringVar1 - ldr r1, =gBattleMoves - adds r0, r6, r7 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x4] - adds r0, r5, 0 - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - movs r0, 0x24 - str r0, [sp] - str r4, [sp, 0x4] - str r4, [sp, 0x8] - mov r0, r8 - str r0, [sp, 0xC] - mov r0, r9 - str r0, [sp, 0x10] - movs r0, 0x4 - movs r1, 0x1 - adds r2, r5, 0 - movs r3, 0x7 - bl bag_menu_print - movs r0, 0x4 - movs r1, 0x2 - bl CopyWindowToVram -_081AE440: - add sp, 0x14 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end PrintTMHMMoveData - - .align 2, 0 @ Don't pad with nop. diff --git a/ld_script.txt b/ld_script.txt index 8e7d996d9..48608473e 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -251,7 +251,6 @@ SECTIONS { asm/menu.o(.text); asm/battle_frontier_2.o(.text); src/item_menu.o(.text); - asm/item_menu.o(.text); asm/list_menu.o(.text); asm/menu_indicators.o(.text); src/unk_text_util.o(.text); diff --git a/src/item_menu.c b/src/item_menu.c index 00ba284bd..55d3f088c 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1,47 +1,59 @@ #include "global.h" +#include "battle_frontier_2.h" #include "bg.h" #include "constants/items.h" #include "constants/songs.h" #include "decompress.h" #include "event_data.h" +#include "field_player_avatar.h" #include "gpu_regs.h" #include "international_string_util.h" #include "item.h" #include "list_menu.h" +#include "link.h" +#include "mail.h" #include "main.h" #include "malloc.h" +#include "map_name_popup.h" #include "menu.h" #include "menu_indicators.h" #include "money.h" #include "new_menu_helpers.h" +#include "overworld.h" #include "palette.h" +#include "pokemon.h" #include "rom_818CFC8.h" #include "scanline_effect.h" +#include "script.h" #include "sound.h" #include "sprite.h" #include "string.h" #include "string_util.h" #include "task.h" +#include "text_window.h" #include "menu_helpers.h" #include "window.h" struct bagStruct { - void *func; - u8 unk4; + void (*bagCallback)(void); + u8 location; u8 pocket; u8 unk6[2]; - u16 unk8[5]; - u16 unk12[5]; - void *unk1C; + u16 cursorPosition[5]; + u16 scrollPosition[5]; + u8 **pocketStringsPtr; }; struct unkBagStruct { - void* unk0; + MainCallback unk0; u8 unk4[0x800]; u8 unk804; - u8 filler4; + u8 unk805; u8 unk806[10]; - u8 unk810[10]; + u8 unk810[7]; + u8 unk817; + u8 unk818; + u8 unk819; u8 unk81A; u8 unk81B:4; u8 unk81B_1:2; @@ -50,11 +62,17 @@ struct unkBagStruct { u8 filler3[2]; u8 unk81E; u8 unk81F; - u8 filler5[9]; + u8* unk820; + u8 unk824; + u8 unk825; + u8 filler[2]; + u8 unk828; u8 unk829[5]; u8 unk82E[6]; s16 unk834; - u8 filler2[0x412]; + u8 filler4[0xE]; + u8 unk844[32][32]; + u8 filler2[4]; }; struct listBuffer1 { @@ -65,10 +83,25 @@ struct listBuffer2 { s8 name[65][24]; }; +struct unkWallyStruct { + struct ItemSlot bagPocket_Items[30]; + struct ItemSlot bagPocket_PokeBalls[16]; + u16 cursorPosition[5]; + u16 scrollPosition[5]; + u8 filler[0x2]; + u16 pocket; +}; + +struct unkStructTextFunc{ + u8* text; + TaskFunc func; +}; + extern struct bagStruct gUnknown_0203CE58; extern struct unkBagStruct *gUnknown_0203CE54; extern struct listBuffer1 *gUnknown_0203CE74; extern struct listBuffer2 *gUnknown_0203CE78; +extern struct unkWallyStruct *gUnknown_0203CE80; extern u16 gUnknown_0203CE6A[]; extern u16 gUnknown_0203CE60[]; extern void sub_8086194(void); @@ -95,6 +128,29 @@ extern void sub_80D6FB4(struct BagPocket*); extern void sub_80D6F64(struct BagPocket*); extern u8 GetLRKeysState(void); extern void sub_81AC23C(u8); +extern void sub_81AF15C(u8, u8, u8); +extern void sub_80D4FEC(u8); +extern void sub_80D4FC8(u8); +extern void sub_80D702C(struct ItemSlot*, s16, u16); +extern bool8 sub_8122148(u16); +extern void AddItemMenuActionTextPrinters (u8, u8, u8, u8, u8, u8, u8, struct unkStructTextFunc*, u8*); +extern void sub_8198DBC(u8, u8, u8, u8, u8, u8, u8, struct unkStructTextFunc*, u8*); +extern void sub_8199944(u8, u8, u8, u8, u8); +extern void sub_8199134(s8, s8); +extern void sub_80FDD10(u8); +extern bool8 AdjustQuantityAccordingToDPadInput(s16*, u16); +extern void sub_81B7F60(void); +extern bool8 itemid_80BF6D8_mail_related(u16); +extern void sub_8177C14(void); +extern void sub_808B864(void); +extern void sub_808BCF4(void); +extern void FreezeMapObjects(void); +extern bool8 InMultiBattleRoom(void); +extern void (*gFieldCallback)(void); +extern void sub_819FA50(void); +extern void sub_818DEF4(void); +extern void sub_818E564(void); +extern void sub_819A2BC(u8, u8); void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()); void CB2_Bag(void); @@ -105,7 +161,7 @@ void setup_bag_menu_textboxes(void); void allocate_bag_item_list_buffers(void); void load_bag_item_list_buffers(u8); void bag_menu_print_pocket_names(u8*, u8*); -void bag_menu_copy_pocket_name_to_window(u8); +void bag_menu_copy_pocket_name_to_window(u32); void bag_menu_draw_pocket_indicator_square(u8, u8); void AddBagVisualObject(u8); void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void); @@ -139,6 +195,36 @@ void SetBagVisualPocketId(u8, u8); void RemoveBagObject(u8); void AddSwitchPocketRotatingBallObject(s16); void sub_81AC10C(u8); +void sub_81AC3C0(u8); +void sub_81AC498(u8); +void sub_81AC590(u8); +void PrintTMHMMoveData(u16); +void sub_81ACAF8(u8); +void sub_81ACB54(u8, u8, u8); +void Task_HandleInBattleItemMenuInput(u8); +void Task_HandleOutOfBattleItemMenuInput(u8); +bool8 sub_81ACDFC(s8); +void bag_menu_remove_window(u8); +void bag_menu_print_there_is_no_pokemon(u8); +void Task_ChooseHowManyToToss(u8); +void BagMenuConfirmToss(u8); +void bag_menu_yes_no(u8, u8, struct YesNoFuncTable*); +void Task_ActuallyToss(u8); +void ItemMenu_Cancel(u8); +void sub_81AD350(u8); +void bag_menu_print_cant_be_held_msg(u8); +void bag_menu_AddMoney_window(void); +void sub_81AD680(u8); +void sub_81AD730(u8); +void sub_81AD6E4(u8); +void bag_menu_remove_money_window(void); +void bag_menu_RemoveBagItem_message_window(u8); +void sub_81AD794(u8); +void sub_81AD8C8(u8); +void sub_81AD9C0(u8); +void sub_81ADB14(u8); +void sub_81ADA7C(u8); +void sub_81ADC0C(u8); extern u8 *gPocketNamesStringsTable[]; extern struct BgTemplate gUnknown_08613F90[]; @@ -164,12 +250,51 @@ extern u32 gUnknown_08614094[]; extern u32 gUnknown_0203CE5E[]; extern u16 gSpecialVar_ItemId; extern TaskFunc gUnknown_08614054[]; +extern u8 gText_MoveVar1Where[]; +extern u8 gUnknown_0861402C[]; +extern u8 gUnknown_08614030[]; +extern u8 gUnknown_08614034[]; +extern u8 gUnknown_08614038[]; +extern u8 gUnknown_0861403C[]; +extern u8 gUnknown_08614042[]; +extern u8 gUnknown_08614044[]; +extern u8 gUnknown_08614046[]; +extern u8 gUnknown_08614047[]; +extern u8 gUnknown_0861404B[]; +extern u8 gUnknown_0861404D[]; +extern u8 gUnknown_0861404F[]; +extern u8 gText_Var1IsSelected[]; +extern struct unkStructTextFunc gUnknown_08613FB4[]; +extern u8 gText_TossHowManyVar1s[]; +extern u8 gText_ConfirmTossItems[]; +extern struct YesNoFuncTable gUnknown_08614084; +extern u8 gText_ThrewAwayVar2Var1s[]; +extern u8 gText_CantWriteMail[]; +extern u8 gText_NoPokemon[]; +extern u8 gText_Var1CantBeHeld[]; +extern u8 gText_Var1CantBeHeldHere[]; +extern u8 EventScript_2736B3[]; +extern u8 gText_CantBuyKeyItem[]; +extern u8 gText_HowManyToSell[]; +extern u8 gText_ICanPayVar1[]; +extern struct YesNoFuncTable gUnknown_0861408C; +extern u8 gText_TurnedOverVar1ForVar2[]; +extern u8 gText_DepositHowManyVar1[]; +extern u8 gText_CantStoreImportantItems[]; +extern u8 gText_DepositedVar2Var1s[]; +extern u8 gText_NoRoomForItems[]; +extern struct WindowTemplate gUnknown_08614174[]; +extern u16 gUnknown_0860F074[]; +extern struct TextColor gUnknown_08614164[]; +extern struct WindowTemplate gUnknown_086141AC[]; +extern struct BattleMove gBattleMoves[]; +extern u8 gText_ThreeDashes[]; void ResetBagScrollPositions(void) { gUnknown_0203CE58.pocket = 0; - memset(gUnknown_0203CE58.unk8, 0, 10); - memset(gUnknown_0203CE58.unk12, 0, 10); + memset(gUnknown_0203CE58.cursorPosition, 0, 10); + memset(gUnknown_0203CE58.scrollPosition, 0, 10); } void CB2_BagMenuFromStartMenu(void) @@ -233,12 +358,12 @@ void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2) else { if (bagMenuType != 12) - gUnknown_0203CE58.unk4 = bagMenuType; + gUnknown_0203CE58.location = bagMenuType; if (postExitMenuMainCallback2) - gUnknown_0203CE58.func = postExitMenuMainCallback2; + gUnknown_0203CE58.bagCallback = postExitMenuMainCallback2; if (pocketId <= 4) gUnknown_0203CE58.pocket = pocketId; - temp = gUnknown_0203CE58.unk4 - 4; + temp = gUnknown_0203CE58.location - 4; if (temp <= 1) gUnknown_0203CE54->unk81B = 1; gUnknown_0203CE54->unk0 = 0; @@ -344,8 +469,8 @@ bool8 setup_bag_menu(void) gMain.state++; break; case 14: - taskId = sub_81AB1F0(gUnknown_0203CE58.unk4); - gTasks[taskId].data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]); + taskId = sub_81AB1F0(gUnknown_0203CE58.location); + gTasks[taskId].data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); gTasks[taskId].data[3] = 0; gTasks[taskId].data[8] = 0; gMain.state++; @@ -590,7 +715,7 @@ void bag_menu_print_description_box_text(int a) str = (u8*)ItemId_GetDescription(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, a)); else { - StringCopy(gStringVar1, gReturnToXStringsTable[gUnknown_0203CE58.unk4]); + StringCopy(gStringVar1, gReturnToXStringsTable[gUnknown_0203CE58.location]); str = gStringVar4; StringExpandPlaceholders(str, gText_ReturnToVar1); } @@ -615,7 +740,7 @@ void bag_menu_print_cursor(u8 a, u8 b) void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void) { if (gUnknown_0203CE54->unk81E == 0xFF) - gUnknown_0203CE54->unk81E = AddScrollIndicatorArrowPairParametrized(2, 0xAC, 12, 0x94, gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - gUnknown_0203CE54->unk82E[gUnknown_0203CE58.pocket], 0x6E, 0x6E, &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket]); + gUnknown_0203CE54->unk81E = AddScrollIndicatorArrowPairParametrized(2, 0xAC, 12, 0x94, gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - gUnknown_0203CE54->unk82E[gUnknown_0203CE58.pocket], 0x6E, 0x6E, &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]); } void sub_81AB824(void) @@ -662,11 +787,11 @@ void task_close_bag_menu_2(u8 taskId) s16* data = gTasks[taskId].data; if (!gPaletteFade.active) { - sub_81AE6C8(data[0], &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]); + sub_81AE6C8(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); if (gUnknown_0203CE54->unk0 != 0) SetMainCallback2(gUnknown_0203CE54->unk0); else - SetMainCallback2(gUnknown_0203CE58.func); + SetMainCallback2(gUnknown_0203CE58.bagCallback); sub_81AB824(); ResetSpriteData(); FreeAllSpritePalettes(); @@ -709,7 +834,7 @@ void sub_81ABA6C(void) void sub_81ABA88(u8 a) { - sub_812225C(&gUnknown_0203CE58.unk12[a], &gUnknown_0203CE58.unk8[a], gUnknown_0203CE54->unk82E[a], gUnknown_0203CE54->unk829[a]); + sub_812225C(&gUnknown_0203CE58.scrollPosition[a], &gUnknown_0203CE58.cursorPosition[a], gUnknown_0203CE54->unk82E[a], gUnknown_0203CE54->unk829[a]); } void sub_81ABAC4(void) @@ -723,12 +848,12 @@ void sub_81ABAE0(void) { u8 i; for (i = 0;i < 5;i++) - sub_8122298(&gUnknown_0203CE58.unk12[i], &gUnknown_0203CE58.unk8[i], gUnknown_0203CE54->unk82E[i], gUnknown_0203CE54->unk829[i], 8); + sub_8122298(&gUnknown_0203CE58.scrollPosition[i], &gUnknown_0203CE58.cursorPosition[i], gUnknown_0203CE54->unk82E[i], gUnknown_0203CE54->unk829[i], 8); } u8 sub_81ABB2C(u8 a) { - return gUnknown_0203CE58.unk12[a] + gUnknown_0203CE58.unk8[a]; + return gUnknown_0203CE58.scrollPosition[a] + gUnknown_0203CE58.cursorPosition[a]; } void DisplayItemMessage(u8 taskId, u8 fontId, u8 *str, void ( *callback)(u8 taskId)) @@ -744,14 +869,14 @@ void DisplayItemMessage(u8 taskId, u8 fontId, u8 *str, void ( *callback)(u8 task void bag_menu_inits_lists_menu(u8 taskId) { s16* data = gTasks[taskId].data; - u16* ScrollPos = &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket]; - u16* CursorPos = &gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]; + u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]; + u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; bag_menu_RemoveBagItem_message_window(4); - sub_81AE6C8(data[0], ScrollPos, CursorPos); + sub_81AE6C8(data[0], scrollPos, cursorPos); sub_81AB9A8(gUnknown_0203CE58.pocket); sub_81ABA88(gUnknown_0203CE58.pocket); load_bag_item_list_buffers(gUnknown_0203CE58.pocket); - data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *ScrollPos, *CursorPos); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); schedule_bg_copy_tilemap_to_vram(0); set_callback3_to_bag(taskId); } @@ -781,8 +906,8 @@ void sub_81ABCC0(int a, int b, int c) void Task_BagMenu(u8 taskId) { s16* data = gTasks[taskId].data; - u16* ScrollPos = &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket]; - u16* CursorPos = &gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]; + u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]; + u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; u16 select; if (sub_81221EC() != TRUE && !gPaletteFade.active) { @@ -799,8 +924,8 @@ void Task_BagMenu(u8 taskId) { if (sub_81AC2C0() == 1) { - sub_81AE860(data[0], ScrollPos, CursorPos); - if ((*ScrollPos + *CursorPos) != gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - 1) + sub_81AE860(data[0], scrollPos, cursorPos); + if ((*scrollPos + *cursorPos) != gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - 1) { PlaySE(SE_SELECT); bag_menu_swap_items(taskId); @@ -811,13 +936,13 @@ void Task_BagMenu(u8 taskId) else { int r4 = ListMenuHandleInputGetItemId(data[0]); - sub_81AE860(data[0], ScrollPos, CursorPos); + sub_81AE860(data[0], scrollPos, cursorPos); switch (r4) { case -1: break; case -2: - if (gUnknown_0203CE58.unk4 == 5) + if (gUnknown_0203CE58.location == 5) { PlaySE(SE_HAZURE); break; @@ -833,7 +958,7 @@ void Task_BagMenu(u8 taskId) data[1] = r4; data[2] = BagGetQuantityByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); - gUnknown_08614054[gUnknown_0203CE58.unk4](taskId); + gUnknown_08614054[gUnknown_0203CE58.location](taskId); } } } @@ -896,7 +1021,7 @@ void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3) { ClearWindowTilemap(0); ClearWindowTilemap(1); - sub_81AE6C8(data[0], &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]); + sub_81AE6C8(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); schedule_bg_copy_tilemap_to_vram(0); gSprites[gUnknown_0203CE54->unk806[gUnknown_0203CE54->unk81B_1 ^ 1]].invisible = 1; sub_81AB824(); @@ -1100,9 +1225,9 @@ void sub_81AC10C(u8 taskId) if (!(++data[12] & 1)) { if (data[11] == 1) - bag_menu_copy_pocket_name_to_window(data[12] >> 1); + bag_menu_copy_pocket_name_to_window((u8)(data[12] >> 1)); else - bag_menu_copy_pocket_name_to_window(8 - (data[12] >> 1)); + bag_menu_copy_pocket_name_to_window((u8)(8 - (data[12] >> 1))); } if (data[12] == 16) data[13]++; @@ -1110,7 +1235,7 @@ void sub_81AC10C(u8 taskId) case 1: ChangeBagPocketId(&gUnknown_0203CE58.pocket, data[11]); load_bag_item_list_buffers(gUnknown_0203CE58.pocket); - data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); PutWindowTilemap(1); PutWindowTilemap(2); schedule_bg_copy_tilemap_to_vram(0); @@ -1119,3 +1244,1151 @@ void sub_81AC10C(u8 taskId) SwitchTaskToFollowupFunc(taskId); } } + +void sub_81AC23C(u8 a) +{ + FillBgTilemapBufferRect_Palette0(2, 17, 14, a + 2, 15, 1); + schedule_bg_copy_tilemap_to_vram(2); +} + +void bag_menu_draw_pocket_indicator_square(u8 x, u8 is_current_bag) +{ + if (is_current_bag == 0) + FillBgTilemapBufferRect_Palette0(2, 0x1017, x + 5, 3, 1, 1); + else + FillBgTilemapBufferRect_Palette0(2, 0x102B, x + 5, 3, 1, 1); + schedule_bg_copy_tilemap_to_vram(2); +} + +bool8 sub_81AC2C0(void) +{ + if (gUnknown_0203CE58.location <= 1) + { + u8 temp = gUnknown_0203CE58.pocket - 2; + if (temp > 1) + return TRUE; + } + return FALSE; +} + +void bag_menu_swap_items(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + sub_81AF15C(data[0], 16, 1); + data[1] = gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket] + gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; + gUnknown_0203CE54->unk81A = data[1]; + CopyItemName(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, data[1]), gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where); + FillWindowPixelBuffer(1, 0); + bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); + sub_80D4FEC(data[1]); + sub_81AB89C(); + bag_menu_print_cursor_(data[0], 2); + gTasks[taskId].func = sub_81AC3C0; +} + +void sub_81AC3C0(u8 taskId) +{ + s16* data = gTasks[taskId].data; + int r7; + + if (sub_81221EC() != TRUE) + { + if (gMain.newKeys & SELECT_BUTTON) + { + PlaySE(SE_SELECT); + sub_81AE860(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); + sub_81AC498(taskId); + } + else + { + r7 = ListMenuHandleInputGetItemId(data[0]); + sub_81AE860(data[0], &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); + sub_80D4FC8(0); + sub_80D4FEC(gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]); + switch (r7) + { + case -1: + break; + case -2: + PlaySE(SE_SELECT); + if (gMain.newKeys & A_BUTTON) + sub_81AC498(taskId); + else + sub_81AC590(taskId); + break; + default: + PlaySE(SE_SELECT); + sub_81AC498(taskId); + } + } + } +} + +void sub_81AC498(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]; + u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; + u16 realPos = *scrollPos + *cursorPos; + + if (data[1] == realPos || data[1] == (realPos - 1)) + sub_81AC590(taskId); + else + { + sub_80D702C(gBagPockets[gUnknown_0203CE58.pocket].itemSlots, data[1], realPos); + gUnknown_0203CE54->unk81A = -1; + sub_81AE6C8(data[0], scrollPos, cursorPos); + if (data[1] < realPos) + gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]--; + load_bag_item_list_buffers(gUnknown_0203CE58.pocket); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); + sub_80D4FC8(1); + bag_menu_add_list_scroll_arrow_indicators_maybe(); + gTasks[taskId].func = Task_BagMenu; + } +} + +void sub_81AC590(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]; + u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; + + gUnknown_0203CE54->unk81A = -1; + sub_81AE6C8(data[0], scrollPos, cursorPos); + if (data[1] < (*scrollPos + *cursorPos)) + gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]--; + load_bag_item_list_buffers(gUnknown_0203CE58.pocket); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); + sub_80D4FC8(1); + bag_menu_add_list_scroll_arrow_indicators_maybe(); + gTasks[taskId].func = Task_BagMenu; +} + +void sub_81AC644(u8 unused) +{ + switch (gUnknown_0203CE58.location - 1) + { + case 0: + case 9: + if (ItemId_GetBattleUsage(gSpecialVar_ItemId)) + { + gUnknown_0203CE54->unk820 = gUnknown_08614042; + gUnknown_0203CE54->unk828 = 2; + } + else + { + gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk828 = 1; + } + break; + case 4: + gUnknown_0203CE54->unk820 = gUnknown_08614047; + gUnknown_0203CE54->unk828 = 4; + break; + case 8: + if (!itemid_is_unique(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY) + { + gUnknown_0203CE54->unk820 = gUnknown_0861404B; + gUnknown_0203CE54->unk828 = 2; + } + else + { + gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk828 = 1; + } + break; + case 6: + if (!itemid_is_unique(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY) + { + gUnknown_0203CE54->unk820 = gUnknown_0861404D; + gUnknown_0203CE54->unk828 = 2; + } + else + { + gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk828 = 1; + } + break; + case 7: + if (!itemid_is_unique(gSpecialVar_ItemId) && gSpecialVar_ItemId != ITEM_ENIGMA_BERRY) + { + gUnknown_0203CE54->unk820 = gUnknown_0861404F; + gUnknown_0203CE54->unk828 = 2; + } + else + { + gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk828 = 1; + } + break; + case 1: + case 2: + case 3: + case 5: + default: + if (sub_81221AC() == TRUE || InUnionRoom() == TRUE) + { + if (gUnknown_0203CE58.pocket == 4 || !sub_8122148(gSpecialVar_ItemId)) + { + gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk828 = 1; + } + else + { + gUnknown_0203CE54->unk820 = gUnknown_08614044; + gUnknown_0203CE54->unk828 = 2; + } + } + else + { + switch (gUnknown_0203CE58.pocket) + { + case 0: + gUnknown_0203CE54->unk820 = &gUnknown_0203CE54->unk824; + gUnknown_0203CE54->unk828 = 4; + memcpy(&gUnknown_0203CE54->unk824, &gUnknown_0861402C, 4); + if (ItemIsMail(gSpecialVar_ItemId) == TRUE) + gUnknown_0203CE54->unk824 = 6; + break; + case 4: + gUnknown_0203CE54->unk820 = &gUnknown_0203CE54->unk824; + gUnknown_0203CE54->unk828 = 4; + memcpy(&gUnknown_0203CE54->unk824, &gUnknown_08614030, 4); + if (gSaveBlock1Ptr->registeredItem == gSpecialVar_ItemId) + gUnknown_0203CE54->unk825 = 8; + if (gSpecialVar_ItemId == ITEM_MACH_BIKE || gSpecialVar_ItemId == ITEM_ACRO_BIKE) + { + if (TestPlayerAvatarFlags(6)) + gUnknown_0203CE54->unk824 = 7; + } + break; + case 1: + gUnknown_0203CE54->unk820 = gUnknown_08614034; + gUnknown_0203CE54->unk828 = 4; + break; + case 2: + gUnknown_0203CE54->unk820 = gUnknown_08614038; + gUnknown_0203CE54->unk828 = 4; + break; + case 3: + gUnknown_0203CE54->unk820 = gUnknown_0861403C; + gUnknown_0203CE54->unk828 = 6; + break; + } + } + } + if (gUnknown_0203CE58.pocket == 2) + { + ClearWindowTilemap(1); + PrintTMHMMoveData(gSpecialVar_ItemId); + PutWindowTilemap(3); + PutWindowTilemap(4); + schedule_bg_copy_tilemap_to_vram(0); + } + else + { + CopyItemName(gSpecialVar_ItemId, gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected); + FillWindowPixelBuffer(1, 0); + bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); + } + if (gUnknown_0203CE54->unk828 == 1) + sub_81ACAF8(bag_menu_add_window(0)); + else if (gUnknown_0203CE54->unk828 == 2) + { + sub_81ACAF8(bag_menu_add_window(1)); + } + else if (gUnknown_0203CE54->unk828 == 4) + { + sub_81ACB54(bag_menu_add_window(2), 2, 2); + } + else + sub_81ACB54(bag_menu_add_window(3), 2, 3); +} + +void sub_81ACAF8(u8 a) +{ + AddItemMenuActionTextPrinters(a, 7, 8, 1, 0, 16, gUnknown_0203CE54->unk828, gUnknown_08613FB4, gUnknown_0203CE54->unk820); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(a, gUnknown_0203CE54->unk828, 0); +} + +void sub_81ACB54(u8 a, u8 b, u8 c) +{ + sub_8198DBC(a, 7, 8, 1, 0x38, b, c, gUnknown_08613FB4, gUnknown_0203CE54->unk820); + sub_8199944(a, 0x38, b, c, 0); +} + +void unknown_item_menu_type(u8 taskId) +{ + sub_81AC644(taskId); + if (gUnknown_0203CE54->unk828 <= 2) + gTasks[taskId].func = Task_HandleInBattleItemMenuInput; + else + gTasks[taskId].func = Task_HandleOutOfBattleItemMenuInput; +} + +void Task_HandleInBattleItemMenuInput(u8 taskId) +{ + if (sub_81221EC() != TRUE) + { + s8 r4 = ProcessMenuInputNoWrapAround(); + switch (r4) + { + case -2: + break; + case -1: + PlaySE(SE_SELECT); + gUnknown_08613FB4[4].func(taskId); + break; + default: + PlaySE(SE_SELECT); + gUnknown_08613FB4[gUnknown_0203CE54->unk820[r4]].func(taskId); + break; + } + } +} + +void Task_HandleOutOfBattleItemMenuInput(u8 taskId) +{ + if (sub_81221EC() != TRUE) + { + s8 cursorPos = GetMenuCursorPos(); + if (gMain.newKeys & DPAD_UP) + { + if (cursorPos > 0 && sub_81ACDFC(cursorPos - 2)) + { + PlaySE(SE_SELECT); + sub_8199134(0, -1); + } + } + else if (gMain.newKeys & DPAD_DOWN) + { + if (cursorPos < (gUnknown_0203CE54->unk828 - 2) && sub_81ACDFC(cursorPos + 2)) + { + PlaySE(SE_SELECT); + sub_8199134(0, 1); + } + } + else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysState() == 1) + { + if ((cursorPos & 1) && sub_81ACDFC(cursorPos - 1)) + { + PlaySE(SE_SELECT); + sub_8199134(-1, 0); + } + } + else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysState() == 2) + { + if (!(cursorPos & 1) && sub_81ACDFC(cursorPos + 1)) + { + PlaySE(SE_SELECT); + sub_8199134(1, 0); + } + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + gUnknown_08613FB4[gUnknown_0203CE54->unk820[cursorPos]].func(taskId); + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + gUnknown_08613FB4[4].func(taskId); + } + } +} + +bool8 sub_81ACDFC(s8 a) +{ + if (a < 0) + return FALSE; + if (a > gUnknown_0203CE54->unk828) + return FALSE; + if (gUnknown_0203CE54->unk820[a] == 14) + return FALSE; + return TRUE; +} + +void bag_menu_remove_some_window(void) +{ + if (gUnknown_0203CE54->unk828 == 1) + bag_menu_remove_window(0); + else if (gUnknown_0203CE54->unk828 == 2) + { + bag_menu_remove_window(1); + } + else if (gUnknown_0203CE54->unk828 == 4) + { + bag_menu_remove_window(2); + } + else + bag_menu_remove_window(3); +} + +void ItemMenu_UseOutOfBattle(u8 taskId) +{ + if (ItemId_GetFieldFunc(gSpecialVar_ItemId)) + { + bag_menu_remove_some_window(); + if (CalculatePlayerPartyCount() == 0 && ItemId_GetType(gSpecialVar_ItemId) == 1) + bag_menu_print_there_is_no_pokemon(taskId); + else + { + FillWindowPixelBuffer(1, 0); + schedule_bg_copy_tilemap_to_vram(0); + if (gUnknown_0203CE58.pocket != 3) + ItemId_GetFieldFunc(gSpecialVar_ItemId)(taskId); + else + sub_80FDD10(taskId); + } + } +} + +void ItemMenu_Toss(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + bag_menu_remove_some_window(); + data[8] = 1; + if (data[2] == 1) + BagMenuConfirmToss(taskId); + else + { + CopyItemName(gSpecialVar_ItemId, gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_TossHowManyVar1s); + FillWindowPixelBuffer(1, 0); + bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); + sub_81ABC3C(7); + gTasks[taskId].func = Task_ChooseHowManyToToss; + } +} + +void BagMenuConfirmToss(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + CopyItemName(gSpecialVar_ItemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, data[8], 0, 3); + StringExpandPlaceholders(gStringVar4, gText_ConfirmTossItems); + FillWindowPixelBuffer(1, 0); + bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); + bag_menu_yes_no(taskId, 5, &gUnknown_08614084); +} + +void BagMenuCancelToss(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + bag_menu_print_description_box_text(data[1]); + bag_menu_print_cursor_(data[0], 0); + set_callback3_to_bag(taskId); +} + +void Task_ChooseHowManyToToss(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE) + sub_81ABC54(gUnknown_0203CE54->unk817, data[8]); + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + bag_menu_remove_window(7); + BagMenuConfirmToss(taskId); + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + bag_menu_remove_window(7); + BagMenuCancelToss(taskId); + } +} + +void BagMenuActuallyToss(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + CopyItemName(gSpecialVar_ItemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, data[8], 0, 3); + StringExpandPlaceholders(gStringVar4, gText_ThrewAwayVar2Var1s); + FillWindowPixelBuffer(1, 0); + bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); + gTasks[taskId].func = Task_ActuallyToss; +} + +void Task_ActuallyToss(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]; + u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; + + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PlaySE(SE_SELECT); + RemoveBagItem(gSpecialVar_ItemId, data[8]); + sub_81AE6C8(data[0], scrollPos, cursorPos); + sub_81AB9A8(gUnknown_0203CE58.pocket); + sub_81ABA88(gUnknown_0203CE58.pocket); + load_bag_item_list_buffers(gUnknown_0203CE58.pocket); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); + schedule_bg_copy_tilemap_to_vram(0); + set_callback3_to_bag(taskId); + } +} + +void ItemMenu_Register(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]; + u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; + + if (gSaveBlock1Ptr->registeredItem == gSpecialVar_ItemId) + gSaveBlock1Ptr->registeredItem = 0; + else + gSaveBlock1Ptr->registeredItem = gSpecialVar_ItemId; + sub_81AE6C8(data[0], scrollPos, cursorPos); + load_bag_item_list_buffers(gUnknown_0203CE58.pocket); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); + schedule_bg_copy_tilemap_to_vram(0); + ItemMenu_Cancel(taskId); +} + +void ItemMenu_Give(u8 taskId) +{ + bag_menu_remove_some_window(); + if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId)) + DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350); + else if (!itemid_is_unique(gSpecialVar_ItemId)) + { + if (CalculatePlayerPartyCount() == 0) + bag_menu_print_there_is_no_pokemon(taskId); + else + { + gUnknown_0203CE54->unk0 = sub_81B7F60; + unknown_ItemMenu_Confirm(taskId); + } + } + else + bag_menu_print_cant_be_held_msg(taskId); +} + +void bag_menu_print_there_is_no_pokemon(u8 taskId) +{ + DisplayItemMessage(taskId, 1, gText_NoPokemon, sub_81AD350); +} + +void bag_menu_print_cant_be_held_msg(u8 taskId) +{ + CopyItemName(gSpecialVar_ItemId, gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeld); + DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD350); +} + +void sub_81AD350(u8 taskId) +{ + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + bag_menu_inits_lists_menu(taskId); + } +} + +void ItemMenu_CheckTag(u8 taskId) +{ + gUnknown_0203CE54->unk0 = sub_8177C14; + unknown_ItemMenu_Confirm(taskId); +} + +void ItemMenu_Cancel(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + bag_menu_remove_some_window(); + bag_menu_print_description_box_text(data[1]); + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); + bag_menu_print_cursor_(data[0], 0); + set_callback3_to_bag(taskId); +} + +void ItemMenu_UseInBattle(u8 taskId) +{ + if (ItemId_GetBattleFunc(gSpecialVar_ItemId)) + { + bag_menu_remove_some_window(); + ItemId_GetBattleFunc(gSpecialVar_ItemId)(taskId); + } +} + +void bag_menu_mail_related(void) +{ + GoToBagMenu(12, 5, NULL); +} + +void item_menu_type_2(u8 taskId) +{ + if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId)) + DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350); + else if (!sub_8122148(gSpecialVar_ItemId)) + { + CopyItemName(gSpecialVar_ItemId, gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeldHere); + DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD350); + } + else if (gUnknown_0203CE58.pocket != 4 && !itemid_is_unique(gSpecialVar_ItemId)) + { + unknown_ItemMenu_Confirm(taskId); + } + else + bag_menu_print_cant_be_held_msg(taskId); +} + +void item_menu_type_b(u8 taskId) +{ + if (ItemIsMail(gSpecialVar_ItemId) == TRUE) + DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350); + else if (gUnknown_0203CE58.pocket != 4 && !itemid_is_unique(gSpecialVar_ItemId)) + { + gTasks[taskId].func = unknown_ItemMenu_Confirm; + } + else + bag_menu_print_cant_be_held_msg(taskId); +} + +bool8 UseRegisteredKeyItemOnField(void) +{ + u8 taskId; + + if (InUnionRoom() == TRUE || InBattlePyramid() || InBattlePike() || InMultiBattleRoom() == TRUE) + return FALSE; + else + { + HideMapNamePopUpWindow(); + ChangeBgY_ScreenOff(0, 0, 0); + if (gSaveBlock1Ptr->registeredItem != ITEM_NONE) + { + if (CheckBagHasItem(gSaveBlock1Ptr->registeredItem, 1) == TRUE) + { + ScriptContext2_Enable(); + FreezeMapObjects(); + sub_808B864(); + sub_808BCF4(); + gSpecialVar_ItemId = gSaveBlock1Ptr->registeredItem; + taskId = CreateTask(ItemId_GetFieldFunc(gSaveBlock1Ptr->registeredItem), 8); + gTasks[taskId].data[3] = 1; + return TRUE; + } + else + gSaveBlock1Ptr->registeredItem = ITEM_NONE; + } + ScriptContext1_SetupScript(EventScript_2736B3); + } + return TRUE; +} + +void display_sell_item_ask_str(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + if (itemid_get_market_price(gSpecialVar_ItemId) == 0) + { + CopyItemName(gSpecialVar_ItemId, gStringVar2); + StringExpandPlaceholders(gStringVar4, gText_CantBuyKeyItem); + DisplayItemMessage(taskId, 1, gStringVar4, bag_menu_inits_lists_menu); + } + else + { + data[8] = 1; + if (data[2] == 1) + { + bag_menu_AddMoney_window(); + sub_81AD680(taskId); + } + else + { + CopyItemName(gSpecialVar_ItemId, gStringVar2); + StringExpandPlaceholders(gStringVar4, gText_HowManyToSell); + DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD730); + } + } +} + +void sub_81AD680(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + ConvertIntToDecimalStringN(gStringVar1, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8], 0, 6); + StringExpandPlaceholders(gStringVar4, gText_ICanPayVar1); + DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD6E4); +} + +void sub_81AD6E4(u8 taskId) +{ + bag_menu_yes_no(taskId, 6, &gUnknown_0861408C); +} + +void sub_81AD6FC(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + bag_menu_remove_money_window(); + bag_menu_RemoveBagItem_message_window(4); + bag_menu_print_cursor_(data[0], 0); + set_callback3_to_bag(taskId); +} + +void sub_81AD730(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u8 windowId = bag_menu_add_window(8); + + sub_81ABCC0(windowId, 1, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8]); + bag_menu_AddMoney_window(); + gTasks[taskId].func = sub_81AD794; +} + +void sub_81AD794(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE) + sub_81ABCC0(gUnknown_0203CE54->unk818, data[8], (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8]); + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + bag_menu_remove_window(8); + sub_81AD680(taskId); + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + bag_menu_print_cursor_(data[0], 0); + bag_menu_remove_money_window(); + bag_menu_remove_window(8); + bag_menu_RemoveBagItem_message_window(4); + set_callback3_to_bag(taskId); + } +} + +void sub_81AD84C(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + CopyItemName(gSpecialVar_ItemId, gStringVar2); + ConvertIntToDecimalStringN(gStringVar1, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8], 0, 6); + StringExpandPlaceholders(gStringVar4, gText_TurnedOverVar1ForVar2); + DisplayItemMessage(taskId, 1, gStringVar4, sub_81AD8C8); +} + +void sub_81AD8C8(u8 taskId) +{ + s16* data = gTasks[taskId].data; + u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]; + u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; + + PlaySE(SE_REGI); + RemoveBagItem(gSpecialVar_ItemId, data[8]); + AddMoney(&gSaveBlock1Ptr->money, (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8]); + sub_81AE6C8(data[0], scrollPos, cursorPos); + sub_81AB9A8(gUnknown_0203CE58.pocket); + sub_81ABA88(gUnknown_0203CE58.pocket); + load_bag_item_list_buffers(gUnknown_0203CE58.pocket); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollPos, *cursorPos); + bag_menu_print_cursor_(data[0], 2); + PrintMoneyAmountInMoneyBox(gUnknown_0203CE54->unk819, GetMoney(&gSaveBlock1Ptr->money), 0); + gTasks[taskId].func = sub_81AD9C0; +} + +void sub_81AD9C0(u8 taskId) +{ + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PlaySE(SE_SELECT); + bag_menu_remove_money_window(); + bag_menu_inits_lists_menu(taskId); + } +} + +void display_deposit_item_ask_str(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + data[8] = 1; + if (data[2] == 1) + sub_81ADB14(taskId); + else + { + CopyItemName(gSpecialVar_ItemId, gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_DepositHowManyVar1); + FillWindowPixelBuffer(1, 0); + bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); + sub_81ABC3C(7); + gTasks[taskId].func = sub_81ADA7C; + } +} + +void sub_81ADA7C(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE) + sub_81ABC54(gUnknown_0203CE54->unk817, data[8]); + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + bag_menu_remove_window(7); + sub_81ADB14(taskId); + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + bag_menu_print_description_box_text(data[1]); + bag_menu_print_cursor_(data[0], 0); + bag_menu_remove_window(7); + set_callback3_to_bag(taskId); + } +} + +void sub_81ADB14(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + FillWindowPixelBuffer(1, 0); + if (itemid_is_unique(gSpecialVar_ItemId)) + { + bag_menu_print(1, 1, gText_CantStoreImportantItems, 3, 1, 0, 0, 0, 0); + gTasks[taskId].func = sub_81ADC0C; + } + else if (AddPCItem(gSpecialVar_ItemId, data[8]) == TRUE) + { + CopyItemName(gSpecialVar_ItemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, data[8], 0, 3); + StringExpandPlaceholders(gStringVar4, gText_DepositedVar2Var1s); + bag_menu_print(1, 1, gStringVar4, 3, 1, 0, 0, 0, 0); + gTasks[taskId].func = Task_ActuallyToss; + } + else + { + bag_menu_print(1, 1, gText_NoRoomForItems, 3, 1, 0, 0, 0, 0); + gTasks[taskId].func = sub_81ADC0C; + } +} + +void sub_81ADC0C(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PlaySE(SE_SELECT); + bag_menu_print_description_box_text(data[1]); + bag_menu_print_cursor_(data[0], 0); + set_callback3_to_bag(taskId); + } +} + +bool8 IsWallysBag(void) +{ + if (gUnknown_0203CE58.location == 10) + return TRUE; + return FALSE; +} + +void PrepareBagForWallyTutorial(void) +{ + u32 i; + + gUnknown_0203CE80 = AllocZeroed(sizeof(struct unkWallyStruct)); + memcpy(gUnknown_0203CE80->bagPocket_Items, gSaveBlock1Ptr->bagPocket_Items, sizeof(gSaveBlock1Ptr->bagPocket_Items)); + memcpy(gUnknown_0203CE80->bagPocket_PokeBalls, gSaveBlock1Ptr->bagPocket_PokeBalls, sizeof(gSaveBlock1Ptr->bagPocket_PokeBalls)); + gUnknown_0203CE80->pocket = gUnknown_0203CE58.pocket; + for (i = 0; i <= 4; i++) + { + gUnknown_0203CE80->cursorPosition[i] = gUnknown_0203CE58.cursorPosition[i]; + gUnknown_0203CE80->scrollPosition[i] = gUnknown_0203CE58.scrollPosition[i]; + } + ClearItemSlots(gSaveBlock1Ptr->bagPocket_Items, 30); + ClearItemSlots(gSaveBlock1Ptr->bagPocket_PokeBalls, 16); + ResetBagScrollPositions(); +} + +void RestoreBagAfterWallyTutorial(void) +{ + u32 i; + + memcpy(gSaveBlock1Ptr->bagPocket_Items, gUnknown_0203CE80->bagPocket_Items, sizeof(gUnknown_0203CE80->bagPocket_Items)); + memcpy(gSaveBlock1Ptr->bagPocket_PokeBalls, gUnknown_0203CE80->bagPocket_PokeBalls, sizeof(gUnknown_0203CE80->bagPocket_PokeBalls)); + gUnknown_0203CE58.pocket = gUnknown_0203CE80->pocket; + for (i = 0; i <= 4; i++) + { + gUnknown_0203CE58.cursorPosition[i] = gUnknown_0203CE80->cursorPosition[i]; + gUnknown_0203CE58.scrollPosition[i] = gUnknown_0203CE80->scrollPosition[i]; + } + Free(gUnknown_0203CE80); +} + +void DoWallyTutorialBagMenu(void) +{ + PrepareBagForWallyTutorial(); + AddBagItem(ITEM_POTION, 1); + AddBagItem(ITEM_POKE_BALL, 1); + GoToBagMenu(10, 0, SetCB2ToReshowScreenAfterMenu2); +} + +void Task_WallyTutorialBagMenu(u8 taskId) +{ + s16* data = gTasks[taskId].data; + + if (!gPaletteFade.active) + { + switch (data[8]) + { + case 0x66: + PlaySE(SE_SELECT); + SwitchBagPocket(taskId, 1, 0); + data[8]++; + break; + case 0xCC: + PlaySE(SE_SELECT); + bag_menu_print_cursor_(data[0], 2); + gSpecialVar_ItemId = ITEM_POKE_BALL; + sub_81AC644(taskId); + data[8]++; + break; + case 0x132: + PlaySE(SE_SELECT); + bag_menu_remove_some_window(); + sub_81AE6C8(data[0], 0, 0); + RestoreBagAfterWallyTutorial(); + unknown_ItemMenu_Confirm(taskId); + break; + default: + data[8]++; + break; + } + } +} + +void unknown_ItemMenu_Show(u8 taskId) +{ + gSpecialVar_0x8005 = gSpecialVar_ItemId; + gSpecialVar_Result = 1; + bag_menu_remove_some_window(); + unknown_ItemMenu_Confirm(taskId); +} + +void bag_menu_leave_maybe_3(void) +{ + gFieldCallback = sub_819FA50; + SetMainCallback2(c2_exit_to_overworld_2_switch); +} + +void unknown_ItemMenu_Give2(u8 taskId) +{ + RemoveBagItem(gSpecialVar_ItemId, 1); + gSpecialVar_Result = 1; + bag_menu_remove_some_window(); + unknown_ItemMenu_Confirm(taskId); +} + +void bag_menu_leave_maybe_2(void) +{ + gFieldCallback = sub_818DEF4; + SetMainCallback2(c2_exit_to_overworld_2_switch); +} + +void unknown_ItemMenu_Confirm2(u8 taskId) +{ + gSpecialVar_Result = 1; + bag_menu_remove_some_window(); + unknown_ItemMenu_Confirm(taskId); +} + +void bag_menu_leave_maybe(void) +{ + gFieldCallback = sub_818E564; + SetMainCallback2(c2_exit_to_overworld_2_switch); +} + +void bag_menu_print_pocket_names(u8 *pocketName1, u8 *pocketName2) +{ + struct WindowTemplate window = {0, 0, 0, 0, 0, 0, 0}; + u16 windowId; + int offset; + + window.width = 16; + window.height = 2; + windowId = AddWindow(&window); + FillWindowPixelBuffer(windowId, 0); + offset = GetStringCenterAlignXOffset(1, pocketName1, 0x40); + bag_menu_print(windowId, 1, pocketName1, offset, 1, 0, 0, -1, 1); + if (pocketName2) + { + offset = GetStringCenterAlignXOffset(1, pocketName2, 0x40); + bag_menu_print(windowId, 1, pocketName2, offset + 0x40, 1, 0, 0, -1, 1); + } + CpuCopy32((u8*)GetWindowAttribute(windowId, 7), gUnknown_0203CE54->unk844, 0x400); + RemoveWindow(windowId); +} + +// probably a fakematching + +void bag_menu_copy_pocket_name_to_window(u32 a) +{ + u8 (* r4)[32][32]; + u8* windowAttribute; + int b; + if (a > 8) + a = 8; + r4 = &gUnknown_0203CE54->unk844; + windowAttribute = (u8*)GetWindowAttribute(2, 7); + CpuCopy32(r4[0][a], windowAttribute, 0x100); + b = a + 16; + CpuCopy32(r4[0][b], windowAttribute + 0x100, 0x100); + CopyWindowToVram(2, 2); +} + +void setup_bag_menu_textboxes(void) +{ + u8 i; + + InitWindows(gUnknown_08614174); + DeactivateAllTextPrinters(); + sub_809882C(0, 1, -32); + copy_textbox_border_tile_patterns_to_vram(0, 10, -48); + sub_819A2BC(-64, 1); + LoadPalette(&gUnknown_0860F074, 0xF0, 0x20); + for (i = 0;i < 3; i++) + { + FillWindowPixelBuffer(i, 0); + PutWindowTilemap(i); + } + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); +} + +void bag_menu_print(u8 a, u8 b, u8 *str, u8 c, u8 d, u8 e, u8 f, u8 g, u8 h) +{ + AddTextPrinterParameterized2(a, b, c, d, e, f, &gUnknown_08614164[h], g, str); +} + +u8 sub_81AE124(u8 a) +{ + return gUnknown_0203CE54->unk810[a]; +} + +u8 bag_menu_add_window(u8 a) +{ + u8 *ptr = &gUnknown_0203CE54->unk810[a]; + if (*ptr == 0xFF) + { + *ptr = AddWindow(&gUnknown_086141AC[a]); + SetWindowBorderStyle(*ptr, 0, 1, 14); + schedule_bg_copy_tilemap_to_vram(1); + } + return *ptr; +} + +void bag_menu_remove_window(u8 a) +{ + u8 *ptr = &gUnknown_0203CE54->unk810[a]; + if (*ptr != 0xFF) + { + sub_8198070(*ptr, 0); + ClearWindowTilemap(*ptr); + RemoveWindow(*ptr); + schedule_bg_copy_tilemap_to_vram(1); + *ptr = 0xFF; + } +} + +u8 AddItemMessageWindow(u8 a) +{ + u8 *ptr = &gUnknown_0203CE54->unk810[a]; + if (*ptr == 0xFF) + *ptr = AddWindow(&gUnknown_086141AC[a]); + return *ptr; +} + +void bag_menu_RemoveBagItem_message_window(u8 a) +{ + u8 *ptr = &gUnknown_0203CE54->unk810[a]; + if (*ptr != 0xFF) + { + sub_8197DF8(*ptr, 0); + ClearWindowTilemap(*ptr); + RemoveWindow(*ptr); + schedule_bg_copy_tilemap_to_vram(1); + *ptr = 0xFF; + } +} + +void bag_menu_yes_no(u8 a, u8 b, struct YesNoFuncTable *funcTable) +{ + CreateYesNoMenuWithCallbacks(a, &gUnknown_086141AC[b], 1, 0, 2, 1, 14, funcTable); +} + +void bag_menu_AddMoney_window(void) +{ + u8 windowId = bag_menu_add_window(9); + PrintMoneyAmountInMoneyBoxWithBorder(windowId, 1, 14, GetMoney(&gSaveBlock1Ptr->money)); + AddMoneyLabelObject(19, 11); +} + +void bag_menu_remove_money_window(void) +{ + bag_menu_remove_window(9); + RemoveMoneyLabelObject(); +} + +void bag_menu_prepare_tmhm_move_window(void) +{ + FillWindowPixelBuffer(3, 0); + blit_move_info_icon(3, 19, 0, 0); + blit_move_info_icon(3, 20, 0, 12); + blit_move_info_icon(3, 21, 0, 24); + blit_move_info_icon(3, 22, 0, 36); + CopyWindowToVram(3, 2); +} + +void PrintTMHMMoveData(u16 itemId) +{ + u8 i; + u16 moveId; + u8* text; + + FillWindowPixelBuffer(4, 0); + if (itemId == ITEM_NONE) + { + for (i = 0;i < 4; i++) + bag_menu_print(4, 1, gText_ThreeDashes, 7, i * 12, 0, 0, -1, 4); + CopyWindowToVram(4, 2); + } + else + { + moveId = ItemIdToBattleMoveId(itemId); + blit_move_info_icon(4, gBattleMoves[moveId].type + 1, 0, 0); + if (gBattleMoves[moveId].power <= 1) + text = gText_ThreeDashes; + else + { + ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].power, 1, 3); + text = gStringVar1; + } + bag_menu_print(4, 1, text, 7, 12, 0, 0, -1, 4); + if (gBattleMoves[moveId].accuracy == 0) + text = gText_ThreeDashes; + else + { + ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].accuracy, 1, 3); + text = gStringVar1; + } + bag_menu_print(4, 1, text, 7, 24, 0, 0, -1, 4); + ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].pp, 1, 3); + bag_menu_print(4, 1, gStringVar1, 7, 36, 0, 0, -1, 4); + CopyWindowToVram(4, 2); + } +} From 76e6be7ff251f321665860037b794ae42c8e798f Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Wed, 7 Feb 2018 14:22:49 -0500 Subject: [PATCH 09/12] update function name and struct names --- src/item_menu.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/item_menu.c b/src/item_menu.c index 55d3f088c..76e760d13 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -34,7 +34,7 @@ #include "menu_helpers.h" #include "window.h" -struct bagStruct { +struct BagStruct { void (*bagCallback)(void); u8 location; u8 pocket; @@ -44,7 +44,7 @@ struct bagStruct { u8 **pocketStringsPtr; }; -struct unkBagStruct { +struct UnkBagStruct { MainCallback unk0; u8 unk4[0x800]; u8 unk804; @@ -75,15 +75,15 @@ struct unkBagStruct { u8 filler2[4]; }; -struct listBuffer1 { +struct ListBuffer1 { struct ListMenuItem subBuffers[65]; }; -struct listBuffer2 { +struct ListBuffer2 { s8 name[65][24]; }; -struct unkWallyStruct { +struct TempWallyStruct { struct ItemSlot bagPocket_Items[30]; struct ItemSlot bagPocket_PokeBalls[16]; u16 cursorPosition[5]; @@ -92,16 +92,16 @@ struct unkWallyStruct { u16 pocket; }; -struct unkStructTextFunc{ +struct UnkStructTextFunc{ u8* text; TaskFunc func; }; -extern struct bagStruct gUnknown_0203CE58; -extern struct unkBagStruct *gUnknown_0203CE54; -extern struct listBuffer1 *gUnknown_0203CE74; -extern struct listBuffer2 *gUnknown_0203CE78; -extern struct unkWallyStruct *gUnknown_0203CE80; +extern struct BagStruct gUnknown_0203CE58; +extern struct UnkBagStruct *gUnknown_0203CE54; +extern struct ListBuffer1 *gUnknown_0203CE74; +extern struct ListBuffer2 *gUnknown_0203CE78; +extern struct TempWallyStruct *gUnknown_0203CE80; extern u16 gUnknown_0203CE6A[]; extern u16 gUnknown_0203CE60[]; extern void sub_8086194(void); @@ -133,15 +133,15 @@ extern void sub_80D4FEC(u8); extern void sub_80D4FC8(u8); extern void sub_80D702C(struct ItemSlot*, s16, u16); extern bool8 sub_8122148(u16); -extern void AddItemMenuActionTextPrinters (u8, u8, u8, u8, u8, u8, u8, struct unkStructTextFunc*, u8*); -extern void sub_8198DBC(u8, u8, u8, u8, u8, u8, u8, struct unkStructTextFunc*, u8*); +extern void AddItemMenuActionTextPrinters (u8, u8, u8, u8, u8, u8, u8, struct UnkStructTextFunc*, u8*); +extern void sub_8198DBC(u8, u8, u8, u8, u8, u8, u8, struct UnkStructTextFunc*, u8*); extern void sub_8199944(u8, u8, u8, u8, u8); extern void sub_8199134(s8, s8); extern void sub_80FDD10(u8); extern bool8 AdjustQuantityAccordingToDPadInput(s16*, u16); extern void sub_81B7F60(void); extern bool8 itemid_80BF6D8_mail_related(u16); -extern void sub_8177C14(void); +extern void DoBerryTagScreen(void); extern void sub_808B864(void); extern void sub_808BCF4(void); extern void FreezeMapObjects(void); @@ -264,7 +264,7 @@ extern u8 gUnknown_0861404B[]; extern u8 gUnknown_0861404D[]; extern u8 gUnknown_0861404F[]; extern u8 gText_Var1IsSelected[]; -extern struct unkStructTextFunc gUnknown_08613FB4[]; +extern struct UnkStructTextFunc gUnknown_08613FB4[]; extern u8 gText_TossHowManyVar1s[]; extern u8 gText_ConfirmTossItems[]; extern struct YesNoFuncTable gUnknown_08614084; @@ -352,7 +352,7 @@ void sub_81AAC70(void) void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()) { u8 temp; - gUnknown_0203CE54 = AllocZeroed(sizeof(struct unkBagStruct)); + gUnknown_0203CE54 = AllocZeroed(sizeof(struct UnkBagStruct)); if (gUnknown_0203CE54 == 0) SetMainCallback2(postExitMenuMainCallback2); else @@ -579,8 +579,8 @@ u8 sub_81AB1F0(u8 a) void allocate_bag_item_list_buffers(void) { - gUnknown_0203CE74 = Alloc(sizeof(struct listBuffer1)); - gUnknown_0203CE78 = Alloc(sizeof(struct listBuffer2)); + gUnknown_0203CE74 = Alloc(sizeof(struct ListBuffer1)); + gUnknown_0203CE78 = Alloc(sizeof(struct ListBuffer2)); } void load_bag_item_list_buffers(u8 pocketId) @@ -1798,7 +1798,7 @@ void sub_81AD350(u8 taskId) void ItemMenu_CheckTag(u8 taskId) { - gUnknown_0203CE54->unk0 = sub_8177C14; + gUnknown_0203CE54->unk0 = DoBerryTagScreen; unknown_ItemMenu_Confirm(taskId); } @@ -2101,7 +2101,7 @@ void PrepareBagForWallyTutorial(void) { u32 i; - gUnknown_0203CE80 = AllocZeroed(sizeof(struct unkWallyStruct)); + gUnknown_0203CE80 = AllocZeroed(sizeof(struct TempWallyStruct)); memcpy(gUnknown_0203CE80->bagPocket_Items, gSaveBlock1Ptr->bagPocket_Items, sizeof(gSaveBlock1Ptr->bagPocket_Items)); memcpy(gUnknown_0203CE80->bagPocket_PokeBalls, gSaveBlock1Ptr->bagPocket_PokeBalls, sizeof(gSaveBlock1Ptr->bagPocket_PokeBalls)); gUnknown_0203CE80->pocket = gUnknown_0203CE58.pocket; From 56e1a52823e111ba360031338249a08162150a08 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Thu, 8 Feb 2018 21:00:28 -0500 Subject: [PATCH 10/12] Fixes --- common_syms/item_menu.txt | 1 + include/battle_frontier_2.h | 1 + include/field_map_obj_helpers.h | 1 + include/field_player_avatar.h | 2 + include/field_specials.h | 1 + include/graphics.h | 6 + include/item.h | 3 + include/item_menu_icons.h | 4 + include/item_use.h | 1 + include/list_menu.h | 1 + include/menu.h | 5 + include/menu_helpers.h | 5 + include/menu_indicators.h | 2 + include/overworld.h | 2 + include/party_menu.h | 1 + include/player_pc.h | 1 + include/pokemon_summary_screen.h | 6 + include/shop.h | 1 + include/strings.h | 26 ++++ include/text.h | 1 + src/item_menu.c | 216 ++++++++++++------------------- sym_common.txt | 3 +- sym_ewram.txt | 34 +---- 23 files changed, 162 insertions(+), 162 deletions(-) create mode 100755 common_syms/item_menu.txt create mode 100755 include/pokemon_summary_screen.h diff --git a/common_syms/item_menu.txt b/common_syms/item_menu.txt new file mode 100755 index 000000000..112b591aa --- /dev/null +++ b/common_syms/item_menu.txt @@ -0,0 +1 @@ +gFieldCallback diff --git a/include/battle_frontier_2.h b/include/battle_frontier_2.h index 801c3f3ec..638ff692e 100644 --- a/include/battle_frontier_2.h +++ b/include/battle_frontier_2.h @@ -6,5 +6,6 @@ void sub_81A895C(void); u16 sub_81A89A0(u8); void sub_81A8AF8(void); bool8 InBattlePike(void); +void sub_819FA50(void); #endif // GUARD_BATTLE_FRONTIER_2_H diff --git a/include/field_map_obj_helpers.h b/include/field_map_obj_helpers.h index 031c7a8ab..ae96b67d8 100644 --- a/include/field_map_obj_helpers.h +++ b/include/field_map_obj_helpers.h @@ -27,5 +27,6 @@ void sub_8098044(u8); void UnfreezeMapObjects(void); void FreezeMapObjectsExceptOne(u8 mapObjectId); void sub_8097B78(u8, u8); +void FreezeMapObjects(void); #endif //GUARD_FIELD_MAP_OBJ_HELPERS_H diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index af602245b..5b9a632fa 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -31,6 +31,8 @@ u8 CheckForFieldObjectCollision(struct MapObject *a, s16 b, s16 c, u8 d, u8 e); u8 PlayerGetZCoord(void); void SetPlayerAvatarTransitionFlags(u16 a); void sub_808BCE8(void); +void sub_808B864(void); +void sub_808BCF4(void); void sub_808D074(u8); void GetXYCoordsOneStepInFrontOfPlayer(s16 *xPtr, s16 *yPtr); diff --git a/include/field_specials.h b/include/field_specials.h index dd72bdd13..c1f70a399 100644 --- a/include/field_specials.h +++ b/include/field_specials.h @@ -4,5 +4,6 @@ u8 GetLeadMonIndex(void); u8 sub_813B260(void); u16 get_unknown_box_id(void); +bool8 InMultiBattleRoom(void); #endif // GUARD_FIELD_SPECIALS_H diff --git a/include/graphics.h b/include/graphics.h index 39662c8c1..8ed54bcfb 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2719,4 +2719,10 @@ extern const u16 gFireRedMenuElements2_Pal[16]; extern const u16 gFireRedMenuElements3_Pal[16]; extern const u8 gFireRedMenuElements_Gfx[]; +//item menu graphics +extern const u8 gBagScreen_Gfx[]; +extern u16 gBagScreenFemale_Pal[]; +extern u16 gBagScreenMale_Pal[]; +extern u8 gBagMenuHMIcon_Gfx[]; + #endif //GUARD_GRAPHICS_H diff --git a/include/item.h b/include/item.h index 06eb08046..d81a3de33 100644 --- a/include/item.h +++ b/include/item.h @@ -61,5 +61,8 @@ ItemUseFunc ItemId_GetBattleFunc(u16 itemId); u8 ItemId_GetSecondaryId(u16 itemId); u16 itemid_get_market_price(u16 itemId); u16 BagGetItemIdByPocketPosition(u8 pocketId, u16 pocketPos); +void sub_80D6FB4(struct BagPocket*); +void sub_80D6F64(struct BagPocket*); +void sub_80D702C(struct ItemSlot*, s16, u16); #endif // ITEM_H diff --git a/include/item_menu_icons.h b/include/item_menu_icons.h index c3932390c..56e012421 100644 --- a/include/item_menu_icons.h +++ b/include/item_menu_icons.h @@ -8,5 +8,9 @@ u8 sub_80D511C(u8 a0, u8 a1, u8 a2, u8 a3); u8 CreateBerryTagSprite(u8 id, s16 x, s16 y); void FreeBerryTagSpritePalette(void); u8 CreateBerryFlavorCircleSprite(s16 x); +void sub_80D4FAC(void); +void RemoveBagItemIconObject(u8); +void sub_80D4FEC(u8); +void sub_80D4FC8(u8); #endif // GUARD_ITEM_MENU_ICONS diff --git a/include/item_use.h b/include/item_use.h index ee7939824..6f84a63df 100644 --- a/include/item_use.h +++ b/include/item_use.h @@ -50,5 +50,6 @@ void ItemUseOutOfBattle_EnigmaBerry(u8); void ItemUseInBattle_EnigmaBerry(u8); void ItemUseOutOfBattle_CannotUse(u8); u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId); +void sub_80FDD10(u8); #endif // GUARD_ITEM_USE_H diff --git a/include/list_menu.h b/include/list_menu.h index 8b793c0e4..77d00bf97 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -57,5 +57,6 @@ u8 ListMenuInit(struct ListMenuTemplate *template, u16 cursorPage, u16 cursorPos s32 ListMenuHandleInputGetItemId(u8 listTaskId); void sub_81AE860(u8 listTaskId, u16 *a1, u16 *a2); void sub_81AE6C8(u8 listTaskId, u16 *a1, u16 *a2); +u8 ListMenuGetYCoordForPrintingArrowCursor(u8); #endif //GUARD_LIST_MENU_H diff --git a/include/menu.h b/include/menu.h index 2046f7d2b..f6efdbf03 100644 --- a/include/menu.h +++ b/include/menu.h @@ -59,5 +59,10 @@ u16 sub_8198AA4(u8, u8, u8, u8, u8, u8, u16); void *malloc_and_decompress(const void *src, int *sizeOut); u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress); +void AddItemMenuActionTextPrinters (u8, u8, u8, u8, u8, u8, u8, const struct MenuAction*, const u8*); +void sub_8198DBC(u8, u8, u8, u8, u8, u8, u8, const struct MenuAction*, const u8*); +u8 sub_8199944(u8, u8, u8, u8, u8); +u8 sub_8199134(s8, s8); +void sub_819A2BC(u8, u8); #endif // GUARD_MENU_H diff --git a/include/menu_helpers.h b/include/menu_helpers.h index 048a4aa43..e744c293c 100644 --- a/include/menu_helpers.h +++ b/include/menu_helpers.h @@ -32,5 +32,10 @@ void DisplayMessageAndContinueTask(u8 taskId, u8 arg1, u16 arg2, u8 arg3, u8 arg void CreateYesNoMenuWithCallbacks(u8 taskId, const struct WindowTemplate *template, u8 arg2, u8 arg3, u8 arg4, u16 tileStart, u8 palette, const struct YesNoFuncTable *yesNo); u8 GetLRKeysState(void); u8 sub_812210C(void); +bool8 sub_81221EC(void); +bool8 sub_81221AC(void); +bool8 sub_8122148(u16); +bool8 AdjustQuantityAccordingToDPadInput(s16*, u16); +bool8 itemid_80BF6D8_mail_related(u16); #endif //GUARD_MENU_HELPERS_H diff --git a/include/menu_indicators.h b/include/menu_indicators.h index d0baac810..794ecf777 100644 --- a/include/menu_indicators.h +++ b/include/menu_indicators.h @@ -8,5 +8,7 @@ // Exported ROM declarations u8 AddScrollIndicatorArrowPairParametrized(u8, u8, u8, u8, s32, u16, u16, u16 *); void RemoveScrollIndicatorArrowPair(u8); +u8 AddScrollIndicatorArrowPair(void*, void*); +void sub_81AF15C(u8, u8, u8); #endif //GUARD_MENU_INDICATORS_H diff --git a/include/overworld.h b/include/overworld.h index 974f8f091..8c507b321 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -72,6 +72,8 @@ void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused); void mapldr_default(void); u8 get_map_light_from_warp0(void); bool8 is_light_level_1_2_3_5_or_6(u8 a1); +void sub_8086194(void); +void sub_80861B0(void); void IncrementGameStat(u8); u32 GetGameStat(u8); diff --git a/include/party_menu.h b/include/party_menu.h index 1d1661cee..14aacce88 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -18,5 +18,6 @@ u8 pokemon_ailments_get_primary(u32 status); u8 *GetMonNickname(struct Pokemon *mon, u8 *dst); u8 GetCursorSelectionMonId(void); bool8 FieldCallback_Teleport(void); +void sub_81B7F60(void); #endif // GUARD_PARTY_MENU_H diff --git a/include/player_pc.h b/include/player_pc.h index b14d1ede3..cc2e85b2b 100644 --- a/include/player_pc.h +++ b/include/player_pc.h @@ -8,5 +8,6 @@ // Exported ROM declarations void sub_816B060(u8 taskId); +void sub_816B31C(void); #endif //GUARD_PLAYER_PC_H diff --git a/include/pokemon_summary_screen.h b/include/pokemon_summary_screen.h new file mode 100755 index 000000000..a4e46dd6e --- /dev/null +++ b/include/pokemon_summary_screen.h @@ -0,0 +1,6 @@ +#ifndef GUARD_POKEMON_SUMMARY_SCREEN_H +#define GUARD_POKEMON_SUMMARY_SCREEN_H + +void sub_81C4F98(u8, void(*)(void)); + +#endif // GUARD_POKEMON_SUMMARY_SCREEN_H \ No newline at end of file diff --git a/include/shop.h b/include/shop.h index d3e86408c..9b14a672e 100644 --- a/include/shop.h +++ b/include/shop.h @@ -6,5 +6,6 @@ extern EWRAM_DATA struct ItemSlot gUnknown_02039F80[3]; void CreatePokemartMenu(const u16 *); void CreateDecorationShop1Menu(const u16 *); void CreateDecorationShop2Menu(const u16 *); +void CB2_ExitSellMenu(void); #endif // GUARD_SHOP_H diff --git a/include/strings.h b/include/strings.h index 6d569e57a..4e96dc528 100644 --- a/include/strings.h +++ b/include/strings.h @@ -239,4 +239,30 @@ extern const u8 gText_Var1DotVar2[]; extern const u8 gText_ThreeMarks[]; extern const u8 gText_FirmSlash[]; +//item menu screen text +extern u8 gText_CloseBag[]; +extern u8 gText_ClearTo11Var1Clear5Var2[]; +extern u8 gText_UnkF908Var1Clear7Var2[]; +extern u8 gText_xVar1[]; +extern u8 gText_ReturnToVar1[]; +extern u8 gText_SelectorArrow2[]; +extern u8 gText_MoveVar1Where[]; +extern u8 gText_Var1IsSelected[]; +extern u8 gText_TossHowManyVar1s[]; +extern u8 gText_ConfirmTossItems[]; +extern u8 gText_ThrewAwayVar2Var1s[]; +extern u8 gText_CantWriteMail[]; +extern u8 gText_NoPokemon[]; +extern u8 gText_Var1CantBeHeld[]; +extern u8 gText_Var1CantBeHeldHere[]; +extern u8 gText_CantBuyKeyItem[]; +extern u8 gText_HowManyToSell[]; +extern u8 gText_ICanPayVar1[]; +extern u8 gText_TurnedOverVar1ForVar2[]; +extern u8 gText_DepositHowManyVar1[]; +extern u8 gText_CantStoreImportantItems[]; +extern u8 gText_DepositedVar2Var1s[]; +extern u8 gText_NoRoomForItems[]; +extern u8 gText_ThreeDashes[]; + #endif //GUARD_STRINGS_H diff --git a/include/text.h b/include/text.h index e073c3762..81c066426 100644 --- a/include/text.h +++ b/include/text.h @@ -208,6 +208,7 @@ void DecompressGlyphTile(const u16 *src, u16 *dest); u8 GetLastTextColor(u8 colorType); void CopyGlyphToWindow(struct TextPrinter *x); void ClearTextSpan(struct TextPrinter *textPrinter, u32 width); +u8 GetMenuCursorDimensionByFont(u8, u8); u16 Font0Func(struct TextPrinter *textPrinter); u16 Font1Func(struct TextPrinter *textPrinter); diff --git a/src/item_menu.c b/src/item_menu.c index 76e760d13..112f6faad 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1,14 +1,23 @@ #include "global.h" +#include "battle.h" +#include "battle_controllers.h" #include "battle_frontier_2.h" +#include "berry_tag_screen.h" #include "bg.h" #include "constants/items.h" #include "constants/songs.h" #include "decompress.h" #include "event_data.h" +#include "field_map_obj_helpers.h" #include "field_player_avatar.h" +#include "field_specials.h" +#include "graphics.h" #include "gpu_regs.h" #include "international_string_util.h" #include "item.h" +#include "item_menu_icons.h" +#include "item_use.h" +#include "lilycove_lady.h" #include "list_menu.h" #include "link.h" #include "mail.h" @@ -18,22 +27,28 @@ #include "menu.h" #include "menu_indicators.h" #include "money.h" -#include "new_menu_helpers.h" #include "overworld.h" #include "palette.h" +#include "party_menu.h" +#include "player_pc.h" #include "pokemon.h" +#include "pokemon_summary_screen.h" #include "rom_818CFC8.h" #include "scanline_effect.h" #include "script.h" +#include "shop.h" #include "sound.h" #include "sprite.h" #include "string.h" +#include "strings.h" #include "string_util.h" #include "task.h" #include "text_window.h" #include "menu_helpers.h" #include "window.h" +// .text + struct BagStruct { void (*bagCallback)(void); u8 location; @@ -41,7 +56,6 @@ struct BagStruct { u8 unk6[2]; u16 cursorPosition[5]; u16 scrollPosition[5]; - u8 **pocketStringsPtr; }; struct UnkBagStruct { @@ -92,65 +106,14 @@ struct TempWallyStruct { u16 pocket; }; -struct UnkStructTextFunc{ - u8* text; - TaskFunc func; -}; +EWRAM_DATA struct UnkBagStruct *gUnknown_0203CE54 = 0; +EWRAM_DATA struct BagStruct gUnknown_0203CE58 = {0, 0, 0, {0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}; +EWRAM_DATA struct ListBuffer1 *gUnknown_0203CE74 = 0; +EWRAM_DATA struct ListBuffer2 *gUnknown_0203CE78 = 0; +EWRAM_DATA u16 gSpecialVar_ItemId = 0; +EWRAM_DATA struct TempWallyStruct *gUnknown_0203CE80 = 0; -extern struct BagStruct gUnknown_0203CE58; -extern struct UnkBagStruct *gUnknown_0203CE54; -extern struct ListBuffer1 *gUnknown_0203CE74; -extern struct ListBuffer2 *gUnknown_0203CE78; -extern struct TempWallyStruct *gUnknown_0203CE80; -extern u16 gUnknown_0203CE6A[]; -extern u16 gUnknown_0203CE60[]; -extern void sub_8086194(void); -extern void sub_80861B0(void); -extern void sub_816B31C(void); -extern void bag_menu_leave_maybe_3(void); -extern void bag_menu_leave_maybe_2(void); -extern void bag_menu_leave_maybe(void); -extern void CB2_ExitSellMenu(void); -extern void SetCB2ToReshowScreenAfterMenu2(void); -extern void sub_81C4F98(u8, void(*)(void)); -extern bool8 sub_81221EC(void); -extern bool8 sub_81221AC(void); -extern void sub_81ABA6C(void); -extern void sub_81ABAC4(void); -extern void sub_81ABAE0(void); -extern u8 sub_81AB1F0(u8); -extern void sub_80D4FAC(void); -extern void RemoveBagItemIconObject(u8); -extern u8 ListMenuGetYCoordForPrintingArrowCursor(u8); -extern u8 GetMenuCursorDimensionByFont(u8, u8); -extern u8 AddScrollIndicatorArrowPair(void*, void*); -extern void sub_80D6FB4(struct BagPocket*); -extern void sub_80D6F64(struct BagPocket*); -extern u8 GetLRKeysState(void); -extern void sub_81AC23C(u8); -extern void sub_81AF15C(u8, u8, u8); -extern void sub_80D4FEC(u8); -extern void sub_80D4FC8(u8); -extern void sub_80D702C(struct ItemSlot*, s16, u16); -extern bool8 sub_8122148(u16); -extern void AddItemMenuActionTextPrinters (u8, u8, u8, u8, u8, u8, u8, struct UnkStructTextFunc*, u8*); -extern void sub_8198DBC(u8, u8, u8, u8, u8, u8, u8, struct UnkStructTextFunc*, u8*); -extern void sub_8199944(u8, u8, u8, u8, u8); -extern void sub_8199134(s8, s8); -extern void sub_80FDD10(u8); -extern bool8 AdjustQuantityAccordingToDPadInput(s16*, u16); -extern void sub_81B7F60(void); -extern bool8 itemid_80BF6D8_mail_related(u16); -extern void DoBerryTagScreen(void); -extern void sub_808B864(void); -extern void sub_808BCF4(void); -extern void FreezeMapObjects(void); -extern bool8 InMultiBattleRoom(void); -extern void (*gFieldCallback)(void); -extern void sub_819FA50(void); -extern void sub_818DEF4(void); -extern void sub_818E564(void); -extern void sub_819A2BC(u8, u8); +void (*gFieldCallback)(void); void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()); void CB2_Bag(void); @@ -225,32 +188,28 @@ void sub_81AD9C0(u8); void sub_81ADB14(u8); void sub_81ADA7C(u8); void sub_81ADC0C(u8); +void bag_menu_leave_maybe_3(void); +void bag_menu_leave_maybe_2(void); +void bag_menu_leave_maybe(void); +void sub_81ABA6C(void); +void sub_81ABAC4(void); +void sub_81ABAE0(void); +u8 sub_81AB1F0(u8); +void sub_81AC23C(u8); extern u8 *gPocketNamesStringsTable[]; extern struct BgTemplate gUnknown_08613F90[]; -extern u8 gBagScreen_Gfx[]; extern u8 gUnknown_08D9A88C[]; -extern u16 gBagScreenFemale_Pal[]; -extern u16 gBagScreenMale_Pal[]; extern struct CompressedSpriteSheet gUnknown_0857FB34; extern struct CompressedSpriteSheet gUnknown_0857FB3C; extern struct CompressedSpritePalette gUnknown_0857FB44; -extern u8 gText_CloseBag[]; extern struct ListMenuTemplate gUnknown_08613F9C; -extern u8 gText_ClearTo11Var1Clear5Var2[]; -extern u8 gText_UnkF908Var1Clear7Var2[]; extern u8 gMoveNames[][0xD]; -extern u8 gBagMenuHMIcon_Gfx[]; extern u8 gUnknown_086140A4[]; -extern u8 gText_xVar1[]; extern u8* gReturnToXStringsTable[]; -extern u8 gText_ReturnToVar1[]; -extern u8 gText_SelectorArrow2[]; extern u32 gUnknown_08614094[]; extern u32 gUnknown_0203CE5E[]; -extern u16 gSpecialVar_ItemId; extern TaskFunc gUnknown_08614054[]; -extern u8 gText_MoveVar1Where[]; extern u8 gUnknown_0861402C[]; extern u8 gUnknown_08614030[]; extern u8 gUnknown_08614034[]; @@ -263,32 +222,15 @@ extern u8 gUnknown_08614047[]; extern u8 gUnknown_0861404B[]; extern u8 gUnknown_0861404D[]; extern u8 gUnknown_0861404F[]; -extern u8 gText_Var1IsSelected[]; -extern struct UnkStructTextFunc gUnknown_08613FB4[]; -extern u8 gText_TossHowManyVar1s[]; -extern u8 gText_ConfirmTossItems[]; +extern struct MenuAction gUnknown_08613FB4[]; extern struct YesNoFuncTable gUnknown_08614084; -extern u8 gText_ThrewAwayVar2Var1s[]; -extern u8 gText_CantWriteMail[]; -extern u8 gText_NoPokemon[]; -extern u8 gText_Var1CantBeHeld[]; -extern u8 gText_Var1CantBeHeldHere[]; extern u8 EventScript_2736B3[]; -extern u8 gText_CantBuyKeyItem[]; -extern u8 gText_HowManyToSell[]; -extern u8 gText_ICanPayVar1[]; extern struct YesNoFuncTable gUnknown_0861408C; -extern u8 gText_TurnedOverVar1ForVar2[]; -extern u8 gText_DepositHowManyVar1[]; -extern u8 gText_CantStoreImportantItems[]; -extern u8 gText_DepositedVar2Var1s[]; -extern u8 gText_NoRoomForItems[]; extern struct WindowTemplate gUnknown_08614174[]; extern u16 gUnknown_0860F074[]; -extern struct TextColor gUnknown_08614164[]; +extern u8 gUnknown_08614164[][3]; extern struct WindowTemplate gUnknown_086141AC[]; extern struct BattleMove gBattleMoves[]; -extern u8 gText_ThreeDashes[]; void ResetBagScrollPositions(void) { @@ -354,7 +296,9 @@ void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2) u8 temp; gUnknown_0203CE54 = AllocZeroed(sizeof(struct UnkBagStruct)); if (gUnknown_0203CE54 == 0) + { SetMainCallback2(postExitMenuMainCallback2); + } else { if (bagMenuType != 12) @@ -712,12 +656,14 @@ void bag_menu_print_description_box_text(int a) { u8* str; if (a != -2) + { str = (u8*)ItemId_GetDescription(BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, a)); + } else { StringCopy(gStringVar1, gReturnToXStringsTable[gUnknown_0203CE58.location]); + StringExpandPlaceholders(gStringVar4, gText_ReturnToVar1); str = gStringVar4; - StringExpandPlaceholders(str, gText_ReturnToVar1); } FillWindowPixelBuffer(1, 0); bag_menu_print(1, 1, str, 3, 1, 0, 0, 0, 0); @@ -756,7 +702,7 @@ void sub_81AB824(void) void bag_menu_add_list_scroll_arrow_indicators_maybe(void) { if (gUnknown_0203CE54->unk81B != 1 && gUnknown_0203CE54->unk81F == 0xFF) - gUnknown_0203CE54->unk81F = AddScrollIndicatorArrowPair(&gUnknown_08614094, &gUnknown_0203CE5E); + gUnknown_0203CE54->unk81F = AddScrollIndicatorArrowPair(&gUnknown_08614094, gUnknown_0203CE58.unk6); } void sub_81AB89C(void) @@ -828,7 +774,7 @@ void sub_81AB9A8(u8 pocketId) void sub_81ABA6C(void) { u8 i; - for (i = 0;i < 5;i++) + for (i = 0; i < 5; i++) sub_81AB9A8(i); } @@ -840,14 +786,14 @@ void sub_81ABA88(u8 a) void sub_81ABAC4(void) { u8 i; - for (i = 0;i < 5;i++) + for (i = 0; i < 5; i++) sub_81ABA88(i); } void sub_81ABAE0(void) { u8 i; - for (i = 0;i < 5;i++) + for (i = 0; i < 5; i++) sub_8122298(&gUnknown_0203CE58.scrollPosition[i], &gUnknown_0203CE58.cursorPosition[i], gUnknown_0203CE54->unk82E[i], gUnknown_0203CE54->unk829[i], 8); } @@ -959,6 +905,7 @@ void Task_BagMenu(u8 taskId) data[2] = BagGetQuantityByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); gSpecialVar_ItemId = BagGetItemIdByPocketPosition(gUnknown_0203CE58.pocket + 1, r4); gUnknown_08614054[gUnknown_0203CE58.location](taskId); + break; } } } @@ -1000,9 +947,7 @@ void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId) if (deltaBagPocketId == 1 && *bagPocketId == 4) *bagPocketId = 0; else if (deltaBagPocketId == -1 && *bagPocketId == 0) - { *bagPocketId = 4; - } else *bagPocketId += deltaBagPocketId; } @@ -1331,7 +1276,7 @@ void sub_81AC498(u8 taskId) s16* data = gTasks[taskId].data; u16* scrollPos = &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]; u16* cursorPos = &gUnknown_0203CE58.cursorPosition[gUnknown_0203CE58.pocket]; - u16 realPos = *scrollPos + *cursorPos; + u16 realPos = (*scrollPos + *cursorPos); if (data[1] == realPos || data[1] == (realPos - 1)) sub_81AC590(taskId); @@ -1498,13 +1443,9 @@ void sub_81AC644(u8 unused) if (gUnknown_0203CE54->unk828 == 1) sub_81ACAF8(bag_menu_add_window(0)); else if (gUnknown_0203CE54->unk828 == 2) - { sub_81ACAF8(bag_menu_add_window(1)); - } else if (gUnknown_0203CE54->unk828 == 4) - { sub_81ACB54(bag_menu_add_window(2), 2, 2); - } else sub_81ACB54(bag_menu_add_window(3), 2, 3); } @@ -1541,11 +1482,11 @@ void Task_HandleInBattleItemMenuInput(u8 taskId) break; case -1: PlaySE(SE_SELECT); - gUnknown_08613FB4[4].func(taskId); + gUnknown_08613FB4[4].func.void_u8(taskId); break; default: PlaySE(SE_SELECT); - gUnknown_08613FB4[gUnknown_0203CE54->unk820[r4]].func(taskId); + gUnknown_08613FB4[gUnknown_0203CE54->unk820[r4]].func.void_u8(taskId); break; } } @@ -1591,12 +1532,12 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - gUnknown_08613FB4[gUnknown_0203CE54->unk820[cursorPos]].func(taskId); + gUnknown_08613FB4[gUnknown_0203CE54->unk820[cursorPos]].func.void_u8(taskId); } else if (gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); - gUnknown_08613FB4[4].func(taskId); + gUnknown_08613FB4[4].func.void_u8(taskId); } } } @@ -1654,7 +1595,9 @@ void ItemMenu_Toss(u8 taskId) bag_menu_remove_some_window(); data[8] = 1; if (data[2] == 1) + { BagMenuConfirmToss(taskId); + } else { CopyItemName(gSpecialVar_ItemId, gStringVar1); @@ -1692,7 +1635,9 @@ void Task_ChooseHowManyToToss(u8 taskId) s16* data = gTasks[taskId].data; if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE) + { sub_81ABC54(gUnknown_0203CE54->unk817, data[8]); + } else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); @@ -1760,7 +1705,9 @@ void ItemMenu_Give(u8 taskId) { bag_menu_remove_some_window(); if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId)) + { DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350); + } else if (!itemid_is_unique(gSpecialVar_ItemId)) { if (CalculatePlayerPartyCount() == 0) @@ -1772,7 +1719,9 @@ void ItemMenu_Give(u8 taskId) } } else + { bag_menu_print_cant_be_held_msg(taskId); + } } void bag_menu_print_there_is_no_pokemon(u8 taskId) @@ -1831,7 +1780,9 @@ void bag_menu_mail_related(void) void item_menu_type_2(u8 taskId) { if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId)) + { DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350); + } else if (!sub_8122148(gSpecialVar_ItemId)) { CopyItemName(gSpecialVar_ItemId, gStringVar1); @@ -1843,7 +1794,9 @@ void item_menu_type_2(u8 taskId) unknown_ItemMenu_Confirm(taskId); } else + { bag_menu_print_cant_be_held_msg(taskId); + } } void item_menu_type_b(u8 taskId) @@ -1851,9 +1804,7 @@ void item_menu_type_b(u8 taskId) if (ItemIsMail(gSpecialVar_ItemId) == TRUE) DisplayItemMessage(taskId, 1, gText_CantWriteMail, sub_81AD350); else if (gUnknown_0203CE58.pocket != 4 && !itemid_is_unique(gSpecialVar_ItemId)) - { gTasks[taskId].func = unknown_ItemMenu_Confirm; - } else bag_menu_print_cant_be_held_msg(taskId); } @@ -1864,28 +1815,25 @@ bool8 UseRegisteredKeyItemOnField(void) if (InUnionRoom() == TRUE || InBattlePyramid() || InBattlePike() || InMultiBattleRoom() == TRUE) return FALSE; - else + HideMapNamePopUpWindow(); + ChangeBgY_ScreenOff(0, 0, 0); + if (gSaveBlock1Ptr->registeredItem != ITEM_NONE) { - HideMapNamePopUpWindow(); - ChangeBgY_ScreenOff(0, 0, 0); - if (gSaveBlock1Ptr->registeredItem != ITEM_NONE) + if (CheckBagHasItem(gSaveBlock1Ptr->registeredItem, 1) == TRUE) { - if (CheckBagHasItem(gSaveBlock1Ptr->registeredItem, 1) == TRUE) - { - ScriptContext2_Enable(); - FreezeMapObjects(); - sub_808B864(); - sub_808BCF4(); - gSpecialVar_ItemId = gSaveBlock1Ptr->registeredItem; - taskId = CreateTask(ItemId_GetFieldFunc(gSaveBlock1Ptr->registeredItem), 8); - gTasks[taskId].data[3] = 1; - return TRUE; - } - else - gSaveBlock1Ptr->registeredItem = ITEM_NONE; + ScriptContext2_Enable(); + FreezeMapObjects(); + sub_808B864(); + sub_808BCF4(); + gSpecialVar_ItemId = gSaveBlock1Ptr->registeredItem; + taskId = CreateTask(ItemId_GetFieldFunc(gSaveBlock1Ptr->registeredItem), 8); + gTasks[taskId].data[3] = 1; + return TRUE; } - ScriptContext1_SetupScript(EventScript_2736B3); + else + gSaveBlock1Ptr->registeredItem = ITEM_NONE; } + ScriptContext1_SetupScript(EventScript_2736B3); return TRUE; } @@ -1955,7 +1903,9 @@ void sub_81AD794(u8 taskId) s16* data = gTasks[taskId].data; if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE) + { sub_81ABCC0(gUnknown_0203CE54->unk818, data[8], (itemid_get_market_price(gSpecialVar_ItemId) / 2) * data[8]); + } else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); @@ -2018,7 +1968,9 @@ void display_deposit_item_ask_str(u8 taskId) data[8] = 1; if (data[2] == 1) + { sub_81ADB14(taskId); + } else { CopyItemName(gSpecialVar_ItemId, gStringVar1); @@ -2035,7 +1987,9 @@ void sub_81ADA7C(u8 taskId) s16* data = gTasks[taskId].data; if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE) + { sub_81ABC54(gUnknown_0203CE54->unk817, data[8]); + } else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); @@ -2234,8 +2188,6 @@ void bag_menu_print_pocket_names(u8 *pocketName1, u8 *pocketName2) RemoveWindow(windowId); } -// probably a fakematching - void bag_menu_copy_pocket_name_to_window(u32 a) { u8 (* r4)[32][32]; @@ -2272,7 +2224,7 @@ void setup_bag_menu_textboxes(void) void bag_menu_print(u8 a, u8 b, u8 *str, u8 c, u8 d, u8 e, u8 f, u8 g, u8 h) { - AddTextPrinterParameterized2(a, b, c, d, e, f, &gUnknown_08614164[h], g, str); + AddTextPrinterParameterized2(a, b, c, d, e, f, gUnknown_08614164[h], g, str); } u8 sub_81AE124(u8 a) @@ -2372,7 +2324,9 @@ void PrintTMHMMoveData(u16 itemId) moveId = ItemIdToBattleMoveId(itemId); blit_move_info_icon(4, gBattleMoves[moveId].type + 1, 0, 0); if (gBattleMoves[moveId].power <= 1) + { text = gText_ThreeDashes; + } else { ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].power, 1, 3); @@ -2380,7 +2334,9 @@ void PrintTMHMMoveData(u16 itemId) } bag_menu_print(4, 1, text, 7, 12, 0, 0, -1, 4); if (gBattleMoves[moveId].accuracy == 0) + { text = gText_ThreeDashes; + } else { ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].accuracy, 1, 3); diff --git a/sym_common.txt b/sym_common.txt index ec6c95b20..88f6ad92f 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -264,7 +264,8 @@ gUnknown_03005DA8: @ 3005DA8 .space 0x4 gFieldCallback: @ 3005DAC - .space 0x4 + + .include "item_menu.o" gUnknown_03005DB0: @ 3005DB0 .space 0x4 diff --git a/sym_ewram.txt b/sym_ewram.txt index fb7c7a4e7..9719a28c6 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -1308,37 +1308,9 @@ gUnknown_0203CE50: @ 203CE50 .space 0x4 gUnknown_0203CE54: @ 203CE54 - .space 0x4 - -gUnknown_0203CE58: @ 203CE58 - .space 0x5 - -gUnknown_0203CE5D: @ 203CE5D - .space 0x1 - -gUnknown_0203CE5E: @ 203CE5E - .space 0x2 - -gUnknown_0203CE60: @ 203CE60 - .space 0xA - -gUnknown_0203CE6A: @ 203CE6A - .space 0x6 - -gUnknown_0203CE70: @ 203CE70 - .space 0x4 - -gUnknown_0203CE74: @ 203CE74 - .space 0x4 - -gUnknown_0203CE78: @ 203CE78 - .space 0x4 - -gSpecialVar_ItemId: @ 203CE7C - .space 0x4 - -gUnknown_0203CE80: @ 203CE80 - .space 0x4 + .align 2 + + .include "src/item_menu.o" gUnknown_0203CE84: @ 203CE84 .space 0x8 From f81c52b56e865d8ecc753a69a31a5148548320a6 Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Mon, 12 Feb 2018 13:59:42 -0500 Subject: [PATCH 11/12] more fixes --- data/item_menu.s | 127 ------------ include/graphics.h | 6 +- include/pokemon_summary_screen.h | 2 +- include/strings.h | 56 ++--- ld_script.txt | 2 +- src/item_menu.c | 338 ++++++++++++++++++++----------- src/item_use.c | 2 +- 7 files changed, 256 insertions(+), 277 deletions(-) delete mode 100644 data/item_menu.s diff --git a/data/item_menu.s b/data/item_menu.s deleted file mode 100644 index 1b11c5e59..000000000 --- a/data/item_menu.s +++ /dev/null @@ -1,127 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - -gUnknown_08613F90:: @ 8613F90 - .4byte 0x11F0, 0x1E1, 0x21DE - -@ possibly a struct -gUnknown_08613F9C:: @ 8613F9C - .4byte 0 - .4byte bag_menu_change_item_callback - .4byte sub_81AB520 - .4byte 0 - .4byte 0x80000 - .4byte 0x7003011 - -gUnknown_08613FB4:: @ 8613FB4 - .4byte gMenuText_Use, ItemMenu_UseOutOfBattle - .4byte gMenuText_Toss, ItemMenu_Toss - .4byte gMenuText_Register, ItemMenu_Register - .4byte gMenuText_Give, ItemMenu_Give - .4byte gText_Cancel2, ItemMenu_Cancel - .4byte gMenuText_Use, ItemMenu_UseInBattle - .4byte gMenuText_Check, ItemMenu_UseOutOfBattle - .4byte gMenuText_Walk, ItemMenu_UseOutOfBattle - .4byte gMenuText_Deselect, ItemMenu_Register - .4byte gMenuText_CheckTag, ItemMenu_CheckTag - .4byte gMenuText_Confirm, unknown_ItemMenu_Confirm - .4byte gMenuText_Show, unknown_ItemMenu_Show - .4byte gMenuText_Give2, unknown_ItemMenu_Give2 - .4byte gMenuText_Confirm, unknown_ItemMenu_Confirm2 - .4byte gText_EmptyString2, NULL - -gUnknown_0861402C:: @ 861402C - .byte 0, 3, 1, 4 - -gUnknown_08614030:: @ 8614030 - .byte 0, 2, 14, 4 - -gUnknown_08614034:: @ 8614034 - .byte 3, 14, 1, 4 - -gUnknown_08614038:: @ 8614038 - .byte 0, 3, 14, 4 - -gUnknown_0861403C:: @ 861403C - .byte 9, 14, 0, 3, 1, 4 - -gUnknown_08614042:: @ 8614042 - .byte 5, 4 - -gUnknown_08614044:: @ 8614044 - .byte 3, 4 - -gUnknown_08614046:: @ 8614046 - .byte 4 - -gUnknown_08614047:: @ 8614047 - .byte 10, 9, 14, 4 - -gUnknown_0861404B:: @ 861404B - .byte 11, 4 - -gUnknown_0861404D:: @ 861404D - .byte 12, 4 - -gUnknown_0861404F:: @ 861404F - .byte 13, 4 - - .align 2 -gUnknown_08614054:: @ 8614054 - .4byte unknown_item_menu_type - .4byte unknown_item_menu_type - .4byte item_menu_type_2 - .4byte display_sell_item_ask_str - .4byte unknown_ItemMenu_Confirm - .4byte unknown_item_menu_type - .4byte display_deposit_item_ask_str - .4byte unknown_item_menu_type - .4byte unknown_item_menu_type - .4byte unknown_item_menu_type - .4byte NULL - .4byte item_menu_type_b - - .align 2 -gUnknown_08614084:: @ 8614084 - .4byte BagMenuActuallyToss - .4byte BagMenuCancelToss - -gUnknown_0861408C:: @ 861408C - .4byte sub_81AD84C - .4byte sub_81AD6FC - -@ probably a struct -gUnknown_08614094:: @ 8614094 - .4byte 0x1101C00 - .4byte 0xFFFF1064 - .4byte 0x6FFFFF - .4byte 0x6F - -gUnknown_086140A4:: @ 86140A4 - .incbin "graphics/interface/select_button.4bpp" - -gUnknown_08614164:: @ 8614164 - .byte 0, 1, 3, 0, 1, 4, 0, 3, 6, 2, 1, 3, 0, 14, 10, 0 - -gUnknown_08614174:: @ 8614174 - window_template 0, 14, 2, 15, 16, 1, 0x27 - window_template 0, 0, 13, 14, 6, 1, 0x117 - window_template 0, 4, 1, 8, 2, 1, 0x1A1 - window_template 0, 1, 13, 5, 6, 12, 0x16B - window_template 0, 7, 13, 4, 6, 12, 0x189 - window_template 1, 2, 15, 27, 4, 15, 0x1B1 - null_window_template - -gUnknown_086141AC:: @ 86141AC - window_template 1, 22, 17, 7, 2, 15, 0x21D - window_template 1, 22, 15, 7, 4, 15, 0x21D - window_template 1, 15, 15, 14, 4, 15, 0x21D - window_template 1, 15, 13, 14, 6, 15, 0x21D - window_template 1, 2, 15, 27, 4, 15, 0x1B1 - window_template 1, 24, 15, 5, 4, 15, 0x21D - window_template 1, 21, 9, 5, 4, 15, 0x21D - window_template 1, 24, 17, 5, 2, 15, 0x21D - window_template 1, 18, 11, 10, 2, 15, 0x245 - window_template 1, 1, 1, 10, 2, 15, 0x231 diff --git a/include/graphics.h b/include/graphics.h index 8ed54bcfb..6e5de9ef4 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -2721,8 +2721,8 @@ extern const u8 gFireRedMenuElements_Gfx[]; //item menu graphics extern const u8 gBagScreen_Gfx[]; -extern u16 gBagScreenFemale_Pal[]; -extern u16 gBagScreenMale_Pal[]; -extern u8 gBagMenuHMIcon_Gfx[]; +extern const u16 gBagScreenFemale_Pal[]; +extern const u16 gBagScreenMale_Pal[]; +extern const u8 gBagMenuHMIcon_Gfx[]; #endif //GUARD_GRAPHICS_H diff --git a/include/pokemon_summary_screen.h b/include/pokemon_summary_screen.h index a4e46dd6e..adadcea03 100755 --- a/include/pokemon_summary_screen.h +++ b/include/pokemon_summary_screen.h @@ -3,4 +3,4 @@ void sub_81C4F98(u8, void(*)(void)); -#endif // GUARD_POKEMON_SUMMARY_SCREEN_H \ No newline at end of file +#endif // GUARD_POKEMON_SUMMARY_SCREEN_H diff --git a/include/strings.h b/include/strings.h index 4e96dc528..2bdeef8ca 100644 --- a/include/strings.h +++ b/include/strings.h @@ -134,6 +134,14 @@ extern const u8 gMenuText_Use[]; extern const u8 gMenuText_Toss[]; extern const u8 gMenuText_Give[]; extern const u8 gMenuText_Give2[]; +extern const u8 gMenuText_Register[]; +extern const u8 gMenuText_Check[]; +extern const u8 gMenuText_Walk[]; +extern const u8 gMenuText_Deselect[]; +extern const u8 gMenuText_CheckTag[]; +extern const u8 gMenuText_Confirm[]; +extern const u8 gMenuText_Show[]; +extern const u8 gMenuText_Give2[]; extern const u8 gText_Cancel2[]; @@ -240,29 +248,29 @@ extern const u8 gText_ThreeMarks[]; extern const u8 gText_FirmSlash[]; //item menu screen text -extern u8 gText_CloseBag[]; -extern u8 gText_ClearTo11Var1Clear5Var2[]; -extern u8 gText_UnkF908Var1Clear7Var2[]; -extern u8 gText_xVar1[]; -extern u8 gText_ReturnToVar1[]; -extern u8 gText_SelectorArrow2[]; -extern u8 gText_MoveVar1Where[]; -extern u8 gText_Var1IsSelected[]; -extern u8 gText_TossHowManyVar1s[]; -extern u8 gText_ConfirmTossItems[]; -extern u8 gText_ThrewAwayVar2Var1s[]; -extern u8 gText_CantWriteMail[]; -extern u8 gText_NoPokemon[]; -extern u8 gText_Var1CantBeHeld[]; -extern u8 gText_Var1CantBeHeldHere[]; -extern u8 gText_CantBuyKeyItem[]; -extern u8 gText_HowManyToSell[]; -extern u8 gText_ICanPayVar1[]; -extern u8 gText_TurnedOverVar1ForVar2[]; -extern u8 gText_DepositHowManyVar1[]; -extern u8 gText_CantStoreImportantItems[]; -extern u8 gText_DepositedVar2Var1s[]; -extern u8 gText_NoRoomForItems[]; -extern u8 gText_ThreeDashes[]; +extern const u8 gText_CloseBag[]; +extern const u8 gText_ClearTo11Var1Clear5Var2[]; +extern const u8 gText_UnkF908Var1Clear7Var2[]; +extern const u8 gText_xVar1[]; +extern const u8 gText_ReturnToVar1[]; +extern const u8 gText_SelectorArrow2[]; +extern const u8 gText_MoveVar1Where[]; +extern const u8 gText_Var1IsSelected[]; +extern const u8 gText_TossHowManyVar1s[]; +extern const u8 gText_ConfirmTossItems[]; +extern const u8 gText_ThrewAwayVar2Var1s[]; +extern const u8 gText_CantWriteMail[]; +extern const u8 gText_NoPokemon[]; +extern const u8 gText_Var1CantBeHeld[]; +extern const u8 gText_Var1CantBeHeldHere[]; +extern const u8 gText_CantBuyKeyItem[]; +extern const u8 gText_HowManyToSell[]; +extern const u8 gText_ICanPayVar1[]; +extern const u8 gText_TurnedOverVar1ForVar2[]; +extern const u8 gText_DepositHowManyVar1[]; +extern const u8 gText_CantStoreImportantItems[]; +extern const u8 gText_DepositedVar2Var1s[]; +extern const u8 gText_NoRoomForItems[]; +extern const u8 gText_ThreeDashes[]; #endif //GUARD_STRINGS_H diff --git a/ld_script.txt b/ld_script.txt index f9cb25225..2aebc9adb 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -522,7 +522,7 @@ SECTIONS { data/battle_frontier_1.o(.rodata); src/menu.o(.rodata); data/battle_frontier_2.o(.rodata); - data/item_menu.o(.rodata); + src/item_menu.o(.rodata); data/menu_indicators.o(.rodata); src/save_location.o(.rodata); data/item_icon.o(.rodata); diff --git a/src/item_menu.c b/src/item_menu.c index 112f6faad..3c1b88cd7 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -47,6 +47,208 @@ #include "menu_helpers.h" #include "window.h" +void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()); +void CB2_Bag(void); +bool8 setup_bag_menu(void); +void bag_menu_init_bgs(void); +bool8 load_bag_menu_graphics(void); +void setup_bag_menu_textboxes(void); +void allocate_bag_item_list_buffers(void); +void load_bag_item_list_buffers(u8); +void bag_menu_print_pocket_names(u8*, u8*); +void bag_menu_copy_pocket_name_to_window(u32); +void bag_menu_draw_pocket_indicator_square(u8, u8); +void AddBagVisualObject(u8); +void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void); +void bag_menu_add_list_scroll_arrow_indicators_maybe(void); +void bag_menu_prepare_tmhm_move_window(void); +bool8 IsWallysBag(void); +void Task_WallyTutorialBagMenu(u8); +void Task_BagMenu(u8); +void get_name(s8*, u16); +u16 ItemIdToBattleMoveId(u16); +void ShakeBagVisual(void); +u16 BagGetItemIdByPocketPosition(u8, u16); +void AddBagItemIconObject(u16, u8); +void bag_menu_print_description_box_text(int); +void bag_menu_print_cursor(u8, u8); +void bag_menu_print(u8, u8, const u8*, u8, u8, u8, u8, u8, u8); +bool8 itemid_is_unique(u16); +u16 BagGetQuantityByPocketPosition(u8, u16); +void sub_81AB89C(void); +void task_close_bag_menu_2(u8); +u8 AddItemMessageWindow(u8); +void bag_menu_RemoveBagItem_message_window(u8); +void set_callback3_to_bag(u8); +void sub_81ABC54(u8, s16); +u8 bag_menu_add_window(u8); +u8 GetSwitchBagPocketDirection(void); +void SwitchBagPocket(u8, s16, u16); +bool8 sub_81AC2C0(void); +void bag_menu_swap_items(u8); +void SetBagVisualPocketId(u8, u8); +void RemoveBagObject(u8); +void AddSwitchPocketRotatingBallObject(s16); +void sub_81AC10C(u8); +void sub_81AC3C0(u8); +void sub_81AC498(u8); +void sub_81AC590(u8); +void PrintTMHMMoveData(u16); +void sub_81ACAF8(u8); +void sub_81ACB54(u8, u8, u8); +void Task_HandleInBattleItemMenuInput(u8); +void Task_HandleOutOfBattleItemMenuInput(u8); +bool8 sub_81ACDFC(s8); +void bag_menu_remove_window(u8); +void bag_menu_print_there_is_no_pokemon(u8); +void Task_ChooseHowManyToToss(u8); +void BagMenuConfirmToss(u8); +void bag_menu_yes_no(u8, u8, const struct YesNoFuncTable*); +void Task_ActuallyToss(u8); +void ItemMenu_Cancel(u8); +void sub_81AD350(u8); +void bag_menu_print_cant_be_held_msg(u8); +void bag_menu_AddMoney_window(void); +void sub_81AD680(u8); +void sub_81AD730(u8); +void sub_81AD6E4(u8); +void bag_menu_remove_money_window(void); +void bag_menu_RemoveBagItem_message_window(u8); +void sub_81AD794(u8); +void sub_81AD8C8(u8); +void sub_81AD9C0(u8); +void sub_81ADB14(u8); +void sub_81ADA7C(u8); +void sub_81ADC0C(u8); +void bag_menu_leave_maybe_3(void); +void bag_menu_leave_maybe_2(void); +void bag_menu_leave_maybe(void); +void sub_81ABA6C(void); +void sub_81ABAC4(void); +void sub_81ABAE0(void); +u8 sub_81AB1F0(u8); +void sub_81AC23C(u8); +void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu*); +void sub_81AB520(u8 rboxId, int item_index_in_pocket, u8 a); +void ItemMenu_UseOutOfBattle(u8 taskId); +void ItemMenu_Toss(u8 taskId); +void ItemMenu_Register(u8 taskId); +void ItemMenu_Give(u8 taskId); +void ItemMenu_Cancel(u8 taskId); +void ItemMenu_UseInBattle(u8 taskId); +void ItemMenu_CheckTag(u8 taskId); +void unknown_ItemMenu_Confirm(u8 taskId); +void unknown_ItemMenu_Show(u8 taskId); +void unknown_ItemMenu_Give2(u8 taskId); +void unknown_ItemMenu_Confirm2(u8 taskId); +void unknown_item_menu_type(u8 taskId); +void item_menu_type_2(u8 taskId); +void display_sell_item_ask_str(u8 taskId); +void unknown_ItemMenu_Confirm(u8 taskId); +void display_deposit_item_ask_str(u8 taskId); +void item_menu_type_b(u8 taskId); +void BagMenuActuallyToss(u8 taskId); +void BagMenuCancelToss(u8 taskId); +void sub_81AD84C(u8 taskId); +void sub_81AD6FC(u8 taskId); + +// .rodata + +const struct BgTemplate gUnknown_08613F90[3] = { + {0, 0, 31, 0, 0, 1, 0}, + {1, 0, 30, 0, 0, 0, 0}, + {2, 3, 29, 0, 0, 2, 0} +}; + +const struct ListMenuTemplate gUnknown_08613F9C = { + NULL, bag_menu_change_item_callback, sub_81AB520, 0, 0, 0, 0, 8, 0, 1, 1, 0, 3, 0, 0, 0, 7, 0 +}; + +const struct MenuAction gUnknown_08613FB4[] = { + {gMenuText_Use, ItemMenu_UseOutOfBattle}, + {gMenuText_Toss, ItemMenu_Toss}, + {gMenuText_Register, ItemMenu_Register}, + {gMenuText_Give, ItemMenu_Give}, + {gText_Cancel2, ItemMenu_Cancel}, + {gMenuText_Use, ItemMenu_UseInBattle}, + {gMenuText_Check, ItemMenu_UseOutOfBattle}, + {gMenuText_Walk, ItemMenu_UseOutOfBattle}, + {gMenuText_Deselect, ItemMenu_Register}, + {gMenuText_CheckTag, ItemMenu_CheckTag}, + {gMenuText_Confirm, unknown_ItemMenu_Confirm}, + {gMenuText_Show, unknown_ItemMenu_Show}, + {gMenuText_Give2, unknown_ItemMenu_Give2}, + {gMenuText_Confirm, unknown_ItemMenu_Confirm2}, + {gText_EmptyString2, NULL} +}; + +const u8 gUnknown_0861402C[] = {0, 3, 1, 4}; +const u8 gUnknown_08614030[] = {0, 2, 14, 4}; +const u8 gUnknown_08614034[] = {3, 14, 1, 4}; +const u8 gUnknown_08614038[] = {0, 3, 14, 4}; +const u8 gUnknown_0861403C[] = {9, 14, 0, 3, 1, 4}; +const u8 gUnknown_08614042[] = {5, 4}; +const u8 gUnknown_08614044[] = {3, 4}; +const u8 gUnknown_08614046 = 4; +const u8 gUnknown_08614047[] = {10, 9, 14, 4}; +const u8 gUnknown_0861404B[] = {11, 4}; +const u8 gUnknown_0861404D[] = {12, 4}; +const u8 gUnknown_0861404F[] = {13, 4}; + +const TaskFunc gUnknown_08614054[] = { + unknown_item_menu_type, + unknown_item_menu_type, + item_menu_type_2, + display_sell_item_ask_str, + unknown_ItemMenu_Confirm, + unknown_item_menu_type, + display_deposit_item_ask_str, + unknown_item_menu_type, + unknown_item_menu_type, + unknown_item_menu_type, + NULL, + item_menu_type_b +}; + +const struct YesNoFuncTable gUnknown_08614084 = {BagMenuActuallyToss, BagMenuCancelToss}; + +const struct YesNoFuncTable gUnknown_0861408C = {sub_81AD84C, sub_81AD6FC}; + +const u16 gUnknown_08614094[] = {0x1C00, 0x110, 0x1064, -1, -1, 0x6F, 0x6F, 0}; + +const u8 gUnknown_086140A4[] = INCBIN_U8("graphics/interface/select_button.4bpp"); + +const u8 gUnknown_08614164[][3] = { + {0, 1, 3}, + {0, 1, 4}, + {0, 3, 6}, + {2, 1, 3}, + {0, 14, 10} +}; + +const struct WindowTemplate gUnknown_08614174[] = { + {0, 14, 2, 15, 16, 1, 0x27}, + {0, 0, 13, 14, 6, 1, 0x117}, + {0, 4, 1, 8, 2, 1, 0x1A1}, + {0, 1, 13, 5, 6, 12, 0x16B}, + {0, 7, 13, 4, 6, 12, 0x189}, + {1, 2, 15, 27, 4, 15, 0x1B1}, + {0xFF, 0, 0, 0, 0, 0, 0} +}; + +const struct WindowTemplate gUnknown_086141AC[] = { + {1, 22, 17, 7, 2, 15, 0x21D}, + {1, 22, 15, 7, 4, 15, 0x21D}, + {1, 15, 15, 14, 4, 15, 0x21D}, + {1, 15, 13, 14, 6, 15, 0x21D}, + {1, 2, 15, 27, 4, 15, 0x1B1}, + {1, 24, 15, 5, 4, 15, 0x21D}, + {1, 21, 9, 5, 4, 15, 0x21D}, + {1, 24, 17, 5, 2, 15, 0x21D}, + {1, 18, 11, 10, 2, 15, 0x245}, + {1, 1, 1, 10, 2, 15, 0x231} +}; + // .text struct BagStruct { @@ -76,7 +278,7 @@ struct UnkBagStruct { u8 filler3[2]; u8 unk81E; u8 unk81F; - u8* unk820; + const u8* unk820; u8 unk824; u8 unk825; u8 filler[2]; @@ -115,121 +317,17 @@ EWRAM_DATA struct TempWallyStruct *gUnknown_0203CE80 = 0; void (*gFieldCallback)(void); -void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)()); -void CB2_Bag(void); -bool8 setup_bag_menu(void); -void bag_menu_init_bgs(void); -bool8 load_bag_menu_graphics(void); -void setup_bag_menu_textboxes(void); -void allocate_bag_item_list_buffers(void); -void load_bag_item_list_buffers(u8); -void bag_menu_print_pocket_names(u8*, u8*); -void bag_menu_copy_pocket_name_to_window(u32); -void bag_menu_draw_pocket_indicator_square(u8, u8); -void AddBagVisualObject(u8); -void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void); -void bag_menu_add_list_scroll_arrow_indicators_maybe(void); -void bag_menu_prepare_tmhm_move_window(void); -bool8 IsWallysBag(void); -void Task_WallyTutorialBagMenu(u8); -void Task_BagMenu(u8); -void get_name(s8*, u16); -u16 ItemIdToBattleMoveId(u16); -void ShakeBagVisual(void); -u16 BagGetItemIdByPocketPosition(u8, u16); -void AddBagItemIconObject(u16, u8); -void bag_menu_print_description_box_text(int); -void bag_menu_print_cursor(u8, u8); -void bag_menu_print(u8, u8, u8*, u8, u8, u8, u8, u8, u8); -bool8 itemid_is_unique(u16); -u16 BagGetQuantityByPocketPosition(u8, u16); -void sub_81AB89C(void); -void task_close_bag_menu_2(u8); -u8 AddItemMessageWindow(u8); -void bag_menu_RemoveBagItem_message_window(u8); -void set_callback3_to_bag(u8); -void sub_81ABC54(u8, s16); -u8 bag_menu_add_window(u8); -u8 GetSwitchBagPocketDirection(void); -void SwitchBagPocket(u8, s16, u16); -bool8 sub_81AC2C0(void); -void bag_menu_swap_items(u8); -void SetBagVisualPocketId(u8, u8); -void RemoveBagObject(u8); -void AddSwitchPocketRotatingBallObject(s16); -void sub_81AC10C(u8); -void sub_81AC3C0(u8); -void sub_81AC498(u8); -void sub_81AC590(u8); -void PrintTMHMMoveData(u16); -void sub_81ACAF8(u8); -void sub_81ACB54(u8, u8, u8); -void Task_HandleInBattleItemMenuInput(u8); -void Task_HandleOutOfBattleItemMenuInput(u8); -bool8 sub_81ACDFC(s8); -void bag_menu_remove_window(u8); -void bag_menu_print_there_is_no_pokemon(u8); -void Task_ChooseHowManyToToss(u8); -void BagMenuConfirmToss(u8); -void bag_menu_yes_no(u8, u8, struct YesNoFuncTable*); -void Task_ActuallyToss(u8); -void ItemMenu_Cancel(u8); -void sub_81AD350(u8); -void bag_menu_print_cant_be_held_msg(u8); -void bag_menu_AddMoney_window(void); -void sub_81AD680(u8); -void sub_81AD730(u8); -void sub_81AD6E4(u8); -void bag_menu_remove_money_window(void); -void bag_menu_RemoveBagItem_message_window(u8); -void sub_81AD794(u8); -void sub_81AD8C8(u8); -void sub_81AD9C0(u8); -void sub_81ADB14(u8); -void sub_81ADA7C(u8); -void sub_81ADC0C(u8); -void bag_menu_leave_maybe_3(void); -void bag_menu_leave_maybe_2(void); -void bag_menu_leave_maybe(void); -void sub_81ABA6C(void); -void sub_81ABAC4(void); -void sub_81ABAE0(void); -u8 sub_81AB1F0(u8); -void sub_81AC23C(u8); - extern u8 *gPocketNamesStringsTable[]; -extern struct BgTemplate gUnknown_08613F90[]; extern u8 gUnknown_08D9A88C[]; extern struct CompressedSpriteSheet gUnknown_0857FB34; extern struct CompressedSpriteSheet gUnknown_0857FB3C; extern struct CompressedSpritePalette gUnknown_0857FB44; extern struct ListMenuTemplate gUnknown_08613F9C; extern u8 gMoveNames[][0xD]; -extern u8 gUnknown_086140A4[]; extern u8* gReturnToXStringsTable[]; -extern u32 gUnknown_08614094[]; extern u32 gUnknown_0203CE5E[]; -extern TaskFunc gUnknown_08614054[]; -extern u8 gUnknown_0861402C[]; -extern u8 gUnknown_08614030[]; -extern u8 gUnknown_08614034[]; -extern u8 gUnknown_08614038[]; -extern u8 gUnknown_0861403C[]; -extern u8 gUnknown_08614042[]; -extern u8 gUnknown_08614044[]; -extern u8 gUnknown_08614046[]; -extern u8 gUnknown_08614047[]; -extern u8 gUnknown_0861404B[]; -extern u8 gUnknown_0861404D[]; -extern u8 gUnknown_0861404F[]; -extern struct MenuAction gUnknown_08613FB4[]; -extern struct YesNoFuncTable gUnknown_08614084; extern u8 EventScript_2736B3[]; -extern struct YesNoFuncTable gUnknown_0861408C; -extern struct WindowTemplate gUnknown_08614174[]; extern u16 gUnknown_0860F074[]; -extern u8 gUnknown_08614164[][3]; -extern struct WindowTemplate gUnknown_086141AC[]; extern struct BattleMove gBattleMoves[]; void ResetBagScrollPositions(void) @@ -462,7 +560,7 @@ void bag_menu_init_bgs(void) SetBgTilemapBuffer(2, gUnknown_0203CE54->unk4); ResetAllBgsCoordinates(); schedule_bg_copy_tilemap_to_vram(2); - SetGpuReg(REG_OFFSET_DISPCNT, 0x1040); + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); ShowBg(0); ShowBg(1); ShowBg(2); @@ -535,7 +633,7 @@ void load_bag_item_list_buffers(u8 pocketId) if (!gUnknown_0203CE54->unk81B_2) { - for (i = 0;i < gUnknown_0203CE54->unk829[pocketId] - 1; i++) + for (i = 0; i < gUnknown_0203CE54->unk829[pocketId] - 1; i++) { get_name(gUnknown_0203CE78->name[i], pocket->itemSlots[i].itemId); subBuffer = gUnknown_0203CE74->subBuffers; @@ -549,7 +647,7 @@ void load_bag_item_list_buffers(u8 pocketId) } else { - for (i = 0;i < gUnknown_0203CE54->unk829[pocketId]; i++) + for (i = 0; i < gUnknown_0203CE54->unk829[pocketId]; i++) { get_name(gUnknown_0203CE78->name[i], pocket->itemSlots[i].itemId); subBuffer = gUnknown_0203CE74->subBuffers; @@ -591,7 +689,7 @@ void get_name(s8 *dest, u16 itemId) } } -void bag_menu_change_item_callback(u32 a, u8 b) +void bag_menu_change_item_callback(u32 a, bool8 b, struct ListMenu *unused) { if (b != 1) { @@ -802,7 +900,7 @@ u8 sub_81ABB2C(u8 a) return gUnknown_0203CE58.scrollPosition[a] + gUnknown_0203CE58.cursorPosition[a]; } -void DisplayItemMessage(u8 taskId, u8 fontId, u8 *str, void ( *callback)(u8 taskId)) +void DisplayItemMessage(u8 taskId, u8 fontId, const u8 *str, void ( *callback)(u8 taskId)) { s16* data = gTasks[taskId].data; @@ -1325,7 +1423,7 @@ void sub_81AC644(u8 unused) } else { - gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk820 = &gUnknown_08614046; gUnknown_0203CE54->unk828 = 1; } break; @@ -1341,7 +1439,7 @@ void sub_81AC644(u8 unused) } else { - gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk820 = &gUnknown_08614046; gUnknown_0203CE54->unk828 = 1; } break; @@ -1353,7 +1451,7 @@ void sub_81AC644(u8 unused) } else { - gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk820 = &gUnknown_08614046; gUnknown_0203CE54->unk828 = 1; } break; @@ -1365,7 +1463,7 @@ void sub_81AC644(u8 unused) } else { - gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk820 = &gUnknown_08614046; gUnknown_0203CE54->unk828 = 1; } break; @@ -1378,7 +1476,7 @@ void sub_81AC644(u8 unused) { if (gUnknown_0203CE58.pocket == 4 || !sub_8122148(gSpecialVar_ItemId)) { - gUnknown_0203CE54->unk820 = gUnknown_08614046; + gUnknown_0203CE54->unk820 = &gUnknown_08614046; gUnknown_0203CE54->unk828 = 1; } else @@ -2213,7 +2311,7 @@ void setup_bag_menu_textboxes(void) copy_textbox_border_tile_patterns_to_vram(0, 10, -48); sub_819A2BC(-64, 1); LoadPalette(&gUnknown_0860F074, 0xF0, 0x20); - for (i = 0;i < 3; i++) + for (i = 0; i < 3; i++) { FillWindowPixelBuffer(i, 0); PutWindowTilemap(i); @@ -2222,7 +2320,7 @@ void setup_bag_menu_textboxes(void) schedule_bg_copy_tilemap_to_vram(1); } -void bag_menu_print(u8 a, u8 b, u8 *str, u8 c, u8 d, u8 e, u8 f, u8 g, u8 h) +void bag_menu_print(u8 a, u8 b, const u8 *str, u8 c, u8 d, u8 e, u8 f, u8 g, u8 h) { AddTextPrinterParameterized2(a, b, c, d, e, f, gUnknown_08614164[h], g, str); } @@ -2278,7 +2376,7 @@ void bag_menu_RemoveBagItem_message_window(u8 a) } } -void bag_menu_yes_no(u8 a, u8 b, struct YesNoFuncTable *funcTable) +void bag_menu_yes_no(u8 a, u8 b, const struct YesNoFuncTable *funcTable) { CreateYesNoMenuWithCallbacks(a, &gUnknown_086141AC[b], 1, 0, 2, 1, 14, funcTable); } @@ -2310,12 +2408,12 @@ void PrintTMHMMoveData(u16 itemId) { u8 i; u16 moveId; - u8* text; + const u8* text; FillWindowPixelBuffer(4, 0); if (itemId == ITEM_NONE) { - for (i = 0;i < 4; i++) + for (i = 0; i < 4; i++) bag_menu_print(4, 1, gText_ThreeDashes, 7, i * 12, 0, 0, -1, 4); CopyWindowToVram(4, 2); } diff --git a/src/item_use.c b/src/item_use.c index 1fdd925ac..11dca12fb 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -114,7 +114,7 @@ void sub_80FE024(u8 taskId); void sub_80FE124(u8 taskId); void sub_80FE164(u8 taskId); -void DisplayItemMessage(u8 taskId, u8 a, u8* str, void(*callback)(u8 taskId)); +void DisplayItemMessage(u8 taskId, u8 a, const u8* str, void(*callback)(u8 taskId)); void DisplayItemMessageInBattlePyramid(u8 taskId, u8* str, void(*callback)(u8 taskId)); void DisplayItemMessageOnField(u8 taskId, u8* str, void(*callback)(u8 taskId)); void sub_81C6714(u8 taskId); From 511831ff1f026553793599320ed97e07ab851dea Mon Sep 17 00:00:00 2001 From: golem galvanize Date: Mon, 12 Feb 2018 14:06:52 -0500 Subject: [PATCH 12/12] fix const variable --- src/item_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/item_menu.c b/src/item_menu.c index 3c1b88cd7..b14ae403e 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -327,7 +327,7 @@ extern u8 gMoveNames[][0xD]; extern u8* gReturnToXStringsTable[]; extern u32 gUnknown_0203CE5E[]; extern u8 EventScript_2736B3[]; -extern u16 gUnknown_0860F074[]; +extern const u16 gUnknown_0860F074[]; extern struct BattleMove gBattleMoves[]; void ResetBagScrollPositions(void)