diff --git a/asm/field_map_obj.s b/asm/field_map_obj.s index 4d2cd9f9c..8179cb0ec 100644 --- a/asm/field_map_obj.s +++ b/asm/field_map_obj.s @@ -5,46 +5,6 @@ .text - thumb_func_start GetFieldObjectGraphicsInfo -@ FieldObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8 graphicsId) -GetFieldObjectGraphicsInfo: @ 808E694 - push {lr} - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0xEF - bls _0808E6AC - adds r0, r1, 0 - adds r0, 0x10 - lsls r0, 24 - lsrs r0, 24 - bl VarGetFieldObjectGraphicsId - adds r1, r0, 0 -_0808E6AC: - cmp r1, 0x45 - bne _0808E6C4 - bl sub_81201C8 - lsls r0, 24 - ldr r1, =gMauvilleOldManGraphicsInfoPointers - lsrs r0, 22 - adds r0, r1 - ldr r0, [r0] - b _0808E6D2 - .pool -_0808E6C4: - cmp r1, 0xEE - bls _0808E6CA - movs r1, 0x5 -_0808E6CA: - ldr r0, =gFieldObjectGraphicsInfoPointers - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] -_0808E6D2: - pop {r1} - bx r1 - .pool - thumb_func_end GetFieldObjectGraphicsInfo - thumb_func_start FieldObjectHandleDynamicGraphicsId @ void FieldObjectHandleDynamicGraphicsId(struct npc_state *fieldObject) FieldObjectHandleDynamicGraphicsId: @ 808E6DC diff --git a/include/field_map_obj.h b/include/field_map_obj.h index 97c55f12a..5eaee20d9 100644 --- a/include/field_map_obj.h +++ b/include/field_map_obj.h @@ -1,12 +1,13 @@ #ifndef POKEEMERALD_FIELD_MAP_OBJ_H #define POKEEMERALD_FIELD_MAP_OBJ_H +#define NUM_OBJECT_GRAPHICS_INFO 239 +#define SPRITE_VAR 240 + // Exported struct declarations // Exported RAM declarations - - // Exported ROM declarations void sub_808D438(void); diff --git a/include/mauville_old_man.h b/include/mauville_old_man.h new file mode 100644 index 000000000..5ed7b203b --- /dev/null +++ b/include/mauville_old_man.h @@ -0,0 +1,10 @@ +// +// Created by Scott Norton on 9/8/17. +// + +#ifndef POKEEMERALD_MAUVILLE_OLD_MAN_H +#define POKEEMERALD_MAUVILLE_OLD_MAN_H + +u8 sub_81201C8(void); + +#endif //POKEEMERALD_MAUVILLE_OLD_MAN_H diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 37ab01762..775a7b4e4 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -11,6 +11,7 @@ #include "rom_81BE66C.h" #include "field_ground_effect.h" #include "map_obj_8097404.h" +#include "mauville_old_man.h" #include "field_effect_helpers.h" #include "field_map_obj.h" @@ -45,6 +46,8 @@ static void SetPlayerAvatarFieldObjectIdAndObjectId(u8, u8); void (*const gUnknown_08505438[NUM_FIELD_MAP_OBJECT_TEMPLATES])(struct Sprite *); const u8 gUnknown_0850557C[NUM_FIELD_MAP_OBJECT_TEMPLATES]; const u8 gUnknown_085055CD[NUM_FIELD_MAP_OBJECT_TEMPLATES]; +const struct MapObjectGraphicsInfo *const gMauvilleOldManGraphicsInfoPointers[7]; +const struct MapObjectGraphicsInfo *const gFieldObjectGraphicsInfoPointers[0xEF]; // Code @@ -980,7 +983,7 @@ void PlayerObjectTurn(struct PlayerAvatar *playerAvatar, u8 direction) FieldObjectTurn(&gMapObjects[playerAvatar->mapObjectId], direction); } -void get_berry_tree_graphics(struct MapObject *mapObject, struct Sprite *sprite) +/*static*/ void get_berry_tree_graphics(struct MapObject *mapObject, struct Sprite *sprite) { u8 berryStage; u8 berryId; @@ -1004,3 +1007,23 @@ void get_berry_tree_graphics(struct MapObject *mapObject, struct Sprite *sprite) StartSpriteAnim(sprite, berryStage); } } + +const struct MapObjectGraphicsInfo *GetFieldObjectGraphicsInfo(u8 graphicsId) +{ + u8 bard; + + if (graphicsId >= SPRITE_VAR) + { + graphicsId = VarGetFieldObjectGraphicsId(graphicsId - SPRITE_VAR); + } + if (graphicsId == 0x45) + { + bard = sub_81201C8(); + return gMauvilleOldManGraphicsInfoPointers[bard]; + } + if (graphicsId >= NUM_OBJECT_GRAPHICS_INFO) + { + graphicsId = 0x05; // LittleBoy1 + } + return gFieldObjectGraphicsInfoPointers[graphicsId]; +}