From 1f7fb45d0f84bc0a9b66b00b3918e1a16702bda2 Mon Sep 17 00:00:00 2001 From: KDSKardabox Date: Thu, 15 Mar 2018 16:07:24 +0530 Subject: [PATCH] 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 47e56d5f22..8870e342d1 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 e744c293c4..bbdd213278 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 fcd58757e8..9e8ae6ef4f 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 538556efda..f9fb7f6dab 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 b9a1f6bf33..941a1b601b 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: