diff --git a/asm/battle_pyramid_bag.s b/asm/battle_pyramid_bag.s index ea07fdd0a..23ad7172e 100644 --- a/asm/battle_pyramid_bag.s +++ b/asm/battle_pyramid_bag.s @@ -5,3131 +5,8 @@ .text - thumb_func_start sub_81C5238 -sub_81C5238: @ 81C5238 - push {r4,lr} - sub sp, 0x4 - ldr r4, =gUnknown_0203CF2C - ldr r0, [r4] - ldr r1, =0x00000984 - adds r0, r1 - movs r1, 0 - ldrsh r0, [r0, r1] - cmp r0, 0x4 - bhi _081C52F0 - lsls r0, 2 - ldr r1, =_081C5264 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081C5264: - .4byte _081C5278 - .4byte _081C5294 - .4byte _081C52B8 - .4byte _081C52C8 - .4byte _081C52D4 -_081C5278: - 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 _081C52D8 - .pool -_081C5294: - bl free_temp_tile_data_buffers_if_possible - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081C5308 - ldr r0, =gUnknown_08D9AE04 - ldr r4, =gUnknown_0203CF2C - ldr r1, [r4] - adds r1, 0x4 - bl LZDecompressWram - ldr r1, [r4] - b _081C52DC - .pool -_081C52B8: - ldr r0, =gUnknown_08D9AF44 - movs r1, 0 - movs r2, 0x20 - bl LoadCompressedPalette - b _081C52D8 - .pool -_081C52C8: - ldr r0, =gUnknown_0861F3CC - bl LoadCompressedObjectPic - b _081C52D8 - .pool -_081C52D4: - bl sub_81C6E98 -_081C52D8: - ldr r0, =gUnknown_0203CF2C - ldr r1, [r0] -_081C52DC: - ldr r0, =0x00000984 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x1 - strh r0, [r1] - b _081C5308 - .pool -_081C52F0: - bl LoadListMenuArrowsGfx - ldr r0, [r4] - ldr r1, =0x00000984 - adds r0, r1 - movs r1, 0 - strh r1, [r0] - movs r0, 0x1 - b _081C530A - .pool -_081C5308: - movs r0, 0 -_081C530A: - add sp, 0x4 - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81C5238 - thumb_func_start sub_81C5314 -sub_81C5314: @ 81C5314 - push {r4-r7,lr} - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r1, =0x00000ca9 - adds r0, r2, r1 - ldrb r1, [r0] - lsls r1, 30 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - ldr r3, =0x00000e2c - adds r0, r3 - adds r7, r2, r0 - movs r6, 0 - ldr r1, =gUnknown_0203CF2C - ldr r0, [r1] - ldr r4, =0x00000821 - adds r0, r4 - ldrb r0, [r0] - subs r0, 0x1 - cmp r6, r0 - bge _081C5382 - adds r5, r1, 0 -_081C5344: - lsls r1, r6, 1 - adds r4, r1, r6 - lsls r4, 3 - ldr r0, =0x0000087c - adds r4, r0 - ldr r0, [r5] - adds r0, r4 - adds r1, r7 - ldrh r1, [r1] - bl sub_81C540C - ldr r1, [r5] - lsls r2, r6, 3 - ldr r3, =0x00000824 - adds r0, r1, r3 - adds r0, r2 - adds r4, r1, r4 - str r4, [r0] - ldr r4, =0x00000828 - adds r0, r1, r4 - adds r0, r2 - str r6, [r0] - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =0x00000821 - adds r1, r0 - ldrb r0, [r1] - subs r0, 0x1 - cmp r6, r0 - blt _081C5344 -_081C5382: - ldr r5, =gUnknown_0203CF2C - lsls r4, r6, 1 - adds r4, r6 - lsls r4, 3 - ldr r1, =0x0000087c - adds r4, r1 - ldr r0, [r5] - adds r0, r4 - ldr r1, =gText_CloseBag - bl StringCopy - ldr r1, [r5] - lsls r2, r6, 3 - ldr r3, =0x00000824 - adds r0, r1, r3 - adds r0, r2 - adds r4, r1, r4 - str r4, [r0] - ldr r4, =0x00000828 - adds r1, r4 - adds r1, r2 - movs r0, 0x2 - negs r0, r0 - str r0, [r1] - ldr r2, =gMultiuseListMenuTemplate - adds r1, r2, 0 - ldr r0, =gUnknown_0861F2C0 - ldm r0!, {r4,r6,r7} - stm r1!, {r4,r6,r7} - ldm r0!, {r4,r6,r7} - stm r1!, {r4,r6,r7} - ldr r1, [r5] - ldr r6, =0x00000821 - adds r0, r1, r6 - ldrb r0, [r0] - strh r0, [r2, 0xC] - adds r3, r1, r3 - str r3, [r2] - ldr r7, =0x00000822 - adds r1, r7 - ldrb r0, [r1] - strh r0, [r2, 0xE] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5314 - thumb_func_start sub_81C540C -sub_81C540C: @ 81C540C - push {r4,r5,lr} - adds r5, r0, 0 - lsls r1, 16 - lsrs r4, r1, 16 - adds r0, r4, 0 - bl ItemId_GetPocket - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x4 - bne _081C5450 - ldr r0, =gStringVar1 - adds r1, r4, 0 - subs r1, 0x84 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r1, =gStringVar2 - adds r0, r4, 0 - bl CopyItemName - ldr r1, =gText_UnkF908Var1Clear7Var2 - adds r0, r5, 0 - bl StringExpandPlaceholders - b _081C5458 - .pool -_081C5450: - adds r0, r4, 0 - adds r1, r5, 0 - bl CopyItemName -_081C5458: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81C540C - - thumb_func_start sub_81C5460 -sub_81C5460: @ 81C5460 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0x1 - beq _081C5476 - movs r0, 0x5 - bl PlaySE - bl sub_81C6F20 -_081C5476: - ldr r5, =gUnknown_0203CF2C - ldr r1, [r5] - ldr r2, =0x00000814 - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0xFF - bne _081C5504 - adds r2, 0x1 - adds r0, r1, r2 - ldrb r1, [r0] - movs r0, 0x1 - eors r0, r1 - bl sub_81C6FF8 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _081C54E0 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - lsls r3, r4, 1 - ldr r1, =0x00000ca9 - adds r0, r2, r1 - ldrb r1, [r0] - lsls r1, 30 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r3, r0 - ldr r0, =0x00000e2c - adds r2, r0 - adds r2, r3 - ldrh r0, [r2] - ldr r1, [r5] - ldr r2, =0x00000815 - adds r1, r2 - ldrb r1, [r1] - bl sub_81C6F90 - b _081C54EE - .pool -_081C54E0: - ldr r0, =0x0000ffff - ldr r1, [r5] - ldr r2, =0x00000815 - adds r1, r2 - ldrb r1, [r1] - bl sub_81C6F90 -_081C54EE: - ldr r0, =gUnknown_0203CF2C - ldr r1, [r0] - ldr r0, =0x00000815 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x1 - eors r0, r2 - strb r0, [r1] - adds r0, r4, 0 - bl sub_81C55D8 -_081C5504: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5460 - - thumb_func_start sub_81C5518 -sub_81C5518: @ 81C5518 - push {r4-r6,lr} - sub sp, 0x10 - adds r4, r1, 0 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r2, 24 - lsrs r5, r2, 24 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _081C55B8 - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r1, =0x00000814 - adds r0, r1 - ldrb r1, [r0] - cmp r1, 0xFF - beq _081C5560 - lsls r0, r4, 24 - lsrs r0, 24 - cmp r1, r0 - bne _081C5558 - adds r0, r5, 0 - movs r1, 0x1 - bl sub_81C5AB8 - b _081C5560 - .pool -_081C5558: - adds r0, r5, 0 - movs r1, 0xFF - bl sub_81C5AB8 -_081C5560: - ldr r0, =gStringVar1 - ldr r1, =gSaveBlock2Ptr - ldr r3, [r1] - ldr r2, =0x00000ca9 - adds r1, r3, r2 - ldrb r2, [r1] - lsls r2, 30 - lsrs r2, 30 - lsls r1, r2, 2 - adds r1, r2 - lsls r1, 1 - adds r1, r4, r1 - ldr r2, =0x00000e54 - adds r3, r2 - adds r3, r1 - ldrb r1, [r3] - 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 - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - movs r1, 0 - str r1, [sp] - str r1, [sp, 0x4] - movs r0, 0xFF - str r0, [sp, 0x8] - str r1, [sp, 0xC] - adds r0, r6, 0 - adds r1, r4, 0 - adds r3, r5, 0 - bl sub_81C6C94 -_081C55B8: - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5518 - - thumb_func_start sub_81C55D8 -sub_81C55D8: @ 81C55D8 - push {r4,lr} - sub sp, 0x10 - adds r3, r0, 0 - movs r0, 0x2 - negs r0, r0 - cmp r3, r0 - beq _081C561C - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - lsls r3, 1 - ldr r1, =0x00000ca9 - adds r0, r2, r1 - ldrb r1, [r0] - lsls r1, 30 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r3, r0 - ldr r0, =0x00000e2c - adds r2, r0 - adds r2, r3 - ldrh r0, [r2] - bl ItemId_GetDescription - adds r4, r0, 0 - b _081C5638 - .pool -_081C561C: - ldr r0, =gStringVar1 - ldr r2, =gReturnToXStringsTable2 - ldr r1, =gUnknown_0203CF30 - 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 -_081C5638: - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r1, 0 - str r1, [sp] - movs r0, 0x1 - str r0, [sp, 0x4] - str r1, [sp, 0x8] - str r1, [sp, 0xC] - adds r1, r4, 0 - movs r2, 0x3 - movs r3, 0 - bl sub_81C6C3C - add sp, 0x10 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C55D8 - - thumb_func_start sub_81C5674 -sub_81C5674: @ 81C5674 - push {r4,lr} - sub sp, 0x10 - ldr r4, =gUnknown_0203CF2C - ldr r1, [r4] - ldr r2, =0x00000816 - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0xFF - bne _081C56B4 - adds r2, 0xB - adds r0, r1, r2 - ldrb r0, [r0] - adds r2, 0x1 - adds r1, r2 - ldrb r1, [r1] - subs r0, r1 - str r0, [sp] - ldr r0, =0x00000b5e - str r0, [sp, 0x4] - str r0, [sp, 0x8] - ldr r0, =gUnknown_0203CF30+8 - str r0, [sp, 0xC] - movs r0, 0x2 - movs r1, 0xAC - movs r2, 0xC - movs r3, 0x94 - bl AddScrollIndicatorArrowPairParameterized - ldr r1, [r4] - ldr r2, =0x00000816 - adds r1, r2 - strb r0, [r1] -_081C56B4: - add sp, 0x10 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5674 - - thumb_func_start sub_81C56CC -sub_81C56CC: @ 81C56CC - push {r4,lr} - ldr r4, =gUnknown_0203CF2C - ldr r0, [r4] - ldr r2, =0x00000816 - adds r1, r0, r2 - ldrb r0, [r1] - cmp r0, 0xFF - beq _081C56EA - bl RemoveScrollIndicatorArrowPair - ldr r0, [r4] - ldr r1, =0x00000816 - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] -_081C56EA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C56CC - - thumb_func_start sub_81C56F8 -sub_81C56F8: @ 81C56F8 - push {r4,lr} - ldr r0, =sub_81C5BC8 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldr r0, =gMultiuseListMenuTemplate - ldr r2, =gUnknown_0203CF30 - ldrh r1, [r2, 0x8] - ldrh r2, [r2, 0x6] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C56F8 - - thumb_func_start sub_81C5738 -sub_81C5738: @ 81C5738 - push {r4-r6,lr} - mov r6, r8 - push {r6} - lsls r0, 24 - lsrs r0, 24 - lsls r1, 24 - lsrs r1, 24 - ldr r2, =gSaveBlock2Ptr - ldr r6, [r2] - ldr r3, =0x00000ca9 - adds r2, r6, r3 - ldrb r3, [r2] - lsls r3, 30 - lsrs r2, r3, 30 - lsls r4, r2, 2 - adds r4, r2 - lsls r4, 2 - ldr r2, =0x00000e2c - adds r4, r2 - adds r4, r6, r4 - lsrs r3, 30 - lsls r2, r3, 2 - adds r2, r3 - lsls r2, 1 - ldr r3, =0x00000e54 - adds r2, r3 - adds r6, r2 - lsls r5, r0, 1 - adds r5, r4 - ldrh r2, [r5] - mov r8, r2 - lsls r2, r1, 1 - adds r2, r4 - ldrh r3, [r2] - strh r3, [r5] - mov r3, r8 - strh r3, [r2] - adds r0, r6, r0 - ldrb r2, [r0] - adds r6, r1 - ldrb r1, [r6] - strb r1, [r0] - strb r2, [r6] - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5738 - - thumb_func_start sub_81C57A8 -sub_81C57A8: @ 81C57A8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r4, r0, 24 - adds r7, r4, 0 - lsls r1, 24 - lsrs r5, r1, 24 - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r1, =0x00000ca9 - adds r0, r3, r1 - ldrb r1, [r0] - lsls r1, 30 - lsrs r2, r1, 30 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 2 - ldr r2, =0x00000e2c - adds r0, r2 - adds r6, r3, r0 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 1 - ldr r1, =0x00000e54 - adds r0, r1 - adds r3, r0 - cmp r4, r5 - beq _081C5862 - lsls r0, r4, 1 - adds r0, r6 - ldrh r0, [r0] - mov r12, r0 - adds r0, r3, r4 - ldrb r0, [r0] - mov r8, r0 - cmp r5, r4 - bls _081C5830 - subs r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r2, r4, 16 - cmp r4, r5 - bge _081C5854 -_081C5802: - asrs r2, 16 - lsls r0, r2, 1 - adds r0, r6 - ldrh r1, [r0, 0x2] - strh r1, [r0] - adds r1, r3, r2 - ldrb r0, [r1, 0x1] - strb r0, [r1] - adds r2, 0x1 - lsls r2, 16 - asrs r0, r2, 16 - cmp r0, r5 - blt _081C5802 - b _081C5854 - .pool -_081C5830: - lsls r2, r7, 16 - cmp r7, r5 - ble _081C5854 -_081C5836: - asrs r2, 16 - lsls r1, r2, 1 - adds r1, r6 - subs r0, r1, 0x2 - ldrh r0, [r0] - strh r0, [r1] - adds r1, r3, r2 - subs r0, r1, 0x1 - ldrb r0, [r0] - strb r0, [r1] - subs r2, 0x1 - lsls r2, 16 - asrs r0, r2, 16 - cmp r0, r5 - bgt _081C5836 -_081C5854: - lsls r0, r5, 1 - adds r0, r6 - mov r2, r12 - strh r2, [r0] - adds r0, r3, r5 - mov r1, r8 - strb r1, [r0] -_081C5862: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81C57A8 - - thumb_func_start sub_81C586C -sub_81C586C: @ 81C586C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - ldr r1, =0x00000ca9 - adds r0, r3, r1 - ldrb r1, [r0] - lsls r1, 30 - lsrs r2, r1, 30 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 2 - ldr r2, =0x00000e2c - adds r0, r2 - adds r0, r3 - mov r9, r0 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 1 - ldr r4, =0x00000e54 - adds r0, r4 - adds r3, r0 - mov r8, r3 - movs r5, 0 - movs r3, 0 -_081C58A4: - lsls r0, r5, 1 - mov r1, r9 - adds r2, r0, r1 - ldrh r0, [r2] - mov r4, r8 - adds r1, r4, r5 - cmp r0, 0 - beq _081C58BA - ldrb r0, [r1] - cmp r0, 0 - bne _081C58BE -_081C58BA: - strh r3, [r2] - strb r3, [r1] -_081C58BE: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x9 - bls _081C58A4 - movs r5, 0 -_081C58CA: - adds r1, r5, 0x1 - lsls r0, r1, 24 - lsrs r4, r0, 24 - adds r7, r1, 0 - cmp r4, 0x9 - bhi _081C58FE - lsls r0, r5, 1 - mov r1, r9 - adds r6, r0, r1 -_081C58DC: - ldrh r0, [r6] - cmp r0, 0 - beq _081C58EC - mov r2, r8 - adds r0, r2, r5 - ldrb r0, [r0] - cmp r0, 0 - bne _081C58F4 -_081C58EC: - adds r0, r5, 0 - adds r1, r4, 0 - bl sub_81C5738 -_081C58F4: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x9 - bls _081C58DC -_081C58FE: - lsls r0, r7, 24 - lsrs r5, r0, 24 - cmp r5, 0x8 - bls _081C58CA - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C586C - - thumb_func_start sub_81C5924 -sub_81C5924: @ 81C5924 - push {r4-r6,lr} - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - ldr r1, =0x00000ca9 - adds r0, r2, r1 - ldrb r1, [r0] - lsls r1, 30 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - ldr r1, =0x00000e2c - adds r0, r1 - adds r5, r2, r0 - bl sub_81C586C - ldr r3, =gUnknown_0203CF2C - ldr r0, [r3] - ldr r2, =0x00000821 - adds r0, r2 - movs r1, 0 - strb r1, [r0] - movs r4, 0 - adds r6, r3, 0 -_081C5954: - lsls r0, r4, 1 - adds r0, r5 - ldrh r0, [r0] - ldr r3, =gUnknown_0203CF2C - cmp r0, 0 - beq _081C596A - ldr r1, [r6] - adds r1, r2 - ldrb r0, [r1] - adds r0, 0x1 - strb r0, [r1] -_081C596A: - adds r0, r4, 0x1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0x9 - bls _081C5954 - ldr r0, [r3] - ldr r2, =0x00000821 - adds r0, r2 - ldrb r1, [r0] - adds r1, 0x1 - strb r1, [r0] - ldr r0, [r3] - adds r2, r0, r2 - ldrb r2, [r2] - cmp r2, 0x8 - bls _081C59AC - ldr r2, =0x00000822 - adds r1, r0, r2 - movs r0, 0x8 - strb r0, [r1] - b _081C59B2 - .pool -_081C59AC: - ldr r1, =0x00000822 - adds r0, r1 - strb r2, [r0] -_081C59B2: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5924 - - thumb_func_start sub_81C59BC -sub_81C59BC: @ 81C59BC - push {r4,r5,lr} - ldr r0, =gUnknown_0203CF30 - ldrh r1, [r0, 0x8] - adds r3, r0, 0 - ldr r4, =gUnknown_0203CF2C - cmp r1, 0 - beq _081C59E4 - ldrh r0, [r3, 0x8] - ldr r1, [r4] - ldr r5, =0x00000822 - adds r2, r1, r5 - ldrb r2, [r2] - adds r0, r2 - subs r5, 0x1 - adds r1, r5 - ldrb r1, [r1] - cmp r0, r1 - ble _081C59E4 - subs r0, r1, r2 - strh r0, [r3, 0x8] -_081C59E4: - adds r2, r3, 0 - ldrh r1, [r2, 0x8] - ldrh r0, [r2, 0x6] - adds r1, r0 - ldr r0, [r4] - ldr r4, =0x00000821 - adds r0, r4 - ldrb r0, [r0] - cmp r1, r0 - blt _081C5A18 - adds r1, r0, 0 - cmp r1, 0 - bne _081C5A14 - strh r1, [r2, 0x6] - b _081C5A18 - .pool -_081C5A14: - subs r0, 0x1 - strh r0, [r3, 0x6] -_081C5A18: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81C59BC - - thumb_func_start sub_81C5A20 -sub_81C5A20: @ 81C5A20 - push {r4-r7,lr} - ldr r0, =gUnknown_0203CF30 - ldrh r1, [r0, 0x6] - adds r5, r0, 0 - cmp r1, 0x4 - bls _081C5A80 - movs r4, 0 - ldrh r0, [r5, 0x6] - subs r0, 0x4 - cmp r4, r0 - bgt _081C5A80 - ldrh r2, [r5, 0x8] - ldr r6, =gUnknown_0203CF2C - ldr r0, [r6] - ldr r3, =0x00000822 - adds r1, r0, r3 - ldrb r1, [r1] - adds r2, r1 - ldr r7, =0x00000821 - adds r0, r7 - ldrb r0, [r0] - cmp r2, r0 - beq _081C5A80 - adds r3, r5, 0 -_081C5A50: - ldrh r0, [r3, 0x6] - subs r0, 0x1 - strh r0, [r3, 0x6] - ldrh r0, [r3, 0x8] - adds r0, 0x1 - strh r0, [r3, 0x8] - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - ldrh r0, [r3, 0x6] - subs r0, 0x4 - cmp r4, r0 - bgt _081C5A80 - ldrh r2, [r5, 0x8] - ldr r1, [r6] - ldr r7, =0x00000822 - adds r0, r1, r7 - ldrb r0, [r0] - adds r2, r0 - ldr r0, =0x00000821 - adds r1, r0 - ldrb r1, [r1] - cmp r2, r1 - bne _081C5A50 -_081C5A80: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5A20 - - thumb_func_start sub_81C5A98 -sub_81C5A98: @ 81C5A98 - 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 sub_81C5AB8 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_81C5A98 - - thumb_func_start sub_81C5AB8 -sub_81C5AB8: @ 81C5AB8 - push {r4,r5,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r1, 24 - lsrs r2, r1, 24 - cmp r2, 0xFF - bne _081C5AF4 - 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 _081C5B08 -_081C5AF4: - ldr r1, =gText_SelectorArrow2 - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - str r0, [sp, 0x8] - str r2, [sp, 0xC] - movs r2, 0 - adds r3, r5, 0 - bl sub_81C6C3C -_081C5B08: - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5AB8 - - thumb_func_start sub_81C5B14 -sub_81C5B14: @ 81C5B14 - 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, =sub_81C5B4C - str r1, [r0] - add sp, 0x4 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5B14 - - thumb_func_start sub_81C5B4C -sub_81C5B4C: @ 81C5B4C - 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 _081C5BBC - ldrb r0, [r2] - ldr r4, =gUnknown_0203CF30+8 - subs r2, r4, 0x2 - adds r1, r4, 0 - bl DestroyListMenuTask - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r0, [r0] - cmp r0, 0 - beq _081C5B94 - bl SetMainCallback2 - b _081C5B9E - .pool -_081C5B94: - adds r0, r4, 0 - subs r0, 0x8 - ldr r0, [r0] - bl SetMainCallback2 -_081C5B9E: - bl sub_81C56CC - bl ResetSpriteData - bl FreeAllSpritePalettes - bl FreeAllWindowBuffers - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - bl Free - adds r0, r5, 0 - bl DestroyTask -_081C5BBC: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5B4C - - thumb_func_start sub_81C5BC8 -sub_81C5BC8: @ 81C5BC8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r7, r0, r1 - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081C5BEA - b _081C5D16 -_081C5BEA: - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _081C5BF8 - b _081C5D16 -_081C5BF8: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x4 - ands r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - cmp r4, 0 - beq _081C5C5C - ldr r4, =gUnknown_0203CF30 - ldrb r0, [r4, 0x4] - cmp r0, 0x2 - bne _081C5C12 - b _081C5D16 -_081C5C12: - ldrb r0, [r7] - adds r1, r4, 0 - adds r1, 0x8 - adds r2, r4, 0x6 - bl ListMenuGetScrollAndRow - ldrh r1, [r4, 0x8] - ldrh r0, [r4, 0x6] - adds r1, r0 - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r2, =0x00000821 - adds r0, r2 - ldrb r0, [r0] - subs r0, 0x1 - cmp r1, r0 - beq _081C5D16 - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_81C67CC - b _081C5D16 - .pool -_081C5C5C: - ldrb r0, [r7] - bl ListMenuHandleInputGetItemId - adds r6, r0, 0 - ldrb r0, [r7] - ldr r1, =gUnknown_0203CF30+8 - mov r8, r1 - mov r2, r8 - subs r2, 0x2 - bl ListMenuGetScrollAndRow - movs r0, 0x2 - negs r0, r0 - cmp r6, r0 - beq _081C5C88 - adds r0, 0x1 - cmp r6, r0 - bne _081C5CA0 - b _081C5D16 - .pool -_081C5C88: - movs r0, 0x5 - bl PlaySE - ldr r0, =gSpecialVar_ItemId - strh r4, [r0] - adds r0, r5, 0 - bl sub_81C5B14 - b _081C5D16 - .pool -_081C5CA0: - movs r0, 0x5 - bl PlaySE - ldr r2, =gSpecialVar_ItemId - mov r12, r2 - ldr r0, =gSaveBlock2Ptr - ldr r2, [r0] - lsls r3, r6, 1 - ldr r0, =0x00000ca9 - adds r4, r2, r0 - ldrb r1, [r4] - lsls r1, 30 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r3, r0 - ldr r1, =0x00000e2c - adds r0, r2, r1 - adds r0, r3 - ldrh r0, [r0] - mov r1, r12 - strh r0, [r1] - strh r6, [r7, 0x2] - ldrb r1, [r4] - lsls r1, 30 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 1 - adds r0, r6, r0 - ldr r1, =0x00000e54 - adds r2, r1 - adds r2, r0 - ldrb r0, [r2] - strh r0, [r7, 0x4] - mov r0, r8 - subs r0, 0x8 - ldrb r0, [r0, 0x4] - cmp r0, 0x2 - bne _081C5D10 - adds r0, r5, 0 - bl sub_81C674C - b _081C5D16 - .pool -_081C5D10: - adds r0, r5, 0 - bl sub_81C5D20 -_081C5D16: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81C5BC8 - - thumb_func_start sub_81C5D20 -sub_81C5D20: @ 81C5D20 - push {r4,r5,lr} - sub sp, 0x10 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r4, r5, 2 - adds r4, r5 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - bl sub_81C56CC - ldrb r0, [r4] - movs r1, 0x1 - bl sub_81C5A98 - ldr r0, =gUnknown_0203CF30 - ldrb r4, [r0, 0x4] - cmp r4, 0x1 - beq _081C5D74 - cmp r4, 0x3 - beq _081C5DC4 - ldr r0, =gUnknown_0203CF2C - ldr r1, [r0] - ldr r0, =0x00000818 - adds r2, r1, r0 - ldr r0, =gUnknown_0861F308 - str r0, [r2] - movs r0, 0x82 - lsls r0, 4 - adds r1, r0 - movs r0, 0x4 - b _081C5DD8 - .pool -_081C5D74: - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - bl ItemId_GetBattleUsage - lsls r0, 24 - cmp r0, 0 - beq _081C5DA0 - ldr r0, =gUnknown_0203CF2C - ldr r1, [r0] - ldr r0, =0x00000818 - adds r2, r1, r0 - ldr r0, =gUnknown_0861F30E - b _081C5DCE - .pool -_081C5DA0: - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r1, =0x00000818 - adds r2, r0, r1 - ldr r1, =gUnknown_0861F310 - str r1, [r2] - movs r1, 0x82 - lsls r1, 4 - adds r0, r1 - strb r4, [r0] - b _081C5DDA - .pool -_081C5DC4: - ldr r0, =gUnknown_0203CF2C - ldr r1, [r0] - ldr r0, =0x00000818 - adds r2, r1, r0 - ldr r0, =gUnknown_0861F30C -_081C5DCE: - str r0, [r2] - movs r0, 0x82 - lsls r0, 4 - adds r1, r0 - movs r0, 0x2 -_081C5DD8: - strb r0, [r1] -_081C5DDA: - 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 r1, 0 - str r1, [sp] - movs r0, 0x1 - str r0, [sp, 0x4] - str r1, [sp, 0x8] - str r1, [sp, 0xC] - adds r1, r4, 0 - movs r2, 0x3 - movs r3, 0 - bl sub_81C6C3C - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - movs r1, 0x82 - lsls r1, 4 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x1 - bne _081C5E3C - movs r0, 0 - b _081C5E42 - .pool -_081C5E3C: - cmp r0, 0x2 - bne _081C5E50 - movs r0, 0x1 -_081C5E42: - bl sub_81C6D24 - lsls r0, 24 - lsrs r0, 24 - bl sub_81C5EAC - b _081C5E62 -_081C5E50: - movs r0, 0x2 - bl sub_81C6D24 - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x2 - movs r2, 0x2 - bl sub_81C5F08 -_081C5E62: - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - movs r1, 0x82 - lsls r1, 4 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x4 - bne _081C5E8C - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_81C5FE4 - b _081C5E98 - .pool -_081C5E8C: - ldr r0, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_81C5F68 -_081C5E98: - str r0, [r1] - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5D20 - - thumb_func_start sub_81C5EAC -sub_81C5EAC: @ 81C5EAC - 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_0203CF2C - ldr r1, [r6] - movs r5, 0x82 - lsls r5, 4 - adds r0, r1, r5 - ldrb r0, [r0] - str r0, [sp, 0x8] - ldr r0, =gUnknown_0861F2D8 - str r0, [sp, 0xC] - ldr r0, =0x00000818 - 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_81C5EAC - - thumb_func_start sub_81C5F08 -sub_81C5F08: @ 81C5F08 - 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_0861F2D8 - str r0, [sp, 0xC] - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r1, =0x00000818 - 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_81C5F08 - - thumb_func_start sub_81C5F68 -sub_81C5F68: @ 81C5F68 - 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 _081C5FD0 - bl Menu_ProcessInputNoWrapAround - lsls r0, 24 - asrs r4, r0, 24 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _081C5FD0 - adds r0, 0x1 - cmp r4, r0 - bne _081C5FA8 - movs r0, 0x5 - bl PlaySE - ldr r0, =gUnknown_0861F2D8 - ldr r1, [r0, 0x1C] - adds r0, r5, 0 - bl _call_via_r1 - b _081C5FD0 - .pool -_081C5FA8: - movs r0, 0x5 - bl PlaySE - ldr r1, =gUnknown_0861F2D8 - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r2, =0x00000818 - adds r0, r2 - ldr r0, [r0] - adds r0, r4 - ldrb r0, [r0] - lsls r0, 3 - adds r1, 0x4 - adds r0, r1 - ldr r1, [r0] - cmp r1, 0 - beq _081C5FD0 - adds r0, r6, 0 - bl _call_via_r1 -_081C5FD0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5F68 - - thumb_func_start sub_81C5FE4 -sub_81C5FE4: @ 81C5FE4 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081C5FF8 - b _081C6160 -_081C5FF8: - 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 _081C6040 - lsls r0, r4, 24 - asrs r0, 24 - cmp r0, 0 - bgt _081C6016 - b _081C6160 -_081C6016: - subs r0, 0x2 - lsls r0, 24 - asrs r0, 24 - bl sub_81C616C - lsls r0, 24 - cmp r0, 0 - bne _081C6028 - b _081C6160 -_081C6028: - movs r0, 0x5 - bl PlaySE - movs r1, 0x1 - negs r1, r1 - movs r0, 0 - bl sub_8199134 - b _081C6160 - .pool -_081C6040: - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - beq _081C6084 - lsls r0, r4, 24 - asrs r1, r0, 24 - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - movs r2, 0x82 - lsls r2, 4 - adds r0, r2 - ldrb r0, [r0] - subs r0, 0x2 - cmp r1, r0 - blt _081C6060 - b _081C6160 -_081C6060: - adds r0, r1, 0x2 - lsls r0, 24 - asrs r0, 24 - bl sub_81C616C - lsls r0, 24 - cmp r0, 0 - beq _081C6160 - movs r0, 0x5 - bl PlaySE - movs r0, 0 - movs r1, 0x1 - bl sub_8199134 - b _081C6160 - .pool -_081C6084: - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - bne _081C6098 - bl GetLRKeysState - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081C60C0 -_081C6098: - lsls r0, r4, 24 - asrs r1, r0, 24 - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081C6160 - subs r0, r1, 0x1 - lsls r0, 24 - asrs r0, 24 - bl sub_81C616C - lsls r0, 24 - cmp r0, 0 - beq _081C6160 - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 - negs r0, r0 - b _081C60FA -_081C60C0: - ldrh r1, [r5, 0x2E] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - bne _081C60D6 - bl GetLRKeysState - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x2 - bne _081C6102 -_081C60D6: - lsls r0, r4, 24 - asrs r1, r0, 24 - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - bne _081C6160 - adds r0, r1, 0x1 - lsls r0, 24 - asrs r0, 24 - bl sub_81C616C - lsls r0, 24 - cmp r0, 0 - beq _081C6160 - movs r0, 0x5 - bl PlaySE - movs r0, 0x1 -_081C60FA: - movs r1, 0 - bl sub_8199134 - b _081C6160 -_081C6102: - ldrh r1, [r5, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081C6148 - movs r0, 0x5 - bl PlaySE - ldr r2, =gUnknown_0861F2D8 - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - lsls r1, r4, 24 - asrs r1, 24 - ldr r3, =0x00000818 - adds r0, r3 - ldr r0, [r0] - adds r0, r1 - ldrb r0, [r0] - lsls r0, 3 - adds r2, 0x4 - adds r0, r2 - ldr r1, [r0] - cmp r1, 0 - beq _081C6160 - adds r0, r6, 0 - bl _call_via_r1 - b _081C6160 - .pool -_081C6148: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081C6160 - movs r0, 0x5 - bl PlaySE - ldr r0, =gUnknown_0861F2D8 - ldr r1, [r0, 0x1C] - adds r0, r6, 0 - bl _call_via_r1 -_081C6160: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C5FE4 - - thumb_func_start sub_81C616C -sub_81C616C: @ 81C616C - push {lr} - lsls r0, 24 - asrs r1, r0, 24 - cmp r1, 0 - blt _081C61A0 - ldr r0, =gUnknown_0203CF2C - ldr r2, [r0] - movs r3, 0x82 - lsls r3, 4 - adds r0, r2, r3 - ldrb r0, [r0] - cmp r1, r0 - bgt _081C61A0 - ldr r3, =0x00000818 - adds r0, r2, r3 - ldr r0, [r0] - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x5 - beq _081C61A0 - movs r0, 0x1 - b _081C61A2 - .pool -_081C61A0: - movs r0, 0 -_081C61A2: - pop {r1} - bx r1 - thumb_func_end sub_81C616C - - thumb_func_start sub_81C61A8 -sub_81C61A8: @ 81C61A8 - push {lr} - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - movs r1, 0x82 - lsls r1, 4 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0x1 - bne _081C61C8 - movs r0, 0 - bl sub_81C6D6C - b _081C61DA - .pool -_081C61C8: - cmp r0, 0x2 - bne _081C61D4 - movs r0, 0x1 - bl sub_81C6D6C - b _081C61DA -_081C61D4: - movs r0, 0x2 - bl sub_81C6D6C -_081C61DA: - pop {r0} - bx r0 - thumb_func_end sub_81C61A8 - - thumb_func_start sub_81C61E0 -sub_81C61E0: @ 81C61E0 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gSpecialVar_ItemId - ldrh r0, [r4] - bl ItemId_GetPocket - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x5 - beq _081C620C - cmp r0, 0x2 - beq _081C620C - cmp r0, 0x3 - beq _081C620C - ldrh r0, [r4] - bl ItemIsMail - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081C6228 -_081C620C: - bl sub_81C61A8 - ldr r1, =gText_DadsAdvice - ldr r2, =sub_81C6714 - adds r0, r5, 0 - bl DisplayItemMessageInBattlePyramid - b _081C6252 - .pool -_081C6228: - ldrh r0, [r4] - bl ItemId_GetFieldFunc - cmp r0, 0 - beq _081C6252 - bl sub_81C61A8 - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldrh r0, [r4] - bl ItemId_GetFieldFunc - adds r1, r0, 0 - adds r0, r5, 0 - bl _call_via_r1 -_081C6252: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81C61E0 - - thumb_func_start sub_81C6258 -sub_81C6258: @ 81C6258 - 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 sub_81C61A8 - movs r1, 0x2 - ldrsh r0, [r4, r1] - bl sub_81C55D8 - 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 sub_81C5A98 - adds r0, r5, 0 - bl sub_81C629C - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6258 - - thumb_func_start sub_81C629C -sub_81C629C: @ 81C629C - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl sub_81C5674 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_81C5BC8 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C629C - - thumb_func_start sub_81C62C4 -sub_81C62C4: @ 81C62C4 - push {r4-r7,lr} - sub sp, 0x10 - 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 sub_81C61A8 - movs r0, 0x1 - strh r0, [r4, 0x10] - movs r1, 0x4 - ldrsh r0, [r4, r1] - cmp r0, 0x1 - bne _081C62F4 - adds r0, r5, 0 - bl sub_81C6350 - b _081C6334 - .pool -_081C62F4: - 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 r1, 0 - str r1, [sp] - movs r0, 0x1 - str r0, [sp, 0x4] - str r1, [sp, 0x8] - str r1, [sp, 0xC] - adds r1, r4, 0 - movs r2, 0x3 - movs r3, 0 - bl sub_81C6C3C - bl sub_81C6404 - adds r0, r7, 0 - subs r0, 0x8 - adds r0, r6, r0 - ldr r1, =sub_81C64B4 - str r1, [r0] -_081C6334: - add sp, 0x10 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C62C4 - - thumb_func_start sub_81C6350 -sub_81C6350: @ 81C6350 - push {r4,r5,lr} - sub sp, 0x10 - 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, 0x2 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_ConfirmTossItems - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r1, 0 - str r1, [sp] - movs r0, 0x1 - str r0, [sp, 0x4] - str r1, [sp, 0x8] - str r1, [sp, 0xC] - adds r1, r4, 0 - movs r2, 0x3 - movs r3, 0 - bl sub_81C6C3C - ldr r1, =gUnknown_0861F314 - adds r0, r5, 0 - bl sub_81C6DAC - add sp, 0x10 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6350 - - thumb_func_start sub_81C63D0 -sub_81C63D0: @ 81C63D0 - 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 sub_81C55D8 - ldrb r0, [r4] - movs r1, 0 - bl sub_81C5A98 - adds r0, r5, 0 - bl sub_81C629C - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C63D0 - - thumb_func_start sub_81C6404 -sub_81C6404: @ 81C6404 - push {r4,lr} - sub sp, 0xC - ldr r0, =gStringVar1 - movs r1, 0x1 - movs r2, 0x2 - movs r3, 0x2 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_xVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x3 - bl sub_81C6CEC - 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] - movs r0, 0x3 - movs r1, 0x1 - adds r2, r4, 0 - bl PrintTextOnWindow - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6404 - - thumb_func_start sub_81C645C -sub_81C645C: @ 81C645C - push {r4,lr} - sub sp, 0xC - adds r1, r0, 0 - ldr r0, =gStringVar1 - lsls r1, 16 - asrs r1, 16 - movs r2, 0x2 - movs r3, 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] - movs r0, 0x3 - movs r1, 0x1 - adds r2, r4, 0 - bl PrintTextOnWindow - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C645C - - thumb_func_start sub_81C64B4 -sub_81C64B4: @ 81C64B4 - 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 _081C64E8 - movs r1, 0x10 - ldrsh r0, [r4, r1] - bl sub_81C645C - b _081C6544 - .pool -_081C64E8: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081C651C - movs r0, 0x5 - bl PlaySE - movs r0, 0x3 - movs r1, 0 - bl sub_8198070 - movs r0, 0x3 - bl ClearWindowTilemap - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - adds r0, r5, 0 - bl sub_81C6350 - b _081C6544 - .pool -_081C651C: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _081C6544 - movs r0, 0x5 - bl PlaySE - movs r0, 0x3 - movs r1, 0 - bl sub_8198070 - movs r0, 0x3 - bl ClearWindowTilemap - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - adds r0, r6, 0 - bl sub_81C63D0 -_081C6544: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81C64B4 - - thumb_func_start sub_81C654C -sub_81C654C: @ 81C654C - push {r4-r6,lr} - sub sp, 0x10 - 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, 0x2 - bl ConvertIntToDecimalStringN - ldr r6, =gStringVar4 - ldr r1, =gText_ThrewAwayVar2Var1s - adds r0, r6, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - movs r1, 0 - str r1, [sp] - movs r0, 0x1 - str r0, [sp, 0x4] - str r1, [sp, 0x8] - str r1, [sp, 0xC] - adds r1, r6, 0 - movs r2, 0x3 - movs r3, 0 - bl sub_81C6C3C - subs r5, 0x8 - adds r4, r5 - ldr r0, =sub_81C65CC - str r0, [r4] - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C654C - - thumb_func_start sub_81C65CC -sub_81C65CC: @ 81C65CC - push {r4-r7,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 r6, =gUnknown_0203CF30+8 - subs r7, r6, 0x2 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _081C662E - movs r0, 0x5 - bl PlaySE - ldr r0, =gSpecialVar_ItemId - ldrh r0, [r0] - ldrh r1, [r4, 0x10] - bl RemovePyramidBagItem - ldrb r0, [r4] - adds r1, r6, 0 - adds r2, r7, 0 - bl DestroyListMenuTask - bl sub_81C5924 - bl sub_81C59BC - bl sub_81C5314 - ldr r0, =gMultiuseListMenuTemplate - ldrh r1, [r6] - ldrh r2, [r7] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - adds r0, r5, 0 - bl sub_81C629C -_081C662E: - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C65CC - - thumb_func_start sub_81C6648 -sub_81C6648: @ 81C6648 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - bl sub_81C61A8 - ldr r5, =gSpecialVar_ItemId - ldrh r0, [r5] - bl ItemIsMail - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _081C667C - ldr r1, =gText_CantWriteMail - ldr r2, =sub_81C66EC - adds r0, r4, 0 - bl DisplayItemMessageInBattlePyramid - b _081C66A6 - .pool -_081C667C: - ldrh r0, [r5] - bl ItemId_GetImportance - lsls r0, 24 - cmp r0, 0 - bne _081C66A0 - ldr r0, =gUnknown_0203CF2C - ldr r1, [r0] - ldr r0, =sub_81B7F60 - str r0, [r1] - adds r0, r4, 0 - bl sub_81C5B14 - b _081C66A6 - .pool -_081C66A0: - adds r0, r6, 0 - bl sub_81C66AC -_081C66A6: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81C6648 - - thumb_func_start sub_81C66AC -sub_81C66AC: @ 81C66AC - 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 r2, =sub_81C66EC - adds r0, r4, 0 - adds r1, r5, 0 - bl DisplayItemMessageInBattlePyramid - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C66AC - - thumb_func_start sub_81C66EC -sub_81C66EC: @ 81C66EC - 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 _081C670A - movs r0, 0x5 - bl PlaySE - adds r0, r4, 0 - bl sub_81C6714 -_081C670A: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C66EC - - thumb_func_start sub_81C6714 -sub_81C6714: @ 81C6714 - 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 sub_81C6E1C - movs r1, 0x2 - ldrsh r0, [r4, r1] - bl sub_81C55D8 - ldrb r0, [r4] - movs r1, 0 - bl sub_81C5A98 - adds r0, r5, 0 - bl sub_81C629C - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6714 - - thumb_func_start sub_81C674C -sub_81C674C: @ 81C674C - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - ldr r5, =gSpecialVar_ItemId - ldrh r0, [r5] - bl itemid_80BF6D8_mail_related - lsls r0, 24 - cmp r0, 0 - bne _081C677C - ldr r1, =gText_CantWriteMail - ldr r2, =sub_81C66EC - adds r0, r4, 0 - bl DisplayItemMessageInBattlePyramid - b _081C6796 - .pool -_081C677C: - ldrh r0, [r5] - bl ItemId_GetImportance - lsls r0, 24 - cmp r0, 0 - bne _081C6790 - adds r0, r4, 0 - bl sub_81C5B14 - b _081C6796 -_081C6790: - adds r0, r6, 0 - bl sub_81C66AC -_081C6796: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_81C674C - - thumb_func_start sub_81C679C -sub_81C679C: @ 81C679C - 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 _081C67C0 - bl sub_81C61A8 - ldrh r0, [r4] - bl ItemId_GetBattleFunc - adds r1, r0, 0 - adds r0, r5, 0 - bl _call_via_r1 -_081C67C0: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C679C - - thumb_func_start sub_81C67CC -sub_81C67CC: @ 81C67CC - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0x10 - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - mov r9, r0 - adds r5, r4, r0 - ldr r0, =gUnknown_0203CF30 - ldrh r1, [r0, 0x6] - ldrh r0, [r0, 0x8] - adds r1, r0 - strh r1, [r5, 0x2] - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r2, =0x00000814 - adds r0, r2 - movs r2, 0 - mov r8, r2 - strb r1, [r0] - ldrb r0, [r5] - movs r1, 0x10 - movs r2, 0x1 - bl ListMenuSetUnkIndicatorsStructField - ldr r0, =gSaveBlock2Ptr - ldr r3, [r0] - movs r0, 0x2 - ldrsh r2, [r5, r0] - lsls r2, 1 - ldr r1, =0x00000ca9 - adds r0, r3, r1 - ldrb r1, [r0] - lsls r1, 30 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r2, r0 - ldr r0, =0x00000e2c - adds r3, r0 - adds r3, r2 - ldrh r0, [r3] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r6, =gStringVar4 - ldr r1, =gText_MoveVar1Where - adds r0, r6, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - movs r1, 0 - bl FillWindowPixelBuffer - mov r1, r8 - str r1, [sp] - movs r0, 0x1 - str r0, [sp, 0x4] - str r1, [sp, 0x8] - str r1, [sp, 0xC] - adds r1, r6, 0 - movs r2, 0x3 - movs r3, 0 - bl sub_81C6C3C - ldrb r0, [r5] - movs r1, 0x1 - bl sub_81C5A98 - ldrb r0, [r5, 0x2] - bl sub_81C704C - movs r2, 0x8 - negs r2, r2 - add r9, r2 - add r4, r9 - ldr r0, =sub_81C68B0 - str r0, [r4] - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C67CC - - thumb_func_start sub_81C68B0 -sub_81C68B0: @ 81C68B0 - push {r4-r7,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 - bl sub_81221EC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - beq _081C695C - ldr r7, =gMain - ldrh r1, [r7, 0x2E] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _081C68F8 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4] - ldr r1, =gUnknown_0203CF30+8 - subs r2, r1, 0x2 - bl ListMenuGetScrollAndRow - b _081C6940 - .pool -_081C68F8: - ldrb r0, [r4] - bl ListMenuHandleInputGetItemId - adds r6, r0, 0 - ldrb r0, [r4] - ldr r4, =gUnknown_0203CF30+8 - subs r2, r4, 0x2 - adds r1, r4, 0 - bl ListMenuGetScrollAndRow - movs r0, 0 - bl sub_81C7028 - subs r4, 0x8 - ldrb r0, [r4, 0x6] - bl sub_81C704C - movs r0, 0x2 - negs r0, r0 - cmp r6, r0 - beq _081C6930 - adds r0, 0x1 - cmp r6, r0 - bne _081C6950 - b _081C695C - .pool -_081C6930: - movs r0, 0x5 - bl PlaySE - ldrh r1, [r7, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _081C6948 -_081C6940: - adds r0, r5, 0 - bl sub_81C6964 - b _081C695C -_081C6948: - adds r0, r5, 0 - bl sub_81C6A14 - b _081C695C -_081C6950: - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_81C6964 -_081C695C: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81C68B0 - - thumb_func_start sub_81C6964 -sub_81C6964: @ 81C6964 - 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 r7, =gUnknown_0203CF30+8 - subs r0, r7, 0x2 - mov r8, r0 - ldrh r0, [r0] - ldrh r1, [r7] - adds r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - movs r3, 0x2 - ldrsh r1, [r5, r3] - cmp r1, r4 - beq _081C6996 - subs r0, r4, 0x1 - cmp r1, r0 - bne _081C69A8 -_081C6996: - adds r0, r6, 0 - bl sub_81C6A14 - b _081C69FC - .pool -_081C69A8: - ldrb r0, [r5, 0x2] - lsls r1, r4, 24 - lsrs r1, 24 - bl sub_81C57A8 - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r1, =0x00000814 - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - movs r0, 0x1 - bl sub_81C7028 - ldrb r0, [r5] - adds r1, r7, 0 - mov r2, r8 - bl DestroyListMenuTask - movs r3, 0x2 - ldrsh r0, [r5, r3] - cmp r0, r4 - bge _081C69E0 - adds r1, r7, 0 - subs r1, 0x8 - ldrh r0, [r1, 0x6] - subs r0, 0x1 - strh r0, [r1, 0x6] -_081C69E0: - bl sub_81C5314 - ldr r0, =gMultiuseListMenuTemplate - ldrh r1, [r7] - mov r3, r8 - ldrh r2, [r3] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5] - adds r0, r6, 0 - bl sub_81C629C -_081C69FC: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6964 - - thumb_func_start sub_81C6A14 -sub_81C6A14: @ 81C6A14 - push {r4-r7,lr} - lsls r0, 24 - lsrs r0, 24 - adds r6, r0, 0 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - ldr r5, =gUnknown_0203CF30+8 - subs r7, r5, 0x2 - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r1, =0x00000814 - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - movs r0, 0x1 - bl sub_81C7028 - ldrb r0, [r4] - adds r1, r5, 0 - adds r2, r7, 0 - bl DestroyListMenuTask - movs r0, 0x2 - ldrsh r2, [r4, r0] - ldrh r0, [r5] - ldrh r1, [r7] - adds r0, r1 - cmp r2, r0 - bge _081C6A5E - adds r1, r5, 0 - subs r1, 0x8 - ldrh r0, [r1, 0x6] - subs r0, 0x1 - strh r0, [r1, 0x6] -_081C6A5E: - bl sub_81C5314 - ldr r0, =gMultiuseListMenuTemplate - ldrh r1, [r5] - ldrh r2, [r7] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4] - adds r0, r6, 0 - bl sub_81C629C - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6A14 - - thumb_func_start sub_81C6A94 -sub_81C6A94: @ 81C6A94 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x4 - ldr r0, =gPlayerParty - mov r9, r0 - movs r0, 0x14 - bl Alloc - adds r7, r0, 0 - movs r0, 0xA - bl Alloc - adds r5, r0, 0 - ldr r1, =gSaveBlock2Ptr - mov r8, r1 - ldr r2, [r1] - ldr r4, =0x00000ca9 - adds r0, r2, r4 - ldrb r0, [r0] - lsls r0, 30 - lsrs r0, 30 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldr r0, =0x00000e2c - adds r1, r0 - adds r0, r7, 0 - movs r2, 0x14 - bl memcpy - mov r1, r8 - ldr r2, [r1] - adds r0, r2, r4 - ldrb r0, [r0] - lsls r0, 30 - lsrs r0, 30 - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 1 - adds r1, r2 - ldr r0, =0x00000e54 - adds r1, r0 - adds r0, r5, 0 - movs r2, 0xA - bl memcpy - movs r6, 0 -_081C6AF8: - movs r0, 0x64 - muls r0, r6 - add r0, r9 - movs r1, 0xC - bl GetMonData - lsls r0, 16 - lsrs r0, 16 - mov r1, sp - strh r0, [r1] - cmp r0, 0 - beq _081C6B88 - movs r1, 0x1 - bl AddBagItem - lsls r0, 24 - cmp r0, 0 - bne _081C6B88 - mov r1, r8 - ldr r2, [r1] - adds r0, r2, r4 - ldrb r1, [r0] - lsls r1, 30 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldr r1, =0x00000e2c - adds r0, r1 - adds r1, r7, 0 - movs r2, 0x14 - bl memcpy - mov r0, r8 - ldr r2, [r0] - adds r0, r2, r4 - ldrb r1, [r0] - lsls r1, 30 - lsrs r1, 30 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 1 - adds r0, r2 - ldr r1, =0x00000e54 - adds r0, r1 - adds r1, r5, 0 - movs r2, 0xA - bl memcpy - adds r0, r7, 0 - bl Free - adds r0, r5, 0 - bl Free - ldr r1, =gSpecialVar_Result - movs r0, 0x1 - strh r0, [r1] - b _081C6BC6 - .pool -_081C6B88: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x2 - bls _081C6AF8 - movs r1, 0 - mov r0, sp - strh r1, [r0] - movs r6, 0 - movs r4, 0x64 -_081C6B9C: - adds r0, r6, 0 - muls r0, r4 - add r0, r9 - movs r1, 0xC - mov r2, sp - bl SetMonData - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0x2 - bls _081C6B9C - ldr r1, =gSpecialVar_Result - movs r0, 0 - strh r0, [r1] - adds r0, r7, 0 - bl Free - adds r0, r5, 0 - bl Free -_081C6BC6: - add sp, 0x4 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6A94 - - thumb_func_start sub_81C6BD8 -sub_81C6BD8: @ 81C6BD8 - push {r4,lr} - ldr r0, =gUnknown_0861F328 - bl InitWindows - bl DeactivateAllTextPrinters - movs r0, 0 - movs r1, 0x1 - movs r2, 0xE0 - bl LoadUserWindowBorderGfx - movs r0, 0 - movs r1, 0xA - movs r2, 0xD0 - bl LoadMessageBoxGfx - ldr r0, =gUnknown_0860F074 - movs r1, 0xF0 - movs r2, 0x20 - bl LoadPalette - movs r4, 0 -_081C6C04: - adds r0, r4, 0 - movs r1, 0 - bl FillWindowPixelBuffer - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x4 - bls _081C6C04 - movs r0, 0 - bl PutWindowTilemap - movs r0, 0x1 - bl PutWindowTilemap - 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 sub_81C6BD8 - - thumb_func_start sub_81C6C3C -sub_81C6C3C: @ 81C6C3C - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x14 - ldr r4, [sp, 0x28] - ldr r6, [sp, 0x2C] - ldr r5, [sp, 0x30] - mov r8, r5 - ldr r5, [sp, 0x34] - lsls r0, 24 - lsrs r0, 24 - lsls r2, 24 - lsrs r2, 24 - 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_0861F31C - adds r4, r5 - str r4, [sp, 0x8] - mov r4, r8 - lsls r4, 24 - asrs r4, 24 - str r4, [sp, 0xC] - str r1, [sp, 0x10] - movs r1, 0x1 - bl AddTextPrinterParameterized2 - add sp, 0x14 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6C3C - - thumb_func_start sub_81C6C94 -sub_81C6C94: @ 81C6C94 - push {r4-r6,lr} - mov r6, r8 - push {r6} - sub sp, 0x14 - ldr r4, [sp, 0x28] - ldr r6, [sp, 0x2C] - ldr r5, [sp, 0x30] - mov r8, r5 - ldr r5, [sp, 0x34] - lsls r0, 24 - lsrs r0, 24 - lsls r2, 24 - lsrs r2, 24 - 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_0861F31C - adds r4, r5 - str r4, [sp, 0x8] - mov r4, r8 - lsls r4, 24 - asrs r4, 24 - str r4, [sp, 0xC] - str r1, [sp, 0x10] - movs r1, 0x7 - bl AddTextPrinterParameterized2 - add sp, 0x14 - pop {r3} - mov r8, r3 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6C94 - - thumb_func_start sub_81C6CEC -sub_81C6CEC: @ 81C6CEC - push {lr} - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - movs r2, 0x1 - movs r3, 0xE - bl SetWindowBorderStyle - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - pop {r0} - bx r0 - thumb_func_end sub_81C6CEC - - thumb_func_start sub_81C6D08 -sub_81C6D08: @ 81C6D08 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203CF2C - ldr r1, [r1] - ldr r2, =0x0000080f - adds r1, r2 - adds r1, r0 - ldrb r0, [r1] - bx lr - .pool - thumb_func_end sub_81C6D08 - - thumb_func_start sub_81C6D24 -sub_81C6D24: @ 81C6D24 - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0203CF2C - ldr r3, =0x0000080f - adds r1, r2, r3 - ldr r0, [r0] - adds r4, r0, r1 - ldrb r0, [r4] - cmp r0, 0xFF - bne _081C6D58 - lsls r0, r2, 3 - ldr r1, =gUnknown_0861F350 - 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 -_081C6D58: - ldrb r0, [r4] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81C6D24 - - thumb_func_start sub_81C6D6C -sub_81C6D6C: @ 81C6D6C - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203CF2C - ldr r2, =0x0000080f - adds r0, r2 - ldr r1, [r1] - adds r4, r1, r0 - ldrb r0, [r4] - cmp r0, 0xFF - beq _081C6D9E - 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] -_081C6D9E: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6D6C thumb_func_start sub_81C6DAC sub_81C6DAC: @ 81C6DAC @@ -3353,8 +230,8 @@ _081C6F84: .pool thumb_func_end sub_81C6F68 - thumb_func_start sub_81C6F90 -sub_81C6F90: @ 81C6F90 + thumb_func_start ShowItemImage +ShowItemImage: @ 81C6F90 push {r4-r6,lr} lsls r0, 16 lsrs r6, r0, 16 @@ -3397,7 +274,7 @@ _081C6FE0: pop {r0} bx r0 .pool - thumb_func_end sub_81C6F90 + thumb_func_end ShowItemImage thumb_func_start sub_81C6FF8 sub_81C6FF8: @ 81C6FF8 diff --git a/include/global.h b/include/global.h index ab31e3c5d..0fff11d09 100644 --- a/include/global.h +++ b/include/global.h @@ -27,6 +27,13 @@ #define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0])) +#define SWAP(a, b, temp) \ +{ \ + temp = a; \ + a = b; \ + b = temp; \ +} + // useful math macros // Converts a number to Q8.8 fixed-point format diff --git a/include/item_use.h b/include/item_use.h index 7874f7ee9..8f0ce272b 100644 --- a/include/item_use.h +++ b/include/item_use.h @@ -1,8 +1,6 @@ #ifndef GUARD_ITEM_USE_H #define GUARD_ITEM_USE_H -extern u16 gSpecialVar_ItemId; - void ItemUseOutOfBattle_Mail(u8); void ItemUseOutOfBattle_Bike(u8); void ItemUseOnFieldCB_Bike(u8); @@ -53,5 +51,6 @@ void ItemUseInBattle_EnigmaBerry(u8); void ItemUseOutOfBattle_CannotUse(u8); u8 CheckIfItemIsTMHMOrEvolutionStone(u16 itemId); void sub_80FDD10(u8); +void DisplayItemMessageInBattlePyramid(u8 taskId, const u8* str, void(*callback)(u8 taskId)); #endif // GUARD_ITEM_USE_H diff --git a/include/list_menu.h b/include/list_menu.h index ee3d60f3d..84c38306b 100644 --- a/include/list_menu.h +++ b/include/list_menu.h @@ -11,7 +11,8 @@ #define LIST_MULTIPLE_SCROLL_DPAD 1 #define LIST_MULTIPLE_SCROLL_L_R 2 -enum { +enum +{ SCROLL_ARROW_LEFT, SCROLL_ARROW_RIGHT, SCROLL_ARROW_UP, diff --git a/include/menu.h b/include/menu.h index 8ead4ea08..a13fe73ec 100644 --- a/include/menu.h +++ b/include/menu.h @@ -66,9 +66,9 @@ 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); +void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8); +void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8); +u8 sub_8199944(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, u8 initialCursorPos); u8 sub_8199134(s8, s8); u8 GetStartMenuWindowId(void); void sub_819A2BC(u8, u8); diff --git a/include/strings.h b/include/strings.h index f88425b26..e72360563 100644 --- a/include/strings.h +++ b/include/strings.h @@ -776,6 +776,23 @@ extern const u8 gText_TeachWhichMoveToPkmn[]; extern const u8 gText_GiveUpTeachingNewMove[]; extern const u8 gText_TeachX[]; +extern const u8 gText_DadsAdvice[]; +extern const u8 gText_CantDismountBike[]; +extern const u8 gText_ItemFinderNothing[]; +extern const u8 gText_ItemFinderNearby[]; +extern const u8 gText_ItemFinderOnTop[]; +extern const u8 gText_CoinCase[]; +extern const u8 gText_PowderQty[]; +extern const u8 gText_BootedUpHM[]; +extern const u8 gText_BootedUpTM[]; +extern const u8 gText_TMHMContainedVar1[]; +extern const u8 gText_PlayerUsedVar2[]; +extern const u8 gText_RepelEffectsLingered[]; +extern const u8 gText_UsedVar2WildLured[]; +extern const u8 gText_UsedVar2WildRepelled[]; +extern const u8 gText_BoxFull[]; +extern const u8 gText_WontHaveEffect[]; + extern const u8 gText_LevelSymbol[]; extern const u8 gText_PkmnInfo[]; extern const u8 gText_PkmnSkills[]; @@ -824,4 +841,6 @@ extern const u8 gText_RibbonsVar1[]; extern const u8 gText_OneDash[]; extern const u8 gText_TwoDashes[]; +extern const u8 *const gReturnToXStringsTable2[]; + #endif //GUARD_STRINGS_H diff --git a/src/battle_dome.c b/src/battle_dome.c index 0183811cd..9f400bc7a 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -2810,23 +2810,16 @@ static void CalcDomeMonStats(u16 species, s32 level, s32 ivs, u8 evBits, u8 natu CALC_STAT(baseSpDefense, STAT_SPDEF); } -#define SWAP_16(x, y) \ -{ \ - temp = x; \ - x = y; \ - y = temp; \ -} - static void SwapDomeTrainers(s32 id1, s32 id2, u16 *statsArray) { s32 i; u16 temp; - SWAP_16(statsArray[id1], statsArray[id2]); - SWAP_16(gSaveBlock2Ptr->frontier.domeTrainers[id1].trainerId, gSaveBlock2Ptr->frontier.domeTrainers[id2].trainerId); + SWAP(statsArray[id1], statsArray[id2], temp); + SWAP(gSaveBlock2Ptr->frontier.domeTrainers[id1].trainerId, gSaveBlock2Ptr->frontier.domeTrainers[id2].trainerId, temp); for (i = 0; i < 3; i++) - SWAP_16(gSaveBlock2Ptr->frontier.domeMonId[id1][i], gSaveBlock2Ptr->frontier.domeMonId[id2][i]); + SWAP(gSaveBlock2Ptr->frontier.domeMonId[id1][i], gSaveBlock2Ptr->frontier.domeMonId[id2][i], temp); } static void sub_818F9B0(void) diff --git a/src/battle_main.c b/src/battle_main.c index 9f9511c38..c31fb48d5 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -4596,13 +4596,10 @@ static void sub_803CDF8(void) void SwapTurnOrder(u8 id1, u8 id2) { - u32 temp = gActionsByTurnOrder[id1]; - gActionsByTurnOrder[id1] = gActionsByTurnOrder[id2]; - gActionsByTurnOrder[id2] = temp; - - temp = gBattlerByTurnOrder[id1]; - gBattlerByTurnOrder[id1] = gBattlerByTurnOrder[id2]; - gBattlerByTurnOrder[id2] = temp; + u32 temp; + + SWAP(gActionsByTurnOrder[id1], gActionsByTurnOrder[id2], temp); + SWAP(gBattlerByTurnOrder[id1], gBattlerByTurnOrder[id2], temp); } u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index f9cc48a9a..721dfca98 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -7,6 +7,7 @@ #include "gpu_regs.h" #include "malloc.h" #include "menu.h" +#include "overworld.h" #include "menu_helpers.h" #include "overworld.h" #include "palette.h" @@ -14,21 +15,46 @@ #include "scanline_effect.h" #include "script.h" #include "task.h" +#include "decompress.h" +#include "graphics.h" +#include "string_util.h" +#include "list_menu.h" +#include "strings.h" +#include "item.h" +#include "sound.h" +#include "item_menu.h" +#include "mail.h" +#include "item_use.h" +#include "event_data.h" +#include "text_window.h" +#include "international_string_util.h" +#include "constants/items.h" #include "constants/rgb.h" +#include "constants/songs.h" EWRAM_DATA struct { - u32 unk0; - u8 filler4[0x804 - 0x4]; - u8 unk804[11]; - u8 unk80F[5]; + MainCallback callback2; + u8 tilemapBuffer[0x800]; + u8 itemsSpriteIds[PYRAMID_BAG_ITEMS_COUNT + 1]; + u8 windowIds[5]; u8 unk814; - u8 filler815; - s8 unk816; - u8 filler817[0x984 - 0x817]; - u16 unk984; + u8 unk815; + u8 unk816; + const u8 *menuActionIds; + u8 filler81C; + u8 filler81D; + u8 filler81E; + u8 filler81F; + u8 menuActionsCount; + u8 listMenuCount; + u8 listMenuMaxShown; + struct ListMenuItem bagListItems[PYRAMID_BAG_ITEMS_COUNT + 1]; + u8 itemStrings[PYRAMID_BAG_ITEMS_COUNT + 1][ITEM_NAME_LENGTH + 10]; + s16 unk984; u8 filler986[0x98C - 0x986]; } *gUnknown_0203CF2C = NULL; + EWRAM_DATA struct { void (*callback)(void); @@ -38,14 +64,44 @@ EWRAM_DATA struct } gUnknown_0203CF30 = {0}; extern const struct BgTemplate gUnknown_0861F2B4[3]; +extern const struct WindowTemplate gUnknown_0861F328[]; +extern const struct WindowTemplate gUnknown_0861F350[]; +extern const struct CompressedSpriteSheet gUnknown_0861F3CC; +extern const struct ListMenuTemplate gUnknown_0861F2C0; +extern const u8 gUnknown_0861F310[1]; +extern const u8 gUnknown_0861F308[4]; +extern const u8 gUnknown_0861F30E[2]; +extern const u8 gUnknown_0861F30C[2]; +extern const struct MenuAction gUnknown_0861F2D8[]; +extern const struct YesNoFuncTable gUnknown_0861F314; +extern const u16 gUnknown_0860F074[]; +extern const u8 gUnknown_0861F31C[][3]; +// This file's functions. void sub_81C4F98(u8 a0, void (*callback)(void)); void sub_81C4F44(u8 taskId); +void Task_HandlePyramidBagInput(u8 taskId); +void sub_81C5B4C(u8 taskId); +void sub_81C67CC(u8 taskId); +void sub_81C5D20(u8 taskId); +void sub_81C674C(u8 taskId); +void sub_81C5FE4(u8 taskId); +void sub_81C5F68(u8 taskId); +void sub_81C6714(u8 taskId); +void sub_81C66EC(u8 taskId); +void sub_81C629C(u8 taskId); +void sub_81C6350(u8 taskId); +void sub_81C64B4(u8 taskId); +void sub_81C65CC(u8 taskId); +void sub_81C66AC(u8 taskId); +void sub_81C6964(u8 taskId); +void sub_81C68B0(u8 taskId); +void sub_81C6A14(u8 taskId); void sub_81C504C(void); bool8 sub_81C5078(void); void sub_81C51DC(void); bool8 sub_81C5238(void); -void sub_81C5314(void); +void SetBagItemsListTemplate(void); void sub_81C5674(void); void sub_81C56F8(void); void sub_81C5924(void); @@ -54,7 +110,28 @@ void sub_81C5A20(void); void sub_81C6BD8(void); void sub_81C6EF4(void); void sub_81C700C(void); +void sub_81C6E98(void); +void sub_81C6F20(void); +void sub_81C6404(void); +void sub_81C6E1C(void); +void ShowItemImage(u16 itemId, u8 tagIdAdder); +void PyramidBag_CopyItemName(u8 *dst, u16 itemId); +void sub_81C6FF8(u8 arg0); +void PrintItemDescription(s32 listMenuId); +void sub_81C5AB8(u8 y, u8 arg1); +void PrintOnWindow_Font1(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId); +void PrintOnWindow_Font7(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId); +u8 sub_81C6D24(u8 windowArrayId); +void sub_81C6D6C(u8 windowArrayId); +void sub_81C5EAC(u8 windowId); +void sub_81C5F08(u8 windowId, u8 horizontalCount, u8 verticalCount); +bool8 sub_81C616C(s8 arg0); +void sub_81C6DAC(u8 taskId, const struct YesNoFuncTable *yesNoTable); +void sub_81C6CEC(u8 windowId); +void sub_81C704C(u8 arg0); +void sub_81C7028(u8 arg0); +// code void sub_81C4EEC(void) { gUnknown_0203CF30.unk6 = 0; @@ -99,22 +176,18 @@ void sub_81C4F98(u8 a0, void (*callback)(void)) gUnknown_0203CF2C = AllocZeroed(sizeof(*gUnknown_0203CF2C)); if (a0 != 4) - { gUnknown_0203CF30.unk4 = a0; - } if (callback != NULL) - { gUnknown_0203CF30.callback = callback; - } - gUnknown_0203CF2C->unk0 = 0; - gUnknown_0203CF2C->unk814 = -1; - gUnknown_0203CF2C->unk816 = -1; + gUnknown_0203CF2C->callback2 = NULL; + gUnknown_0203CF2C->unk814 = 0xFF; + gUnknown_0203CF2C->unk816 = 0xFF; + + memset(gUnknown_0203CF2C->itemsSpriteIds, 0xFF, sizeof(gUnknown_0203CF2C->itemsSpriteIds)); + memset(gUnknown_0203CF2C->windowIds, 0xFF, sizeof(gUnknown_0203CF2C->windowIds)); - memset(gUnknown_0203CF2C->unk804, 0xFF, sizeof(gUnknown_0203CF2C->unk804)); - memset(gUnknown_0203CF2C->unk80F, 0xFF, sizeof(gUnknown_0203CF2C->unk80F)); - SetMainCallback2(sub_81C504C); } @@ -194,7 +267,7 @@ bool8 sub_81C5078(void) gMain.state++; break; case 10: - sub_81C5314(); + SetBagItemsListTemplate(); gMain.state++; break; case 11: @@ -235,14 +308,940 @@ void sub_81C51DC(void) ResetVramOamAndBgCntRegs(); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, gUnknown_0861F2B4, ARRAY_COUNT(gUnknown_0861F2B4)); - SetBgTilemapBuffer(2, gUnknown_0203CF2C->filler4); + SetBgTilemapBuffer(2, gUnknown_0203CF2C->tilemapBuffer); ResetAllBgsCoordinates(); schedule_bg_copy_tilemap_to_vram(2); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | - DISPCNT_OBJ_1D_MAP | + DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); ShowBg(0); ShowBg(1); ShowBg(2); SetGpuReg(REG_OFFSET_BLDCNT, 0); } + +extern const u8 gUnknown_08D9AE04[]; +extern const u8 gUnknown_08D9AF44[]; + +bool8 sub_81C5238(void) +{ + switch (gUnknown_0203CF2C->unk984) + { + case 0: + reset_temp_tile_data_buffers(); + decompress_and_copy_tile_data_to_vram(2, gBagScreen_Gfx, 0, 0, 0); + gUnknown_0203CF2C->unk984++; + break; + case 1: + if (free_temp_tile_data_buffers_if_possible() != TRUE) + { + LZDecompressWram(gUnknown_08D9AE04, gUnknown_0203CF2C->tilemapBuffer); + gUnknown_0203CF2C->unk984++; + } + break; + case 2: + LoadCompressedPalette(gUnknown_08D9AF44, 0, 0x20); + gUnknown_0203CF2C->unk984++; + break; + case 3: + LoadCompressedObjectPic(&gUnknown_0861F3CC); + gUnknown_0203CF2C->unk984++; + break; + case 4: + sub_81C6E98(); + gUnknown_0203CF2C->unk984++; + break; + default: + LoadListMenuArrowsGfx(); + gUnknown_0203CF2C->unk984 = 0; + return TRUE; + } + + return FALSE; +} + +void SetBagItemsListTemplate(void) +{ + u16 i; + u16 *pyramidItems = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; + + for (i = 0; i < gUnknown_0203CF2C->listMenuCount - 1; i++) + { + PyramidBag_CopyItemName(gUnknown_0203CF2C->itemStrings[i], pyramidItems[i]); + gUnknown_0203CF2C->bagListItems[i].name = gUnknown_0203CF2C->itemStrings[i]; + gUnknown_0203CF2C->bagListItems[i].id = i; + } + StringCopy(gUnknown_0203CF2C->itemStrings[i], gText_CloseBag); + gUnknown_0203CF2C->bagListItems[i].name = gUnknown_0203CF2C->itemStrings[i]; + gUnknown_0203CF2C->bagListItems[i].id = LIST_B_PRESSED; + gMultiuseListMenuTemplate = gUnknown_0861F2C0; + gMultiuseListMenuTemplate.totalItems = gUnknown_0203CF2C->listMenuCount; + gMultiuseListMenuTemplate.items = gUnknown_0203CF2C->bagListItems; + gMultiuseListMenuTemplate.maxShowed = gUnknown_0203CF2C->listMenuMaxShown; +} + +void PyramidBag_CopyItemName(u8 *dst, u16 itemId) +{ + if (ItemId_GetPocket(itemId) == POCKET_BERRIES) + { + ConvertIntToDecimalStringN(gStringVar1, ITEM_TO_BERRY(itemId), STR_CONV_MODE_LEADING_ZEROS, 2); + CopyItemName(itemId, gStringVar2); + StringExpandPlaceholders(dst, gText_UnkF908Var1Clear7Var2); + } + else + { + CopyItemName(itemId, dst); + } +} + +void PyramidBagMoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list) +{ + if (onInit != TRUE) + { + PlaySE(SE_SELECT); + sub_81C6F20(); + } + if (gUnknown_0203CF2C->unk814 == 0xFF) + { + sub_81C6FF8(gUnknown_0203CF2C->unk815 ^ 1); + if (itemIndex != LIST_B_PRESSED) + ShowItemImage(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][itemIndex], gUnknown_0203CF2C->unk815); + else + ShowItemImage(0xFFFF, gUnknown_0203CF2C->unk815); + gUnknown_0203CF2C->unk815 ^= 1; + PrintItemDescription(itemIndex); + } +} + +void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y) +{ + s32 xAlign; + if (itemIndex == LIST_B_PRESSED) + return; + + if (gUnknown_0203CF2C->unk814 != 0xFF) + { + if (gUnknown_0203CF2C->unk814 == (u8)(itemIndex)) + sub_81C5AB8(y, 1); + else + sub_81C5AB8(y, 0xFF); + } + ConvertIntToDecimalStringN(gStringVar1, + gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode][itemIndex], + STR_CONV_MODE_RIGHT_ALIGN, + 2); + StringExpandPlaceholders(gStringVar4, gText_xVar1); + xAlign = GetStringRightAlignXOffset(7, gStringVar4, 0x77); + PrintOnWindow_Font7(windowId, gStringVar4, xAlign, y, 0, 0, TEXT_SPEED_FF, 0); +} + +void PrintItemDescription(s32 listMenuId) +{ + const u8 *desc; + if (listMenuId != LIST_B_PRESSED) + { + desc = ItemId_GetDescription(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][listMenuId]); + } + else + { + StringCopy(gStringVar1, gReturnToXStringsTable2[gUnknown_0203CF30.unk4]); + StringExpandPlaceholders(gStringVar4, gText_ReturnToVar1); + desc = gStringVar4; + } + FillWindowPixelBuffer(1, 0); + PrintOnWindow_Font1(1, desc, 3, 0, 0, 1, 0, 0); +} + +void sub_81C5674(void) +{ + if (gUnknown_0203CF2C->unk816 == 0xFF) + gUnknown_0203CF2C->unk816 = AddScrollIndicatorArrowPairParameterized(2, 172, 12, 148, gUnknown_0203CF2C->listMenuCount - gUnknown_0203CF2C->listMenuMaxShown, 0xB5E, 0xB5E, &gUnknown_0203CF30.unk8); +} + +void sub_81C56CC(void) +{ + if (gUnknown_0203CF2C->unk816 != 0xFF) + { + RemoveScrollIndicatorArrowPair(gUnknown_0203CF2C->unk816); + gUnknown_0203CF2C->unk816 = 0xFF; + } +} + +void sub_81C56F8(void) +{ + u8 taskId = CreateTask(Task_HandlePyramidBagInput, 0); + s16 *data = gTasks[taskId].data; + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203CF30.unk8, gUnknown_0203CF30.unk6); +} + +void SwapItems(u8 id1, u8 id2) +{ + u16 temp; + u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; + u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode]; + + SWAP(itemIds[id1], itemIds[id2], temp); + SWAP(quantities[id1], quantities[id2], temp); +} + +void MovePyramidBagItemSlotInList(u8 from, u8 to) +{ + u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; + u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode]; + + if (from != to) + { + s16 i; + u16 firstSlotItemId = itemIds[from]; + u8 firstSlotQuantity = quantities[from]; + + if (to > from) + { + to--; + for (i = from; i < to; i++) + { + itemIds[i] = itemIds[i + 1]; + quantities[i] = quantities[i + 1]; + } + } + else + { + for (i = from; i > to; i--) + { + itemIds[i] = itemIds[i - 1]; + quantities[i] = quantities[i - 1]; + } + } + itemIds[to] = firstSlotItemId; + quantities[to] = firstSlotQuantity; + } +} + +void CompactItems(void) +{ + u8 i, j; + u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; + u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode]; + + for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++) + { + if (itemIds[i] == 0 || quantities[i] == 0) + { + itemIds[i] = 0; + quantities[i] = 0; + } + } + for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT - 1; i++) + { + for (j = i + 1; j < PYRAMID_BAG_ITEMS_COUNT; j++) + { + if (itemIds[i] == 0 || quantities[i] == 0) + SwapItems(i, j); + } + } +} + +void sub_81C5924(void) +{ + u16 i; + u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; + + CompactItems(); + gUnknown_0203CF2C->listMenuCount = 0; + for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++) + { + if (itemIds[i] != 0) + gUnknown_0203CF2C->listMenuCount++; + } + gUnknown_0203CF2C->listMenuCount++; + if (gUnknown_0203CF2C->listMenuCount > 8) + gUnknown_0203CF2C->listMenuMaxShown = 8; + else + gUnknown_0203CF2C->listMenuMaxShown = gUnknown_0203CF2C->listMenuCount; +} + +void sub_81C59BC(void) +{ + if (gUnknown_0203CF30.unk8 != 0 && gUnknown_0203CF30.unk8 + gUnknown_0203CF2C->listMenuMaxShown > gUnknown_0203CF2C->listMenuCount) + gUnknown_0203CF30.unk8 = gUnknown_0203CF2C->listMenuCount - gUnknown_0203CF2C->listMenuMaxShown; + if (gUnknown_0203CF30.unk8 + gUnknown_0203CF30.unk6 >= gUnknown_0203CF2C->listMenuCount) + { + if (gUnknown_0203CF2C->listMenuCount == 0) + gUnknown_0203CF30.unk6 = 0; + else + gUnknown_0203CF30.unk6 = gUnknown_0203CF2C->listMenuCount - 1; + } +} + +void sub_81C5A20(void) +{ + u8 i; + + if (gUnknown_0203CF30.unk6 > 4) + { + for (i = 0; i <= gUnknown_0203CF30.unk6 - 4; i++) + { + if (gUnknown_0203CF30.unk8 + gUnknown_0203CF2C->listMenuMaxShown == gUnknown_0203CF2C->listMenuCount) + { + // daycare.c sends its regards. + break; + } + gUnknown_0203CF30.unk6--; + gUnknown_0203CF30.unk8++; + } + } +} + +void sub_81C5A98(u8 listMenuTaskId, u8 arg1) +{ + u8 y = ListMenuGetYCoordForPrintingArrowCursor(listMenuTaskId); + sub_81C5AB8(y, arg1); +} + +void sub_81C5AB8(u8 y, u8 arg1) +{ + if (arg1 == 0xFF) + FillWindowPixelRect(0, 0, 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); + else + PrintOnWindow_Font1(0, gText_SelectorArrow2, 0, y, 0, 0, 0, arg1); +} + +void sub_81C5B14(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); + gTasks[taskId].func = sub_81C5B4C; +} + +void sub_81C5B4C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if (!gPaletteFade.active) + { + DestroyListMenuTask(data[0], &gUnknown_0203CF30.unk8, &gUnknown_0203CF30.unk6); + if (gUnknown_0203CF2C->callback2 != NULL) + SetMainCallback2(gUnknown_0203CF2C->callback2); + else + SetMainCallback2(gUnknown_0203CF30.callback); + sub_81C56CC(); + ResetSpriteData(); + FreeAllSpritePalettes(); + FreeAllWindowBuffers(); + Free(gUnknown_0203CF2C); + DestroyTask(taskId); + } +} + +void Task_HandlePyramidBagInput(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if (sub_81221EC() != TRUE && !gPaletteFade.active) + { + if (gMain.newKeys & SELECT_BUTTON) + { + if (gUnknown_0203CF30.unk4 != 2) + { + ListMenuGetScrollAndRow(data[0], &gUnknown_0203CF30.unk8, &gUnknown_0203CF30.unk6); + if (gUnknown_0203CF30.unk8 + gUnknown_0203CF30.unk6 != gUnknown_0203CF2C->listMenuCount - 1) + { + PlaySE(SE_SELECT); + sub_81C67CC(taskId); + } + } + } + else + { + s32 listId = ListMenuHandleInputGetItemId(data[0]); + ListMenuGetScrollAndRow(data[0], &gUnknown_0203CF30.unk8, &gUnknown_0203CF30.unk6); + switch (listId) + { + case LIST_NOTHING_CHOSEN: + break; + case LIST_B_PRESSED: + PlaySE(SE_SELECT); + gSpecialVar_ItemId = 0; + sub_81C5B14(taskId); + break; + default: + PlaySE(SE_SELECT); + gSpecialVar_ItemId = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][listId]; + data[1] = listId; + data[2] = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode][listId]; + if (gUnknown_0203CF30.unk4 == 2) + sub_81C674C(taskId); + else + sub_81C5D20(taskId); + break; + } + } + } +} + +void sub_81C5D20(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + sub_81C56CC(); + sub_81C5A98(data[0], 1); + switch (gUnknown_0203CF30.unk4) + { + default: + gUnknown_0203CF2C->menuActionIds = gUnknown_0861F308; + gUnknown_0203CF2C->menuActionsCount = ARRAY_COUNT(gUnknown_0861F308); + break; + case 1: + if (ItemId_GetBattleUsage(gSpecialVar_ItemId)) + { + gUnknown_0203CF2C->menuActionIds = gUnknown_0861F30E; + gUnknown_0203CF2C->menuActionsCount = ARRAY_COUNT(gUnknown_0861F30E); + } + else + { + gUnknown_0203CF2C->menuActionIds = gUnknown_0861F310; + gUnknown_0203CF2C->menuActionsCount = ARRAY_COUNT(gUnknown_0861F310); + } + break; + case 3: + gUnknown_0203CF2C->menuActionIds = gUnknown_0861F30C; + gUnknown_0203CF2C->menuActionsCount = ARRAY_COUNT(gUnknown_0861F30C); + break; + } + + CopyItemName(gSpecialVar_ItemId, gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected); + FillWindowPixelBuffer(1, 0); + PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0); + if (gUnknown_0203CF2C->menuActionsCount == 1) + sub_81C5EAC(sub_81C6D24(0)); + else if (gUnknown_0203CF2C->menuActionsCount == 2) + sub_81C5EAC(sub_81C6D24(1)); + else + sub_81C5F08(sub_81C6D24(2), 2, 2); + + if (gUnknown_0203CF2C->menuActionsCount == 4) + gTasks[taskId].func = sub_81C5FE4; + else + gTasks[taskId].func = sub_81C5F68; +} + +void sub_81C5EAC(u8 windowId) +{ + AddItemMenuActionTextPrinters(windowId, 7, 8, 1, 0, 0x10, gUnknown_0203CF2C->menuActionsCount, gUnknown_0861F2D8, gUnknown_0203CF2C->menuActionIds); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, gUnknown_0203CF2C->menuActionsCount, 0); +} + +void sub_81C5F08(u8 windowId, u8 horizontalCount, u8 verticalCount) +{ + sub_8198DBC(windowId, 7, 8, 1, 0x38, horizontalCount, verticalCount, gUnknown_0861F2D8, gUnknown_0203CF2C->menuActionIds); + sub_8199944(windowId, 0x38, horizontalCount, verticalCount, 0); +} + +void sub_81C5F68(u8 taskId) +{ + if (sub_81221EC() != TRUE) + { + s32 id = Menu_ProcessInputNoWrapAround(); + switch (id) + { + case -2: + break; + case -1: + PlaySE(SE_SELECT); + gUnknown_0861F2D8[3].func.void_u8(taskId); + break; + default: + PlaySE(SE_SELECT); + if (gUnknown_0861F2D8[gUnknown_0203CF2C->menuActionIds[id]].func.void_u8 != NULL) + gUnknown_0861F2D8[gUnknown_0203CF2C->menuActionIds[id]].func.void_u8(taskId); + break; + } + } +} + +void sub_81C5FE4(u8 taskId) +{ + if (sub_81221EC() != TRUE) + { + s8 id = GetMenuCursorPos(); + if (gMain.newKeys & DPAD_UP) + { + if (id > 0 && sub_81C616C(id - 2)) + { + PlaySE(SE_SELECT); + sub_8199134(0, -1); + } + } + else if (gMain.newKeys & DPAD_DOWN) + { + if (id < gUnknown_0203CF2C->menuActionsCount - 2 && sub_81C616C(id + 2)) + { + PlaySE(SE_SELECT); + sub_8199134(0, 1); + } + } + else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) + { + if (id & 1 && sub_81C616C(id - 1)) + { + PlaySE(SE_SELECT); + sub_8199134(-1, 0); + } + } + else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) + { + if (!(id & 1) && sub_81C616C(id + 1)) + { + PlaySE(SE_SELECT); + sub_8199134(1, 0); + } + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + if (gUnknown_0861F2D8[gUnknown_0203CF2C->menuActionIds[id]].func.void_u8 != NULL) + gUnknown_0861F2D8[gUnknown_0203CF2C->menuActionIds[id]].func.void_u8(taskId); + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + gUnknown_0861F2D8[3].func.void_u8(taskId); + } + } +} + +bool8 sub_81C616C(s8 arg0) +{ + if (arg0 < 0) + return FALSE; + else if (arg0 > gUnknown_0203CF2C->menuActionsCount) + return FALSE; + else if (gUnknown_0203CF2C->menuActionIds[arg0] == 5) + return FALSE; + else + return TRUE; +} + +void sub_81C61A8(void) +{ + if (gUnknown_0203CF2C->menuActionsCount == 1) + sub_81C6D6C(0); + else if (gUnknown_0203CF2C->menuActionsCount == 2) + sub_81C6D6C(1); + else + sub_81C6D6C(2); +} + +void sub_81C61E0(u8 taskId) +{ + u8 pocketId = ItemId_GetPocket(gSpecialVar_ItemId); + + if (pocketId == POCKET_KEY_ITEMS + || pocketId == POCKET_POKE_BALLS + || pocketId == POCKET_TM_HM + || ItemIsMail(gSpecialVar_ItemId) == TRUE) + { + sub_81C61A8(); + DisplayItemMessageInBattlePyramid(taskId, gText_DadsAdvice, sub_81C6714); + } + else if (ItemId_GetFieldFunc(gSpecialVar_ItemId) != NULL) + { + sub_81C61A8(); + FillWindowPixelBuffer(1, 0); + schedule_bg_copy_tilemap_to_vram(0); + ItemId_GetFieldFunc(gSpecialVar_ItemId)(taskId); + } +} + +void sub_81C6258(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + sub_81C61A8(); + PrintItemDescription(data[1]); + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); + sub_81C5A98(data[0], 0); + sub_81C629C(taskId); +} + +void sub_81C629C(u8 taskId) +{ + sub_81C5674(); + gTasks[taskId].func = Task_HandlePyramidBagInput; +} + +void sub_81C62C4(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + sub_81C61A8(); + data[8] = 1; + if (data[2] == 1) + { + sub_81C6350(taskId); + } + else + { + CopyItemName(gSpecialVar_ItemId, gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_TossHowManyVar1s); + FillWindowPixelBuffer(1, 0); + PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0); + sub_81C6404(); + gTasks[taskId].func = sub_81C64B4; + } +} + +void sub_81C6350(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + CopyItemName(gSpecialVar_ItemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 2); + StringExpandPlaceholders(gStringVar4, gText_ConfirmTossItems); + FillWindowPixelBuffer(1, 0); + PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0); + sub_81C6DAC(taskId, &gUnknown_0861F314); +} + +void sub_81C63D0(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + PrintItemDescription(data[1]); + sub_81C5A98(data[0], 0); + sub_81C629C(taskId); +} + +void sub_81C6404(void) +{ + s32 x; + + ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, 2); + StringExpandPlaceholders(gStringVar4, gText_xVar1); + sub_81C6CEC(3); + x = GetStringCenterAlignXOffset(1, gStringVar4, 0x28); + PrintTextOnWindow(3, 1, gStringVar4, x, 2, 0, NULL); +} + +void sub_81C645C(s16 value) +{ + s32 x; + + ConvertIntToDecimalStringN(gStringVar1, value, STR_CONV_MODE_LEADING_ZEROS, 2); + StringExpandPlaceholders(gStringVar4, gText_xVar1); + x = GetStringCenterAlignXOffset(1, gStringVar4, 0x28); + PrintTextOnWindow(3, 1, gStringVar4, x, 2, 0, NULL); +} + +void sub_81C64B4(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + if (AdjustQuantityAccordingToDPadInput(&data[8], data[2]) == TRUE) + { + sub_81C645C(data[8]); + } + else if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_8198070(3, 0); + ClearWindowTilemap(3); + schedule_bg_copy_tilemap_to_vram(1); + sub_81C6350(taskId); + } + else if (gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + sub_8198070(3, 0); + ClearWindowTilemap(3); + schedule_bg_copy_tilemap_to_vram(1); + sub_81C63D0(taskId); + } +} + +void sub_81C654C(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + CopyItemName(gSpecialVar_ItemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, data[8], STR_CONV_MODE_LEFT_ALIGN, 2); + StringExpandPlaceholders(gStringVar4, gText_ThrewAwayVar2Var1s); + FillWindowPixelBuffer(1, 0); + PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0); + gTasks[taskId].func = sub_81C65CC; +} + +void sub_81C65CC(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + u16 *scrollOffset = &gUnknown_0203CF30.unk8; + u16 *selectedRow = &gUnknown_0203CF30.unk6; + + if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + PlaySE(SE_SELECT); + RemovePyramidBagItem(gSpecialVar_ItemId, data[8]); + DestroyListMenuTask(data[0], scrollOffset, selectedRow); + sub_81C5924(); + sub_81C59BC(); + SetBagItemsListTemplate(); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollOffset, *selectedRow); + schedule_bg_copy_tilemap_to_vram(0); + sub_81C629C(taskId); + } +} + +void sub_81C6648(u8 taskId) +{ + sub_81C61A8(); + if (ItemIsMail(gSpecialVar_ItemId) == TRUE) + { + DisplayItemMessageInBattlePyramid(taskId, gText_CantWriteMail, sub_81C66EC); + } + else if (!ItemId_GetImportance(gSpecialVar_ItemId)) + { + gUnknown_0203CF2C->callback2 = sub_81B7F60; + sub_81C5B14(taskId); + } + else + { + sub_81C66AC(taskId); + } +} + +void sub_81C66AC(u8 taskId) +{ + CopyItemName(gSpecialVar_ItemId, gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeld); + DisplayItemMessageInBattlePyramid(taskId, gStringVar4, sub_81C66EC); +} + +void sub_81C66EC(u8 taskId) +{ + if (gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_81C6714(taskId); + } +} + +void sub_81C6714(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + sub_81C6E1C(); + PrintItemDescription(data[1]); + sub_81C5A98(data[0], 0); + sub_81C629C(taskId); +} + +void sub_81C674C(u8 taskId) +{ + if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId)) + DisplayItemMessageInBattlePyramid(taskId, gText_CantWriteMail, sub_81C66EC); + else if (!ItemId_GetImportance(gSpecialVar_ItemId)) + sub_81C5B14(taskId); + else + sub_81C66AC(taskId); +} + +void sub_81C679C(u8 taskId) +{ + if (ItemId_GetBattleFunc(gSpecialVar_ItemId) != NULL) + { + sub_81C61A8(); + ItemId_GetBattleFunc(gSpecialVar_ItemId)(taskId); + } +} + +void sub_81C67CC(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + data[1] = gUnknown_0203CF30.unk8 + gUnknown_0203CF30.unk6; + gUnknown_0203CF2C->unk814 = data[1]; + ListMenuSetUnkIndicatorsStructField(data[0], 0x10, 1); + CopyItemName(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][data[1]], gStringVar1); + StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where); + FillWindowPixelBuffer(1, 0); + PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0); + sub_81C5A98(data[0], 1); + sub_81C704C(data[1]); + gTasks[taskId].func = sub_81C68B0; +} + +void sub_81C68B0(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + if (sub_81221EC() != TRUE) + { + if (gMain.newKeys & SELECT_BUTTON) + { + PlaySE(SE_SELECT); + ListMenuGetScrollAndRow(data[0], &gUnknown_0203CF30.unk8, &gUnknown_0203CF30.unk6); + sub_81C6964(taskId); + } + else + { + s32 id = ListMenuHandleInputGetItemId(data[0]); + ListMenuGetScrollAndRow(data[0], &gUnknown_0203CF30.unk8, &gUnknown_0203CF30.unk6); + sub_81C7028(0); + sub_81C704C(gUnknown_0203CF30.unk6); + switch (id) + { + case LIST_NOTHING_CHOSEN: + break; + case LIST_B_PRESSED: + PlaySE(SE_SELECT); + if (gMain.newKeys & A_BUTTON) + sub_81C6964(taskId); + else + sub_81C6A14(taskId); + break; + default: + PlaySE(SE_SELECT); + sub_81C6964(taskId); + break; + } + } + } +} + +void sub_81C6964(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + u16 *scrollOffset = &gUnknown_0203CF30.unk8; + u16 *selectedRow = &gUnknown_0203CF30.unk6; + u16 var = *scrollOffset + *selectedRow; + + if (data[1] == var || data[1] == var - 1) + { + sub_81C6A14(taskId); + } + else + { + MovePyramidBagItemSlotInList(data[1], var); + gUnknown_0203CF2C->unk814 = 0xFF; + sub_81C7028(1); + DestroyListMenuTask(data[0], scrollOffset, selectedRow); + if (data[1] < var) + gUnknown_0203CF30.unk6--; + SetBagItemsListTemplate(); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollOffset, *selectedRow); + sub_81C629C(taskId); + } +} + +void sub_81C6A14(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + u16 *scrollOffset = &gUnknown_0203CF30.unk8; + u16 *selectedRow = &gUnknown_0203CF30.unk6; + + gUnknown_0203CF2C->unk814 = 0xFF; + sub_81C7028(1); + DestroyListMenuTask(data[0], scrollOffset, selectedRow); + if (data[1] < *scrollOffset + *selectedRow) + gUnknown_0203CF30.unk6--; + SetBagItemsListTemplate(); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollOffset, *selectedRow); + sub_81C629C(taskId); +} + +void sub_81C6A94(void) +{ + u8 i; + struct Pokemon *party = gPlayerParty; + u16 *newItems = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(u16)); + u8 *newQuantities = Alloc(PYRAMID_BAG_ITEMS_COUNT * sizeof(u8)); + u16 heldItem; + + memcpy(newItems, gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode], PYRAMID_BAG_ITEMS_COUNT * sizeof(u16)); + memcpy(newQuantities, gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode], PYRAMID_BAG_ITEMS_COUNT * sizeof(u8)); + for (i = 0; i < 3; i++) + { + heldItem = GetMonData(&party[i], MON_DATA_HELD_ITEM); + if (heldItem != 0 && !AddBagItem(heldItem, 1)) + { + memcpy(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode], newItems, PYRAMID_BAG_ITEMS_COUNT * sizeof(u16)); + memcpy(gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode], newQuantities, PYRAMID_BAG_ITEMS_COUNT * sizeof(u8)); + Free(newItems); + Free(newQuantities); + gSpecialVar_Result = 1; + return; + } + } + + heldItem = 0; + for (i = 0; i < 3; i++) + { + SetMonData(&party[i], MON_DATA_HELD_ITEM, &heldItem); + } + gSpecialVar_Result = 0; + Free(newItems); + Free(newQuantities); +} + +void sub_81C6BD8(void) +{ + u8 i; + + InitWindows(gUnknown_0861F328); + DeactivateAllTextPrinters(); + LoadUserWindowBorderGfx(0, 0x1, 0xE0); + LoadMessageBoxGfx(0, 0xA, 0xD0); + LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + + for (i = 0; i < 5; i++) + FillWindowPixelBuffer(i, 0); + + PutWindowTilemap(0); + PutWindowTilemap(1); + schedule_bg_copy_tilemap_to_vram(0); + schedule_bg_copy_tilemap_to_vram(1); +} + +void PrintOnWindow_Font1(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId) +{ + AddTextPrinterParameterized2(windowId, 1, x, y, letterSpacing, lineSpacing, gUnknown_0861F31C[colorTableId], speed, src); +} + +void PrintOnWindow_Font7(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId) +{ + AddTextPrinterParameterized2(windowId, 7, x, y, letterSpacing, lineSpacing, gUnknown_0861F31C[colorTableId], speed, src); +} + +void sub_81C6CEC(u8 windowId) +{ + SetWindowBorderStyle(windowId, 0, 1, 0xE); + schedule_bg_copy_tilemap_to_vram(1); +} + +u8 sub_81C6D08(u8 windowArrayId) +{ + return gUnknown_0203CF2C->windowIds[windowArrayId]; +} + +u8 sub_81C6D24(u8 windowArrayId) +{ + u8 *windowId = &gUnknown_0203CF2C->windowIds[windowArrayId]; + if (*windowId == 0xFF) + { + *windowId = AddWindow(&gUnknown_0861F350[windowArrayId]); + SetWindowBorderStyle(*windowId, FALSE, 1, 0xE); + schedule_bg_copy_tilemap_to_vram(1); + } + return *windowId; +} + +void sub_81C6D6C(u8 windowArrayId) +{ + u8 *windowId = &gUnknown_0203CF2C->windowIds[windowArrayId]; + if (*windowId != 0xFF) + { + sub_8198070(*windowId, FALSE); + ClearWindowTilemap(*windowId); + RemoveWindow(*windowId); + schedule_bg_copy_tilemap_to_vram(1); + *windowId = 0xFF; + } +} diff --git a/src/item.c b/src/item.c index 22894bbff..29c250989 100644 --- a/src/item.c +++ b/src/item.c @@ -752,9 +752,8 @@ u16 BagGetQuantityByPocketPosition(u8 pocketId, u16 pocketPos) static void SwapItemSlots(struct ItemSlot *a, struct ItemSlot *b) { - struct ItemSlot temp = *a; - *a = *b; - *b = temp; + struct ItemSlot temp; + SWAP(*a, *b, temp); } void CompactItemsInBagPocket(struct BagPocket *bagPocket) diff --git a/src/item_use.c b/src/item_use.c index 9031338dd..23c829391 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -29,44 +29,26 @@ #include "string_util.h" #include "task.h" #include "text.h" +#include "strings.h" +#include "pokeblock.h" +#include "menu.h" +#include "item_menu.h" -extern void(**gUnknown_0203CE54)(void); extern void(**gUnknown_0203CF2C)(void); extern void(*gUnknown_0203A0F4)(u8 taskId); extern void(*gUnknown_085920D8[])(void); extern void (*gUnknown_03006328)(u8, u16, TaskFunc); extern void unknown_ItemMenu_Confirm(u8 taskId); extern void sub_81C5B14(u8 taskId); -extern u8 gText_DadsAdvice[]; -extern u8 gText_CantDismountBike[]; -extern void sub_8197434(u8 a, u8 b); extern void ScriptUnfreezeEventObjects(void); extern void ItemUseOutOfBattle_TMHM(u8 a); extern void ItemUseOutOfBattle_EvolutionStone(u8 b); -extern void bag_menu_mail_related(void); -extern void OpenPokeblockCase(u8 a, void(*b)(void)); -extern void overworld_free_bg_tilemaps(void); -extern bool32 Overworld_IsBikingAllowed(void); extern bool8 IsPlayerFacingSurfableFishableWater(void); extern bool8 sub_81221AC(void); -extern u8 gText_ItemFinderNothing[]; -extern u8 gText_ItemFinderNearby[]; -extern u8 gText_ItemFinderOnTop[]; -extern u8 gText_CoinCase[]; -extern u8 gText_PowderQty[]; extern u8 gUnknown_085920E4[]; extern u8 Route102_EventScript_274482[]; extern u8 Route102_EventScript_2744C0[]; extern u8 BattleFrontier_OutsideEast_EventScript_242CFC[]; -extern u8 gText_BootedUpHM[]; -extern u8 gText_BootedUpTM[]; -extern u8 gText_TMHMContainedVar1[]; -extern u8 gText_PlayerUsedVar2[]; -extern u8 gText_RepelEffectsLingered[]; -extern u8 gText_UsedVar2WildLured[]; -extern u8 gText_UsedVar2WildRepelled[]; -extern u8 gText_BoxFull[]; -extern u8 gText_WontHaveEffect[]; extern int sub_80247BC(void); extern struct MapHeader* mapconnection_get_mapheader(struct MapConnection *connection); extern void SetUpItemUseCallback(u8 taskId); @@ -86,7 +68,6 @@ extern void sub_81C59BC(void); extern void sub_81AB9A8(u8); extern void sub_81ABA88(u8); extern void sub_80B7CC8(void); -extern void Overworld_ResetStateAfterDigEscRope(void); extern u8* sub_806CF78(u16); extern void sub_81B89F0(void); extern u8 GetItemEffectType(u16); @@ -115,8 +96,7 @@ void sub_80FE124(u8 taskId); void sub_80FE164(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 DisplayItemMessageOnField(u8 taskId, const u8* str, void(*callback)(u8 taskId)); void sub_81C6714(u8 taskId); void CleanUpAfterFailingToUseRegisteredKeyItemOnField(u8 taskId); void StartFishing(u8 a); @@ -137,7 +117,7 @@ void SetUpItemUseCallback(u8 taskId) type = ItemId_GetType(gSpecialVar_ItemId) - 1; if (!InBattlePyramid()) { - *gUnknown_0203CE54 = gUnknown_085920D8[type]; + gUnknown_0203CE54->unk0 = gUnknown_085920D8[type]; unknown_ItemMenu_Confirm(taskId); } else @@ -221,7 +201,7 @@ void sub_80FD254() void ItemUseOutOfBattle_Mail(u8 taskId) { - *gUnknown_0203CE54 = sub_80FD254; + gUnknown_0203CE54->unk0 = sub_80FD254; unknown_ItemMenu_Confirm(taskId); } @@ -617,7 +597,7 @@ void ItemUseOutOfBattle_PokeblockCase(u8 taskId) } else if (gTasks[taskId].data[3] != TRUE) { - *gUnknown_0203CE54 = sub_80FDBEC; + gUnknown_0203CE54->unk0 = sub_80FDBEC; unknown_ItemMenu_Confirm(taskId); } else @@ -679,7 +659,7 @@ void sub_80FDD10(u8 taskId) { gUnknown_0203A0F4 = sub_80FDD74; gFieldCallback = MapPostLoadHook_UseItem; - *gUnknown_0203CE54 = CB2_ReturnToField; + gUnknown_0203CE54->unk0 = CB2_ReturnToField; unknown_ItemMenu_Confirm(taskId); } else @@ -1002,7 +982,7 @@ void sub_80FE54C(u8 taskId) { if (!InBattlePyramid()) { - *gUnknown_0203CE54 = sub_81B89F0; + gUnknown_0203CE54->unk0 = sub_81B89F0; unknown_ItemMenu_Confirm(taskId); } else