From 3a3a2b9c27a1e75882d9aec059607f48c5a80243 Mon Sep 17 00:00:00 2001 From: Seth Barberee Date: Sun, 29 May 2022 12:03:10 -0700 Subject: [PATCH] decomp sub_8048D50 --- asm/code_8048480.s | 52 ---------------------------------------------- include/item.h | 1 + src/code_8048DB8.c | 32 +++++++++++++++++++++++++++- 3 files changed, 32 insertions(+), 53 deletions(-) diff --git a/asm/code_8048480.s b/asm/code_8048480.s index 76f20e0a..d9ee2d60 100644 --- a/asm/code_8048480.s +++ b/asm/code_8048480.s @@ -723,56 +723,4 @@ _08048D40: bx r1 thumb_func_end sub_8048B9C - thumb_func_start sub_8048D50 -sub_8048D50: - push {r4,lr} - adds r4, r0, 0 - adds r2, r1, 0 - ldr r3, [r4, 0x70] - ldrb r1, [r2] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _08048D78 - ldr r0, _08048D70 - adds r1, r2, 0 - bl sub_8045BF8 - ldr r0, _08048D74 - b _08048D9A - .align 2, 0 -_08048D70: .4byte gUnknown_202DE58 -_08048D74: .4byte gUnknown_80FE3E8 -_08048D78: - adds r0, r3, 0 - adds r0, 0xEC - ldrb r0, [r0] - cmp r0, 0x1 - bne _08048DB0 - ldrb r0, [r2, 0x2] - bl IsEdibleItem - lsls r0, 24 - cmp r0, 0 - beq _08048DB0 - ldr r0, _08048DA8 - adds r1, r4, 0 - movs r2, 0 - bl SetMessageArgument - ldr r0, _08048DAC -_08048D9A: - ldr r1, [r0] - adds r0, r4, 0 - bl SendMessage - movs r0, 0 - b _08048DB2 - .align 2, 0 -_08048DA8: .4byte gAvailablePokemonNames -_08048DAC: .4byte gUnknown_80FDCA4 -_08048DB0: - movs r0, 0x1 -_08048DB2: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_8048D50 - .align 2, 0 diff --git a/include/item.h b/include/item.h index d9a9de60..2f45e7c3 100644 --- a/include/item.h +++ b/include/item.h @@ -118,6 +118,7 @@ bool8 AddHeldItemToInventory(struct HeldItem* slot); bool8 IsNotMoneyOrUsedTMItem(u8 id); s32 FindItemInInventory(u8 itemIndex); bool8 IsHMItem(u8 id); +bool8 IsEdibleItem(u8 id); void RestoreHeldItem(struct unkStruct_8094924*, struct HeldItem*); diff --git a/src/code_8048DB8.c b/src/code_8048DB8.c index 0a932ec7..7012ae64 100644 --- a/src/code_8048DB8.c +++ b/src/code_8048DB8.c @@ -1,7 +1,8 @@ #include "global.h" +#include "constants/status.h" #include "code_80521D0.h" #include "dungeon_random.h" - +#include "item.h" extern void sub_803E708(u32, u32); extern void sub_80421C0(struct DungeonEntity *r0, u16 r1); @@ -12,6 +13,9 @@ extern void sub_8076210(struct DungeonEntity *, u32, u32, u32); extern void sub_8077780(struct DungeonEntity *, u32, u32); extern void sub_8076E20(struct DungeonEntity *, u32, u32, u32, u32, u32); +extern u8 gAvailablePokemonNames[]; +extern u8 gUnknown_202DE58[]; + extern u8 *gPtrMusicBoxPlayedCrumbledMessage[]; extern u8 *gPtrWishStoneCrumbledMessage[]; extern u8 *gPtrIcePartCrumbledMessage[]; @@ -22,7 +26,33 @@ extern u32 gUnknown_8106A50; extern s16 gUnknown_80F4FAC; extern void sub_806F370(struct DungeonEntity *r0, struct DungeonEntity *r1, u32, u32, u8 *, u8, s32, u32, u32, u32); extern void sub_8051E7C(struct DungeonEntity *pokemon); +extern void sub_8045BF8(u8 *, struct ItemSlot *); +extern void SetMessageArgument(char[], struct DungeonEntity*, u32); +extern u8 *gUnknown_80FDCA4[]; +extern u8 *gUnknown_80FE3E8[]; + +bool8 sub_8048D50(struct DungeonEntity * param_1,struct ItemSlot *param_2) +{ + struct DungeonEntityData *iVar2; + + iVar2 = param_1->entityData; + + if ((param_2->itemFlags & ITEM_FLAG_STICKY) != 0) { + sub_8045BF8(gUnknown_202DE58,param_2); + SendMessage(param_1,*gUnknown_80FE3E8); + return FALSE; + } + else + { + if ((iVar2->muzzledStatus == MUZZLED_STATUS_MUZZLED) && (IsEdibleItem(param_2->itemIndex))) { + SetMessageArgument(gAvailablePokemonNames,param_1,0); + SendMessage(param_1,*gUnknown_80FDCA4); + return FALSE; + } + } + return TRUE; +} void sub_8048DB8(struct DungeonEntity *pokemon, struct DungeonEntity *r1, u8 r2) {