From f8e8adf82ec56e986ece7a5eb6de87977ce2f506 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 7 Sep 2017 20:04:59 -0400 Subject: [PATCH] SetPlayerAvatarFieldObjectIdAndObjectId --- asm/field_map_obj.s | 26 -------------------------- include/field_player_avatar.h | 2 ++ src/field_map_obj.c | 12 +++++++++++- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 299893a29..a560fb8f7 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,32 +5,6 @@ .text - thumb_func_start SetPlayerAvatarFieldObjectIdAndObjectId -@ void SetPlayerAvatarFieldObjectIdAndObjectId(u8 fieldObjectId, u8 objectId) -SetPlayerAvatarFieldObjectIdAndObjectId: @ 808E3C4 - push {r4,r5,lr} - lsls r0, 24 - lsrs r0, 24 - ldr r5, =gPlayerAvatar - strb r0, [r5, 0x5] - strb r1, [r5, 0x4] - ldr r1, =gMapObjects - lsls r4, r0, 3 - adds r4, r0 - lsls r4, 2 - adds r4, r1 - ldrb r0, [r4, 0x5] - bl GetPlayerAvatarGenderByGraphicsId - strb r0, [r5, 0x7] - ldrb r0, [r4, 0x5] - movs r1, 0x20 - bl SetPlayerAvatarExtraStateTransition - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end SetPlayerAvatarFieldObjectIdAndObjectId - thumb_func_start FieldObjectSetGraphicsId @ void FieldObjectSetGraphicsId(npc_state *npcState, u8 graphicsId) FieldObjectSetGraphicsId: @ 808E3F8 diff --git a/include/field_player_avatar.h b/include/field_player_avatar.h index 8438add26..5e2f0822c 100644 --- a/include/field_player_avatar.h +++ b/include/field_player_avatar.h @@ -6,5 +6,7 @@ #define POKEEMERALD_FIELD_PLAYER_AVATAR_H void ClearPlayerAvatarInfo(void); +void SetPlayerAvatarExtraStateTransition(u8, u8); +u8 GetPlayerAvatarGenderByGraphicsId(u8); #endif //POKEEMERALD_FIELD_PLAYER_AVATAR_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 469993068..53dd1a863 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -36,7 +36,7 @@ static void MakeObjectTemplateFromFieldObjectTemplate(struct MapObjectTemplate * /*static*/ void sub_808E894(u16); static void RemoveFieldObjectIfOutsideView(struct MapObject *); static void sub_808E1B8(u8, s16, s16); -/*static*/ void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); +static void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); /*static*/ void sub_808E38C(struct MapObject *); // ROM data @@ -205,6 +205,8 @@ static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u mapObject->mapobj_unk_20 = gUnknown_085055CD[template->movementType]; FieldObjectSetDirection(mapObject, mapObject->mapobj_unk_20); FieldObjectHandleDynamicGraphicsId(mapObject); + + // This block is the culprit if (gUnknown_0850557C[mapObject->animPattern]) { if (mapObject->mapobj_unk_19 == 0) @@ -892,3 +894,11 @@ static void sub_808E1B8(u8 mapObjectId, s16 x, s16 y) mapObject->mapobj_bit_21 = FALSE; FieldObjectClearAnim(mapObject); } + +static void SetPlayerAvatarFieldObjectIdAndObjectId(u8 mapObjectId, u8 spriteId) +{ + gPlayerAvatar.mapObjectId = mapObjectId; + gPlayerAvatar.spriteId = spriteId; + gPlayerAvatar.gender = GetPlayerAvatarGenderByGraphicsId(gMapObjects[mapObjectId].graphicsId); + SetPlayerAvatarExtraStateTransition(gMapObjects[mapObjectId].graphicsId, 0x20); +}