From e7cf8e5c1713c624b7b9db7a58c6c812e90ec7a9 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 12 Mar 2018 13:56:20 +0530 Subject: [PATCH 1/6] Start decompile player_pc --- asm/player_pc.s | 2531 +++++++++-------- data/event_scripts.s | 2 +- data/player_pc.s | 28 +- .../maps/LittlerootTown_BrendansHouse_2F.inc | 2 +- .../maps/LittlerootTown_MaysHouse_2F.inc | 2 +- data/specials.inc | 4 +- include/event_scripts.h | 4 + include/item_menu.h | 1 + include/menu.h | 1 + include/player_pc.h | 75 +- include/strings.h | 4 + ld_script.txt | 1 + src/decoration.c | 2 +- src/player_pc.c | 702 +++++ sym_ewram.txt | 7 +- 15 files changed, 2075 insertions(+), 1291 deletions(-) create mode 100644 src/player_pc.c diff --git a/asm/player_pc.s b/asm/player_pc.s index 8a329a2fe..8c8bde42d 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -5,1286 +5,1289 @@ .text - thumb_func_start NewGameInitPCItems -NewGameInitPCItems: @ 816ADF4 - push {r4-r6,lr} - movs r4, 0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x93 - lsls r1, 3 - adds r0, r1 - movs r1, 0x32 - bl ClearItemSlots - ldr r1, =gUnknown_085DFEFC - ldrh r0, [r1] - cmp r0, 0 - beq _0816AE48 - ldrh r0, [r1, 0x2] - cmp r0, 0 - beq _0816AE48 - adds r5, r1, 0 - adds r6, r5, 0x2 -_0816AE1A: - lsls r1, r4, 2 - adds r0, r1, r5 - ldrh r0, [r0] - adds r1, r6 - ldrh r1, [r1] - bl AddPCItem - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0816AE48 - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - lsls r1, r4, 2 - adds r0, r1, r5 - ldrh r0, [r0] - cmp r0, 0 - beq _0816AE48 - adds r0, r1, r6 - ldrh r0, [r0] - cmp r0, 0 - bne _0816AE1A -_0816AE48: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end NewGameInitPCItems + .equ gPcItemMenuOptionOrder, 0x0203BCB0 + .equ gPcItemMenuOptionsNum, 0x0203BCB4 + +// thumb_func_start NewGameInitPCItems +//NewGameInitPCItems: @ 816ADF4 +// push {r4-r6,lr} +// movs r4, 0 +// ldr r0, =gSaveBlock1Ptr +// ldr r0, [r0] +// movs r1, 0x93 +// lsls r1, 3 +// adds r0, r1 +// movs r1, 0x32 +// bl ClearItemSlots +// ldr r1, =gUnknown_085DFEFC +// ldrh r0, [r1] +// cmp r0, 0 +// beq _0816AE48 +// ldrh r0, [r1, 0x2] +// cmp r0, 0 +// beq _0816AE48 +// adds r5, r1, 0 +// adds r6, r5, 0x2 +//_0816AE1A: +// lsls r1, r4, 2 +// adds r0, r1, r5 +// ldrh r0, [r0] +// adds r1, r6 +// ldrh r1, [r1] +// bl AddPCItem +// lsls r0, 24 +// lsrs r0, 24 +// cmp r0, 0x1 +// bne _0816AE48 +// adds r0, r4, 0x1 +// lsls r0, 24 +// lsrs r4, r0, 24 +// lsls r1, r4, 2 +// adds r0, r1, r5 +// ldrh r0, [r0] +// cmp r0, 0 +// beq _0816AE48 +// adds r0, r1, r6 +// ldrh r0, [r0] +// cmp r0, 0 +// bne _0816AE1A +//_0816AE48: +// pop {r4-r6} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end NewGameInitPCItems - thumb_func_start sub_816AE58 -sub_816AE58: @ 816AE58 - push {lr} - ldr r1, =gUnknown_0203BCB0 - ldr r0, =gUnknown_085DFED4 - str r0, [r1] - ldr r1, =gUnknown_0203BCB4 - movs r0, 0x4 - strb r0, [r1] - ldr r0, =TaskDummy - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gText_WhatWouldYouLike - ldr r2, =sub_816AED8 - bl DisplayItemMessageOnField - pop {r0} - bx r0 - .pool - thumb_func_end sub_816AE58 +// thumb_func_start sub_816AE58 +//sub_816AE58: @ 816AE58 +// push {lr} +// ldr r1, =gPcItemMenuOptionOrder +// ldr r0, =gUnknown_085DFED4 +// str r0, [r1] +// ldr r1, =gPcItemMenuOptionsNum +// movs r0, 0x4 +// strb r0, [r1] +// ldr r0, =TaskDummy +// movs r1, 0 +// bl CreateTask +// lsls r0, 24 +// lsrs r0, 24 +// ldr r1, =gText_WhatWouldYouLike +// ldr r2, =InitPlayerPCMenu +// bl DisplayItemMessageOnField +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816AE58 - thumb_func_start sub_816AE98 -sub_816AE98: @ 816AE98 - push {lr} - ldr r1, =gUnknown_0203BCB0 - ldr r0, =gUnknown_085DFED8 - str r0, [r1] - ldr r1, =gUnknown_0203BCB4 - movs r0, 0x3 - strb r0, [r1] - ldr r0, =TaskDummy - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gText_WhatWouldYouLike - ldr r2, =sub_816AED8 - bl DisplayItemMessageOnField - pop {r0} - bx r0 - .pool - thumb_func_end sub_816AE98 +// thumb_func_start sub_816AE98 +//sub_816AE98: @ 816AE98 +// push {lr} +// ldr r1, =gPcItemMenuOptionOrder +// ldr r0, =gUnknown_085DFED8 +// str r0, [r1] +// ldr r1, =gPcItemMenuOptionsNum +// movs r0, 0x3 +// strb r0, [r1] +// ldr r0, =TaskDummy +// movs r1, 0 +// bl CreateTask +// lsls r0, 24 +// lsrs r0, 24 +// ldr r1, =gText_WhatWouldYouLike +// ldr r2, =InitPlayerPCMenu +// bl DisplayItemMessageOnField +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816AE98 - thumb_func_start sub_816AED8 -sub_816AED8: @ 816AED8 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r7, r0, 24 - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - ldr r0, =gUnknown_0203BCB4 - ldrb r1, [r0] - mov r8, r0 - cmp r1, 0x3 - bne _0816AF0C - ldr r0, =gUnknown_085DFF24 - ldr r1, [r0, 0x4] - ldr r0, [r0] - b _0816AF12 - .pool -_0816AF0C: - ldr r0, =gUnknown_085DFF24 - ldr r1, [r0, 0xC] - ldr r0, [r0, 0x8] -_0816AF12: - str r0, [sp] - str r1, [sp, 0x4] - ldr r5, =gUnknown_085DFEB4 - ldr r4, =gUnknown_0203BCB0 - ldr r1, [r4] - mov r0, r8 - ldrb r2, [r0] - adds r0, r5, 0 - bl sub_81DB3D8 - lsls r0, 24 - ldr r2, =0x00ffffff - ldr r1, [sp] - ands r1, r2 - orrs r1, r0 - str r1, [sp] - mov r0, sp - bl AddWindow - strh r0, [r6, 0x8] - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl SetStandardWindowBorderStyle - ldrb r0, [r6, 0x8] - mov r2, r8 - ldrb r1, [r2] - ldr r3, [r4] - adds r2, r5, 0 - bl sub_81995E4 - ldrb r0, [r6, 0x8] - mov r2, r8 - ldrb r1, [r2] - movs r2, 0 - bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816AF98 - str r1, [r0] - add sp, 0x8 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816AED8 +// thumb_func_start InitPlayerPCMenu +//InitPlayerPCMenu: @ 816AED8 +// push {r4-r7,lr} +// mov r7, r8 +// push {r7} +// sub sp, 0x8 +// lsls r0, 24 +// lsrs r7, r0, 24 +// lsls r0, r7, 2 +// adds r0, r7 +// lsls r0, 3 +// ldr r1, =gTasks + 0x8 +// adds r6, r0, r1 +// ldr r0, =gPcItemMenuOptionsNum +// ldrb r1, [r0] +// mov r8, r0 +// cmp r1, 0x3 +// bne _0816AF0C +// ldr r0, =gUnknown_085DFF24 +// ldr r1, [r0, 0x4] +// ldr r0, [r0] +// b _0816AF12 +// .pool +//_0816AF0C: +// ldr r0, =gUnknown_085DFF24 +// ldr r1, [r0, 0xC] +// ldr r0, [r0, 0x8] +//_0816AF12: +// str r0, [sp] +// str r1, [sp, 0x4] +// ldr r5, =gUnknown_085DFEB4 +// ldr r4, =gPcItemMenuOptionOrder +// ldr r1, [r4] +// mov r0, r8 +// ldrb r2, [r0] +// adds r0, r5, 0 +// bl sub_81DB3D8 +// lsls r0, 24 +// ldr r2, =0x00ffffff +// ldr r1, [sp] +// ands r1, r2 +// orrs r1, r0 +// str r1, [sp] +// mov r0, sp +// bl AddWindow +// strh r0, [r6, 0x8] +// lsls r0, 24 +// lsrs r0, 24 +// movs r1, 0 +// bl SetStandardWindowBorderStyle +// ldrb r0, [r6, 0x8] +// mov r2, r8 +// ldrb r1, [r2] +// ldr r3, [r4] +// adds r2, r5, 0 +// bl sub_81995E4 +// ldrb r0, [r6, 0x8] +// mov r2, r8 +// ldrb r1, [r2] +// movs r2, 0 +// bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed +// movs r0, 0 +// bl schedule_bg_copy_tilemap_to_vram +// ldr r1, =gTasks +// lsls r0, r7, 2 +// adds r0, r7 +// lsls r0, 3 +// adds r0, r1 +// ldr r1, =sub_816AF98 +// str r1, [r0] +// add sp, 0x8 +// pop {r3} +// mov r8, r3 +// pop {r4-r7} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end InitPlayerPCMenu - thumb_func_start sub_816AF98 -sub_816AF98: @ 816AF98 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - ldr r0, =gUnknown_0203BCB4 - ldrb r0, [r0] - cmp r0, 0x3 - bls _0816AFC0 - bl ProcessMenuInput - b _0816AFC4 - .pool -_0816AFC0: - bl ProcessMenuInputNoWrapAround -_0816AFC4: - lsls r0, 24 - lsrs r0, 24 - lsls r0, 24 - asrs r5, r0, 24 - movs r0, 0x2 - negs r0, r0 - cmp r5, r0 - beq _0816B04C - adds r0, 0x1 - cmp r5, r0 - bne _0816B014 - movs r0, 0x5 - bl PlaySE - ldrb r0, [r4, 0x8] - movs r1, 0 - bl sub_8198070 - ldrb r0, [r4, 0x8] - bl ClearWindowTilemap - ldrb r0, [r4, 0x8] - bl RemoveWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816B148 - str r1, [r0] - b _0816B04C - .pool -_0816B014: - ldrb r0, [r4, 0x8] - movs r1, 0 - bl sub_8198070 - ldrb r0, [r4, 0x8] - bl ClearWindowTilemap - ldrb r0, [r4, 0x8] - bl RemoveWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r0, =gTasks - lsls r1, r6, 2 - adds r1, r6 - lsls r1, 3 - adds r1, r0 - ldr r2, =gUnknown_085DFEB4 - ldr r0, =gUnknown_0203BCB0 - ldr r0, [r0] - adds r0, r5 - ldrb r0, [r0] - lsls r0, 3 - adds r2, 0x4 - adds r0, r2 - ldr r0, [r0] - str r0, [r1] -_0816B04C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816AF98 +// thumb_func_start PlayerPCProcessMenuInput +//PlayerPCProcessMenuInput: @ 816AF98 +// push {r4-r6,lr} +// lsls r0, 24 +// lsrs r6, r0, 24 +// lsls r0, r6, 2 +// adds r0, r6 +// lsls r0, 3 +// ldr r1, =gTasks + 0x8 +// adds r4, r0, r1 +// ldr r0, =gPcItemMenuOptionsNum +// ldrb r0, [r0] +// cmp r0, 0x3 +// bls _0816AFC0 +// bl ProcessMenuInput +// b _0816AFC4 +// .pool +//_0816AFC0: +// bl ProcessMenuInputNoWrapAround +//_0816AFC4: +// lsls r0, 24 +// lsrs r0, 24 +// lsls r0, 24 +// asrs r5, r0, 24 +// movs r0, 0x2 +// negs r0, r0 +// cmp r5, r0 +// beq _0816B04C +// adds r0, 0x1 +// cmp r5, r0 +// bne _0816B014 +// movs r0, 0x5 +// bl PlaySE +// ldrb r0, [r4, 0x8] +// movs r1, 0 +// bl sub_8198070 +// ldrb r0, [r4, 0x8] +// bl ClearWindowTilemap +// ldrb r0, [r4, 0x8] +// bl RemoveWindow +// movs r0, 0 +// bl schedule_bg_copy_tilemap_to_vram +// ldr r1, =gTasks +// lsls r0, r6, 2 +// adds r0, r6 +// lsls r0, 3 +// adds r0, r1 +// ldr r1, =PlayerPC_TurnOff +// str r1, [r0] +// b _0816B04C +// .pool +//_0816B014: +// ldrb r0, [r4, 0x8] +// movs r1, 0 +// bl sub_8198070 +// ldrb r0, [r4, 0x8] +// bl ClearWindowTilemap +// ldrb r0, [r4, 0x8] +// bl RemoveWindow +// movs r0, 0 +// bl schedule_bg_copy_tilemap_to_vram +// ldr r0, =gTasks +// lsls r1, r6, 2 +// adds r1, r6 +// lsls r1, 3 +// adds r1, r0 +// ldr r2, =sPlayerPCMenuActions +// ldr r0, =gPcItemMenuOptionOrder +// ldr r0, [r0] +// adds r0, r5 +// ldrb r0, [r0] +// lsls r0, 3 +// adds r2, 0x4 +// adds r0, r2 +// ldr r0, [r0] +// str r0, [r1] +//_0816B04C: +// pop {r4-r6} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end PlayerPCProcessMenuInput - thumb_func_start sub_816B060 -sub_816B060: @ 816B060 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gText_WhatWouldYouLike - ldr r2, =sub_816AED8 - bl DisplayItemMessageOnField - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B060 +// thumb_func_start ReshowPlayerPC +//ReshowPlayerPC: @ 816B060 +// push {lr} +// lsls r0, 24 +// lsrs r0, 24 +// ldr r1, =gText_WhatWouldYouLike +// ldr r2, =InitPlayerPCMenu +// bl DisplayItemMessageOnField +// pop {r0} +// bx r0 +// .pool +// thumb_func_end ReshowPlayerPC - thumb_func_start task_pc_itemstorage -task_pc_itemstorage: @ 816B07C - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - movs r1, 0 - bl sub_816B190 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816B248 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task_pc_itemstorage +// thumb_func_start PlayerPC_ItemStorage +//PlayerPC_ItemStorage: @ 816B07C +// push {r4,lr} +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// adds r0, r4, 0 +// movs r1, 0 +// bl InitItemStorageMenu +// ldr r1, =gTasks +// lsls r0, r4, 2 +// adds r0, r4 +// lsls r0, 3 +// adds r0, r1 +// ldr r1, =ItemStorageMenuProcessInput +// str r1, [r0] +// pop {r4} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end PlayerPC_ItemStorage - thumb_func_start sub_816B0A8 -sub_816B0A8: @ 816B0A8 - push {r4-r6,lr} - lsls r0, 24 - lsrs r4, r0, 24 - adds r6, r4, 0 - bl sub_816B510 - ldr r5, =gUnknown_0203BCB8 - movs r1, 0 - strb r0, [r5, 0x5] - lsls r0, 24 - cmp r0, 0 - bne _0816B0D8 - ldr r1, =gText_NoMailHere - ldr r2, =sub_816B060 - adds r0, r4, 0 - bl DisplayItemMessageOnField - b _0816B12A - .pool -_0816B0D8: - strh r1, [r5] - strh r1, [r5, 0x2] - movs r0, 0xFF - strb r0, [r5, 0x9] - bl sub_816B54C - adds r0, r4, 0 - bl sub_816B4C0 - ldrb r0, [r5, 0x5] - bl sub_81D1C44 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0816B120 - movs r0, 0 - movs r1, 0 - bl sub_8197434 - adds r0, r4, 0 - bl sub_816B5F8 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_816B674 - str r0, [r1] - b _0816B12A - .pool -_0816B120: - ldr r1, =gText_NoMailHere - ldr r2, =sub_816B060 - adds r0, r6, 0 - bl DisplayItemMessageOnField -_0816B12A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B0A8 +// thumb_func_start PlayerPC_Mailbox +//PlayerPC_Mailbox: @ 816B0A8 +// push {r4-r6,lr} +// lsls r0, 24 +// lsrs r4, r0, 24 +// adds r6, r4, 0 +// bl GetMailboxMailCount +// ldr r5, =gUnknown_0203BCB8 +// movs r1, 0 +// strb r0, [r5, 0x5] +// lsls r0, 24 +// cmp r0, 0 +// bne _0816B0D8 +// ldr r1, =gText_NoMailHere +// ldr r2, =ReshowPlayerPC +// adds r0, r4, 0 +// bl DisplayItemMessageOnField +// b _0816B12A +// .pool +//_0816B0D8: +// strh r1, [r5] +// strh r1, [r5, 0x2] +// movs r0, 0xFF +// strb r0, [r5, 0x9] +// bl Mailbox_UpdateMailList +// adds r0, r4, 0 +// bl ItemStorage_SetItemAndMailCount +// ldrb r0, [r5, 0x5] +// bl sub_81D1C44 +// lsls r0, 24 +// lsrs r0, 24 +// cmp r0, 0x1 +// bne _0816B120 +// movs r0, 0 +// movs r1, 0 +// bl sub_8197434 +// adds r0, r4, 0 +// bl Mailbox_DrawMailboxMenu +// ldr r0, =gTasks +// lsls r1, r4, 2 +// adds r1, r4 +// lsls r1, 3 +// adds r1, r0 +// ldr r0, =Mailbox_ProcessInput +// str r0, [r1] +// b _0816B12A +// .pool +//_0816B120: +// ldr r1, =gText_NoMailHere +// ldr r2, =ReshowPlayerPC +// adds r0, r6, 0 +// bl DisplayItemMessageOnField +//_0816B12A: +// pop {r4-r6} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end PlayerPC_Mailbox - thumb_func_start sub_816B138 -sub_816B138: @ 816B138 - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl sub_8126B2C - pop {r0} - bx r0 - thumb_func_end sub_816B138 +// thumb_func_start PlayerPC_Decoration +//PlayerPC_Decoration: @ 816B138 +// push {lr} +// lsls r0, 24 +// lsrs r0, 24 +// bl sub_8126B2C +// pop {r0} +// bx r0 +// thumb_func_end PlayerPC_Decoration - thumb_func_start sub_816B148 -sub_816B148: @ 816B148 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gUnknown_0203BCB4 - ldrb r0, [r0] - cmp r0, 0x4 - bne _0816B180 - ldr r0, =gSaveBlock2Ptr - ldr r0, [r0] - ldrb r0, [r0, 0x8] - cmp r0, 0 - bne _0816B174 - ldr r0, =LittlerootTown_BrendansHouse_2F_EventScript_1F863F - bl ScriptContext1_SetupScript - b _0816B184 - .pool -_0816B174: - ldr r0, =LittlerootTown_MaysHouse_2F_EventScript_1F958F - bl ScriptContext1_SetupScript - b _0816B184 - .pool -_0816B180: - bl EnableBothScriptContexts -_0816B184: - adds r0, r4, 0 - bl DestroyTask - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_816B148 +// thumb_func_start PlayerPC_TurnOff +//PlayerPC_TurnOff: @ 816B148 +// push {r4,lr} +// lsls r0, 24 +// lsrs r4, r0, 24 +// ldr r0, =gPcItemMenuOptionsNum +// ldrb r0, [r0] +// cmp r0, 0x4 +// bne _0816B180 +// ldr r0, =gSaveBlock2Ptr +// ldr r0, [r0] +// ldrb r0, [r0, 0x8] +// cmp r0, 0 +// bne _0816B174 +// ldr r0, =LittlerootTown_BrendansHouse_2F_EventScript_1F863F +// bl ScriptContext1_SetupScript +// b _0816B184 +// .pool +//_0816B174: +// ldr r0, =LittlerootTown_MaysHouse_2F_EventScript_1F958F +// bl ScriptContext1_SetupScript +// b _0816B184 +// .pool +//_0816B180: +// bl EnableBothScriptContexts +//_0816B184: +// adds r0, r4, 0 +// bl DestroyTask +// pop {r4} +// pop {r0} +// bx r0 +// thumb_func_end PlayerPC_TurnOff - thumb_func_start sub_816B190 -sub_816B190: @ 816B190 - push {r4-r6,lr} - sub sp, 0x8 - adds r5, r1, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldr r0, =gUnknown_085DFF24 - ldr r1, [r0, 0x14] - ldr r0, [r0, 0x10] - str r0, [sp] - str r1, [sp, 0x4] - ldr r6, =gUnknown_085DFEDC - adds r0, r6, 0 - movs r1, 0x4 - bl GetMaxWidthInMenuTable - lsls r0, 24 - ldr r2, =0x00ffffff - ldr r1, [sp] - ands r1, r2 - orrs r1, r0 - str r1, [sp] - mov r0, sp - bl AddWindow - strh r0, [r4, 0x8] - lsls r0, 24 - lsrs r0, 24 - movs r1, 0 - bl SetStandardWindowBorderStyle - ldrb r0, [r4, 0x8] - movs r1, 0x4 - adds r2, r6, 0 - bl PrintMenuTable - ldrb r0, [r4, 0x8] - movs r1, 0x4 - adds r2, r5, 0 - bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r0, =gUnknown_085DFEA4 - lsls r5, 2 - adds r5, r0 - ldr r0, [r5] - bl sub_816B21C - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B190 +// thumb_func_start InitItemStorageMenu +//InitItemStorageMenu: @ 816B190 +// push {r4-r6,lr} +// sub sp, 0x8 +// adds r5, r1, 0 +// lsls r0, 24 +// lsrs r0, 24 +// lsls r5, 24 +// lsrs r5, 24 +// lsls r4, r0, 2 +// adds r4, r0 +// lsls r4, 3 +// ldr r0, =gTasks + 0x8 +// adds r4, r0 +// ldr r0, =gUnknown_085DFF24 +// ldr r1, [r0, 0x14] +// ldr r0, [r0, 0x10] +// str r0, [sp] +// str r1, [sp, 0x4] +// ldr r6, =gPCText_ItemPCOptionsText +// adds r0, r6, 0 +// movs r1, 0x4 +// bl GetMaxWidthInMenuTable +// lsls r0, 24 +// ldr r2, =0x00ffffff +// ldr r1, [sp] +// ands r1, r2 +// orrs r1, r0 +// str r1, [sp] +// mov r0, sp +// bl AddWindow +// strh r0, [r4, 0x8] +// lsls r0, 24 +// lsrs r0, 24 +// movs r1, 0 +// bl SetStandardWindowBorderStyle +// ldrb r0, [r4, 0x8] +// movs r1, 0x4 +// adds r2, r6, 0 +// bl PrintMenuTable +// ldrb r0, [r4, 0x8] +// movs r1, 0x4 +// adds r2, r5, 0 +// bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed +// movs r0, 0 +// bl schedule_bg_copy_tilemap_to_vram +// ldr r0, =gPCText_OptionDescList +// lsls r5, 2 +// adds r5, r0 +// ldr r0, [r5] +// bl sub_816B21C +// add sp, 0x8 +// pop {r4-r6} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end InitItemStorageMenu - thumb_func_start sub_816B21C -sub_816B21C: @ 816B21C - push {r4,lr} - sub sp, 0xC - adds r4, r0, 0 - movs r0, 0 - movs r1, 0 - bl NewMenuHelpers_DrawDialogueFrame - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0 - bl PrintTextOnWindow - add sp, 0xC - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_816B21C +// thumb_func_start sub_816B21C +//sub_816B21C: @ 816B21C +// push {r4,lr} +// sub sp, 0xC +// adds r4, r0, 0 +// movs r0, 0 +// movs r1, 0 +// bl NewMenuHelpers_DrawDialogueFrame +// movs r0, 0x1 +// str r0, [sp] +// movs r0, 0 +// str r0, [sp, 0x4] +// str r0, [sp, 0x8] +// movs r1, 0x1 +// adds r2, r4, 0 +// movs r3, 0 +// bl PrintTextOnWindow +// add sp, 0xC +// pop {r4} +// pop {r0} +// bx r0 +// thumb_func_end sub_816B21C - thumb_func_start sub_816B248 -sub_816B248: @ 816B248 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - bl GetMenuCursorPos - lsls r0, 24 - lsrs r5, r0, 24 - bl ProcessMenuInput - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl GetMenuCursorPos - lsls r0, 24 - lsrs r2, r0, 24 - lsls r4, 24 - asrs r4, 24 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _0816B298 - adds r0, 0x1 - cmp r4, r0 - beq _0816B2B4 - movs r0, 0x5 - bl PlaySE - ldr r0, =gUnknown_085DFEDC - lsls r1, r4, 3 - adds r0, 0x4 - adds r1, r0 - ldr r1, [r1] - adds r0, r6, 0 - bl _call_via_r1 - b _0816B2C0 - .pool -_0816B298: - lsls r1, r5, 24 - lsls r0, r2, 24 - asrs r2, r0, 24 - cmp r1, r0 - beq _0816B2C0 - ldr r0, =gUnknown_085DFEA4 - lsls r1, r2, 2 - adds r1, r0 - ldr r0, [r1] - bl sub_816B21C - b _0816B2C0 - .pool -_0816B2B4: - movs r0, 0x5 - bl PlaySE - adds r0, r6, 0 - bl sub_816B4A4 -_0816B2C0: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_816B248 +// thumb_func_start ItemStorageMenuProcessInput +//ItemStorageMenuProcessInput: @ 816B248 +// push {r4-r6,lr} +// lsls r0, 24 +// lsrs r6, r0, 24 +// bl GetMenuCursorPos +// lsls r0, 24 +// lsrs r5, r0, 24 +// bl ProcessMenuInput +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// bl GetMenuCursorPos +// lsls r0, 24 +// lsrs r2, r0, 24 +// lsls r4, 24 +// asrs r4, 24 +// movs r0, 0x2 +// negs r0, r0 +// cmp r4, r0 +// beq _0816B298 +// adds r0, 0x1 +// cmp r4, r0 +// beq _0816B2B4 +// movs r0, 0x5 +// bl PlaySE +// ldr r0, =gPCText_ItemPCOptionsText +// lsls r1, r4, 3 +// adds r0, 0x4 +// adds r1, r0 +// ldr r1, [r1] +// adds r0, r6, 0 +// bl _call_via_r1 +// b _0816B2C0 +// .pool +//_0816B298: +// lsls r1, r5, 24 +// lsls r0, r2, 24 +// asrs r2, r0, 24 +// cmp r1, r0 +// beq _0816B2C0 +// ldr r0, =gPCText_OptionDescList +// lsls r1, r2, 2 +// adds r1, r0 +// ldr r0, [r1] +// bl ItemStorageMenuPrint +// b _0816B2C0 +// .pool +//_0816B2B4: +// movs r0, 0x5 +// bl PlaySE +// adds r0, r6, 0 +// bl ItemStorage_Exit +//_0816B2C0: +// pop {r4-r6} +// pop {r0} +// bx r0 +// thumb_func_end ItemStorageMenuProcessInput - thumb_func_start sub_816B2C8 -sub_816B2C8: @ 816B2C8 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r2, =gTasks - lsls r1, r0, 2 - adds r1, r0 - lsls r1, 3 - adds r1, r2 - ldr r0, =sub_816B2F0 - str r0, [r1] - movs r0, 0x1 - movs r1, 0 - bl FadeScreen - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B2C8 +// thumb_func_start ItemStorage_Deposit +//ItemStorage_Deposit: @ 816B2C8 +// push {lr} +// lsls r0, 24 +// lsrs r0, 24 +// ldr r2, =gTasks +// lsls r1, r0, 2 +// adds r1, r0 +// lsls r1, 3 +// adds r1, r2 +// ldr r0, =sub_816B2F0 +// str r0, [r1] +// movs r0, 0x1 +// movs r1, 0 +// bl FadeScreen +// pop {r0} +// bx r0 +// .pool +// thumb_func_end ItemStorage_Deposit +// +// thumb_func_start sub_816B2F0 +//sub_816B2F0: @ 816B2F0 +// push {r4,lr} +// lsls r0, 24 +// lsrs r4, r0, 24 +// ldr r0, =gPaletteFade +// ldrb r1, [r0, 0x7] +// movs r0, 0x80 +// ands r0, r1 +// cmp r0, 0 +// bne _0816B310 +// bl overworld_free_bg_tilemaps +// bl sub_81AAC14 +// adds r0, r4, 0 +// bl DestroyTask +//_0816B310: +// pop {r4} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B2F0 - thumb_func_start sub_816B2F0 -sub_816B2F0: @ 816B2F0 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0816B310 - bl overworld_free_bg_tilemaps - bl sub_81AAC14 - adds r0, r4, 0 - bl DestroyTask -_0816B310: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B2F0 +// thumb_func_start sub_816B31C +//sub_816B31C: @ 816B31C +// push {lr} +// ldr r0, =gFieldCallback +// ldr r1, =mapldr_080EBC0C +// str r1, [r0] +// ldr r0, =CB2_ReturnToField +// bl SetMainCallback2 +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B31C +// +// thumb_func_start mapldr_080EBC0C +//mapldr_080EBC0C: @ 816B33C +// push {lr} +// bl sub_81973A4 +// movs r0, 0 +// movs r1, 0x1 +// bl NewMenuHelpers_DrawDialogueFrame +// ldr r0, =ItemStorage_HandleReturnToProcessInput +// movs r1, 0 +// bl CreateTask +// lsls r0, 24 +// lsrs r0, 24 +// movs r1, 0x1 +// bl InitItemStorageMenu +// bl pal_fill_black +// pop {r0} +// bx r0 +// .pool +// thumb_func_end mapldr_080EBC0C +// +// thumb_func_start ItemStorage_HandleReturnToProcessInput +//ItemStorage_HandleReturnToProcessInput: @ 816B368 +// push {r4,lr} +// lsls r0, 24 +// lsrs r4, r0, 24 +// bl sub_80ABDFC +// lsls r0, 24 +// lsrs r0, 24 +// cmp r0, 0x1 +// bne _0816B388 +// ldr r0, =gTasks +// lsls r1, r4, 2 +// adds r1, r4 +// lsls r1, 3 +// adds r1, r0 +// ldr r0, =ItemStorageMenuProcessInput +// str r0, [r1] +//_0816B388: +// pop {r4} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end ItemStorage_HandleReturnToProcessInput - thumb_func_start sub_816B31C -sub_816B31C: @ 816B31C - push {lr} - ldr r0, =gFieldCallback - ldr r1, =mapldr_080EBC0C - str r1, [r0] - ldr r0, =CB2_ReturnToField - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B31C +// thumb_func_start ItemStorage_Withdraw +//ItemStorage_Withdraw: @ 816B398 +// push {r4,r5,lr} +// 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_80D6CE4 +// lsls r0, 24 +// lsrs r0, 24 +// strh r0, [r4, 0x2] +// cmp r0, 0 +// beq _0816B3C4 +// adds r0, r5, 0 +// movs r1, 0 +// bl sub_816B430 +// b _0816B3D4 +// .pool +//_0816B3C4: +// adds r0, r5, 0 +// bl sub_816B4DC +// ldr r1, =gText_NoItems +// ldr r2, =PlayerPC_ItemStorage +// adds r0, r5, 0 +// bl DisplayItemMessageOnField +//_0816B3D4: +// pop {r4,r5} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end ItemStorage_Withdraw +// +// thumb_func_start ItemStorage_Toss +//ItemStorage_Toss: @ 816B3E4 +// push {r4,r5,lr} +// 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_80D6CE4 +// lsls r0, 24 +// lsrs r0, 24 +// strh r0, [r4, 0x2] +// cmp r0, 0 +// beq _0816B410 +// adds r0, r5, 0 +// movs r1, 0x1 +// bl sub_816B430 +// b _0816B420 +// .pool +//_0816B410: +// adds r0, r5, 0 +// bl sub_816B4DC +// ldr r1, =gText_NoItems +// ldr r2, =PlayerPC_ItemStorage +// adds r0, r5, 0 +// bl DisplayItemMessageOnField +//_0816B420: +// pop {r4,r5} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end ItemStorage_Toss - thumb_func_start mapldr_080EBC0C -mapldr_080EBC0C: @ 816B33C - push {lr} - bl sub_81973A4 - movs r0, 0 - movs r1, 0x1 - bl NewMenuHelpers_DrawDialogueFrame - ldr r0, =sub_816B368 - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - bl sub_816B190 - bl pal_fill_black - pop {r0} - bx r0 - .pool - thumb_func_end mapldr_080EBC0C +// thumb_func_start sub_816B430 +//sub_816B430: @ 816B430 +// push {r4-r6,lr} +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// lsls r1, 24 +// lsrs r1, 24 +// lsls r5, r4, 2 +// adds r5, r4 +// lsls r5, 3 +// ldr r6, =gTasks + 0x8 +// adds r0, r5, r6 +// strh r1, [r0, 0x6] +// adds r0, r4, 0 +// bl sub_816B4DC +// ldr r1, =gUnknown_0203BCB8 +// movs r0, 0 +// strh r0, [r1] +// strh r0, [r1, 0x2] +// movs r0, 0xFF +// strb r0, [r1, 0x9] +// adds r0, r4, 0 +// bl ItemStorage_SetItemAndMailCount +// bl sub_816BC14 +// bl gpu_pal_allocator_reset__manage_upper_four +// bl LoadListMenuArrowsGfx +// ldr r0, =gUnknown_0203BCC4 +// ldr r0, [r0] +// movs r1, 0xCD +// lsls r1, 3 +// adds r0, r1 +// movs r1, 0x7 +// bl sub_8122344 +// movs r0, 0 +// movs r1, 0 +// bl sub_8197434 +// subs r6, 0x8 +// adds r5, r6 +// ldr r0, =sub_816C158 +// str r0, [r5] +// pop {r4-r6} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B430 - thumb_func_start sub_816B368 -sub_816B368: @ 816B368 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_80ABDFC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0816B388 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_816B248 - str r0, [r1] -_0816B388: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B368 +// thumb_func_start ItemStorage_Exit +//ItemStorage_Exit: @ 816B4A4 +// push {r4,lr} +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// adds r0, r4, 0 +// bl sub_816B4DC +// adds r0, r4, 0 +// bl ReshowPlayerPC +// pop {r4} +// pop {r0} +// bx r0 +// thumb_func_end ItemStorage_Exit - thumb_func_start sub_816B398 -sub_816B398: @ 816B398 - push {r4,r5,lr} - 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_80D6CE4 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x2] - cmp r0, 0 - beq _0816B3C4 - adds r0, r5, 0 - movs r1, 0 - bl sub_816B430 - b _0816B3D4 - .pool -_0816B3C4: - adds r0, r5, 0 - bl sub_816B4DC - ldr r1, =gText_NoItems - ldr r2, =task_pc_itemstorage - adds r0, r5, 0 - bl DisplayItemMessageOnField -_0816B3D4: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B398 +// thumb_func_start ItemStorage_SetItemAndMailCount +//ItemStorage_SetItemAndMailCount: @ 816B4C0 +// push {lr} +// ldr r1, =gUnknown_0203BCB8 +// ldrb r0, [r1, 0x5] +// cmp r0, 0x7 +// bls _0816B4D4 +// movs r0, 0x8 +// b _0816B4D6 +// .pool +//_0816B4D4: +// adds r0, 0x1 +//_0816B4D6: +// strb r0, [r1, 0x4] +// pop {r0} +// bx r0 +// thumb_func_end ItemStorage_SetItemAndMailCount - thumb_func_start sub_816B3E4 -sub_816B3E4: @ 816B3E4 - push {r4,r5,lr} - 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_80D6CE4 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r4, 0x2] - cmp r0, 0 - beq _0816B410 - adds r0, r5, 0 - movs r1, 0x1 - bl sub_816B430 - b _0816B420 - .pool -_0816B410: - adds r0, r5, 0 - bl sub_816B4DC - ldr r1, =gText_NoItems - ldr r2, =task_pc_itemstorage - adds r0, r5, 0 - bl DisplayItemMessageOnField -_0816B420: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B3E4 +// thumb_func_start sub_816B4DC +//sub_816B4DC: @ 816B4DC +// push {r4,lr} +// lsls r0, 24 +// lsrs r0, 24 +// lsls r4, r0, 2 +// adds r4, r0 +// lsls r4, 3 +// ldr r0, =gTasks + 0x8 +// adds r4, r0 +// ldrb r0, [r4, 0x8] +// movs r1, 0 +// bl sub_8198070 +// ldrb r0, [r4, 0x8] +// bl ClearWindowTilemap +// ldrb r0, [r4, 0x8] +// bl RemoveWindow +// movs r0, 0 +// bl schedule_bg_copy_tilemap_to_vram +// pop {r4} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B4DC - thumb_func_start sub_816B430 -sub_816B430: @ 816B430 - push {r4-r6,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r5, r4, 2 - adds r5, r4 - lsls r5, 3 - ldr r6, =gTasks + 0x8 - adds r0, r5, r6 - strh r1, [r0, 0x6] - adds r0, r4, 0 - bl sub_816B4DC - ldr r1, =gUnknown_0203BCB8 - movs r0, 0 - strh r0, [r1] - strh r0, [r1, 0x2] - movs r0, 0xFF - strb r0, [r1, 0x9] - adds r0, r4, 0 - bl sub_816B4C0 - bl sub_816BC14 - bl gpu_pal_allocator_reset__manage_upper_four - bl LoadListMenuArrowsGfx - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - movs r1, 0xCD - lsls r1, 3 - adds r0, r1 - movs r1, 0x7 - bl sub_8122344 - movs r0, 0 - movs r1, 0 - bl sub_8197434 - subs r6, 0x8 - adds r5, r6 - ldr r0, =sub_816C158 - str r0, [r5] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B430 +// thumb_func_start GetMailboxMailCount +//GetMailboxMailCount: @ 816B510 +// push {r4,lr} +// movs r2, 0 +// movs r1, 0x6 +// ldr r0, =gSaveBlock1Ptr +// ldr r3, [r0] +// movs r4, 0xB0 +// lsls r4, 6 +//_0816B51E: +// lsls r0, r1, 3 +// adds r0, r1 +// lsls r0, 2 +// adds r0, r3, r0 +// adds r0, r4 +// ldrh r0, [r0] +// cmp r0, 0 +// beq _0816B534 +// adds r0, r2, 0x1 +// lsls r0, 24 +// lsrs r2, r0, 24 +//_0816B534: +// adds r0, r1, 0x1 +// lsls r0, 24 +// lsrs r1, r0, 24 +// cmp r1, 0xF +// bls _0816B51E +// adds r0, r2, 0 +// pop {r4} +// pop {r1} +// bx r1 +// .pool +// thumb_func_end GetMailboxMailCount - thumb_func_start sub_816B4A4 -sub_816B4A4: @ 816B4A4 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - adds r0, r4, 0 - bl sub_816B4DC - adds r0, r4, 0 - bl sub_816B060 - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_816B4A4 +// thumb_func_start Mailbox_UpdateMailList +//Mailbox_UpdateMailList: @ 816B54C +// push {r4-r7,lr} +// mov r7, r10 +// mov r6, r9 +// mov r5, r8 +// push {r5-r7} +// sub sp, 0x24 +// movs r2, 0x6 +//_0816B55A: +// adds r1, r2, 0x1 +// lsls r0, r1, 24 +// lsrs r4, r0, 24 +// mov r8, r1 +// cmp r4, 0xF +// bhi _0816B5D4 +// ldr r0, =gSaveBlock1Ptr +// mov r10, r0 +// lsls r0, r2, 3 +// adds r0, r2 +// lsls r0, 2 +// mov r12, r0 +// ldr r6, =0x00002be0 +//_0816B574: +// mov r1, r10 +// ldr r1, [r1] +// mov r9, r1 +// mov r2, r9 +// add r2, r12 +// movs r3, 0xB0 +// lsls r3, 6 +// adds r0, r2, r3 +// ldrh r0, [r0] +// cmp r0, 0 +// bne _0816B5CA +// adds r2, r6 +// mov r1, sp +// adds r0, r2, 0 +// ldm r0!, {r3,r5,r7} +// stm r1!, {r3,r5,r7} +// ldm r0!, {r3,r5,r7} +// stm r1!, {r3,r5,r7} +// ldm r0!, {r3,r5,r7} +// stm r1!, {r3,r5,r7} +// lsls r3, r4, 3 +// adds r3, r4 +// lsls r3, 2 +// mov r5, r9 +// adds r0, r5, r3 +// adds r0, r6 +// ldm r0!, {r1,r5,r7} +// stm r2!, {r1,r5,r7} +// ldm r0!, {r1,r5,r7} +// stm r2!, {r1,r5,r7} +// ldm r0!, {r1,r5,r7} +// stm r2!, {r1,r5,r7} +// mov r7, r10 +// ldr r1, [r7] +// adds r1, r3 +// adds r1, r6 +// mov r0, sp +// ldm r0!, {r2,r3,r5} +// stm r1!, {r2,r3,r5} +// ldm r0!, {r2,r3,r7} +// stm r1!, {r2,r3,r7} +// ldm r0!, {r2,r5,r7} +// stm r1!, {r2,r5,r7} +//_0816B5CA: +// adds r0, r4, 0x1 +// lsls r0, 24 +// lsrs r4, r0, 24 +// cmp r4, 0xF +// bls _0816B574 +//_0816B5D4: +// mov r3, r8 +// lsls r0, r3, 24 +// lsrs r2, r0, 24 +// cmp r2, 0xE +// bls _0816B55A +// add sp, 0x24 +// pop {r3-r5} +// mov r8, r3 +// mov r9, r4 +// mov r10, r5 +// pop {r4-r7} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end Mailbox_UpdateMailList - thumb_func_start sub_816B4C0 -sub_816B4C0: @ 816B4C0 - push {lr} - ldr r1, =gUnknown_0203BCB8 - ldrb r0, [r1, 0x5] - cmp r0, 0x7 - bls _0816B4D4 - movs r0, 0x8 - b _0816B4D6 - .pool -_0816B4D4: - adds r0, 0x1 -_0816B4D6: - strb r0, [r1, 0x4] - pop {r0} - bx r0 - thumb_func_end sub_816B4C0 +// thumb_func_start Mailbox_DrawMailboxMenu +//Mailbox_DrawMailboxMenu: @ 816B5F8 +// push {r4-r6,lr} +// sub sp, 0xC +// adds r5, r0, 0 +// lsls r5, 24 +// lsrs r5, 24 +// movs r0, 0 +// bl sub_81D1C84 +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// movs r0, 0x1 +// bl sub_81D1C84 +// ldr r6, =gText_Mailbox +// movs r0, 0x1 +// adds r1, r6, 0 +// movs r2, 0x40 +// bl GetStringCenterAlignXOffset +// adds r3, r0, 0 +// lsls r3, 24 +// lsrs r3, 24 +// movs r0, 0x1 +// str r0, [sp] +// movs r0, 0 +// str r0, [sp, 0x4] +// str r0, [sp, 0x8] +// adds r0, r4, 0 +// movs r1, 0x1 +// adds r2, r6, 0 +// bl PrintTextOnWindow +// movs r0, 0 +// bl schedule_bg_copy_tilemap_to_vram +// ldr r4, =gUnknown_0203BCB8 +// adds r0, r4, 0 +// bl sub_81D1DC0 +// ldr r2, =gTasks +// lsls r1, r5, 2 +// adds r1, r5 +// lsls r1, 3 +// adds r1, r2 +// lsls r0, 24 +// lsrs r0, 24 +// strh r0, [r1, 0x12] +// adds r0, r4, 0 +// bl sub_81D1E90 +// add sp, 0xC +// pop {r4-r6} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end Mailbox_DrawMailboxMenu - thumb_func_start sub_816B4DC -sub_816B4DC: @ 816B4DC - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - adds r4, r0 - ldrb r0, [r4, 0x8] - movs r1, 0 - bl sub_8198070 - ldrb r0, [r4, 0x8] - bl ClearWindowTilemap - ldrb r0, [r4, 0x8] - bl RemoveWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B4DC +// thumb_func_start Mailbox_ProcessInput +//Mailbox_ProcessInput: @ 816B674 +// push {r4-r7,lr} +// mov r7, r10 +// mov r6, r9 +// mov r5, r8 +// push {r5-r7} +// lsls r0, 24 +// lsrs r5, r0, 24 +// lsls r0, r5, 2 +// adds r0, r5 +// lsls r0, 3 +// mov r9, r0 +// ldr r0, =gTasks + 0x8 +// mov r10, r0 +// mov r4, r9 +// add r4, r10 +// ldr r0, =gPaletteFade +// ldrb r1, [r0, 0x7] +// movs r0, 0x80 +// ands r0, r1 +// cmp r0, 0 +// bne _0816B71E +// ldrb r0, [r4, 0xA] +// bl ListMenuHandleInputGetItemId +// adds r6, r0, 0 +// ldrb r0, [r4, 0xA] +// ldr r7, =gUnknown_0203BCBA +// subs r1, r7, 0x2 +// mov r8, r1 +// adds r1, r7, 0 +// mov r2, r8 +// bl sub_81AE860 +// movs r0, 0x2 +// negs r0, r0 +// cmp r6, r0 +// beq _0816B6D4 +// adds r0, 0x1 +// cmp r6, r0 +// bne _0816B6EA +// b _0816B71E +// .pool +//_0816B6D4: +// movs r0, 0x5 +// bl PlaySE +// mov r1, r8 +// ldrb r0, [r1, 0x9] +// bl RemoveScrollIndicatorArrowPair +// adds r0, r5, 0 +// bl sub_816B798 +// b _0816B71E +//_0816B6EA: +// movs r0, 0x5 +// bl PlaySE +// movs r0, 0 +// bl sub_81D1D04 +// movs r0, 0x1 +// bl sub_81D1D04 +// ldrb r0, [r4, 0xA] +// adds r1, r7, 0 +// mov r2, r8 +// bl sub_81AE6C8 +// movs r0, 0 +// bl schedule_bg_copy_tilemap_to_vram +// mov r1, r8 +// ldrb r0, [r1, 0x9] +// bl RemoveScrollIndicatorArrowPair +// mov r0, r10 +// subs r0, 0x8 +// add r0, r9 +// ldr r1, =sub_816B730 +// str r1, [r0] +//_0816B71E: +// pop {r3-r5} +// mov r8, r3 +// mov r9, r4 +// mov r10, r5 +// pop {r4-r7} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end Mailbox_ProcessInput - thumb_func_start sub_816B510 -sub_816B510: @ 816B510 - push {r4,lr} - movs r2, 0 - movs r1, 0x6 - ldr r0, =gSaveBlock1Ptr - ldr r3, [r0] - movs r4, 0xB0 - lsls r4, 6 -_0816B51E: - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - adds r0, r3, r0 - adds r0, r4 - ldrh r0, [r0] - cmp r0, 0 - beq _0816B534 - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 -_0816B534: - adds r0, r1, 0x1 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0xF - bls _0816B51E - adds r0, r2, 0 - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_816B510 +// thumb_func_start sub_816B730 +//sub_816B730: @ 816B730 +// push {r4,r5,lr} +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// ldr r5, =gStringVar1 +// ldr r2, =gSaveBlock1Ptr +// ldr r1, =gUnknown_0203BCB8 +// ldrh r0, [r1] +// adds r0, 0x6 +// ldrh r1, [r1, 0x2] +// adds r0, r1 +// lsls r1, r0, 3 +// adds r1, r0 +// lsls r1, 2 +// ldr r0, [r2] +// adds r1, r0 +// ldr r0, =0x00002bf2 +// adds r1, r0 +// adds r0, r5, 0 +// bl StringCopy +// adds r0, r5, 0 +// movs r1, 0 +// bl sub_81DB554 +// ldr r5, =gStringVar4 +// ldr r1, =gText_WhatToDoWithVar1sMail +// adds r0, r5, 0 +// bl StringExpandPlaceholders +// ldr r2, =sub_816B7DC +// adds r0, r4, 0 +// adds r1, r5, 0 +// bl DisplayItemMessageOnField +// pop {r4,r5} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B730 - thumb_func_start sub_816B54C -sub_816B54C: @ 816B54C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x24 - movs r2, 0x6 -_0816B55A: - adds r1, r2, 0x1 - lsls r0, r1, 24 - lsrs r4, r0, 24 - mov r8, r1 - cmp r4, 0xF - bhi _0816B5D4 - ldr r0, =gSaveBlock1Ptr - mov r10, r0 - lsls r0, r2, 3 - adds r0, r2 - lsls r0, 2 - mov r12, r0 - ldr r6, =0x00002be0 -_0816B574: - mov r1, r10 - ldr r1, [r1] - mov r9, r1 - mov r2, r9 - add r2, r12 - movs r3, 0xB0 - lsls r3, 6 - adds r0, r2, r3 - ldrh r0, [r0] - cmp r0, 0 - bne _0816B5CA - adds r2, r6 - mov r1, sp - adds r0, r2, 0 - ldm r0!, {r3,r5,r7} - stm r1!, {r3,r5,r7} - ldm r0!, {r3,r5,r7} - stm r1!, {r3,r5,r7} - ldm r0!, {r3,r5,r7} - stm r1!, {r3,r5,r7} - lsls r3, r4, 3 - adds r3, r4 - lsls r3, 2 - mov r5, r9 - adds r0, r5, r3 - adds r0, r6 - ldm r0!, {r1,r5,r7} - stm r2!, {r1,r5,r7} - ldm r0!, {r1,r5,r7} - stm r2!, {r1,r5,r7} - ldm r0!, {r1,r5,r7} - stm r2!, {r1,r5,r7} - mov r7, r10 - ldr r1, [r7] - adds r1, r3 - adds r1, r6 - mov r0, sp - ldm r0!, {r2,r3,r5} - stm r1!, {r2,r3,r5} - ldm r0!, {r2,r3,r7} - stm r1!, {r2,r3,r7} - ldm r0!, {r2,r5,r7} - stm r1!, {r2,r5,r7} -_0816B5CA: - adds r0, r4, 0x1 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0xF - bls _0816B574 -_0816B5D4: - mov r3, r8 - lsls r0, r3, 24 - lsrs r2, r0, 24 - cmp r2, 0xE - bls _0816B55A - add sp, 0x24 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B54C +// thumb_func_start sub_816B798 +//sub_816B798: @ 816B798 +// 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 r0, 0 +// bl sub_81D1D04 +// movs r0, 0x1 +// bl sub_81D1D04 +// ldrb r0, [r4, 0xA] +// movs r1, 0 +// movs r2, 0 +// bl sub_81AE6C8 +// movs r0, 0 +// bl schedule_bg_copy_tilemap_to_vram +// bl sub_81D1EC0 +// adds r0, r5, 0 +// bl ReshowPlayerPC +// pop {r4,r5} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B798 - thumb_func_start sub_816B5F8 -sub_816B5F8: @ 816B5F8 - push {r4-r6,lr} - sub sp, 0xC - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - movs r0, 0 - bl sub_81D1C84 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - bl sub_81D1C84 - ldr r6, =gText_Mailbox - movs r0, 0x1 - adds r1, r6, 0 - movs r2, 0x40 - bl GetStringCenterAlignXOffset - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - adds r0, r4, 0 - movs r1, 0x1 - adds r2, r6, 0 - bl PrintTextOnWindow - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r4, =gUnknown_0203BCB8 - adds r0, r4, 0 - bl sub_81D1DC0 - ldr r2, =gTasks - lsls r1, r5, 2 - adds r1, r5 - lsls r1, 3 - adds r1, r2 - lsls r0, 24 - lsrs r0, 24 - strh r0, [r1, 0x12] - adds r0, r4, 0 - bl sub_81D1E90 - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B5F8 +// thumb_func_start sub_816B7DC +//sub_816B7DC: @ 816B7DC +// push {r4,r5,lr} +// adds r5, r0, 0 +// lsls r5, 24 +// lsrs r5, 24 +// movs r0, 0x2 +// bl sub_81D1C84 +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// ldr r2, =gUnknown_085DFF04 +// adds r0, r4, 0 +// movs r1, 0x4 +// bl PrintMenuTable +// adds r0, r4, 0 +// movs r1, 0x4 +// movs r2, 0 +// bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed +// movs r0, 0 +// bl schedule_bg_copy_tilemap_to_vram +// ldr r1, =gTasks +// lsls r0, r5, 2 +// adds r0, r5 +// lsls r0, 3 +// adds r0, r1 +// ldr r1, =sub_816B82C +// str r1, [r0] +// pop {r4,r5} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B7DC - thumb_func_start sub_816B674 -sub_816B674: @ 816B674 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - mov r9, r0 - ldr r0, =gTasks + 0x8 - mov r10, r0 - mov r4, r9 - add r4, r10 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0816B71E - ldrb r0, [r4, 0xA] - bl ListMenuHandleInputGetItemId - adds r6, r0, 0 - ldrb r0, [r4, 0xA] - ldr r7, =gUnknown_0203BCBA - subs r1, r7, 0x2 - mov r8, r1 - adds r1, r7, 0 - mov r2, r8 - bl sub_81AE860 - movs r0, 0x2 - negs r0, r0 - cmp r6, r0 - beq _0816B6D4 - adds r0, 0x1 - cmp r6, r0 - bne _0816B6EA - b _0816B71E - .pool -_0816B6D4: - movs r0, 0x5 - bl PlaySE - mov r1, r8 - ldrb r0, [r1, 0x9] - bl RemoveScrollIndicatorArrowPair - adds r0, r5, 0 - bl sub_816B798 - b _0816B71E -_0816B6EA: - movs r0, 0x5 - bl PlaySE - movs r0, 0 - bl sub_81D1D04 - movs r0, 0x1 - bl sub_81D1D04 - ldrb r0, [r4, 0xA] - adds r1, r7, 0 - mov r2, r8 - bl sub_81AE6C8 - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - mov r1, r8 - ldrb r0, [r1, 0x9] - bl RemoveScrollIndicatorArrowPair - mov r0, r10 - subs r0, 0x8 - add r0, r9 - ldr r1, =sub_816B730 - str r1, [r0] -_0816B71E: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B674 +// thumb_func_start sub_816B82C +//sub_816B82C: @ 816B82C +// push {r4-r6,lr} +// lsls r0, 24 +// lsrs r5, r0, 24 +// adds r6, r5, 0 +// bl ProcessMenuInput_other +// lsls r0, 24 +// asrs r4, r0, 24 +// movs r0, 0x2 +// negs r0, r0 +// cmp r4, r0 +// beq _0816B86E +// adds r0, 0x1 +// cmp r4, r0 +// bne _0816B858 +// movs r0, 0x5 +// bl PlaySE +// adds r0, r5, 0 +// bl sub_816BBD4 +// b _0816B86E +//_0816B858: +// movs r0, 0x5 +// bl PlaySE +// ldr r0, =gUnknown_085DFF04 +// lsls r1, r4, 3 +// adds r0, 0x4 +// adds r1, r0 +// ldr r1, [r1] +// adds r0, r6, 0 +// bl _call_via_r1 +//_0816B86E: +// pop {r4-r6} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B82C - thumb_func_start sub_816B730 -sub_816B730: @ 816B730 - push {r4,r5,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r5, =gStringVar1 - ldr r2, =gSaveBlock1Ptr - ldr r1, =gUnknown_0203BCB8 - ldrh r0, [r1] - adds r0, 0x6 - ldrh r1, [r1, 0x2] - adds r0, r1 - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, [r2] - adds r1, r0 - ldr r0, =0x00002bf2 - adds r1, r0 - adds r0, r5, 0 - bl StringCopy - adds r0, r5, 0 - movs r1, 0 - bl sub_81DB554 - ldr r5, =gStringVar4 - ldr r1, =gText_WhatToDoWithVar1sMail - adds r0, r5, 0 - bl StringExpandPlaceholders - ldr r2, =sub_816B7DC - adds r0, r4, 0 - adds r1, r5, 0 - bl DisplayItemMessageOnField - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B730 +// thumb_func_start sub_816B878 +//sub_816B878: @ 816B878 +// push {r4,lr} +// adds r4, r0, 0 +// lsls r4, 24 +// lsrs r4, 24 +// movs r0, 0x1 +// movs r1, 0 +// bl FadeScreen +// ldr r1, =gTasks +// lsls r0, r4, 2 +// adds r0, r4 +// lsls r0, 3 +// adds r0, r1 +// ldr r1, =sub_816B8A4 +// str r1, [r0] +// pop {r4} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B878 +// +// thumb_func_start sub_816B8A4 +//sub_816B8A4: @ 816B8A4 +// push {r4,lr} +// lsls r0, 24 +// lsrs r4, r0, 24 +// ldr r0, =gPaletteFade +// ldrb r1, [r0, 0x7] +// movs r0, 0x80 +// ands r0, r1 +// cmp r0, 0 +// bne _0816B8E6 +// bl sub_81D1EC0 +// bl overworld_free_bg_tilemaps +// ldr r2, =gSaveBlock1Ptr +// ldr r1, =gUnknown_0203BCB8 +// ldrh r0, [r1] +// adds r0, 0x6 +// ldrh r1, [r1, 0x2] +// adds r0, r1 +// lsls r1, r0, 3 +// adds r1, r0 +// lsls r1, 2 +// ldr r0, =0x00002be0 +// adds r1, r0 +// ldr r0, [r2] +// adds r0, r1 +// ldr r1, =sub_816B900 +// movs r2, 0x1 +// bl ReadMail +// adds r0, r4, 0 +// bl DestroyTask +//_0816B8E6: +// pop {r4} +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B8A4 - thumb_func_start sub_816B798 -sub_816B798: @ 816B798 - 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 r0, 0 - bl sub_81D1D04 - movs r0, 0x1 - bl sub_81D1D04 - ldrb r0, [r4, 0xA] - movs r1, 0 - movs r2, 0 - bl sub_81AE6C8 - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - bl sub_81D1EC0 - adds r0, r5, 0 - bl sub_816B060 - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B798 - - thumb_func_start sub_816B7DC -sub_816B7DC: @ 816B7DC - push {r4,r5,lr} - adds r5, r0, 0 - lsls r5, 24 - lsrs r5, 24 - movs r0, 0x2 - bl sub_81D1C84 - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r2, =gUnknown_085DFF04 - adds r0, r4, 0 - movs r1, 0x4 - bl PrintMenuTable - adds r0, r4, 0 - movs r1, 0x4 - movs r2, 0 - bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816B82C - str r1, [r0] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B7DC - - thumb_func_start sub_816B82C -sub_816B82C: @ 816B82C - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - adds r6, r5, 0 - bl ProcessMenuInput_other - lsls r0, 24 - asrs r4, r0, 24 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _0816B86E - adds r0, 0x1 - cmp r4, r0 - bne _0816B858 - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_816BBD4 - b _0816B86E -_0816B858: - movs r0, 0x5 - bl PlaySE - ldr r0, =gUnknown_085DFF04 - lsls r1, r4, 3 - adds r0, 0x4 - adds r1, r0 - ldr r1, [r1] - adds r0, r6, 0 - bl _call_via_r1 -_0816B86E: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B82C - - thumb_func_start sub_816B878 -sub_816B878: @ 816B878 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x1 - movs r1, 0 - bl FadeScreen - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816B8A4 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B878 - - thumb_func_start sub_816B8A4 -sub_816B8A4: @ 816B8A4 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0816B8E6 - bl sub_81D1EC0 - bl overworld_free_bg_tilemaps - ldr r2, =gSaveBlock1Ptr - ldr r1, =gUnknown_0203BCB8 - ldrh r0, [r1] - adds r0, 0x6 - ldrh r1, [r1, 0x2] - adds r0, r1 - lsls r1, r0, 3 - adds r1, r0 - lsls r1, 2 - ldr r0, =0x00002be0 - adds r1, r0 - ldr r0, [r2] - adds r0, r1 - ldr r1, =sub_816B900 - movs r2, 0x1 - bl ReadMail - adds r0, r4, 0 - bl DestroyTask -_0816B8E6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B8A4 - - thumb_func_start sub_816B900 -sub_816B900: @ 816B900 - push {lr} - ldr r0, =gFieldCallback - ldr r1, =pal_fill_for_maplights_or_black - str r1, [r0] - ldr r0, =CB2_ReturnToField - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B900 +// thumb_func_start sub_816B900 +//sub_816B900: @ 816B900 +// push {lr} +// ldr r0, =gFieldCallback +// ldr r1, =pal_fill_for_maplights_or_black +// str r1, [r0] +// ldr r0, =CB2_ReturnToField +// bl SetMainCallback2 +// pop {r0} +// bx r0 +// .pool +// thumb_func_end sub_816B900 thumb_func_start pal_fill_for_maplights_or_black pal_fill_for_maplights_or_black: @ 816B920 @@ -1303,7 +1306,7 @@ pal_fill_for_maplights_or_black: @ 816B920 cmp r0, 0x1 bne _0816B954 adds r0, r4, 0 - bl sub_816B5F8 + bl Mailbox_DrawMailboxMenu b _0816B95A .pool _0816B954: @@ -1331,7 +1334,7 @@ task00_080EBBDC: @ 816B964 adds r1, r4 lsls r1, 3 adds r1, r0 - ldr r0, =sub_816B674 + ldr r0, =Mailbox_ProcessInput str r0, [r1] _0816B984: pop {r4} @@ -1445,7 +1448,7 @@ _0816BA68: bl DisplayItemMessageOnField adds r0, r5, 0 bl ClearMailStruct - bl sub_816B54C + bl Mailbox_UpdateMailList ldrb r0, [r4, 0x5] subs r0, 0x1 strb r0, [r4, 0x5] @@ -1461,7 +1464,7 @@ _0816BA68: strh r0, [r4, 0x2] _0816BA96: adds r0, r6, 0 - bl sub_816B4C0 + bl ItemStorage_SetItemAndMailCount _0816BA9C: pop {r4-r6} pop {r0} @@ -1555,9 +1558,9 @@ sub_816BB48: @ 816BB48 lsrs r6, r0, 24 ldr r5, =gUnknown_0203BCB8 ldrb r4, [r5, 0x5] - bl sub_816B510 + bl GetMailboxMailCount strb r0, [r5, 0x5] - bl sub_816B54C + bl Mailbox_UpdateMailList ldrb r0, [r5, 0x5] cmp r4, r0 beq _0816BB7E @@ -1573,7 +1576,7 @@ sub_816BB48: @ 816BB48 strh r0, [r5, 0x2] _0816BB7E: adds r0, r6, 0 - bl sub_816B4C0 + bl ItemStorage_SetItemAndMailCount bl sub_81973A4 ldr r0, =gUnknown_0203BCB8 ldrb r0, [r0, 0x5] @@ -1583,7 +1586,7 @@ _0816BB7E: cmp r0, 0x1 bne _0816BBA8 adds r0, r6, 0 - bl sub_816B5F8 + bl Mailbox_DrawMailboxMenu b _0816BBAE .pool _0816BBA8: @@ -1621,7 +1624,7 @@ sub_816BBD4: @ 816BBD4 movs r1, 0 bl sub_8197434 adds r0, r4, 0 - bl sub_816B5F8 + bl Mailbox_DrawMailboxMenu movs r0, 0 bl schedule_bg_copy_tilemap_to_vram ldr r1, =gTasks @@ -1629,7 +1632,7 @@ sub_816BBD4: @ 816BBD4 adds r0, r4 lsls r0, 3 adds r0, r1 - ldr r1, =sub_816B674 + ldr r1, =Mailbox_ProcessInput str r1, [r0] pop {r4} pop {r0} @@ -2547,20 +2550,20 @@ bx_battle_menu_t3: @ 816C3A4 bne _0816C3DC adds r0, r4, 0 movs r1, 0 - bl sub_816B190 + bl InitItemStorageMenu b _0816C3E4 .pool _0816C3DC: adds r0, r4, 0 movs r1, 0x2 - bl sub_816B190 + bl InitItemStorageMenu _0816C3E4: ldr r0, =gTasks lsls r1, r4, 2 adds r1, r4 lsls r1, 3 adds r1, r0 - ldr r0, =sub_816B248 + ldr r0, =ItemStorageMenuProcessInput str r0, [r1] _0816C3F2: pop {r4,r5} diff --git a/data/event_scripts.s b/data/event_scripts.s index 42c5aa1ad..44705269c 100644 --- a/data/event_scripts.s +++ b/data/event_scripts.s @@ -1788,7 +1788,7 @@ EventScript_271DBC:: @ 8271DBC EventScript_271DF9:: @ 8271DF9 playse SE_PC_LOGIN msgbox gUnknown_082726C2, 4 - special sub_816AE98 + special PlayerPC waitstate goto EventScript_271DAC end diff --git a/data/player_pc.s b/data/player_pc.s index 47bdbff39..ef8a2ba9c 100644 --- a/data/player_pc.s +++ b/data/player_pc.s @@ -5,36 +5,36 @@ .section .rodata .align 2 -gUnknown_085DFEA4:: @ 85DFEA4 +gPCText_OptionDescList:: @ 85DFEA4 .4byte gText_TakeOutItemsFromPC .4byte gText_StoreItemsInPC .4byte gText_ThrowAwayItemsInPC .4byte gText_GoBackPrevMenu .align 2 -gUnknown_085DFEB4:: @ 85DFEB4 - .4byte gText_ItemStorage, task_pc_itemstorage - .4byte gText_Mailbox, sub_816B0A8 - .4byte gText_Decoration, sub_816B138 - .4byte gText_TurnOff, sub_816B148 +sPlayerPCMenuActions:: @ 85DFEB4 + .4byte gText_ItemStorage, PlayerPC_ItemStorage + .4byte gText_Mailbox, PlayerPC_Mailbox + .4byte gText_Decoration, PlayerPC_Decoration + .4byte gText_TurnOff, PlayerPC_TurnOff .align 2 -gUnknown_085DFED4:: @ 85DFED4 +gBedroomPC_OptionOrder:: @ 85DFED4 .byte 0x00, 0x01, 0x02, 0x03 .align 2 -gUnknown_085DFED8:: @ 85DFED8 +gPlayerPC_OptionOrder:: @ 85DFED8 .byte 0x00, 0x01, 0x03, 0x00 .align 2 -gUnknown_085DFEDC:: @ 85DFEDC - .4byte gText_WithdrawItem, sub_816B398 - .4byte gText_DepositItem, sub_816B2C8 - .4byte gText_TossItem, sub_816B3E4 - .4byte gText_Cancel, sub_816B4A4 +gPCText_ItemPCOptionsText:: @ 85DFEDC + .4byte gText_WithdrawItem, ItemStorage_Withdraw + .4byte gText_DepositItem, ItemStorage_Deposit + .4byte gText_TossItem, ItemStorage_Toss + .4byte gText_Cancel, ItemStorage_Exit .align 2 -gUnknown_085DFEFC:: @ 85DFEFC +gNewGamePCItems:: @ 85DFEFC .2byte ITEM_POTION, 0x0001 .2byte 0x0000, 0x0000 diff --git a/data/scripts/maps/LittlerootTown_BrendansHouse_2F.inc b/data/scripts/maps/LittlerootTown_BrendansHouse_2F.inc index 0e7ecbf22..a5223d38a 100644 --- a/data/scripts/maps/LittlerootTown_BrendansHouse_2F.inc +++ b/data/scripts/maps/LittlerootTown_BrendansHouse_2F.inc @@ -259,7 +259,7 @@ LittlerootTown_BrendansHouse_2F_EventScript_1F8626:: @ 81F8626 special DoPCTurnOnEffect playse SE_PC_ON msgbox gUnknown_08272D87, 4 - special sub_816AE58 + special BedroomPC waitstate releaseall end diff --git a/data/scripts/maps/LittlerootTown_MaysHouse_2F.inc b/data/scripts/maps/LittlerootTown_MaysHouse_2F.inc index 327112d2f..f300b5849 100644 --- a/data/scripts/maps/LittlerootTown_MaysHouse_2F.inc +++ b/data/scripts/maps/LittlerootTown_MaysHouse_2F.inc @@ -320,7 +320,7 @@ LittlerootTown_MaysHouse_2F_EventScript_1F9576:: @ 81F9576 special DoPCTurnOnEffect playse SE_PC_ON msgbox gUnknown_08272D87, 4 - special sub_816AE58 + special BedroomPC waitstate releaseall end diff --git a/data/specials.inc b/data/specials.inc index 62dd9717e..df85fb140 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -260,8 +260,8 @@ gSpecials:: @ 81DBA64 def_special ValidateEReaderTrainer def_special sub_8139228 def_special sub_80F94E8 - def_special sub_816AE58 - def_special sub_816AE98 + def_special BedroomPC + def_special PlayerPC def_special FieldShowRegionMap def_special sub_807E73C def_special sub_807EA10 diff --git a/include/event_scripts.h b/include/event_scripts.h index 4c5dfd544..defeadc30 100644 --- a/include/event_scripts.h +++ b/include/event_scripts.h @@ -387,4 +387,8 @@ extern const u8 FieryPath_EventScript_2908FD[]; extern const u8 EventScript_290CAE[]; extern const u8 EventScript_2926F8[]; +//player pc +extern const u8 LittlerootTown_BrendansHouse_2F_EventScript_1F863F[]; +extern const u8 LittlerootTown_MaysHouse_2F_EventScript_1F958F[]; + #endif //GUARD_EVENT_SCRIPTS_H diff --git a/include/item_menu.h b/include/item_menu.h index 5c1b26faa..ccf52a7a9 100644 --- a/include/item_menu.h +++ b/include/item_menu.h @@ -20,6 +20,7 @@ extern struct BagStruct gUnknown_0203CE58; extern u16 gSpecialVar_ItemId; // Exported ROM declarations +void sub_81AAC14(void); void sub_81AAC50(void); void sub_81AAC70(void); void bag_menu_mail_related(void); diff --git a/include/menu.h b/include/menu.h index c2f15422a..4de9d4b75 100644 --- a/include/menu.h +++ b/include/menu.h @@ -53,6 +53,7 @@ struct WindowTemplate sub_8198A50(u8, u8, u8, u8, u8, u8, u16); void CreateYesNoMenu(const struct WindowTemplate *windowTemplate, u16 borderFirstTileNum, u8 borderPalette, u8 initialCursorPos); void copy_decompressed_tile_data_to_vram_autofree(u8 bgId, const void *src, int size, u16 offset, u8 mode); s8 ProcessMenuInputNoWrap_(void); +s8 ProcessMenuInput_other(void); void do_scheduled_bg_tilemap_copies_to_vram(void); void clear_scheduled_bg_copies_to_vram(void); void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, const u8 *color, s8 speed, const u8 *str); diff --git a/include/player_pc.h b/include/player_pc.h index cc2e85b2b..fcd58757e 100644 --- a/include/player_pc.h +++ b/include/player_pc.h @@ -1,13 +1,86 @@ #ifndef GUARD_PLAYER_PC_H #define GUARD_PLAYER_PC_H +// local task defines +#define PAGE_INDEX data[0] +#define ITEMS_ABOVE_TOP data[1] +#define NUM_ITEMS data[1] +#define NUM_QUANTITY_ROLLER data[3] +#define NUM_PAGE_ITEMS data[4] +// not used +#define CURRENT_ITEM_STORAGE_MENU data[3] +// not used +#define SWAP_ITEM_INDEX data[8] +#define SWITCH_MODE_ACTIVE data[9] + +// this is potentially an ewram access occuring in high ewram. TODO: investigate this further. +#define NEW_GAME_PC_ITEMS(i, type) ((u16)((u16 *)gNewGamePCItems + type)[i * 2]) + +// defined and used in the above macro +enum +{ + PC_ITEM_ID, + PC_QUANTITY +}; + +// player PC menu options +enum +{ + PLAYERPC_MENU_ITEMSTORAGE, + PLAYERPC_MENU_MAILBOX, + PLAYERPC_MENU_DECORATION, + PLAYERPC_MENU_TURNOFF +}; + +// item storage menus +enum +{ + ITEMPC_MENU_WITHDRAW, + ITEMPC_MENU_DEPOSIT, + ITEMPC_MENU_TOSS, + ITEMPC_MENU_EXIT +}; + +// mailbox mail options +enum +{ + MAILBOX_READ, + MAILBOX_MOVE_TO_BAG, + MAILBOX_GIVE, + MAILBOX_CANCEL, +}; + +// special item description handlers +enum +{ + ITEMPC_SWITCH_WHICH_ITEM = 0xFFF7, + ITEMPC_OKAY_TO_THROW_AWAY, + ITEMPC_TOO_IMPORTANT, + ITEMPC_NO_MORE_ROOM, + ITEMPC_THREW_AWAY_ITEM, + ITEMPC_HOW_MANY_TO_TOSS, + ITEMPC_WITHDREW_THING, + ITEMPC_HOW_MANY_TO_WITHDRAW, + ITEMPC_GO_BACK_TO_PREV +}; + +struct MailboxStruct +{ + u16 cursorPos; + u16 itemsAbove; + u8 pageItems; + u8 count; + u8 unk6[6]; + u8 unkC[4]; +}; + // Exported type declarations // Exported RAM declarations // Exported ROM declarations -void sub_816B060(u8 taskId); +void ReshowPlayerPC(u8 taskId); void sub_816B31C(void); #endif //GUARD_PLAYER_PC_H diff --git a/include/strings.h b/include/strings.h index ceb994900..907873160 100644 --- a/include/strings.h +++ b/include/strings.h @@ -372,4 +372,8 @@ extern const u8 gBirchDexRatingText_LessThan190[]; extern const u8 gBirchDexRatingText_LessThan200[]; extern const u8 gBirchDexRatingText_DexCompleted[]; +//player menu text +extern const u8 gText_WhatWouldYouLike[]; +extern const u8 gText_NoMailHere[]; + #endif //GUARD_STRINGS_H diff --git a/ld_script.txt b/ld_script.txt index 7dcf21569..27344f720 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -217,6 +217,7 @@ SECTIONS { src/use_pokeblock.o(.text); asm/use_pokeblock.o(.text); src/battle_controller_wally.o(.text); + src/player_pc.o(.text); asm/player_pc.o(.text); src/intro.o(.text); src/reset_save_heap.o(.text); diff --git a/src/decoration.c b/src/decoration.c index e4d867a34..0b1157000 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -562,7 +562,7 @@ void SecretBasePC_Cancel(u8 taskId) } else { - sub_816B060(taskId); + ReshowPlayerPC(taskId); } } diff --git a/src/player_pc.c b/src/player_pc.c new file mode 100644 index 000000000..aa58f2e32 --- /dev/null +++ b/src/player_pc.c @@ -0,0 +1,702 @@ +#include "global.h" +#include "constants/songs.h" +#include "decoration.h" +#include "event_scripts.h" +#include "field_fadetransition.h" +#include "field_screen.h" +#include "field_weather.h" +#include "international_string_util.h" +#include "item.h" +#include "item_menu.h" +#include "constants/items.h" +#include "mail.h" +#include "main.h" +#include "menu.h" +#include "menu_helpers.h" +#include "overworld.h" +#include "palette.h" +#include "player_pc.h" +#include "script.h" +#include "sound.h" +#include "string_util.h" +#include "strings.h" +#include "task.h" +#include "window.h" + + +static EWRAM_DATA u8 *gPcItemMenuOptionOrder = NULL; + +static EWRAM_DATA u8 gPcItemMenuOptionsNum = 0; + +extern struct MailboxStruct gUnknown_0203BCB8; + +#define eMailboxInfo gUnknown_0203BCB8 + +struct Struct203BCC4 +{ + u8 filler[0x668]; + u32 unk668; + u8 filler2[4]; + +}; + +extern struct Struct203BCC4 *gUnknown_0203BCC4; + + +/*static*/void InitPlayerPCMenu(u8 taskId); +/*static*/void PlayerPCProcessMenuInput(u8 taskId); +/*static*/void InitItemStorageMenu(u8 taskId, u8 var); +/*static*/ void ItemStorageMenuPrint(const u8 *); +/*static*/ void ItemStorageMenuProcessInput(u8 taskId); +/* +static void ItemStorage_ProcessInput(u8); +*/ +/*static*/ void ItemStorage_SetItemAndMailCount(u8); +/* +static void ItemStorage_DoItemAction(u8); +static void ItemStorage_GoBackToPlayerPCMenu(u8); +static void ItemStorage_HandleQuantityRolling(u8); +static void ItemStorage_DoItemWithdraw(u8); +static void ItemStorage_DoItemToss(u8); +static void ItemStorage_HandleRemoveItem(u8); +static void ItemStorage_WaitPressHandleResumeProcessInput(u8); +*/ +/*static*/ void ItemStorage_HandleReturnToProcessInput(u8); +/* +static void ItemStorage_HandleResumeProcessInput(u8); +static void ItemStorage_DoItemSwap(u8, bool8); +static void ItemStorage_DrawItemList(u8); +static void ItemStorage_PrintItemPcResponse(u16); +static void ItemStorage_DrawBothListAndDescription(u8); +static void ItemStorage_GoBackToItemPCMenu(u8, u8); +static void ItemStorage_LoadPalette(void); +*/ +/*static*/ u8 GetMailboxMailCount(void); + +/*static*/ void Mailbox_UpdateMailList(void); +/*static*/ void Mailbox_DrawMailboxMenu(u8); +/*static*/ void Mailbox_ProcessInput(u8); +/* +static void Mailbox_CloseScrollIndicators(void); +static void Mailbox_PrintWhatToDoWithPlayerMailText(u8); +static void Mailbox_TurnOff(u8); +static void Mailbox_PrintMailOptions(u8); +static void Mailbox_MailOptionsProcessInput(u8); +static void Mailbox_FadeAndReadMail(u8); +static void Mailbox_ReturnToFieldFromReadMail(void); +static void Mailbox_DrawYesNoBeforeMove(u8); +static void Mailbox_DoGiveMailPokeMenu(u8); +static void Mailbox_NoPokemonForMail(u8); +static void Mailbox_Cancel(u8); +static void Mailbox_DrawMailMenuAndDoProcessInput(u8); +*/ +/*static*/ void PlayerPC_ItemStorage(u8 taskId); +/*static*/ void PlayerPC_Mailbox(u8 taskId); +/*static*/ void PlayerPC_Decoration(u8 var); +/*static*/ void PlayerPC_TurnOff(u8 taskId); +/* +static void ItemStorage_Withdraw(u8); +static void ItemStorage_Deposit(u8); +static void ItemStorage_Toss(u8); +*/ +/*static*/ void ItemStorage_Exit(u8); +/* +static void ItemStorage_ResumeInputFromYesToss(u8); +static void ItemStorage_ResumeInputFromNoToss(u8); +static void Mailbox_DoMailMoveToBag(u8); +static void Mailbox_ReturnToInputAfterNo(u8); +static void Mailbox_DoMailRead(u8); +static void Mailbox_MoveToBag(u8); +static void Mailbox_Give(u8); +static void Mailbox_Cancel(u8); +*/ + +extern const u8 *const gPCText_OptionDescList[]; +/* +static const u8 *const gPCText_OptionDescList[] = +{ + PCText_TakeOutItems, + PCText_StoreItems, + PCText_ThrowAwayItems, + gMenuText_GoBackToPrev +}; +*/ +/*static*/ extern const struct MenuAction sPlayerPCMenuActions[];/* = +{ + { SecretBaseText_ItemStorage, PlayerPC_ItemStorage }, + { gPCText_Mailbox, PlayerPC_Mailbox }, + { SecretBaseText_Decoration, PlayerPC_Decoration }, + { SecretBaseText_TurnOff, PlayerPC_TurnOff } +}; +*/ +/*static*/ extern u8 gBedroomPC_OptionOrder[];/* = +{ + PLAYERPC_MENU_ITEMSTORAGE, + PLAYERPC_MENU_MAILBOX, + PLAYERPC_MENU_DECORATION, + PLAYERPC_MENU_TURNOFF +}; +*/ +/*static*/ extern u8 gPlayerPC_OptionOrder[];/* = +{ + PLAYERPC_MENU_ITEMSTORAGE, + PLAYERPC_MENU_MAILBOX, + PLAYERPC_MENU_TURNOFF +}; +*/ +extern const struct MenuAction gPCText_ItemPCOptionsText[]; +/* +static const struct MenuAction2 gPCText_ItemPCOptionsText[] = +{ + { PCText_WithdrawItem, ItemStorage_Withdraw }, + { PCText_DepositItem, ItemStorage_Deposit }, + { PCText_TossItem, ItemStorage_Toss }, + { gUnknownText_Exit, ItemStorage_Exit } +}; + +static const struct YesNoFuncTable ResumeFromTossYesNoFuncList[] = // ResumeFromTossYesNoFuncList +{ + ItemStorage_ResumeInputFromYesToss, + ItemStorage_ResumeInputFromNoToss +}; + +static const struct YesNoFuncTable ResumeFromWithdrawYesNoFuncList[] = // ResumeFromWithdrawYesNoFuncList +{ + Mailbox_DoMailMoveToBag, + Mailbox_ReturnToInputAfterNo +}; +*/ +// the use of this struct is meant to be an ItemSlot struct, but NewGameInitPCItems refuses to match without a weird pointer access. +/*static*/ extern const struct ItemSlot gNewGamePCItems[];/* = +{ + { ITEM_POTION, 1 }, + { ITEM_NONE, 0 } +}; + +static const struct MenuAction2 gMailboxMailOptions[] = +{ + { OtherText_Read, Mailbox_DoMailRead }, + { gOtherText_MoveToBag, Mailbox_MoveToBag }, + { OtherText_Give, Mailbox_Give }, + { gOtherText_CancelNoTerminator, Mailbox_Cancel } +}; + +static const u8 gNonSelectedItemFormattedText[] = _("{STR_VAR_1}{CLEAR_TO 80}"); +static const u8 gSelectedItemFormattedText[] = _("{COLOR RED}{STR_VAR_1}{CLEAR_TO 80}"); +static const u8 gNonSelectedItemQuantityFormatText[] = _("{STR_VAR_1}"); +static const u8 gSelectedItemQuantityFormatText[] = _("{COLOR RED}{STR_VAR_1}"); +static const u8 gUnknown_08406330[] = _("{CLEAR_TO 32}"); +*/ + +extern const struct WindowTemplate gUnknown_085DFF24[3]; + +/* +extern u8 *gUnknown_02039314; +extern struct MenuAction gUnknown_08406298[]; + +extern u8 gUnknown_084062B8[]; +extern u8 gUnknown_084062BC[]; +extern u8 gUnknown_0840632A[]; +extern u8 gUnknown_08406327[]; +extern u8 gUnknown_0840631E[]; +extern u8 gUnknown_08406318[]; + +extern u8 gUnknown_030007B4; +extern u8 unk_201FE00[]; + +extern u8 gUnknown_08152850; +extern u8 gUnknown_08152C75; + +extern u32 gUnknown_08406288[]; +extern const struct MenuAction gUnknown_084062C0[]; +extern const struct YesNoFuncTable gUnknown_084062E0; +*/ + + +void NewGameInitPCItems(void) +{ + u8 i; + + // because Game Freak don't know how to use a struct or a 2d array + for(i = 0, ClearItemSlots(gSaveBlock1Ptr->pcItems, ARRAY_COUNT(gSaveBlock1Ptr->pcItems)); NEW_GAME_PC_ITEMS(i, PC_ITEM_ID) && NEW_GAME_PC_ITEMS(i, PC_QUANTITY) && + AddPCItem(NEW_GAME_PC_ITEMS(i, PC_ITEM_ID), NEW_GAME_PC_ITEMS(i, PC_QUANTITY)) == TRUE; i++); +} + +void BedroomPC(void) +{ + gPcItemMenuOptionOrder = gBedroomPC_OptionOrder; + gPcItemMenuOptionsNum = 4; + DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gText_WhatWouldYouLike, InitPlayerPCMenu); +} + +void PlayerPC(void) +{ + gPcItemMenuOptionOrder = gPlayerPC_OptionOrder; + gPcItemMenuOptionsNum = 3; + DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gText_WhatWouldYouLike, InitPlayerPCMenu); +} + +/*static*/ void InitPlayerPCMenu(u8 taskId) +{ + u16 *data; + struct WindowTemplate windowTemplate; + + data = gTasks[taskId].data; + if(gPcItemMenuOptionsNum == 3) + windowTemplate = gUnknown_085DFF24[0]; + else + windowTemplate = gUnknown_085DFF24[1]; + windowTemplate.width = sub_81DB3D8(sPlayerPCMenuActions, gPcItemMenuOptionOrder, gPcItemMenuOptionsNum); + data[4] = AddWindow(&windowTemplate); + SetStandardWindowBorderStyle(data[4], 0); + sub_81995E4(data[4], gPcItemMenuOptionsNum, sPlayerPCMenuActions, gPcItemMenuOptionOrder); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], gPcItemMenuOptionsNum, 0); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].func = PlayerPCProcessMenuInput; +} + +/*static*/ void PlayerPCProcessMenuInput(u8 taskId) +{ + u16 *data; + s8 inputOptionId; + + data = gTasks[taskId].data; + if(gPcItemMenuOptionsNum > 3) + inputOptionId = ProcessMenuInput(); + else + inputOptionId = ProcessMenuInputNoWrapAround(); + + switch(inputOptionId) + { + case -2: + break; + case -1: + PlaySE(SE_SELECT); + sub_8198070(data[4], FALSE); + ClearWindowTilemap(data[4]); + RemoveWindow(data[4]); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].func = PlayerPC_TurnOff; + break; + default: + sub_8198070(data[4], FALSE); + ClearWindowTilemap(data[4]); + RemoveWindow(data[4]); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].func = sPlayerPCMenuActions[gPcItemMenuOptionOrder[inputOptionId]].func.void_u8; + break; + } +} + +void ReshowPlayerPC(u8 var) +{ + DisplayItemMessageOnField(var, gText_WhatWouldYouLike, InitPlayerPCMenu); +} + +/*static*/ void PlayerPC_ItemStorage(u8 taskId) +{ + InitItemStorageMenu(taskId, ITEMPC_MENU_WITHDRAW); + gTasks[taskId].func = ItemStorageMenuProcessInput; +} + +bool8 sub_81D1C44(u8); + +/*static*/ void PlayerPC_Mailbox(u8 taskId) +{ + + eMailboxInfo.count = GetMailboxMailCount(); + + if (eMailboxInfo.count == 0) + DisplayItemMessageOnField(taskId, gText_NoMailHere, ReshowPlayerPC); + else + { + eMailboxInfo.cursorPos = 0; + eMailboxInfo.itemsAbove = 0; + eMailboxInfo.unk6[3] = 0xFF; + Mailbox_UpdateMailList(); + ItemStorage_SetItemAndMailCount(taskId); + if(sub_81D1C44(eMailboxInfo.count) == TRUE) + { + sub_8197434(0, 0); + Mailbox_DrawMailboxMenu(taskId); + gTasks[taskId].func = Mailbox_ProcessInput; + } + else + DisplayItemMessageOnField(taskId, gText_NoMailHere, ReshowPlayerPC); + } +} + +void sub_8126B2C(u8); + +/*static*/ void PlayerPC_Decoration(u8 var) +{ + sub_8126B2C(var); //DoPlayerPCDecoration(var); +} + +/*static*/ void PlayerPC_TurnOff(u8 taskId) +{ + if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC and not player PC, so do gender specific handling. + { + if (gSaveBlock2Ptr->playerGender == MALE) + ScriptContext1_SetupScript(LittlerootTown_BrendansHouse_2F_EventScript_1F863F); + else + ScriptContext1_SetupScript(LittlerootTown_MaysHouse_2F_EventScript_1F958F); + } + else + { + EnableBothScriptContexts(); + } + DestroyTask(taskId); +} + +void ItemStorageMenuPrint(const u8*); + +void InitItemStorageMenu(u8 taskId, u8 var) +{ + u16 *data; + struct WindowTemplate windowTemplate; + + data = gTasks[taskId].data; + windowTemplate = gUnknown_085DFF24[2]; + windowTemplate.width = GetMaxWidthInMenuTable(gPCText_ItemPCOptionsText, 4); + data[4] = AddWindow(&windowTemplate); + SetStandardWindowBorderStyle(data[4], 0); + PrintMenuTable(data[4], 4, gPCText_ItemPCOptionsText); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[4], 4, var); + schedule_bg_copy_tilemap_to_vram(0); + ItemStorageMenuPrint(gPCText_OptionDescList[var]); +} + +/*static*/ void ItemStorageMenuPrint(const u8 *textPtr) +{ + NewMenuHelpers_DrawDialogueFrame(0, 0); + PrintTextOnWindow(0, 1, textPtr, 0, 1, 0, 0); +} + +/*static*/ void ItemStorageMenuProcessInput(u8 var) +{ + s8 r5; + s8 r2; + s8 inputOptionId; + + r5 = GetMenuCursorPos(); + inputOptionId = ProcessMenuInput(); + r2 = GetMenuCursorPos(); + switch(inputOptionId) + { + case -2: + if (r5 != r2) + ItemStorageMenuPrint(gPCText_OptionDescList[r2]); + break; + case -1: + PlaySE(SE_SELECT); + ItemStorage_Exit(var); + break; + default: + PlaySE(SE_SELECT); + gPCText_ItemPCOptionsText[inputOptionId].func.void_u8(var); + break; + } +} + +void Task_ItemStorage_Deposit(u8 taskId); +/*static*/ void ItemStorage_Deposit(u8 taskId) +{ + gTasks[taskId].func = Task_ItemStorage_Deposit; + FadeScreen(1, 0); +} + +/*static*/ void Task_ItemStorage_Deposit(u8 taskId) +{ + if (!gPaletteFade.active) + { + overworld_free_bg_tilemaps(); + sub_81AAC14(); + DestroyTask(taskId); + } +} + +void mapldr_080EBC0C(void); + +void (*gFieldCallback)(void); +void sub_816B31C(void) +{ + gFieldCallback = mapldr_080EBC0C; + SetMainCallback2(CB2_ReturnToField); +} + +void mapldr_080EBC0C(void) +{ + sub_81973A4(); + NewMenuHelpers_DrawDialogueFrame(0, 1); + InitItemStorageMenu(CreateTask(ItemStorage_HandleReturnToProcessInput, 0), 1); + pal_fill_black(); +} + +/*static*/ void ItemStorage_HandleReturnToProcessInput(u8 taskId) +{ + if (sub_80ABDFC() == TRUE) + gTasks[taskId].func = ItemStorageMenuProcessInput; +} + +u8 sub_80D6CE4(); //count of items +void sub_816B4DC(u8 taskId); +void sub_816B430(u8 taskId, bool8 toss); +extern const u8 gText_NoItems[]; + +/*static*/ void ItemStorage_Withdraw(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + NUM_ITEMS = sub_80D6CE4(); + + if (NUM_ITEMS != 0) + sub_816B430(taskId, FALSE); + else + { + sub_816B4DC(taskId); + DisplayItemMessageOnField(taskId, gText_NoItems, PlayerPC_ItemStorage); + } + +} + +/*static*/ void ItemStorage_Toss(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + NUM_ITEMS = sub_80D6CE4(); + if (NUM_ITEMS != 0) + sub_816B430(taskId, TRUE); + else + { + sub_816B4DC(taskId); + DisplayItemMessageOnField(taskId, gText_NoItems, PlayerPC_ItemStorage); + } +} + +void sub_816BC14(void); +void gpu_pal_allocator_reset__manage_upper_four(void); +void sub_816C158(u8 taskId); + +/*static*/ void sub_816B430(u8 taskId, bool8 toss) +{ + u16 *data = gTasks[taskId].data; + + data[3] = toss; + sub_816B4DC(taskId); + eMailboxInfo.cursorPos = 0; + eMailboxInfo.itemsAbove = 0; + eMailboxInfo.unk6[3] = 0xFF; + ItemStorage_SetItemAndMailCount(taskId); + sub_816BC14(); + gpu_pal_allocator_reset__manage_upper_four(); + LoadListMenuArrowsGfx(); + sub_8122344(&(gUnknown_0203BCC4->unk668), 7); + sub_8197434(0,0); + gTasks[taskId].func = sub_816C158; +} + + + +/*static*/ void ItemStorage_Exit(u8 taskId) +{ + sub_816B4DC(taskId); + ReshowPlayerPC(taskId); +} + + +/*static*/ void ItemStorage_SetItemAndMailCount(u8 taskId) +{ + if (eMailboxInfo.count > 7) + eMailboxInfo.pageItems = 8; + else + eMailboxInfo.pageItems = eMailboxInfo.count + 1; +} + +/*static*/ void sub_816B4DC(u8 taskId) +{ + u16 *data = gTasks[taskId].data; + + sub_8198070(data[4], FALSE); + ClearWindowTilemap(data[4]); + RemoveWindow(data[4]); + schedule_bg_copy_tilemap_to_vram(0); +} + +/*static*/ u8 GetMailboxMailCount(void) +{ + u8 i, j; + + for(i = 0, j = 6; j < 16; j++) + if(gSaveBlock1Ptr->mail[j].itemId != 0) + i++; + + return i; +} + +/*static*/ void Mailbox_UpdateMailList(void) +{ + struct MailStruct mailBuffer; + u8 i, j; + + for (i=6; i<15; i++) + { + for (j=i+1; j<16; j++) + { + if (gSaveBlock1Ptr->mail[i].itemId == 0) + { + mailBuffer = gSaveBlock1Ptr->mail[i]; + gSaveBlock1Ptr->mail[i] = gSaveBlock1Ptr->mail[j]; + gSaveBlock1Ptr->mail[j] = mailBuffer; + } + } + } +} + +extern const u8 gText_Mailbox[]; +u8 sub_81D1C84(u8); +u8 sub_81D1DC0(struct MailboxStruct *); +void sub_81D1E90(struct MailboxStruct *); + + +/*static*/ void Mailbox_DrawMailboxMenu(u8 taskId) +{ + u8 windowId; + + windowId = sub_81D1C84(0); + sub_81D1C84(1); + PrintTextOnWindow(windowId, 1, gText_Mailbox, GetStringCenterAlignXOffset(1, gText_Mailbox, 0x40), 1, 0, NULL); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].data[5] = sub_81D1DC0(&eMailboxInfo); + sub_81D1E90(&eMailboxInfo); +} + +u32 ListMenuHandleInputGetItemId(u8); +void sub_81AE860(u8, void *, void *); +void sub_81AE6C8(u8, void *, void *); +void sub_816B798(u8); +void RemoveScrollIndicatorArrowPair(u8); +void sub_81D1D04(u8); +void sub_816B730(u8); + +/*static*/ void Mailbox_ProcessInput(u8 taskId) +{ + u16 *data = gTasks[taskId].data; + s32 inputOptionId; + + if(!gPaletteFade.active) + { + inputOptionId = ListMenuHandleInputGetItemId(data[5]); + sub_81AE860(data[5], &(eMailboxInfo.itemsAbove), &eMailboxInfo); + + switch(inputOptionId) + { + case -1: + break; + case -2: + PlaySE(SE_SELECT); + RemoveScrollIndicatorArrowPair(eMailboxInfo.unk6[3]); + sub_816B798(taskId); + break; + default: + PlaySE(SE_SELECT); + sub_81D1D04(0); + sub_81D1D04(1); + sub_81AE6C8(data[5], &(eMailboxInfo.itemsAbove), &eMailboxInfo); + schedule_bg_copy_tilemap_to_vram(0); + RemoveScrollIndicatorArrowPair(eMailboxInfo.unk6[3]); + gTasks[taskId].func = sub_816B730; + break; + } + } +} + +void sub_81DB554(u8 *, u8); +void sub_816B7DC(u8); +extern const u8 gText_WhatToDoWithVar1sMail[]; + +/*static*/ void sub_816B730(u8 taskId)//Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) +{ + StringCopy(gStringVar1, gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos].playerName); + sub_81DB554(gStringVar1, 0); + StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithVar1sMail); + DisplayItemMessageOnField(taskId, gStringVar4, sub_816B7DC); +} + +void sub_81D1EC0(void); + +/*static*/ void sub_816B798(u8 taskId)//Mailbox_ReturnToPlayerPC(u8 taskId) +{ + s16 *data = gTasks[taskId].data; + + sub_81D1D04(0); + sub_81D1D04(1); + sub_81AE6C8(data[5], NULL, NULL); + schedule_bg_copy_tilemap_to_vram(0); + sub_81D1EC0(); + ReshowPlayerPC(taskId); +} + +extern const struct MenuAction gUnknown_085DFF04[]; + +void sub_816B82C(u8 taskId); + +void sub_816B7DC(u8 taskId) +{ + u8 r4 = sub_81D1C84(2); + PrintMenuTable(r4, 4, gUnknown_085DFF04); + InitMenuInUpperLeftCornerPlaySoundWhenAPressed(r4, 4, 0); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].func = sub_816B82C; +} + +void sub_816BBD4(u8 taskId); + +void sub_816B82C(u8 taskId) +{ + s8 inputOptionId = ProcessMenuInput_other(); + + switch(inputOptionId) + { + case -2: + break; + case -1: + PlaySE(SE_SELECT); + sub_816BBD4(taskId); + break; + default: + PlaySE(SE_SELECT); + gUnknown_085DFF04[inputOptionId].func.void_u8(taskId); + break; + } +} + +void sub_816B8A4(u8 taskId); + +void sub_816B878(u8 taskId) +{ + FadeScreen(1, 0); + gTasks[taskId].func = sub_816B8A4; +} + +void sub_816B900(); + +void sub_816B8A4(u8 taskId) +{ + if(!gPaletteFade.active) + { + sub_81D1EC0(); + overworld_free_bg_tilemaps(); + ReadMail(&(gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos]), sub_816B900, TRUE); + DestroyTask(taskId); + } +} + +void pal_fill_for_maplights_or_black(); + +void sub_816B900() +{ + gFieldCallback = pal_fill_for_maplights_or_black; + SetMainCallback2(CB2_ReturnToField); +} + diff --git a/sym_ewram.txt b/sym_ewram.txt index 96862ccd5..da32fe5a0 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -805,12 +805,7 @@ gUnknown_0203BC8C: @ 203BC8C .space 0x4 .include "src/use_pokeblock.o" - -gUnknown_0203BCB0: @ 203BCB0 - .space 0x4 - -gUnknown_0203BCB4: @ 203BCB4 - .space 0x4 + .include "src/player_pc.o" gUnknown_0203BCB8: @ 203BCB8 .space 0x2 From f3b5ed0d121126ee05ab33700c0de40a0da77966 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Tue, 13 Mar 2018 14:41:39 +0530 Subject: [PATCH 2/6] Decompile more functions & rename some labels --- asm/party_menu.s | 2 +- asm/player_pc.s | 1906 +--------------------------------------------- asm/pokenav.s | 2 +- data/player_pc.s | 10 +- src/player_pc.c | 510 ++++++++----- 5 files changed, 326 insertions(+), 2104 deletions(-) diff --git a/asm/party_menu.s b/asm/party_menu.s index b71804617..1ee1fb8d1 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -15413,7 +15413,7 @@ sub_81B8448: @ 81B8448 str r0, [sp] ldr r0, =sub_81B1370 str r0, [sp, 0x4] - ldr r0, =sub_816BB28 + ldr r0, =Mailbox_ReturnToMailListAfterDeposit str r0, [sp, 0x8] movs r0, 0 movs r1, 0 diff --git a/asm/player_pc.s b/asm/player_pc.s index 8c8bde42d..47e56d5f2 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -5,1906 +5,6 @@ .text - .equ gPcItemMenuOptionOrder, 0x0203BCB0 - .equ gPcItemMenuOptionsNum, 0x0203BCB4 - -// thumb_func_start NewGameInitPCItems -//NewGameInitPCItems: @ 816ADF4 -// push {r4-r6,lr} -// movs r4, 0 -// ldr r0, =gSaveBlock1Ptr -// ldr r0, [r0] -// movs r1, 0x93 -// lsls r1, 3 -// adds r0, r1 -// movs r1, 0x32 -// bl ClearItemSlots -// ldr r1, =gUnknown_085DFEFC -// ldrh r0, [r1] -// cmp r0, 0 -// beq _0816AE48 -// ldrh r0, [r1, 0x2] -// cmp r0, 0 -// beq _0816AE48 -// adds r5, r1, 0 -// adds r6, r5, 0x2 -//_0816AE1A: -// lsls r1, r4, 2 -// adds r0, r1, r5 -// ldrh r0, [r0] -// adds r1, r6 -// ldrh r1, [r1] -// bl AddPCItem -// lsls r0, 24 -// lsrs r0, 24 -// cmp r0, 0x1 -// bne _0816AE48 -// adds r0, r4, 0x1 -// lsls r0, 24 -// lsrs r4, r0, 24 -// lsls r1, r4, 2 -// adds r0, r1, r5 -// ldrh r0, [r0] -// cmp r0, 0 -// beq _0816AE48 -// adds r0, r1, r6 -// ldrh r0, [r0] -// cmp r0, 0 -// bne _0816AE1A -//_0816AE48: -// pop {r4-r6} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end NewGameInitPCItems - -// thumb_func_start sub_816AE58 -//sub_816AE58: @ 816AE58 -// push {lr} -// ldr r1, =gPcItemMenuOptionOrder -// ldr r0, =gUnknown_085DFED4 -// str r0, [r1] -// ldr r1, =gPcItemMenuOptionsNum -// movs r0, 0x4 -// strb r0, [r1] -// ldr r0, =TaskDummy -// movs r1, 0 -// bl CreateTask -// lsls r0, 24 -// lsrs r0, 24 -// ldr r1, =gText_WhatWouldYouLike -// ldr r2, =InitPlayerPCMenu -// bl DisplayItemMessageOnField -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816AE58 - -// thumb_func_start sub_816AE98 -//sub_816AE98: @ 816AE98 -// push {lr} -// ldr r1, =gPcItemMenuOptionOrder -// ldr r0, =gUnknown_085DFED8 -// str r0, [r1] -// ldr r1, =gPcItemMenuOptionsNum -// movs r0, 0x3 -// strb r0, [r1] -// ldr r0, =TaskDummy -// movs r1, 0 -// bl CreateTask -// lsls r0, 24 -// lsrs r0, 24 -// ldr r1, =gText_WhatWouldYouLike -// ldr r2, =InitPlayerPCMenu -// bl DisplayItemMessageOnField -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816AE98 - -// thumb_func_start InitPlayerPCMenu -//InitPlayerPCMenu: @ 816AED8 -// push {r4-r7,lr} -// mov r7, r8 -// push {r7} -// sub sp, 0x8 -// lsls r0, 24 -// lsrs r7, r0, 24 -// lsls r0, r7, 2 -// adds r0, r7 -// lsls r0, 3 -// ldr r1, =gTasks + 0x8 -// adds r6, r0, r1 -// ldr r0, =gPcItemMenuOptionsNum -// ldrb r1, [r0] -// mov r8, r0 -// cmp r1, 0x3 -// bne _0816AF0C -// ldr r0, =gUnknown_085DFF24 -// ldr r1, [r0, 0x4] -// ldr r0, [r0] -// b _0816AF12 -// .pool -//_0816AF0C: -// ldr r0, =gUnknown_085DFF24 -// ldr r1, [r0, 0xC] -// ldr r0, [r0, 0x8] -//_0816AF12: -// str r0, [sp] -// str r1, [sp, 0x4] -// ldr r5, =gUnknown_085DFEB4 -// ldr r4, =gPcItemMenuOptionOrder -// ldr r1, [r4] -// mov r0, r8 -// ldrb r2, [r0] -// adds r0, r5, 0 -// bl sub_81DB3D8 -// lsls r0, 24 -// ldr r2, =0x00ffffff -// ldr r1, [sp] -// ands r1, r2 -// orrs r1, r0 -// str r1, [sp] -// mov r0, sp -// bl AddWindow -// strh r0, [r6, 0x8] -// lsls r0, 24 -// lsrs r0, 24 -// movs r1, 0 -// bl SetStandardWindowBorderStyle -// ldrb r0, [r6, 0x8] -// mov r2, r8 -// ldrb r1, [r2] -// ldr r3, [r4] -// adds r2, r5, 0 -// bl sub_81995E4 -// ldrb r0, [r6, 0x8] -// mov r2, r8 -// ldrb r1, [r2] -// movs r2, 0 -// bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed -// movs r0, 0 -// bl schedule_bg_copy_tilemap_to_vram -// ldr r1, =gTasks -// lsls r0, r7, 2 -// adds r0, r7 -// lsls r0, 3 -// adds r0, r1 -// ldr r1, =sub_816AF98 -// str r1, [r0] -// add sp, 0x8 -// pop {r3} -// mov r8, r3 -// pop {r4-r7} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end InitPlayerPCMenu - -// thumb_func_start PlayerPCProcessMenuInput -//PlayerPCProcessMenuInput: @ 816AF98 -// push {r4-r6,lr} -// lsls r0, 24 -// lsrs r6, r0, 24 -// lsls r0, r6, 2 -// adds r0, r6 -// lsls r0, 3 -// ldr r1, =gTasks + 0x8 -// adds r4, r0, r1 -// ldr r0, =gPcItemMenuOptionsNum -// ldrb r0, [r0] -// cmp r0, 0x3 -// bls _0816AFC0 -// bl ProcessMenuInput -// b _0816AFC4 -// .pool -//_0816AFC0: -// bl ProcessMenuInputNoWrapAround -//_0816AFC4: -// lsls r0, 24 -// lsrs r0, 24 -// lsls r0, 24 -// asrs r5, r0, 24 -// movs r0, 0x2 -// negs r0, r0 -// cmp r5, r0 -// beq _0816B04C -// adds r0, 0x1 -// cmp r5, r0 -// bne _0816B014 -// movs r0, 0x5 -// bl PlaySE -// ldrb r0, [r4, 0x8] -// movs r1, 0 -// bl sub_8198070 -// ldrb r0, [r4, 0x8] -// bl ClearWindowTilemap -// ldrb r0, [r4, 0x8] -// bl RemoveWindow -// movs r0, 0 -// bl schedule_bg_copy_tilemap_to_vram -// ldr r1, =gTasks -// lsls r0, r6, 2 -// adds r0, r6 -// lsls r0, 3 -// adds r0, r1 -// ldr r1, =PlayerPC_TurnOff -// str r1, [r0] -// b _0816B04C -// .pool -//_0816B014: -// ldrb r0, [r4, 0x8] -// movs r1, 0 -// bl sub_8198070 -// ldrb r0, [r4, 0x8] -// bl ClearWindowTilemap -// ldrb r0, [r4, 0x8] -// bl RemoveWindow -// movs r0, 0 -// bl schedule_bg_copy_tilemap_to_vram -// ldr r0, =gTasks -// lsls r1, r6, 2 -// adds r1, r6 -// lsls r1, 3 -// adds r1, r0 -// ldr r2, =sPlayerPCMenuActions -// ldr r0, =gPcItemMenuOptionOrder -// ldr r0, [r0] -// adds r0, r5 -// ldrb r0, [r0] -// lsls r0, 3 -// adds r2, 0x4 -// adds r0, r2 -// ldr r0, [r0] -// str r0, [r1] -//_0816B04C: -// pop {r4-r6} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end PlayerPCProcessMenuInput - -// thumb_func_start ReshowPlayerPC -//ReshowPlayerPC: @ 816B060 -// push {lr} -// lsls r0, 24 -// lsrs r0, 24 -// ldr r1, =gText_WhatWouldYouLike -// ldr r2, =InitPlayerPCMenu -// bl DisplayItemMessageOnField -// pop {r0} -// bx r0 -// .pool -// thumb_func_end ReshowPlayerPC - -// thumb_func_start PlayerPC_ItemStorage -//PlayerPC_ItemStorage: @ 816B07C -// push {r4,lr} -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// adds r0, r4, 0 -// movs r1, 0 -// bl InitItemStorageMenu -// ldr r1, =gTasks -// lsls r0, r4, 2 -// adds r0, r4 -// lsls r0, 3 -// adds r0, r1 -// ldr r1, =ItemStorageMenuProcessInput -// str r1, [r0] -// pop {r4} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end PlayerPC_ItemStorage - -// thumb_func_start PlayerPC_Mailbox -//PlayerPC_Mailbox: @ 816B0A8 -// push {r4-r6,lr} -// lsls r0, 24 -// lsrs r4, r0, 24 -// adds r6, r4, 0 -// bl GetMailboxMailCount -// ldr r5, =gUnknown_0203BCB8 -// movs r1, 0 -// strb r0, [r5, 0x5] -// lsls r0, 24 -// cmp r0, 0 -// bne _0816B0D8 -// ldr r1, =gText_NoMailHere -// ldr r2, =ReshowPlayerPC -// adds r0, r4, 0 -// bl DisplayItemMessageOnField -// b _0816B12A -// .pool -//_0816B0D8: -// strh r1, [r5] -// strh r1, [r5, 0x2] -// movs r0, 0xFF -// strb r0, [r5, 0x9] -// bl Mailbox_UpdateMailList -// adds r0, r4, 0 -// bl ItemStorage_SetItemAndMailCount -// ldrb r0, [r5, 0x5] -// bl sub_81D1C44 -// lsls r0, 24 -// lsrs r0, 24 -// cmp r0, 0x1 -// bne _0816B120 -// movs r0, 0 -// movs r1, 0 -// bl sub_8197434 -// adds r0, r4, 0 -// bl Mailbox_DrawMailboxMenu -// ldr r0, =gTasks -// lsls r1, r4, 2 -// adds r1, r4 -// lsls r1, 3 -// adds r1, r0 -// ldr r0, =Mailbox_ProcessInput -// str r0, [r1] -// b _0816B12A -// .pool -//_0816B120: -// ldr r1, =gText_NoMailHere -// ldr r2, =ReshowPlayerPC -// adds r0, r6, 0 -// bl DisplayItemMessageOnField -//_0816B12A: -// pop {r4-r6} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end PlayerPC_Mailbox - -// thumb_func_start PlayerPC_Decoration -//PlayerPC_Decoration: @ 816B138 -// push {lr} -// lsls r0, 24 -// lsrs r0, 24 -// bl sub_8126B2C -// pop {r0} -// bx r0 -// thumb_func_end PlayerPC_Decoration - -// thumb_func_start PlayerPC_TurnOff -//PlayerPC_TurnOff: @ 816B148 -// push {r4,lr} -// lsls r0, 24 -// lsrs r4, r0, 24 -// ldr r0, =gPcItemMenuOptionsNum -// ldrb r0, [r0] -// cmp r0, 0x4 -// bne _0816B180 -// ldr r0, =gSaveBlock2Ptr -// ldr r0, [r0] -// ldrb r0, [r0, 0x8] -// cmp r0, 0 -// bne _0816B174 -// ldr r0, =LittlerootTown_BrendansHouse_2F_EventScript_1F863F -// bl ScriptContext1_SetupScript -// b _0816B184 -// .pool -//_0816B174: -// ldr r0, =LittlerootTown_MaysHouse_2F_EventScript_1F958F -// bl ScriptContext1_SetupScript -// b _0816B184 -// .pool -//_0816B180: -// bl EnableBothScriptContexts -//_0816B184: -// adds r0, r4, 0 -// bl DestroyTask -// pop {r4} -// pop {r0} -// bx r0 -// thumb_func_end PlayerPC_TurnOff - -// thumb_func_start InitItemStorageMenu -//InitItemStorageMenu: @ 816B190 -// push {r4-r6,lr} -// sub sp, 0x8 -// adds r5, r1, 0 -// lsls r0, 24 -// lsrs r0, 24 -// lsls r5, 24 -// lsrs r5, 24 -// lsls r4, r0, 2 -// adds r4, r0 -// lsls r4, 3 -// ldr r0, =gTasks + 0x8 -// adds r4, r0 -// ldr r0, =gUnknown_085DFF24 -// ldr r1, [r0, 0x14] -// ldr r0, [r0, 0x10] -// str r0, [sp] -// str r1, [sp, 0x4] -// ldr r6, =gPCText_ItemPCOptionsText -// adds r0, r6, 0 -// movs r1, 0x4 -// bl GetMaxWidthInMenuTable -// lsls r0, 24 -// ldr r2, =0x00ffffff -// ldr r1, [sp] -// ands r1, r2 -// orrs r1, r0 -// str r1, [sp] -// mov r0, sp -// bl AddWindow -// strh r0, [r4, 0x8] -// lsls r0, 24 -// lsrs r0, 24 -// movs r1, 0 -// bl SetStandardWindowBorderStyle -// ldrb r0, [r4, 0x8] -// movs r1, 0x4 -// adds r2, r6, 0 -// bl PrintMenuTable -// ldrb r0, [r4, 0x8] -// movs r1, 0x4 -// adds r2, r5, 0 -// bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed -// movs r0, 0 -// bl schedule_bg_copy_tilemap_to_vram -// ldr r0, =gPCText_OptionDescList -// lsls r5, 2 -// adds r5, r0 -// ldr r0, [r5] -// bl sub_816B21C -// add sp, 0x8 -// pop {r4-r6} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end InitItemStorageMenu - -// thumb_func_start sub_816B21C -//sub_816B21C: @ 816B21C -// push {r4,lr} -// sub sp, 0xC -// adds r4, r0, 0 -// movs r0, 0 -// movs r1, 0 -// bl NewMenuHelpers_DrawDialogueFrame -// movs r0, 0x1 -// str r0, [sp] -// movs r0, 0 -// str r0, [sp, 0x4] -// str r0, [sp, 0x8] -// movs r1, 0x1 -// adds r2, r4, 0 -// movs r3, 0 -// bl PrintTextOnWindow -// add sp, 0xC -// pop {r4} -// pop {r0} -// bx r0 -// thumb_func_end sub_816B21C - -// thumb_func_start ItemStorageMenuProcessInput -//ItemStorageMenuProcessInput: @ 816B248 -// push {r4-r6,lr} -// lsls r0, 24 -// lsrs r6, r0, 24 -// bl GetMenuCursorPos -// lsls r0, 24 -// lsrs r5, r0, 24 -// bl ProcessMenuInput -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// bl GetMenuCursorPos -// lsls r0, 24 -// lsrs r2, r0, 24 -// lsls r4, 24 -// asrs r4, 24 -// movs r0, 0x2 -// negs r0, r0 -// cmp r4, r0 -// beq _0816B298 -// adds r0, 0x1 -// cmp r4, r0 -// beq _0816B2B4 -// movs r0, 0x5 -// bl PlaySE -// ldr r0, =gPCText_ItemPCOptionsText -// lsls r1, r4, 3 -// adds r0, 0x4 -// adds r1, r0 -// ldr r1, [r1] -// adds r0, r6, 0 -// bl _call_via_r1 -// b _0816B2C0 -// .pool -//_0816B298: -// lsls r1, r5, 24 -// lsls r0, r2, 24 -// asrs r2, r0, 24 -// cmp r1, r0 -// beq _0816B2C0 -// ldr r0, =gPCText_OptionDescList -// lsls r1, r2, 2 -// adds r1, r0 -// ldr r0, [r1] -// bl ItemStorageMenuPrint -// b _0816B2C0 -// .pool -//_0816B2B4: -// movs r0, 0x5 -// bl PlaySE -// adds r0, r6, 0 -// bl ItemStorage_Exit -//_0816B2C0: -// pop {r4-r6} -// pop {r0} -// bx r0 -// thumb_func_end ItemStorageMenuProcessInput - -// thumb_func_start ItemStorage_Deposit -//ItemStorage_Deposit: @ 816B2C8 -// push {lr} -// lsls r0, 24 -// lsrs r0, 24 -// ldr r2, =gTasks -// lsls r1, r0, 2 -// adds r1, r0 -// lsls r1, 3 -// adds r1, r2 -// ldr r0, =sub_816B2F0 -// str r0, [r1] -// movs r0, 0x1 -// movs r1, 0 -// bl FadeScreen -// pop {r0} -// bx r0 -// .pool -// thumb_func_end ItemStorage_Deposit -// -// thumb_func_start sub_816B2F0 -//sub_816B2F0: @ 816B2F0 -// push {r4,lr} -// lsls r0, 24 -// lsrs r4, r0, 24 -// ldr r0, =gPaletteFade -// ldrb r1, [r0, 0x7] -// movs r0, 0x80 -// ands r0, r1 -// cmp r0, 0 -// bne _0816B310 -// bl overworld_free_bg_tilemaps -// bl sub_81AAC14 -// adds r0, r4, 0 -// bl DestroyTask -//_0816B310: -// pop {r4} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B2F0 - -// thumb_func_start sub_816B31C -//sub_816B31C: @ 816B31C -// push {lr} -// ldr r0, =gFieldCallback -// ldr r1, =mapldr_080EBC0C -// str r1, [r0] -// ldr r0, =CB2_ReturnToField -// bl SetMainCallback2 -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B31C -// -// thumb_func_start mapldr_080EBC0C -//mapldr_080EBC0C: @ 816B33C -// push {lr} -// bl sub_81973A4 -// movs r0, 0 -// movs r1, 0x1 -// bl NewMenuHelpers_DrawDialogueFrame -// ldr r0, =ItemStorage_HandleReturnToProcessInput -// movs r1, 0 -// bl CreateTask -// lsls r0, 24 -// lsrs r0, 24 -// movs r1, 0x1 -// bl InitItemStorageMenu -// bl pal_fill_black -// pop {r0} -// bx r0 -// .pool -// thumb_func_end mapldr_080EBC0C -// -// thumb_func_start ItemStorage_HandleReturnToProcessInput -//ItemStorage_HandleReturnToProcessInput: @ 816B368 -// push {r4,lr} -// lsls r0, 24 -// lsrs r4, r0, 24 -// bl sub_80ABDFC -// lsls r0, 24 -// lsrs r0, 24 -// cmp r0, 0x1 -// bne _0816B388 -// ldr r0, =gTasks -// lsls r1, r4, 2 -// adds r1, r4 -// lsls r1, 3 -// adds r1, r0 -// ldr r0, =ItemStorageMenuProcessInput -// str r0, [r1] -//_0816B388: -// pop {r4} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end ItemStorage_HandleReturnToProcessInput - -// thumb_func_start ItemStorage_Withdraw -//ItemStorage_Withdraw: @ 816B398 -// push {r4,r5,lr} -// 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_80D6CE4 -// lsls r0, 24 -// lsrs r0, 24 -// strh r0, [r4, 0x2] -// cmp r0, 0 -// beq _0816B3C4 -// adds r0, r5, 0 -// movs r1, 0 -// bl sub_816B430 -// b _0816B3D4 -// .pool -//_0816B3C4: -// adds r0, r5, 0 -// bl sub_816B4DC -// ldr r1, =gText_NoItems -// ldr r2, =PlayerPC_ItemStorage -// adds r0, r5, 0 -// bl DisplayItemMessageOnField -//_0816B3D4: -// pop {r4,r5} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end ItemStorage_Withdraw -// -// thumb_func_start ItemStorage_Toss -//ItemStorage_Toss: @ 816B3E4 -// push {r4,r5,lr} -// 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_80D6CE4 -// lsls r0, 24 -// lsrs r0, 24 -// strh r0, [r4, 0x2] -// cmp r0, 0 -// beq _0816B410 -// adds r0, r5, 0 -// movs r1, 0x1 -// bl sub_816B430 -// b _0816B420 -// .pool -//_0816B410: -// adds r0, r5, 0 -// bl sub_816B4DC -// ldr r1, =gText_NoItems -// ldr r2, =PlayerPC_ItemStorage -// adds r0, r5, 0 -// bl DisplayItemMessageOnField -//_0816B420: -// pop {r4,r5} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end ItemStorage_Toss - -// thumb_func_start sub_816B430 -//sub_816B430: @ 816B430 -// push {r4-r6,lr} -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// lsls r1, 24 -// lsrs r1, 24 -// lsls r5, r4, 2 -// adds r5, r4 -// lsls r5, 3 -// ldr r6, =gTasks + 0x8 -// adds r0, r5, r6 -// strh r1, [r0, 0x6] -// adds r0, r4, 0 -// bl sub_816B4DC -// ldr r1, =gUnknown_0203BCB8 -// movs r0, 0 -// strh r0, [r1] -// strh r0, [r1, 0x2] -// movs r0, 0xFF -// strb r0, [r1, 0x9] -// adds r0, r4, 0 -// bl ItemStorage_SetItemAndMailCount -// bl sub_816BC14 -// bl gpu_pal_allocator_reset__manage_upper_four -// bl LoadListMenuArrowsGfx -// ldr r0, =gUnknown_0203BCC4 -// ldr r0, [r0] -// movs r1, 0xCD -// lsls r1, 3 -// adds r0, r1 -// movs r1, 0x7 -// bl sub_8122344 -// movs r0, 0 -// movs r1, 0 -// bl sub_8197434 -// subs r6, 0x8 -// adds r5, r6 -// ldr r0, =sub_816C158 -// str r0, [r5] -// pop {r4-r6} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B430 - -// thumb_func_start ItemStorage_Exit -//ItemStorage_Exit: @ 816B4A4 -// push {r4,lr} -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// adds r0, r4, 0 -// bl sub_816B4DC -// adds r0, r4, 0 -// bl ReshowPlayerPC -// pop {r4} -// pop {r0} -// bx r0 -// thumb_func_end ItemStorage_Exit - -// thumb_func_start ItemStorage_SetItemAndMailCount -//ItemStorage_SetItemAndMailCount: @ 816B4C0 -// push {lr} -// ldr r1, =gUnknown_0203BCB8 -// ldrb r0, [r1, 0x5] -// cmp r0, 0x7 -// bls _0816B4D4 -// movs r0, 0x8 -// b _0816B4D6 -// .pool -//_0816B4D4: -// adds r0, 0x1 -//_0816B4D6: -// strb r0, [r1, 0x4] -// pop {r0} -// bx r0 -// thumb_func_end ItemStorage_SetItemAndMailCount - -// thumb_func_start sub_816B4DC -//sub_816B4DC: @ 816B4DC -// push {r4,lr} -// lsls r0, 24 -// lsrs r0, 24 -// lsls r4, r0, 2 -// adds r4, r0 -// lsls r4, 3 -// ldr r0, =gTasks + 0x8 -// adds r4, r0 -// ldrb r0, [r4, 0x8] -// movs r1, 0 -// bl sub_8198070 -// ldrb r0, [r4, 0x8] -// bl ClearWindowTilemap -// ldrb r0, [r4, 0x8] -// bl RemoveWindow -// movs r0, 0 -// bl schedule_bg_copy_tilemap_to_vram -// pop {r4} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B4DC - -// thumb_func_start GetMailboxMailCount -//GetMailboxMailCount: @ 816B510 -// push {r4,lr} -// movs r2, 0 -// movs r1, 0x6 -// ldr r0, =gSaveBlock1Ptr -// ldr r3, [r0] -// movs r4, 0xB0 -// lsls r4, 6 -//_0816B51E: -// lsls r0, r1, 3 -// adds r0, r1 -// lsls r0, 2 -// adds r0, r3, r0 -// adds r0, r4 -// ldrh r0, [r0] -// cmp r0, 0 -// beq _0816B534 -// adds r0, r2, 0x1 -// lsls r0, 24 -// lsrs r2, r0, 24 -//_0816B534: -// adds r0, r1, 0x1 -// lsls r0, 24 -// lsrs r1, r0, 24 -// cmp r1, 0xF -// bls _0816B51E -// adds r0, r2, 0 -// pop {r4} -// pop {r1} -// bx r1 -// .pool -// thumb_func_end GetMailboxMailCount - -// thumb_func_start Mailbox_UpdateMailList -//Mailbox_UpdateMailList: @ 816B54C -// push {r4-r7,lr} -// mov r7, r10 -// mov r6, r9 -// mov r5, r8 -// push {r5-r7} -// sub sp, 0x24 -// movs r2, 0x6 -//_0816B55A: -// adds r1, r2, 0x1 -// lsls r0, r1, 24 -// lsrs r4, r0, 24 -// mov r8, r1 -// cmp r4, 0xF -// bhi _0816B5D4 -// ldr r0, =gSaveBlock1Ptr -// mov r10, r0 -// lsls r0, r2, 3 -// adds r0, r2 -// lsls r0, 2 -// mov r12, r0 -// ldr r6, =0x00002be0 -//_0816B574: -// mov r1, r10 -// ldr r1, [r1] -// mov r9, r1 -// mov r2, r9 -// add r2, r12 -// movs r3, 0xB0 -// lsls r3, 6 -// adds r0, r2, r3 -// ldrh r0, [r0] -// cmp r0, 0 -// bne _0816B5CA -// adds r2, r6 -// mov r1, sp -// adds r0, r2, 0 -// ldm r0!, {r3,r5,r7} -// stm r1!, {r3,r5,r7} -// ldm r0!, {r3,r5,r7} -// stm r1!, {r3,r5,r7} -// ldm r0!, {r3,r5,r7} -// stm r1!, {r3,r5,r7} -// lsls r3, r4, 3 -// adds r3, r4 -// lsls r3, 2 -// mov r5, r9 -// adds r0, r5, r3 -// adds r0, r6 -// ldm r0!, {r1,r5,r7} -// stm r2!, {r1,r5,r7} -// ldm r0!, {r1,r5,r7} -// stm r2!, {r1,r5,r7} -// ldm r0!, {r1,r5,r7} -// stm r2!, {r1,r5,r7} -// mov r7, r10 -// ldr r1, [r7] -// adds r1, r3 -// adds r1, r6 -// mov r0, sp -// ldm r0!, {r2,r3,r5} -// stm r1!, {r2,r3,r5} -// ldm r0!, {r2,r3,r7} -// stm r1!, {r2,r3,r7} -// ldm r0!, {r2,r5,r7} -// stm r1!, {r2,r5,r7} -//_0816B5CA: -// adds r0, r4, 0x1 -// lsls r0, 24 -// lsrs r4, r0, 24 -// cmp r4, 0xF -// bls _0816B574 -//_0816B5D4: -// mov r3, r8 -// lsls r0, r3, 24 -// lsrs r2, r0, 24 -// cmp r2, 0xE -// bls _0816B55A -// add sp, 0x24 -// pop {r3-r5} -// mov r8, r3 -// mov r9, r4 -// mov r10, r5 -// pop {r4-r7} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end Mailbox_UpdateMailList - -// thumb_func_start Mailbox_DrawMailboxMenu -//Mailbox_DrawMailboxMenu: @ 816B5F8 -// push {r4-r6,lr} -// sub sp, 0xC -// adds r5, r0, 0 -// lsls r5, 24 -// lsrs r5, 24 -// movs r0, 0 -// bl sub_81D1C84 -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// movs r0, 0x1 -// bl sub_81D1C84 -// ldr r6, =gText_Mailbox -// movs r0, 0x1 -// adds r1, r6, 0 -// movs r2, 0x40 -// bl GetStringCenterAlignXOffset -// adds r3, r0, 0 -// lsls r3, 24 -// lsrs r3, 24 -// movs r0, 0x1 -// str r0, [sp] -// movs r0, 0 -// str r0, [sp, 0x4] -// str r0, [sp, 0x8] -// adds r0, r4, 0 -// movs r1, 0x1 -// adds r2, r6, 0 -// bl PrintTextOnWindow -// movs r0, 0 -// bl schedule_bg_copy_tilemap_to_vram -// ldr r4, =gUnknown_0203BCB8 -// adds r0, r4, 0 -// bl sub_81D1DC0 -// ldr r2, =gTasks -// lsls r1, r5, 2 -// adds r1, r5 -// lsls r1, 3 -// adds r1, r2 -// lsls r0, 24 -// lsrs r0, 24 -// strh r0, [r1, 0x12] -// adds r0, r4, 0 -// bl sub_81D1E90 -// add sp, 0xC -// pop {r4-r6} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end Mailbox_DrawMailboxMenu - -// thumb_func_start Mailbox_ProcessInput -//Mailbox_ProcessInput: @ 816B674 -// push {r4-r7,lr} -// mov r7, r10 -// mov r6, r9 -// mov r5, r8 -// push {r5-r7} -// lsls r0, 24 -// lsrs r5, r0, 24 -// lsls r0, r5, 2 -// adds r0, r5 -// lsls r0, 3 -// mov r9, r0 -// ldr r0, =gTasks + 0x8 -// mov r10, r0 -// mov r4, r9 -// add r4, r10 -// ldr r0, =gPaletteFade -// ldrb r1, [r0, 0x7] -// movs r0, 0x80 -// ands r0, r1 -// cmp r0, 0 -// bne _0816B71E -// ldrb r0, [r4, 0xA] -// bl ListMenuHandleInputGetItemId -// adds r6, r0, 0 -// ldrb r0, [r4, 0xA] -// ldr r7, =gUnknown_0203BCBA -// subs r1, r7, 0x2 -// mov r8, r1 -// adds r1, r7, 0 -// mov r2, r8 -// bl sub_81AE860 -// movs r0, 0x2 -// negs r0, r0 -// cmp r6, r0 -// beq _0816B6D4 -// adds r0, 0x1 -// cmp r6, r0 -// bne _0816B6EA -// b _0816B71E -// .pool -//_0816B6D4: -// movs r0, 0x5 -// bl PlaySE -// mov r1, r8 -// ldrb r0, [r1, 0x9] -// bl RemoveScrollIndicatorArrowPair -// adds r0, r5, 0 -// bl sub_816B798 -// b _0816B71E -//_0816B6EA: -// movs r0, 0x5 -// bl PlaySE -// movs r0, 0 -// bl sub_81D1D04 -// movs r0, 0x1 -// bl sub_81D1D04 -// ldrb r0, [r4, 0xA] -// adds r1, r7, 0 -// mov r2, r8 -// bl sub_81AE6C8 -// movs r0, 0 -// bl schedule_bg_copy_tilemap_to_vram -// mov r1, r8 -// ldrb r0, [r1, 0x9] -// bl RemoveScrollIndicatorArrowPair -// mov r0, r10 -// subs r0, 0x8 -// add r0, r9 -// ldr r1, =sub_816B730 -// str r1, [r0] -//_0816B71E: -// pop {r3-r5} -// mov r8, r3 -// mov r9, r4 -// mov r10, r5 -// pop {r4-r7} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end Mailbox_ProcessInput - -// thumb_func_start sub_816B730 -//sub_816B730: @ 816B730 -// push {r4,r5,lr} -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// ldr r5, =gStringVar1 -// ldr r2, =gSaveBlock1Ptr -// ldr r1, =gUnknown_0203BCB8 -// ldrh r0, [r1] -// adds r0, 0x6 -// ldrh r1, [r1, 0x2] -// adds r0, r1 -// lsls r1, r0, 3 -// adds r1, r0 -// lsls r1, 2 -// ldr r0, [r2] -// adds r1, r0 -// ldr r0, =0x00002bf2 -// adds r1, r0 -// adds r0, r5, 0 -// bl StringCopy -// adds r0, r5, 0 -// movs r1, 0 -// bl sub_81DB554 -// ldr r5, =gStringVar4 -// ldr r1, =gText_WhatToDoWithVar1sMail -// adds r0, r5, 0 -// bl StringExpandPlaceholders -// ldr r2, =sub_816B7DC -// adds r0, r4, 0 -// adds r1, r5, 0 -// bl DisplayItemMessageOnField -// pop {r4,r5} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B730 - -// thumb_func_start sub_816B798 -//sub_816B798: @ 816B798 -// 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 r0, 0 -// bl sub_81D1D04 -// movs r0, 0x1 -// bl sub_81D1D04 -// ldrb r0, [r4, 0xA] -// movs r1, 0 -// movs r2, 0 -// bl sub_81AE6C8 -// movs r0, 0 -// bl schedule_bg_copy_tilemap_to_vram -// bl sub_81D1EC0 -// adds r0, r5, 0 -// bl ReshowPlayerPC -// pop {r4,r5} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B798 - -// thumb_func_start sub_816B7DC -//sub_816B7DC: @ 816B7DC -// push {r4,r5,lr} -// adds r5, r0, 0 -// lsls r5, 24 -// lsrs r5, 24 -// movs r0, 0x2 -// bl sub_81D1C84 -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// ldr r2, =gUnknown_085DFF04 -// adds r0, r4, 0 -// movs r1, 0x4 -// bl PrintMenuTable -// adds r0, r4, 0 -// movs r1, 0x4 -// movs r2, 0 -// bl InitMenuInUpperLeftCornerPlaySoundWhenAPressed -// movs r0, 0 -// bl schedule_bg_copy_tilemap_to_vram -// ldr r1, =gTasks -// lsls r0, r5, 2 -// adds r0, r5 -// lsls r0, 3 -// adds r0, r1 -// ldr r1, =sub_816B82C -// str r1, [r0] -// pop {r4,r5} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B7DC - -// thumb_func_start sub_816B82C -//sub_816B82C: @ 816B82C -// push {r4-r6,lr} -// lsls r0, 24 -// lsrs r5, r0, 24 -// adds r6, r5, 0 -// bl ProcessMenuInput_other -// lsls r0, 24 -// asrs r4, r0, 24 -// movs r0, 0x2 -// negs r0, r0 -// cmp r4, r0 -// beq _0816B86E -// adds r0, 0x1 -// cmp r4, r0 -// bne _0816B858 -// movs r0, 0x5 -// bl PlaySE -// adds r0, r5, 0 -// bl sub_816BBD4 -// b _0816B86E -//_0816B858: -// movs r0, 0x5 -// bl PlaySE -// ldr r0, =gUnknown_085DFF04 -// lsls r1, r4, 3 -// adds r0, 0x4 -// adds r1, r0 -// ldr r1, [r1] -// adds r0, r6, 0 -// bl _call_via_r1 -//_0816B86E: -// pop {r4-r6} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B82C - -// thumb_func_start sub_816B878 -//sub_816B878: @ 816B878 -// push {r4,lr} -// adds r4, r0, 0 -// lsls r4, 24 -// lsrs r4, 24 -// movs r0, 0x1 -// movs r1, 0 -// bl FadeScreen -// ldr r1, =gTasks -// lsls r0, r4, 2 -// adds r0, r4 -// lsls r0, 3 -// adds r0, r1 -// ldr r1, =sub_816B8A4 -// str r1, [r0] -// pop {r4} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B878 -// -// thumb_func_start sub_816B8A4 -//sub_816B8A4: @ 816B8A4 -// push {r4,lr} -// lsls r0, 24 -// lsrs r4, r0, 24 -// ldr r0, =gPaletteFade -// ldrb r1, [r0, 0x7] -// movs r0, 0x80 -// ands r0, r1 -// cmp r0, 0 -// bne _0816B8E6 -// bl sub_81D1EC0 -// bl overworld_free_bg_tilemaps -// ldr r2, =gSaveBlock1Ptr -// ldr r1, =gUnknown_0203BCB8 -// ldrh r0, [r1] -// adds r0, 0x6 -// ldrh r1, [r1, 0x2] -// adds r0, r1 -// lsls r1, r0, 3 -// adds r1, r0 -// lsls r1, 2 -// ldr r0, =0x00002be0 -// adds r1, r0 -// ldr r0, [r2] -// adds r0, r1 -// ldr r1, =sub_816B900 -// movs r2, 0x1 -// bl ReadMail -// adds r0, r4, 0 -// bl DestroyTask -//_0816B8E6: -// pop {r4} -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B8A4 - -// thumb_func_start sub_816B900 -//sub_816B900: @ 816B900 -// push {lr} -// ldr r0, =gFieldCallback -// ldr r1, =pal_fill_for_maplights_or_black -// str r1, [r0] -// ldr r0, =CB2_ReturnToField -// bl SetMainCallback2 -// pop {r0} -// bx r0 -// .pool -// thumb_func_end sub_816B900 - - thumb_func_start pal_fill_for_maplights_or_black -pal_fill_for_maplights_or_black: @ 816B920 - push {r4,lr} - bl sub_81973A4 - ldr r0, =task00_080EBBDC - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gUnknown_0203BCB8 - ldrb r0, [r0, 0x5] - bl sub_81D1C44 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0816B954 - adds r0, r4, 0 - bl Mailbox_DrawMailboxMenu - b _0816B95A - .pool -_0816B954: - adds r0, r4, 0 - bl DestroyTask -_0816B95A: - bl pal_fill_black - pop {r4} - pop {r0} - bx r0 - thumb_func_end pal_fill_for_maplights_or_black - - thumb_func_start task00_080EBBDC -task00_080EBBDC: @ 816B964 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl sub_80ABDFC - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0816B984 - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =Mailbox_ProcessInput - str r0, [r1] -_0816B984: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end task00_080EBBDC - - thumb_func_start sub_816B994 -sub_816B994: @ 816B994 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gText_MessageWillBeLost - ldr r2, =sub_816B9B0 - bl DisplayItemMessageOnField - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B994 - - thumb_func_start sub_816B9B0 -sub_816B9B0: @ 816B9B0 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl sub_8197930 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816B9D8 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816B9B0 - - thumb_func_start sub_816B9D8 -sub_816B9D8: @ 816B9D8 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl ProcessMenuInputNoWrap_ - lsls r0, 24 - asrs r0, 24 - movs r1, 0x1 - negs r1, r1 - cmp r0, r1 - beq _0816BA04 - cmp r0, r1 - ble _0816BA10 - cmp r0, 0 - beq _0816B9FC - cmp r0, 0x1 - beq _0816BA0A - b _0816BA10 -_0816B9FC: - adds r0, r4, 0 - bl sub_816BA18 - b _0816BA10 -_0816BA04: - movs r0, 0x5 - bl PlaySE -_0816BA0A: - adds r0, r4, 0 - bl sub_816BAAC -_0816BA10: - pop {r4} - pop {r0} - bx r0 - thumb_func_end sub_816B9D8 - - thumb_func_start sub_816BA18 -sub_816BA18: @ 816BA18 - push {r4-r6,lr} - lsls r0, 24 - lsrs r6, r0, 24 - ldr r2, =gSaveBlock1Ptr - ldr r4, =gUnknown_0203BCB8 - ldrh r1, [r4] - adds r1, 0x6 - ldrh r0, [r4, 0x2] - adds r1, r0 - lsls r0, r1, 3 - adds r0, r1 - lsls r0, 2 - ldr r1, =0x00002be0 - adds r0, r1 - ldr r1, [r2] - adds r5, r1, r0 - ldrh r0, [r5, 0x20] - movs r1, 0x1 - bl AddBagItem - lsls r0, 24 - cmp r0, 0 - bne _0816BA68 - ldr r1, =gText_BagIsFull - ldr r2, =sub_816BBD4 - adds r0, r6, 0 - bl DisplayItemMessageOnField - b _0816BA9C - .pool -_0816BA68: - ldr r1, =gText_MailToBagMessageErased - ldr r2, =sub_816BBD4 - adds r0, r6, 0 - bl DisplayItemMessageOnField - adds r0, r5, 0 - bl ClearMailStruct - bl Mailbox_UpdateMailList - ldrb r0, [r4, 0x5] - subs r0, 0x1 - strb r0, [r4, 0x5] - ldrb r1, [r4, 0x5] - ldrb r0, [r4, 0x4] - ldrh r2, [r4, 0x2] - adds r0, r2 - cmp r1, r0 - bge _0816BA96 - cmp r2, 0 - beq _0816BA96 - subs r0, r2, 0x1 - strh r0, [r4, 0x2] -_0816BA96: - adds r0, r6, 0 - bl ItemStorage_SetItemAndMailCount -_0816BA9C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BA18 - - thumb_func_start sub_816BAAC -sub_816BAAC: @ 816BAAC - push {lr} - lsls r0, 24 - lsrs r0, 24 - bl sub_816BBD4 - pop {r0} - bx r0 - thumb_func_end sub_816BAAC - - thumb_func_start sub_816BABC -sub_816BABC: @ 816BABC - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - bl CalculatePlayerPartyCount - lsls r0, 24 - cmp r0, 0 - bne _0816BAD4 - adds r0, r4, 0 - bl sub_816BBB8 - b _0816BAEA -_0816BAD4: - movs r0, 0x1 - movs r1, 0 - bl FadeScreen - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =sub_816BAF8 - str r0, [r1] -_0816BAEA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BABC - - thumb_func_start sub_816BAF8 -sub_816BAF8: @ 816BAF8 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gPaletteFade - ldrb r1, [r0, 0x7] - movs r0, 0x80 - ands r0, r1 - cmp r0, 0 - bne _0816BB1C - bl sub_81D1EC0 - bl overworld_free_bg_tilemaps - bl sub_81B8448 - adds r0, r4, 0 - bl DestroyTask -_0816BB1C: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BAF8 - - thumb_func_start sub_816BB28 -sub_816BB28: @ 816BB28 - push {lr} - ldr r0, =gFieldCallback - ldr r1, =sub_816BB48 - str r1, [r0] - ldr r0, =CB2_ReturnToField - bl SetMainCallback2 - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BB28 - - thumb_func_start sub_816BB48 -sub_816BB48: @ 816BB48 - push {r4-r6,lr} - ldr r0, =task00_080EBBDC - movs r1, 0 - bl CreateTask - lsls r0, 24 - lsrs r6, r0, 24 - ldr r5, =gUnknown_0203BCB8 - ldrb r4, [r5, 0x5] - bl GetMailboxMailCount - strb r0, [r5, 0x5] - bl Mailbox_UpdateMailList - ldrb r0, [r5, 0x5] - cmp r4, r0 - beq _0816BB7E - ldrb r1, [r5, 0x5] - ldrb r0, [r5, 0x4] - ldrh r2, [r5, 0x2] - adds r0, r2 - cmp r1, r0 - bge _0816BB7E - cmp r2, 0 - beq _0816BB7E - subs r0, r2, 0x1 - strh r0, [r5, 0x2] -_0816BB7E: - adds r0, r6, 0 - bl ItemStorage_SetItemAndMailCount - bl sub_81973A4 - ldr r0, =gUnknown_0203BCB8 - ldrb r0, [r0, 0x5] - bl sub_81D1C44 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0816BBA8 - adds r0, r6, 0 - bl Mailbox_DrawMailboxMenu - b _0816BBAE - .pool -_0816BBA8: - adds r0, r6, 0 - bl DestroyTask -_0816BBAE: - bl pal_fill_black - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_816BB48 - - thumb_func_start sub_816BBB8 -sub_816BBB8: @ 816BBB8 - push {lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gText_NoPokemon - ldr r2, =sub_816BBD4 - bl DisplayItemMessageOnField - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BBB8 - - thumb_func_start sub_816BBD4 -sub_816BBD4: @ 816BBD4 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - movs r0, 0x2 - bl sub_81D1D04 - movs r0, 0 - movs r1, 0 - bl sub_8197434 - adds r0, r4, 0 - bl Mailbox_DrawMailboxMenu - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =Mailbox_ProcessInput - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BBD4 - - thumb_func_start sub_816BC14 -sub_816BC14: @ 816BC14 - push {r4,lr} - ldr r4, =gUnknown_0203BCC4 - movs r0, 0xCE - lsls r0, 3 - bl AllocZeroed - str r0, [r4] - movs r1, 0xCC - lsls r1, 3 - adds r0, r1 - movs r1, 0xFF - movs r2, 0x6 - bl memset - ldr r0, [r4] - ldr r1, =0x00000666 - adds r0, r1 - movs r1, 0xFF - strb r1, [r0] - ldr r0, [r4] - ldr r1, =0x00000667 - adds r0, r1 - movs r1, 0x1 - negs r1, r1 - strb r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BC14 - - thumb_func_start sub_816BC58 -sub_816BC58: @ 816BC58 - push {r4,lr} - movs r4, 0 -_0816BC5C: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_816BCC4 - adds r4, 0x1 - cmp r4, 0x5 - bls _0816BC5C - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - bl Free - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BC58 - - thumb_func_start sub_816BC7C -sub_816BC7C: @ 816BC7C - push {r4,lr} - lsls r0, 24 - lsrs r2, r0, 24 - ldr r0, =gUnknown_0203BCC4 - movs r3, 0xCC - lsls r3, 3 - adds r1, r2, r3 - ldr r0, [r0] - adds r4, r0, r1 - ldrb r0, [r4] - cmp r0, 0xFF - bne _0816BCB4 - lsls r0, r2, 3 - ldr r1, =gUnknown_085DFF5C - adds r0, r1 - bl AddWindow - strb r0, [r4] - ldrb r0, [r4] - movs r2, 0x85 - lsls r2, 2 - movs r1, 0 - movs r3, 0xE - bl SetWindowBorderStyle - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram -_0816BCB4: - ldrb r0, [r4] - pop {r4} - pop {r1} - bx r1 - .pool - thumb_func_end sub_816BC7C - - thumb_func_start sub_816BCC4 -sub_816BCC4: @ 816BCC4 - push {r4,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gUnknown_0203BCC4 - movs r2, 0xCC - lsls r2, 3 - adds r0, r2 - ldr r1, [r1] - adds r4, r1, r0 - ldrb r0, [r4] - cmp r0, 0xFF - beq _0816BCF8 - movs r1, 0 - bl sub_8198070 - ldrb r0, [r4] - bl ClearWindowTilemap - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldrb r0, [r4] - bl RemoveWindow - movs r0, 0xFF - strb r0, [r4] -_0816BCF8: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BCC4 - - thumb_func_start sub_816BD04 -sub_816BD04: @ 816BD04 - push {r4-r6,lr} - movs r6, 0 - ldr r0, =gUnknown_0203BCB8 - ldrb r0, [r0, 0x5] - subs r0, 0x1 - cmp r6, r0 - bge _0816BD58 - ldr r5, =gUnknown_0203BCC4 -_0816BD14: - lsls r4, r6, 1 - adds r4, r6 - lsls r4, 3 - movs r0, 0xCC - lsls r0, 1 - adds r4, r0 - ldr r0, [r5] - adds r0, r4 - ldr r1, =gSaveBlock1Ptr - ldr r1, [r1] - lsls r2, r6, 2 - adds r1, r2 - movs r2, 0x93 - lsls r2, 3 - adds r1, r2 - ldrh r1, [r1] - bl sub_816BDC8 - ldr r0, [r5] - lsls r2, r6, 3 - adds r1, r0, r2 - adds r4, r0, r4 - str r4, [r1] - adds r0, 0x4 - adds r0, r2 - str r6, [r0] - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =gUnknown_0203BCB8 - ldrb r0, [r0, 0x5] - subs r0, 0x1 - cmp r6, r0 - blt _0816BD14 -_0816BD58: - ldr r5, =gUnknown_0203BCC4 - lsls r4, r6, 1 - adds r4, r6 - lsls r4, 3 - movs r3, 0xCC - lsls r3, 1 - adds r4, r3 - ldr r0, [r5] - adds r0, r4 - ldr r1, =gText_Cancel2 - bl StringCopy - ldr r0, [r5] - lsls r2, r6, 3 - adds r1, r0, r2 - adds r4, r0, r4 - str r4, [r1] - adds r0, 0x4 - adds r0, r2 - movs r1, 0x2 - negs r1, r1 - str r1, [r0] - ldr r4, =gMultiuseListMenuTemplate - adds r1, r4, 0 - ldr r0, =gUnknown_085DFF44 - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - ldm r0!, {r2,r3,r6} - stm r1!, {r2,r3,r6} - movs r0, 0 - bl sub_816BC7C - strb r0, [r4, 0x10] - ldr r1, =gUnknown_0203BCB8 - ldrb r0, [r1, 0x5] - strh r0, [r4, 0xC] - ldr r0, [r5] - str r0, [r4] - ldrb r0, [r1, 0x4] - strh r0, [r4, 0xE] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BD04 - - thumb_func_start sub_816BDC8 -sub_816BDC8: @ 816BDC8 - push {lr} - adds r2, r0, 0 - lsls r0, r1, 16 - lsrs r0, 16 - adds r1, r2, 0 - bl CopyItemName - pop {r0} - bx r0 - thumb_func_end sub_816BDC8 - - thumb_func_start sub_816BDDC -sub_816BDDC: @ 816BDDC - push {r4,lr} - adds r4, r0, 0 - lsls r1, 24 - lsrs r1, 24 - cmp r1, 0x1 - beq _0816BDEE - movs r0, 0x5 - bl PlaySE -_0816BDEE: - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - ldr r1, =0x00000666 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0xFF - bne _0816BE38 - bl sub_816C0C8 - movs r0, 0x2 - negs r0, r0 - cmp r4, r0 - beq _0816BE2C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - lsls r1, r4, 2 - adds r0, r1 - movs r1, 0x93 - lsls r1, 3 - adds r0, r1 - ldrh r0, [r0] - bl sub_816C060 - b _0816BE32 - .pool -_0816BE2C: - ldr r0, =0x0000ffff - bl sub_816C060 -_0816BE32: - adds r0, r4, 0 - bl sub_816BEF0 -_0816BE38: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BDDC - thumb_func_start fish4_goto_x5_or_x6 fish4_goto_x5_or_x6: @ 816BE44 push {r4-r6,lr} @@ -2275,8 +375,8 @@ sub_816C140: @ 816C140 .pool thumb_func_end sub_816C140 - thumb_func_start sub_816C158 -sub_816C158: @ 816C158 + thumb_func_start ItemStorage_ProcessInput +ItemStorage_ProcessInput: @ 816C158 push {r4-r7,lr} sub sp, 0xC lsls r0, 24 @@ -2353,7 +453,7 @@ _0816C186: pop {r0} bx r0 .pool - thumb_func_end sub_816C158 + thumb_func_end ItemStorage_ProcessInput thumb_func_start sub_816C228 sub_816C228: @ 816C228 diff --git a/asm/pokenav.s b/asm/pokenav.s index 56bf3d41f..4e54d63d0 100644 --- a/asm/pokenav.s +++ b/asm/pokenav.s @@ -21780,7 +21780,7 @@ sub_81D1C84: @ 81D1C84 ldr r0, [r0, 0x10] str r0, [sp] str r1, [sp, 0x4] - ldr r0, =gUnknown_085DFF04 + ldr r0, =gMailboxMailOptions movs r1, 0x4 bl GetMaxWidthInMenuTable lsls r0, 24 diff --git a/data/player_pc.s b/data/player_pc.s index ef8a2ba9c..69eacb69b 100644 --- a/data/player_pc.s +++ b/data/player_pc.s @@ -39,11 +39,11 @@ gNewGamePCItems:: @ 85DFEFC .2byte 0x0000, 0x0000 .align 2 -gUnknown_085DFF04:: @ 85DFF04 - .4byte gText_Read, sub_816B878 - .4byte gText_MoveToBag, sub_816B994 - .4byte gText_Give2, sub_816BABC - .4byte gText_Cancel2, sub_816BBD4 +gMailboxMailOptions:: @ 85DFF04 + .4byte gText_Read, Mailbox_DoMailRead + .4byte gText_MoveToBag, Mailbox_MoveToBag + .4byte gText_Give2, Mailbox_Give + .4byte gText_Cancel2, Mailbox_Cancel .align 2 gUnknown_085DFF24:: @ 85DFF24 diff --git a/src/player_pc.c b/src/player_pc.c index aa58f2e32..538556efd 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -9,8 +9,10 @@ #include "item.h" #include "item_menu.h" #include "constants/items.h" +#include "list_menu.h" #include "mail.h" #include "main.h" +#include "malloc.h" #include "menu.h" #include "menu_helpers.h" #include "overworld.h" @@ -23,6 +25,21 @@ #include "task.h" #include "window.h" +struct Struct203BCC4 +{ + struct ListMenuItem unk0[51]; + //u8 filler[0x118]; + u8 unk198[51][0x18]; + //u8 filler2[0x348]; + u8 unk660[6]; + u8 unk666; + s8 unk667; + u32 unk668; + u8 filler3[4]; + +}; + +extern struct Struct203BCC4 *gUnknown_0203BCC4; static EWRAM_DATA u8 *gPcItemMenuOptionOrder = NULL; @@ -32,185 +49,45 @@ extern struct MailboxStruct gUnknown_0203BCB8; #define eMailboxInfo gUnknown_0203BCB8 -struct Struct203BCC4 -{ - u8 filler[0x668]; - u32 unk668; - u8 filler2[4]; -}; - -extern struct Struct203BCC4 *gUnknown_0203BCC4; - - -/*static*/void InitPlayerPCMenu(u8 taskId); -/*static*/void PlayerPCProcessMenuInput(u8 taskId); -/*static*/void InitItemStorageMenu(u8 taskId, u8 var); +/*static*/ void InitPlayerPCMenu(u8 taskId); +/*static*/ void PlayerPCProcessMenuInput(u8 taskId); +/*static*/ void InitItemStorageMenu(u8 taskId, u8 var); /*static*/ void ItemStorageMenuPrint(const u8 *); /*static*/ void ItemStorageMenuProcessInput(u8 taskId); -/* -static void ItemStorage_ProcessInput(u8); -*/ +/*static*/ void ItemStorage_ProcessInput(u8 taskId); /*static*/ void ItemStorage_SetItemAndMailCount(u8); -/* -static void ItemStorage_DoItemAction(u8); -static void ItemStorage_GoBackToPlayerPCMenu(u8); -static void ItemStorage_HandleQuantityRolling(u8); -static void ItemStorage_DoItemWithdraw(u8); -static void ItemStorage_DoItemToss(u8); -static void ItemStorage_HandleRemoveItem(u8); -static void ItemStorage_WaitPressHandleResumeProcessInput(u8); -*/ +/*static*/ void ItemStorage_DoItemWithdraw(u8); +/*static*/ void ItemStorage_DoItemToss(u8); +/*static*/ void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss); + /*static*/ void ItemStorage_HandleReturnToProcessInput(u8); -/* -static void ItemStorage_HandleResumeProcessInput(u8); -static void ItemStorage_DoItemSwap(u8, bool8); -static void ItemStorage_DrawItemList(u8); -static void ItemStorage_PrintItemPcResponse(u16); -static void ItemStorage_DrawBothListAndDescription(u8); -static void ItemStorage_GoBackToItemPCMenu(u8, u8); -static void ItemStorage_LoadPalette(void); -*/ + /*static*/ u8 GetMailboxMailCount(void); /*static*/ void Mailbox_UpdateMailList(void); /*static*/ void Mailbox_DrawMailboxMenu(u8); /*static*/ void Mailbox_ProcessInput(u8); -/* -static void Mailbox_CloseScrollIndicators(void); -static void Mailbox_PrintWhatToDoWithPlayerMailText(u8); -static void Mailbox_TurnOff(u8); -static void Mailbox_PrintMailOptions(u8); -static void Mailbox_MailOptionsProcessInput(u8); -static void Mailbox_FadeAndReadMail(u8); -static void Mailbox_ReturnToFieldFromReadMail(void); -static void Mailbox_DrawYesNoBeforeMove(u8); -static void Mailbox_DoGiveMailPokeMenu(u8); -static void Mailbox_NoPokemonForMail(u8); -static void Mailbox_Cancel(u8); -static void Mailbox_DrawMailMenuAndDoProcessInput(u8); -*/ +/*static*/ void Mailbox_PrintWhatToDoWithPlayerMailText(u8); + /*static*/ void PlayerPC_ItemStorage(u8 taskId); /*static*/ void PlayerPC_Mailbox(u8 taskId); /*static*/ void PlayerPC_Decoration(u8 var); /*static*/ void PlayerPC_TurnOff(u8 taskId); -/* -static void ItemStorage_Withdraw(u8); -static void ItemStorage_Deposit(u8); -static void ItemStorage_Toss(u8); -*/ + /*static*/ void ItemStorage_Exit(u8); -/* -static void ItemStorage_ResumeInputFromYesToss(u8); -static void ItemStorage_ResumeInputFromNoToss(u8); -static void Mailbox_DoMailMoveToBag(u8); -static void Mailbox_ReturnToInputAfterNo(u8); -static void Mailbox_DoMailRead(u8); -static void Mailbox_MoveToBag(u8); -static void Mailbox_Give(u8); -static void Mailbox_Cancel(u8); -*/ + extern const u8 *const gPCText_OptionDescList[]; -/* -static const u8 *const gPCText_OptionDescList[] = -{ - PCText_TakeOutItems, - PCText_StoreItems, - PCText_ThrowAwayItems, - gMenuText_GoBackToPrev -}; -*/ -/*static*/ extern const struct MenuAction sPlayerPCMenuActions[];/* = -{ - { SecretBaseText_ItemStorage, PlayerPC_ItemStorage }, - { gPCText_Mailbox, PlayerPC_Mailbox }, - { SecretBaseText_Decoration, PlayerPC_Decoration }, - { SecretBaseText_TurnOff, PlayerPC_TurnOff } -}; -*/ -/*static*/ extern u8 gBedroomPC_OptionOrder[];/* = -{ - PLAYERPC_MENU_ITEMSTORAGE, - PLAYERPC_MENU_MAILBOX, - PLAYERPC_MENU_DECORATION, - PLAYERPC_MENU_TURNOFF -}; -*/ -/*static*/ extern u8 gPlayerPC_OptionOrder[];/* = -{ - PLAYERPC_MENU_ITEMSTORAGE, - PLAYERPC_MENU_MAILBOX, - PLAYERPC_MENU_TURNOFF -}; -*/ -extern const struct MenuAction gPCText_ItemPCOptionsText[]; -/* -static const struct MenuAction2 gPCText_ItemPCOptionsText[] = -{ - { PCText_WithdrawItem, ItemStorage_Withdraw }, - { PCText_DepositItem, ItemStorage_Deposit }, - { PCText_TossItem, ItemStorage_Toss }, - { gUnknownText_Exit, ItemStorage_Exit } -}; - -static const struct YesNoFuncTable ResumeFromTossYesNoFuncList[] = // ResumeFromTossYesNoFuncList -{ - ItemStorage_ResumeInputFromYesToss, - ItemStorage_ResumeInputFromNoToss -}; - -static const struct YesNoFuncTable ResumeFromWithdrawYesNoFuncList[] = // ResumeFromWithdrawYesNoFuncList -{ - Mailbox_DoMailMoveToBag, - Mailbox_ReturnToInputAfterNo -}; -*/ -// the use of this struct is meant to be an ItemSlot struct, but NewGameInitPCItems refuses to match without a weird pointer access. -/*static*/ extern const struct ItemSlot gNewGamePCItems[];/* = -{ - { ITEM_POTION, 1 }, - { ITEM_NONE, 0 } -}; - -static const struct MenuAction2 gMailboxMailOptions[] = -{ - { OtherText_Read, Mailbox_DoMailRead }, - { gOtherText_MoveToBag, Mailbox_MoveToBag }, - { OtherText_Give, Mailbox_Give }, - { gOtherText_CancelNoTerminator, Mailbox_Cancel } -}; - -static const u8 gNonSelectedItemFormattedText[] = _("{STR_VAR_1}{CLEAR_TO 80}"); -static const u8 gSelectedItemFormattedText[] = _("{COLOR RED}{STR_VAR_1}{CLEAR_TO 80}"); -static const u8 gNonSelectedItemQuantityFormatText[] = _("{STR_VAR_1}"); -static const u8 gSelectedItemQuantityFormatText[] = _("{COLOR RED}{STR_VAR_1}"); -static const u8 gUnknown_08406330[] = _("{CLEAR_TO 32}"); -*/ +/*static*/ extern const struct ItemSlot gNewGamePCItems[]; +/*static*/ extern const struct MenuAction gPCText_ItemPCOptionsText[]; +/*static*/ extern const struct MenuAction gMailboxMailOptions[]; +/*static*/ extern const struct MenuAction sPlayerPCMenuActions[]; +/*static*/ extern u8 gBedroomPC_OptionOrder[]; +/*static*/ extern u8 gPlayerPC_OptionOrder[]; extern const struct WindowTemplate gUnknown_085DFF24[3]; -/* -extern u8 *gUnknown_02039314; -extern struct MenuAction gUnknown_08406298[]; - -extern u8 gUnknown_084062B8[]; -extern u8 gUnknown_084062BC[]; -extern u8 gUnknown_0840632A[]; -extern u8 gUnknown_08406327[]; -extern u8 gUnknown_0840631E[]; -extern u8 gUnknown_08406318[]; - -extern u8 gUnknown_030007B4; -extern u8 unk_201FE00[]; - -extern u8 gUnknown_08152850; -extern u8 gUnknown_08152C75; - -extern u32 gUnknown_08406288[]; -extern const struct MenuAction gUnknown_084062C0[]; -extern const struct YesNoFuncTable gUnknown_084062E0; -*/ void NewGameInitPCItems(void) @@ -441,7 +318,7 @@ void mapldr_080EBC0C(void) u8 sub_80D6CE4(); //count of items void sub_816B4DC(u8 taskId); -void sub_816B430(u8 taskId, bool8 toss); + extern const u8 gText_NoItems[]; /*static*/ void ItemStorage_Withdraw(u8 taskId) @@ -451,7 +328,7 @@ extern const u8 gText_NoItems[]; NUM_ITEMS = sub_80D6CE4(); if (NUM_ITEMS != 0) - sub_816B430(taskId, FALSE); + ItemStorage_WithdrawToss_Helper(taskId, FALSE); else { sub_816B4DC(taskId); @@ -466,7 +343,7 @@ extern const u8 gText_NoItems[]; NUM_ITEMS = sub_80D6CE4(); if (NUM_ITEMS != 0) - sub_816B430(taskId, TRUE); + ItemStorage_WithdrawToss_Helper(taskId, TRUE); else { sub_816B4DC(taskId); @@ -476,9 +353,9 @@ extern const u8 gText_NoItems[]; void sub_816BC14(void); void gpu_pal_allocator_reset__manage_upper_four(void); -void sub_816C158(u8 taskId); -/*static*/ void sub_816B430(u8 taskId, bool8 toss) + +/*static*/ void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss) { u16 *data = gTasks[taskId].data; @@ -493,7 +370,7 @@ void sub_816C158(u8 taskId); LoadListMenuArrowsGfx(); sub_8122344(&(gUnknown_0203BCC4->unk668), 7); sub_8197434(0,0); - gTasks[taskId].func = sub_816C158; + gTasks[taskId].func = ItemStorage_ProcessInput; } @@ -571,13 +448,11 @@ void sub_81D1E90(struct MailboxStruct *); sub_81D1E90(&eMailboxInfo); } -u32 ListMenuHandleInputGetItemId(u8); -void sub_81AE860(u8, void *, void *); -void sub_81AE6C8(u8, void *, void *); -void sub_816B798(u8); + +void Mailbox_ReturnToPlayerPC(u8); void RemoveScrollIndicatorArrowPair(u8); void sub_81D1D04(u8); -void sub_816B730(u8); + /*static*/ void Mailbox_ProcessInput(u8 taskId) { @@ -587,7 +462,7 @@ void sub_816B730(u8); if(!gPaletteFade.active) { inputOptionId = ListMenuHandleInputGetItemId(data[5]); - sub_81AE860(data[5], &(eMailboxInfo.itemsAbove), &eMailboxInfo); + sub_81AE860(data[5], &(eMailboxInfo.itemsAbove), &(eMailboxInfo.cursorPos)); switch(inputOptionId) { @@ -596,36 +471,36 @@ void sub_816B730(u8); case -2: PlaySE(SE_SELECT); RemoveScrollIndicatorArrowPair(eMailboxInfo.unk6[3]); - sub_816B798(taskId); + Mailbox_ReturnToPlayerPC(taskId); break; default: PlaySE(SE_SELECT); sub_81D1D04(0); sub_81D1D04(1); - sub_81AE6C8(data[5], &(eMailboxInfo.itemsAbove), &eMailboxInfo); + sub_81AE6C8(data[5], &(eMailboxInfo.itemsAbove), &(eMailboxInfo.cursorPos)); schedule_bg_copy_tilemap_to_vram(0); RemoveScrollIndicatorArrowPair(eMailboxInfo.unk6[3]); - gTasks[taskId].func = sub_816B730; + gTasks[taskId].func = Mailbox_PrintWhatToDoWithPlayerMailText; break; } } } void sub_81DB554(u8 *, u8); -void sub_816B7DC(u8); +void Mailbox_PrintMailOptions(u8); extern const u8 gText_WhatToDoWithVar1sMail[]; -/*static*/ void sub_816B730(u8 taskId)//Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) +/*static*/ void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId)//Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) { StringCopy(gStringVar1, gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos].playerName); sub_81DB554(gStringVar1, 0); StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithVar1sMail); - DisplayItemMessageOnField(taskId, gStringVar4, sub_816B7DC); + DisplayItemMessageOnField(taskId, gStringVar4, Mailbox_PrintMailOptions); } void sub_81D1EC0(void); -/*static*/ void sub_816B798(u8 taskId)//Mailbox_ReturnToPlayerPC(u8 taskId) +/*static*/ void Mailbox_ReturnToPlayerPC(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -637,22 +512,22 @@ void sub_81D1EC0(void); ReshowPlayerPC(taskId); } -extern const struct MenuAction gUnknown_085DFF04[]; +extern const struct MenuAction gMailboxMailOptions[]; -void sub_816B82C(u8 taskId); +void Mailbox_MailOptionsProcessInput(u8 taskId); -void sub_816B7DC(u8 taskId) +void Mailbox_PrintMailOptions(u8 taskId) { u8 r4 = sub_81D1C84(2); - PrintMenuTable(r4, 4, gUnknown_085DFF04); + PrintMenuTable(r4, 4, gMailboxMailOptions); InitMenuInUpperLeftCornerPlaySoundWhenAPressed(r4, 4, 0); schedule_bg_copy_tilemap_to_vram(0); - gTasks[taskId].func = sub_816B82C; + gTasks[taskId].func = Mailbox_MailOptionsProcessInput; } -void sub_816BBD4(u8 taskId); +void Mailbox_Cancel(u8 taskId); -void sub_816B82C(u8 taskId) +void Mailbox_MailOptionsProcessInput(u8 taskId) { s8 inputOptionId = ProcessMenuInput_other(); @@ -662,41 +537,288 @@ void sub_816B82C(u8 taskId) break; case -1: PlaySE(SE_SELECT); - sub_816BBD4(taskId); + Mailbox_Cancel(taskId); break; default: PlaySE(SE_SELECT); - gUnknown_085DFF04[inputOptionId].func.void_u8(taskId); + gMailboxMailOptions[inputOptionId].func.void_u8(taskId); break; } } -void sub_816B8A4(u8 taskId); +void Mailbox_FadeAndReadMail(u8 taskId); -void sub_816B878(u8 taskId) +void Mailbox_DoMailRead(u8 taskId) { FadeScreen(1, 0); - gTasks[taskId].func = sub_816B8A4; + gTasks[taskId].func = Mailbox_FadeAndReadMail; } -void sub_816B900(); +void Mailbox_ReturnToFieldFromReadMail(); -void sub_816B8A4(u8 taskId) +void Mailbox_FadeAndReadMail(u8 taskId) { if(!gPaletteFade.active) { sub_81D1EC0(); overworld_free_bg_tilemaps(); - ReadMail(&(gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos]), sub_816B900, TRUE); + ReadMail(&(gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos]), Mailbox_ReturnToFieldFromReadMail, TRUE); DestroyTask(taskId); } } void pal_fill_for_maplights_or_black(); -void sub_816B900() +void Mailbox_ReturnToFieldFromReadMail() { gFieldCallback = pal_fill_for_maplights_or_black; SetMainCallback2(CB2_ReturnToField); } +void Mailbox_HandleReturnToProcessInput(u8 taskId); + +void pal_fill_for_maplights_or_black() +{ + u8 taskId; + + sub_81973A4(); + taskId = CreateTask(Mailbox_HandleReturnToProcessInput, 0); + if(sub_81D1C44(eMailboxInfo.count) == TRUE) + Mailbox_DrawMailboxMenu(taskId); + else + DestroyTask(taskId); + pal_fill_black(); +} + +void Mailbox_HandleReturnToProcessInput(u8 taskId) +{ + if(sub_80ABDFC() == TRUE) + gTasks[taskId].func = Mailbox_ProcessInput; +} + +extern const u8 gText_MessageWillBeLost[]; + +void Mailbox_DrawYesNoBeforeMove(u8 taskId); + +void Mailbox_MoveToBag(u8 taskId) +{ + DisplayItemMessageOnField(taskId, gText_MessageWillBeLost, Mailbox_DrawYesNoBeforeMove); +} + +void Mailbox_DoMailMoveToBag(u8 taskId); +void Mailbox_CancelMoveToBag(u8 taskId); +void Mailbox_MoveToBagYesNoPrompt(u8 taskId); + +void Mailbox_DrawYesNoBeforeMove(u8 taskId) +{ + sub_8197930(); + gTasks[taskId].func = Mailbox_MoveToBagYesNoPrompt; +} + +void Mailbox_MoveToBagYesNoPrompt(u8 taskId) +{ + switch(ProcessMenuInputNoWrap_()) + { + case 0: + Mailbox_DoMailMoveToBag(taskId); + break; + case -1: + PlaySE(SE_SELECT); + case 1: + Mailbox_CancelMoveToBag(taskId); + break; + case -2: + default: + break; + } +} + +extern const u8 gText_BagIsFull[]; +extern const u8 gText_MailToBagMessageErased[]; + +void Mailbox_DoMailMoveToBag(u8 taskId) +{ + struct MailStruct *mailStruct = &(gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos]); + if(!AddBagItem(mailStruct->itemId, 1)) + { + DisplayItemMessageOnField(taskId, gText_BagIsFull, Mailbox_Cancel); + } + else + { + DisplayItemMessageOnField(taskId, gText_MailToBagMessageErased, Mailbox_Cancel); + ClearMailStruct(mailStruct); + Mailbox_UpdateMailList(); + eMailboxInfo.count--; + if(eMailboxInfo.count < (eMailboxInfo.pageItems + eMailboxInfo.itemsAbove) && eMailboxInfo.itemsAbove != 0) + eMailboxInfo.itemsAbove--; + ItemStorage_SetItemAndMailCount(taskId); + } +} + +void Mailbox_CancelMoveToBag(u8 taskId) +{ + Mailbox_Cancel(taskId); +} + +void Mailbox_DoGiveMailPokeMenu(u8 taskId); +void Mailbox_NoPokemonForMail(u8 taskId); + +void Mailbox_Give(u8 taskId) +{ + if(CalculatePlayerPartyCount() == 0) + Mailbox_NoPokemonForMail(taskId); + else + { + FadeScreen(1, 0); + gTasks[taskId].func = Mailbox_DoGiveMailPokeMenu; + } +} + +void sub_81B8448(); + +void Mailbox_DoGiveMailPokeMenu(u8 taskId) +{ + if(!gPaletteFade.active) + { + sub_81D1EC0(); + overworld_free_bg_tilemaps(); + sub_81B8448(); + DestroyTask(taskId); + } +} + +void Mailbox_UpdateMailListAfterDeposit(void); + +void Mailbox_ReturnToMailListAfterDeposit(void) +{ + gFieldCallback = Mailbox_UpdateMailListAfterDeposit; + SetMainCallback2(CB2_ReturnToField); +} + +void Mailbox_UpdateMailListAfterDeposit(void) +{ + u8 taskId; + u8 prevCount; + taskId = CreateTask(Mailbox_HandleReturnToProcessInput, 0); + prevCount = eMailboxInfo.count; + eMailboxInfo.count = GetMailboxMailCount(); + Mailbox_UpdateMailList(); + if(prevCount != eMailboxInfo.count && (eMailboxInfo.count < (eMailboxInfo.pageItems + eMailboxInfo.itemsAbove)) + && eMailboxInfo.itemsAbove != 0) + eMailboxInfo.itemsAbove--; + ItemStorage_SetItemAndMailCount(taskId); + sub_81973A4(); + if(sub_81D1C44(eMailboxInfo.count) == TRUE) + Mailbox_DrawMailboxMenu(taskId); + else + DestroyTask(taskId); + pal_fill_black(); +} + +void Mailbox_NoPokemonForMail(u8 taskId) +{ + DisplayItemMessageOnField(taskId, gText_NoPokemon, Mailbox_Cancel); +} + +void Mailbox_Cancel(u8 taskId) +{ + sub_81D1D04(2); + sub_8197434(0, 0); + Mailbox_DrawMailboxMenu(taskId); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].func = Mailbox_ProcessInput; +} + +void sub_816BC14(void) +{ + gUnknown_0203BCC4 = AllocZeroed(sizeof(struct Struct203BCC4)); + memset(gUnknown_0203BCC4->unk660, 0xFF, 0x6); + gUnknown_0203BCC4->unk666 = 0xFF; + gUnknown_0203BCC4->unk667 = -1; +} + +void sub_816BCC4(u8); + +void sub_816BC58(void) +{ + u32 i; + + for(i = 0; i < 6; i++) + sub_816BCC4(i); + Free(gUnknown_0203BCC4); +} + +extern const struct WindowTemplate gUnknown_085DFF5C[6]; + +u8 sub_816BC7C(u8 a) +{ + u8 *windowIdLoc = &(gUnknown_0203BCC4->unk660[a]); + if(*windowIdLoc == 0xFF) + { + *windowIdLoc = AddWindow(&gUnknown_085DFF5C[a]); + SetWindowBorderStyle(*windowIdLoc, FALSE, 0x214, 0xE); + schedule_bg_copy_tilemap_to_vram(0); + } + return *windowIdLoc; +} + +void sub_816BCC4(u8 a) +{ + u8 *windowIdLoc = &(gUnknown_0203BCC4->unk660[a]); + if(*windowIdLoc != 0xFF) + { + sub_8198070(*windowIdLoc, FALSE); + ClearWindowTilemap(*windowIdLoc); + schedule_bg_copy_tilemap_to_vram(0); + RemoveWindow(*windowIdLoc); + *windowIdLoc = 0xFF; + } +} + +void sub_816BDC8(u8 *string, u16 itemId); + +extern struct ListMenuTemplate gUnknown_085DFF44; + +void sub_816BD04(void) +{ + u16 i; + + for(i = 0; i < eMailboxInfo.count - 1; i++) + { + sub_816BDC8(&(gUnknown_0203BCC4->unk198[i][0]), gSaveBlock1Ptr->pcItems[i].itemId); + gUnknown_0203BCC4->unk0[i].name = &(gUnknown_0203BCC4->unk198[i][0]); + gUnknown_0203BCC4->unk0[i].id = i; + } + StringCopy(&(gUnknown_0203BCC4->unk198[i][0]) ,gText_Cancel2); + gUnknown_0203BCC4->unk0[i].name = &(gUnknown_0203BCC4->unk198[i][0]); + gUnknown_0203BCC4->unk0[i].id = -2; + gMultiuseListMenuTemplate = gUnknown_085DFF44; + gMultiuseListMenuTemplate.unk_10 = sub_816BC7C(0); + gMultiuseListMenuTemplate.totalItems = eMailboxInfo.count; + gMultiuseListMenuTemplate.items = gUnknown_0203BCC4->unk0; + gMultiuseListMenuTemplate.maxShowed = eMailboxInfo.pageItems; +} + +void sub_816BDC8(u8 *string, u16 itemId) +{ + CopyItemName(itemId, string); +} + +void sub_816C0C8(); +void sub_816C060(u16 itemId); +void sub_816BEF0(s32 id); + +void sub_816BDDC(s32 id, bool8 b) +{ + if(b != TRUE) + PlaySE(SE_SELECT); + if(gUnknown_0203BCC4->unk666 == 0xFF) + { + sub_816C0C8(); + if(id != -2) + sub_816C060(gSaveBlock1Ptr->pcItems[id].itemId); + else + sub_816C060(0xFFFF); + sub_816BEF0(id); + } +} From 1f7fb45d0f84bc0a9b66b00b3918e1a16702bda2 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Thu, 15 Mar 2018 16:07:24 +0530 Subject: [PATCH 3/6] Decompile more functions --- asm/player_pc.s | 700 ----------------------------------------- include/menu_helpers.h | 3 +- include/player_pc.h | 7 +- src/player_pc.c | 375 +++++++++++++++++++--- src/pokeblock.c | 2 +- 5 files changed, 333 insertions(+), 754 deletions(-) diff --git a/asm/player_pc.s b/asm/player_pc.s index 47e56d5f2..8870e342d 100644 --- a/asm/player_pc.s +++ b/asm/player_pc.s @@ -5,706 +5,6 @@ .text - thumb_func_start fish4_goto_x5_or_x6 -fish4_goto_x5_or_x6: @ 816BE44 - push {r4-r6,lr} - sub sp, 0xC - 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 _0816BED4 - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - ldr r1, =0x00000666 - adds r0, r1 - ldrb r1, [r0] - cmp r1, 0xFF - beq _0816BE8E - lsls r0, r4, 24 - lsrs r0, 24 - cmp r1, r0 - bne _0816BE84 - adds r0, r5, 0 - movs r1, 0 - movs r2, 0xFF - bl sub_816BFE0 - b _0816BE8E - .pool -_0816BE84: - adds r0, r5, 0 - movs r1, 0xFF - movs r2, 0xFF - bl sub_816BFE0 -_0816BE8E: - ldr r0, =gStringVar1 - ldr r1, =gSaveBlock1Ptr - ldr r1, [r1] - lsls r2, r4, 2 - adds r1, r2 - ldr r2, =0x0000049a - adds r1, r2 - ldrh r1, [r1] - movs r2, 0x1 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_xVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x7 - adds r1, r4, 0 - movs r2, 0x68 - bl GetStringRightAlignXOffset - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - str r5, [sp] - movs r0, 0xFF - str r0, [sp, 0x4] - movs r0, 0 - str r0, [sp, 0x8] - adds r0, r6, 0 - movs r1, 0x7 - adds r2, r4, 0 - bl PrintTextOnWindow -_0816BED4: - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end fish4_goto_x5_or_x6 - - thumb_func_start sub_816BEF0 -sub_816BEF0: @ 816BEF0 - push {r4,r5,lr} - sub sp, 0xC - adds r1, r0, 0 - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - ldr r2, =0x00000661 - adds r0, r2 - ldrb r5, [r0] - movs r0, 0x2 - negs r0, r0 - cmp r1, r0 - beq _0816BF2C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - lsls r1, 2 - adds r0, r1 - movs r1, 0x93 - lsls r1, 3 - adds r0, r1 - ldrh r0, [r0] - bl ItemId_GetDescription - b _0816BF32 - .pool -_0816BF2C: - ldr r0, =0x0000ffff - bl sub_816C228 -_0816BF32: - adds r4, r0, 0 - adds r0, r5, 0 - movs r1, 0x11 - bl FillWindowPixelBuffer - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0 - bl PrintTextOnWindow - add sp, 0xC - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BEF0 - - thumb_func_start sub_816BF60 -sub_816BF60: @ 816BF60 - push {r4,lr} - sub sp, 0x10 - ldr r4, =gUnknown_0203BCB8 - ldrb r0, [r4, 0x9] - cmp r0, 0xFF - bne _0816BF8C - ldrb r0, [r4, 0x5] - ldrb r1, [r4, 0x4] - subs r0, r1 - str r0, [sp] - ldr r0, =0x000013f8 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - adds r0, r4, 0x2 - str r0, [sp, 0xC] - movs r0, 0x2 - movs r1, 0xB0 - movs r2, 0xC - movs r3, 0x94 - bl AddScrollIndicatorArrowPairParametrized - strb r0, [r4, 0x9] -_0816BF8C: - add sp, 0x10 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BF60 - - thumb_func_start sub_816BF9C -sub_816BF9C: @ 816BF9C - push {r4,lr} - ldr r4, =gUnknown_0203BCB8 - ldrb r0, [r4, 0x9] - cmp r0, 0xFF - beq _0816BFAE - bl RemoveScrollIndicatorArrowPair - movs r0, 0xFF - strb r0, [r4, 0x9] -_0816BFAE: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BF9C - - thumb_func_start sub_816BFB8 -sub_816BFB8: @ 816BFB8 - push {r4,r5,lr} - adds r4, r1, 0 - adds r5, r2, 0 - lsls r0, 24 - lsrs r0, 24 - lsls r4, 24 - lsrs r4, 24 - lsls r5, 24 - lsrs r5, 24 - bl ListMenuGetYCoordForPrintingArrowCursor - lsls r0, 24 - lsrs r0, 24 - adds r1, r4, 0 - adds r2, r5, 0 - bl sub_816BFE0 - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end sub_816BFB8 - - thumb_func_start sub_816BFE0 -sub_816BFE0: @ 816BFE0 - push {r4-r6,lr} - sub sp, 0x14 - lsls r0, 24 - lsrs r6, r0, 24 - lsls r1, 24 - lsrs r1, 24 - lsls r2, 24 - lsrs r2, 24 - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - movs r3, 0xCC - lsls r3, 3 - adds r0, r3 - ldrb r5, [r0] - cmp r1, 0xFF - bne _0816C030 - 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] - adds r0, r5, 0 - movs r1, 0x11 - movs r2, 0 - adds r3, r6, 0 - bl FillWindowPixelRect - b _0816C050 - .pool -_0816C030: - movs r0, 0 - str r0, [sp] - str r0, [sp, 0x4] - ldr r0, =gUnknown_085DFF8C - str r0, [sp, 0x8] - lsls r0, r2, 24 - asrs r0, 24 - str r0, [sp, 0xC] - ldr r0, =gText_SelectorArrow2 - str r0, [sp, 0x10] - adds r0, r5, 0 - movs r1, 0x1 - movs r2, 0 - adds r3, r6, 0 - bl AddTextPrinterParameterized2 -_0816C050: - add sp, 0x14 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816BFE0 - - thumb_func_start sub_816C060 -sub_816C060: @ 816C060 - push {r4-r6,lr} - lsls r0, 16 - lsrs r6, r0, 16 - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - ldr r1, =0x00000667 - adds r5, r0, r1 - ldrb r0, [r5] - cmp r0, 0xFF - bne _0816C0B2 - ldr r4, =0x000013f6 - 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 _0816C0B2 - strb r2, [r5] - ldr r0, =gSprites - lsls r1, r2, 4 - adds r1, r2 - lsls r1, 2 - adds r1, r0 - ldrb r2, [r1, 0x5] - movs r0, 0xD - negs r0, r0 - ands r0, r2 - strb r0, [r1, 0x5] - movs r0, 0x18 - strh r0, [r1, 0x24] - movs r0, 0x50 - strh r0, [r1, 0x26] -_0816C0B2: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C060 - - thumb_func_start sub_816C0C8 -sub_816C0C8: @ 816C0C8 - push {r4,r5,lr} - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - ldr r1, =0x00000667 - adds r5, r0, r1 - ldrb r0, [r5] - cmp r0, 0xFF - beq _0816C0FA - ldr r4, =0x000013f6 - 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 r1, =gSprites - adds r0, r1 - bl DestroySprite - movs r0, 0xFF - strb r0, [r5] -_0816C0FA: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C0C8 - - thumb_func_start sub_816C110 -sub_816C110: @ 816C110 - push {lr} - sub sp, 0x4 - bl sub_80D6E84 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x93 - lsls r1, 3 - adds r0, r1 - ldr r2, =gUnknown_0203BCBC - adds r3, r2, 0x1 - movs r1, 0x8 - str r1, [sp] - movs r1, 0x32 - bl sub_812220C - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C110 - - thumb_func_start sub_816C140 -sub_816C140: @ 816C140 - push {lr} - ldr r0, =gUnknown_0203BCBA - subs r1, r0, 0x2 - ldrb r2, [r1, 0x4] - ldrb r3, [r1, 0x5] - bl sub_812225C - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C140 - - thumb_func_start ItemStorage_ProcessInput -ItemStorage_ProcessInput: @ 816C158 - push {r4-r7,lr} - sub sp, 0xC - lsls r0, 24 - lsrs r6, r0, 24 - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r7, r0, r1 - movs r4, 0 -_0816C16C: - lsls r0, r4, 24 - lsrs r0, 24 - bl sub_816BC7C - adds r4, 0x1 - cmp r4, 0x3 - bls _0816C16C - movs r1, 0x6 - ldrsh r0, [r7, r1] - ldr r5, =gText_TossItem - cmp r0, 0 - bne _0816C186 - ldr r5, =gText_WithdrawItem -_0816C186: - movs r0, 0x1 - adds r1, r5, 0 - movs r2, 0x68 - bl GetStringCenterAlignXOffset - adds r3, r0, 0 - ldr r4, =gUnknown_0203BCC4 - ldr r0, [r4] - ldr r1, =0x00000663 - adds r0, r1 - ldrb r0, [r0] - lsls r3, 24 - lsrs r3, 24 - movs r1, 0x1 - str r1, [sp] - movs r1, 0 - str r1, [sp, 0x4] - str r1, [sp, 0x8] - movs r1, 0x1 - adds r2, r5, 0 - bl PrintTextOnWindow - ldr r0, [r4] - ldr r1, =0x00000662 - adds r0, r1 - ldrb r0, [r0] - movs r1, 0x2 - bl CopyWindowToVram - bl sub_816C110 - bl sub_816C140 - bl sub_816BD04 - ldr r0, =gMultiuseListMenuTemplate - ldr r2, =gUnknown_0203BCB8 - ldrh r1, [r2, 0x2] - ldrh r2, [r2] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r7, 0xA] - bl sub_816BF60 - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - lsls r0, r6, 2 - adds r0, r6 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816C30C - str r1, [r0] - add sp, 0xC - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end ItemStorage_ProcessInput - - thumb_func_start sub_816C228 -sub_816C228: @ 816C228 - push {lr} - lsls r0, 16 - lsrs r1, r0, 16 - ldr r2, =0xffff0009 - adds r0, r1, r2 - cmp r0, 0x8 - bhi _0816C2B4 - lsls r0, 2 - ldr r1, =_0816C248 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_0816C248: - .4byte _0816C2AC - .4byte _0816C2A4 - .4byte _0816C29C - .4byte _0816C294 - .4byte _0816C28C - .4byte _0816C284 - .4byte _0816C27C - .4byte _0816C274 - .4byte _0816C26C -_0816C26C: - ldr r0, =gText_GoBackPrevMenu - b _0816C2BA - .pool -_0816C274: - ldr r0, =gText_WithdrawHowManyItems - b _0816C2BA - .pool -_0816C27C: - ldr r0, =gText_WithdrawXItems - b _0816C2BA - .pool -_0816C284: - ldr r0, =gText_TossHowManyVar1s - b _0816C2BA - .pool -_0816C28C: - ldr r0, =gText_ThrewAwayVar2Var1s - b _0816C2BA - .pool -_0816C294: - ldr r0, =gText_NoRoomInBag - b _0816C2BA - .pool -_0816C29C: - ldr r0, =gText_TooImportantToToss - b _0816C2BA - .pool -_0816C2A4: - ldr r0, =gText_ConfirmTossItems - b _0816C2BA - .pool -_0816C2AC: - ldr r0, =gText_MoveVar1Where - b _0816C2BA - .pool -_0816C2B4: - adds r0, r1, 0 - bl ItemId_GetDescription -_0816C2BA: - pop {r1} - bx r1 - thumb_func_end sub_816C228 - - thumb_func_start sub_816C2C0 -sub_816C2C0: @ 816C2C0 - push {r4-r6,lr} - sub sp, 0xC - adds r6, r0, 0 - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - ldr r1, =0x00000661 - adds r0, r1 - ldrb r5, [r0] - adds r0, r5, 0 - movs r1, 0x11 - bl FillWindowPixelBuffer - ldr r4, =gStringVar4 - adds r0, r4, 0 - adds r1, r6, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - str r0, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - adds r0, r5, 0 - movs r1, 0x1 - adds r2, r4, 0 - movs r3, 0 - bl PrintTextOnWindow - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C2C0 - - thumb_func_start sub_816C30C -sub_816C30C: @ 816C30C - push {r4-r6,lr} - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r4, r0, r1 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0816C35C - ldrb r0, [r4, 0xA] - ldr r1, =gUnknown_0203BCBA - subs r4, r1, 0x2 - adds r2, r4, 0 - bl sub_81AE860 - ldrh r1, [r4, 0x2] - ldrh r0, [r4] - adds r1, r0 - ldrb r0, [r4, 0x5] - subs r0, 0x1 - cmp r1, r0 - beq _0816C39E - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_816C450 - b _0816C39E - .pool -_0816C35C: - ldrb r0, [r4, 0xA] - bl ListMenuHandleInputGetItemId - adds r6, r0, 0 - ldrb r0, [r4, 0xA] - ldr r1, =gUnknown_0203BCBA - subs r2, r1, 0x2 - bl sub_81AE860 - movs r0, 0x2 - negs r0, r0 - cmp r6, r0 - beq _0816C384 - adds r0, 0x1 - cmp r6, r0 - bne _0816C392 - b _0816C39E - .pool -_0816C384: - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_816C400 - b _0816C39E -_0816C392: - movs r0, 0x5 - bl PlaySE - adds r0, r5, 0 - bl sub_816C71C -_0816C39E: - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_816C30C - - thumb_func_start bx_battle_menu_t3 -bx_battle_menu_t3: @ 816C3A4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r4, r0, 24 - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r5, r0, r1 - bl IsDma3ManagerBusyWithBgCopy - lsls r0, 24 - cmp r0, 0 - bne _0816C3F2 - movs r0, 0 - movs r1, 0 - bl NewMenuHelpers_DrawDialogueFrame - movs r1, 0x6 - ldrsh r0, [r5, r1] - cmp r0, 0 - bne _0816C3DC - adds r0, r4, 0 - movs r1, 0 - bl InitItemStorageMenu - b _0816C3E4 - .pool -_0816C3DC: - adds r0, r4, 0 - movs r1, 0x2 - bl InitItemStorageMenu -_0816C3E4: - ldr r0, =gTasks - lsls r1, r4, 2 - adds r1, r4 - lsls r1, 3 - adds r1, r0 - ldr r0, =ItemStorageMenuProcessInput - str r0, [r1] -_0816C3F2: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end bx_battle_menu_t3 - - thumb_func_start sub_816C400 -sub_816C400: @ 816C400 - push {r4-r6,lr} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r6, =gTasks + 0x8 - adds r5, r4, r6 - bl sub_816C0C8 - bl sub_816BF9C - ldrb r0, [r5, 0xA] - movs r1, 0 - movs r2, 0 - bl sub_81AE6C8 - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - movs r1, 0xCD - lsls r1, 3 - adds r0, r1 - movs r1, 0x7 - bl sub_81223B0 - bl sub_816BC58 - subs r6, 0x8 - adds r4, r6 - ldr r0, =bx_battle_menu_t3 - str r0, [r4] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C400 thumb_func_start sub_816C450 sub_816C450: @ 816C450 diff --git a/include/menu_helpers.h b/include/menu_helpers.h index e744c293c..bbdd21327 100644 --- a/include/menu_helpers.h +++ b/include/menu_helpers.h @@ -24,7 +24,8 @@ void ResetVramOamAndBgCntRegs(void); void SetVBlankHBlankCallbacksToNull(void); void ResetAllBgsCoordinates(void); bool16 RunTextPrintersRetIsActive(u8 textPrinterId); -void sub_8122344(void *arg0, u8 arg1); +void sub_8122344(u8 *arg0, u8 arg1); +void sub_81223B0(u8 *arg0, u8 arg1); void LoadListMenuArrowsGfx(void); void sub_81223FC(u8 *a0, u8 count, u8 a2); void sub_8122448(u8 *a0, u8 count, u16 x, u16 y); diff --git a/include/player_pc.h b/include/player_pc.h index fcd58757e..9e8ae6ef4 100644 --- a/include/player_pc.h +++ b/include/player_pc.h @@ -64,14 +64,15 @@ enum ITEMPC_GO_BACK_TO_PREV }; -struct MailboxStruct +struct PlayerPCItemPageStruct { u16 cursorPos; u16 itemsAbove; u8 pageItems; u8 count; - u8 unk6[6]; - u8 unkC[4]; + u8 filler[3]; + u8 scrollIndicatorId; + u8 filler2[4]; }; // Exported type declarations diff --git a/src/player_pc.c b/src/player_pc.c index 538556efd..f9fb7f6da 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -1,5 +1,6 @@ #include "global.h" #include "constants/songs.h" +#include "bg.h" #include "decoration.h" #include "event_scripts.h" #include "field_fadetransition.h" @@ -7,6 +8,7 @@ #include "field_weather.h" #include "international_string_util.h" #include "item.h" +#include "item_icon.h" #include "item_menu.h" #include "constants/items.h" #include "list_menu.h" @@ -15,11 +17,13 @@ #include "malloc.h" #include "menu.h" #include "menu_helpers.h" +#include "menu_indicators.h" #include "overworld.h" #include "palette.h" #include "player_pc.h" #include "script.h" #include "sound.h" +#include "sprite.h" #include "string_util.h" #include "strings.h" #include "task.h" @@ -31,11 +35,10 @@ struct Struct203BCC4 //u8 filler[0x118]; u8 unk198[51][0x18]; //u8 filler2[0x348]; - u8 unk660[6]; + u8 windowIds[6]; u8 unk666; - s8 unk667; - u32 unk668; - u8 filler3[4]; + u8 spriteId; + u8 spriteIds[7]; }; @@ -45,9 +48,9 @@ static EWRAM_DATA u8 *gPcItemMenuOptionOrder = NULL; static EWRAM_DATA u8 gPcItemMenuOptionsNum = 0; -extern struct MailboxStruct gUnknown_0203BCB8; +extern struct PlayerPCItemPageStruct gUnknown_0203BCB8; -#define eMailboxInfo gUnknown_0203BCB8 +#define playerPCItemPageInfo gUnknown_0203BCB8 /*static*/ void InitPlayerPCMenu(u8 taskId); @@ -181,18 +184,18 @@ bool8 sub_81D1C44(u8); /*static*/ void PlayerPC_Mailbox(u8 taskId) { - eMailboxInfo.count = GetMailboxMailCount(); + playerPCItemPageInfo.count = GetMailboxMailCount(); - if (eMailboxInfo.count == 0) + if (playerPCItemPageInfo.count == 0) DisplayItemMessageOnField(taskId, gText_NoMailHere, ReshowPlayerPC); else { - eMailboxInfo.cursorPos = 0; - eMailboxInfo.itemsAbove = 0; - eMailboxInfo.unk6[3] = 0xFF; + playerPCItemPageInfo.cursorPos = 0; + playerPCItemPageInfo.itemsAbove = 0; + playerPCItemPageInfo.scrollIndicatorId = 0xFF; Mailbox_UpdateMailList(); ItemStorage_SetItemAndMailCount(taskId); - if(sub_81D1C44(eMailboxInfo.count) == TRUE) + if(sub_81D1C44(playerPCItemPageInfo.count) == TRUE) { sub_8197434(0, 0); Mailbox_DrawMailboxMenu(taskId); @@ -361,14 +364,14 @@ void gpu_pal_allocator_reset__manage_upper_four(void); data[3] = toss; sub_816B4DC(taskId); - eMailboxInfo.cursorPos = 0; - eMailboxInfo.itemsAbove = 0; - eMailboxInfo.unk6[3] = 0xFF; + playerPCItemPageInfo.cursorPos = 0; + playerPCItemPageInfo.itemsAbove = 0; + playerPCItemPageInfo.scrollIndicatorId = 0xFF; ItemStorage_SetItemAndMailCount(taskId); sub_816BC14(); gpu_pal_allocator_reset__manage_upper_four(); LoadListMenuArrowsGfx(); - sub_8122344(&(gUnknown_0203BCC4->unk668), 7); + sub_8122344(gUnknown_0203BCC4->spriteIds, 7); sub_8197434(0,0); gTasks[taskId].func = ItemStorage_ProcessInput; } @@ -384,10 +387,10 @@ void gpu_pal_allocator_reset__manage_upper_four(void); /*static*/ void ItemStorage_SetItemAndMailCount(u8 taskId) { - if (eMailboxInfo.count > 7) - eMailboxInfo.pageItems = 8; + if (playerPCItemPageInfo.count > 7) + playerPCItemPageInfo.pageItems = 8; else - eMailboxInfo.pageItems = eMailboxInfo.count + 1; + playerPCItemPageInfo.pageItems = playerPCItemPageInfo.count + 1; } /*static*/ void sub_816B4DC(u8 taskId) @@ -432,8 +435,8 @@ void gpu_pal_allocator_reset__manage_upper_four(void); extern const u8 gText_Mailbox[]; u8 sub_81D1C84(u8); -u8 sub_81D1DC0(struct MailboxStruct *); -void sub_81D1E90(struct MailboxStruct *); +u8 sub_81D1DC0(struct PlayerPCItemPageStruct *); +void sub_81D1E90(struct PlayerPCItemPageStruct *); /*static*/ void Mailbox_DrawMailboxMenu(u8 taskId) @@ -444,8 +447,8 @@ void sub_81D1E90(struct MailboxStruct *); sub_81D1C84(1); PrintTextOnWindow(windowId, 1, gText_Mailbox, GetStringCenterAlignXOffset(1, gText_Mailbox, 0x40), 1, 0, NULL); schedule_bg_copy_tilemap_to_vram(0); - gTasks[taskId].data[5] = sub_81D1DC0(&eMailboxInfo); - sub_81D1E90(&eMailboxInfo); + gTasks[taskId].data[5] = sub_81D1DC0(&playerPCItemPageInfo); + sub_81D1E90(&playerPCItemPageInfo); } @@ -462,7 +465,7 @@ void sub_81D1D04(u8); if(!gPaletteFade.active) { inputOptionId = ListMenuHandleInputGetItemId(data[5]); - sub_81AE860(data[5], &(eMailboxInfo.itemsAbove), &(eMailboxInfo.cursorPos)); + sub_81AE860(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); switch(inputOptionId) { @@ -470,16 +473,16 @@ void sub_81D1D04(u8); break; case -2: PlaySE(SE_SELECT); - RemoveScrollIndicatorArrowPair(eMailboxInfo.unk6[3]); + RemoveScrollIndicatorArrowPair(playerPCItemPageInfo.scrollIndicatorId); Mailbox_ReturnToPlayerPC(taskId); break; default: PlaySE(SE_SELECT); sub_81D1D04(0); sub_81D1D04(1); - sub_81AE6C8(data[5], &(eMailboxInfo.itemsAbove), &(eMailboxInfo.cursorPos)); + sub_81AE6C8(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); schedule_bg_copy_tilemap_to_vram(0); - RemoveScrollIndicatorArrowPair(eMailboxInfo.unk6[3]); + RemoveScrollIndicatorArrowPair(playerPCItemPageInfo.scrollIndicatorId); gTasks[taskId].func = Mailbox_PrintWhatToDoWithPlayerMailText; break; } @@ -492,7 +495,7 @@ extern const u8 gText_WhatToDoWithVar1sMail[]; /*static*/ void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId)//Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) { - StringCopy(gStringVar1, gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos].playerName); + StringCopy(gStringVar1, gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos].playerName); sub_81DB554(gStringVar1, 0); StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithVar1sMail); DisplayItemMessageOnField(taskId, gStringVar4, Mailbox_PrintMailOptions); @@ -562,7 +565,7 @@ void Mailbox_FadeAndReadMail(u8 taskId) { sub_81D1EC0(); overworld_free_bg_tilemaps(); - ReadMail(&(gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos]), Mailbox_ReturnToFieldFromReadMail, TRUE); + ReadMail(&(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]), Mailbox_ReturnToFieldFromReadMail, TRUE); DestroyTask(taskId); } } @@ -583,7 +586,7 @@ void pal_fill_for_maplights_or_black() sub_81973A4(); taskId = CreateTask(Mailbox_HandleReturnToProcessInput, 0); - if(sub_81D1C44(eMailboxInfo.count) == TRUE) + if(sub_81D1C44(playerPCItemPageInfo.count) == TRUE) Mailbox_DrawMailboxMenu(taskId); else DestroyTask(taskId); @@ -638,7 +641,7 @@ extern const u8 gText_MailToBagMessageErased[]; void Mailbox_DoMailMoveToBag(u8 taskId) { - struct MailStruct *mailStruct = &(gSaveBlock1Ptr->mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos]); + struct MailStruct *mailStruct = &(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]); if(!AddBagItem(mailStruct->itemId, 1)) { DisplayItemMessageOnField(taskId, gText_BagIsFull, Mailbox_Cancel); @@ -648,9 +651,9 @@ void Mailbox_DoMailMoveToBag(u8 taskId) DisplayItemMessageOnField(taskId, gText_MailToBagMessageErased, Mailbox_Cancel); ClearMailStruct(mailStruct); Mailbox_UpdateMailList(); - eMailboxInfo.count--; - if(eMailboxInfo.count < (eMailboxInfo.pageItems + eMailboxInfo.itemsAbove) && eMailboxInfo.itemsAbove != 0) - eMailboxInfo.itemsAbove--; + playerPCItemPageInfo.count--; + if(playerPCItemPageInfo.count < (playerPCItemPageInfo.pageItems + playerPCItemPageInfo.itemsAbove) && playerPCItemPageInfo.itemsAbove != 0) + playerPCItemPageInfo.itemsAbove--; ItemStorage_SetItemAndMailCount(taskId); } } @@ -700,15 +703,15 @@ void Mailbox_UpdateMailListAfterDeposit(void) u8 taskId; u8 prevCount; taskId = CreateTask(Mailbox_HandleReturnToProcessInput, 0); - prevCount = eMailboxInfo.count; - eMailboxInfo.count = GetMailboxMailCount(); + prevCount = playerPCItemPageInfo.count; + playerPCItemPageInfo.count = GetMailboxMailCount(); Mailbox_UpdateMailList(); - if(prevCount != eMailboxInfo.count && (eMailboxInfo.count < (eMailboxInfo.pageItems + eMailboxInfo.itemsAbove)) - && eMailboxInfo.itemsAbove != 0) - eMailboxInfo.itemsAbove--; + if(prevCount != playerPCItemPageInfo.count && (playerPCItemPageInfo.count < (playerPCItemPageInfo.pageItems + playerPCItemPageInfo.itemsAbove)) + && playerPCItemPageInfo.itemsAbove != 0) + playerPCItemPageInfo.itemsAbove--; ItemStorage_SetItemAndMailCount(taskId); sub_81973A4(); - if(sub_81D1C44(eMailboxInfo.count) == TRUE) + if(sub_81D1C44(playerPCItemPageInfo.count) == TRUE) Mailbox_DrawMailboxMenu(taskId); else DestroyTask(taskId); @@ -732,9 +735,9 @@ void Mailbox_Cancel(u8 taskId) void sub_816BC14(void) { gUnknown_0203BCC4 = AllocZeroed(sizeof(struct Struct203BCC4)); - memset(gUnknown_0203BCC4->unk660, 0xFF, 0x6); + memset(gUnknown_0203BCC4->windowIds, 0xFF, 0x6); gUnknown_0203BCC4->unk666 = 0xFF; - gUnknown_0203BCC4->unk667 = -1; + gUnknown_0203BCC4->spriteId = 0xFF; } void sub_816BCC4(u8); @@ -752,7 +755,7 @@ extern const struct WindowTemplate gUnknown_085DFF5C[6]; u8 sub_816BC7C(u8 a) { - u8 *windowIdLoc = &(gUnknown_0203BCC4->unk660[a]); + u8 *windowIdLoc = &(gUnknown_0203BCC4->windowIds[a]); if(*windowIdLoc == 0xFF) { *windowIdLoc = AddWindow(&gUnknown_085DFF5C[a]); @@ -764,7 +767,7 @@ u8 sub_816BC7C(u8 a) void sub_816BCC4(u8 a) { - u8 *windowIdLoc = &(gUnknown_0203BCC4->unk660[a]); + u8 *windowIdLoc = &(gUnknown_0203BCC4->windowIds[a]); if(*windowIdLoc != 0xFF) { sub_8198070(*windowIdLoc, FALSE); @@ -783,7 +786,7 @@ void sub_816BD04(void) { u16 i; - for(i = 0; i < eMailboxInfo.count - 1; i++) + for(i = 0; i < playerPCItemPageInfo.count - 1; i++) { sub_816BDC8(&(gUnknown_0203BCC4->unk198[i][0]), gSaveBlock1Ptr->pcItems[i].itemId); gUnknown_0203BCC4->unk0[i].name = &(gUnknown_0203BCC4->unk198[i][0]); @@ -794,9 +797,9 @@ void sub_816BD04(void) gUnknown_0203BCC4->unk0[i].id = -2; gMultiuseListMenuTemplate = gUnknown_085DFF44; gMultiuseListMenuTemplate.unk_10 = sub_816BC7C(0); - gMultiuseListMenuTemplate.totalItems = eMailboxInfo.count; + gMultiuseListMenuTemplate.totalItems = playerPCItemPageInfo.count; gMultiuseListMenuTemplate.items = gUnknown_0203BCC4->unk0; - gMultiuseListMenuTemplate.maxShowed = eMailboxInfo.pageItems; + gMultiuseListMenuTemplate.maxShowed = playerPCItemPageInfo.pageItems; } void sub_816BDC8(u8 *string, u16 itemId) @@ -804,7 +807,7 @@ void sub_816BDC8(u8 *string, u16 itemId) CopyItemName(itemId, string); } -void sub_816C0C8(); +void sub_816C0C8(void); void sub_816C060(u16 itemId); void sub_816BEF0(s32 id); @@ -818,7 +821,281 @@ void sub_816BDDC(s32 id, bool8 b) if(id != -2) sub_816C060(gSaveBlock1Ptr->pcItems[id].itemId); else - sub_816C060(0xFFFF); + sub_816C060(ITEMPC_GO_BACK_TO_PREV); sub_816BEF0(id); } } + +void sub_816BFE0(u8 y, u8, u8 speed); + +void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset) +{ + if(id != -2) + { + if(gUnknown_0203BCC4->unk666 != 0xFF) + { + if(gUnknown_0203BCC4->unk666 == (u8)id) + sub_816BFE0(yOffset, 0, 0xFF); + else + sub_816BFE0(yOffset, 0xFF, 0xFF); + } + ConvertIntToDecimalStringN(gStringVar1, gSaveBlock1Ptr->pcItems[id].quantity, STR_CONV_MODE_RIGHT_ALIGN, 3); + StringExpandPlaceholders(gStringVar4, gText_xVar1); + PrintTextOnWindow(windowId, 7, gStringVar4, GetStringRightAlignXOffset(7, gStringVar4, 104), yOffset, 0xFF, NULL); + } +} + +const u8* sub_816C228(u16); + +void sub_816BEF0(s32 id) +{ + const u8* description; + u8 windowId = gUnknown_0203BCC4->windowIds[1]; + + if(id != -2) + description = (u8 *)ItemId_GetDescription(gSaveBlock1Ptr->pcItems[id].itemId); + else + description = sub_816C228(0xFFFF); + FillWindowPixelBuffer(windowId, 17); + PrintTextOnWindow(windowId, 1, description, 0, 1, 0, NULL); +} + +void sub_816BF60(void) +{ + if(playerPCItemPageInfo.scrollIndicatorId == 0xFF) + playerPCItemPageInfo.scrollIndicatorId = AddScrollIndicatorArrowPairParametrized(0x2, 0xB0, 0xC, 0x94, playerPCItemPageInfo.count - playerPCItemPageInfo.pageItems, 0x13F8, 0x13F8, &(playerPCItemPageInfo.itemsAbove)); +} + +void sub_816BF9C(void) +{ + if(playerPCItemPageInfo.scrollIndicatorId != 0xFF) + { + RemoveScrollIndicatorArrowPair(playerPCItemPageInfo.scrollIndicatorId); + playerPCItemPageInfo.scrollIndicatorId = 0xFF; + } +} + +void sub_816BFB8(u8 a, u8 b, u8 speed) +{ + sub_816BFE0(ListMenuGetYCoordForPrintingArrowCursor(a), b, speed); +} + +extern const u8 gUnknown_085DFF8C[3]; + +void sub_816BFE0(u8 y, u8 b, u8 speed) +{ + u8 windowId = gUnknown_0203BCC4->windowIds[0]; + if(b == 0xFF) + FillWindowPixelRect(windowId, 17, 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); + else + AddTextPrinterParameterized2(windowId, 1, 0, y, 0, 0, gUnknown_085DFF8C, speed, gText_SelectorArrow2); +} + + +void sub_816C060(u16 itemId) +{ + u8 spriteId; + u8* spriteIdLoc = &(gUnknown_0203BCC4->spriteId); + + if(*spriteIdLoc == 0xFF) + { + FreeSpriteTilesByTag(0x13F6); + FreeSpritePaletteByTag(0x13F6); + spriteId = AddItemIconSprite(0x13F6, 0x13F6, itemId); + if(spriteId != 64) + { + *spriteIdLoc = spriteId; + gSprites[spriteId].oam.priority = 0; + gSprites[spriteId].pos2.x = 24; + gSprites[spriteId].pos2.y = 80; + } + } +} + +void sub_816C0C8(void) +{ + u8* spriteIdLoc = &(gUnknown_0203BCC4->spriteId); + if(*spriteIdLoc != 0xFF) + { + FreeSpriteTilesByTag(0x13F6); + FreeSpritePaletteByTag(0x13F6); + DestroySprite(&(gSprites[*spriteIdLoc])); + *spriteIdLoc = 0xFF; + } +} + +void sub_80D6E84(void); +void sub_812220C(struct ItemSlot *, u8, u8 *, u8 *, u8); + +void sub_816C110(void) +{ + sub_80D6E84(); + sub_812220C(gSaveBlock1Ptr->pcItems, 50, &(playerPCItemPageInfo.pageItems), &(playerPCItemPageInfo.count), 0x8); +} + +void sub_812225C(u16 *, u16 *, u8, u8); + +void sub_816C140(void) +{ + sub_812225C(&(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos), playerPCItemPageInfo.pageItems, playerPCItemPageInfo.count); +} + +extern const u8 gText_TossItem[]; +extern const u8 gText_WithdrawItem[]; + +void sub_816C30C(u8 taskId); + +void ItemStorage_ProcessInput(u8 taskId) +{ + s16 *data; + bool32 toss; + u32 i, x; + u8 windowId; + const u8* text; + + data = gTasks[taskId].data; + for(i = 0; i <=3; i++) + sub_816BC7C(i); + toss = data[3]; + text = gText_TossItem; + if(!toss) + text = gText_WithdrawItem; + x = GetStringCenterAlignXOffset(1, text, 104); + PrintTextOnWindow(gUnknown_0203BCC4->windowIds[3], 1, text, x, 1, 0, NULL); + CopyWindowToVram(gUnknown_0203BCC4->windowIds[2], 2); + sub_816C110(); + sub_816C140(); + sub_816BD04(); + data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos); + sub_816BF60(); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].func = sub_816C30C; +} + +extern const u8 gText_GoBackPrevMenu[]; +extern const u8 gText_WithdrawHowManyItems[]; +extern const u8 gText_WithdrawXItems[]; +extern const u8 gText_TossHowManyVar1s[]; +extern const u8 gText_ThrewAwayVar2Var1s[]; +extern const u8 gText_NoRoomInBag[]; +extern const u8 gText_TooImportantToToss[]; +extern const u8 gText_ConfirmTossItems[]; +extern const u8 gText_MoveVar1Where[]; + +const u8* sub_816C228(u16 itemId) +{ + const u8 *string; + + switch(itemId) + { + case ITEMPC_GO_BACK_TO_PREV: + string = gText_GoBackPrevMenu; + break; + case ITEMPC_HOW_MANY_TO_WITHDRAW: + string = gText_WithdrawHowManyItems; + break; + case ITEMPC_WITHDREW_THING: + string = gText_WithdrawXItems; + break; + case ITEMPC_HOW_MANY_TO_TOSS: + string = gText_TossHowManyVar1s; + break; + case ITEMPC_THREW_AWAY_ITEM: + string = gText_ThrewAwayVar2Var1s; + break; + case ITEMPC_NO_MORE_ROOM: + string = gText_NoRoomInBag; + break; + case ITEMPC_TOO_IMPORTANT: + string = gText_TooImportantToToss; + break; + case ITEMPC_OKAY_TO_THROW_AWAY: + string = gText_ConfirmTossItems; + break; + case ITEMPC_SWITCH_WHICH_ITEM: + string = gText_MoveVar1Where; + break; + default: + string = ItemId_GetDescription(itemId); + break; + } + return string; +} + +void sub_816C2C0(const u8 *string) +{ + u8 windowId = gUnknown_0203BCC4->windowIds[1]; + FillWindowPixelBuffer(windowId, 0x11); + StringExpandPlaceholders(gStringVar4, string); + PrintTextOnWindow(windowId, 1, gStringVar4, 0, 1, 0, NULL); +} + +void sub_816C400(u8 taskId); +void sub_816C450(u8 taskId); +void sub_816C71C(u8 taskId); + +void sub_816C30C(u8 taskId) +{ + s16 *data; + s32 id; + + data = gTasks[taskId].data; + if(gMain.newKeys & SELECT_BUTTON) + { + sub_81AE860(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); + if((playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos) != (playerPCItemPageInfo.count - 1)) + { + PlaySE(SE_SELECT); + sub_816C450(taskId); + } + } + else + { + id = ListMenuHandleInputGetItemId(data[5]); + sub_81AE860(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); + switch(id) + { + case -1: + break; + case -2: + PlaySE(SE_SELECT); + sub_816C400(taskId); + break; + default: + PlaySE(SE_SELECT); + sub_816C71C(taskId); + break; + } + } +} + +void bx_battle_menu_t3(u8 taskId) +{ + s16 *data; + + data = gTasks[taskId].data; + if(!IsDma3ManagerBusyWithBgCopy()) + { + NewMenuHelpers_DrawDialogueFrame(0, 0); + if(!data[3]) + InitItemStorageMenu(taskId, 0); + else + InitItemStorageMenu(taskId, 2); + gTasks[taskId].func = ItemStorageMenuProcessInput; + } +} + + +void sub_816C400(u8 taskId) +{ + s16 *data; + + data = gTasks[taskId].data; + sub_816C0C8(); + sub_816BF9C(); + sub_81AE6C8(data[5], NULL, NULL); + sub_81223B0(gUnknown_0203BCC4->spriteIds, 7); + sub_816BC58(); + gTasks[taskId].func = bx_battle_menu_t3; +} + diff --git a/src/pokeblock.c b/src/pokeblock.c index b9a1f6bf3..941a1b601 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -460,7 +460,7 @@ static bool8 InitPokeblockMenu(void) gMain.state++; break; case 10: - sub_8122344(&sPokeblockMenu->field_E75, FIELD_E75_COUNT); + sub_8122344(sPokeblockMenu->field_E75, FIELD_E75_COUNT); gMain.state++; break; case 11: From a454bd98faf6bd7317a841c27f4bee9966c45da3 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Fri, 16 Mar 2018 16:01:11 +0530 Subject: [PATCH 4/6] Finish .text part of player_pc --- asm/player_pc.s | 839 ------------------------------------------------ ld_script.txt | 1 - src/player_pc.c | 272 ++++++++++++++++ 3 files changed, 272 insertions(+), 840 deletions(-) delete mode 100644 asm/player_pc.s diff --git a/asm/player_pc.s b/asm/player_pc.s deleted file mode 100644 index 8870e342d..000000000 --- a/asm/player_pc.s +++ /dev/null @@ -1,839 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - - thumb_func_start sub_816C450 -sub_816C450: @ 816C450 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - lsls r0, 24 - lsrs r0, 24 - lsls r4, r0, 2 - adds r4, r0 - lsls r4, 3 - ldr r0, =gTasks + 0x8 - mov r8, r0 - adds r1, r4, 0 - add r1, r8 - mov r9, r1 - ldrb r0, [r1, 0xA] - movs r1, 0x10 - movs r2, 0x1 - bl sub_81AF15C - ldr r6, =gUnknown_0203BCC4 - ldr r2, [r6] - ldr r1, =gUnknown_0203BCB8 - ldrb r0, [r1] - ldrb r1, [r1, 0x2] - adds r0, r1 - ldr r5, =0x00000666 - adds r2, r5 - strb r0, [r2] - mov r1, r9 - ldrb r0, [r1, 0xA] - movs r1, 0 - movs r2, 0 - bl sub_816BFB8 - ldr r0, [r6] - adds r0, r5 - ldrb r0, [r0] - bl sub_816C690 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - ldr r0, [r6] - adds r0, r5 - ldrb r0, [r0] - lsls r0, 2 - adds r1, r0 - movs r0, 0x93 - lsls r0, 3 - adds r1, r0 - ldrh r0, [r1] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r0, =0x0000fff7 - bl sub_816C228 - bl sub_816C2C0 - movs r1, 0x8 - negs r1, r1 - add r8, r1 - add r4, r8 - ldr r0, =sub_816C4FC - str r0, [r4] - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C450 - - thumb_func_start sub_816C4FC -sub_816C4FC: @ 816C4FC - 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 r7, =gMain - ldrh r1, [r7, 0x2E] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _0816C530 - ldrb r0, [r4, 0xA] - ldr r1, =gUnknown_0203BCBA - subs r2, r1, 0x2 - bl sub_81AE860 - b _0816C57E - .pool -_0816C530: - ldrb r0, [r4, 0xA] - bl ListMenuHandleInputGetItemId - adds r6, r0, 0 - ldrb r0, [r4, 0xA] - ldr r1, =gUnknown_0203BCBA - subs r4, r1, 0x2 - adds r2, r4, 0 - bl sub_81AE860 - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - movs r1, 0xCD - lsls r1, 3 - adds r0, r1 - movs r1, 0x7 - movs r2, 0 - bl sub_81223FC - ldrb r0, [r4] - bl sub_816C690 - movs r0, 0x2 - negs r0, r0 - cmp r6, r0 - beq _0816C574 - adds r0, 0x1 - cmp r6, r0 - bne _0816C592 - b _0816C59A - .pool -_0816C574: - ldrh r1, [r7, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0816C588 -_0816C57E: - adds r0, r5, 0 - movs r1, 0 - bl sub_816C5A0 - b _0816C59A -_0816C588: - adds r0, r5, 0 - movs r1, 0x1 - bl sub_816C5A0 - b _0816C59A -_0816C592: - adds r0, r5, 0 - movs r1, 0 - bl sub_816C5A0 -_0816C59A: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_816C4FC - - thumb_func_start sub_816C5A0 -sub_816C5A0: @ 816C5A0 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r5, r1, 0 - lsls r0, 24 - lsrs r7, r0, 24 - lsls r5, 24 - lsrs r5, 24 - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r0, r1 - mov r8, r0 - ldr r4, =gUnknown_0203BCB8 - ldrh r0, [r4] - ldrh r1, [r4, 0x2] - adds r0, r1 - lsls r0, 16 - lsrs r6, r0, 16 - movs r0, 0x5 - bl PlaySE - mov r2, r8 - ldrb r0, [r2, 0xA] - adds r1, r4, 0x2 - adds r2, r4, 0 - bl sub_81AE6C8 - cmp r5, 0 - bne _0816C60A - ldr r1, =gUnknown_0203BCC4 - ldr r0, [r1] - ldr r2, =0x00000666 - adds r0, r2 - ldrb r2, [r0] - adds r4, r1, 0 - cmp r2, r6 - beq _0816C622 - subs r0, r6, 0x1 - cmp r2, r0 - beq _0816C60A - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - movs r1, 0x93 - lsls r1, 3 - adds r0, r1 - adds r1, r2, 0 - adds r2, r6, 0 - bl sub_80D702C - bl sub_816BD04 -_0816C60A: - ldr r0, =gUnknown_0203BCC4 - ldr r1, [r0] - ldr r2, =0x00000666 - adds r1, r2 - ldrb r1, [r1] - adds r4, r0, 0 - cmp r1, r6 - bcs _0816C622 - ldr r1, =gUnknown_0203BCB8 - ldrh r0, [r1] - subs r0, 0x1 - strh r0, [r1] -_0816C622: - ldr r0, [r4] - movs r1, 0xCD - lsls r1, 3 - adds r0, r1 - movs r1, 0x7 - movs r2, 0x1 - bl sub_81223FC - ldr r0, [r4] - ldr r2, =0x00000666 - adds r0, r2 - movs r1, 0xFF - strb r1, [r0] - ldr r0, =gMultiuseListMenuTemplate - ldr r2, =gUnknown_0203BCB8 - ldrh r1, [r2, 0x2] - ldrh r2, [r2] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - mov r1, r8 - strh r0, [r1, 0xA] - movs r0, 0 - bl schedule_bg_copy_tilemap_to_vram - ldr r1, =gTasks - lsls r0, r7, 2 - adds r0, r7 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816C30C - str r1, [r0] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C5A0 - - thumb_func_start sub_816C690 -sub_816C690: @ 816C690 - push {lr} - adds r3, r0, 0 - lsls r3, 24 - ldr r0, =gUnknown_0203BCC4 - ldr r0, [r0] - movs r1, 0xCD - lsls r1, 3 - adds r0, r1 - lsrs r3, 4 - movs r1, 0x80 - lsls r1, 13 - adds r3, r1 - lsrs r3, 16 - movs r1, 0x7 - movs r2, 0x80 - bl sub_8122448 - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C690 - - thumb_func_start sub_816C6BC -sub_816C6BC: @ 816C6BC - push {r4-r6,lr} - sub sp, 0xC - adds r6, r0, 0 - ldr r5, [sp, 0x1C] - ldr r3, [sp, 0x20] - lsls r6, 24 - lsrs r6, 24 - lsls r1, 16 - lsrs r1, 16 - lsls r5, 24 - lsrs r5, 24 - lsls r3, 24 - lsrs r3, 24 - ldr r0, =gStringVar1 - bl ConvertIntToDecimalStringN - ldr r4, =gStringVar4 - ldr r1, =gText_xVar1 - adds r0, r4, 0 - bl StringExpandPlaceholders - movs r0, 0x1 - adds r1, r4, 0 - movs r2, 0x30 - bl GetStringCenterAlignXOffset - adds r3, r0, 0 - lsls r3, 24 - lsrs r3, 24 - str r5, [sp] - movs r0, 0 - str r0, [sp, 0x4] - str r0, [sp, 0x8] - adds r0, r6, 0 - movs r1, 0x1 - adds r2, r4, 0 - bl PrintTextOnWindow - add sp, 0xC - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C6BC - - thumb_func_start sub_816C71C -sub_816C71C: @ 816C71C - push {r4-r6,lr} - sub sp, 0x8 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - ldr r1, =gUnknown_0203BCB8 - ldrh r0, [r1, 0x2] - ldrh r1, [r1] - adds r0, r1 - lsls r0, 16 - lsrs r4, r0, 16 - bl sub_816BF9C - movs r0, 0x1 - strh r0, [r6, 0x4] - movs r1, 0x6 - ldrsh r0, [r6, r1] - cmp r0, 0 - bne _0816C798 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - lsls r0, r4, 2 - adds r1, r0 - ldr r2, =0x0000049a - adds r0, r1, r2 - ldrh r0, [r0] - cmp r0, 0x1 - bne _0816C774 - adds r0, r5, 0 - bl sub_816C8FC - b _0816C7FE - .pool -_0816C774: - movs r2, 0x93 - lsls r2, 3 - adds r0, r1, r2 - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r0, =0x0000fffe - bl sub_816C228 - bl sub_816C2C0 - b _0816C7D4 - .pool -_0816C798: - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - lsls r0, r4, 2 - adds r1, r0 - ldr r2, =0x0000049a - adds r0, r1, r2 - ldrh r0, [r0] - cmp r0, 0x1 - bne _0816C7BC - adds r0, r5, 0 - bl sub_816C9B8 - b _0816C7FE - .pool -_0816C7BC: - movs r2, 0x93 - lsls r2, 3 - adds r0, r1, r2 - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r0, =0x0000fffc - bl sub_816C228 - bl sub_816C2C0 -_0816C7D4: - movs r0, 0x4 - bl sub_816BC7C - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r6, 0x4] - movs r2, 0x1 - str r2, [sp] - movs r2, 0x3 - str r2, [sp, 0x4] - movs r2, 0x2 - movs r3, 0x8 - bl sub_816C6BC - ldr r1, =gTasks - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816C818 - str r1, [r0] -_0816C7FE: - add sp, 0x8 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C71C - - thumb_func_start sub_816C818 -sub_816C818: @ 816C818 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x8 - lsls r0, 24 - lsrs r5, r0, 24 - mov r9, r5 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - ldr r1, =gTasks + 0x8 - adds r6, r0, r1 - ldr r0, =gUnknown_0203BCB8 - ldrh r2, [r0, 0x2] - ldrh r0, [r0] - adds r2, r0 - lsls r2, 16 - adds r0, r6, 0x4 - ldr r1, =gSaveBlock1Ptr - mov r8, r1 - ldr r1, [r1] - lsrs r7, r2, 14 - adds r1, r7 - ldr r2, =0x0000049a - adds r1, r2 - ldrh r1, [r1] - bl AdjustQuantityAccordingToDPadInput - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0x1 - bne _0816C888 - movs r0, 0x4 - bl sub_816BC7C - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r6, 0x4] - str r4, [sp] - movs r2, 0x3 - str r2, [sp, 0x4] - movs r2, 0x2 - movs r3, 0x8 - bl sub_816C6BC - b _0816C8EC - .pool -_0816C888: - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0816C8BC - movs r0, 0x5 - bl PlaySE - movs r0, 0x4 - bl sub_816BCC4 - movs r3, 0x6 - ldrsh r0, [r6, r3] - cmp r0, 0 - bne _0816C8B4 - adds r0, r5, 0 - bl sub_816C8FC - b _0816C8EC - .pool -_0816C8B4: - adds r0, r5, 0 - bl sub_816C9B8 - b _0816C8EC -_0816C8BC: - movs r0, 0x2 - ands r0, r1 - cmp r0, 0 - beq _0816C8EC - movs r0, 0x5 - bl PlaySE - movs r0, 0x4 - bl sub_816BCC4 - mov r1, r8 - ldr r0, [r1] - adds r0, r7 - movs r2, 0x93 - lsls r2, 3 - adds r0, r2 - ldrh r0, [r0] - bl sub_816C228 - bl sub_816C2C0 - mov r0, r9 - bl sub_816CBC0 -_0816C8EC: - add sp, 0x8 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_816C818 - - thumb_func_start sub_816C8FC -sub_816C8FC: @ 816C8FC - push {r4-r7,lr} - mov r7, r8 - push {r7} - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 2 - adds r1, r0 - lsls r6, r1, 3 - ldr r0, =gTasks + 0x8 - mov r8, r0 - adds r4, r6, r0 - ldr r0, =gUnknown_0203BCB8 - ldrh r1, [r0, 0x2] - ldrh r0, [r0] - adds r1, r0 - lsls r1, 16 - ldr r7, =gSaveBlock1Ptr - ldr r0, [r7] - lsrs r5, r1, 14 - adds r0, r5 - movs r1, 0x93 - lsls r1, 3 - adds r0, r1 - ldrh r0, [r0] - ldrh r1, [r4, 0x4] - bl AddBagItem - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _0816C98C - ldr r0, [r7] - adds r0, r5 - movs r2, 0x93 - lsls r2, 3 - adds r0, r2 - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r0, =gStringVar2 - movs r2, 0x4 - ldrsh r1, [r4, r2] - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r0, =0x0000fffd - bl sub_816C228 - bl sub_816C2C0 - mov r0, r8 - subs r0, 0x8 - adds r0, r6, r0 - ldr r1, =sub_816CB04 - b _0816C9A2 - .pool -_0816C98C: - movs r0, 0 - strh r0, [r4, 0x4] - ldr r0, =0x0000fffa - bl sub_816C228 - bl sub_816C2C0 - mov r0, r8 - subs r0, 0x8 - adds r0, r6, r0 - ldr r1, =sub_816CB74 -_0816C9A2: - str r1, [r0] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C8FC - - thumb_func_start sub_816C9B8 -sub_816C9B8: @ 816C9B8 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0x10 - lsls r0, 24 - lsrs r5, r0, 24 - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 3 - mov r8, r0 - ldr r0, =gTasks + 0x8 - mov r9, r0 - mov r7, r8 - add r7, r9 - ldr r0, =gUnknown_0203BCB8 - ldrh r1, [r0, 0x2] - ldrh r0, [r0] - adds r1, r0 - lsls r1, 16 - ldr r6, =gSaveBlock1Ptr - ldr r0, [r6] - lsrs r4, r1, 14 - adds r0, r4 - movs r1, 0x93 - lsls r1, 3 - adds r0, r1 - ldrh r0, [r0] - bl itemid_is_unique - lsls r0, 24 - cmp r0, 0 - bne _0816CA64 - ldr r0, [r6] - adds r0, r4 - movs r2, 0x93 - lsls r2, 3 - adds r0, r2 - ldrh r0, [r0] - ldr r1, =gStringVar1 - bl CopyItemName - ldr r0, =gStringVar2 - movs r2, 0x4 - ldrsh r1, [r7, r2] - movs r2, 0 - movs r3, 0x3 - bl ConvertIntToDecimalStringN - ldr r0, =0x0000fff8 - bl sub_816C228 - bl sub_816C2C0 - ldr r1, =gUnknown_085DFF84 - movs r0, 0x1 - str r0, [sp] - movs r0, 0x85 - lsls r0, 2 - str r0, [sp, 0x4] - movs r0, 0xE - str r0, [sp, 0x8] - ldr r0, =gUnknown_085DFF3C - str r0, [sp, 0xC] - adds r0, r5, 0 - movs r2, 0x1 - movs r3, 0 - bl CreateYesNoMenuWithCallbacks - b _0816CA7C - .pool -_0816CA64: - movs r0, 0 - strh r0, [r7, 0x4] - ldr r0, =0x0000fff9 - bl sub_816C228 - bl sub_816C2C0 - mov r0, r9 - subs r0, 0x8 - add r0, r8 - ldr r1, =sub_816CB74 - str r1, [r0] -_0816CA7C: - add sp, 0x10 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816C9B8 - - thumb_func_start sub_816CA94 -sub_816CA94: @ 816CA94 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =0x0000fffb - bl sub_816C228 - bl sub_816C2C0 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816CB04 - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816CA94 - - thumb_func_start sub_816CAC8 -sub_816CAC8: @ 816CAC8 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldr r1, =gUnknown_0203BCB8 - ldrh r0, [r1, 0x2] - ldrh r1, [r1] - adds r0, r1 - lsls r0, 2 - adds r2, r0 - movs r0, 0x93 - lsls r0, 3 - adds r2, r0 - ldrh r0, [r2] - bl sub_816C228 - bl sub_816C2C0 - adds r0, r4, 0 - bl sub_816CBC0 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816CAC8 - - thumb_func_start sub_816CB04 -sub_816CB04: @ 816CB04 - push {r4-r6,lr} - 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 r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _0816CB5E - ldr r4, =gUnknown_0203BCB8 - ldrb r0, [r4, 0x2] - ldrb r1, [r4] - adds r0, r1 - lsls r0, 24 - lsrs r0, 24 - ldrh r1, [r5, 0x4] - bl sub_80D6E48 - ldrb r0, [r5, 0xA] - adds r1, r4, 0x2 - adds r2, r4, 0 - bl sub_81AE6C8 - bl sub_816C110 - bl sub_816C140 - bl sub_816BD04 - ldr r0, =gMultiuseListMenuTemplate - ldrh r1, [r4, 0x2] - ldrh r2, [r4] - bl ListMenuInit - lsls r0, 24 - lsrs r0, 24 - strh r0, [r5, 0xA] - adds r0, r6, 0 - bl sub_816CBC0 -_0816CB5E: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816CB04 - - thumb_func_start sub_816CB74 -sub_816CB74: @ 816CB74 - push {r4,lr} - lsls r0, 24 - lsrs r4, r0, 24 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _0816CBAC - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldr r1, =gUnknown_0203BCB8 - ldrh r0, [r1, 0x2] - ldrh r1, [r1] - adds r0, r1 - lsls r0, 2 - adds r2, r0 - movs r0, 0x93 - lsls r0, 3 - adds r2, r0 - ldrh r0, [r2] - bl sub_816C228 - bl sub_816C2C0 - adds r0, r4, 0 - bl sub_816CBC0 -_0816CBAC: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816CB74 - - thumb_func_start sub_816CBC0 -sub_816CBC0: @ 816CBC0 - push {r4,lr} - adds r4, r0, 0 - lsls r4, 24 - lsrs r4, 24 - bl sub_816BF60 - ldr r1, =gTasks - lsls r0, r4, 2 - adds r0, r4 - lsls r0, 3 - adds r0, r1 - ldr r1, =sub_816C30C - str r1, [r0] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_816CBC0 - - .align 2, 0 @ Don't pad with nop. diff --git a/ld_script.txt b/ld_script.txt index 27344f720..2f8bd7b78 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -218,7 +218,6 @@ SECTIONS { asm/use_pokeblock.o(.text); src/battle_controller_wally.o(.text); src/player_pc.o(.text); - asm/player_pc.o(.text); src/intro.o(.text); src/reset_save_heap.o(.text); src/field_region_map.o(.text); diff --git a/src/player_pc.c b/src/player_pc.c index f9fb7f6da..cc886ae61 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -1099,3 +1099,275 @@ void sub_816C400(u8 taskId) gTasks[taskId].func = bx_battle_menu_t3; } +void sub_816C690(u8); +void sub_816C4FC(u8 taskId); + +void sub_816C450(u8 taskId) +{ + s16 *data; + + data = gTasks[taskId].data; + sub_81AF15C(data[5], 16, 1); + gUnknown_0203BCC4->unk666 = (playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos); + sub_816BFB8(data[5], 0, 0); + sub_816C690(gUnknown_0203BCC4->unk666); + CopyItemName(gSaveBlock1Ptr->pcItems[gUnknown_0203BCC4->unk666].itemId, gStringVar1); + sub_816C2C0(sub_816C228(ITEMPC_SWITCH_WHICH_ITEM)); + gTasks[taskId].func = sub_816C4FC; +} + +void sub_816C5A0(u8 taskId, bool8 a); + +void sub_816C4FC(u8 taskId) +{ + s16 *data; + s32 id; + + data = gTasks[taskId].data; + if(gMain.newKeys & SELECT_BUTTON) + { + sub_81AE860(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); + sub_816C5A0(taskId, FALSE); + return; + } + id = ListMenuHandleInputGetItemId(data[5]); + sub_81AE860(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); + sub_81223FC(gUnknown_0203BCC4->spriteIds, 7, 0); + sub_816C690(playerPCItemPageInfo.cursorPos); + switch(id) + { + case -1: + break; + case -2: + if(gMain.newKeys & A_BUTTON) + { + sub_816C5A0(taskId, FALSE); + } + else + sub_816C5A0(taskId, TRUE); + break; + default: + sub_816C5A0(taskId, FALSE); + break; + } +} + + +void sub_816C5A0(u8 taskId, bool8 a) +{ + s16 *data; + s32 id; + u16 b; + u8 c; + + data = gTasks[taskId].data; + b = (playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos); + PlaySE(SE_SELECT); + sub_81AE6C8(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); + if(!a) + { + c = gUnknown_0203BCC4->unk666; + if(c != b) + { + if(c != b - 1) + { + sub_80D702C(gSaveBlock1Ptr->pcItems, c, b); + sub_816BD04(); + } + + } + else + goto LABEL_SKIP_CURSOR_DECREMENT; + } + if (gUnknown_0203BCC4->unk666 < b) + playerPCItemPageInfo.cursorPos--; + LABEL_SKIP_CURSOR_DECREMENT: + sub_81223FC(gUnknown_0203BCC4->spriteIds, 7, 1); + gUnknown_0203BCC4->unk666 = 0xFF; + data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos); + schedule_bg_copy_tilemap_to_vram(0); + gTasks[taskId].func = sub_816C30C; +} + +//void +void sub_816C690(u8 a) +{ + sub_8122448(gUnknown_0203BCC4->spriteIds, 7, 128, ((a+1) * 16)); +} + +void sub_816C6BC(u8 windowId, u16 value, u32 mode, u8 x, u8 y, u8 n) +{ + ConvertIntToDecimalStringN(gStringVar1, value, mode, n); + StringExpandPlaceholders(gStringVar4, gText_xVar1); + PrintTextOnWindow(windowId, 1, gStringVar4, GetStringCenterAlignXOffset(1, gStringVar4, 48), y, 0, NULL); +} + +void sub_816C8FC(u8 taskId); +void sub_816C9B8(u8 taskid); +void sub_816C818(u8 taskid); + +void sub_816C71C(u8 taskId) +{ + s16 *data; + u16 b; + + data = gTasks[taskId].data; + b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove); + sub_816BF9C(); + data[2] = 1; + if(!data[3]) + { + if(gSaveBlock1Ptr->pcItems[b].quantity == 1) + { + sub_816C8FC(taskId); + return; + } + CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1); + sub_816C2C0(sub_816C228(ITEMPC_HOW_MANY_TO_WITHDRAW)); + } + else + { + if(gSaveBlock1Ptr->pcItems[b].quantity == 1) + { + sub_816C9B8(taskId); + return; + } + CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1); + sub_816C2C0(sub_816C228(ITEMPC_HOW_MANY_TO_TOSS)); + } + sub_816C6BC(sub_816BC7C(4), data[2], STR_CONV_MODE_LEADING_ZEROS, 8, 1, 3); + gTasks[taskId].func = sub_816C818; +} + +void sub_816CBC0(u8 taskId); + +void sub_816C818(u8 taskId) +{ + s16 *data; + u16 b; + + data = gTasks[taskId].data; + b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove); + if(AdjustQuantityAccordingToDPadInput(&(data[2]), gSaveBlock1Ptr->pcItems[b].quantity) == TRUE) + sub_816C6BC(sub_816BC7C(4), data[2], STR_CONV_MODE_LEADING_ZEROS, 8, 1, 3); + else + { + if(gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + sub_816BCC4(4); + if(!data[3]) + sub_816C8FC(taskId); + else + sub_816C9B8(taskId); + } + else if(gMain.newKeys & B_BUTTON) + { + PlaySE(SE_SELECT); + sub_816BCC4(4); + sub_816C2C0(sub_816C228(gSaveBlock1Ptr->pcItems[b].itemId)); + sub_816CBC0(taskId); + } + } +} + +void sub_816CB04(u8 taskId); +void sub_816CB74(u8 taskId); + +void sub_816C8FC(u8 taskId) +{ + s16 *data; + u16 b; + + data = gTasks[taskId].data; + b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove); + if(AddBagItem(gSaveBlock1Ptr->pcItems[b].itemId, data[2]) == TRUE) + { + CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, data[2], STR_CONV_MODE_LEFT_ALIGN, 3); + sub_816C2C0(sub_816C228(ITEMPC_WITHDREW_THING)); + gTasks[taskId].func = sub_816CB04; + } + else + { + data[2] = 0; + sub_816C2C0(sub_816C228(ITEMPC_NO_MORE_ROOM)); + gTasks[taskId].func = sub_816CB74; + } +} + +extern const struct WindowTemplate gUnknown_085DFF84; +extern const struct YesNoFuncTable gUnknown_085DFF3C; + +bool8 itemid_is_unique(u16 itemId); + +void sub_816C9B8(u8 taskId) +{ + s16 *data; + u16 b; + + data = gTasks[taskId].data; + b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove); + if(!itemid_is_unique(gSaveBlock1Ptr->pcItems[b].itemId)) + { + CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1); + ConvertIntToDecimalStringN(gStringVar2, data[2], STR_CONV_MODE_LEFT_ALIGN, 3); + sub_816C2C0(sub_816C228(ITEMPC_OKAY_TO_THROW_AWAY)); + CreateYesNoMenuWithCallbacks(taskId, &gUnknown_085DFF84, 1, 0, 1, 0x214, 0xE, &gUnknown_085DFF3C); + } + else + { + data[2] = 0; + sub_816C2C0(sub_816C228(ITEMPC_TOO_IMPORTANT)); + gTasks[taskId].func = sub_816CB74; + } +} + +void sub_816CA94(u8 taskId) +{ + sub_816C2C0(sub_816C228(ITEMPC_THREW_AWAY_ITEM)); + gTasks[taskId].func = sub_816CB04; +} + +void sub_816CAC8(u8 taskId) +{ + sub_816C2C0(sub_816C228(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId)); + sub_816CBC0(taskId); +} + +void sub_80D6E48(u8, u16); + +void sub_816CB04(u8 taskId) +{ + s16 *data; + + data = gTasks[taskId].data; + if(gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_80D6E48((playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove), data[2]); + sub_81AE6C8(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); + sub_816C110(); + sub_816C140(); + sub_816BD04(); + data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos); + sub_816CBC0(taskId); + } +} + +void sub_816CB74(u8 taskId) +{ + s16 *data; + + data = gTasks[taskId].data; + if(gMain.newKeys & (A_BUTTON | B_BUTTON)) + { + sub_816C2C0(sub_816C228(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId)); + sub_816CBC0(taskId); + } +} + +void sub_816CBC0(u8 taskId) +{ + sub_816BF60(); + gTasks[taskId].func = sub_816C30C; +} From a24ffb13213b7cd8761cd501bc4c052da66f57c4 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 19 Mar 2018 15:57:33 +0530 Subject: [PATCH 5/6] Finish decompiling player_pc rodata --- asm/party_menu.s | 2 +- data/player_pc.s | 75 ---- include/decoration.h | 1 + include/international_string_util.h | 4 +- include/item.h | 4 + include/menu_helpers.h | 2 +- include/party_menu.h | 1 + include/player_pc.h | 3 +- include/pokenav.h | 8 + include/strings.h | 39 +- ld_script.txt | 2 +- src/international_string_util.c | 2 +- src/player_pc.c | 607 ++++++++++++++-------------- sym_ewram.txt | 13 - 14 files changed, 358 insertions(+), 405 deletions(-) delete mode 100644 data/player_pc.s diff --git a/asm/party_menu.s b/asm/party_menu.s index 1ee1fb8d1..5d01bd745 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -15442,7 +15442,7 @@ sub_81B8474: @ 81B8474 movs r0, 0 strb r0, [r1] ldr r2, =gSaveBlock1Ptr - ldr r0, =gUnknown_0203BCB8 + ldr r0, =playerPCItemPageInfo ldrh r1, [r0] adds r1, 0x6 ldrh r0, [r0, 0x2] diff --git a/data/player_pc.s b/data/player_pc.s deleted file mode 100644 index 69eacb69b..000000000 --- a/data/player_pc.s +++ /dev/null @@ -1,75 +0,0 @@ -#include "constants/items.h" - .include "asm/macros.inc" - .include "constants/constants.inc" - - .section .rodata - - .align 2 -gPCText_OptionDescList:: @ 85DFEA4 - .4byte gText_TakeOutItemsFromPC - .4byte gText_StoreItemsInPC - .4byte gText_ThrowAwayItemsInPC - .4byte gText_GoBackPrevMenu - - .align 2 -sPlayerPCMenuActions:: @ 85DFEB4 - .4byte gText_ItemStorage, PlayerPC_ItemStorage - .4byte gText_Mailbox, PlayerPC_Mailbox - .4byte gText_Decoration, PlayerPC_Decoration - .4byte gText_TurnOff, PlayerPC_TurnOff - - .align 2 -gBedroomPC_OptionOrder:: @ 85DFED4 - .byte 0x00, 0x01, 0x02, 0x03 - - .align 2 -gPlayerPC_OptionOrder:: @ 85DFED8 - .byte 0x00, 0x01, 0x03, 0x00 - - .align 2 -gPCText_ItemPCOptionsText:: @ 85DFEDC - .4byte gText_WithdrawItem, ItemStorage_Withdraw - .4byte gText_DepositItem, ItemStorage_Deposit - .4byte gText_TossItem, ItemStorage_Toss - .4byte gText_Cancel, ItemStorage_Exit - - .align 2 -gNewGamePCItems:: @ 85DFEFC - .2byte ITEM_POTION, 0x0001 - .2byte 0x0000, 0x0000 - - .align 2 -gMailboxMailOptions:: @ 85DFF04 - .4byte gText_Read, Mailbox_DoMailRead - .4byte gText_MoveToBag, Mailbox_MoveToBag - .4byte gText_Give2, Mailbox_Give - .4byte gText_Cancel2, Mailbox_Cancel - - .align 2 -gUnknown_085DFF24:: @ 85DFF24 - .4byte 0x09010100, 0x00010f06, 0x09010100, 0x00010f08, 0x0a010100, 0x00010f08 - - .align 2 -gUnknown_085DFF3C:: @ 85DFF3C - .4byte sub_816CA94 - .4byte sub_816CAC8 - - .align 2 -gUnknown_085DFF44:: @ 85DFF44 - .4byte 0x00000000, sub_816BDDC, fish4_goto_x5_or_x6, 0x00000000, 0x00080000, 0x07003129 - - .align 2 -gUnknown_085DFF5C:: @ 85DFF5C - window_template 0x00, 0x10, 0x01, 0x0d, 0x12, 0x0f, 0x0001 - window_template 0x00, 0x01, 0x0d, 0x0d, 0x06, 0x0f, 0x00eb - window_template 0x00, 0x01, 0x08, 0x03, 0x03, 0x0f, 0x0153 - window_template 0x00, 0x01, 0x01, 0x0d, 0x02, 0x0f, 0x0139 - window_template 0x00, 0x08, 0x09, 0x06, 0x02, 0x0f, 0x015c - - .align 2 -gUnknown_085DFF84:: @ 85DFF84 - window_template 0x00, 0x09, 0x07, 0x05, 0x04, 0x0f, 0x0168 - - .align 2 -gUnknown_085DFF8C:: @ 85DFF8C - .byte 0x01, 0x03, 0x02, 0x00 diff --git a/include/decoration.h b/include/decoration.h index c841bbfc1..a51d9ccce 100644 --- a/include/decoration.h +++ b/include/decoration.h @@ -69,5 +69,6 @@ extern EWRAM_DATA u8 gCurDecorationIndex; void sub_8126968(void); void sub_8126AD8(u8 taskId); void sub_8127D38(u16 mapX, u16 mapY, u16 decor); +void sub_8126B2C(u8 taskId); #endif //GUARD_DECORATION_H diff --git a/include/international_string_util.h b/include/international_string_util.h index f4ba827e3..426a2d48c 100644 --- a/include/international_string_util.h +++ b/include/international_string_util.h @@ -10,12 +10,12 @@ s32 GetStringRightAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth); s32 GetStringCenterAlignXOffsetWithLetterSpacing(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing); s32 GetStringWidthDifference(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing); s32 GetMaxWidthInMenuTable(const struct MenuAction *str, s32 arg1); -s32 sub_81DB3D8(const struct MenuAction *str, u8* arg1, s32 arg2); +s32 sub_81DB3D8(const struct MenuAction *str, const u8* arg1, s32 arg2); // sub_81DB41C // CopyMonCategoryText // sub_81DB494 void PadNameString(u8 *dst, u8 padWith); -// sub_81DB554 +void sub_81DB554(u8 *, u8); // sub_81DB5AC u32 sub_81DB604(const u8 *); // sub_81DB620 diff --git a/include/item.h b/include/item.h index d81a3de33..33d434f78 100644 --- a/include/item.h +++ b/include/item.h @@ -64,5 +64,9 @@ u16 BagGetItemIdByPocketPosition(u8 pocketId, u16 pocketPos); void sub_80D6FB4(struct BagPocket*); void sub_80D6F64(struct BagPocket*); void sub_80D702C(struct ItemSlot*, s16, u16); +u8 sub_80D6CE4(); +bool8 itemid_is_unique(u16 itemId); +void sub_80D6E48(u8, u16); +void sub_80D6E84(void); #endif // ITEM_H diff --git a/include/menu_helpers.h b/include/menu_helpers.h index bbdd21327..4de6603a3 100644 --- a/include/menu_helpers.h +++ b/include/menu_helpers.h @@ -14,7 +14,7 @@ struct YesNoFuncTable // Exported RAM declarations // Exported ROM declarations - +void sub_812220C(struct ItemSlot *, u8, u8 *, u8 *, u8); void sub_812225C(u16 *, u16 *, u8, u8); void sub_8122298(u16 *, u16 *, u8, u8, u8); void sub_8121F68(u8 taskId, const struct YesNoFuncTable *data); diff --git a/include/party_menu.h b/include/party_menu.h index 1ce12d98f..c96eb0d9d 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -37,5 +37,6 @@ void display_pokemon_menu_message(u8 windowId); void sub_81B1F18(u8 taskId, u8 pokemonIdx, s8 a, s16 hp, TaskFunc func); void sub_81B1B5C(void *a, u8 b); u8 sub_81B1BD4(); +void sub_81B8448(); #endif // GUARD_PARTY_MENU_H diff --git a/include/player_pc.h b/include/player_pc.h index 9e8ae6ef4..bd060faa8 100644 --- a/include/player_pc.h +++ b/include/player_pc.h @@ -72,14 +72,15 @@ struct PlayerPCItemPageStruct u8 count; u8 filler[3]; u8 scrollIndicatorId; - u8 filler2[4]; }; // Exported type declarations // Exported RAM declarations +extern struct PlayerPCItemPageStruct playerPCItemPageInfo; // Exported ROM declarations +extern const struct MenuAction gMailboxMailOptions[]; void ReshowPlayerPC(u8 taskId); void sub_816B31C(void); diff --git a/include/pokenav.h b/include/pokenav.h index ebe3b325c..fabe211ea 100644 --- a/include/pokenav.h +++ b/include/pokenav.h @@ -1,5 +1,6 @@ #ifndef GUARD_POKENAV_H #define GUARD_POKENAV_H +#include "player_pc.h" bool8 sub_81D5C18(void); bool8 sub_81D20BC(void *arg0); @@ -13,5 +14,12 @@ void sub_81D3480(void *arg0, u8 arg1); void sub_81D2754(void *arg0, void *arg1); void sub_81D1F84(void *arg0, void *arg1, void *arg2); const u8 *sub_81D62AC(void); +u8 sub_81D1C84(u8); +u8 sub_81D1DC0(struct PlayerPCItemPageStruct *); +void sub_81D1E90(struct PlayerPCItemPageStruct *); +void sub_81D1EC0(void); +void sub_81D1D04(u8); +bool8 sub_81D1C44(u8); + #endif //GUARD_POKENAV_H diff --git a/include/strings.h b/include/strings.h index 907873160..689acff5e 100644 --- a/include/strings.h +++ b/include/strings.h @@ -372,8 +372,45 @@ extern const u8 gBirchDexRatingText_LessThan190[]; extern const u8 gBirchDexRatingText_LessThan200[]; extern const u8 gBirchDexRatingText_DexCompleted[]; -//player menu text +//player pc text extern const u8 gText_WhatWouldYouLike[]; extern const u8 gText_NoMailHere[]; +extern const u8 gText_TakeOutItemsFromPC[]; +extern const u8 gText_StoreItemsInPC[]; +extern const u8 gText_ThrowAwayItemsInPC[]; +extern const u8 gText_GoBackPrevMenu[]; + +extern const u8 gText_ItemStorage[]; +extern const u8 gText_Mailbox[]; +extern const u8 gText_Decoration[]; +extern const u8 gText_TurnOff[]; + +extern const u8 gText_WithdrawItem[]; +extern const u8 gText_DepositItem[]; +extern const u8 gText_TossItem[]; +extern const u8 gText_Cancel[]; + +extern const u8 gText_Read[]; +extern const u8 gText_MoveToBag[]; +extern const u8 gText_Give2[]; +extern const u8 gText_Cancel2[]; + +extern const u8 gText_NoItems[]; +extern const u8 gText_WhatToDoWithVar1sMail[]; +extern const u8 gText_MessageWillBeLost[]; +extern const u8 gText_BagIsFull[]; + +extern const u8 gText_MailToBagMessageErased[]; +extern const u8 gText_GoBackPrevMenu[]; +extern const u8 gText_WithdrawHowManyItems[]; +extern const u8 gText_WithdrawXItems[]; +extern const u8 gText_TossHowManyVar1s[]; +extern const u8 gText_ThrewAwayVar2Var1s[]; +extern const u8 gText_NoRoomInBag[]; +extern const u8 gText_TooImportantToToss[]; +extern const u8 gText_ConfirmTossItems[]; +extern const u8 gText_MoveVar1Where[]; + + #endif //GUARD_STRINGS_H diff --git a/ld_script.txt b/ld_script.txt index 2f8bd7b78..f4aa85186 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -493,7 +493,7 @@ SECTIONS { src/use_pokeblock.o(.rodata); data/use_pokeblock.o(.rodata); src/battle_controller_wally.o(.rodata); - data/player_pc.o(.rodata); + src/player_pc.o(.rodata); src/intro.o(.rodata); src/field_region_map.o(.rodata); data/battle_anim_8170478.o(.rodata); diff --git a/src/international_string_util.c b/src/international_string_util.c index 89b4a7a69..9de338c59 100644 --- a/src/international_string_util.c +++ b/src/international_string_util.c @@ -42,7 +42,7 @@ s32 GetMaxWidthInMenuTable(const struct MenuAction *str, s32 arg1) return convert_pixel_width_to_tile_width(var); } -s32 sub_81DB3D8(const struct MenuAction *str, u8* arg1, s32 arg2) +s32 sub_81DB3D8(const struct MenuAction *str, const u8* arg1, s32 arg2) { s32 i, var; diff --git a/src/player_pc.c b/src/player_pc.c index cc886ae61..651a18327 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -4,6 +4,7 @@ #include "decoration.h" #include "event_scripts.h" #include "field_fadetransition.h" +#include "field_map_obj.h" #include "field_screen.h" #include "field_weather.h" #include "international_string_util.h" @@ -20,6 +21,8 @@ #include "menu_indicators.h" #include "overworld.h" #include "palette.h" +#include "party_menu.h" +#include "pokenav.h" #include "player_pc.h" #include "script.h" #include "sound.h" @@ -32,65 +35,192 @@ struct Struct203BCC4 { struct ListMenuItem unk0[51]; - //u8 filler[0x118]; u8 unk198[51][0x18]; - //u8 filler2[0x348]; u8 windowIds[6]; u8 unk666; u8 spriteId; u8 spriteIds[7]; - }; -extern struct Struct203BCC4 *gUnknown_0203BCC4; +void (*gFieldCallback)(void); -static EWRAM_DATA u8 *gPcItemMenuOptionOrder = NULL; +static void InitPlayerPCMenu(u8 taskId); +static void PlayerPCProcessMenuInput(u8 taskId); +static void InitItemStorageMenu(u8 taskId, u8 var); +static u8 GetMailboxMailCount(void); +static void Mailbox_UpdateMailList(void); +static void Mailbox_DrawMailboxMenu(u8 taskId); +static void Mailbox_ProcessInput(u8 taskId); +static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId); +static void Mailbox_ReturnToPlayerPC(u8); +static void Mailbox_PrintMailOptions(u8 taskId); +static void Mailbox_MailOptionsProcessInput(u8 taskId); + +static void PlayerPC_ItemStorage(u8 taskId); +static void PlayerPC_Mailbox(u8 taskId); +static void PlayerPC_Decoration(u8 var); +static void PlayerPC_TurnOff(u8 taskId); + +static void Mailbox_DoMailMoveToBag(u8 taskId); +static void Mailbox_DoMailRead(u8 taskId); +static void Mailbox_MoveToBag(u8 taskId); +static void Mailbox_Give(u8 taskId); +static void Mailbox_Cancel(u8 taskId); + +static void Mailbox_CancelMoveToBag(u8 taskId); +static void Mailbox_MoveToBagYesNoPrompt(u8 taskId); +static void Mailbox_DrawYesNoBeforeMove(u8 taskId); +static void Mailbox_DoGiveMailPokeMenu(u8 taskId); +static void Mailbox_NoPokemonForMail(u8 taskId); + +static void Mailbox_FadeAndReadMail(u8 taskId); +static void Mailbox_ReturnToFieldFromReadMail(void); +static void Mailbox_DoRedrawMailboxMenuAfterReturn(void); +static void pal_fill_for_maplights_or_black(void); +static void Mailbox_HandleReturnToProcessInput(u8 taskId); + +static void ItemStorage_Withdraw(u8 taskId); +static void ItemStorage_Deposit(u8 taskId); +static void ItemStorage_Toss(u8 taskId); +static void ItemStorage_Exit(u8 taskId); +static void ItemStorage_ResumeInputFromYesToss(u8 taskId); +static void ItemStorage_ResumeInputFromNoToss(u8 taskId); + +static void ItemStorageMenuPrint(const u8 *); +static void ItemStorageMenuProcessInput(u8 taskId); +static void ItemStorage_ProcessWithdrawTossInput(u8 taskId); +static void ItemStorage_SetItemAndMailCount(u8); +static void ItemStorage_HandleReturnToProcessInput(u8 taskId); + +static void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss); +static void Task_ItemStorage_Deposit(u8 taskId); +static void ItemStorage_DoItemWithdraw(u8 taskId); +static void ItemStorage_DoItemToss(u8 taskid); +static void ItemStorage_HandleQuantityRolling(u8 taskid); +static void ItemStorage_GoBackToPlayerPCMenu(u8 taskId); +static void ItemStorage_ItemSwapChoosePrompt(u8 taskId); +static void ItemStorage_DoItemAction(u8 taskId); +static void ItemStorage_ProcessInput(u8 taskId); +static void ItemStorage_DoItemSwap(u8 taskId, bool8 a); +static void ItemStorage_HandleRemoveItem(u8 taskId); +static void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId); +static void ItemStorage_StartScrollIndicatorAndProcessInput(u8 taskId); + +static const u8* ItemStorage_GetItemPcResponse(u16); +static void CopyItemName_PlayerPC(u8 *string, u16 itemId); + +static void sub_816BC14(void); +static void sub_816BFE0(u8 y, u8, u8 speed); +static void sub_816BCC4(u8); +static void sub_816C690(u8); +static void sub_816C4FC(u8 taskId); +static void sub_816C0C8(void); +static void sub_816C060(u16 itemId); +static void sub_816BEF0(s32 id); +static void sub_816B4DC(u8 taskId); +static void ItemStorage_DrawBothListAndDescription(u32 id, bool8 b, struct ListMenu * thisMenu); +static void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset); + + +static void Mailbox_UpdateMailListAfterDeposit(void); + +static EWRAM_DATA const u8 *gPcItemMenuOptionOrder = NULL; static EWRAM_DATA u8 gPcItemMenuOptionsNum = 0; - -extern struct PlayerPCItemPageStruct gUnknown_0203BCB8; - -#define playerPCItemPageInfo gUnknown_0203BCB8 +EWRAM_DATA struct PlayerPCItemPageStruct playerPCItemPageInfo = {0, 0, 0, 0, {0, 0, 0}, 0}; +static EWRAM_DATA struct Struct203BCC4 *gUnknown_0203BCC4 = NULL; -/*static*/ void InitPlayerPCMenu(u8 taskId); -/*static*/ void PlayerPCProcessMenuInput(u8 taskId); -/*static*/ void InitItemStorageMenu(u8 taskId, u8 var); -/*static*/ void ItemStorageMenuPrint(const u8 *); -/*static*/ void ItemStorageMenuProcessInput(u8 taskId); -/*static*/ void ItemStorage_ProcessInput(u8 taskId); -/*static*/ void ItemStorage_SetItemAndMailCount(u8); -/*static*/ void ItemStorage_DoItemWithdraw(u8); -/*static*/ void ItemStorage_DoItemToss(u8); -/*static*/ void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss); +static const u8 *const gPCText_OptionDescList[] = +{ + gText_TakeOutItemsFromPC, + gText_StoreItemsInPC, + gText_ThrowAwayItemsInPC, + gText_GoBackPrevMenu, +}; -/*static*/ void ItemStorage_HandleReturnToProcessInput(u8); +static const struct MenuAction sPlayerPCMenuActions[] = +{ + { gText_ItemStorage, PlayerPC_ItemStorage }, + { gText_Mailbox, PlayerPC_Mailbox }, + { gText_Decoration, PlayerPC_Decoration }, + { gText_TurnOff, PlayerPC_TurnOff } +}; -/*static*/ u8 GetMailboxMailCount(void); +static const u8 gBedroomPC_OptionOrder[] = +{ + PLAYERPC_MENU_ITEMSTORAGE, + PLAYERPC_MENU_MAILBOX, + PLAYERPC_MENU_DECORATION, + PLAYERPC_MENU_TURNOFF +}; -/*static*/ void Mailbox_UpdateMailList(void); -/*static*/ void Mailbox_DrawMailboxMenu(u8); -/*static*/ void Mailbox_ProcessInput(u8); -/*static*/ void Mailbox_PrintWhatToDoWithPlayerMailText(u8); +static const u8 gPlayerPC_OptionOrder[] = +{ + PLAYERPC_MENU_ITEMSTORAGE, + PLAYERPC_MENU_MAILBOX, + PLAYERPC_MENU_TURNOFF +}; -/*static*/ void PlayerPC_ItemStorage(u8 taskId); -/*static*/ void PlayerPC_Mailbox(u8 taskId); -/*static*/ void PlayerPC_Decoration(u8 var); -/*static*/ void PlayerPC_TurnOff(u8 taskId); +static const struct MenuAction gPCText_ItemPCOptionsText[] = +{ + { gText_WithdrawItem, ItemStorage_Withdraw }, + { gText_DepositItem, ItemStorage_Deposit }, + { gText_TossItem, ItemStorage_Toss }, + { gText_Cancel, ItemStorage_Exit } +}; -/*static*/ void ItemStorage_Exit(u8); +static const struct ItemSlot gNewGamePCItems[] = +{ + { ITEM_POTION, 1 }, + { ITEM_NONE, 0 } +}; +const struct MenuAction gMailboxMailOptions[] = +{ + { gText_Read, Mailbox_DoMailRead }, + { gText_MoveToBag, Mailbox_MoveToBag }, + { gText_Give2, Mailbox_Give }, + { gText_Cancel2, Mailbox_Cancel } +}; -extern const u8 *const gPCText_OptionDescList[]; -/*static*/ extern const struct ItemSlot gNewGamePCItems[]; -/*static*/ extern const struct MenuAction gPCText_ItemPCOptionsText[]; -/*static*/ extern const struct MenuAction gMailboxMailOptions[]; -/*static*/ extern const struct MenuAction sPlayerPCMenuActions[]; -/*static*/ extern u8 gBedroomPC_OptionOrder[]; -/*static*/ extern u8 gPlayerPC_OptionOrder[]; +static const struct WindowTemplate gUnknown_085DFF24[3] = +{ + {0x00, 0x01, 0x01, 0x09, 0x06, 0x0F, 0x0001}, + {0x00, 0x01, 0x01, 0x09, 0x08, 0x0F, 0x0001}, + {0x00, 0x01, 0x01, 0x0A, 0x08, 0x0F, 0x0001} +}; -extern const struct WindowTemplate gUnknown_085DFF24[3]; +static const struct YesNoFuncTable gUnknown_085DFF3C = // ResumeFromWithdrawYesNoFuncList +{ + ItemStorage_ResumeInputFromYesToss, + ItemStorage_ResumeInputFromNoToss +}; +static const struct ListMenuTemplate gUnknown_085DFF44 = { + NULL, + ItemStorage_DrawBothListAndDescription, + fish4_goto_x5_or_x6, + 0, 0, + 0, 0, 8, 0, + 9, 2, 1, 3, FALSE, 0, FALSE, 7 +}; + +static const struct WindowTemplate gUnknown_085DFF5C[5] = +{ + {0x00, 0x10, 0x01, 0x0D, 0x12, 0x0F, 0x0001}, + {0x00, 0x01, 0x0D, 0x0D, 0x06, 0x0F, 0x00EB}, + {0x00, 0x01, 0x08, 0x03, 0x03, 0x0F, 0x0153}, + {0x00, 0x01, 0x01, 0x0D, 0x02, 0x0F, 0x0139}, + {0x00, 0x08, 0x09, 0x06, 0x02, 0x0F, 0x015C} +}; + +static const struct WindowTemplate gUnknown_085DFF84 = +{ + 0x00, 0x09, 0x07, 0x05, 0x04, 0x0F, 0x0168 +}; + +static const u8 gUnknown_085DFF8C[] = {0x01, 0x03, 0x02, 0x00}; void NewGameInitPCItems(void) @@ -116,7 +246,7 @@ void PlayerPC(void) DisplayItemMessageOnField(CreateTask(TaskDummy, 0), gText_WhatWouldYouLike, InitPlayerPCMenu); } -/*static*/ void InitPlayerPCMenu(u8 taskId) +static void InitPlayerPCMenu(u8 taskId) { u16 *data; struct WindowTemplate windowTemplate; @@ -135,7 +265,7 @@ void PlayerPC(void) gTasks[taskId].func = PlayerPCProcessMenuInput; } -/*static*/ void PlayerPCProcessMenuInput(u8 taskId) +static void PlayerPCProcessMenuInput(u8 taskId) { u16 *data; s8 inputOptionId; @@ -173,17 +303,14 @@ void ReshowPlayerPC(u8 var) DisplayItemMessageOnField(var, gText_WhatWouldYouLike, InitPlayerPCMenu); } -/*static*/ void PlayerPC_ItemStorage(u8 taskId) +static void PlayerPC_ItemStorage(u8 taskId) { InitItemStorageMenu(taskId, ITEMPC_MENU_WITHDRAW); gTasks[taskId].func = ItemStorageMenuProcessInput; } -bool8 sub_81D1C44(u8); - -/*static*/ void PlayerPC_Mailbox(u8 taskId) +static void PlayerPC_Mailbox(u8 taskId) { - playerPCItemPageInfo.count = GetMailboxMailCount(); if (playerPCItemPageInfo.count == 0) @@ -206,14 +333,12 @@ bool8 sub_81D1C44(u8); } } -void sub_8126B2C(u8); - -/*static*/ void PlayerPC_Decoration(u8 var) +static void PlayerPC_Decoration(u8 var) { sub_8126B2C(var); //DoPlayerPCDecoration(var); } -/*static*/ void PlayerPC_TurnOff(u8 taskId) +static void PlayerPC_TurnOff(u8 taskId) { if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC and not player PC, so do gender specific handling. { @@ -229,9 +354,7 @@ void sub_8126B2C(u8); DestroyTask(taskId); } -void ItemStorageMenuPrint(const u8*); - -void InitItemStorageMenu(u8 taskId, u8 var) +static void InitItemStorageMenu(u8 taskId, u8 var) { u16 *data; struct WindowTemplate windowTemplate; @@ -247,13 +370,13 @@ void InitItemStorageMenu(u8 taskId, u8 var) ItemStorageMenuPrint(gPCText_OptionDescList[var]); } -/*static*/ void ItemStorageMenuPrint(const u8 *textPtr) +static void ItemStorageMenuPrint(const u8 *textPtr) { NewMenuHelpers_DrawDialogueFrame(0, 0); PrintTextOnWindow(0, 1, textPtr, 0, 1, 0, 0); } -/*static*/ void ItemStorageMenuProcessInput(u8 var) +static void ItemStorageMenuProcessInput(u8 taskId) { s8 r5; s8 r2; @@ -270,23 +393,22 @@ void InitItemStorageMenu(u8 taskId, u8 var) break; case -1: PlaySE(SE_SELECT); - ItemStorage_Exit(var); + ItemStorage_Exit(taskId); break; default: PlaySE(SE_SELECT); - gPCText_ItemPCOptionsText[inputOptionId].func.void_u8(var); + gPCText_ItemPCOptionsText[inputOptionId].func.void_u8(taskId); break; } } -void Task_ItemStorage_Deposit(u8 taskId); -/*static*/ void ItemStorage_Deposit(u8 taskId) +static void ItemStorage_Deposit(u8 taskId) { gTasks[taskId].func = Task_ItemStorage_Deposit; FadeScreen(1, 0); } -/*static*/ void Task_ItemStorage_Deposit(u8 taskId) +static void Task_ItemStorage_Deposit(u8 taskId) { if (!gPaletteFade.active) { @@ -296,16 +418,13 @@ void Task_ItemStorage_Deposit(u8 taskId); } } -void mapldr_080EBC0C(void); - -void (*gFieldCallback)(void); void sub_816B31C(void) { - gFieldCallback = mapldr_080EBC0C; + gFieldCallback = Mailbox_DoRedrawMailboxMenuAfterReturn; SetMainCallback2(CB2_ReturnToField); } -void mapldr_080EBC0C(void) +void Mailbox_DoRedrawMailboxMenuAfterReturn(void) { sub_81973A4(); NewMenuHelpers_DrawDialogueFrame(0, 1); @@ -313,23 +432,17 @@ void mapldr_080EBC0C(void) pal_fill_black(); } -/*static*/ void ItemStorage_HandleReturnToProcessInput(u8 taskId) +static void ItemStorage_HandleReturnToProcessInput(u8 taskId) { if (sub_80ABDFC() == TRUE) gTasks[taskId].func = ItemStorageMenuProcessInput; } -u8 sub_80D6CE4(); //count of items -void sub_816B4DC(u8 taskId); - -extern const u8 gText_NoItems[]; - -/*static*/ void ItemStorage_Withdraw(u8 taskId) +static void ItemStorage_Withdraw(u8 taskId) { s16 *data = gTasks[taskId].data; NUM_ITEMS = sub_80D6CE4(); - if (NUM_ITEMS != 0) ItemStorage_WithdrawToss_Helper(taskId, FALSE); else @@ -340,7 +453,7 @@ extern const u8 gText_NoItems[]; } -/*static*/ void ItemStorage_Toss(u8 taskId) +static void ItemStorage_Toss(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -354,11 +467,7 @@ extern const u8 gText_NoItems[]; } } -void sub_816BC14(void); -void gpu_pal_allocator_reset__manage_upper_four(void); - - -/*static*/ void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss) +static void ItemStorage_WithdrawToss_Helper(u8 taskId, bool8 toss) { u16 *data = gTasks[taskId].data; @@ -373,19 +482,17 @@ void gpu_pal_allocator_reset__manage_upper_four(void); LoadListMenuArrowsGfx(); sub_8122344(gUnknown_0203BCC4->spriteIds, 7); sub_8197434(0,0); - gTasks[taskId].func = ItemStorage_ProcessInput; + gTasks[taskId].func = ItemStorage_ProcessWithdrawTossInput; } - - -/*static*/ void ItemStorage_Exit(u8 taskId) +static void ItemStorage_Exit(u8 taskId) { sub_816B4DC(taskId); ReshowPlayerPC(taskId); } -/*static*/ void ItemStorage_SetItemAndMailCount(u8 taskId) +static void ItemStorage_SetItemAndMailCount(u8 taskId) { if (playerPCItemPageInfo.count > 7) playerPCItemPageInfo.pageItems = 8; @@ -393,7 +500,7 @@ void gpu_pal_allocator_reset__manage_upper_four(void); playerPCItemPageInfo.pageItems = playerPCItemPageInfo.count + 1; } -/*static*/ void sub_816B4DC(u8 taskId) +static void sub_816B4DC(u8 taskId) { u16 *data = gTasks[taskId].data; @@ -403,7 +510,7 @@ void gpu_pal_allocator_reset__manage_upper_four(void); schedule_bg_copy_tilemap_to_vram(0); } -/*static*/ u8 GetMailboxMailCount(void) +static u8 GetMailboxMailCount(void) { u8 i, j; @@ -414,7 +521,7 @@ void gpu_pal_allocator_reset__manage_upper_four(void); return i; } -/*static*/ void Mailbox_UpdateMailList(void) +static void Mailbox_UpdateMailList(void) { struct MailStruct mailBuffer; u8 i, j; @@ -433,13 +540,7 @@ void gpu_pal_allocator_reset__manage_upper_four(void); } } -extern const u8 gText_Mailbox[]; -u8 sub_81D1C84(u8); -u8 sub_81D1DC0(struct PlayerPCItemPageStruct *); -void sub_81D1E90(struct PlayerPCItemPageStruct *); - - -/*static*/ void Mailbox_DrawMailboxMenu(u8 taskId) +static void Mailbox_DrawMailboxMenu(u8 taskId) { u8 windowId; @@ -451,13 +552,7 @@ void sub_81D1E90(struct PlayerPCItemPageStruct *); sub_81D1E90(&playerPCItemPageInfo); } - -void Mailbox_ReturnToPlayerPC(u8); -void RemoveScrollIndicatorArrowPair(u8); -void sub_81D1D04(u8); - - -/*static*/ void Mailbox_ProcessInput(u8 taskId) +static void Mailbox_ProcessInput(u8 taskId) { u16 *data = gTasks[taskId].data; s32 inputOptionId; @@ -489,11 +584,7 @@ void sub_81D1D04(u8); } } -void sub_81DB554(u8 *, u8); -void Mailbox_PrintMailOptions(u8); -extern const u8 gText_WhatToDoWithVar1sMail[]; - -/*static*/ void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId)//Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) +static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) { StringCopy(gStringVar1, gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos].playerName); sub_81DB554(gStringVar1, 0); @@ -501,9 +592,7 @@ extern const u8 gText_WhatToDoWithVar1sMail[]; DisplayItemMessageOnField(taskId, gStringVar4, Mailbox_PrintMailOptions); } -void sub_81D1EC0(void); - -/*static*/ void Mailbox_ReturnToPlayerPC(u8 taskId) +static void Mailbox_ReturnToPlayerPC(u8 taskId) { s16 *data = gTasks[taskId].data; @@ -515,11 +604,7 @@ void sub_81D1EC0(void); ReshowPlayerPC(taskId); } -extern const struct MenuAction gMailboxMailOptions[]; - -void Mailbox_MailOptionsProcessInput(u8 taskId); - -void Mailbox_PrintMailOptions(u8 taskId) +static void Mailbox_PrintMailOptions(u8 taskId) { u8 r4 = sub_81D1C84(2); PrintMenuTable(r4, 4, gMailboxMailOptions); @@ -528,9 +613,7 @@ void Mailbox_PrintMailOptions(u8 taskId) gTasks[taskId].func = Mailbox_MailOptionsProcessInput; } -void Mailbox_Cancel(u8 taskId); - -void Mailbox_MailOptionsProcessInput(u8 taskId) +static void Mailbox_MailOptionsProcessInput(u8 taskId) { s8 inputOptionId = ProcessMenuInput_other(); @@ -542,6 +625,7 @@ void Mailbox_MailOptionsProcessInput(u8 taskId) PlaySE(SE_SELECT); Mailbox_Cancel(taskId); break; + default: PlaySE(SE_SELECT); gMailboxMailOptions[inputOptionId].func.void_u8(taskId); @@ -549,17 +633,13 @@ void Mailbox_MailOptionsProcessInput(u8 taskId) } } -void Mailbox_FadeAndReadMail(u8 taskId); - -void Mailbox_DoMailRead(u8 taskId) +static void Mailbox_DoMailRead(u8 taskId) { FadeScreen(1, 0); gTasks[taskId].func = Mailbox_FadeAndReadMail; } -void Mailbox_ReturnToFieldFromReadMail(); - -void Mailbox_FadeAndReadMail(u8 taskId) +static void Mailbox_FadeAndReadMail(u8 taskId) { if(!gPaletteFade.active) { @@ -570,17 +650,13 @@ void Mailbox_FadeAndReadMail(u8 taskId) } } -void pal_fill_for_maplights_or_black(); - -void Mailbox_ReturnToFieldFromReadMail() +static void Mailbox_ReturnToFieldFromReadMail(void) { gFieldCallback = pal_fill_for_maplights_or_black; SetMainCallback2(CB2_ReturnToField); } -void Mailbox_HandleReturnToProcessInput(u8 taskId); - -void pal_fill_for_maplights_or_black() +static void pal_fill_for_maplights_or_black(void) { u8 taskId; @@ -593,32 +669,24 @@ void pal_fill_for_maplights_or_black() pal_fill_black(); } -void Mailbox_HandleReturnToProcessInput(u8 taskId) +static void Mailbox_HandleReturnToProcessInput(u8 taskId) { if(sub_80ABDFC() == TRUE) gTasks[taskId].func = Mailbox_ProcessInput; } -extern const u8 gText_MessageWillBeLost[]; - -void Mailbox_DrawYesNoBeforeMove(u8 taskId); - -void Mailbox_MoveToBag(u8 taskId) +static void Mailbox_MoveToBag(u8 taskId) { DisplayItemMessageOnField(taskId, gText_MessageWillBeLost, Mailbox_DrawYesNoBeforeMove); } -void Mailbox_DoMailMoveToBag(u8 taskId); -void Mailbox_CancelMoveToBag(u8 taskId); -void Mailbox_MoveToBagYesNoPrompt(u8 taskId); - -void Mailbox_DrawYesNoBeforeMove(u8 taskId) +static void Mailbox_DrawYesNoBeforeMove(u8 taskId) { sub_8197930(); gTasks[taskId].func = Mailbox_MoveToBagYesNoPrompt; } -void Mailbox_MoveToBagYesNoPrompt(u8 taskId) +static void Mailbox_MoveToBagYesNoPrompt(u8 taskId) { switch(ProcessMenuInputNoWrap_()) { @@ -636,10 +704,7 @@ void Mailbox_MoveToBagYesNoPrompt(u8 taskId) } } -extern const u8 gText_BagIsFull[]; -extern const u8 gText_MailToBagMessageErased[]; - -void Mailbox_DoMailMoveToBag(u8 taskId) +static void Mailbox_DoMailMoveToBag(u8 taskId) { struct MailStruct *mailStruct = &(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]); if(!AddBagItem(mailStruct->itemId, 1)) @@ -658,15 +723,12 @@ void Mailbox_DoMailMoveToBag(u8 taskId) } } -void Mailbox_CancelMoveToBag(u8 taskId) +static void Mailbox_CancelMoveToBag(u8 taskId) { Mailbox_Cancel(taskId); } -void Mailbox_DoGiveMailPokeMenu(u8 taskId); -void Mailbox_NoPokemonForMail(u8 taskId); - -void Mailbox_Give(u8 taskId) +static void Mailbox_Give(u8 taskId) { if(CalculatePlayerPartyCount() == 0) Mailbox_NoPokemonForMail(taskId); @@ -677,9 +739,7 @@ void Mailbox_Give(u8 taskId) } } -void sub_81B8448(); - -void Mailbox_DoGiveMailPokeMenu(u8 taskId) +static void Mailbox_DoGiveMailPokeMenu(u8 taskId) { if(!gPaletteFade.active) { @@ -690,15 +750,13 @@ void Mailbox_DoGiveMailPokeMenu(u8 taskId) } } -void Mailbox_UpdateMailListAfterDeposit(void); - void Mailbox_ReturnToMailListAfterDeposit(void) { gFieldCallback = Mailbox_UpdateMailListAfterDeposit; SetMainCallback2(CB2_ReturnToField); } -void Mailbox_UpdateMailListAfterDeposit(void) +static void Mailbox_UpdateMailListAfterDeposit(void) { u8 taskId; u8 prevCount; @@ -718,12 +776,12 @@ void Mailbox_UpdateMailListAfterDeposit(void) pal_fill_black(); } -void Mailbox_NoPokemonForMail(u8 taskId) +static void Mailbox_NoPokemonForMail(u8 taskId) { DisplayItemMessageOnField(taskId, gText_NoPokemon, Mailbox_Cancel); } -void Mailbox_Cancel(u8 taskId) +static void Mailbox_Cancel(u8 taskId) { sub_81D1D04(2); sub_8197434(0, 0); @@ -732,7 +790,7 @@ void Mailbox_Cancel(u8 taskId) gTasks[taskId].func = Mailbox_ProcessInput; } -void sub_816BC14(void) +static void sub_816BC14(void) { gUnknown_0203BCC4 = AllocZeroed(sizeof(struct Struct203BCC4)); memset(gUnknown_0203BCC4->windowIds, 0xFF, 0x6); @@ -740,9 +798,7 @@ void sub_816BC14(void) gUnknown_0203BCC4->spriteId = 0xFF; } -void sub_816BCC4(u8); - -void sub_816BC58(void) +static void sub_816BC58(void) { u32 i; @@ -751,9 +807,7 @@ void sub_816BC58(void) Free(gUnknown_0203BCC4); } -extern const struct WindowTemplate gUnknown_085DFF5C[6]; - -u8 sub_816BC7C(u8 a) +static u8 sub_816BC7C(u8 a) { u8 *windowIdLoc = &(gUnknown_0203BCC4->windowIds[a]); if(*windowIdLoc == 0xFF) @@ -765,7 +819,7 @@ u8 sub_816BC7C(u8 a) return *windowIdLoc; } -void sub_816BCC4(u8 a) +static void sub_816BCC4(u8 a) { u8 *windowIdLoc = &(gUnknown_0203BCC4->windowIds[a]); if(*windowIdLoc != 0xFF) @@ -778,17 +832,13 @@ void sub_816BCC4(u8 a) } } -void sub_816BDC8(u8 *string, u16 itemId); - -extern struct ListMenuTemplate gUnknown_085DFF44; - -void sub_816BD04(void) +void ItemStorage_RefreshListMenu(void) { u16 i; for(i = 0; i < playerPCItemPageInfo.count - 1; i++) { - sub_816BDC8(&(gUnknown_0203BCC4->unk198[i][0]), gSaveBlock1Ptr->pcItems[i].itemId); + CopyItemName_PlayerPC(&(gUnknown_0203BCC4->unk198[i][0]), gSaveBlock1Ptr->pcItems[i].itemId); gUnknown_0203BCC4->unk0[i].name = &(gUnknown_0203BCC4->unk198[i][0]); gUnknown_0203BCC4->unk0[i].id = i; } @@ -802,16 +852,12 @@ void sub_816BD04(void) gMultiuseListMenuTemplate.maxShowed = playerPCItemPageInfo.pageItems; } -void sub_816BDC8(u8 *string, u16 itemId) +void CopyItemName_PlayerPC(u8 *string, u16 itemId) { CopyItemName(itemId, string); } -void sub_816C0C8(void); -void sub_816C060(u16 itemId); -void sub_816BEF0(s32 id); - -void sub_816BDDC(s32 id, bool8 b) +static void ItemStorage_DrawBothListAndDescription(u32 id, bool8 b, struct ListMenu *thisMenu) { if(b != TRUE) PlaySE(SE_SELECT); @@ -826,9 +872,7 @@ void sub_816BDDC(s32 id, bool8 b) } } -void sub_816BFE0(u8 y, u8, u8 speed); - -void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset) +static void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset) { if(id != -2) { @@ -845,9 +889,7 @@ void fish4_goto_x5_or_x6(u8 windowId, s32 id, u8 yOffset) } } -const u8* sub_816C228(u16); - -void sub_816BEF0(s32 id) +static void sub_816BEF0(s32 id) { const u8* description; u8 windowId = gUnknown_0203BCC4->windowIds[1]; @@ -855,18 +897,18 @@ void sub_816BEF0(s32 id) if(id != -2) description = (u8 *)ItemId_GetDescription(gSaveBlock1Ptr->pcItems[id].itemId); else - description = sub_816C228(0xFFFF); + description = ItemStorage_GetItemPcResponse(ITEMPC_GO_BACK_TO_PREV); FillWindowPixelBuffer(windowId, 17); PrintTextOnWindow(windowId, 1, description, 0, 1, 0, NULL); } -void sub_816BF60(void) +static void ItemStorage_StartScrollIndicator(void) { if(playerPCItemPageInfo.scrollIndicatorId == 0xFF) playerPCItemPageInfo.scrollIndicatorId = AddScrollIndicatorArrowPairParametrized(0x2, 0xB0, 0xC, 0x94, playerPCItemPageInfo.count - playerPCItemPageInfo.pageItems, 0x13F8, 0x13F8, &(playerPCItemPageInfo.itemsAbove)); } -void sub_816BF9C(void) +static void ItemStorage_RemoveScrollIndicator(void) { if(playerPCItemPageInfo.scrollIndicatorId != 0xFF) { @@ -875,14 +917,12 @@ void sub_816BF9C(void) } } -void sub_816BFB8(u8 a, u8 b, u8 speed) +static void sub_816BFB8(u8 a, u8 b, u8 speed) { sub_816BFE0(ListMenuGetYCoordForPrintingArrowCursor(a), b, speed); } -extern const u8 gUnknown_085DFF8C[3]; - -void sub_816BFE0(u8 y, u8 b, u8 speed) +static void sub_816BFE0(u8 y, u8 b, u8 speed) { u8 windowId = gUnknown_0203BCC4->windowIds[0]; if(b == 0xFF) @@ -891,8 +931,7 @@ void sub_816BFE0(u8 y, u8 b, u8 speed) AddTextPrinterParameterized2(windowId, 1, 0, y, 0, 0, gUnknown_085DFF8C, speed, gText_SelectorArrow2); } - -void sub_816C060(u16 itemId) +static void sub_816C060(u16 itemId) { u8 spriteId; u8* spriteIdLoc = &(gUnknown_0203BCC4->spriteId); @@ -912,7 +951,7 @@ void sub_816C060(u16 itemId) } } -void sub_816C0C8(void) +static void sub_816C0C8(void) { u8* spriteIdLoc = &(gUnknown_0203BCC4->spriteId); if(*spriteIdLoc != 0xFF) @@ -924,28 +963,18 @@ void sub_816C0C8(void) } } -void sub_80D6E84(void); -void sub_812220C(struct ItemSlot *, u8, u8 *, u8 *, u8); - -void sub_816C110(void) +static void sub_816C110(void) { sub_80D6E84(); sub_812220C(gSaveBlock1Ptr->pcItems, 50, &(playerPCItemPageInfo.pageItems), &(playerPCItemPageInfo.count), 0x8); } -void sub_812225C(u16 *, u16 *, u8, u8); - -void sub_816C140(void) +static void sub_816C140(void) { sub_812225C(&(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos), playerPCItemPageInfo.pageItems, playerPCItemPageInfo.count); } -extern const u8 gText_TossItem[]; -extern const u8 gText_WithdrawItem[]; - -void sub_816C30C(u8 taskId); - -void ItemStorage_ProcessInput(u8 taskId) +static void ItemStorage_ProcessWithdrawTossInput(u8 taskId) { s16 *data; bool32 toss; @@ -965,24 +994,14 @@ void ItemStorage_ProcessInput(u8 taskId) CopyWindowToVram(gUnknown_0203BCC4->windowIds[2], 2); sub_816C110(); sub_816C140(); - sub_816BD04(); + ItemStorage_RefreshListMenu(); data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos); - sub_816BF60(); + ItemStorage_StartScrollIndicator(); schedule_bg_copy_tilemap_to_vram(0); - gTasks[taskId].func = sub_816C30C; + gTasks[taskId].func = ItemStorage_ProcessInput; } -extern const u8 gText_GoBackPrevMenu[]; -extern const u8 gText_WithdrawHowManyItems[]; -extern const u8 gText_WithdrawXItems[]; -extern const u8 gText_TossHowManyVar1s[]; -extern const u8 gText_ThrewAwayVar2Var1s[]; -extern const u8 gText_NoRoomInBag[]; -extern const u8 gText_TooImportantToToss[]; -extern const u8 gText_ConfirmTossItems[]; -extern const u8 gText_MoveVar1Where[]; - -const u8* sub_816C228(u16 itemId) +static const u8* ItemStorage_GetItemPcResponse(u16 itemId) { const u8 *string; @@ -1022,7 +1041,7 @@ const u8* sub_816C228(u16 itemId) return string; } -void sub_816C2C0(const u8 *string) +static void ItemStorage_PrintItemPcResponse(const u8 *string) { u8 windowId = gUnknown_0203BCC4->windowIds[1]; FillWindowPixelBuffer(windowId, 0x11); @@ -1030,11 +1049,7 @@ void sub_816C2C0(const u8 *string) PrintTextOnWindow(windowId, 1, gStringVar4, 0, 1, 0, NULL); } -void sub_816C400(u8 taskId); -void sub_816C450(u8 taskId); -void sub_816C71C(u8 taskId); - -void sub_816C30C(u8 taskId) +static void ItemStorage_ProcessInput(u8 taskId) { s16 *data; s32 id; @@ -1046,7 +1061,7 @@ void sub_816C30C(u8 taskId) if((playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos) != (playerPCItemPageInfo.count - 1)) { PlaySE(SE_SELECT); - sub_816C450(taskId); + ItemStorage_ItemSwapChoosePrompt(taskId); } } else @@ -1059,17 +1074,17 @@ void sub_816C30C(u8 taskId) break; case -2: PlaySE(SE_SELECT); - sub_816C400(taskId); + ItemStorage_GoBackToPlayerPCMenu(taskId); break; default: PlaySE(SE_SELECT); - sub_816C71C(taskId); + ItemStorage_DoItemAction(taskId); break; } } } -void bx_battle_menu_t3(u8 taskId) +static void ItemStorage_GoBackToPlayerPCMenu_InitStorage(u8 taskId) { s16 *data; @@ -1078,31 +1093,27 @@ void bx_battle_menu_t3(u8 taskId) { NewMenuHelpers_DrawDialogueFrame(0, 0); if(!data[3]) - InitItemStorageMenu(taskId, 0); + InitItemStorageMenu(taskId, ITEMPC_MENU_WITHDRAW); else - InitItemStorageMenu(taskId, 2); + InitItemStorageMenu(taskId, ITEMPC_MENU_TOSS); gTasks[taskId].func = ItemStorageMenuProcessInput; } } - -void sub_816C400(u8 taskId) +static void ItemStorage_GoBackToPlayerPCMenu(u8 taskId) { s16 *data; data = gTasks[taskId].data; sub_816C0C8(); - sub_816BF9C(); + ItemStorage_RemoveScrollIndicator(); sub_81AE6C8(data[5], NULL, NULL); sub_81223B0(gUnknown_0203BCC4->spriteIds, 7); sub_816BC58(); - gTasks[taskId].func = bx_battle_menu_t3; + gTasks[taskId].func = ItemStorage_GoBackToPlayerPCMenu_InitStorage; } -void sub_816C690(u8); -void sub_816C4FC(u8 taskId); - -void sub_816C450(u8 taskId) +static void ItemStorage_ItemSwapChoosePrompt(u8 taskId) { s16 *data; @@ -1112,13 +1123,11 @@ void sub_816C450(u8 taskId) sub_816BFB8(data[5], 0, 0); sub_816C690(gUnknown_0203BCC4->unk666); CopyItemName(gSaveBlock1Ptr->pcItems[gUnknown_0203BCC4->unk666].itemId, gStringVar1); - sub_816C2C0(sub_816C228(ITEMPC_SWITCH_WHICH_ITEM)); + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_SWITCH_WHICH_ITEM)); gTasks[taskId].func = sub_816C4FC; } -void sub_816C5A0(u8 taskId, bool8 a); - -void sub_816C4FC(u8 taskId) +static void sub_816C4FC(u8 taskId) { s16 *data; s32 id; @@ -1127,7 +1136,7 @@ void sub_816C4FC(u8 taskId) if(gMain.newKeys & SELECT_BUTTON) { sub_81AE860(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); - sub_816C5A0(taskId, FALSE); + ItemStorage_DoItemSwap(taskId, FALSE); return; } id = ListMenuHandleInputGetItemId(data[5]); @@ -1141,22 +1150,20 @@ void sub_816C4FC(u8 taskId) case -2: if(gMain.newKeys & A_BUTTON) { - sub_816C5A0(taskId, FALSE); + ItemStorage_DoItemSwap(taskId, FALSE); } else - sub_816C5A0(taskId, TRUE); + ItemStorage_DoItemSwap(taskId, TRUE); break; default: - sub_816C5A0(taskId, FALSE); + ItemStorage_DoItemSwap(taskId, FALSE); break; } } - -void sub_816C5A0(u8 taskId, bool8 a) +static void ItemStorage_DoItemSwap(u8 taskId, bool8 a) { s16 *data; - s32 id; u16 b; u8 c; @@ -1172,9 +1179,8 @@ void sub_816C5A0(u8 taskId, bool8 a) if(c != b - 1) { sub_80D702C(gSaveBlock1Ptr->pcItems, c, b); - sub_816BD04(); + ItemStorage_RefreshListMenu(); } - } else goto LABEL_SKIP_CURSOR_DECREMENT; @@ -1186,62 +1192,55 @@ void sub_816C5A0(u8 taskId, bool8 a) gUnknown_0203BCC4->unk666 = 0xFF; data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos); schedule_bg_copy_tilemap_to_vram(0); - gTasks[taskId].func = sub_816C30C; + gTasks[taskId].func = ItemStorage_ProcessInput; } -//void -void sub_816C690(u8 a) +static void sub_816C690(u8 a) { sub_8122448(gUnknown_0203BCC4->spriteIds, 7, 128, ((a+1) * 16)); } -void sub_816C6BC(u8 windowId, u16 value, u32 mode, u8 x, u8 y, u8 n) +static void sub_816C6BC(u8 windowId, u16 value, u32 mode, u8 x, u8 y, u8 n) { ConvertIntToDecimalStringN(gStringVar1, value, mode, n); StringExpandPlaceholders(gStringVar4, gText_xVar1); PrintTextOnWindow(windowId, 1, gStringVar4, GetStringCenterAlignXOffset(1, gStringVar4, 48), y, 0, NULL); } -void sub_816C8FC(u8 taskId); -void sub_816C9B8(u8 taskid); -void sub_816C818(u8 taskid); - -void sub_816C71C(u8 taskId) +static void ItemStorage_DoItemAction(u8 taskId) { s16 *data; u16 b; data = gTasks[taskId].data; b = (playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove); - sub_816BF9C(); + ItemStorage_RemoveScrollIndicator(); data[2] = 1; if(!data[3]) { if(gSaveBlock1Ptr->pcItems[b].quantity == 1) { - sub_816C8FC(taskId); + ItemStorage_DoItemWithdraw(taskId); return; } CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1); - sub_816C2C0(sub_816C228(ITEMPC_HOW_MANY_TO_WITHDRAW)); + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_HOW_MANY_TO_WITHDRAW)); } else { if(gSaveBlock1Ptr->pcItems[b].quantity == 1) { - sub_816C9B8(taskId); + ItemStorage_DoItemToss(taskId); return; } CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1); - sub_816C2C0(sub_816C228(ITEMPC_HOW_MANY_TO_TOSS)); + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_HOW_MANY_TO_TOSS)); } sub_816C6BC(sub_816BC7C(4), data[2], STR_CONV_MODE_LEADING_ZEROS, 8, 1, 3); - gTasks[taskId].func = sub_816C818; + gTasks[taskId].func = ItemStorage_HandleQuantityRolling; } -void sub_816CBC0(u8 taskId); - -void sub_816C818(u8 taskId) +static void ItemStorage_HandleQuantityRolling(u8 taskId) { s16 *data; u16 b; @@ -1257,24 +1256,21 @@ void sub_816C818(u8 taskId) PlaySE(SE_SELECT); sub_816BCC4(4); if(!data[3]) - sub_816C8FC(taskId); + ItemStorage_DoItemWithdraw(taskId); else - sub_816C9B8(taskId); + ItemStorage_DoItemToss(taskId); } else if(gMain.newKeys & B_BUTTON) { PlaySE(SE_SELECT); sub_816BCC4(4); - sub_816C2C0(sub_816C228(gSaveBlock1Ptr->pcItems[b].itemId)); - sub_816CBC0(taskId); + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(gSaveBlock1Ptr->pcItems[b].itemId)); + ItemStorage_StartScrollIndicatorAndProcessInput(taskId); } } } -void sub_816CB04(u8 taskId); -void sub_816CB74(u8 taskId); - -void sub_816C8FC(u8 taskId) +static void ItemStorage_DoItemWithdraw(u8 taskId) { s16 *data; u16 b; @@ -1285,23 +1281,18 @@ void sub_816C8FC(u8 taskId) { CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, data[2], STR_CONV_MODE_LEFT_ALIGN, 3); - sub_816C2C0(sub_816C228(ITEMPC_WITHDREW_THING)); - gTasks[taskId].func = sub_816CB04; + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_WITHDREW_THING)); + gTasks[taskId].func = ItemStorage_HandleRemoveItem; } else { data[2] = 0; - sub_816C2C0(sub_816C228(ITEMPC_NO_MORE_ROOM)); - gTasks[taskId].func = sub_816CB74; + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_NO_MORE_ROOM)); + gTasks[taskId].func = ItemStorage_WaitPressHandleResumeProcessInput; } } -extern const struct WindowTemplate gUnknown_085DFF84; -extern const struct YesNoFuncTable gUnknown_085DFF3C; - -bool8 itemid_is_unique(u16 itemId); - -void sub_816C9B8(u8 taskId) +static void ItemStorage_DoItemToss(u8 taskId) { s16 *data; u16 b; @@ -1312,32 +1303,30 @@ void sub_816C9B8(u8 taskId) { CopyItemName(gSaveBlock1Ptr->pcItems[b].itemId, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, data[2], STR_CONV_MODE_LEFT_ALIGN, 3); - sub_816C2C0(sub_816C228(ITEMPC_OKAY_TO_THROW_AWAY)); + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_OKAY_TO_THROW_AWAY)); CreateYesNoMenuWithCallbacks(taskId, &gUnknown_085DFF84, 1, 0, 1, 0x214, 0xE, &gUnknown_085DFF3C); } else { data[2] = 0; - sub_816C2C0(sub_816C228(ITEMPC_TOO_IMPORTANT)); - gTasks[taskId].func = sub_816CB74; + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_TOO_IMPORTANT)); + gTasks[taskId].func = ItemStorage_WaitPressHandleResumeProcessInput; } } -void sub_816CA94(u8 taskId) +static void ItemStorage_ResumeInputFromYesToss(u8 taskId) { - sub_816C2C0(sub_816C228(ITEMPC_THREW_AWAY_ITEM)); - gTasks[taskId].func = sub_816CB04; + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(ITEMPC_THREW_AWAY_ITEM)); + gTasks[taskId].func = ItemStorage_HandleRemoveItem; } -void sub_816CAC8(u8 taskId) +static void ItemStorage_ResumeInputFromNoToss(u8 taskId) { - sub_816C2C0(sub_816C228(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId)); - sub_816CBC0(taskId); + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId)); + ItemStorage_StartScrollIndicatorAndProcessInput(taskId); } -void sub_80D6E48(u8, u16); - -void sub_816CB04(u8 taskId) +static void ItemStorage_HandleRemoveItem(u8 taskId) { s16 *data; @@ -1348,26 +1337,26 @@ void sub_816CB04(u8 taskId) sub_81AE6C8(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); sub_816C110(); sub_816C140(); - sub_816BD04(); + ItemStorage_RefreshListMenu(); data[5] = ListMenuInit(&gMultiuseListMenuTemplate, playerPCItemPageInfo.itemsAbove, playerPCItemPageInfo.cursorPos); - sub_816CBC0(taskId); + ItemStorage_StartScrollIndicatorAndProcessInput(taskId); } } -void sub_816CB74(u8 taskId) +static void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId) { s16 *data; data = gTasks[taskId].data; if(gMain.newKeys & (A_BUTTON | B_BUTTON)) { - sub_816C2C0(sub_816C228(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId)); - sub_816CBC0(taskId); + ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId)); + ItemStorage_StartScrollIndicatorAndProcessInput(taskId); } } -void sub_816CBC0(u8 taskId) +static void ItemStorage_StartScrollIndicatorAndProcessInput(u8 taskId) { - sub_816BF60(); - gTasks[taskId].func = sub_816C30C; + ItemStorage_StartScrollIndicator(); + gTasks[taskId].func = ItemStorage_ProcessInput; } diff --git a/sym_ewram.txt b/sym_ewram.txt index da32fe5a0..c909a0374 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -806,19 +806,6 @@ gUnknown_0203BC8C: @ 203BC8C .include "src/use_pokeblock.o" .include "src/player_pc.o" - -gUnknown_0203BCB8: @ 203BCB8 - .space 0x2 - -gUnknown_0203BCBA: @ 203BCBA - .space 0x2 - -gUnknown_0203BCBC: @ 203BCBC - .space 0x8 - -gUnknown_0203BCC4: @ 203BCC4 - .space 0x4 - .include "src/intro.o" .include "src/field_region_map.o" From 8ba626b3c4b7eabbee56e39f2af65c49adafcd18 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Mon, 19 Mar 2018 17:16:44 +0530 Subject: [PATCH 6/6] Update RAM map for fossil_specials and fldeff_groundshake --- sym_ewram.txt | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/sym_ewram.txt b/sym_ewram.txt index c909a0374..f96ce30e7 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -936,23 +936,8 @@ gUnknown_0203CEFC: @ 203CEFC gUnknown_0203CF00: @ 203CF00 .space 0x4 -gUnknown_0203CF04: @ 203CF04 - .space 0x4 - -gUnknown_0203CF08: @ 203CF08 - .space 0x4 - -gUnknown_0203CF0C: @ 203CF0C - .space 0x4 - -gUnknown_0203CF10: @ 203CF10 - .space 0x4 - -gUnknown_0203CF14: @ 203CF14 - .space 0x4 - -gUnknown_0203CF18: @ 203CF18 - .space 0x4 + .include "src/fossil_specials.o" + .include "src/fldeff_groundshake.o" gUnknown_0203CF1C: @ 203CF1C .space 0x4