From bc9fe72c6e85b1930f137ed49c5d2b0c4e4b10de Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 30 Aug 2018 15:01:07 +0200 Subject: [PATCH 1/4] Do some pyramid bag --- asm/battle_pyramid_bag.s | 3129 +------------------------------------- include/global.h | 7 + include/item_use.h | 3 +- include/list_menu.h | 3 +- include/menu.h | 6 +- include/strings.h | 19 + src/battle_dome.c | 13 +- src/battle_main.c | 11 +- src/battle_pyramid_bag.c | 1043 ++++++++++++- src/item.c | 5 +- src/item_use.c | 40 +- 11 files changed, 1075 insertions(+), 3204 deletions(-) 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 From 917b32ffbe15243207de849683f8933f56bdeb07 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 30 Aug 2018 20:10:57 +0200 Subject: [PATCH 2/4] Finish decompiling pyramid bag. --- asm/battle_pyramid_bag.s | 576 ------------------------- asm/party_menu.s | 2 +- asm/pokenav.s | 233 +++++++++++ data/battle_pyramid_bag.s | 54 --- include/battle_pyramid_bag.h | 49 +++ include/item_use.h | 1 - include/save.h | 2 +- ld_script.txt | 2 +- src/battle_pyramid_bag.c | 789 ++++++++++++++++++++++------------- src/item.c | 3 +- src/item_use.c | 6 +- src/start_menu.c | 9 +- 12 files changed, 782 insertions(+), 944 deletions(-) delete mode 100644 asm/battle_pyramid_bag.s create mode 100644 include/battle_pyramid_bag.h diff --git a/asm/battle_pyramid_bag.s b/asm/battle_pyramid_bag.s deleted file mode 100644 index 23ad7172e..000000000 --- a/asm/battle_pyramid_bag.s +++ /dev/null @@ -1,576 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - - - thumb_func_start sub_81C6DAC -sub_81C6DAC: @ 81C6DAC - push {lr} - sub sp, 0x10 - adds r3, r1, 0 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0861F370 - movs r2, 0x2 - str r2, [sp] - movs r2, 0x1 - str r2, [sp, 0x4] - movs r2, 0xE - str r2, [sp, 0x8] - str r3, [sp, 0xC] - movs r2, 0x1 - movs r3, 0 - bl CreateYesNoMenuWithCallbacks - add sp, 0x10 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6DAC - - thumb_func_start DisplayItemMessageInBattlePyramid -@ void DisplayItemMessageInBattlePyramid(u8 taskId, u8 *str, void ( *callback)(u8 taskId)) -DisplayItemMessageInBattlePyramid: @ 81C6DD8 - push {r4-r6,lr} - sub sp, 0x10 - adds r4, r0, 0 - adds r5, r1, 0 - adds r6, r2, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x2 - movs r1, 0x11 - bl FillWindowPixelBuffer - bl GetPlayerTextSpeed - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - str r1, [sp] - str r0, [sp, 0x4] - str r5, [sp, 0x8] - str r6, [sp, 0xC] - adds r0, r4, 0 - movs r1, 0x2 - movs r2, 0xA - movs r3, 0xD - bl DisplayMessageAndContinueTask - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - add sp, 0x10 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end DisplayItemMessageInBattlePyramid - - thumb_func_start sub_81C6E1C -sub_81C6E1C: @ 81C6E1C - push {lr} - movs r0, 0x2 - movs r1, 0 - bl sub_8197DF8 - movs r0, 0x2 - bl ClearWindowTilemap - movs r0, 0x1 - bl schedule_bg_copy_tilemap_to_vram - pop {r0} - bx r0 - thumb_func_end sub_81C6E1C - - thumb_func_start sub_81C6E38 -sub_81C6E38: @ 81C6E38 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gUnknown_0203CF2C - ldr r2, =0x00000804 - adds r1, r4, r2 - ldr r0, [r0] - adds r5, r0, r1 - ldrb r0, [r5] - cmp r0, 0xFF - beq _081C6E80 - ldr r0, =0x00001024 - adds r4, r0 - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r4, =gSprites - adds r0, r4 - bl FreeSpriteOamMatrix - ldrb r1, [r5] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - adds r0, r4 - bl DestroySprite - movs r0, 0xFF - strb r0, [r5] -_081C6E80: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6E38 - - thumb_func_start sub_81C6E98 -sub_81C6E98: @ 81C6E98 - push {r4,lr} - sub sp, 0x8 - movs r0, 0x40 - bl Alloc - adds r4, r0, 0 - ldr r0, =gUnknown_08D9ADD0 - adds r1, r4, 0 - bl LZDecompressWram - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldr r1, =0x00000ca9 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 30 - lsrs r0, 25 - adds r0, r4, r0 - str r0, [sp] - ldr r1, =0xffff0000 - ldr r0, [sp, 0x4] - ands r0, r1 - ldr r1, =0x00001024 - orrs r0, r1 - str r0, [sp, 0x4] - mov r0, sp - bl LoadSpritePalette - adds r0, r4, 0 - bl Free - add sp, 0x8 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6E98 - - thumb_func_start sub_81C6EF4 -sub_81C6EF4: @ 81C6EF4 - push {r4,lr} - ldr r0, =gUnknown_0203CF2C - ldr r4, [r0] - ldr r0, =0x00000804 - adds r4, r0 - ldr r0, =gUnknown_0861F3D4 - movs r1, 0x44 - movs r2, 0x38 - movs r3, 0 - bl CreateSprite - strb r0, [r4] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6EF4 - - thumb_func_start sub_81C6F20 -sub_81C6F20: @ 81C6F20 - push {r4,lr} - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r1, =0x00000804 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r4, r0, r1 - adds r0, r4, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _081C6F50 - adds r0, r4, 0 - movs r1, 0x1 - bl StartSpriteAffineAnim - ldr r0, =sub_81C6F68 - str r0, [r4, 0x1C] -_081C6F50: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6F20 - - thumb_func_start sub_81C6F68 -sub_81C6F68: @ 81C6F68 - push {r4,lr} - adds r4, r0, 0 - adds r0, 0x3F - ldrb r1, [r0] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _081C6F84 - adds r0, r4, 0 - movs r1, 0 - bl StartSpriteAffineAnim - ldr r0, =SpriteCallbackDummy - str r0, [r4, 0x1C] -_081C6F84: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C6F68 - - thumb_func_start ShowItemImage -ShowItemImage: @ 81C6F90 - push {r4-r6,lr} - lsls r0, 16 - lsrs r6, r0, 16 - lsls r1, 24 - lsrs r4, r1, 24 - ldr r0, =gUnknown_0203CF2C - ldr r2, =0x00000805 - adds r1, r4, r2 - ldr r0, [r0] - adds r5, r0, r1 - ldrb r0, [r5] - cmp r0, 0xFF - bne _081C6FE0 - ldr r0, =0x00001025 - adds r4, r0 - adds r0, r4, 0 - bl FreeSpriteTilesByTag - adds r0, r4, 0 - bl FreeSpritePaletteByTag - adds r0, r4, 0 - adds r1, r4, 0 - adds r2, r6, 0 - bl AddItemIconSprite - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x40 - beq _081C6FE0 - strb r2, [r5] - ldr r1, =gSprites - lsls r0, r2, 4 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - movs r1, 0x18 - strh r1, [r0, 0x24] - movs r1, 0x58 - strh r1, [r0, 0x26] -_081C6FE0: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end ShowItemImage - - thumb_func_start sub_81C6FF8 -sub_81C6FF8: @ 81C6FF8 - push {lr} - lsls r0, 24 - movs r1, 0x80 - lsls r1, 17 - adds r0, r1 - lsrs r0, 24 - bl sub_81C6E38 - pop {r0} - bx r0 - thumb_func_end sub_81C6FF8 - - thumb_func_start sub_81C700C -sub_81C700C: @ 81C700C - push {lr} - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r1, =0x00000807 - adds r0, r1 - movs r1, 0x8 - bl sub_8122344 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C700C - - thumb_func_start sub_81C7028 -sub_81C7028: @ 81C7028 - push {lr} - adds r2, r0, 0 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r1, =0x00000807 - adds r0, r1 - movs r1, 0x8 - bl sub_81223FC - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C7028 - - thumb_func_start sub_81C704C -sub_81C704C: @ 81C704C - push {lr} - adds r3, r0, 0 - lsls r3, 24 - ldr r0, =gUnknown_0203CF2C - ldr r0, [r0] - ldr r1, =0x00000807 - adds r0, r1 - lsrs r3, 4 - movs r1, 0x80 - lsls r1, 13 - adds r3, r1 - lsrs r3, 16 - movs r1, 0x88 - movs r2, 0x78 - bl sub_8122448 - pop {r0} - bx r0 - .pool - thumb_func_end sub_81C704C - - thumb_func_start sub_81C7078 -sub_81C7078: @ 81C7078 - push {r4,r5,lr} - adds r5, r0, 0 - adds r4, r1, 0 - bl is_c1_link_related_active - cmp r0, 0 - bne _081C7090 - ldr r0, =sub_81C7170 - b _081C7092 - .pool -_081C7090: - ldr r0, =sub_81C71E4 -_081C7092: - lsls r1, r4, 24 - lsrs r1, 24 - bl CreateTask - lsls r0, 24 - lsrs r4, r0, 24 - adds r0, r4, 0 - movs r1, 0x1 - adds r2, r5, 0 - bl SetWordTaskArg - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r2, =gUnknown_0203CF3C - ldrb r1, [r2] - strh r1, [r0, 0xE] - ldrb r0, [r2] - adds r1, r0, 0x1 - strb r1, [r2] - lsls r0, 24 - lsrs r0, 8 - orrs r0, r4 - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81C7078 - - thumb_func_start sub_81C70D8 -sub_81C70D8: @ 81C70D8 - push {lr} - ldr r1, =0x0000ffff - ands r1, r0 - lsrs r3, r0, 16 - ldr r2, =gTasks - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 3 - adds r1, r0, r2 - ldrb r0, [r1, 0x4] - cmp r0, 0 - beq _081C711C - ldr r2, [r1] - ldr r0, =sub_81C7170 - cmp r2, r0 - beq _081C70FE - ldr r0, =sub_81C71E4 - cmp r2, r0 - bne _081C711C -_081C70FE: - movs r2, 0xE - ldrsh r0, [r1, r2] - cmp r0, r3 - bne _081C711C - movs r0, 0x1 - b _081C711E - .pool -_081C711C: - movs r0, 0 -_081C711E: - pop {r1} - bx r1 - thumb_func_end sub_81C70D8 - - thumb_func_start sub_81C7124 -sub_81C7124: @ 81C7124 - push {r4-r6,lr} - adds r6, r0, 0 - movs r5, 0 - ldr r4, =gTasks -_081C712C: - ldrb r0, [r4, 0x4] - cmp r0, 0 - beq _081C7160 - ldr r1, [r4] - ldr r0, =sub_81C7170 - cmp r1, r0 - beq _081C7140 - ldr r0, =sub_81C71E4 - cmp r1, r0 - bne _081C7160 -_081C7140: - lsls r0, r5, 24 - lsrs r0, 24 - movs r1, 0x1 - bl GetWordTaskArg - cmp r0, r6 - bne _081C7160 - movs r0, 0x1 - b _081C716A - .pool -_081C7160: - adds r4, 0x28 - adds r5, 0x1 - cmp r5, 0xF - ble _081C712C - movs r0, 0 -_081C716A: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_81C7124 - - thumb_func_start sub_81C7170 -sub_81C7170: @ 81C7170 - push {r4-r7,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r0, r5, 0 - movs r1, 0x1 - bl GetWordTaskArg - adds r6, r0, 0 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - movs r7, 0 -_081C718C: - movs r1, 0 - ldrsh r0, [r4, r1] - bl _call_via_r6 - cmp r0, 0x4 - bhi _081C71D6 - lsls r0, 2 - ldr r1, =_081C71AC - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081C71AC: - .4byte _081C71C6 - .4byte _081C71C0 - .4byte _081C71DE - .4byte _081C71DA - .4byte _081C71CE -_081C71C0: - ldrh r0, [r4] - adds r0, 0x1 - b _081C71D8 -_081C71C6: - ldrh r0, [r4] - adds r0, 0x1 - strh r0, [r4] - b _081C71DE -_081C71CE: - adds r0, r5, 0 - bl DestroyTask - b _081C71DE -_081C71D6: - subs r0, 0x5 -_081C71D8: - strh r0, [r4] -_081C71DA: - cmp r7, 0 - beq _081C718C -_081C71DE: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_81C7170 - - thumb_func_start sub_81C71E4 -sub_81C71E4: @ 81C71E4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r5, r0, 24 - bl sub_8087598 - cmp r0, 0 - bne _081C724A - adds r0, r5, 0 - movs r1, 0x1 - bl GetWordTaskArg - adds r2, r0, 0 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - movs r1, 0 - ldrsh r0, [r4, r1] - bl _call_via_r2 - cmp r0, 0x4 - bhi _081C7246 - lsls r0, 2 - ldr r1, =_081C7224 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_081C7224: - .4byte _081C7238 - .4byte _081C7238 - .4byte _081C724A - .4byte _081C724A - .4byte _081C723E -_081C7238: - ldrh r0, [r4] - adds r0, 0x1 - b _081C7248 -_081C723E: - adds r0, r5, 0 - bl DestroyTask - b _081C724A -_081C7246: - subs r0, 0x5 -_081C7248: - strh r0, [r4] -_081C724A: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_81C71E4 - - .align 2, 0 @ Don't pad with nop. diff --git a/asm/party_menu.s b/asm/party_menu.s index 92c4905a4..2d1faadab 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -11626,7 +11626,7 @@ c2_815ABFC: @ 81B6254 bl GoToBagMenu b _081B6276 _081B626C: - ldr r0, =gUnknown_0203CF30 + ldr r0, =gPyramidBagCursorData ldr r1, [r0] movs r0, 0x4 bl sub_81C4F98 diff --git a/asm/pokenav.s b/asm/pokenav.s index 8adb3cbd9..b8165ec80 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -4,6 +4,239 @@ .syntax unified .text + + + + thumb_func_start sub_81C7078 +sub_81C7078: @ 81C7078 + push {r4,r5,lr} + adds r5, r0, 0 + adds r4, r1, 0 + bl is_c1_link_related_active + cmp r0, 0 + bne _081C7090 + ldr r0, =sub_81C7170 + b _081C7092 + .pool +_081C7090: + ldr r0, =sub_81C71E4 +_081C7092: + lsls r1, r4, 24 + lsrs r1, 24 + bl CreateTask + lsls r0, 24 + lsrs r4, r0, 24 + adds r0, r4, 0 + movs r1, 0x1 + adds r2, r5, 0 + bl SetWordTaskArg + ldr r1, =gTasks + lsls r0, r4, 2 + adds r0, r4 + lsls r0, 3 + adds r0, r1 + ldr r2, =gUnknown_0203CF3C + ldrb r1, [r2] + strh r1, [r0, 0xE] + ldrb r0, [r2] + adds r1, r0, 0x1 + strb r1, [r2] + lsls r0, 24 + lsrs r0, 8 + orrs r0, r4 + pop {r4,r5} + pop {r1} + bx r1 + .pool + thumb_func_end sub_81C7078 + + thumb_func_start sub_81C70D8 +sub_81C70D8: @ 81C70D8 + push {lr} + ldr r1, =0x0000ffff + ands r1, r0 + lsrs r3, r0, 16 + ldr r2, =gTasks + lsls r0, r1, 2 + adds r0, r1 + lsls r0, 3 + adds r1, r0, r2 + ldrb r0, [r1, 0x4] + cmp r0, 0 + beq _081C711C + ldr r2, [r1] + ldr r0, =sub_81C7170 + cmp r2, r0 + beq _081C70FE + ldr r0, =sub_81C71E4 + cmp r2, r0 + bne _081C711C +_081C70FE: + movs r2, 0xE + ldrsh r0, [r1, r2] + cmp r0, r3 + bne _081C711C + movs r0, 0x1 + b _081C711E + .pool +_081C711C: + movs r0, 0 +_081C711E: + pop {r1} + bx r1 + thumb_func_end sub_81C70D8 + + thumb_func_start sub_81C7124 +sub_81C7124: @ 81C7124 + push {r4-r6,lr} + adds r6, r0, 0 + movs r5, 0 + ldr r4, =gTasks +_081C712C: + ldrb r0, [r4, 0x4] + cmp r0, 0 + beq _081C7160 + ldr r1, [r4] + ldr r0, =sub_81C7170 + cmp r1, r0 + beq _081C7140 + ldr r0, =sub_81C71E4 + cmp r1, r0 + bne _081C7160 +_081C7140: + lsls r0, r5, 24 + lsrs r0, 24 + movs r1, 0x1 + bl GetWordTaskArg + cmp r0, r6 + bne _081C7160 + movs r0, 0x1 + b _081C716A + .pool +_081C7160: + adds r4, 0x28 + adds r5, 0x1 + cmp r5, 0xF + ble _081C712C + movs r0, 0 +_081C716A: + pop {r4-r6} + pop {r1} + bx r1 + thumb_func_end sub_81C7124 + + thumb_func_start sub_81C7170 +sub_81C7170: @ 81C7170 + push {r4-r7,lr} + lsls r0, 24 + lsrs r5, r0, 24 + adds r0, r5, 0 + movs r1, 0x1 + bl GetWordTaskArg + adds r6, r0, 0 + lsls r0, r5, 2 + adds r0, r5 + lsls r0, 3 + ldr r1, =gTasks + 0x8 + adds r4, r0, r1 + movs r7, 0 +_081C718C: + movs r1, 0 + ldrsh r0, [r4, r1] + bl _call_via_r6 + cmp r0, 0x4 + bhi _081C71D6 + lsls r0, 2 + ldr r1, =_081C71AC + adds r0, r1 + ldr r0, [r0] + mov pc, r0 + .pool + .align 2, 0 +_081C71AC: + .4byte _081C71C6 + .4byte _081C71C0 + .4byte _081C71DE + .4byte _081C71DA + .4byte _081C71CE +_081C71C0: + ldrh r0, [r4] + adds r0, 0x1 + b _081C71D8 +_081C71C6: + ldrh r0, [r4] + adds r0, 0x1 + strh r0, [r4] + b _081C71DE +_081C71CE: + adds r0, r5, 0 + bl DestroyTask + b _081C71DE +_081C71D6: + subs r0, 0x5 +_081C71D8: + strh r0, [r4] +_081C71DA: + cmp r7, 0 + beq _081C718C +_081C71DE: + pop {r4-r7} + pop {r0} + bx r0 + thumb_func_end sub_81C7170 + + thumb_func_start sub_81C71E4 +sub_81C71E4: @ 81C71E4 + push {r4,r5,lr} + lsls r0, 24 + lsrs r5, r0, 24 + bl sub_8087598 + cmp r0, 0 + bne _081C724A + adds r0, r5, 0 + movs r1, 0x1 + bl GetWordTaskArg + adds r2, r0, 0 + lsls r0, r5, 2 + adds r0, r5 + lsls r0, 3 + ldr r1, =gTasks + 0x8 + adds r4, r0, r1 + movs r1, 0 + ldrsh r0, [r4, r1] + bl _call_via_r2 + cmp r0, 0x4 + bhi _081C7246 + lsls r0, 2 + ldr r1, =_081C7224 + adds r0, r1 + ldr r0, [r0] + mov pc, r0 + .pool + .align 2, 0 +_081C7224: + .4byte _081C7238 + .4byte _081C7238 + .4byte _081C724A + .4byte _081C724A + .4byte _081C723E +_081C7238: + ldrh r0, [r4] + adds r0, 0x1 + b _081C7248 +_081C723E: + adds r0, r5, 0 + bl DestroyTask + b _081C724A +_081C7246: + subs r0, 0x5 +_081C7248: + strh r0, [r4] +_081C724A: + pop {r4,r5} + pop {r0} + bx r0 + thumb_func_end sub_81C71E4 thumb_func_start CB2_PokeNav CB2_PokeNav: @ 81C7250 diff --git a/data/battle_pyramid_bag.s b/data/battle_pyramid_bag.s index 7327fb1f8..de459075f 100644 --- a/data/battle_pyramid_bag.s +++ b/data/battle_pyramid_bag.s @@ -3,60 +3,6 @@ .section .rodata - .align 2 -gUnknown_0861F2B4:: @ 861F2B4 - .4byte 0x000011f0, 0x000001e1, 0x000021de - - .align 2 -gUnknown_0861F2C0:: @ 861F2C0 - .4byte 0x00000000, sub_81C5460, sub_81C5518, 0x00000000, 0x00080000, 0x07003021 - - .align 2 -gUnknown_0861F2D8:: @ 861F2D8 - .4byte gMenuText_Use, sub_81C61E0 - .4byte gMenuText_Toss, sub_81C62C4 - .4byte gMenuText_Give, sub_81C6648 - .4byte gText_Cancel2, sub_81C6258 - .4byte gMenuText_Use, sub_81C679C - .4byte gText_EmptyString2, NULL - -gUnknown_0861F308:: @ 861F308 - .byte 0x00, 0x02, 0x01, 0x03 - -gUnknown_0861F30C:: @ 861F30C - .byte 0x01, 0x03 - -gUnknown_0861F30E:: @ 861F30E - .byte 0x04, 0x03 - -gUnknown_0861F310:: @ 861F310 - .byte 0x03, 0x00, 0x00, 0x00 - -gUnknown_0861F314:: @ 861F314 - .4byte sub_81C654C - .4byte sub_81C63D0 - -gUnknown_0861F31C:: @ 861F31C - .byte 0x00, 0x02, 0x03, 0x00, 0x03, 0x01, 0x01, 0x02, 0x03, 0x00, 0x00, 0x00 - - .align 2 -gUnknown_0861F328:: @ 861F328 - window_template 0x00, 0x0e, 0x02, 0x0f, 0x10, 0x0f, 0x001e - window_template 0x00, 0x00, 0x0d, 0x0e, 0x06, 0x0f, 0x010e - window_template 0x01, 0x02, 0x0f, 0x1b, 0x04, 0x0f, 0x0162 - window_template 0x01, 0x18, 0x11, 0x05, 0x02, 0x0f, 0x01ce - null_window_template - - .align 2 -gUnknown_0861F350:: @ 861F350 - window_template 0x01, 0x16, 0x11, 0x07, 0x02, 0x0f, 0x01d8 - window_template 0x01, 0x16, 0x0f, 0x07, 0x04, 0x0f, 0x01d8 - window_template 0x01, 0x0f, 0x0f, 0x0e, 0x04, 0x0f, 0x01d8 - window_template 0x01, 0x0f, 0x0d, 0x0e, 0x06, 0x0f, 0x01d8 - - .align 2 -gUnknown_0861F370:: @ 861F370 - window_template 0x01, 0x18, 0x0f, 0x05, 0x04, 0x0f, 0x01d8 .align 2 gOamData_861F378:: @ 861F378 diff --git a/include/battle_pyramid_bag.h b/include/battle_pyramid_bag.h new file mode 100644 index 000000000..5d5d8ccfa --- /dev/null +++ b/include/battle_pyramid_bag.h @@ -0,0 +1,49 @@ +#ifndef GUARD_BATTLE_PYRAMID_BAG_H +#define GUARD_BATTLE_PYRAMID_BAG_H + +#include "list_menu.h" + +struct PyramidBagResources +{ + void (*callback2)(void); + u8 tilemapBuffer[0x800]; + u8 itemsSpriteIds[PYRAMID_BAG_ITEMS_COUNT + 1]; + u8 windowIds[5]; + u8 unk814; + u8 unk815; + u8 scrollArrowSpriteId; + const u8 *menuActionIds; + u8 filler81C[0x820 - 0x81C]; + 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 state; + u8 filler986[0x98C - 0x986]; +}; + +struct PyramidBagCursorData +{ + void (*callback)(void); + u8 unk4; + u16 cursorPosition; + u16 scrollPosition; +}; + +extern struct PyramidBagResources *gPyramidBagResources; +extern struct PyramidBagCursorData gPyramidBagCursorData; + +void CB2_PyramidBagMenuFromStartMenu(void); +void sub_81C4F84(void); +void sub_81C5924(void); +void sub_81C59BC(void); +void sub_81C4EFC(void); +void sub_81C4F98(u8 a0, void (*callback)(void)); +void sub_81C6714(u8 taskId); +void sub_81C6A94(void); +void sub_81C4F24(void); +void sub_81C5B14(u8 taskId); +void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback)(u8 taskId)); + +#endif // GUARD_BATTLE_PYRAMID_BAG_H diff --git a/include/item_use.h b/include/item_use.h index 8f0ce272b..37343f6e7 100644 --- a/include/item_use.h +++ b/include/item_use.h @@ -51,6 +51,5 @@ 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/save.h b/include/save.h index 7b271129a..9859870b4 100644 --- a/include/save.h +++ b/include/save.h @@ -32,7 +32,7 @@ struct SaveSectionOffsets }; // Emerald changes this definition to be the sectors per slot. -#define NUM_SECTORS_PER_SLOT 16 // move to save.h +#define NUM_SECTORS_PER_SLOT 16 #define UNKNOWN_CHECK_VALUE 0x8012025 diff --git a/ld_script.txt b/ld_script.txt index a4219faf3..668cf7c5a 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -267,7 +267,6 @@ SECTIONS { src/pokemon_summary_screen.o(.text); src/unk_pokedex_area_screen_helper.o(.text); src/battle_pyramid_bag.o(.text); - asm/battle_pyramid_bag.o(.text); asm/pokenav.o(.text); src/match_call.o(.text); asm/pokenav.o(.text.after.match.call); @@ -545,6 +544,7 @@ SECTIONS { src/berry_fix_program.o(.rodata); src/pokemon_summary_screen.o(.rodata); src/unk_pokedex_area_screen_helper.o(.rodata); + src/battle_pyramid_bag.o(.rodata); data/battle_pyramid_bag.o(.rodata); data/pokenav.o(.rodata); src/match_call.o(.rodata); diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 721dfca98..9cb35074b 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -1,4 +1,5 @@ #include "global.h" +#include "battle_pyramid_bag.h" #include "main.h" #include "battle_controllers.h" #include "bg.h" @@ -28,122 +29,202 @@ #include "event_data.h" #include "text_window.h" #include "international_string_util.h" +#include "item_icon.h" #include "constants/items.h" #include "constants/rgb.h" #include "constants/songs.h" -EWRAM_DATA struct -{ - MainCallback callback2; - u8 tilemapBuffer[0x800]; - u8 itemsSpriteIds[PYRAMID_BAG_ITEMS_COUNT + 1]; - u8 windowIds[5]; - u8 unk814; - 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 PyramidBagResources *gPyramidBagResources = NULL; +EWRAM_DATA struct PyramidBagCursorData gPyramidBagCursorData = {0}; -EWRAM_DATA struct -{ - void (*callback)(void); - u8 unk4; - u16 unk6; - u16 unk8; -} 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; +// gfx +extern const u8 gUnknown_08D9ADD0[]; +extern const u8 gUnknown_08D9AE04[]; +extern const u8 gUnknown_08D9AF44[]; 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 SetBagItemsListTemplate(void); -void sub_81C5674(void); -void sub_81C56F8(void); -void sub_81C5924(void); -void sub_81C59BC(void); -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); +static void Task_HandlePyramidBagInput(u8 taskId); +static void sub_81C4F44(u8 taskId); +static void sub_81C5B4C(u8 taskId); +static void Task_BeginItemSwap(u8 taskId); +static void sub_81C5D20(u8 taskId); +static void sub_81C674C(u8 taskId); +static void HandleMenuActionInput(u8 taskId); +static void HandleFewMenuActionsInput(u8 taskId); +static void sub_81C66EC(u8 taskId); +static void SetTaskToMainPyramidBagInputHandler(u8 taskId); +static void sub_81C6350(u8 taskId); +static void sub_81C64B4(u8 taskId); +static void sub_81C65CC(u8 taskId); +static void sub_81C66AC(u8 taskId); +static void PerformItemSwap(u8 taskId); +static void Task_ItemSwapHandleInput(u8 taskId); +static void sub_81C6A14(u8 taskId); +static void SetBagItemsListTemplate(void); +static void sub_81C504C(void); +static void sub_81C51DC(void); +static void AddScrollArrow(void); +static void sub_81C56F8(void); +static void sub_81C5A20(void); +static void sub_81C6BD8(void); +static void sub_81C6EF4(void); +static void sub_81C700C(void); +static void sub_81C6E98(void); +static void sub_81C6F20(void); +static void sub_81C6404(void); +static void sub_81C6E1C(void); +static bool8 sub_81C5238(void); +static bool8 sub_81C5078(void); +static void ShowItemImage(u16 itemId, u8 itemSpriteArrayId); +static void PyramidBag_CopyItemName(u8 *dst, u16 itemId); +static void sub_81C6FF8(u8 arg0); +static void PrintItemDescription(s32 listMenuId); +static void sub_81C5AB8(u8 y, u8 arg1); +static void PrintOnWindow_Font1(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId); +static void PrintOnWindow_Font7(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId); +static u8 sub_81C6D24(u8 windowArrayId); +static void sub_81C6D6C(u8 windowArrayId); +static void sub_81C5EAC(u8 windowId); +static void sub_81C5F08(u8 windowId, u8 horizontalCount, u8 verticalCount); +static bool8 IsAValidMenuAction(s8 arg0); +static void sub_81C6DAC(u8 taskId, const struct YesNoFuncTable *yesNoTable); +static void sub_81C6CEC(u8 windowId); +static void sub_81C704C(u8 y); +static void sub_81C7028(bool8 invisible); +static void sub_81C6F68(struct Sprite *sprite); +static void BagAction_UseOnField(u8 taskId); +static void BagAction_Toss(u8 taskId); +static void BagAction_Give(u8 taskId); +static void BagAction_Cancel(u8 taskId); +static void BagAction_UseInBattle(u8 taskId); +static void PyramidBagMoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list); +static void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y); +static void TossItem(u8 taskId); +static void DontTossItem(u8 taskId); + +// Const rom data. +static const struct BgTemplate gUnknown_0861F2B4[] = +{ + { + .bg = 0, + .charBaseIndex = 0, + .mapBaseIndex = 31, + .screenSize = 0, + .paletteMode = 0, + .priority = 1, + .baseTile = 0 + }, + { + .bg = 1, + .charBaseIndex = 0, + .mapBaseIndex = 30, + .screenSize = 0, + .paletteMode = 0, + .priority = 0, + .baseTile = 0 + }, + { + .bg = 2, + .charBaseIndex = 3, + .mapBaseIndex = 29, + .screenSize = 0, + .paletteMode = 0, + .priority = 2, + .baseTile = 0 + }, +}; + +static const struct ListMenuTemplate gUnknown_0861F2C0 = +{ + .items = NULL, + .moveCursorFunc = PyramidBagMoveCursorFunc, + .itemPrintFunc = PrintItemQuantity, + .totalItems = 0, + .maxShowed = 0, + .windowId = 0, + .header_X = 0, + .item_X = 8, + .cursor_X = 0, + .upText_Y = 1, + .cursorPal = 2, + .fillValue = 0, + .cursorShadowPal = 3, + .lettersSpacing = 0, + .itemVerticalPadding = 0, + .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, + .fontId = 7, + .cursorKind = 0 +}; + +#define ACTION_USE_FIELD 0 +#define ACTION_TOSS 1 +#define ACTION_GIVE 2 +#define ACTION_CANCEL 3 +#define ACTION_USE_BATTLE 4 +#define ACTION_DUMMY 5 + +static const struct MenuAction sMenuActions[] = +{ + [ACTION_USE_FIELD] = { gMenuText_Use, BagAction_UseOnField }, + [ACTION_TOSS] = { gMenuText_Toss, BagAction_Toss }, + [ACTION_GIVE] = { gMenuText_Give, BagAction_Give }, + [ACTION_CANCEL] = { gText_Cancel2, BagAction_Cancel }, + [ACTION_USE_BATTLE] = { gMenuText_Use, BagAction_UseInBattle }, + [ACTION_DUMMY] = { gText_EmptyString2, NULL }, +}; + +static const u8 sFieldMenuActionIds[] = {ACTION_USE_FIELD, ACTION_GIVE, ACTION_TOSS, ACTION_CANCEL}; +static const u8 gUnknown_0861F30C[] = {ACTION_TOSS, ACTION_CANCEL}; +static const u8 sBattleMenuActionIds[] = {ACTION_USE_BATTLE, ACTION_CANCEL}; +static const u8 gUnknown_0861F310[] = {ACTION_CANCEL}; + +static const struct YesNoFuncTable sYesNoTossFuncions = +{ + TossItem, DontTossItem +}; + +static const u8 sColorTable[][3] = +{ + {0, 2, 3}, + {0, 3, 1}, + {1, 2, 3}, +}; + +static const struct WindowTemplate gUnknown_0861F328[] = +{ + {0x00, 0x0e, 0x02, 0x0f, 0x10, 0x0f, 0x001e}, + {0x00, 0x00, 0x0d, 0x0e, 0x06, 0x0f, 0x010e}, + {0x01, 0x02, 0x0f, 0x1b, 0x04, 0x0f, 0x0162}, + {0x01, 0x18, 0x11, 0x05, 0x02, 0x0f, 0x01ce}, + DUMMY_WIN_TEMPLATE, +}; + +static const struct WindowTemplate gUnknown_0861F350[] = +{ + {0x01, 0x16, 0x11, 0x07, 0x02, 0x0f, 0x01d8}, + {0x01, 0x16, 0x0f, 0x07, 0x04, 0x0f, 0x01d8}, + {0x01, 0x0f, 0x0f, 0x0e, 0x04, 0x0f, 0x01d8}, + {0x01, 0x0f, 0x0d, 0x0e, 0x06, 0x0f, 0x01d8}, + {0x01, 0x18, 0x0f, 0x05, 0x04, 0x0f, 0x01d8}, +}; + +extern const struct CompressedSpriteSheet gUnknown_0861F3CC; +extern const struct SpriteTemplate gUnknown_0861F3D4; // code void sub_81C4EEC(void) { - gUnknown_0203CF30.unk6 = 0; - gUnknown_0203CF30.unk8 = 0; + gPyramidBagCursorData.cursorPosition = 0; + gPyramidBagCursorData.scrollPosition = 0; } -void sub_81C4EFC(void) +void CB2_PyramidBagMenuFromStartMenu(void) { sub_81C4F98(0, CB2_ReturnToFieldWithOpenMenu); } -void sub_81C4F10(void) +static void sub_81C4F10(void) { sub_81C4F98(1, SetCB2ToReshowScreenAfterMenu2); } @@ -155,7 +236,7 @@ void sub_81C4F24(void) CreateTask(sub_81C4F44, 10); } -void sub_81C4F44(u8 taskId) +static void sub_81C4F44(u8 taskId) { if (!gPaletteFade.active) { @@ -168,30 +249,30 @@ void sub_81C4F44(u8 taskId) void sub_81C4F84(void) { - sub_81C4F98(4, gUnknown_0203CF30.callback); + sub_81C4F98(4, gPyramidBagCursorData.callback); } void sub_81C4F98(u8 a0, void (*callback)(void)) { - gUnknown_0203CF2C = AllocZeroed(sizeof(*gUnknown_0203CF2C)); + gPyramidBagResources = AllocZeroed(sizeof(*gPyramidBagResources)); if (a0 != 4) - gUnknown_0203CF30.unk4 = a0; + gPyramidBagCursorData.unk4 = a0; if (callback != NULL) - gUnknown_0203CF30.callback = callback; + gPyramidBagCursorData.callback = callback; - gUnknown_0203CF2C->callback2 = NULL; - gUnknown_0203CF2C->unk814 = 0xFF; - gUnknown_0203CF2C->unk816 = 0xFF; + gPyramidBagResources->callback2 = NULL; + gPyramidBagResources->unk814 = 0xFF; + gPyramidBagResources->scrollArrowSpriteId = 0xFF; - memset(gUnknown_0203CF2C->itemsSpriteIds, 0xFF, sizeof(gUnknown_0203CF2C->itemsSpriteIds)); - memset(gUnknown_0203CF2C->windowIds, 0xFF, sizeof(gUnknown_0203CF2C->windowIds)); + memset(gPyramidBagResources->itemsSpriteIds, 0xFF, sizeof(gPyramidBagResources->itemsSpriteIds)); + memset(gPyramidBagResources->windowIds, 0xFF, sizeof(gPyramidBagResources->windowIds)); SetMainCallback2(sub_81C504C); } -void sub_81C501C(void) +static void sub_81C501C(void) { RunTasks(); AnimateSprites(); @@ -200,19 +281,19 @@ void sub_81C501C(void) UpdatePaletteFade(); } -void sub_81C5038(void) +static void sub_81C5038(void) { LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); } -void sub_81C504C(void) +static void sub_81C504C(void) { while (sub_81221EC() != TRUE && sub_81C5078() != TRUE && sub_81221AC() != TRUE); } -bool8 sub_81C5078(void) +static bool8 sub_81C5078(void) { switch (gMain.state) { @@ -247,7 +328,7 @@ bool8 sub_81C5078(void) break; case 6: sub_81C51DC(); - gUnknown_0203CF2C->unk984 = 0; + gPyramidBagResources->state = 0; gMain.state++; break; case 7: @@ -279,7 +360,7 @@ bool8 sub_81C5078(void) gMain.state++; break; case 13: - sub_81C5674(); + AddScrollArrow(); gMain.state++; break; case 14: @@ -303,12 +384,12 @@ bool8 sub_81C5078(void) return FALSE; } -void sub_81C51DC(void) +static void sub_81C51DC(void) { ResetVramOamAndBgCntRegs(); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, gUnknown_0861F2B4, ARRAY_COUNT(gUnknown_0861F2B4)); - SetBgTilemapBuffer(2, gUnknown_0203CF2C->tilemapBuffer); + SetBgTilemapBuffer(2, gPyramidBagResources->tilemapBuffer); ResetAllBgsCoordinates(); schedule_bg_copy_tilemap_to_vram(2); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | @@ -320,67 +401,64 @@ void sub_81C51DC(void) SetGpuReg(REG_OFFSET_BLDCNT, 0); } -extern const u8 gUnknown_08D9AE04[]; -extern const u8 gUnknown_08D9AF44[]; - -bool8 sub_81C5238(void) +static bool8 sub_81C5238(void) { - switch (gUnknown_0203CF2C->unk984) + switch (gPyramidBagResources->state) { case 0: reset_temp_tile_data_buffers(); decompress_and_copy_tile_data_to_vram(2, gBagScreen_Gfx, 0, 0, 0); - gUnknown_0203CF2C->unk984++; + gPyramidBagResources->state++; break; case 1: if (free_temp_tile_data_buffers_if_possible() != TRUE) { - LZDecompressWram(gUnknown_08D9AE04, gUnknown_0203CF2C->tilemapBuffer); - gUnknown_0203CF2C->unk984++; + LZDecompressWram(gUnknown_08D9AE04, gPyramidBagResources->tilemapBuffer); + gPyramidBagResources->state++; } break; case 2: LoadCompressedPalette(gUnknown_08D9AF44, 0, 0x20); - gUnknown_0203CF2C->unk984++; + gPyramidBagResources->state++; break; case 3: LoadCompressedObjectPic(&gUnknown_0861F3CC); - gUnknown_0203CF2C->unk984++; + gPyramidBagResources->state++; break; case 4: sub_81C6E98(); - gUnknown_0203CF2C->unk984++; + gPyramidBagResources->state++; break; default: LoadListMenuArrowsGfx(); - gUnknown_0203CF2C->unk984 = 0; + gPyramidBagResources->state = 0; return TRUE; } return FALSE; } -void SetBagItemsListTemplate(void) +static void SetBagItemsListTemplate(void) { u16 i; u16 *pyramidItems = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; - for (i = 0; i < gUnknown_0203CF2C->listMenuCount - 1; i++) + for (i = 0; i < gPyramidBagResources->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; + PyramidBag_CopyItemName(gPyramidBagResources->itemStrings[i], pyramidItems[i]); + gPyramidBagResources->bagListItems[i].name = gPyramidBagResources->itemStrings[i]; + gPyramidBagResources->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; + StringCopy(gPyramidBagResources->itemStrings[i], gText_CloseBag); + gPyramidBagResources->bagListItems[i].name = gPyramidBagResources->itemStrings[i]; + gPyramidBagResources->bagListItems[i].id = LIST_B_PRESSED; gMultiuseListMenuTemplate = gUnknown_0861F2C0; - gMultiuseListMenuTemplate.totalItems = gUnknown_0203CF2C->listMenuCount; - gMultiuseListMenuTemplate.items = gUnknown_0203CF2C->bagListItems; - gMultiuseListMenuTemplate.maxShowed = gUnknown_0203CF2C->listMenuMaxShown; + gMultiuseListMenuTemplate.totalItems = gPyramidBagResources->listMenuCount; + gMultiuseListMenuTemplate.items = gPyramidBagResources->bagListItems; + gMultiuseListMenuTemplate.maxShowed = gPyramidBagResources->listMenuMaxShown; } -void PyramidBag_CopyItemName(u8 *dst, u16 itemId) +static void PyramidBag_CopyItemName(u8 *dst, u16 itemId) { if (ItemId_GetPocket(itemId) == POCKET_BERRIES) { @@ -394,34 +472,34 @@ void PyramidBag_CopyItemName(u8 *dst, u16 itemId) } } -void PyramidBagMoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list) +static void PyramidBagMoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list) { if (onInit != TRUE) { PlaySE(SE_SELECT); sub_81C6F20(); } - if (gUnknown_0203CF2C->unk814 == 0xFF) + if (gPyramidBagResources->unk814 == 0xFF) { - sub_81C6FF8(gUnknown_0203CF2C->unk815 ^ 1); + sub_81C6FF8(gPyramidBagResources->unk815 ^ 1); if (itemIndex != LIST_B_PRESSED) - ShowItemImage(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][itemIndex], gUnknown_0203CF2C->unk815); + ShowItemImage(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][itemIndex], gPyramidBagResources->unk815); else - ShowItemImage(0xFFFF, gUnknown_0203CF2C->unk815); - gUnknown_0203CF2C->unk815 ^= 1; + ShowItemImage(0xFFFF, gPyramidBagResources->unk815); + gPyramidBagResources->unk815 ^= 1; PrintItemDescription(itemIndex); } } -void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y) +static void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y) { s32 xAlign; if (itemIndex == LIST_B_PRESSED) return; - if (gUnknown_0203CF2C->unk814 != 0xFF) + if (gPyramidBagResources->unk814 != 0xFF) { - if (gUnknown_0203CF2C->unk814 == (u8)(itemIndex)) + if (gPyramidBagResources->unk814 == (u8)(itemIndex)) sub_81C5AB8(y, 1); else sub_81C5AB8(y, 0xFF); @@ -435,7 +513,7 @@ void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y) PrintOnWindow_Font7(windowId, gStringVar4, xAlign, y, 0, 0, TEXT_SPEED_FF, 0); } -void PrintItemDescription(s32 listMenuId) +static void PrintItemDescription(s32 listMenuId) { const u8 *desc; if (listMenuId != LIST_B_PRESSED) @@ -444,7 +522,7 @@ void PrintItemDescription(s32 listMenuId) } else { - StringCopy(gStringVar1, gReturnToXStringsTable2[gUnknown_0203CF30.unk4]); + StringCopy(gStringVar1, gReturnToXStringsTable2[gPyramidBagCursorData.unk4]); StringExpandPlaceholders(gStringVar4, gText_ReturnToVar1); desc = gStringVar4; } @@ -452,29 +530,29 @@ void PrintItemDescription(s32 listMenuId) PrintOnWindow_Font1(1, desc, 3, 0, 0, 1, 0, 0); } -void sub_81C5674(void) +static void AddScrollArrow(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); + if (gPyramidBagResources->scrollArrowSpriteId == 0xFF) + gPyramidBagResources->scrollArrowSpriteId = AddScrollIndicatorArrowPairParameterized(2, 172, 12, 148, gPyramidBagResources->listMenuCount - gPyramidBagResources->listMenuMaxShown, 0xB5E, 0xB5E, &gPyramidBagCursorData.scrollPosition); } -void sub_81C56CC(void) +static void RemoveScrollArrow(void) { - if (gUnknown_0203CF2C->unk816 != 0xFF) + if (gPyramidBagResources->scrollArrowSpriteId != 0xFF) { - RemoveScrollIndicatorArrowPair(gUnknown_0203CF2C->unk816); - gUnknown_0203CF2C->unk816 = 0xFF; + RemoveScrollIndicatorArrowPair(gPyramidBagResources->scrollArrowSpriteId); + gPyramidBagResources->scrollArrowSpriteId = 0xFF; } } -void sub_81C56F8(void) +static 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); + data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gPyramidBagCursorData.scrollPosition, gPyramidBagCursorData.cursorPosition); } -void SwapItems(u8 id1, u8 id2) +static void SwapItems(u8 id1, u8 id2) { u16 temp; u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; @@ -484,7 +562,7 @@ void SwapItems(u8 id1, u8 id2) SWAP(quantities[id1], quantities[id2], temp); } -void MovePyramidBagItemSlotInList(u8 from, u8 to) +static void MovePyramidBagItemSlotInList(u8 from, u8 to) { u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode]; @@ -517,7 +595,7 @@ void MovePyramidBagItemSlotInList(u8 from, u8 to) } } -void CompactItems(void) +static void CompactItems(void) { u8 i, j; u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; @@ -547,58 +625,58 @@ void sub_81C5924(void) u16 *itemIds = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; CompactItems(); - gUnknown_0203CF2C->listMenuCount = 0; + gPyramidBagResources->listMenuCount = 0; for (i = 0; i < PYRAMID_BAG_ITEMS_COUNT; i++) { if (itemIds[i] != 0) - gUnknown_0203CF2C->listMenuCount++; + gPyramidBagResources->listMenuCount++; } - gUnknown_0203CF2C->listMenuCount++; - if (gUnknown_0203CF2C->listMenuCount > 8) - gUnknown_0203CF2C->listMenuMaxShown = 8; + gPyramidBagResources->listMenuCount++; + if (gPyramidBagResources->listMenuCount > 8) + gPyramidBagResources->listMenuMaxShown = 8; else - gUnknown_0203CF2C->listMenuMaxShown = gUnknown_0203CF2C->listMenuCount; + gPyramidBagResources->listMenuMaxShown = gPyramidBagResources->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 (gPyramidBagCursorData.scrollPosition != 0 && gPyramidBagCursorData.scrollPosition + gPyramidBagResources->listMenuMaxShown > gPyramidBagResources->listMenuCount) + gPyramidBagCursorData.scrollPosition = gPyramidBagResources->listMenuCount - gPyramidBagResources->listMenuMaxShown; + if (gPyramidBagCursorData.scrollPosition + gPyramidBagCursorData.cursorPosition >= gPyramidBagResources->listMenuCount) { - if (gUnknown_0203CF2C->listMenuCount == 0) - gUnknown_0203CF30.unk6 = 0; + if (gPyramidBagResources->listMenuCount == 0) + gPyramidBagCursorData.cursorPosition = 0; else - gUnknown_0203CF30.unk6 = gUnknown_0203CF2C->listMenuCount - 1; + gPyramidBagCursorData.cursorPosition = gPyramidBagResources->listMenuCount - 1; } } -void sub_81C5A20(void) +static void sub_81C5A20(void) { u8 i; - if (gUnknown_0203CF30.unk6 > 4) + if (gPyramidBagCursorData.cursorPosition > 4) { - for (i = 0; i <= gUnknown_0203CF30.unk6 - 4; i++) + for (i = 0; i <= gPyramidBagCursorData.cursorPosition - 4; i++) { - if (gUnknown_0203CF30.unk8 + gUnknown_0203CF2C->listMenuMaxShown == gUnknown_0203CF2C->listMenuCount) + if (gPyramidBagCursorData.scrollPosition + gPyramidBagResources->listMenuMaxShown == gPyramidBagResources->listMenuCount) { // daycare.c sends its regards. break; } - gUnknown_0203CF30.unk6--; - gUnknown_0203CF30.unk8++; + gPyramidBagCursorData.cursorPosition--; + gPyramidBagCursorData.scrollPosition++; } } } -void sub_81C5A98(u8 listMenuTaskId, u8 arg1) +static void sub_81C5A98(u8 listMenuTaskId, u8 arg1) { u8 y = ListMenuGetYCoordForPrintingArrowCursor(listMenuTaskId); sub_81C5AB8(y, arg1); } -void sub_81C5AB8(u8 y, u8 arg1) +static void sub_81C5AB8(u8 y, u8 arg1) { if (arg1 == 0xFF) FillWindowPixelRect(0, 0, 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); @@ -612,46 +690,46 @@ void sub_81C5B14(u8 taskId) gTasks[taskId].func = sub_81C5B4C; } -void sub_81C5B4C(u8 taskId) +static 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); + DestroyListMenuTask(data[0], &gPyramidBagCursorData.scrollPosition, &gPyramidBagCursorData.cursorPosition); + if (gPyramidBagResources->callback2 != NULL) + SetMainCallback2(gPyramidBagResources->callback2); else - SetMainCallback2(gUnknown_0203CF30.callback); - sub_81C56CC(); + SetMainCallback2(gPyramidBagCursorData.callback); + RemoveScrollArrow(); ResetSpriteData(); FreeAllSpritePalettes(); FreeAllWindowBuffers(); - Free(gUnknown_0203CF2C); + Free(gPyramidBagResources); DestroyTask(taskId); } } -void Task_HandlePyramidBagInput(u8 taskId) +static 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) + if (gPyramidBagCursorData.unk4 != 2) { - ListMenuGetScrollAndRow(data[0], &gUnknown_0203CF30.unk8, &gUnknown_0203CF30.unk6); - if (gUnknown_0203CF30.unk8 + gUnknown_0203CF30.unk6 != gUnknown_0203CF2C->listMenuCount - 1) + ListMenuGetScrollAndRow(data[0], &gPyramidBagCursorData.scrollPosition, &gPyramidBagCursorData.cursorPosition); + if (gPyramidBagCursorData.scrollPosition + gPyramidBagCursorData.cursorPosition != gPyramidBagResources->listMenuCount - 1) { PlaySE(SE_SELECT); - sub_81C67CC(taskId); + Task_BeginItemSwap(taskId); } } } else { s32 listId = ListMenuHandleInputGetItemId(data[0]); - ListMenuGetScrollAndRow(data[0], &gUnknown_0203CF30.unk8, &gUnknown_0203CF30.unk6); + ListMenuGetScrollAndRow(data[0], &gPyramidBagCursorData.scrollPosition, &gPyramidBagCursorData.cursorPosition); switch (listId) { case LIST_NOTHING_CHOSEN: @@ -666,7 +744,7 @@ void Task_HandlePyramidBagInput(u8 taskId) 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) + if (gPyramidBagCursorData.unk4 == 2) sub_81C674C(taskId); else sub_81C5D20(taskId); @@ -676,33 +754,33 @@ void Task_HandlePyramidBagInput(u8 taskId) } } -void sub_81C5D20(u8 taskId) +static void sub_81C5D20(u8 taskId) { s16 *data = gTasks[taskId].data; - sub_81C56CC(); + RemoveScrollArrow(); sub_81C5A98(data[0], 1); - switch (gUnknown_0203CF30.unk4) + switch (gPyramidBagCursorData.unk4) { default: - gUnknown_0203CF2C->menuActionIds = gUnknown_0861F308; - gUnknown_0203CF2C->menuActionsCount = ARRAY_COUNT(gUnknown_0861F308); + gPyramidBagResources->menuActionIds = sFieldMenuActionIds; + gPyramidBagResources->menuActionsCount = ARRAY_COUNT(sFieldMenuActionIds); break; case 1: if (ItemId_GetBattleUsage(gSpecialVar_ItemId)) { - gUnknown_0203CF2C->menuActionIds = gUnknown_0861F30E; - gUnknown_0203CF2C->menuActionsCount = ARRAY_COUNT(gUnknown_0861F30E); + gPyramidBagResources->menuActionIds = sBattleMenuActionIds; + gPyramidBagResources->menuActionsCount = ARRAY_COUNT(sBattleMenuActionIds); } else { - gUnknown_0203CF2C->menuActionIds = gUnknown_0861F310; - gUnknown_0203CF2C->menuActionsCount = ARRAY_COUNT(gUnknown_0861F310); + gPyramidBagResources->menuActionIds = gUnknown_0861F310; + gPyramidBagResources->menuActionsCount = ARRAY_COUNT(gUnknown_0861F310); } break; case 3: - gUnknown_0203CF2C->menuActionIds = gUnknown_0861F30C; - gUnknown_0203CF2C->menuActionsCount = ARRAY_COUNT(gUnknown_0861F30C); + gPyramidBagResources->menuActionIds = gUnknown_0861F30C; + gPyramidBagResources->menuActionsCount = ARRAY_COUNT(gUnknown_0861F30C); break; } @@ -710,32 +788,32 @@ void sub_81C5D20(u8 taskId) StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected); FillWindowPixelBuffer(1, 0); PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0); - if (gUnknown_0203CF2C->menuActionsCount == 1) + if (gPyramidBagResources->menuActionsCount == 1) sub_81C5EAC(sub_81C6D24(0)); - else if (gUnknown_0203CF2C->menuActionsCount == 2) + else if (gPyramidBagResources->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; + if (gPyramidBagResources->menuActionsCount == 4) + gTasks[taskId].func = HandleMenuActionInput; else - gTasks[taskId].func = sub_81C5F68; + gTasks[taskId].func = HandleFewMenuActionsInput; } -void sub_81C5EAC(u8 windowId) +static 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); + AddItemMenuActionTextPrinters(windowId, 7, 8, 1, 0, 0x10, gPyramidBagResources->menuActionsCount, sMenuActions, gPyramidBagResources->menuActionIds); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, gPyramidBagResources->menuActionsCount, 0); } -void sub_81C5F08(u8 windowId, u8 horizontalCount, u8 verticalCount) +static void sub_81C5F08(u8 windowId, u8 horizontalCount, u8 verticalCount) { - sub_8198DBC(windowId, 7, 8, 1, 0x38, horizontalCount, verticalCount, gUnknown_0861F2D8, gUnknown_0203CF2C->menuActionIds); + sub_8198DBC(windowId, 7, 8, 1, 0x38, horizontalCount, verticalCount, sMenuActions, gPyramidBagResources->menuActionIds); sub_8199944(windowId, 0x38, horizontalCount, verticalCount, 0); } -void sub_81C5F68(u8 taskId) +static void HandleFewMenuActionsInput(u8 taskId) { if (sub_81221EC() != TRUE) { @@ -746,25 +824,25 @@ void sub_81C5F68(u8 taskId) break; case -1: PlaySE(SE_SELECT); - gUnknown_0861F2D8[3].func.void_u8(taskId); + sMenuActions[ACTION_CANCEL].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); + if (sMenuActions[gPyramidBagResources->menuActionIds[id]].func.void_u8 != NULL) + sMenuActions[gPyramidBagResources->menuActionIds[id]].func.void_u8(taskId); break; } } } -void sub_81C5FE4(u8 taskId) +static void HandleMenuActionInput(u8 taskId) { if (sub_81221EC() != TRUE) { s8 id = GetMenuCursorPos(); if (gMain.newKeys & DPAD_UP) { - if (id > 0 && sub_81C616C(id - 2)) + if (id > 0 && IsAValidMenuAction(id - 2)) { PlaySE(SE_SELECT); sub_8199134(0, -1); @@ -772,7 +850,7 @@ void sub_81C5FE4(u8 taskId) } else if (gMain.newKeys & DPAD_DOWN) { - if (id < gUnknown_0203CF2C->menuActionsCount - 2 && sub_81C616C(id + 2)) + if (id < gPyramidBagResources->menuActionsCount - 2 && IsAValidMenuAction(id + 2)) { PlaySE(SE_SELECT); sub_8199134(0, 1); @@ -780,7 +858,7 @@ void sub_81C5FE4(u8 taskId) } else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) { - if (id & 1 && sub_81C616C(id - 1)) + if (id & 1 && IsAValidMenuAction(id - 1)) { PlaySE(SE_SELECT); sub_8199134(-1, 0); @@ -788,7 +866,7 @@ void sub_81C5FE4(u8 taskId) } else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) { - if (!(id & 1) && sub_81C616C(id + 1)) + if (!(id & 1) && IsAValidMenuAction(id + 1)) { PlaySE(SE_SELECT); sub_8199134(1, 0); @@ -797,40 +875,40 @@ void sub_81C5FE4(u8 taskId) 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); + if (sMenuActions[gPyramidBagResources->menuActionIds[id]].func.void_u8 != NULL) + sMenuActions[gPyramidBagResources->menuActionIds[id]].func.void_u8(taskId); } else if (gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); - gUnknown_0861F2D8[3].func.void_u8(taskId); + sMenuActions[ACTION_CANCEL].func.void_u8(taskId); } } } -bool8 sub_81C616C(s8 arg0) +static bool8 IsAValidMenuAction(s8 actionTableId) { - if (arg0 < 0) + if (actionTableId < 0) return FALSE; - else if (arg0 > gUnknown_0203CF2C->menuActionsCount) + else if (actionTableId > gPyramidBagResources->menuActionsCount) return FALSE; - else if (gUnknown_0203CF2C->menuActionIds[arg0] == 5) + else if (gPyramidBagResources->menuActionIds[actionTableId] == ACTION_DUMMY) return FALSE; else return TRUE; } -void sub_81C61A8(void) +static void sub_81C61A8(void) { - if (gUnknown_0203CF2C->menuActionsCount == 1) + if (gPyramidBagResources->menuActionsCount == 1) sub_81C6D6C(0); - else if (gUnknown_0203CF2C->menuActionsCount == 2) + else if (gPyramidBagResources->menuActionsCount == 2) sub_81C6D6C(1); else sub_81C6D6C(2); } -void sub_81C61E0(u8 taskId) +static void BagAction_UseOnField(u8 taskId) { u8 pocketId = ItemId_GetPocket(gSpecialVar_ItemId); @@ -851,7 +929,7 @@ void sub_81C61E0(u8 taskId) } } -void sub_81C6258(u8 taskId) +static void BagAction_Cancel(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -860,16 +938,16 @@ void sub_81C6258(u8 taskId) schedule_bg_copy_tilemap_to_vram(0); schedule_bg_copy_tilemap_to_vram(1); sub_81C5A98(data[0], 0); - sub_81C629C(taskId); + SetTaskToMainPyramidBagInputHandler(taskId); } -void sub_81C629C(u8 taskId) +static void SetTaskToMainPyramidBagInputHandler(u8 taskId) { - sub_81C5674(); + AddScrollArrow(); gTasks[taskId].func = Task_HandlePyramidBagInput; } -void sub_81C62C4(u8 taskId) +static void BagAction_Toss(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -890,7 +968,7 @@ void sub_81C62C4(u8 taskId) } } -void sub_81C6350(u8 taskId) +static void sub_81C6350(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -899,19 +977,19 @@ void sub_81C6350(u8 taskId) StringExpandPlaceholders(gStringVar4, gText_ConfirmTossItems); FillWindowPixelBuffer(1, 0); PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0); - sub_81C6DAC(taskId, &gUnknown_0861F314); + sub_81C6DAC(taskId, &sYesNoTossFuncions); } -void sub_81C63D0(u8 taskId) +static void DontTossItem(u8 taskId) { s16 *data = gTasks[taskId].data; PrintItemDescription(data[1]); sub_81C5A98(data[0], 0); - sub_81C629C(taskId); + SetTaskToMainPyramidBagInputHandler(taskId); } -void sub_81C6404(void) +static void sub_81C6404(void) { s32 x; @@ -922,7 +1000,7 @@ void sub_81C6404(void) PrintTextOnWindow(3, 1, gStringVar4, x, 2, 0, NULL); } -void sub_81C645C(s16 value) +static void sub_81C645C(s16 value) { s32 x; @@ -932,7 +1010,7 @@ void sub_81C645C(s16 value) PrintTextOnWindow(3, 1, gStringVar4, x, 2, 0, NULL); } -void sub_81C64B4(u8 taskId) +static void sub_81C64B4(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -954,11 +1032,11 @@ void sub_81C64B4(u8 taskId) sub_8198070(3, 0); ClearWindowTilemap(3); schedule_bg_copy_tilemap_to_vram(1); - sub_81C63D0(taskId); + DontTossItem(taskId); } } -void sub_81C654C(u8 taskId) +static void TossItem(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -970,11 +1048,11 @@ void sub_81C654C(u8 taskId) gTasks[taskId].func = sub_81C65CC; } -void sub_81C65CC(u8 taskId) +static void sub_81C65CC(u8 taskId) { s16 *data = gTasks[taskId].data; - u16 *scrollOffset = &gUnknown_0203CF30.unk8; - u16 *selectedRow = &gUnknown_0203CF30.unk6; + u16 *scrollOffset = &gPyramidBagCursorData.scrollPosition; + u16 *selectedRow = &gPyramidBagCursorData.cursorPosition; if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { @@ -986,11 +1064,11 @@ void sub_81C65CC(u8 taskId) SetBagItemsListTemplate(); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollOffset, *selectedRow); schedule_bg_copy_tilemap_to_vram(0); - sub_81C629C(taskId); + SetTaskToMainPyramidBagInputHandler(taskId); } } -void sub_81C6648(u8 taskId) +static void BagAction_Give(u8 taskId) { sub_81C61A8(); if (ItemIsMail(gSpecialVar_ItemId) == TRUE) @@ -999,7 +1077,7 @@ void sub_81C6648(u8 taskId) } else if (!ItemId_GetImportance(gSpecialVar_ItemId)) { - gUnknown_0203CF2C->callback2 = sub_81B7F60; + gPyramidBagResources->callback2 = sub_81B7F60; sub_81C5B14(taskId); } else @@ -1008,14 +1086,14 @@ void sub_81C6648(u8 taskId) } } -void sub_81C66AC(u8 taskId) +static void sub_81C66AC(u8 taskId) { CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeld); DisplayItemMessageInBattlePyramid(taskId, gStringVar4, sub_81C66EC); } -void sub_81C66EC(u8 taskId) +static void sub_81C66EC(u8 taskId) { if (gMain.newKeys & A_BUTTON) { @@ -1031,10 +1109,10 @@ void sub_81C6714(u8 taskId) sub_81C6E1C(); PrintItemDescription(data[1]); sub_81C5A98(data[0], 0); - sub_81C629C(taskId); + SetTaskToMainPyramidBagInputHandler(taskId); } -void sub_81C674C(u8 taskId) +static void sub_81C674C(u8 taskId) { if (!itemid_80BF6D8_mail_related(gSpecialVar_ItemId)) DisplayItemMessageInBattlePyramid(taskId, gText_CantWriteMail, sub_81C66EC); @@ -1044,7 +1122,7 @@ void sub_81C674C(u8 taskId) sub_81C66AC(taskId); } -void sub_81C679C(u8 taskId) +static void BagAction_UseInBattle(u8 taskId) { if (ItemId_GetBattleFunc(gSpecialVar_ItemId) != NULL) { @@ -1053,12 +1131,12 @@ void sub_81C679C(u8 taskId) } } -void sub_81C67CC(u8 taskId) +static void Task_BeginItemSwap(u8 taskId) { s16 *data = gTasks[taskId].data; - data[1] = gUnknown_0203CF30.unk8 + gUnknown_0203CF30.unk6; - gUnknown_0203CF2C->unk814 = data[1]; + data[1] = gPyramidBagCursorData.scrollPosition + gPyramidBagCursorData.cursorPosition; + gPyramidBagResources->unk814 = data[1]; ListMenuSetUnkIndicatorsStructField(data[0], 0x10, 1); CopyItemName(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][data[1]], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where); @@ -1066,10 +1144,10 @@ void sub_81C67CC(u8 taskId) PrintOnWindow_Font1(1, gStringVar4, 3, 0, 0, 1, 0, 0); sub_81C5A98(data[0], 1); sub_81C704C(data[1]); - gTasks[taskId].func = sub_81C68B0; + gTasks[taskId].func = Task_ItemSwapHandleInput; } -void sub_81C68B0(u8 taskId) +static void Task_ItemSwapHandleInput(u8 taskId) { s16 *data = gTasks[taskId].data; if (sub_81221EC() != TRUE) @@ -1077,15 +1155,15 @@ void sub_81C68B0(u8 taskId) if (gMain.newKeys & SELECT_BUTTON) { PlaySE(SE_SELECT); - ListMenuGetScrollAndRow(data[0], &gUnknown_0203CF30.unk8, &gUnknown_0203CF30.unk6); - sub_81C6964(taskId); + ListMenuGetScrollAndRow(data[0], &gPyramidBagCursorData.scrollPosition, &gPyramidBagCursorData.cursorPosition); + PerformItemSwap(taskId); } else { s32 id = ListMenuHandleInputGetItemId(data[0]); - ListMenuGetScrollAndRow(data[0], &gUnknown_0203CF30.unk8, &gUnknown_0203CF30.unk6); - sub_81C7028(0); - sub_81C704C(gUnknown_0203CF30.unk6); + ListMenuGetScrollAndRow(data[0], &gPyramidBagCursorData.scrollPosition, &gPyramidBagCursorData.cursorPosition); + sub_81C7028(FALSE); + sub_81C704C(gPyramidBagCursorData.cursorPosition); switch (id) { case LIST_NOTHING_CHOSEN: @@ -1093,24 +1171,24 @@ void sub_81C68B0(u8 taskId) case LIST_B_PRESSED: PlaySE(SE_SELECT); if (gMain.newKeys & A_BUTTON) - sub_81C6964(taskId); + PerformItemSwap(taskId); else sub_81C6A14(taskId); break; default: PlaySE(SE_SELECT); - sub_81C6964(taskId); + PerformItemSwap(taskId); break; } } } } -void sub_81C6964(u8 taskId) +static void PerformItemSwap(u8 taskId) { s16 *data = gTasks[taskId].data; - u16 *scrollOffset = &gUnknown_0203CF30.unk8; - u16 *selectedRow = &gUnknown_0203CF30.unk6; + u16 *scrollOffset = &gPyramidBagCursorData.scrollPosition; + u16 *selectedRow = &gPyramidBagCursorData.cursorPosition; u16 var = *scrollOffset + *selectedRow; if (data[1] == var || data[1] == var - 1) @@ -1120,31 +1198,31 @@ void sub_81C6964(u8 taskId) else { MovePyramidBagItemSlotInList(data[1], var); - gUnknown_0203CF2C->unk814 = 0xFF; - sub_81C7028(1); + gPyramidBagResources->unk814 = 0xFF; + sub_81C7028(TRUE); DestroyListMenuTask(data[0], scrollOffset, selectedRow); if (data[1] < var) - gUnknown_0203CF30.unk6--; + gPyramidBagCursorData.cursorPosition--; SetBagItemsListTemplate(); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollOffset, *selectedRow); - sub_81C629C(taskId); + SetTaskToMainPyramidBagInputHandler(taskId); } } -void sub_81C6A14(u8 taskId) +static void sub_81C6A14(u8 taskId) { s16 *data = gTasks[taskId].data; - u16 *scrollOffset = &gUnknown_0203CF30.unk8; - u16 *selectedRow = &gUnknown_0203CF30.unk6; + u16 *scrollOffset = &gPyramidBagCursorData.scrollPosition; + u16 *selectedRow = &gPyramidBagCursorData.cursorPosition; - gUnknown_0203CF2C->unk814 = 0xFF; - sub_81C7028(1); + gPyramidBagResources->unk814 = 0xFF; + sub_81C7028(TRUE); DestroyListMenuTask(data[0], scrollOffset, selectedRow); if (data[1] < *scrollOffset + *selectedRow) - gUnknown_0203CF30.unk6--; + gPyramidBagCursorData.cursorPosition--; SetBagItemsListTemplate(); data[0] = ListMenuInit(&gMultiuseListMenuTemplate, *scrollOffset, *selectedRow); - sub_81C629C(taskId); + SetTaskToMainPyramidBagInputHandler(taskId); } void sub_81C6A94(void) @@ -1181,7 +1259,7 @@ void sub_81C6A94(void) Free(newQuantities); } -void sub_81C6BD8(void) +static void sub_81C6BD8(void) { u8 i; @@ -1200,30 +1278,30 @@ void sub_81C6BD8(void) 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) +static 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); + AddTextPrinterParameterized2(windowId, 1, x, y, letterSpacing, lineSpacing, sColorTable[colorTableId], speed, src); } -void PrintOnWindow_Font7(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId) +static 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); + AddTextPrinterParameterized2(windowId, 7, x, y, letterSpacing, lineSpacing, sColorTable[colorTableId], speed, src); } -void sub_81C6CEC(u8 windowId) +static void sub_81C6CEC(u8 windowId) { SetWindowBorderStyle(windowId, 0, 1, 0xE); schedule_bg_copy_tilemap_to_vram(1); } -u8 sub_81C6D08(u8 windowArrayId) +static u8 sub_81C6D08(u8 windowArrayId) { - return gUnknown_0203CF2C->windowIds[windowArrayId]; + return gPyramidBagResources->windowIds[windowArrayId]; } -u8 sub_81C6D24(u8 windowArrayId) +static u8 sub_81C6D24(u8 windowArrayId) { - u8 *windowId = &gUnknown_0203CF2C->windowIds[windowArrayId]; + u8 *windowId = &gPyramidBagResources->windowIds[windowArrayId]; if (*windowId == 0xFF) { *windowId = AddWindow(&gUnknown_0861F350[windowArrayId]); @@ -1233,9 +1311,9 @@ u8 sub_81C6D24(u8 windowArrayId) return *windowId; } -void sub_81C6D6C(u8 windowArrayId) +static void sub_81C6D6C(u8 windowArrayId) { - u8 *windowId = &gUnknown_0203CF2C->windowIds[windowArrayId]; + u8 *windowId = &gPyramidBagResources->windowIds[windowArrayId]; if (*windowId != 0xFF) { sub_8198070(*windowId, FALSE); @@ -1245,3 +1323,112 @@ void sub_81C6D6C(u8 windowArrayId) *windowId = 0xFF; } } + +static void sub_81C6DAC(u8 taskId, const struct YesNoFuncTable *yesNoTable) +{ + CreateYesNoMenuWithCallbacks(taskId, &gUnknown_0861F350[4], 1, 0, 2, 1, 0xE, yesNoTable); +} + +void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback)(u8 taskId)) +{ + FillWindowPixelBuffer(2, 0x11); + DisplayMessageAndContinueTask(taskId, 2, 0xA, 0xD, 1, GetPlayerTextSpeed(), str, callback); + schedule_bg_copy_tilemap_to_vram(1); +} + +static void sub_81C6E1C(void) +{ + sub_8197DF8(2, FALSE); + ClearWindowTilemap(2); + schedule_bg_copy_tilemap_to_vram(1); +} + +#define ITEM_IMAGE_TAG 0x1024 + +static void sub_81C6E38(u8 itemSpriteArrayId) +{ + u8 *spriteId = &gPyramidBagResources->itemsSpriteIds[itemSpriteArrayId]; + if (*spriteId != 0xFF) + { + FreeSpriteTilesByTag(ITEM_IMAGE_TAG + itemSpriteArrayId); + FreeSpritePaletteByTag(ITEM_IMAGE_TAG + itemSpriteArrayId); + FreeSpriteOamMatrix(&gSprites[*spriteId]); + DestroySprite(&gSprites[*spriteId]); + *spriteId = 0xFF; + } +} + +static void sub_81C6E98(void) +{ + struct SpritePalette spritePalette; + u16 *palPtr = Alloc(0x40); + + LZDecompressWram(gUnknown_08D9ADD0, palPtr); + spritePalette.data = palPtr + (gSaveBlock2Ptr->frontier.lvlMode * 16); + spritePalette.tag = ITEM_IMAGE_TAG; + LoadSpritePalette(&spritePalette); + Free(palPtr); +} + +static void sub_81C6EF4(void) +{ + u8 *spriteId = &gPyramidBagResources->itemsSpriteIds[0]; + *spriteId = CreateSprite(&gUnknown_0861F3D4, 0x44, 0x38, 0); +} + +static void sub_81C6F20(void) +{ + struct Sprite *sprite = &gSprites[gPyramidBagResources->itemsSpriteIds[0]]; + if (sprite->affineAnimEnded) + { + StartSpriteAffineAnim(sprite, 1); + sprite->callback = sub_81C6F68; + } +} + +static void sub_81C6F68(struct Sprite *sprite) +{ + if (sprite->affineAnimEnded) + { + StartSpriteAffineAnim(sprite, 0); + sprite->callback = SpriteCallbackDummy; + } +} + +static void ShowItemImage(u16 itemId, u8 itemSpriteArrayId) +{ + u8 itemSpriteId; + u8 *spriteId = &gPyramidBagResources->itemsSpriteIds[itemSpriteArrayId + 1]; + if (*spriteId == 0xFF) + { + FreeSpriteTilesByTag(ITEM_IMAGE_TAG + 1 + itemSpriteArrayId); + FreeSpritePaletteByTag(ITEM_IMAGE_TAG + 1 + itemSpriteArrayId); + itemSpriteId = AddItemIconSprite(ITEM_IMAGE_TAG + 1 + itemSpriteArrayId, ITEM_IMAGE_TAG + 1 + itemSpriteArrayId, itemId); + if (itemSpriteId != MAX_SPRITES) + { + *spriteId = itemSpriteId; + gSprites[itemSpriteId].pos2.x = 24; + gSprites[itemSpriteId].pos2.y = 88; + } + } +} + +static void sub_81C6FF8(u8 itemSpriteArrayId) +{ + sub_81C6E38(itemSpriteArrayId + 1); +} + +static void sub_81C700C(void) +{ + sub_8122344(&gPyramidBagResources->itemsSpriteIds[3], 8); +} + +static void sub_81C7028(bool8 invisible) +{ + sub_81223FC(&gPyramidBagResources->itemsSpriteIds[3], 8, invisible); +} + +static void sub_81C704C(u8 y) +{ + sub_8122448(&gPyramidBagResources->itemsSpriteIds[3], 8 | 0x80, 120, (y + 1) * 16); +} diff --git a/src/item.c b/src/item.c index 29c250989..3866d7316 100644 --- a/src/item.c +++ b/src/item.c @@ -10,6 +10,7 @@ #include "item_menu.h" #include "strings.h" #include "load_save.h" +#include "battle_pyramid_bag.h" extern bool8 InBattlePyramid(void); extern u16 gUnknown_0203CF30[]; @@ -965,7 +966,7 @@ bool8 RemovePyramidBagItem(u16 itemId, u16 count) u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode]; - i = gUnknown_0203CF30[3] + gUnknown_0203CF30[4]; + i = gPyramidBagCursorData.cursorPosition + gPyramidBagCursorData.scrollPosition; if (items[i] == itemId && quantities[i] >= count) { quantities[i] -= count; diff --git a/src/item_use.c b/src/item_use.c index 23c829391..bf7c2a386 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -33,8 +33,8 @@ #include "pokeblock.h" #include "menu.h" #include "item_menu.h" +#include "battle_pyramid_bag.h" -extern void(**gUnknown_0203CF2C)(void); extern void(*gUnknown_0203A0F4)(u8 taskId); extern void(*gUnknown_085920D8[])(void); extern void (*gUnknown_03006328)(u8, u16, TaskFunc); @@ -122,7 +122,7 @@ void SetUpItemUseCallback(u8 taskId) } else { - *gUnknown_0203CF2C = gUnknown_085920D8[type]; + gPyramidBagResources->callback2 = gUnknown_085920D8[type]; sub_81C5B14(taskId); } } @@ -987,7 +987,7 @@ void sub_80FE54C(u8 taskId) } else { - *gUnknown_0203CF2C = sub_81B89F0; + gPyramidBagResources->callback2 = sub_81B89F0; sub_81C5B14(taskId); } } diff --git a/src/start_menu.c b/src/start_menu.c index 60271317a..4a58c146e 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -33,6 +33,7 @@ #include "international_string_util.h" #include "constants/songs.h" #include "field_player_avatar.h" +#include "battle_pyramid_bag.h" // Menu actions enum @@ -73,12 +74,11 @@ EWRAM_DATA static u8 sSaveDialogTimer = 0; EWRAM_DATA static bool8 sSavingComplete = FALSE; EWRAM_DATA static u8 sSaveInfoWindowId = 0; -// Extern variables +// Extern variables. extern u8 gDifferentSaveFile; -extern u16 gSaveFileStatus; extern u8 gUnknown_03005DB4; -// Extern functions in uncompiled files +// Extern functions in not decompiled files. extern void sub_80AF688(void); extern void var_800D_set_xB(void); extern void sub_808B864(void); @@ -89,7 +89,6 @@ extern void CB2_PokeNav(void); extern void sub_80C4DDC(void (*)(void)); extern void sub_80C51C4(void (*)(void)); extern void sub_80C4E74(u8, void (*)(void)); -extern void sub_81C4EFC(void); extern void ScriptUnfreezeEventObjects(void); extern void sub_81A9EC8(void); extern void save_serialize_map(void); @@ -781,7 +780,7 @@ static bool8 StartMenuBattlePyramidBagCallback(void) play_some_sound(); RemoveExtraStartMenuWindows(); overworld_free_bg_tilemaps(); - SetMainCallback2(sub_81C4EFC); // Display battle pyramid bag + SetMainCallback2(CB2_PyramidBagMenuFromStartMenu); return TRUE; } From 43b74032fa981a06e2e66fe5a2d4cf2edaad27c8 Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 30 Aug 2018 20:25:57 +0200 Subject: [PATCH 3/4] Make pyramid bag compile. --- src/battle_controller_player.c | 4 +--- src/battle_controller_safari.c | 2 +- src/battle_controller_wally.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index ffe8936a0..7f038a0c3 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -28,7 +28,7 @@ #include "pokeball.h" #include "data2.h" #include "battle_setup.h" -#include "item_use.h" +#include "item_menu.h" #include "recorded_battle.h" #include "party_menu.h" #include "battle_dome.h" @@ -40,7 +40,6 @@ extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; extern struct UnusedControllerStruct gUnknown_02022D0C; extern struct MusicPlayerInfo gMPlayInfo_BGM; -extern struct SpriteTemplate gMultiuseSpriteTemplate; extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[]; @@ -52,7 +51,6 @@ extern void sub_81851A8(u8 *); // this file's functions static void PlayerHandleGetMonData(void); -void PlayerHandleGetRawMonData(void); static void PlayerHandleSetMonData(void); static void PlayerHandleSetRawMonData(void); static void PlayerHandleLoadMonSprite(void); diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index bc97c01f9..aab804b41 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -21,7 +21,7 @@ #include "pokeball.h" #include "data2.h" #include "pokeblock.h" -#include "item_use.h" +#include "item_menu.h" extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 960181fbc..4faf78681 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -29,7 +29,7 @@ #include "data2.h" #include "party_menu.h" #include "battle_setup.h" -#include "item_use.h" +#include "item_menu.h" extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; From 96f2b995dc67d1278bd65b3661426da95503cb5d Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Thu, 30 Aug 2018 21:28:03 +0200 Subject: [PATCH 4/4] Pyramid bag review changes --- src/battle_pyramid_bag.c | 12 ++++++------ src/item.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 9cb35074b..8a5ce7a99 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -87,7 +87,7 @@ static u8 sub_81C6D24(u8 windowArrayId); static void sub_81C6D6C(u8 windowArrayId); static void sub_81C5EAC(u8 windowId); static void sub_81C5F08(u8 windowId, u8 horizontalCount, u8 verticalCount); -static bool8 IsAValidMenuAction(s8 arg0); +static bool8 IsValidMenuAction(s8 arg0); static void sub_81C6DAC(u8 taskId, const struct YesNoFuncTable *yesNoTable); static void sub_81C6CEC(u8 windowId); static void sub_81C704C(u8 y); @@ -842,7 +842,7 @@ static void HandleMenuActionInput(u8 taskId) s8 id = GetMenuCursorPos(); if (gMain.newKeys & DPAD_UP) { - if (id > 0 && IsAValidMenuAction(id - 2)) + if (id > 0 && IsValidMenuAction(id - 2)) { PlaySE(SE_SELECT); sub_8199134(0, -1); @@ -850,7 +850,7 @@ static void HandleMenuActionInput(u8 taskId) } else if (gMain.newKeys & DPAD_DOWN) { - if (id < gPyramidBagResources->menuActionsCount - 2 && IsAValidMenuAction(id + 2)) + if (id < gPyramidBagResources->menuActionsCount - 2 && IsValidMenuAction(id + 2)) { PlaySE(SE_SELECT); sub_8199134(0, 1); @@ -858,7 +858,7 @@ static void HandleMenuActionInput(u8 taskId) } else if (gMain.newKeys & DPAD_LEFT || GetLRKeysState() == 1) { - if (id & 1 && IsAValidMenuAction(id - 1)) + if (id & 1 && IsValidMenuAction(id - 1)) { PlaySE(SE_SELECT); sub_8199134(-1, 0); @@ -866,7 +866,7 @@ static void HandleMenuActionInput(u8 taskId) } else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysState() == 2) { - if (!(id & 1) && IsAValidMenuAction(id + 1)) + if (!(id & 1) && IsValidMenuAction(id + 1)) { PlaySE(SE_SELECT); sub_8199134(1, 0); @@ -886,7 +886,7 @@ static void HandleMenuActionInput(u8 taskId) } } -static bool8 IsAValidMenuAction(s8 actionTableId) +static bool8 IsValidMenuAction(s8 actionTableId) { if (actionTableId < 0) return FALSE; diff --git a/src/item.c b/src/item.c index 3866d7316..b4a2fd6f0 100644 --- a/src/item.c +++ b/src/item.c @@ -754,7 +754,7 @@ u16 BagGetQuantityByPocketPosition(u8 pocketId, u16 pocketPos) static void SwapItemSlots(struct ItemSlot *a, struct ItemSlot *b) { struct ItemSlot temp; - SWAP(*a, *b, temp); + SWAP(*a, *b, temp); } void CompactItemsInBagPocket(struct BagPocket *bagPocket)